ホテル管理システム
ogi
yesterday 1a1c8e71fcd14858f595029f089b2d4a00202b32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO;
using System.Windows.Forms;
using HotelPms.Share.Windows.Util;
using HotelPms.Share.Util;
using HotelPms.SourceFactory.Util;
using HotelPms.Share.Data;
using System.Diagnostics;
 
namespace HotelPms.SourceFactory
{
    public partial class BeanCreator : FormBase
    {
        private MsSqlNet msSqlNet;
 
        public BeanCreator()
        {
            InitializeComponent();
        }
 
        private void BeanCreator_Load(object sender, EventArgs e)
        {
            GeneralSub.InitDataGridView(dataGridView1, true);
            GeneralSub.InitDataGridView(dataGridView2, true);
            msSqlNet = EnvironmentSetting.Default.CreateDBAccess();
            dataGridView1.DataSource = msSqlNet.GetTableList();
            dataGridView2.ReadOnly = false;
            dataGridView1.ColumnHeadersDefaultCellStyle.SelectionBackColor = SystemColors.Control;
            dataGridView1.EnableHeadersVisualStyles = false;
            dataGridView2.ColumnHeadersDefaultCellStyle.SelectionBackColor = SystemColors.Control;
            dataGridView2.EnableHeadersVisualStyles = false;
 
 
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                System.Diagnostics.Debug.WriteLine(row.Cells[0].Value.ToString() + ",");
            }
        }
 
        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow == null) { return; }
            dataGridView2.DataSource = msSqlNet.GetFieldList(dataGridView1.CurrentRow.Cells[0].Value.ToString());
            foreach (DataGridViewRow row in dataGridView2.Rows) { row.Cells["colFieldSel"].Value = true; }
 
            txtTsBeanClassName.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString().Substring(2);
            txtTsBeanInterfaceName.Text = $"I{dataGridView1.CurrentRow.Cells[0].Value.ToString().Substring(2)}";
            txtTsAccessClassName.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString().Substring(2) + "Api";
 
            string baseName = dataGridView1.CurrentRow.Cells[0].Value.ToString().Substring(2);
            lblBlazorViewModel.Text = $"{baseName}.cs";
            chkBlazorViewModel.Checked = false;
 
            lblProtos.Text = $"{baseName.ToLower()}.proto";
            chkProtos.Checked = false;
 
            chkStartup.Checked = false;
 
            lblServices.Text = $"{baseName}Service.cs";
            chkServices.Checked = false;
 
            lblClientAccess.Text = $"{baseName}Access.cs";
            chkClientAccess.Checked = false;
            lblClientDirectAccess.Text = $"{baseName}Access.cs";
            chkClientDirectAccess.Checked = false;
            lblClientMaster.Text = $"{baseName}.cs";
            chkClientMaster.Checked = false;
            lblClientTable.Text = $"{baseName}Table.cs";
            chkClientTable.Checked = false;
            lblClientUse.Text = $"{baseName}.cs";
            chkClientUse.Checked = false;
        }
 
        public object GetField(string name)
        {
            if (name.ToLower() == "".ToLower()) { return name; }
            else if (name.ToLower() == "".ToLower()) { return name; }
            else { return string.Empty; }
        }
 
        public Dictionary<string, int> GetPrimaryKey()
        {
            Dictionary<string, int> dict = new Dictionary<string, int>();
            dict.Add("", 0);
            dict.Add("ddd", 1);
            return dict;
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
 
        }
 
        private string ToProto3Type(string type)
        {
            if (type.ToLower() == "int") { return "int32"; }
            else if (type.ToLower() == "bytestring") { return "bytes"; }
            else if (type.ToLower() == "long") { return "int64"; }
            else if (type.ToLower() == "datetime") { return "google.protobuf.Timestamp"; }            
            else { return type.ToLower(); }
        }
 
 
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
 
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
//            /// ****************************** Description *******************************
//            /// žƒVƒXƒeƒ€–¼Ì
//            /// @PMS FrameWork 1.0
//            /// žŠT—v
//            /// @SPA”Å
//            /// ž—š—ð
//            /// @ƒ}ƒXƒ^ƒf[ƒ^‚ÌŠî‘b
//            /// ****************************** Declarations ******************************
//            export default interface IMasterListRowBase
//        {
//            ID: number;
//    Name: string;
//}
 
 
        //‚±‚ñ‚ÈŠ´‚¶
        //            import MasterBase from './MasterBase';
 
        //            export default class Login extends MasterBase
        //        {
        //  public GroupID: number = 0;
        //  public Kana: string = '';
        //  public Password: string = '';
        //  public PWCreateDate: Date = new Date();
        //        public LanguageType: number = 0;
        //}
 
 
        DirectoryInfo dir = Directory.CreateDirectory(Application.StartupPath + Path.DirectorySeparatorChar + @"Work");
 
            //ƒNƒ‰ƒX
            string[] items = new string[17];
            items[0] = txtTsBeanClassName.Text;
            items[1] = CConvert.ToDateString(DateTime.Now);
            items[2] = txtTsBeanClassName.Text;
            items[3] = string.Empty;
 
            //ƒCƒ“ƒ^[ƒtƒF[ƒX
            string[] accessItems = new string[11];
            accessItems[0] = txtTsBeanInterfaceName.Text;
            accessItems[1] = CConvert.ToDateString(DateTime.Now);
            accessItems[2] = txtTsBeanInterfaceName.Text;
            accessItems[3] = string.Empty;
 
            int index = 0;
            foreach (DataGridViewRow row in dataGridView2.Rows)
            {
                if (!CConvert.ToBool(row.Cells["colFieldSel"].Value)) { continue; }
 
                string type = TypeScriptFactory.ToTsType(row.Cells["Type"].Value.ToString());
                string name = row.Cells["Field"].Value.ToString();
                if(name.ToUpper() == "ID" || name.ToUpper() == "NAME") { continue; }
 
                if(index > 0)
                {
                    items[3] += Environment.NewLine;
                    accessItems[3] += Environment.NewLine;
                }
 
                items[3] += $"  public {name}: {type} = {TypeScriptFactory.GetDefValue(row.Cells["Type"].Value.ToString())};";
                accessItems[3] += $"  {name}: {type};";
                index++;
            }
 
            string fileInfo = EnvironmentSetting.TsBeanFileMode;
            for (int i = 0; i < items.Length; i++)
            {
                fileInfo = fileInfo.Replace("@" + i.ToString() + "@", items[i]);
            }
            if (!Directory.Exists(dir.FullName + Path.DirectorySeparatorChar + @"Ts\")) { Directory.CreateDirectory(dir.FullName + Path.DirectorySeparatorChar + @"Ts\"); }
            File.WriteAllText(dir.FullName + Path.DirectorySeparatorChar + @"Ts\" + txtTsBeanClassName.Text + ".ts", fileInfo, Encoding.UTF8);
 
            fileInfo = EnvironmentSetting.TsInterfaceFileMode;
            for (int i = 0; i < accessItems.Length; i++)
            {
                fileInfo = fileInfo.Replace("@" + i.ToString() + "@", accessItems[i]);
            }
            if (!Directory.Exists(dir.FullName + Path.DirectorySeparatorChar + @"Ts\")) { Directory.CreateDirectory(dir.FullName + Path.DirectorySeparatorChar + @"Ts\"); }
            File.WriteAllText(dir.FullName + Path.DirectorySeparatorChar + @"Ts\" + txtTsBeanInterfaceName.Text + ".ts", fileInfo, Encoding.UTF8);
 
            MessageBox.Show("OK");
 
        }
 
        private void BeanCreator_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (msSqlNet != null) { msSqlNet.Dispose(); }
        }
 
        private void btnCreate_Click(object sender, EventArgs e)
        {
            string tableName = dataGridView1.CurrentRow.Cells[0].Value.ToString();
            string baseName = tableName.Substring(2);
 
            string root = Path.Combine(Application.StartupPath, @"Work");
            if (!Directory.Exists(root)) { Directory.CreateDirectory(root); }
            string[] accessItems = new string[6];
            accessItems[0] = baseName;
            accessItems[1] = tableName;
            accessItems[2] = "";   //2.int id,int id....
            accessItems[3] = "";   //3.ID = {id}
            accessItems[4] = "HotelPms.DataAccessGrpc.Client";
            accessItems[5] = chkUseInfo.Checked ? "UseInfo" : "Master";
 
            string[] beanItems = new string[15];
            beanItems[0] = baseName;   //ƒNƒ‰ƒX
            beanItems[1] = "";   //1.ƒvƒ‰ƒCƒ}ƒŠ[ƒL[ˆê——
            beanItems[2] = "";   //2.CompareTo
            beanItems[3] = "";   //3.CopyTo
            beanItems[4] = "";   //4.Clear
            beanItems[5] = "";   //5.ConvertDataRowA
            beanItems[6] = "";   //6.ToDataRow
            beanItems[7] = "";   //7.AddSql
            beanItems[8] = "";   //8.UpdateSql
            beanItems[9] = "";   //9.ToText
            beanItems[10] = "";   //10.GetField
            beanItems[11] = "internal";
            beanItems[12] = chkUseInfo.Checked ? "HotelPms.Data.UseInfo" : "HotelPms.Data.Master";
            beanItems[13] = "";   //13.SetField
            beanItems[14] = "";   //14.ConvertReader
 
            string[] viewModelItems = new string[2];
            viewModelItems[0] = baseName;
            viewModelItems[1] = "";
 
 
            string[] tableItems = new string[2];
            tableItems[0] = "internal";
            tableItems[1] = baseName;
 
            string[] proto3Items = new string[5];
            proto3Items[0] = baseName;
            proto3Items[1] = "";
            proto3Items[2] = "";
            proto3Items[3] = chkUseInfo.Checked ? "UseInfo" : "Master";
            proto3Items[4] = "";
 
            string[] serviceItems = new string[3];
            serviceItems[0] = baseName;
            serviceItems[1] = tableName;
            serviceItems[2] = chkUseInfo.Checked ? "UseInfo" : "Master";
 
 
            string fieldList = string.Empty;
            string indexList = string.Empty;
            int addIndex = 0;
            string ret = string.Empty;
 
            string ret1 = string.Empty;
            string fieldList1 = string.Empty;
            int fieldCount = 0;
            string whereList = string.Empty;
            int whereCount = 0;
            int uptIndex = 0;
 
            int index = 0;
            int pkCount = 0;
            foreach (DataGridViewRow row in dataGridView2.Rows)
            {
                if (!CConvert.ToBool(row.Cells["colFieldSel"].Value)) { continue; }
 
                string sqlType = row.Cells["Type"].Value.ToString();
                string type = CommonFunc.ConvertToCsType(sqlType);
                string name = row.Cells["Field"].Value.ToString();
                string varName = $"p{name}";
                string caption = row.Cells["Caption"].Value.ToString();
                int maxLen = CConvert.ToInt(row.Cells["MaxLen"].Value);
 
                if (CConvert.ToInt(row.Cells["PKFlg"].Value.ToString()) == 1)
                {
                    beanItems[1] += $"               PrimaryKey.TryAdd(\"{name}\", 0); " + Environment.NewLine;
 
                    //ŒŸõƒL[
                    accessItems[2] += (accessItems[2].Length == 0 ? string.Empty : ",") + type + " " + varName;
                    accessItems[3] += (accessItems[3].Length == 0 ? string.Empty : " AND ") + name + " = " + CommonFunc.ToSqlValue(type, varName);
                    pkCount++;
                }
 
                beanItems[2] += (index == 0 ? "" : "                || ");
                beanItems[2] += $"{name}.CompareTo(item.{name}) != 0";
                beanItems[2] += Environment.NewLine;
 
                beanItems[3] += string.Format("            item.{0} = {0};" + Environment.NewLine, name);
                beanItems[4] += string.Format("            {0} = {1};" + Environment.NewLine, name, CommonFunc.GetDefValue(sqlType));
                beanItems[5] += CommonFunc.GetConvertDataRowCode(type, name);
                beanItems[14] += CommonFunc.GetConvertReaderCode(sqlType, name);
                beanItems[6] += $"            row[\"{name}\"] = {CommonFunc.ToDataRow(type, name)};" + Environment.NewLine;
                beanItems[9] += ("            text.AppendFormat(\"" + name + "={0};\", " + name + ");" + Environment.NewLine);
                beanItems[10] += (Environment.NewLine + $"            {(index == 0 ? string.Empty : "else ")}if (name == \"{name}\")" + " { return " + name + "; }");
                beanItems[13] += (Environment.NewLine + $"            {(index == 0 ? string.Empty : "else ")}if (name == \"{name}\")" + " { " + CommonFunc.GetConvertValue(type, name) + "return true; }");
 
                if (sqlType.ToLower() == "datetime" && proto3Items[2].Length == 0) { proto3Items[2] = "import \"google/protobuf/timestamp.proto\";"; }
                if ((sqlType.ToLower() == "decimal" || sqlType.ToLower() == "date") && proto3Items[4].Length == 0) { proto3Items[4] = "import \"customTypes.proto\";"; }
                proto3Items[1] += $"  {CommonFunc.ToProto3Type(type)} {name} = {index + 1};{Environment.NewLine}";
 
                viewModelItems[1] += (Environment.NewLine + "        Add(new ValidField() { Name = \"" + name + "\", Caption = \"" + caption + "\", MaxLenth = " + maxLen.ToString() + ", InputChar = " + CommonFunc.ToInputChar(sqlType) + " });");
 
                #region ’ljÁsql
 
                if (name.Equals("UpdateDate"))
                {
                    fieldList += ",UpdateDate";
                    indexList += ",GETDATE()";
                }
                else
                {
                    if (addIndex > 0) { fieldList += ","; indexList += ","; ret += ","; }
                    fieldList += name;
                    indexList += CommonFunc.ToSqlValue(type, name);
                    addIndex++;
                }
 
 
                #endregion
 
                #region XVsql
 
                if (name.Equals("UpdateDate"))
                {
                    fieldList1 += ",UpdateDate = GETDATE()";
                }
                else
                {
                    if (uptIndex > 0) { ret1 += ","; }
 
                    //u€–Ú={index}v‚ÌŽ®
                    string item = name + " = ";
                    item += CommonFunc.ToSqlValue(type, name);
 
                    if (CConvert.ToInt(row.Cells["PKFlg"].Value.ToString()) == 1)
                    {
                        if (whereCount > 0) { whereList += " AND "; }
                        whereList += item;
                        whereCount++;
                    }
                    else
                    {
                        if (fieldCount > 0) { fieldList1 += ","; }
                        fieldList1 += item;
                        fieldCount++;
                    }
                    uptIndex++;
                }
 
                #endregion
 
                index++;
            }
 
            beanItems[7] = "            " + "return $@\"" + $"INSERT INTO {tableName}({fieldList}) VALUES({indexList});" + "\";";
            beanItems[8] = "            " + "return $@\"" + $"UPDATE {tableName} SET {fieldList1} WHERE {whereList};" + "\";";
 
            #region Work“àˆêŽžƒtƒ@ƒCƒ‹ì¬
 
            //HotelPms.Client.Blazor>>ViewModel
            CreateCsFile(root + @"\HotelPms.Client.Blazor\ViewModel", EnvironmentSetting.ViewModel, viewModelItems, $"{baseName}.cs");
 
            //Protos
            CreateCsFile(root + @"\Protos", EnvironmentSetting.Proto3Master, proto3Items, $"{baseName.ToLower()}.proto");
 
            //HotelPms.GrpcService>>Service
            CreateCsFile(root + @"\HotelPms.GrpcService\Services", EnvironmentSetting.BeanFileMode_ProtoEx_Service, serviceItems, $"{baseName}Service.cs");
 
            //HotelPms.DataAccessGrpc.Client
            accessItems[4] = "HotelPms.DataAccessGrpc.Client";
            CreateCsFile(root + @"\HotelPms.DataAccessGrpc.Client", EnvironmentSetting.DataAccessFileMode, accessItems, $"{baseName}Access.cs");
 
            beanItems[11] = "public";
            tableItems[0] = "public";
            if (chkUseInfo.Checked)
            {
                //ProtosExpan>>UseInfo>>
                CreateCsFile(root + @"\ProtosExpan\UseInfo", EnvironmentSetting.BeanFileMode, beanItems, $"{baseName}.cs");
            }
            else
            {
                //ProtosExpan>>Master>>
                CreateCsFile(root + @"\ProtosExpan\Master", EnvironmentSetting.BeanFileMode, beanItems, $"{baseName}.cs");
                CreateCsFile(root + @"\ProtosExpan\Master", EnvironmentSetting.BeanFileMode_ProtoEx_Table, tableItems, $"{baseName}Table.cs");
            }
 
            #endregion
 
            if (!chkCopy.Checked)
            {
                CConvert.StartFile(root); 
                return;
            }
 
            #region Copy To Project
 
            string projDir = @"\HotelPms.Client.Blazor\";
            using (FileEdit.Core core = new FileEdit.Core())
            {
                FileEdit.Item item;
                FileEdit.EditData edit;
 
                //HotelPms.Client.Blazor>>ViewModel
                File.Copy(root + @"\HotelPms.Client.Blazor\ViewModel\" + $"{baseName}.cs", txtSlnDir.Text + projDir + @"ViewModel\" + $"{baseName}.cs", true);
                chkBlazorViewModel.Checked = true;
 
                File.Copy(root + @"\Protos\" + $"{baseName.ToLower()}.proto", txtSlnDir.Text + @"\Protos\" + $"{baseName.ToLower()}.proto", true);
                chkProtos.Checked = true;
 
                //HotelPms.GrpcService>>Service
                projDir = @"\HotelPms.GrpcService\";
                edit = new FileEdit.EditData { FilePath = txtSlnDir.Text + $@"{projDir}Program.cs", Encoding = Encoding.UTF8 };
                string line = $"app.MapGrpcService<{baseName}Service>().RequireCors(\"AllowAll\");";
                if (!edit.Exists(line))
                {
                    item = new FileEdit.Item { Key1 = "app.MapControllers()", Key2 = "app.MapGrpcService" };
                    item.Data.Add(line);
                    edit.Data.Add(item);
                }
                core.Execute(edit); 
                chkStartup.Checked = true;
 
 
                File.Copy(root + @"\HotelPms.GrpcService\Services\" + $"{baseName}Service.cs", txtSlnDir.Text + projDir + @"Services\" + $"{baseName}Service.cs", true);
                chkServices.Checked = true;
 
                //HotelPms.DataAccessGrpc.Client
                projDir = @"\HotelPms.DataAccessGrpc.Client\";
 
                File.Copy(root + @"\HotelPms.DataAccessGrpc.Client\" + $"{baseName}Access.cs", txtSlnDir.Text + projDir + $"{baseName}Access.cs", true);
                chkClientAccess.Checked = true;
 
                edit = new FileEdit.EditData { FilePath = txtSlnDir.Text + $@"\HotelPms.Data.Client\HotelPms.Data.Client.csproj", Encoding = Encoding.UTF8 };
                var edit2 = new FileEdit.EditData { FilePath = txtSlnDir.Text + $@"\HotelPms.Data.Server\HotelPms.Data.Server.csproj", Encoding = Encoding.UTF8 };
 
                if (chkUseInfo.Checked)
                {
                    //HotelPms.Data.Client>>UseInfo>>
                    File.Copy(root + @"\ProtosExpan\UseInfo\" + $"{baseName}.cs", txtSlnDir.Text + @"\ProtosExpan\UseInfo\" + $"{baseName}.cs", true);
                    chkClientUse.Checked = true;
 
                    //ƒNƒ‰ƒCƒAƒ“ƒg‘¤
                    line = $"    <Compile Include=\"..\\ProtosExpan\\UseInfo\\{baseName}.cs\" Link=\"ProtosExpan\\UseInfo\\{baseName}.cs\" />";
                    item = new FileEdit.Item { Key1 = "<ItemGroup>", Key2 = "<Compile Include=\"..\\ProtosExpan" };
                    item.Data.Add(line);
                    if (!edit.Exists(line)) { edit.Data.Add(item); }
 
                    //ƒT[ƒo[‘¤
                    if (!edit2.Exists(line)) { edit2.Data.Add(item); }
                }
                else
                {
                    //HotelPms.Data.Client>>Master>>
                    File.Copy(root + @"\ProtosExpan\Master\" + $"{baseName}.cs", txtSlnDir.Text + @"\ProtosExpan\Master\" + $"{baseName}.cs", true);
                    chkClientMaster.Checked = true;
 
                    //ƒNƒ‰ƒCƒAƒ“ƒg‘¤
                    line = $"    <Compile Include=\"..\\ProtosExpan\\Master\\{baseName}.cs\" Link=\"ProtosExpan\\Master\\{baseName}.cs\" />";
                    item = new FileEdit.Item { Key1 = "<ItemGroup>", Key2 = "<Compile Include=\"..\\ProtosExpan" };
                    item.Data.Add(line);
                    if (!edit.Exists(line)) { edit.Data.Add(item); }
 
                    //ƒT[ƒo[‘¤
                    if (!edit2.Exists(line)) { edit2.Data.Add(item); }
 
 
                    #region ?????Table.cs
 
                    File.Copy(root + @"\ProtosExpan\Master\" + $"{baseName}Table.cs", txtSlnDir.Text + @"\ProtosExpan\Master\" + $"{baseName}Table.cs", true);
                    chkClientTable.Checked = true;
 
                    //ƒNƒ‰ƒCƒAƒ“ƒg‘¤‚Ì‚Ý
                    line = $"    <Compile Include=\"..\\ProtosExpan\\Master\\{baseName}Table.cs\" Link=\"ProtosExpan\\Master\\{baseName}Table.cs\" />";
                    item = new FileEdit.Item { Key1 = "<ItemGroup>", Key2 = "<Compile Include=\"..\\ProtosExpan" };
                    item.Data.Add(line);
                    if(!edit.Exists(line)) { edit.Data.Add(item); }
 
                    #endregion
                }
 
                //‡@HotelPms.Data.Client.csproj
                line = $"   <Protobuf Include=\"..\\Protos\\{baseName.ToLower()}.proto\" GrpcServices=\"Client\" Link=\"Protos\\{baseName.ToLower()}.proto\" />";
                item = new FileEdit.Item { Key1 = "<ItemGroup>", Key2 = "<Protobuf" };
                item.Data.Add(line);
                if (!edit.Exists(line)) { edit.Data.Add(item); }
                core.Execute(edit);
                chkClient.Checked = true;
 
                //HotelPms.Data.Server
                line = $"   <Protobuf Include=\"..\\Protos\\{baseName.ToLower()}.proto\" GrpcServices=\"Server\" Link=\"Protos\\{baseName.ToLower()}.proto\" />";
                projDir = @"\HotelPms.Data.Server\";
                item = new FileEdit.Item { Key1 = "<ItemGroup>", Key2 = "<Protobuf" };
                item.Data.Add(line);
                if (!edit2.Exists(line)) { edit2.Data.Add(item); }
                core.Execute(edit2);
                chkServer.Checked = true;
            }
 
            #endregion
 
            MessageBox.Show("OK");
        }
 
        private void CreateCsFile(string root, string template, string[] items, string fileName)
        {
            if (!Directory.Exists(root)) { Directory.CreateDirectory(root); }
            string fileInfo = template;
            for (int i = 0; i < items.Length; i++)
            {
                fileInfo = fileInfo.Replace($"@{i}@", items[i]);
            }
            File.WriteAllText(root + Path.DirectorySeparatorChar + fileName, fileInfo, Encoding.UTF8);
        }
    }
}