public static bool UpdateUsers(XElement users) { string filePath = Path.Combine(CommonFunctions.GetTempPath(), "users.xml"); users.Save(filePath); RemoteAccess.PutToServer(filePath); return(true); }
public static bool UpdateCompanyData(CompanyData companyData) { try { XElement xmlCompanyData = companyData.Serialize(); string filePath = Path.Combine(CommonFunctions.GetTempPath(), $"{companyData.Code}.xml"); xmlCompanyData.Save(filePath); RemoteAccess.PutToServer("companies", filePath); XElement companies; try { companies = RemoteAccess.GetXmlFromServer("companies.xml"); } catch { companies = new XElement("companies"); } XElement company = companies.Elements().FirstOrDefault(x => x.GetAttribute("code").IsStringEqual(companyData.Code)); if (company != null) { company.Remove(); } XElement factorSheet = xmlCompanyData.Element("factorsheet"); if (factorSheet != null) { factorSheet.Remove(); } companies.Add(xmlCompanyData); filePath = Path.Combine(CommonFunctions.GetTempPath(), "companies.xml"); companies.Save(filePath); RemoteAccess.PutToServer(filePath); return(true); } catch { return(false); } }
public static bool UpdateUserData(UserData userData) { try { XElement xmlUserData = userData.Serialize(); string filePath = Path.Combine(CommonFunctions.GetTempPath(), $"{userData.LoginId}.xml"); xmlUserData.Save(filePath); RemoteAccess.PutToServer("users", filePath); XElement users; try { users = RemoteAccess.GetXmlFromServer("users.xml"); } catch { users = new XElement("users"); } XElement user = users.Elements().FirstOrDefault(x => x.GetAttribute("loginid").IsStringEqual(userData.LoginId)); if (user != null) { user.Remove(); } users.Add(xmlUserData); filePath = Path.Combine(CommonFunctions.GetTempPath(), "users.xml"); users.Save(filePath); RemoteAccess.PutToServer(filePath); return(true); } catch { return(false); } }