Пример #1
0
        async void NewMicroservice_Click(object sender, ExecutedRoutedEventArgs e)
        {
            if (ServicesDirectory == null || !ServicesDirectory.Exists)
            {
                return;
            }

            var msw = new NewMicroservice.NewMicroservice
            {
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            var dialog = msw.ShowDialog();

            if (dialog != true)
            {
                return;
            }

            await new NewMicroserviceCreator(msw.ServiceName, msw.GitRepoUrl).Create();

            Refresh();
        }
Пример #2
0
        private async void NewMicroservice_Click(object sender, ExecutedRoutedEventArgs e)
        {
            string hubAddress = Path.Combine(ServicesDirectory.FullName, "hub");

            var msw = new NewMicroservice.NewMicroservice
            {
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            var dialog = msw.ShowDialog();

            if (dialog != true)
            {
                return;
            }

            if (!ServicesDirectory.Exists || ServicesDirectory == null)
            {
                return;
            }

            var appSettingsProductionAllText = File.ReadAllText(Path.Combine(hubAddress, "website", "appsettings.Production.json"));
            var appSettingsProductionJObject = JObject.Parse(appSettingsProductionAllText);
            var domain           = appSettingsProductionJObject["Authentication"]["Cookie"]["Domain"].ToString();
            var serviceName      = msw.ServiceName;
            var solutionName     = ServicesDirectory.Name;
            var portNumber       = GetNextPortNumberFromHubServices(ServicesDirectory, out var serviesXmlPath);
            var dbType           = DBType.SqlServer;
            var connectionString = dbType.ConnectionString;

            //AddMicroserviceToHubServices(serviesXmlPath, serviceName, domain, portNumber);

            var serviceDirectoryPath = Path.Combine(ServicesDirectory.FullName, serviceName);
            var serviceDirectory     = new DirectoryInfo(serviceDirectoryPath);

            if (!serviceDirectory.Exists)
            {
                serviceDirectory.Create();
            }

            var tmpFolder = await CreateTemplateAsync(serviceDirectoryPath, serviceName, solutionName, domain, portNumber.ToString(),
                                                      dbType, connectionString);

            if (tmpFolder.IsEmpty())
            {
                return;
            }

            AddMicroserviceToHubServices(serviesXmlPath, serviceName, domain, portNumber);
            Execute(serviceDirectoryPath, "build.bat", null);

            try
            {
                Execute(serviceDirectoryPath, "git", "init");
                Execute(serviceDirectoryPath, "git", $"remote add origin {msw.GitRepoUrl}");
                Execute(serviceDirectoryPath, "git", "add .");
                Execute(serviceDirectoryPath, "git", "commit -m \"Initial commit\"");
                Execute(serviceDirectoryPath, "git", "push");
            }
            catch (Exception ex)
            {
                MessageBox.Show($@"Error :{ex.Message}", @"Template initialization failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            Refresh();
        }