public string GetIndex(bool en = false) { string rv = ""; if (en == false) { rv = GetResource("SetupIndex.txt"); } else { rv = GetResource("SetupIndex_en.txt"); } string dbname = ""; if (MainNs.Contains(".")) { dbname = MainNs.Split('.').Last() + "_db"; } else { dbname = MainNs + "_db"; } rv = rv.Replace("{vm.CookiePre}", CookiePre).Replace("{vm.Rpp}", Rpp?.ToString()).Replace("$dbname$", dbname); return(rv); }
public bool RemoveRpp(int id) { methodName = "RemoveRpp"; traceID = 1; using (var uow = new UnitOfWork(AppConfig.Current.ContextName)) { using (var trans = uow.BeginTransaction()) { try { traceID = 2; Rpp oDBRpp = uow.Rpp.SingleOrDefault(m => m.IdRpp == id); if (oDBRpp != null) { traceID = 3; uow.CashActivity.Remove(id); uow.Save(); } traceID = 5; trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw new AppException(500, methodName, traceID, ex); } } } return(true); }
public bool EditRpp(Rpp oData) { methodName = "EditRpp"; traceID = 1; using (var uow = new UnitOfWork(AppConfig.Current.ContextName)) { traceID = 2; var oDBData = uow.Rpp.Get(oData.IdRpp); if (oDBData != null) { using (var trans = uow.BeginTransaction()) { try { traceID = 3; oDBData.MapFrom(oData); uow.Rpp.Update(oDBData); uow.Save(); traceID = 4; trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw new AppException(500, methodName, traceID, ex); } } } } return(true); }
public int AddRpp(Rpp oData) { methodName = "AddRpp"; traceID = 1; using (var uow = new UnitOfWork(AppConfig.Current.ContextName)) { using (var trans = uow.BeginTransaction()) { try { traceID = 2; Rpp oNewRpp = new Rpp(); oNewRpp.MapFrom(oData); oNewRpp = uow.Rpp.Add(oNewRpp); uow.Save(); traceID = 3; oData.IdRpp = oNewRpp.IdRpp; trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw new AppException(500, methodName, traceID, ex); } } } return(oData.IdRpp); }
public bool Edittranscash(OrderTransaksiCash oData, Rpp oDatas) { methodName = "Edittranscash"; traceID = 1; using (var uow = new UnitOfWork(AppConfig.Current.ContextName)) { traceID = 2; var oDBData = uow.OrderTransaksiCash.Get(oData.IdOrderTransaksiCash); if (oDBData != null) { using (var trans = uow.BeginTransaction()) { try { traceID = 3; oDBData.MapFrom(oData); uow.OrderTransaksiCash.Update(oDBData); /* if (oDBData.IdOrderJurnalUmum > 0) * { * traceID = 4; * oData.IdOrderJurnalUmum = oDBData.IdOrderJurnalUmum; * BukuBesar oNewTransjurnal = new BukuBesar(); * oNewTransjurnal.MapFrom(oData); * * traceID = 5; * oNewTransjurnal.IdRekeningPerkiraan = oData.IdRekeningPerkiraan; * oNewTransjurnal.NoRekningPerkiraan = oData.NoRekeningPerkiraan; * oNewTransjurnal.KodeTransaksi = "GJ"; * oNewTransjurnal.IdKlasfikasi = oData.IdKlasifikasi; * oNewTransjurnal.KlasifikasiAkun = oData.KlasifikasiRekeningPerkiraan; * oNewTransjurnal.Deskripsi = oData.Keterangan; * oNewTransjurnal.KursTukar = oData.Kurs; * oNewTransjurnal.IdUserId = oData.IdUserId; * oNewTransjurnal.IdPeriodeAkuntansi = oData.IdPeriodeAkuntasi; * oNewTransjurnal.IdEmployee = oData.IdPetugas; * oNewTransjurnal.RealRecordingTime = DateTime.Now; * uow.BukuBesar.Add(oNewTransjurnal); * }*/ traceID = 6; uow.Save(); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw new AppException(500, methodName, traceID, ex); } } } } return(true); }
public void DoSetup() { string vmdir = MainDir; string datadir = MainDir; string modeldir = MainDir; string vmns = MainNs + ".ViewModels"; string datans = MainNs; string modelns = MainNs; if (ProjectType == ProjectTypeEnum.Single) { Directory.CreateDirectory($"{MainDir}\\Models"); File.WriteAllText($"{MainDir}\\Models\\ReadMe.txt", "Put your models here"); Directory.CreateDirectory($"{MainDir}\\ViewModels\\HomeVMs"); vmdir = MainDir + "\\ViewModels"; } else { Directory.CreateDirectory($"{MainDir}.ViewModel\\HomeVMs"); Directory.CreateDirectory($"{MainDir}.Model"); Directory.CreateDirectory($"{MainDir}.DataAccess"); vmdir = MainDir + ".ViewModel"; datadir = MainDir + ".DataAccess"; modeldir = MainDir + ".Model"; vmns = MainNs + ".ViewModel"; datans = MainNs + ".DataAccess"; modelns = MainNs + ".Model"; File.WriteAllText($"{modeldir}\\{modelns}.csproj", GetResource("Proj.txt"), Encoding.UTF8); File.WriteAllText($"{vmdir}\\{vmns}.csproj", GetResource("Proj.txt"), Encoding.UTF8); File.WriteAllText($"{datadir}\\{datans}.csproj", GetResource("Proj.txt"), Encoding.UTF8); } Directory.CreateDirectory($"{MainDir}\\Areas"); Directory.CreateDirectory($"{MainDir}\\Controllers"); if (UI == UIEnum.LayUI) { Directory.CreateDirectory($"{MainDir}\\Views\\Home"); Directory.CreateDirectory($"{MainDir}\\Views\\Login"); Directory.CreateDirectory($"{MainDir}\\Views\\Shared"); } Directory.CreateDirectory($"{MainDir}\\wwwroot"); var proj = File.ReadAllText($"{MainDir}\\{MainNs}.csproj"); if (UI == UIEnum.LayUI) { proj = proj.Replace("</Project>", $@" <ItemGroup> <PackageReference Include=""WalkingTec.Mvvm.TagHelpers.LayUI"" Version=""{version}"" /> <PackageReference Include=""WalkingTec.Mvvm.Mvc.Admin"" Version=""{version}"" /> </ItemGroup> </Project> "); proj = proj.Replace("</PropertyGroup>", $@" <CopyRefAssembliesToPublishDirectory>true</CopyRefAssembliesToPublishDirectory> </PropertyGroup> "); } if (UI == UIEnum.React) { proj = proj.Replace("</Project>", $@" <ItemGroup> <PackageReference Include=""WalkingTec.Mvvm.TagHelpers.LayUI"" Version=""{version}"" /> <PackageReference Include=""WalkingTec.Mvvm.Mvc.Admin"" Version=""{version}"" /> <PackageReference Include=""Swashbuckle.AspNetCore"" Version=""4.0.1"" /> </ItemGroup> <ItemGroup> <Content Remove=""$(SpaRoot)**"" /> <None Include=""$(SpaRoot)**"" Exclude=""$(SpaRoot)node_modules\**;$(SpaRoot).awcache\**;$(SpaRoot).cache-loader\**"" /> </ItemGroup> <Target Name=""DebugEnsureNodeEnv"" BeforeTargets=""Build"" Condition="" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ""> <Exec Command=""node --version"" ContinueOnError=""true""> <Output TaskParameter=""ExitCode"" PropertyName=""ErrorCode"" /> </Exec> <Error Condition=""'$(ErrorCode)' != '0'"" Text=""Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE."" /> <Message Importance=""high"" Text=""Restoring dependencies using 'npm'. This may take several minutes..."" /> <Exec WorkingDirectory=""$(SpaRoot)"" Command=""npm install"" /> </Target> <Target Name=""PublishRunWebpack"" AfterTargets=""ComputeFilesToPublish""> <Exec WorkingDirectory=""$(SpaRoot)"" Command=""npm install"" /> <Exec WorkingDirectory=""$(SpaRoot)"" Command=""npm run build"" /> <ItemGroup> <DistFiles Include=""$(SpaRoot)build\**"" /> <ResolvedFileToPublish Include=""@(DistFiles->'%(FullPath)')"" Exclude=""@(ResolvedFileToPublish)""> <RelativePath>%(DistFiles.Identity)</RelativePath> <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> </ResolvedFileToPublish> </ItemGroup> </Target> </Project> "); proj = proj.Replace("</PropertyGroup>", $@" <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> <TypeScriptToolsVersion>3.2</TypeScriptToolsVersion> <IsPackable>false</IsPackable> <SpaRoot>ClientApp\</SpaRoot> <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes> <CopyRefAssembliesToPublishDirectory>true</CopyRefAssembliesToPublishDirectory> </PropertyGroup> "); } if (ProjectType == ProjectTypeEnum.Multi) { proj = proj.Replace("</Project>", $@" <ItemGroup> <ProjectReference Include=""..\{modelns}\{modelns}.csproj"" /> <ProjectReference Include=""..\{datans}\{datans}.csproj"" /> <ProjectReference Include=""..\{vmns}\{vmns}.csproj"" /> </ItemGroup > </Project> "); } File.WriteAllText($"{MainDir}\\{MainNs}.csproj", proj, Encoding.UTF8); if (ProjectType == ProjectTypeEnum.Multi) { //修改modelproject var modelproj = File.ReadAllText($"{modeldir}\\{modelns}.csproj"); if (modelproj.IndexOf("WalkingTec.Mvvm.Core") < 0) { modelproj = modelproj.Replace("</Project>", $@" <ItemGroup> <PackageReference Include=""WalkingTec.Mvvm.Core"" Version=""{version}"" /> </ItemGroup > </Project> "); File.WriteAllText($"{modeldir}\\{modelns}.csproj", modelproj, Encoding.UTF8); } //修改dataproject var dataproj = File.ReadAllText($"{datadir}\\{datans}.csproj"); if (dataproj.IndexOf($"{modelns}.csproj") < 0) { dataproj = dataproj.Replace("</Project>", $@" <ItemGroup> <ProjectReference Include=""..\{modelns}\{modelns}.csproj"" /> </ItemGroup > </Project> "); File.WriteAllText($"{datadir}\\{datans}.csproj", dataproj, Encoding.UTF8); } //修改viewmodelproject var vmproj = File.ReadAllText($"{vmdir}\\{vmns}.csproj"); if (vmproj.IndexOf($"{modelns}.csproj") < 0) { vmproj = vmproj.Replace("</Project>", $@" <ItemGroup> <ProjectReference Include=""..\{modelns}\{modelns}.csproj"" /> </ItemGroup > </Project> "); File.WriteAllText($"{vmdir}\\{vmns}.csproj", vmproj, Encoding.UTF8); } var solution = File.ReadAllText($"{Directory.GetParent(MainDir)}\\{MainNs}.sln"); if (solution.IndexOf($"{modelns}.csproj") < 0) { Guid g1 = Guid.NewGuid(); Guid g2 = Guid.NewGuid(); Guid g3 = Guid.NewGuid(); solution = solution.Replace("EndProject", $@"EndProject Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{modelns}"", ""{modelns}\{modelns}.csproj"", ""{{{g1}}}"" EndProject Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{datans}"", ""{datans}\{datans}.csproj"", ""{{{g2}}}"" EndProject Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{vmns}"", ""{vmns}\{vmns}.csproj"", ""{{{g3}}}"" EndProject "); solution = solution.Replace(".Release|Any CPU.Build.0 = Release|Any CPU", $@".Release|Any CPU.Build.0 = Release|Any CPU {{{g1}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {{{g1}}}.Debug|Any CPU.Build.0 = Debug|Any CPU {{{g1}}}.Release|Any CPU.ActiveCfg = Release|Any CPU {{{g1}}}.Release|Any CPU.Build.0 = Release|Any CPU {{{g2}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {{{g2}}}.Debug|Any CPU.Build.0 = Debug|Any CPU {{{g2}}}.Release|Any CPU.ActiveCfg = Release|Any CPU {{{g2}}}.Release|Any CPU.Build.0 = Release|Any CPU {{{g3}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {{{g3}}}.Debug|Any CPU.Build.0 = Debug|Any CPU {{{g3}}}.Release|Any CPU.ActiveCfg = Release|Any CPU {{{g3}}}.Release|Any CPU.Build.0 = Release|Any CPU" ); File.WriteAllText($"{Directory.GetParent(MainDir)}\\{MainNs}.sln", solution, Encoding.UTF8); } } File.WriteAllText($"{MainDir}\\appsettings.json", GetResource("Appsettings.txt") .Replace("$cs$", CS ?? "") .Replace("$dbtype$", DbType.ToString()) .Replace("$pagemode$", PageMode.ToString()) .Replace("$cookiepre$", CookiePre ?? "") .Replace("$enablelog$", EnableLog.ToString().ToLower()) .Replace("$logexception$", LogExceptionOnly.ToString().ToLower()) .Replace("$rpp$", Rpp == null ? "" : Rpp.ToString()) .Replace("$filemode$", FileMode.ToString()) .Replace("$uploaddir$", UploadDir ?? ""), Encoding.UTF8 ); File.WriteAllText($"{datadir}\\DataContext.cs", GetResource("DataContext.txt").Replace("$ns$", datans), Encoding.UTF8); if (UI == UIEnum.LayUI) { File.WriteAllText($"{MainDir}\\Controllers\\HomeController.cs", GetResource("HomeController.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Controllers\\LoginController.cs", GetResource("LoginController.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\_ViewStart.cshtml", GetResource("ViewStart.txt", "Mvc"), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\Home\\Index.cshtml", GetResource("home.Index.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\Login\\ChangePassword.cshtml", GetResource("home.ChangePassword.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\Home\\Header.cshtml", GetResource("home.Header.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\Login\\Login.cshtml", GetResource("home.Login.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\Home\\Menu.cshtml", GetResource("home.Menu.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\Home\\PIndex.cshtml", GetResource("home.PIndex.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\Home\\FrontPage.cshtml", GetResource("home.FrontPage.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{vmdir}\\HomeVMs\\ChangePasswordVM.cs", GetResource("vms.ChangePasswordVM.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{vmdir}\\HomeVMs\\IndexVM.cs", GetResource("vms.IndexVM.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{vmdir}\\HomeVMs\\LoginVM.cs", GetResource("vms.LoginVM.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\Shared\\_Layout.cshtml", GetResource("layui.Layout.txt", "Mvc").Replace("$ns$", MainNs), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\Shared\\_PLayout.cshtml", GetResource("layui.PLayout.txt", "Mvc").Replace("$ns$", MainNs), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Program.cs", GetResource("layui.Program.txt", "Mvc").Replace("$ns$", MainNs), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\_ViewImports.cshtml", GetResource("layui.ViewImports.txt", "Mvc"), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Areas\\_ViewImports.cshtml", GetResource("layui.ViewImports.txt", "Mvc"), Encoding.UTF8); UnZip("WalkingTec.Mvvm.Mvc.SetupFiles.Mvc.layui.layui.zip", $"{MainDir}\\wwwroot"); } if (UI == UIEnum.React) { Directory.CreateDirectory($"{MainDir}\\ClientApp"); UnZip("WalkingTec.Mvvm.Mvc.SetupFiles.Mvc.layui.layui.zip", $"{MainDir}\\wwwroot"); UnZip("WalkingTec.Mvvm.Mvc.SetupFiles.Spa.React.ClientApp.zip", $"{MainDir}\\ClientApp"); File.WriteAllText($"{MainDir}\\Program.cs", GetResource("Program.txt", "Spa").Replace("$ns$", MainNs), Encoding.UTF8); var config = File.ReadAllText($"{MainDir}\\ClientApp\\src\\global.config.tsx"); File.WriteAllText($"{MainDir}\\ClientApp\\src\\global.config.tsx", config.Replace("title: \"WalkingTec MVVM\",", $"title: \"{MainNs}\","), Encoding.UTF8); } if (File.Exists($"{MainDir}\\Startup.cs")) { File.Delete($"{MainDir}\\Startup.cs"); } }
public void DoSetup() { string vmdir = MainDir; string datadir = MainDir; string modeldir = MainDir; string vmns = MainNs + ".ViewModels"; string datans = MainNs; string modelns = MainNs; if (ProjectType == ProjectTypeEnum.Single) { Directory.CreateDirectory($"{MainDir}\\Models"); Directory.CreateDirectory($"{MainDir}\\ViewModels\\HomeVMs"); vmdir = MainDir + "\\ViewModels"; } else { Directory.CreateDirectory($"{MainDir}.ViewModel\\HomeVMs"); Directory.CreateDirectory($"{MainDir}.Model"); Directory.CreateDirectory($"{MainDir}.DataAccess"); vmdir = MainDir + ".ViewModel"; datadir = MainDir + ".DataAccess"; modeldir = MainDir + ".Model"; vmns = MainNs + ".ViewModel"; datans = MainNs + ".DataAccess"; modelns = MainNs + ".Model"; File.WriteAllText($"{modeldir}\\{modelns}.csproj", GetResource("Proj.txt"), Encoding.UTF8); File.WriteAllText($"{vmdir}\\{vmns}.csproj", GetResource("Proj.txt"), Encoding.UTF8); File.WriteAllText($"{datadir}\\{datans}.csproj", GetResource("Proj.txt"), Encoding.UTF8); } Directory.CreateDirectory($"{MainDir}\\Areas"); Directory.CreateDirectory($"{MainDir}\\Controllers"); Directory.CreateDirectory($"{MainDir}\\Views\\Home"); Directory.CreateDirectory($"{MainDir}\\Views\\Login"); Directory.CreateDirectory($"{MainDir}\\Views\\Shared"); Directory.CreateDirectory($"{MainDir}\\wwwroot"); File.WriteAllText($"{MainDir}\\appsettings.json", GetResource("Appsettings.txt") .Replace("$cs$", CS ?? "") .Replace("$dbtype$", DbType.ToString()) .Replace("$cookiepre$", CookiePre ?? "") .Replace("$enablelog$", EnableLog.ToString().ToLower()) .Replace("$logexception$", LogExceptionOnly.ToString().ToLower()) .Replace("$rpp$", Rpp == null ? "" : Rpp.ToString()) .Replace("$filemode$", FileMode.ToString()) .Replace("$uploaddir$", UploadDir ?? ""), Encoding.UTF8 ); File.WriteAllText($"{datadir}\\DataContext.cs", GetResource("DataContext.txt").Replace("$ns$", datans), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Controllers\\HomeController.cs", GetResource("HomeController.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Controllers\\LoginController.cs", GetResource("LoginController.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\_ViewStart.cshtml", GetResource("ViewStart.txt"), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\Home\\Index.cshtml", GetResource("home.Index.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\Login\\ChangePassword.cshtml", GetResource("home.ChangePassword.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\Home\\Header.cshtml", GetResource("home.Header.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\Login\\Login.cshtml", GetResource("home.Login.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\Home\\Menu.cshtml", GetResource("home.Menu.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\Home\\PIndex.cshtml", GetResource("home.PIndex.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\Home\\FrontPage.cshtml", GetResource("home.FrontPage.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{vmdir}\\HomeVMs\\ChangePasswordVM.cs", GetResource("vms.ChangePasswordVM.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{vmdir}\\HomeVMs\\IndexVM.cs", GetResource("vms.IndexVM.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{vmdir}\\HomeVMs\\LoginVM.cs", GetResource("vms.LoginVM.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); if (UI == UIEnum.LayUI) { File.WriteAllText($"{MainDir}\\Views\\Shared\\_Layout.cshtml", GetResource("layui.Layout.txt").Replace("$ns$", MainNs), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\Shared\\_PLayout.cshtml", GetResource("layui.PLayout.txt").Replace("$ns$", MainNs), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Program.cs", GetResource("layui.Program.txt").Replace("$ns$", MainNs), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Views\\_ViewImports.cshtml", GetResource("layui.ViewImports.txt"), Encoding.UTF8); File.WriteAllText($"{MainDir}\\Areas\\_ViewImports.cshtml", GetResource("layui.ViewImports.txt"), Encoding.UTF8); Assembly assembly = Assembly.GetExecutingAssembly(); var sr = assembly.GetManifestResourceStream($"WalkingTec.Mvvm.Mvc.SetupFiles.layui.layui.zip"); System.IO.Compression.ZipArchive zip = new System.IO.Compression.ZipArchive(sr); foreach (var entry in zip.Entries) { if (entry.FullName.EndsWith("/")) { Directory.CreateDirectory($"{MainDir}\\wwwroot\\{entry.FullName}"); } else { var f = File.OpenWrite($"{MainDir}\\wwwroot\\{entry.FullName}"); var z = entry.Open(); z.CopyTo(f); f.Flush(); f.Dispose(); z.Dispose(); } } sr.Dispose(); } if (ProjectType == ProjectTypeEnum.Single) { var proj = File.ReadAllText($"{MainDir}\\{MainNs}.csproj"); if (proj.IndexOf("WalkingTec.Mvvm.TagHelpers.LayUI") < 0) { proj = proj.Replace("</Project>", $@" <ItemGroup> <PackageReference Include=""WalkingTec.Mvvm.TagHelpers.LayUI"" Version=""{version}"" /> <PackageReference Include=""WalkingTec.Mvvm.Mvc.Admin"" Version=""{version}"" /> </ItemGroup > </Project> "); File.WriteAllText($"{MainDir}\\{MainNs}.csproj", proj, Encoding.UTF8); } } if (ProjectType == ProjectTypeEnum.Multi) { var proj = File.ReadAllText($"{MainDir}\\{MainNs}.csproj"); if (proj.IndexOf("WalkingTec.Mvvm.TagHelpers.LayUI") < 0) { proj = proj.Replace("</Project>", $@" <ItemGroup> <PackageReference Include=""WalkingTec.Mvvm.TagHelpers.LayUI"" Version=""{version}"" /> <PackageReference Include=""WalkingTec.Mvvm.Mvc.Admin"" Version=""{version}"" /> <ProjectReference Include=""..\{modelns}\{modelns}.csproj"" /> <ProjectReference Include=""..\{datans}\{datans}.csproj"" /> <ProjectReference Include=""..\{vmns}\{vmns}.csproj"" /> </ItemGroup > </Project> "); File.WriteAllText($"{MainDir}\\{MainNs}.csproj", proj, Encoding.UTF8); } //修改modelproject var modelproj = File.ReadAllText($"{modeldir}\\{modelns}.csproj"); if (modelproj.IndexOf("WalkingTec.Mvvm.Core") < 0) { modelproj = modelproj.Replace("</Project>", $@" <ItemGroup> <PackageReference Include=""WalkingTec.Mvvm.Core"" Version=""{version}"" /> </ItemGroup > </Project> "); File.WriteAllText($"{modeldir}\\{modelns}.csproj", modelproj, Encoding.UTF8); } //修改dataproject var dataproj = File.ReadAllText($"{datadir}\\{datans}.csproj"); if (dataproj.IndexOf($"{modelns}.csproj") < 0) { dataproj = dataproj.Replace("</Project>", $@" <ItemGroup> <ProjectReference Include=""..\{modelns}\{modelns}.csproj"" /> </ItemGroup > </Project> "); File.WriteAllText($"{datadir}\\{datans}.csproj", dataproj, Encoding.UTF8); } //修改viewmodelproject var vmproj = File.ReadAllText($"{vmdir}\\{vmns}.csproj"); if (vmproj.IndexOf($"{modelns}.csproj") < 0) { vmproj = vmproj.Replace("</Project>", $@" <ItemGroup> <ProjectReference Include=""..\{modelns}\{modelns}.csproj"" /> </ItemGroup > </Project> "); File.WriteAllText($"{vmdir}\\{vmns}.csproj", vmproj, Encoding.UTF8); } var solution = File.ReadAllText($"{Directory.GetParent(MainDir)}\\{MainNs}.sln"); if (solution.IndexOf($"{modelns}.csproj") < 0) { Guid g1 = Guid.NewGuid(); Guid g2 = Guid.NewGuid(); Guid g3 = Guid.NewGuid(); solution = solution.Replace("EndProject", $@"EndProject Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{modelns}"", ""{modelns}\{modelns}.csproj"", ""{{{g1}}}"" EndProject Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{datans}"", ""{datans}\{datans}.csproj"", ""{{{g2}}}"" EndProject Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{vmns}"", ""{vmns}\{vmns}.csproj"", ""{{{g3}}}"" EndProject "); solution = solution.Replace(".Release|Any CPU.Build.0 = Release|Any CPU", $@".Release|Any CPU.Build.0 = Release|Any CPU {{{g1}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {{{g1}}}.Debug|Any CPU.Build.0 = Debug|Any CPU {{{g1}}}.Release|Any CPU.ActiveCfg = Release|Any CPU {{{g1}}}.Release|Any CPU.Build.0 = Release|Any CPU {{{g2}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {{{g2}}}.Debug|Any CPU.Build.0 = Debug|Any CPU {{{g2}}}.Release|Any CPU.ActiveCfg = Release|Any CPU {{{g2}}}.Release|Any CPU.Build.0 = Release|Any CPU {{{g3}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {{{g3}}}.Debug|Any CPU.Build.0 = Debug|Any CPU {{{g3}}}.Release|Any CPU.ActiveCfg = Release|Any CPU {{{g3}}}.Release|Any CPU.Build.0 = Release|Any CPU" ); File.WriteAllText($"{Directory.GetParent(MainDir)}\\{MainNs}.sln", solution, Encoding.UTF8); } } if (File.Exists($"{MainDir}\\Startup.cs")) { File.Delete($"{MainDir}\\Startup.cs"); } }
public void DoSetup() { switch (DotnetVersion) { case DotnetVersionEnum.dotnet2_2: EFDesignVersion = "2.2.4"; SwashbuckleVersion = "4.0.1"; version = Utils.GetNugetVersion("2.", false); break; case DotnetVersionEnum.dotnet3_0: EFDesignVersion = "3.0.1"; SwashbuckleVersion = "5.0.0-rc4"; version = Utils.GetNugetVersion("3.", true); break; default: break; } string vmdir = MainDir; string datadir = MainDir; string modeldir = MainDir; string resourcedir = MainDir + $"{Path.DirectorySeparatorChar}Resources"; string testdir = MainDir + ".Test"; string vmns = MainNs + ".ViewModels"; string datans = MainNs; string modelns = MainNs; string testns = MainNs + ".Test"; Directory.CreateDirectory($"{MainDir}.Test"); Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}Resources"); if (ProjectType == ProjectTypeEnum.Single) { Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}Models"); File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Models{Path.DirectorySeparatorChar}ReadMe.txt", "Put your models here"); Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}ViewModels"); if (UI == UIEnum.LayUI) { Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}ViewModels{Path.DirectorySeparatorChar}HomeVMs"); } vmdir = MainDir + $"{Path.DirectorySeparatorChar}ViewModels"; } else { Directory.CreateDirectory($"{MainDir}.ViewModel"); if (UI == UIEnum.LayUI) { Directory.CreateDirectory($"{MainDir}.ViewModel{Path.DirectorySeparatorChar}HomeVMs"); } Directory.CreateDirectory($"{MainDir}.Model"); Directory.CreateDirectory($"{MainDir}.DataAccess"); vmdir = MainDir + ".ViewModel"; datadir = MainDir + ".DataAccess"; modeldir = MainDir + ".Model"; vmns = MainNs + ".ViewModel"; datans = MainNs + ".DataAccess"; modelns = MainNs + ".Model"; File.WriteAllText($"{modeldir}{Path.DirectorySeparatorChar}{modelns}.csproj", GetResource("Proj.txt"), Encoding.UTF8); File.WriteAllText($"{vmdir}{Path.DirectorySeparatorChar}{vmns}.csproj", GetResource("Proj.txt"), Encoding.UTF8); File.WriteAllText($"{datadir}{Path.DirectorySeparatorChar}{datans}.csproj", GetResource("Proj.txt"), Encoding.UTF8); } File.WriteAllText($"{testdir}{Path.DirectorySeparatorChar}{testns}.csproj", GetResource("TestProj.txt").Replace("$ns$", MainNs), Encoding.UTF8); File.WriteAllText($"{testdir}{Path.DirectorySeparatorChar}MockController.cs", GetResource("MockController.txt", "test").Replace("$ns$", testns).Replace("$datans$", datans), Encoding.UTF8); File.WriteAllText($"{testdir}{Path.DirectorySeparatorChar}MockHttpSession.cs", GetResource("MockHttpSession.txt", "test").Replace("$ns$", testns), Encoding.UTF8); Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}Areas"); Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}Controllers"); if (UI == UIEnum.LayUI) { File.WriteAllText($"{testdir}{Path.DirectorySeparatorChar}HomeControllerTest.cs", GetResource("HomeControllerTest.txt", "test").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{testdir}{Path.DirectorySeparatorChar}LoginControllerTest.cs", GetResource("LoginControllerTest.txt", "test").Replace("$ns$", MainNs).Replace("$vmns$", vmns).Replace("$datans$", datans), Encoding.UTF8); Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Home"); Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Login"); Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Shared"); } Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}wwwroot"); var proj = File.ReadAllText($"{MainDir}{Path.DirectorySeparatorChar}{MainNs}.csproj"); if (UI == UIEnum.LayUI) { proj = proj.Replace("</Project>", $@" <ItemGroup> <PackageReference Include=""WalkingTec.Mvvm.TagHelpers.LayUI"" Version=""{version}"" /> <PackageReference Include=""WalkingTec.Mvvm.Mvc.Admin"" Version=""{version}"" /> <PackageReference Include=""Swashbuckle.AspNetCore"" Version=""{SwashbuckleVersion}"" /> <PackageReference Include=""Microsoft.EntityFrameworkCore.Design"" Version=""{EFDesignVersion}"" /> </ItemGroup> </Project> "); proj = proj.Replace("</PropertyGroup>", $@" <CopyRefAssembliesToPublishDirectory>true</CopyRefAssembliesToPublishDirectory> </PropertyGroup> "); } if (UI == UIEnum.React) { proj = proj.Replace("</Project>", $@" <ItemGroup> <PackageReference Include=""WalkingTec.Mvvm.TagHelpers.LayUI"" Version=""{version}"" /> <PackageReference Include=""WalkingTec.Mvvm.Mvc.Admin"" Version=""{version}"" /> <PackageReference Include=""Swashbuckle.AspNetCore"" Version=""{SwashbuckleVersion}"" /> <PackageReference Include=""Microsoft.EntityFrameworkCore.Design"" Version=""{EFDesignVersion}"" /> </ItemGroup> <ItemGroup> <Content Remove=""$(SpaRoot)**"" /> <None Include=""$(SpaRoot)**"" Exclude=""$(SpaRoot)node_modules\**;$(SpaRoot).awcache\**;$(SpaRoot).cache-loader\**"" /> </ItemGroup> <Target Name=""DebugEnsureNodeEnv"" BeforeTargets=""Build"" Condition="" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ""> <Exec Command=""node --version"" ContinueOnError=""true""> <Output TaskParameter=""ExitCode"" PropertyName=""ErrorCode"" /> </Exec> <Error Condition=""'$(ErrorCode)' != '0'"" Text=""Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE."" /> <Message Importance=""high"" Text=""Restoring dependencies using 'npm'. This may take several minutes..."" /> <Exec WorkingDirectory=""$(SpaRoot)"" Command=""npm install"" /> </Target> <Target Name=""PublishRunWebpack"" AfterTargets=""ComputeFilesToPublish""> <Exec WorkingDirectory=""$(SpaRoot)"" Command=""npm install"" /> <Exec WorkingDirectory=""$(SpaRoot)"" Command=""npm run build"" /> <ItemGroup> <DistFiles Include=""$(SpaRoot)build\**"" /> <ResolvedFileToPublish Include=""@(DistFiles->'%(FullPath)')"" Exclude=""@(ResolvedFileToPublish)""> <RelativePath>%(DistFiles.Identity)</RelativePath> <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> </ResolvedFileToPublish> </ItemGroup> </Target> </Project> "); proj = proj.Replace("</PropertyGroup>", $@" <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> <TypeScriptToolsVersion>3.2</TypeScriptToolsVersion> <IsPackable>false</IsPackable> <SpaRoot>ClientApp\</SpaRoot> <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes> <CopyRefAssembliesToPublishDirectory>true</CopyRefAssembliesToPublishDirectory> </PropertyGroup> "); } if (ProjectType == ProjectTypeEnum.Multi) { proj = proj.Replace("</Project>", $@" <ItemGroup> <ProjectReference Include=""..\{modelns}\{modelns}.csproj"" /> <ProjectReference Include=""..\{datans}\{datans}.csproj"" /> <ProjectReference Include=""..\{vmns}\{vmns}.csproj"" /> </ItemGroup > </Project> "); } File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}{MainNs}.csproj", proj, Encoding.UTF8); if (ProjectType == ProjectTypeEnum.Multi) { //修改modelproject var modelproj = File.ReadAllText($"{modeldir}{Path.DirectorySeparatorChar}{modelns}.csproj"); if (modelproj.IndexOf("WalkingTec.Mvvm.Core") < 0) { modelproj = modelproj.Replace("</Project>", $@" <ItemGroup> <PackageReference Include=""WalkingTec.Mvvm.Core"" Version=""{version}"" /> </ItemGroup > </Project> "); File.WriteAllText($"{modeldir}{Path.DirectorySeparatorChar}{modelns}.csproj", modelproj, Encoding.UTF8); } //修改dataproject var dataproj = File.ReadAllText($"{datadir}{Path.DirectorySeparatorChar}{datans}.csproj"); if (dataproj.IndexOf($"{modelns}.csproj") < 0) { dataproj = dataproj.Replace("</Project>", $@" <ItemGroup> <ProjectReference Include=""..\{modelns}\{modelns}.csproj"" /> </ItemGroup > </Project> "); File.WriteAllText($"{datadir}{Path.DirectorySeparatorChar}{datans}.csproj", dataproj, Encoding.UTF8); } //修改viewmodelproject var vmproj = File.ReadAllText($"{vmdir}{Path.DirectorySeparatorChar}{vmns}.csproj"); if (vmproj.IndexOf($"{modelns}.csproj") < 0) { vmproj = vmproj.Replace("</Project>", $@" <ItemGroup> <ProjectReference Include=""..\{modelns}\{modelns}.csproj"" /> </ItemGroup > </Project> "); File.WriteAllText($"{vmdir}{Path.DirectorySeparatorChar}{vmns}.csproj", vmproj, Encoding.UTF8); } var solution = File.ReadAllText($"{Directory.GetParent(MainDir)}{Path.DirectorySeparatorChar}{MainNs}.sln"); if (solution.IndexOf($"{modelns}.csproj") < 0) { Guid g1 = Guid.NewGuid(); Guid g2 = Guid.NewGuid(); Guid g3 = Guid.NewGuid(); solution = solution.Replace("EndProject", $@"EndProject Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{modelns}"", ""{modelns}\{modelns}.csproj"", ""{{{g1}}}"" EndProject Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{datans}"", ""{datans}\{datans}.csproj"", ""{{{g2}}}"" EndProject Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{vmns}"", ""{vmns}\{vmns}.csproj"", ""{{{g3}}}"" EndProject Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{testns}"", ""{testns}\{testns}.csproj"", ""{{{Guid.NewGuid()}}}"" EndProject "); solution = solution.Replace(".Release|Any CPU.Build.0 = Release|Any CPU", $@".Release|Any CPU.Build.0 = Release|Any CPU {{{g1}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {{{g1}}}.Debug|Any CPU.Build.0 = Debug|Any CPU {{{g1}}}.Release|Any CPU.ActiveCfg = Release|Any CPU {{{g1}}}.Release|Any CPU.Build.0 = Release|Any CPU {{{g2}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {{{g2}}}.Debug|Any CPU.Build.0 = Debug|Any CPU {{{g2}}}.Release|Any CPU.ActiveCfg = Release|Any CPU {{{g2}}}.Release|Any CPU.Build.0 = Release|Any CPU {{{g3}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {{{g3}}}.Debug|Any CPU.Build.0 = Debug|Any CPU {{{g3}}}.Release|Any CPU.ActiveCfg = Release|Any CPU {{{g3}}}.Release|Any CPU.Build.0 = Release|Any CPU" ); File.WriteAllText($"{Directory.GetParent(MainDir)}{Path.DirectorySeparatorChar}{MainNs}.sln", solution, Encoding.UTF8); } } else { var s1 = File.ReadAllText($"{Directory.GetParent(MainDir)}{Path.DirectorySeparatorChar}{MainNs}.sln"); s1 = s1.Replace("EndProject", $@"EndProject Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{testns}"", ""{testns}\{testns}.csproj"", ""{{{Guid.NewGuid()}}}"" EndProject "); File.WriteAllText($"{Directory.GetParent(MainDir)}{Path.DirectorySeparatorChar}{MainNs}.sln", s1, Encoding.UTF8); } File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}appsettings.json", GetResource("Appsettings.txt") .Replace("$cs$", CS ?? "") .Replace("$dbtype$", DbType.ToString()) .Replace("$pagemode$", PageMode.ToString()) .Replace("$cookiepre$", CookiePre ?? "") .Replace("$enablelog$", EnableLog.ToString().ToLower()) .Replace("$logexception$", LogExceptionOnly.ToString().ToLower()) .Replace("$rpp$", Rpp == null ? "" : Rpp.ToString()) .Replace("$filemode$", FileMode.ToString()) .Replace("$uploaddir$", UploadDir ?? ""), Encoding.UTF8 ); File.WriteAllText($"{datadir}{Path.DirectorySeparatorChar}DataContext.cs", GetResource("DataContext.txt").Replace("$ns$", datans), Encoding.UTF8); File.WriteAllText($"{resourcedir}{Path.DirectorySeparatorChar}Program.zh.resx", GetResource("Resourcezh.txt"), Encoding.UTF8); File.WriteAllText($"{resourcedir}{Path.DirectorySeparatorChar}Program.en.resx", GetResource("Resourceen.txt"), Encoding.UTF8); if (UI == UIEnum.LayUI) { File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Controllers{Path.DirectorySeparatorChar}HomeController.cs", GetResource("HomeController.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Controllers{Path.DirectorySeparatorChar}LoginController.cs", GetResource("LoginController.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}_ViewStart.cshtml", GetResource("ViewStart.txt", "Mvc"), Encoding.UTF8); File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Home{Path.DirectorySeparatorChar}Index.cshtml", GetResource("home.Index.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Login{Path.DirectorySeparatorChar}ChangePassword.cshtml", GetResource("home.ChangePassword.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Home{Path.DirectorySeparatorChar}Layout.cshtml", GetResource("home.layout.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Login{Path.DirectorySeparatorChar}Login.cshtml", GetResource("home.Login.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Home{Path.DirectorySeparatorChar}PIndex.cshtml", GetResource("home.PIndex.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Home{Path.DirectorySeparatorChar}FrontPage.cshtml", GetResource("home.FrontPage.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{vmdir}{Path.DirectorySeparatorChar}HomeVMs{Path.DirectorySeparatorChar}ChangePasswordVM.cs", GetResource("vms.ChangePasswordVM.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{vmdir}{Path.DirectorySeparatorChar}HomeVMs{Path.DirectorySeparatorChar}IndexVM.cs", GetResource("vms.IndexVM.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{vmdir}{Path.DirectorySeparatorChar}HomeVMs{Path.DirectorySeparatorChar}LoginVM.cs", GetResource("vms.LoginVM.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8); File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Shared{Path.DirectorySeparatorChar}_Layout.cshtml", GetResource("layui.Layout.txt", "Mvc").Replace("$ns$", MainNs), Encoding.UTF8); File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Program.cs", GetResource("layui.Program.txt", "Mvc").Replace("$ns$", MainNs), Encoding.UTF8); File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}_ViewImports.cshtml", GetResource("layui.ViewImports.txt", "Mvc"), Encoding.UTF8); File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Areas{Path.DirectorySeparatorChar}_ViewImports.cshtml", GetResource("layui.ViewImports.txt", "Mvc"), Encoding.UTF8); File.WriteAllText($"{ExtraDir}{Path.DirectorySeparatorChar}alpine.Dockerfile", GetResource("alpine.Dockerfile.txt", "Mvc").Replace("$ns$", MainNs), Encoding.UTF8); File.WriteAllText($"{ExtraDir}{Path.DirectorySeparatorChar}Dockerfile", GetResource("Dockerfile.txt", "Mvc").Replace("$ns$", MainNs), Encoding.UTF8); UnZip("WalkingTec.Mvvm.Doc.SetupFiles.Mvc.layui.layui.zip", $"{MainDir}{Path.DirectorySeparatorChar}wwwroot"); } if (UI == UIEnum.React) { Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}ClientApp"); UnZip("WalkingTec.Mvvm.Doc.SetupFiles.Mvc.layui.layui.zip", $"{MainDir}{Path.DirectorySeparatorChar}wwwroot"); UnZip("WalkingTec.Mvvm.Doc.SetupFiles.Spa.React.ClientApp.zip", $"{MainDir}{Path.DirectorySeparatorChar}ClientApp"); File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Program.cs", GetResource("Program.txt", "Spa").Replace("$ns$", MainNs), Encoding.UTF8); var config = File.ReadAllText($"{MainDir}{Path.DirectorySeparatorChar}ClientApp{Path.DirectorySeparatorChar}src{Path.DirectorySeparatorChar}global.config.tsx"); File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}ClientApp{Path.DirectorySeparatorChar}src{Path.DirectorySeparatorChar}global.config.tsx", config.Replace("title: \"WalkingTec MVVM\",", $"title: \"{MainNs}\","), Encoding.UTF8); File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}ClientApp{Path.DirectorySeparatorChar}src{Path.DirectorySeparatorChar}setupProxy.js", $@" const proxy = require('http-proxy-middleware'); module.exports = (app) => {{ app.use(proxy('/api', {{ target: 'http://localhost:{Port}/', changeOrigin: true, logLevel: ""debug"" }})); }}; ", Encoding.UTF8); } if (File.Exists($"{MainDir}{Path.DirectorySeparatorChar}Startup.cs")) { File.Delete($"{MainDir}{Path.DirectorySeparatorChar}Startup.cs"); } }
private void Savereceivable_Click(object sender, RoutedEventArgs e) { if (cbPaymentType.Text == "" || srcustomer.Name == "" || txtemail.Name == "" || txthp.Name == "" || dtPayment.Text == "" || srnodokumen.Name == "" || txtPaymentNumber.Text == "" || cbCash.Text == "" || txtValue.Text == "" || srstaff.Name == "") { MessageBox.Show("please fill in the blank fields", ("Form Validation"), MessageBoxButton.OK, MessageBoxImage.Error); return; } RppBLL rppBLL = new RppBLL(); RppBLL RppBLL = new RppBLL(); Rpp rpp = new Rpp(); OrderTransaksiCash ordercash = new OrderTransaksiCash(); if (this.dropdownPaymentCashActivitySelected != null) { rpp.PulldownRpp = this.dropdownPaymentCashActivitySelected.Id; rpp.IdKodeTransaksi = this.dropdownPaymentCashActivitySelected.IdKodeTransaksi; rpp.KodeTransaksi = this.dropdownPaymentCashActivitySelected.KodeTransaksi; } if (this.kontakSelected != null) { rpp.IdPelanggan = this.kontakSelected.Id; rpp.NamaPelanggan = this.kontakSelected.NamaA; } rpp.Email = txtemail.Text; rpp.NoHp = double.Parse(txthp.Text); rpp.TanggalTransaksi = DateTime.Parse(dtPayment.Text); if (this.dokumenSelected != null) { rpp.IdNoReferensiDokumen = this.dokumenSelected.Id; rpp.NoReferensiDokumen = this.dokumenSelected.NoReferensiDokumen; } rpp.NoPembayaran = double.Parse(txtPaymentNumber.Text); if (this.dropdownBankKasSelected != null) { rpp.IdAkunKas = this.dropdownBankKasSelected.Id; rpp.NamaAkunKas = this.dropdownBankKasSelected.DropdownBankkas; } rpp.Keterangan = txtNote.Text; if (this.kontakpetugasSelected != null) { rpp.IdPetugas = this.kontakpetugasSelected.Id; rpp.NamaPetugas = this.kontakpetugasSelected.NamaA; } // rpp.TotalPembayaran = double.Parse(txtTotalPaymentValue.Text); rpp.IdPeriodeAkuntansi = 1; rpp.RealRecordingTime = DateTime.Now; if (RppBLL.AddRpp(rpp) > 0) { // this.ClearForm(); MessageBox.Show("Receivable And Payable Payment successfully added !"); } else { MessageBox.Show("Receivable And Payable Payment failed to add !"); } if (DGReceivablePayment.Items.Count > 0) { foreach (var item in DGReceivablePayment.Items) { if (item is OrderTransaksiCash) { OrderTransaksiCash oNewData1 = (OrderTransaksiCash)item; /* oNewData1.NoReferensiTransaksi = double.Parse(txtPaymentNumber.Text); * if (this.dropdownBankKasSelected != null) * { * oNewData1.IdAkunHutangPiutangReferensi = this.dropdownBankKasSelected.Id; * } * if (this.dropdownCashActivitySelected != null) * { * oNewData1.IdDropdownPaymentCashActivity = this.dropdownCashActivitySelected.Id; * oNewData1.IdKodeTransaksi = this.dropdownCashActivitySelected.IdKodeTransaksi; * oNewData1.KodeTransaksi = this.dropdownCashActivitySelected.KodeTransaksi; * } * if (this.kontakSelected != null) * { * oNewData1.IdPelanggan = this.kontakSelected.Id; * oNewData1.NamaPelanggan = this.kontakSelected.NamaA; * } * oNewData1.Email = txtemail.Text; * oNewData1.NoHp = double.Parse(txthp.Text); * if (this.dataMataUangSelected != null) * { * oNewData1.IdMataUang = this.dataMataUangSelected.Id; * oNewData1.MataUang = this.dataMataUangSelected.NamaMataUang; * oNewData1.KursTukar = this.dataMataUangSelected.KursTukar; * } * if (this.dokumenSelected != null) * { * oNewData1.IdNoReferensiDokumen = this.dokumenSelected.Id; * oNewData1.NoReferensiDokumen = this.dokumenSelected.NoReferensiDokumen; * } * oNewData1.TanggalTransaksi = DateTime.Parse(tgl.Text); * if (this.kontakSelecteds != null) * { * oNewData1.IdPetugas = this.kontakSelecteds.Id; * oNewData1.NamaPetugas = this.kontakSelecteds.NamaA; * } * oNewData1.RealRecordingTime = DateTime.Now; * oNewData1.IdPeriodeTransaksi = cash.IdPeriodeAkuntansi; * oNewData1.Checkboxaktif = false; * if (cashBLL.Edittranscash(oNewData1, cash) == true) * { * }*/ } } ReceivableAndPayable v = new ReceivableAndPayable(); Switcher.SwitchNewReceivableAndPayable(v); } }