/// <summary> /// Initializes required paths for this service /// and returns the Assembly Title of this Assembly /// </summary> /// <returns></returns> private String InitializePaths() { this.MattimonAppInstallDirectory = MattimonAgentLibrary.Tools.RegistryTools.GetInstallLocationByDisplayName( MattimonAgentLibrary.Static.MattimonRegistrySubkeyNames.DisplayName); this.guiExePath = System.IO.Path.Combine(this.MattimonAppInstallDirectory, "MattimonAgentApplication.exe"); this.thisSvcExePath = System.IO.Path.Combine(this.MattimonAppInstallDirectory, "MattimonEventLogService.exe"); this.thisSvcAssemAttr = new MattimonAgentLibrary.Tools.ProjectAssemblyAtrributes( this.thisSvcExePath); return(thisSvcAssemAttr.AssemblyTitle); }
/// <summary> /// /// </summary> /// <param name="instances"></param> private void DeleteSqlServerInstance(ServerInstance[] instances) { string svcPath = string.Empty, svcName = string.Empty; FormBackgroundWorker deleteInstances = new FormBackgroundWorker(this, new DoWorkEventHandler((s, e) => { SQLServerRequests requests = new SQLServerRequests(); DeviceServerObjects dso = new DeviceServerObjects(); dso.DeviceID = GetDeviceID(); dso.Instances = instances; try { svcPath = Path.Combine(RegistryTools.GetInstallLocationByDisplayName( MattimonAgentLibrary.Static.MattimonRegistrySubkeyNames.DisplayName), "MattimonSQLServerService.exe"); if (!File.Exists(svcPath)) { throw new IOException("Could not locate the service file: " + svcPath + ".\n" + "Re-installing the application might fix this issue."); } } catch (IOException ioe) { throw ioe; } catch (Exception ex) { throw ex; } svcName = new ProjectAssemblyAtrributes(svcPath).AssemblyTitle; SQLiteClientDatabase db = GetLocalDatabase(); foreach (ServerInstance si in dso.Instances) { string insname = si.InstanceName.ToLower().Equals("mssqlserver") ? "" : si.InstanceName; db.DeleteConnectionStringEntry(si.ServerName, insname); } e.Result = requests.PostDeviceServerObjects(dso, DeviceServerObjectAction.delete); }), "Deleting Instance(s)"); deleteInstances.RunWorkerCompletedEventHandler = new RunWorkerCompletedEventHandler((s, e) => { if (e.Error != null) { GUI.BitscoreForms.BitscoreMessageBox.Show(this, "An error occurred while attempting to delete SQL Server instances.\n\n" + "Error details:\n" + Tools.ExceptionHelper.GetFormatedExceptionMessage(e.Error), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (e.Result != null && e.Result is DeviceServerObjects dso) { if (dso.Exception != null || dso.HttpRequestException != null) { if (dso.Exception != null) { GUI.BitscoreForms.BitscoreMessageBox.Show(this, "An server-side error occurred.\n\n" + "Error details:\n" + Tools.ExceptionHelper.GetFormatedExceptionMessage(dso.Exception), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (dso.HttpRequestException != null) { GUI.BitscoreForms.BitscoreMessageBox.Show(this, "An server-side error occurred.\n\n" + "Error details:\n" + Tools.ExceptionHelper.GetFormatedExceptionMessage(dso.HttpRequestException), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return; } BtnSqlSrv_Refresh_Click(btn_sqlsrv_refresh, EventArgs.Empty); GUI.BitscoreForms.BitscoreMessageBox.Show(this, "Instance(s) have been deleted.", Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }); deleteInstances.DoWork(); }