protected override ReportTask CreateItemFromXmlNode(System.Xml.XmlNode xmlNode) { ReportTask task = new ReportTask(); task.Name = xmlNode.GetAttributeValueIf("Name"); task.Description = xmlNode.GetAttributeValueIf("Description"); task.OutputFolder = xmlNode.GetNodeValueIf("OutputFolder"); task.IsSendMailInSingleMail = bool.Parse(xmlNode.GetNodeValueIf("SendInSingleMail")); task.IsMergeInSingleExcel = bool.Parse(xmlNode.GetNodeValueIf("MergeInSingleExcel")); XmlNodeList reportNodeList = xmlNode.SelectNodes("Reports/Report"); for (int i = 0; i < reportNodeList.Count; i++) { string report = reportNodeList[i].GetNodeValueIf(); if (ReportConfig.QvReportManager.ItemCollection.ContainsKey(report)) { var qvReport = ReportConfig.QvReportManager.ItemCollection[report]; task.Reports.Add(report, qvReport); } } XmlNodeList recipientNodeList = xmlNode.SelectNodes("Recipients/Recipient"); for (int i = 0; i < recipientNodeList.Count; i++) { string recipient = recipientNodeList[i].GetNodeValueIf(); if (ReportConfig.RecipientManager.ItemCollection.ContainsKey(recipient)) { task.Recipients.Add(recipient, ReportConfig.RecipientManager.ItemCollection[recipient]); } } string recipientGroup = xmlNode.GetNodeValueIf("RecipientGroup"); if (ReportConfig.RecipientGroupManager.ItemCollection.ContainsKey(recipientGroup)) { task.Group = ReportConfig.RecipientGroupManager.ItemCollection[recipientGroup]; } task.MessageDefinition = new Message(); task.MessageDefinition.From = xmlNode.GetNodeValueIf("Message/From"); task.MessageDefinition.CC = xmlNode.GetNodeValueIf("Message/CC"); task.MessageDefinition.BCC = xmlNode.GetNodeValueIf("Message/BCC"); task.MessageDefinition.Subject = xmlNode.GetNodeValueIf("Message/Subject"); task.MessageDefinition.Body = xmlNode.GetNodeValueIf("Message/Body"); if (xmlNode.ChildNodeExists("FtpServer")) { task.FtpServer = new FtpServer(); task.FtpServer.Host = xmlNode.GetNodeValueIf("FtpServer/Host"); task.FtpServer.Username = xmlNode.GetNodeValueIf("FtpServer/Username"); task.FtpServer.Password = EncryptionDecryption.Decode(xmlNode.GetNodeValueIf("FtpServer/Password")); task.FtpServer.Folder = xmlNode.GetNodeValueIf("FtpServer/Folder"); task.FtpServer.Port = xmlNode.GetNodeValueIf("FtpServer/Port"); } return(task); }
protected override void RecreateItemXmlNodes(System.Xml.XmlNode itemRootNode, ReportItemDictionary <ReportConnection> itemCollection) { foreach (var item in itemCollection.Values) { XmlNode node = this.CreateNodeBase("Connection", item.Name, item.Description); node.AddChildNode("IsLocal", item.IsLocal.ToString()); node.AddChildNode("ServerName", item.ServerName); node.AddChildNode("WebServicePort", item.ServicePort); node.AddChildNode("WebServiceHost", item.ServiceHost); node.AddChildNode("QlikViewDocument", item.QlikViewDocument); node.AddChildNode("User", item.User); node.AddChildNode("Password", EncryptionDecryption.Encode(item.Password)); itemRootNode.AppendChild(node); } }
protected override ReportConnection CreateItemFromXmlNode(System.Xml.XmlNode xmlNode) { ReportConnection connection = new ReportConnection(); connection.Name = xmlNode.GetAttributeValueIf("Name"); connection.Description = xmlNode.GetAttributeValueIf("Description"); connection.IsLocal = bool.Parse(xmlNode.GetNodeValueIf("IsLocal")); connection.QlikViewDocument = xmlNode.GetNodeValueIf("QlikViewDocument"); connection.ServerName = xmlNode.GetNodeValueIf("ServerName"); connection.ServiceHost = xmlNode.GetNodeValueIf("WebServiceHost"); connection.ServicePort = xmlNode.GetNodeValueIf("WebServicePort"); connection.User = xmlNode.GetNodeValueIf("User"); connection.Password = EncryptionDecryption.Decode(xmlNode.GetNodeValueIf("Password")); return(connection); }
protected override void RecreateItemXmlNodes(System.Xml.XmlNode itemRootNode, ReportItemDictionary <ReportTask> itemCollection) { foreach (var item in itemCollection.Values) { XmlNode node = this.CreateNodeBase("Task", item.Name, item.Description); node.AddChildNode("OutputFolder", item.OutputFolder); node.AddChildNode("SendInSingleMail", item.IsSendMailInSingleMail.ToString()); node.AddChildNode("MergeInSingleExcel", item.IsMergeInSingleExcel.ToString()); XmlNode reportsNode = node.AddChildNode("Reports", string.Empty); foreach (var report in item.Reports.Values) { reportsNode.AddChildNode("Report", report.Name); } XmlNode recipientsNode = node.AddChildNode("Recipients", string.Empty); foreach (var recipient in item.Recipients.Values) { recipientsNode.AddChildNode("Recipient", recipient.Name); } node.AddChildNode("RecipientGroup", item.Group == null ? string.Empty : item.Group.Name); XmlNode messageNode = node.AddChildNode("Message", string.Empty); messageNode.AddChildNode("From", item.MessageDefinition.From); messageNode.AddChildNode("CC", item.MessageDefinition.CC ?? string.Empty); messageNode.AddChildNode("BCC", item.MessageDefinition.BCC ?? string.Empty); messageNode.AddChildNode("Subject", item.MessageDefinition.Subject ?? string.Empty); XmlNode bodyNode = messageNode.AddChildNode("Body", string.Empty); XmlCDataSection dateSec = this._xmlDoc.CreateCDataSection(item.MessageDefinition.Body); bodyNode.AppendChild(dateSec); if (item.FtpServer != null) { XmlNode ftpServerNode = node.AddChildNode("FtpServer", string.Empty); ftpServerNode.AddChildNode("Host", item.FtpServer.Host); ftpServerNode.AddChildNode("Username", item.FtpServer.Username); ftpServerNode.AddChildNode("Password", EncryptionDecryption.Encode(item.FtpServer.Password)); ftpServerNode.AddChildNode("Folder", item.FtpServer.Folder); ftpServerNode.AddChildNode("Port", item.FtpServer.Port); } itemRootNode.AppendChild(node); } }
public void Save() { this._xmlDoc = new XmlDocument(); this._xmlDoc.Load(ConfigFile); XmlNode smtpServerRootNode = this._xmlDoc.SelectSingleNode("ReportConfig/SmtpServer"); smtpServerRootNode.RemoveAll(); smtpServerRootNode.AddChildNode("Server", this.SmtpServer.Server); smtpServerRootNode.AddChildNode("PickupDirectoryLocation", this.SmtpServer.PickupDirectoryLocation); smtpServerRootNode.AddChildNode("User", this.SmtpServer.User); smtpServerRootNode.AddChildNode("Password", EncryptionDecryption.Encode(this.SmtpServer.Password)); smtpServerRootNode.AddChildNode("ExceptionMailFrom", this.SmtpServer.ExceptionFrom); smtpServerRootNode.AddChildNode("ExceptionMailTo", this.SmtpServer.ExceptionTo); smtpServerRootNode.AddChildNode("UsePickupDirectoryLocation", this.SmtpServer.UsePickupDirectoryLocation.ToString()); this._xmlDoc.Save(ConfigFile); }
public SmtpServerManager() { string folder = System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Remove(System.Reflection.Assembly.GetExecutingAssembly().CodeBase.LastIndexOf("/")); folder = folder.Replace("file:///", ""); ConfigFile = folder + "/" + System.Configuration.ConfigurationManager.AppSettings["ReportConfig"]; this._xmlDoc = new XmlDocument(); this._xmlDoc.Load(ConfigFile); XmlNode smtpServerRootNode = this._xmlDoc.SelectSingleNode("ReportConfig/SmtpServer"); //Smtp Server this.SmtpServer = new SmtpServer(); this.SmtpServer.Server = smtpServerRootNode.GetNodeValueIf("Server"); this.SmtpServer.PickupDirectoryLocation = smtpServerRootNode.GetNodeValueIf("PickupDirectoryLocation"); this.SmtpServer.User = smtpServerRootNode.GetNodeValueIf("User"); this.SmtpServer.Password = EncryptionDecryption.Decode(smtpServerRootNode.GetNodeValueIf("Password")); this.SmtpServer.ExceptionFrom = smtpServerRootNode.GetNodeValueIf("ExceptionMailFrom"); this.SmtpServer.ExceptionTo = smtpServerRootNode.GetNodeValueIf("ExceptionMailTo"); this.SmtpServer.UsePickupDirectoryLocation = bool.Parse(smtpServerRootNode.GetNodeValueIf("UsePickupDirectoryLocation")); }