public void AddRequest(GuestRequest req) { if (DataSource.guestRequests.Any(item => req.GuestRequestKey == item.GuestRequestKey)) { throw new DuplicateWaitObjectException("This key already exists, DAL error"); } DataSource.guestRequests.Add(req.Clone()); DataSource_XML.saveConf(); DataSource_XML.SaveToXML(DataSource.guestRequests, guestRequestPath); }
public void AddHostingUnit(HostingUnit hostingUnit) { hostingUnit.HostingUnitKey = Configuration.HostingUnitKey++; if (DataSource.hostingUnits.Any(item => hostingUnit.HostingUnitKey == item.HostingUnitKey)) { throw new DuplicateWaitObjectException("This key already exists, DAL error"); } DataSource.hostingUnits.Add(hostingUnit.Clone()); DataSource_XML.saveConf(); DataSource_XML.SaveToXML(DataSource.hostingUnits, hostingUnitPath); }
internal Dal_XML_imp() { finishBankLoad = false; worker.DoWork += worker_DoWork; worker.RunWorkerAsync(); if (!File.Exists(confPath)) { DataSource_XML.saveConf(); } else { confRoot = XElement.Load(confPath); Configuration.GuestRequestKey = Int32.Parse(confRoot.Element("GuestRequestKey").Value); Configuration.HostingUnitKey = Int32.Parse(confRoot.Element("HostingUnitKey").Value); Configuration.OrderKey = Int32.Parse(confRoot.Element("OrderKey").Value); Configuration.Commission = Int32.Parse(confRoot.Element("Commission").Value); Configuration.Mail = new MailAddress(confRoot.Element("Email").Value); Configuration.Password = confRoot.Element("Password").Value; } if (!File.Exists(guestRequestPath)) { DataSource_XML.SaveToXML(new List <GuestRequest>(), guestRequestPath); } DataSource.guestRequests = DataSource_XML.LoadFromXML <List <GuestRequest> >(guestRequestPath); if (!File.Exists(hostPath)) { DataSource_XML.SaveToXML(new List <Host>(), hostPath); } DataSource.hosts = DataSource_XML.LoadFromXML <List <Host> >(hostPath); if (!File.Exists(hostingUnitPath)) { DataSource_XML.SaveToXML(new List <HostingUnit>(), hostingUnitPath); } DataSource.hostingUnits = DataSource_XML.LoadFromXML <List <HostingUnit> >(hostingUnitPath); if (!File.Exists(orderPath)) { orderRoot = new XElement("order"); orderRoot.Save(orderPath); } orderRoot = XElement.Load(orderPath); }
public void AddOrder(Order order) { var exist = (from item in orderRoot.Elements() where Int32.Parse(item.Element("OrderKey").Value) == order.OrderKey select item).Any(); if (exist) { throw new DuplicateWaitObjectException("This key already exists, DAL error"); } XElement ord = new XElement("Order"); ord.Add(new XElement("HostingUnitKey", order.HostingUnitKey), new XElement("GuestRequestKey", order.GuestRequestKey), new XElement("OrderKey", order.OrderKey), new XElement("Status", order.Status), new XElement("ImageStatus", order.ImageStatus), new XElement("CreateDate", order.CreateDate), new XElement("OrderDate", order.OrderDate)); DataSource_XML.saveConf(); orderRoot.Add(ord); orderRoot.Save(orderPath); }