// #region Methods //Method for checking login authentication and getting user information public LoginSessionDetails getLoginInfo(LoginModels objLogOnModel) { try { XElement LOGXML = null; xdoc = DBXML.USERMAST_g(0, objLogOnModel.UserName.Trim(), objLogOnModel.password.Trim(), 0, LOGXML); DataTable dt = SqlExe.GetDT(xdoc); LoginSessionDetails lst = new LoginSessionDetails(); lst = dt != null && dt.Rows.Count > 0 ? dt.AsEnumerable().Select(s => new LoginSessionDetails { USERID = s.Field <Int64>("USERID"), LOGINID = s.Field <string>("LOGINID"), Email = s.Field <string>("Email"), FNAME = s.Field <string>("FNAME"), MNAME = s.Field <string>("MNAME"), LNAME = s.Field <string>("LNAME"), SVRKEY = s.Field <string>("SVRKEY"), SVRDATE = s.Field <DateTime>("SVRDATE"), ISADMIN = Convert.ToInt32(s.Field <bool>("ISADMIN")) == 1 ? true : false }).ToList().FirstOrDefault() : null; return(lst); } catch (Exception ex) { throw ex; } }
public async Task <CompanyMaster> getComapnyDtl(int COMPID) { try { CompanyMaster obj = new CompanyMaster(); Xdoc = DBXML.CLIENTCONNECTION_h(COMPID, 0); dt = SqlExev2.GetDT(Xdoc, dbConnectionString); obj = (from row in dt.AsEnumerable() select new CompanyMaster { CompName = row.Field <string>("compName"), ServerName = row.Field <string>("serverName"), AuthType = row.Field <string>("AuthType"), UserName = row.Field <string>("userName"), PASSWORD = row.Field <string>("PASSWORD"), DatabaseName = row.Field <string>("databaseName") //isActive = row.Field<string>("isActive"), //createdOn = row.Field<string>("createdOn"), //ceatedBy = row.Field<string>("ceatedBy"), }).FirstOrDefault(); return(await Task.Factory.StartNew(() => obj)); //return obj; } catch (Exception ex) { throw; } }
public Result.Result Save(COUNTRYMAST obj, int USERID, XElement LOGXML = null) { try { xdoc = DBXML.COUNTRYMAST_c(obj.IFLAG, obj.COUNTRYID, obj.COUNTRYCODE, obj.SHORTNAME, obj.COUNTRYNAME1, obj.ISACTIVE, USERID, LOGXML); return(ReadBIErrors(Convert.ToString(SqlExe.GetXml(xdoc)))); } catch (Exception ex) { throw ex; } }
public Result.Result Save(List <ProcessPayslip> objList, int USERID, int COMPID, XElement LOGXML = null) { try { xdoc = DBXML.PROCESSPAYSLIP_c("I", COMPID, objList != null ? objList.FirstOrDefault().EMPID:0, CreateTransXMl(objList), USERID, LOGXML); return(ReadBIErrors(Convert.ToString(SqlExe.GetXml(xdoc)))); } catch (Exception ex) { throw ex; } }
public List <Company> getCompany(int COMPID, string COMPCODE, string COMPNAME, string DESC, int USERID, XElement LOGXML = null) { try { xdoc = DBXML.COMPANY_g(COMPID, COMPCODE, COMPNAME, DESC, USERID, LOGXML); DataTable dt = SqlExe.GetDT(xdoc); List <Company> dbresult = dt != null ? (from s in dt.AsEnumerable() select new Company { COMPID = s.Field <int>("COMPID"), COMPCODE = s.Field <string>("COMPCODE"), COMPNAME = s.Field <string>("COMPNAME"), ADDR1COMPLEXNAME = s.Field <string>("ADDR1COMPLEXNAME"), ADDR1STREETNO = s.Field <string>("ADDR1STREETNO"), ADDR1STREETNAME = s.Field <string>("ADDR1STREETNAME"), ADDR1POSTALCODE = s.Field <string>("ADDR1POSTALCODE"), ADDR1COUNTRYNAME = s.Field <string>("ADDR1COUNTRYNAME"), ADDR1STATENAME = s.Field <string>("ADDR1STATENAME"), ADDR1CITYNAME = s.Field <string>("ADDR1CITYNAME"), ADDR2SAMEASADDR1 = s.Field <bool>("ADDR2SAMEASADDR1"), ADDR2COMPLEXNAME = s.Field <string>("ADDR2COMPLEXNAME"), ADDR2STREETNO = s.Field <string>("ADDR2STREETNO"), ADDR2STREETNAME = s.Field <string>("ADDR2STREETNAME"), ADDR2POSTALCODE = s.Field <string>("ADDR2POSTALCODE"), ADDR2COUNTRYNAME = s.Field <string>("ADDR2COUNTRYNAME"), ADDR2STATENAME = s.Field <string>("ADDR2STATENAME"), ADDR2CITYNAME = s.Field <string>("ADDR2CITYNAME"), PRIMARYPHONE = s.Field <string>("PRIMARYPHONE"), SECONDARYPHONE = s.Field <string>("SECONDARYPHONE"), FAX = s.Field <string>("FAX"), EMAILID = s.Field <string>("EMAILID"), WEBSITE = s.Field <string>("WEBSITE"), ESTABLISHEDIN = s.Field <DateTime>("ESTABLISHEDIN"), MANPOWERWORKING = s.Field <int>("MANPOWERWORKING"), REGNO = s.Field <string>("REGNO"), PROCESSMONTHLY = s.Field <bool>("PROCESSMONTHLY"), MONTHSINTAXYEAR = s.Field <int>("MONTHSINTAXYEAR"), FIRSTMONTHENDDATE = s.Field <DateTime>("FIRSTMONTHENDDATE"), STARTINGMONTH = s.Field <int>("STARTINGMONTH"), ISACTIVE = s.Field <bool>("ISACTIVE"), MONTHID = s.Field <int>("MONTHID"), MONTHENDDATE = s.Field <DateTime>("MONTHENDDATE").ToString("dd-MMM-yyyy"), }).ToList() : null; return(dbresult); } catch (Exception ex) { throw ex; } }
public List <ProcessPayslip> getEmpCurrentPaySlip(Int64 EMPID, Int64 COMPID, int USERID, XElement LOGXML = null) { try { xdoc = DBXML.PROCESSPAYSLIP_g(EMPID, COMPID, USERID, LOGXML); DataTable dt = SqlExe.GetDT(xdoc); List <ProcessPayslip> dbresult = dt != null ? (from s in dt.AsEnumerable() select new ProcessPayslip { EMPCODE = s.Field <string>("EMPCODE"), FIRSTNAME = s.Field <string>("FIRSTNAME"), LASTNAME = s.Field <string>("LASTNAME"), MAPPINGID = s.Field <Int64>("MAPPINGID"), HEADID = s.Field <Int64>("HEADID"), EMPID = s.Field <Int64>("EMPID"), CALSEQUENCE = s.Field <int>("CALSEQUENCE"), MAPAMOUNT = s.Field <decimal>("MAPAMOUNT"), HEADCODE = s.Field <string>("HEADCODE"), HEADDESC = s.Field <string>("HEADDESC"), TRANSACTIONTYPE = s.Field <int>("TRANSACTIONTYPE"), TRANSACTIONTYPEDESC = s.Field <string>("TRANSACTIONTYPEDESC"), IsCalculation = s.Field <bool>("IsCalculation"), ISAFFECTNATIONALPAY = s.Field <bool>("ISAFFECTNATIONALPAY"), ISAFFECTPAYSLIP = s.Field <bool>("ISAFFECTPAYSLIP"), PRINTONPS = s.Field <bool>("PRINTONPS"), TYPEOFINPUTID = s.Field <int>("TYPEOFINPUTID"), TYPEOFINPUTDESC = s.Field <string>("TYPEOFINPUTDESC"), RATEID = s.Field <int>("RATEID"), RATEDESC = s.Field <string>("RATEDESC"), PERIODID = s.Field <int>("PERIODID"), PERIODTRANS = s.Field <int>("PERIODTRANS"), PROCESSID = s.Field <Int64>("PROCESSID"), QTY = s.Field <decimal>("QTY"), RATE = s.Field <decimal>("RATE"), AMOUNT = s.Field <decimal>("AMOUNT"), ISOVERRIDE = s.Field <bool>("ISOVERRIDE"), REFERENCE = s.Field <string>("REFERENCE"), ISPROCESSED = s.Field <bool>("ISPROCESSED"), ISCLOSED = s.Field <bool>("ISCLOSED"), TOTALGROSSINCOME = s.Field <decimal>("TOTALGROSSINCOME"), TOTALDEDUCTION = s.Field <decimal>("TOTALDEDUCTION"), NETPAY = s.Field <decimal>("NETPAY"), }).ToList() : null; return(dbresult); } catch (Exception ex) { throw ex; } }
public async Task <string> getComapnyConnectionstr(int COMPID) { try { CompanyMaster obj = new CompanyMaster(); Xdoc = DBXML.CLIENTCONNECTION_h(COMPID, 0); dt = SqlExev2.GetDT(Xdoc, dbConnectionString); obj = (from row in dt.AsEnumerable() select new CompanyMaster { CompName = row.Field <string>("compName"), ServerName = row.Field <string>("serverName"), AuthType = row.Field <string>("AuthType"), UserName = row.Field <string>("userName"), PASSWORD = row.Field <string>("PASSWORD"), DatabaseName = row.Field <string>("databaseName") }).FirstOrDefault(); string connectionString = ""; if (obj != null) { string connetion = ""; if (obj.AuthType == "SQL Server Authentication") { connetion = "Data Source=" + obj.ServerName + ";Initial Catalog=" + obj.DatabaseName + ";User ID=" + obj.UserName + ";Password="******";"; } else { connetion = "Data Source=" + obj.ServerName + ";Initial Catalog=" + obj.DatabaseName + ";Integrated Security=true;"; } connectionString = connetion; } return(await Task.Factory.StartNew(() => connectionString)); //return obj; } catch (Exception ex) { throw; } }
public List <Company> getPayFrequency(int COMPID, int USERID, XElement LOGXML = null) { try { xdoc = DBXML.PAYFREQUENCY_g(COMPID, 0, 0, "", USERID, LOGXML); DataTable dt = SqlExe.GetDT(xdoc); List <Company> dbresult = dt != null ? (from s in dt.AsEnumerable() select new Company { MID = s.Field <int>("MID"), PROCESSMONTHLY = s.Field <bool>("PROCESSMONTHLY"), STARTINGMONTH = s.Field <int>("STARTINGMONTH"), FIRSTMONTHENDDATE = s.Field <DateTime>("FIRSTMONTHENDDATE"), MONTHSINTAXYEAR = s.Field <int>("MONTHSINTAXYEAR"), COMPID = s.Field <int>("COMPID"), ISACTIVE = s.Field <bool>("MISACTIVE"), ISCLOSED = s.Field <bool>("MISCLOSED"), PayFreqTransList = s.Field <string>("TRANSDETAILS") != null ? (from m in XDocument.Parse(s.Field <string>("TRANSDETAILS")).Elements("TRANSACTION").Elements("TRANS") select new FREQUENCYPERIODTRANS { TID = m.Attributes("TID").FirstOrDefault().Value == null ? 0 : Convert.ToInt32(m.Attributes("TID").FirstOrDefault().Value), MONTHID = m.Attributes("MONTHID").FirstOrDefault().Value == null ? 0 : Convert.ToInt32(m.Attributes("MONTHID").FirstOrDefault().Value), MONTHENDDATE = Convert.ToDateTime(m.Attributes("MONTHENDDATE").FirstOrDefault().Value), STATUS = m.Attributes("STATUS").FirstOrDefault().Value == null ? "" : Convert.ToString(m.Attributes("STATUS").FirstOrDefault().Value), ISACTIVE = Convert.ToInt32(m.Attributes("ISACTIVE").FirstOrDefault().Value) == 0 ? false : true, ISCLOSED = Convert.ToInt32(m.Attributes("ISCLOSED").FirstOrDefault().Value) == 0 ? false : true, ISCURRENT = Convert.ToInt32(m.Attributes("ISCURRENT").FirstOrDefault().Value) == 0 ? false : true, }).ToList() : null, }).ToList() : null; return(dbresult); } catch (Exception ex) { throw ex; } }
public Result.Result Save(Company obj, int USERID, XElement LOGXML = null) { try { xdoc = DBXML.COMPANY_c(obj.IFLAG, obj.COMPID, obj.COMPCODE == null ? "" : obj.COMPCODE, obj.COMPNAME == null ? "" : obj.COMPNAME, obj.ADDR1COMPLEXNAME == null ? "" : obj.ADDR1COMPLEXNAME, obj.ADDR1STREETNO == null ? "" : obj.ADDR1STREETNO, obj.ADDR1STREETNAME == null ? "" : obj.ADDR1STREETNAME, obj.ADDR1POSTALCODE == null ? "" : obj.ADDR1POSTALCODE, obj.ADDR1COUNTRYNAME == null ? "" : obj.ADDR1COUNTRYNAME, obj.ADDR1STATENAME == null ? "" : obj.ADDR1STATENAME, obj.ADDR1CITYNAME == null ? "" : obj.ADDR1CITYNAME, obj.ADDR2SAMEASADDR1, obj.ADDR2COMPLEXNAME == null ? "" : obj.ADDR2COMPLEXNAME, obj.ADDR2STREETNO == null ? "" : obj.ADDR2STREETNO, obj.ADDR2STREETNAME == null ? "" : obj.ADDR2STREETNAME, obj.ADDR2POSTALCODE == null ? "" : obj.ADDR2POSTALCODE, obj.ADDR2COUNTRYNAME == null ? "" : obj.ADDR2COUNTRYNAME, obj.ADDR2STATENAME == null ? "" : obj.ADDR2STATENAME, obj.ADDR2CITYNAME == null ? "" : obj.ADDR2CITYNAME, obj.PRIMARYPHONE == null ? "" : obj.PRIMARYPHONE, obj.SECONDARYPHONE == null ? "" : obj.SECONDARYPHONE, obj.FAX == null ? "" : obj.FAX, obj.EMAILID == null ? "" : obj.EMAILID, obj.WEBSITE == null ? "" : obj.WEBSITE, obj.ESTABLISHEDIN, obj.MANPOWERWORKING, obj.REGNO == null ? "" : obj.REGNO, obj.ISACTIVE, obj.PROCESSMONTHLY, obj.STARTINGMONTH, obj.MONTHSINTAXYEAR, obj.FIRSTMONTHENDDATE, USERID, LOGXML); return(ReadBIErrors(Convert.ToString(SqlExe.GetXml(xdoc)))); } catch (Exception ex) { throw ex; } }
public List <COUNTRYMAST> getCountry(int COUNTRYID, string COUNTRCODE, string COUNTRNAME, string DESC, int USERID, XElement LOGXML = null) { try { xdoc = DBXML.COUNTRYMAST_g(COUNTRYID, COUNTRCODE, COUNTRNAME, USERID, LOGXML); DataTable dt = SqlExe.GetDT(xdoc); List <COUNTRYMAST> dbresult = dt != null ? (from s in dt.AsEnumerable() select new COUNTRYMAST { COUNTRYID = s.Field <int>("COUNTRYID"), COUNTRYNAME = s.Field <string>("COUNTRYNAME"), COUNTRYCODE = s.Field <string>("COUNTRYCODE"), SHORTNAME = s.Field <string>("SHORTNAME"), ISACTIVE = s.Field <bool>("ISACTIVE") }).ToList() : null; return(dbresult); } catch (Exception ex) { throw ex; } }
private void Backup(string rootPath) { System.IO.Directory.CreateDirectory(Path.Combine(rootPath, "Backup")); System.IO.Directory.CreateDirectory(Path.Combine(rootPath, "Backup/DataBase")); System.IO.Directory.CreateDirectory(Path.Combine(rootPath, "Backup/Modules")); System.IO.Directory.CreateDirectory(Path.Combine(rootPath, "Backup/Terrain Sources")); if (File.Exists(Path.Combine(rootPath, "Backup/terrains.xml"))) { /*if backups are already there, the game's already been modded to some extent * backing up now would back up mods, meaning you can break the backup by running * the compiler twice) */ debugLog.Add("Skipping backup"); return; } debugLog.Add("Create debug dirs"); TerrainsXML.Save(Path.Combine(rootPath, "Backup/terrains.xml")); ModulesXML.Save(Path.Combine(rootPath, "Backup/eventModules.xml")); DBXML.Save(Path.Combine(rootPath, "Backup/database.xml")); debugLog.Add("Backup XML collections"); foreach (XMLStore x in Terrains) { x.data.Save(Path.Combine(rootPath, "Backup/Terrain Sources/" + x.fileName)); } foreach (XMLStore x in Modules) { x.data.Save(Path.Combine(rootPath, "Backup/" + x.fileName)); } foreach (XMLStore x in DB) { x.data.Save(Path.Combine(rootPath, "Backup/DataBase/" + x.fileName)); } debugLog.Add("Backup files"); }
public List <string> ParseData(List <string> mods, string path, string strictParam, string inferFromProto, string defaultTo) { //clear values TerrainsXML = null; ModulesXML = null; DBXML = null; Terrains = new List <XMLStore>(); Modules = new List <XMLStore>(); DB = new List <XMLStore>(); ProtoDB = new List <XElement>(); //set behavior bool StrictParamParse = strictParam == "Strict paramteter parsing"; bool InferFromProto = inferFromProto == "Infer from prototype"; RootPath = path; debugLog.Clear(); //load default data ReadXML(RootPath); //load mod data foreach (string dir in mods) { ReadXML(Path.Combine(path, dir)); } //copy scripts (overwrite existing, a mod should only ever overwrite the stock files, and even then only to add "partial") foreach (string dir in mods) { var dataPath = Path.Combine(path, dir); var copyTo = Path.Combine(RootPath, "Scripts"); dataPath = Path.Combine(dataPath, "Scripts"); try { foreach (string f in Directory.GetFiles(dataPath)) { string fileName = Path.GetFileName(f); string destFile = Path.Combine(copyTo, fileName); File.Copy(f, destFile, true); } } catch (FileNotFoundException) {//not an error, per se, just not used debugLog.Add("no scripts in mod"); } } //compile if (debugLog.Any(p => p.Contains("##error"))) { debugLog.Add("Compile aborted"); return(debugLog); } else { string[] lines; /*When saving, check if the XML is just a node (most data files have no header), then * save, then load as string and resave to strip them of BOM, so the game doesn't * throw it's toys out of the pram. */ XmlWriterSettings settings = new XmlWriterSettings { OmitXmlDeclaration = true, Indent = true, IndentChars = " " }; if (DBXML.Declaration != null) { DBXML.Save(Path.Combine(path, "database.xml")); } else { DBXML.Root.Save(Path.Combine(path, "database.xml")); } if (TerrainsXML.Declaration != null) { TerrainsXML.Save(Path.Combine(path, "terrains.xml")); } else { TerrainsXML.Root.Save(Path.Combine(path, "terrains.xml")); } if (ModulesXML.Declaration != null) { ModulesXML.Save(Path.Combine(path, "eventModules.xml")); } else { ModulesXML.Root.Save(Path.Combine(path, "eventModules.xml")); } lines = File.ReadAllLines(Path.Combine(path, "terrains.xml")); File.WriteAllLines(Path.Combine(path, "terrains.xml"), lines); lines = File.ReadAllLines(Path.Combine(path, "eventModules.xml")); File.WriteAllLines(Path.Combine(path, "eventModules.xml"), lines); lines = File.ReadAllLines(Path.Combine(path, "database.xml")); File.WriteAllLines(Path.Combine(path, "database.xml"), lines); foreach (XMLStore x in Terrains) { if (x.data.Declaration != null) { x.data.Save(Path.Combine(path, "Terrain Sources/" + x.fileName)); lines = File.ReadAllLines(Path.Combine(path, "Terrain Sources/" + x.fileName)); File.WriteAllLines(Path.Combine(path, "Terrain Sources/" + x.fileName), lines); } else { using (XmlWriter xw = XmlWriter.Create(Path.Combine(path, "Terrain Sources/" + x.fileName), settings)) { x.data.Save(xw); } lines = File.ReadAllLines(Path.Combine(path, "Terrain Sources/" + x.fileName)); File.WriteAllLines(Path.Combine(path, "Terrain Sources/" + x.fileName), lines); } } foreach (XMLStore x in Modules) { if (x.data.Declaration != null) { x.data.Save(Path.Combine(path, x.fileName)); lines = File.ReadAllLines(Path.Combine(path, x.fileName)); File.WriteAllLines(Path.Combine(path, x.fileName), lines); } else { using (XmlWriter xw = XmlWriter.Create(Path.Combine(path, x.fileName), settings)) { x.data.Save(xw); } lines = File.ReadAllLines(Path.Combine(path, x.fileName)); File.WriteAllLines(Path.Combine(path, x.fileName), lines); } } foreach (XMLStore x in DB) { if (x.data.Declaration != null) { var foo = x.data.Declaration; x.data.Save(Path.Combine(path, "DataBase/" + x.fileName)); lines = File.ReadAllLines(Path.Combine(path, "DataBase/" + x.fileName)); File.WriteAllLines(Path.Combine(path, "DataBase/" + x.fileName), lines); } else { using (XmlWriter xw = XmlWriter.Create(Path.Combine(path, "DataBase/" + x.fileName), settings)) { x.data.Save(xw); } lines = File.ReadAllLines(Path.Combine(path, "DataBase/" + x.fileName)); File.WriteAllLines(Path.Combine(path, "DataBase/" + x.fileName), lines); } } debugLog.Add("Files compiled"); debugLog.Add("Mod compile complete"); } return(debugLog); }
private void ReadXML(string dataPath, bool strictParamParse = false, bool inferFromProto = false, string defaultTo = "Default to merge")//path is root folder, either of game or of mod { //set paths for current dir (StreamingAssets, or @mod string TerrainsPath = Path.Combine(dataPath, "Terrain Sources"); //for some reason,terrains string ModulesPath = Path.Combine(dataPath, ""); //and DB are listed as filenames string DBPath = Path.Combine(dataPath, "DataBase"); //but modules as full paths. if (TerrainsXML == null && ModulesXML == null && DBXML == null) { /*LOAD DEFAULT ARRAYS*/ try { TerrainsXML = XDocument.Load($"{Path.Combine(dataPath, "terrains.xml")}"); ModulesXML = XDocument.Load($"{Path.Combine(dataPath, "eventModules.xml")}"); DBXML = XDocument.Load($"{Path.Combine(dataPath, "database.xml")}"); } catch (FileNotFoundException e) { //if files not found, notify user, and abort MessageBox.Show(e.Message); return; } /*LOAD DEFAULT FILES*/ foreach (XElement x in TerrainsXML.Element("TERRAINS").Elements()) { try { string name = x.Attribute("name").Value; Terrains.Add(new XMLStore(name, XDocument.Load($"{Path.Combine(TerrainsPath, name)}"))); debugLog.Add("load " + name); } catch (FileNotFoundException e) { debugLog.Add("##error: " + e.Message); } catch { debugLog.Add(TerrainsPath); debugLog.Add("##error in terrains.xml : element read error"); } } foreach (XElement x in ModulesXML.Element("ROOT").Elements()) { try { string name = x.Attribute("path").Value; if (!name.Contains("DEBUG")) { Modules.Add(new XMLStore(name, XDocument.Load($"{Path.Combine(ModulesPath, name)}"))); debugLog.Add("load " + name); } else { debugLog.Add("skip " + name); } } catch (FileNotFoundException e) { debugLog.Add("##error: " + e.Message); } catch { debugLog.Add(TerrainsPath); debugLog.Add("##error in eventModules.xml : element read error"); } } foreach (XElement x in DBXML.Element("DATA_BASE").Elements()) { try { string name = x.Attribute("name").Value; if (!name.Contains("Prototype")) { DB.Add(new XMLStore(name, XDocument.Load($"{Path.Combine(DBPath, name)}"))); debugLog.Add("load " + name); } else { //crawl through /DataBase/Proto for potential arrays XDocument newFile = XDocument.Load($"{Path.Combine(DBPath, name)}"); foreach (XElement y in newFile.Root.Elements()) { getArrays(y); } } } catch (FileNotFoundException e) { debugLog.Add("##error: " + e.Message); } catch { debugLog.Add(DBPath); debugLog.Add("##error in database.xml : name = null"); } } //back up files before altering Backup(dataPath); return; } else { /*LOAD MOD DATA*/ /*First load the index files from the mod folders, (if they're missing, log and continue). * Then read the indexes, then start reading new files, merging or adding to XMLStore * and main index as you go. */ XDocument newTerrainsXML = null; XDocument newModulesXML = null; XDocument newDBXML = null; debugLog.Add("Loading " + dataPath); try { newTerrainsXML = XDocument.Load($"{Path.Combine(dataPath, "terrains.xml")}"); debugLog.Add("terrains.xml loaded"); foreach (XElement x in newTerrainsXML.Root.Elements()) { string fileName; XDocument newFile; try {//get file, if it exists, else log and skip fileName = x.Attribute("name").Value; newFile = XDocument.Load($"{Path.Combine(TerrainsPath, fileName)}"); debugLog.Add("load " + fileName); } catch (FileNotFoundException e) { debugLog.Add("##error: " + e.Message + ", skipping"); continue; } catch { debugLog.Add(TerrainsPath); debugLog.Add("##error in terrains.xml : element read error"); continue; } if (!TerrainsXML.Root.Elements().Any(p => p.Attribute("name").Value != fileName)) {//if data files are not already listed, add them to the index and load file to file list XElement newEntry = new XElement("DEFINITION"); newEntry.SetAttributeValue("name", x.Attribute("name").Value); TerrainsXML.Root.Add(newEntry); Terrains.Add(new XMLStore(fileName, newFile)); } else {//else, update existing XMLStore oldFile = Terrains.Where(p => p.fileName == fileName).FirstOrDefault(); //note, oldfile and newfile are disparate object types List <string> output = oldFile.Update(newFile, strictParamParse, inferFromProto, defaultTo, ProtoDB); debugLog.AddRange(output); } } } catch (FileNotFoundException) {//not an error, per se, just not used debugLog.Add("terrains.xml not found"); } try { newModulesXML = XDocument.Load($"{Path.Combine(dataPath, "eventModules.xml")}"); debugLog.Add("eventModules.xml loaded"); foreach (XElement x in newModulesXML.Root.Elements()) { string fileName; XDocument newFile; try {//get file, if it exists, else log and skip fileName = x.Attribute("path").Value; newFile = XDocument.Load($"{Path.Combine(ModulesPath, fileName)}"); debugLog.Add("load " + fileName); } catch (FileNotFoundException e) { debugLog.Add("##error: " + e.Message + ", skipping"); continue; } catch { debugLog.Add(ModulesPath); debugLog.Add("##error in eventModules.xml : element read error"); continue; } if (!ModulesXML.Root.Elements().Any(p => p.Attribute("path").Value == fileName)) {//if data files are not already listed, add them to the index and load file to file list XElement newEntry = new XElement("FILE"); newEntry.SetAttributeValue("path", x.Attribute("path").Value); ModulesXML.Root.Add(newEntry); Modules.Add(new XMLStore(fileName, newFile)); } else {//else, update existing XMLStore oldFile = Modules.Where(p => p.fileName == fileName).FirstOrDefault(); //note, oldfile and newfile are disparate object types List <string> output = oldFile.Update(newFile, strictParamParse, inferFromProto, defaultTo, ProtoDB); debugLog.AddRange(output); } } } catch (FileNotFoundException) {//not an error, per se, just not used debugLog.Add("eventModules.xml not found"); } try { newDBXML = XDocument.Load($"{Path.Combine(dataPath, "database.xml")}"); debugLog.Add("database.xml loaded"); foreach (XElement x in newDBXML.Root.Elements()) { string fileName; XDocument newFile; try {//get file, if it exists, else log and skip fileName = x.Attribute("name").Value; newFile = XDocument.Load($"{Path.Combine(DBPath, fileName)}"); debugLog.Add("load " + fileName); } catch (FileNotFoundException e) { debugLog.Add("##error: " + e.Message + ", skipping"); continue; } catch { debugLog.Add(ModulesPath); debugLog.Add("##error in database.xml : element read error"); continue; } if (!DBXML.Root.Elements().Any(p => p.Attribute("name").Value != fileName)) {//if data files are not already listed, add them to the index and load file to file list XElement newEntry = new XElement("DATA"); newEntry.SetAttributeValue("name", x.Attribute("name").Value); ModulesXML.Root.Add(newEntry); Modules.Add(new XMLStore(fileName, newFile)); } else {//else, update existing XMLStore oldFile = DB.Where(p => p.fileName == fileName).FirstOrDefault(); //note, oldfile and newfile are disparate object types List <string> output = oldFile.Update(newFile, strictParamParse, inferFromProto, defaultTo, ProtoDB); debugLog.AddRange(output); } } } catch (FileNotFoundException) {//not an error, per se, just not used debugLog.Add("database.xml not found"); } } }