示例#1
0
        public ContractXmlModel GetContract(string filePath)
        {
            try
            {
                XDocument xdoc = XDocument.Load(filePath);

                var xExportElement = xdoc.Element(GetFullElementNameXmlns("export"));
                var xContract      = xExportElement.Element(GetFullElementNameXmlns(CONTRACT));
                var version        = xContract.Attribute("schemeVersion").Value;
                var id             = GetNodeValue(xContract, ID);
                var href           = GetNodeValue(xContract, HREF);
                var customer       = GetCustomer(xContract, version);
                var supplier       = GetSupplier(xContract, version);

                var contract = new ContractXmlModel()
                {
                    Id       = id,
                    Href     = href,
                    Customer = customer,
                    Supplier = supplier
                };
                return(contract);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            return(new ContractXmlModel());
        }
示例#2
0
        public static Contract ConvertContract(ContractXmlModel model)
        {
            Contract newModel = new Contract();

            newModel.Id         = model.Id;
            newModel.Href       = model.Href;
            newModel.SupplierId = model.Supplier.Inn;
            newModel.CustomerId = model.Customer.Inn;
            newModel.Supplier   = ConvertSupplier(model.Supplier);
            newModel.Customer   = ConvertCustomer(model.Customer);
            return(newModel);
        }