/// <summary> /// Used to Generate XML files /// </summary> /// <param name="DtXMlData">datatable containing data for creating xml file</param> /// <param name="XmlFileType">Type of XML file--srec of destination</param> private string GenerateLanguageXMLFile(DataTable DtXMlData, Constants.CreateXmlFor XMLFileType) { XmlDocument XMLDoc = new XmlDocument(); string FileName = string.Empty; string XmlFilePath = string.Empty; XmlElement ChildNode; string TemplateFilePath = string.Empty; string RetVal = string.Empty; bool IsTemplateCreated = false; if (XMLFileType.Equals(Constants.CreateXmlFor.SrcXmlFile)) { FileName = DtXMlData.Columns[1].ColumnName; } else { FileName = DtXMlData.Columns[2].ColumnName; } FileName = FileName.Replace("(", "[").Replace(")", "]"); XmlFilePath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.MasterKeyVals, FileName) + ".xml"; if (File.Exists(XmlFilePath)) { CreateBackUpFile(XmlFilePath, FileName); // Check if template xml file exist TemplateFilePath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.LanguageTemplate, Constants.FileName.LanguageXMLTemplate); if (File.Exists(TemplateFilePath)) { // Create XML file template IsTemplateCreated = CreateXMLFromTemplate(FileName); // If XML template created if (IsTemplateCreated) { // Create Doc Type XMLDoc.Load(XmlFilePath); for (int Jcount = 1; Jcount < DtXMlData.Rows.Count; Jcount++) { //create child noods ChildNode = XMLDoc.CreateElement("Row"); //Set attribute name and value! ChildNode.SetAttribute("key", DtXMlData.Rows[Jcount][0].ToString()); if (XMLFileType.Equals(Constants.CreateXmlFor.SrcXmlFile)) { ChildNode.SetAttribute("value", DtXMlData.Rows[Jcount][1].ToString()); } else { ChildNode.SetAttribute("value", DtXMlData.Rows[Jcount][2].ToString()); } XMLDoc.DocumentElement.AppendChild(ChildNode); } XMLDoc.Save(XmlFilePath); RetVal = "true"; } else { RetVal = "false" + Constants.Delimiters.ParamDelimiter + Constants.XLSImportMessage.ErrorCreateXMLTemplate.ToString(); } } else { RetVal = "false" + Constants.Delimiters.ParamDelimiter + Constants.XLSImportMessage.XMLTempNotExist.ToString(); } } else { RetVal = "false" + Constants.Delimiters.ParamDelimiter + Constants.XLSImportMessage.LanguageNotExist.ToString(); } return RetVal; }