private void SaveConfigXML() { DBServiceConfig objXmlConfig = new DBServiceConfig(); Exception ce = new Exception(); objXmlConfig.DBServer = txtdbserver.Text; objXmlConfig.DBName = txtdbname.Text; objXmlConfig.DBUser = txtdbuser.Text; objXmlConfig.DBPassword = txtdbpassword.Text; objXmlConfig.AdminEmailAddress = txtadminemailadd.Text; objXmlConfig.ErrEmailAddress = txterroremailadd.Text; //Server Mail Info objXmlConfig.SMTPServer = txtSMTPServer.Text; objXmlConfig.SMTPSSL = txtSMTPSSL.Text; objXmlConfig.SMTPPort = txtSMTPPort.Text; objXmlConfig.SMTPSenderEmail = txtSMTPSenderEmail.Text; objXmlConfig.SMTPSenderPwd = txtSMTPSenderPwd.Text; if (LastAccessed == null || LastAccessed == "") { objXmlConfig.LastAccessed = ""; } else { objXmlConfig.LastAccessed = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); //MB:29Dec2009 } objXmlConfig.SaveToFile(ConstantStrings.ConfigXMLPath, out ce); objXmlConfig = null; ce = null; }
/// <summary> /// Deserializes workflow markup into an DBServiceConfig object /// </summary> // <param name="xml">string workflow markup to deserialize</param> // <param name="obj">Output DBServiceConfig object</param> // <param name="exception">output Exception value if deserialize failed</param> // <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool Deserialize(string xml, out DBServiceConfig obj, out System.Exception exception) { exception = null; obj = null; try { System.IO.StringReader stringReader = new System.IO.StringReader(xml); System.Xml.XmlTextReader xmlTextReader = new System.Xml.XmlTextReader(stringReader); System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(DBServiceConfig)); obj = ((DBServiceConfig)(xmlSerializer.Deserialize(xmlTextReader))); return(true); } catch (System.Exception ex) { exception = ex; return(false); } }
/// <summary> /// Deserializes workflow markup from file into an DBServiceConfig object /// </summary> // <param name="xml">string workflow markup to deserialize</param> // <param name="obj">Output DBServiceConfig object</param> // <param name="exception">output Exception value if deserialize failed</param> // <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool LoadFromFile(string fileName, out DBServiceConfig obj, out System.Exception exception) { exception = null; obj = null; try { System.IO.FileStream file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); System.IO.StreamReader sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString, out obj, out exception)); } catch (System.Exception ex) { exception = ex; return(false); } }
public DataSourceCommunicator GetDataBaseConnection() { try { DBServiceConfig objXmlConfig = new DBServiceConfig(); Exception ce = new Exception(); DBServiceConfig.LoadFromFile(ConstantStrings.ConfigXMLPath, out objXmlConfig, out ce); DataSourceCommunicator dbget = null; if (objXmlConfig != null) { DBName = objXmlConfig.DBName; dbget = new DataSourceCommunicator(DataSourceCommunicator.ParamType.ServerCredentials, objXmlConfig.DBServer, objXmlConfig.DBUser, objXmlConfig.DBPassword); ce = null; } return(dbget); } catch (System.Exception ex) { Program.log.Write("Scheduler - Error : " + ex.Message); return(null); } }
private void ReadConfigXML() { DBServiceConfig objXmlConfig = new DBServiceConfig(); Exception ce = new Exception(); DBServiceConfig.LoadFromFile(ConstantStrings.ConfigXMLPath, out objXmlConfig, out ce); if (objXmlConfig != null) { txtdbserver.Text = objXmlConfig.DBServer; txtdbname.Text = objXmlConfig.DBName; txtdbuser.Text = objXmlConfig.DBUser; txtdbpassword.Text = objXmlConfig.DBPassword; txtadminemailadd.Text = objXmlConfig.AdminEmailAddress; txterroremailadd.Text = objXmlConfig.ErrEmailAddress; LastAccessed = objXmlConfig.LastAccessed; txtSMTPServer.Text = objXmlConfig.SMTPServer; txtSMTPSSL.Text = objXmlConfig.SMTPSSL; txtSMTPPort.Text = objXmlConfig.SMTPPort; txtSMTPSenderEmail.Text = objXmlConfig.SMTPSenderEmail; txtSMTPSenderPwd.Text = objXmlConfig.SMTPSenderPwd; } objXmlConfig = null; ce = null; }