public bool Save() { try { if (rbConfigurationView.Checked) //No Hijack script { OutboundDBConfigMgt.Config.BuildScriptBySetting(); } else if (bScriptIsHajicked) { OutboundDBConfigMgt.Config.InstallTriggerScript = tbInstallTrigger.Text; OutboundDBConfigMgt.Config.UninstallTriggerScript = tbUninstallTrigger.Text; OutboundDBConfigMgt.Config.ScriptIsHijacked = true; } OutboundDBConfigMgt.Save(); if (OutboundDBConfigMgt.Config.ScriptIsHijacked == false && OutboundDBConfigMgt.Config.IOChannels.Count < 1) { Form frm = this.ParentForm; if (MessageBox.Show(frm, "You did not select any data source for this outbound interface, are you sure to save the configuration?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) != DialogResult.Yes) { return(false); } } return(true); } catch (Exception ex) { Program.log.Write(ex); return(false); } }
public static void PreLoad() { try { LoggingHelper.EnableXmlLogging(log); log.WriteAppStart("OutboundDBInstall.exe"); //OutboundDBConfigMgt.Save(); OutboundDBConfigMgt.FileName = Application.StartupPath + "\\" + OutboundDBConfigMgt.FileName; OutboundDBConfigMgt.Load(); //SaveToFile(OutboundDBConfigMgt.Config.OutboundConfig.InstallTriggerScript, "InstallTrigger_1.sql"); } catch (Exception Ex) { try { string sBakFile = ""; if (File.Exists(OutboundDBConfigMgt.FileName)) { sBakFile = BackupFile(OutboundDBConfigMgt.FileName); File.Delete(OutboundDBConfigMgt.FileName); } //OutboundDBConfigMgtSave(); // Save Calss using (StreamWriter sw = File.CreateText(OutboundDBConfigMgt.FileName)) { string str = OutboundDBConfigMgt.Config.ToXMLString(); sw.Write(str); } log.Write(Ex); log.Write(LogType.Error , "Load Configuration file failure!\n" + "System had rename old configuration file to " + sBakFile + " ,A new empty configuration had been produced!\n" , true); } catch { } } }