31 throw new ArgumentNullException(nameof(session));
35 session.Log(
"Begin DetachStopTgsServiceIfRunning");
36 ServiceController serviceController =
null;
38 session.Log($
"Searching for {CanonicalPackageName} service...");
41 foreach (var controller
in ServiceController.GetServices())
43 serviceController = controller;
47 if (serviceController ==
null || serviceController.Status != ServiceControllerStatus.Running)
49 session.Log($
"{CanonicalPackageName} service not found. Continuing.");
50 return ActionResult.Success;
57 session.Log($
"{CanonicalPackageName} service found. Sending command \"{PipeCommands.CommandDetachingShutdown}\" ({commandId})...");
59 serviceController.ExecuteCommand(commandId);
61 session.Log($
"Command sent. Waiting for {CanonicalPackageName} service to stop...");
63 serviceController.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromMinutes(1));
65 var stopped = serviceController.Status == ServiceControllerStatus.Stopped;
66 session.Log($
"{CanonicalPackageName} stopped {(stopped ? String.Empty : "un
")}successfully.");
69 ? ActionResult.Success
70 : ActionResult.NotExecuted;
74 serviceController?.Dispose();
79 session.Log($
"Exception in DetachStopTgsServiceIfRunning:{Environment.NewLine}{ex}");
80 return ActionResult.Failure;
93 throw new ArgumentNullException(nameof(session));
97 session.Log(
"Begin ApplyProductionAppsettingsIfNonExistant");
98 var programDataDirectory = Path.Combine(
99 Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
101 var initialAppSettingsPath = Path.Combine(programDataDirectory,
"appsettings.Initial.yml");
102 var productionAppSettingsPath = Path.Combine(programDataDirectory,
"appsettings.Production.yml");
104 var initialAppSettingsExists = File.Exists(initialAppSettingsPath);
105 var productionAppSettingsExists = File.Exists(productionAppSettingsPath);
107 if (productionAppSettingsExists)
108 session.Log(
"appsettings.Production.yml present");
110 session.Log(
"appsettings.Production.yml NOT present");
112 if (!initialAppSettingsExists)
113 session.Log(
"appsettings.Initial.yml NOT present!");
116 session.Log(
"appsettings.Initial.yml present");
117 if (!productionAppSettingsExists)
119 session.Log(
"Copying initial settings to production settings...");
120 File.Copy(initialAppSettingsPath, productionAppSettingsPath);
121 return ActionResult.Success;
125 return ActionResult.NotExecuted;
129 session.Log($
"Exception in ApplyProductionAppsettingsIfNonExistant:{Environment.NewLine}{ex}");
130 return ActionResult.Failure;