private void bnSave_Click(object sender, EventArgs e) { ConnStringer stringer = new ConnStringer(); List <string> errors = new List <string>(); if (tbMitelDataLogPath.Text == String.Empty) { errors.Add("Mitel data log file field cannot be blank"); } if (tbDemoRecords.Text == String.Empty) { errors.Add("Demo Call Records file location cannot be blank"); } if (tbCallRecordLoc.Text == String.Empty) { errors.Add("Mitel Call Records file location cannot be blank"); } if (errors.Count == 0) { //Save the file locations MiConfig.SetConnectionString("MiDemoString", stringer.buildLiteConnectionString(tbDemoRecords.Text, "3", "True", "False", "", "", false)); MiConfig.SetConnectionString("MiDatabaseString", stringer.buildLiteConnectionString(tbCallRecordLoc.Text, "3", "True", "False", "", "", false)); MiConfig.SetLogPath(tbMitelDataLogPath.Text); //save options MiConfig.SetConnectOnStartup(cbConnectOnStartup.Checked); MiConfig.SetShowDebug(cbShowDebug.Checked); RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (cbStartWithWindows.Checked) { rkApp.SetValue("MiSMDR", Application.ExecutablePath.ToString()); } else { rkApp.DeleteValue("MiSMDR", false); } MiConfig.SetShowSplash(cbShowSplash.Checked); MiConfig.SetMinimiseToTray(cbMinimiseToTray.Checked); MiConfig.SetRecordLimit(Convert.ToInt32(tbCallRecordLimit.Text)); MiConfig.SetShowNotifications(cbShowNotifications.Checked); //return to MiForm this.DialogResult = DialogResult.OK; } else { string errorString = "Cannot save settings: " + Environment.NewLine; foreach (string error in errors) { errorString += "- " + error + Environment.NewLine; } MessageBox.Show(errorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void afterLoad() { string myDocs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); //first thing is to see if the config is new if (MiConfig.GetProvider() != DataProvider.Sqlite) { this.SetText("Updating configuration file"); MiConfig.buildDefaultConfigFile(_configPath); //rebuild it just in case MiConfig.SetProvider(DataProvider.Sqlite); } if (MiConfig.GetProvider() != DataProvider.Sqlite) { //CHECK AGAIN - this is to make sure the config file is in a writable location this.SetText("Unable to create a config file. Please contact the MiSMDR support team at [email protected]"); } if ((MiConfig.GetConnectionString("MiDatabaseString") == "notinstalled") || (MiConfig.GetConnectionString("MiDemoString") == "notinstalled")) { CheckMiSMDRFolder(); //now we need to check the demo file location if (MiConfig.GetConnectionString("MiDemoString") == "notinstalled") { BuildDemoFile(); } if (MiConfig.GetConnectionString("MiDatabaseString") == "notinstalled") { BuildMitelFile(); } } if (MiConfig.GetLogPath() == "notinstalled") { this.SetText("Checking Mitel Data log file"); string dataLogPath = myDocs + "\\MiSMDR\\MitelData_Log.txt"; MiConfig.SetLogPath(dataLogPath); } DBControl demoChecker = new DBControl(MiConfig.GetConnectionString("MiDemoString"), MiConfig.GetProvider()); DBControl liveChecker = new DBControl(MiConfig.GetConnectionString("MiDatabaseString"), MiConfig.GetProvider()); this.SetText("Configuration looks ok"); this.SetText("Checking Database access"); if (!demoChecker.CheckDataAccess()) { this.SetText("Demo Database looks ok"); CheckMiSMDRFolder(); //check the folder exists BuildDemoFile(); } if (!liveChecker.CheckDataAccess()) { this.SetText("Mitel Database looks ok"); CheckMiSMDRFolder(); BuildMitelFile(); } //Load MiSMDR main CheckProgressBar(); HideSplash(); MiSMDR.MiForm.customStart(_popup, _trialStatus); CloseSplash(); //after the MiForm is closed then kill the App }