Example #1
0
        private static void WalkTxnDeletedRet(XmlNode TxnDeletedRet)
        {
            if (TxnDeletedRet == null)
            {
                return;
            }

            //Go through all the elements of TxnDeletedRet
            //Get value of TxnDelType
            string TxnDelType = TxnDeletedRet.SelectSingleNode("./TxnDelType").InnerText;
            //Get value of TxnID
            string TxnID = TxnDeletedRet.SelectSingleNode("./TxnID").InnerText;
            //Get value of TimeCreated
            string TimeCreated = TxnDeletedRet.SelectSingleNode("./TimeCreated").InnerText;
            //Get value of TimeDeleted
            string TimeDeleted = TxnDeletedRet.SelectSingleNode("./TimeDeleted").InnerText;

            //Get value of RefNumber
            if (TxnDeletedRet.SelectSingleNode("./RefNumber") != null)
            {
                string RefNumber = TxnDeletedRet.SelectSingleNode("./RefNumber").InnerText;
            }

            RotoTrackDb     db     = new RotoTrackDb();
            List <BillLine> blList = db.BillLines.Where(f => f.BillTxnId == TxnID).ToList();

            foreach (BillLine bl in blList.ToList())
            {
                db.BillLines.Remove(bl);
            }
            db.SaveChanges();
        }
        private static void WalkCustomerRetForAdd(XmlNode CustomerRet)
        {
            if (CustomerRet == null)
            {
                return;
            }

            RotoTrackDb db = new RotoTrackDb();

            string ListID       = CustomerRet.SelectSingleNode("./ListID").InnerText;
            string EditSequence = CustomerRet.SelectSingleNode("./EditSequence").InnerText;
            string Name         = CustomerRet.SelectSingleNode("./Name").InnerText;

            if (db.WorkOrders.Any(f => f.WorkOrderNumber == Name))
            {
                WorkOrder wo = db.WorkOrders.First(f => f.WorkOrderNumber == Name);
                wo.QBListId        = ListID;
                wo.QBEditSequence  = EditSequence;
                db.Entry(wo).State = EntityState.Modified;
                if (wo != null)
                {
                    db.SaveChanges();
                }
            }
        }
Example #3
0
        private static Vendor FindOrCreateVendor(RotoTrackDb db, string QBListId, string QBEditSequence, string TimeCreated, string TimeModified, string Name, string IsActive)
        {
            Vendor o = null;

            if (db.Vendors.Any(f => f.QBListId == QBListId))
            {
                o = db.Vendors.First(f => f.QBListId == QBListId);
            }
            else
            {
                o = new Vendor();
                db.Vendors.Add(o);
            }

            o.QBListId       = QBListId;
            o.QBEditSequence = QBEditSequence;
            DateTime createdDate;

            if (DateTime.TryParse(TimeCreated, out createdDate))
            {
                o.TimeCreated = createdDate;
            }
            DateTime modifiedDate;

            if (DateTime.TryParse(TimeModified, out modifiedDate))
            {
                o.TimeModified = modifiedDate;
            }
            o.Name     = Name;
            o.IsActive = (IsActive == "true") ? true : false;

            return(o);
        }
Example #4
0
        private static void WalkClassRet(XmlNode ClassRet)
        {
            if (ClassRet == null) return;

            Area area = null;
            RotoTrackDb db = new RotoTrackDb();

            string ListID = ClassRet.SelectSingleNode("./ListID").InnerText;
            if (db.Areas.Any(a => a.QBListId == ListID))
            {
                area = db.Areas.First(a => a.QBListId == ListID);
            }
            else
            {
                area = new Area();
                db.Areas.Add(area);
            }
            area.QBListId = ListID;

            string Name = ClassRet.SelectSingleNode("./Name").InnerText;
            area.Name = Name;

            string IsActive = "false";
            if (ClassRet.SelectSingleNode("./IsActive") != null)
            {
                IsActive = ClassRet.SelectSingleNode("./IsActive").InnerText;
            }
            area.IsActive = (IsActive == "true") ? true : false;

            if (area != null)
            {
                db.SaveChanges();
            }
        }
Example #5
0
        private static Item FindOrCreateItem(RotoTrackDb db, string QBListId, string QBEditSequence, string TimeCreated, string TimeModified, string Name, string FullName, string IsActive, string ItemType)
        {
            Item o = null;
            if (db.Items.Any(f => f.QBListId == QBListId))
            {
                o = db.Items.First(f => f.QBListId == QBListId);
                db.Entry(o).State = EntityState.Modified;
            }
            else
            {
                o = new Item();
                db.Items.Add(o);
            }

            o.QBListId = QBListId;
            o.QBEditSequence = QBEditSequence;
            DateTime createdDate;
            if (DateTime.TryParse(TimeCreated, out createdDate)) o.TimeCreated = createdDate;
            DateTime modifiedDate;
            if (DateTime.TryParse(TimeModified, out modifiedDate)) o.TimeModified = modifiedDate;
            o.Name = Name;
            o.FullName = FullName;
            o.IsActive = (IsActive == "true") ? true : false;
            o.ItemType = ItemType;

            return o;
        }
        private static void WalkCustomerTypeRetForAdd(XmlNode CustomerTypeRet)
        {
            // Update the QBListID for the newly added BillingInstruction
            if (CustomerTypeRet == null)
            {
                return;
            }

            BillingInstruction bi = null;
            RotoTrackDb        db = new RotoTrackDb();

            string ListID = CustomerTypeRet.SelectSingleNode("./ListID").InnerText;
            string Name   = CustomerTypeRet.SelectSingleNode("./Name").InnerText;

            if (db.BillingInstructions.Any(f => f.Name == Name))
            {
                bi = db.BillingInstructions.First(f => f.Name == Name);
            }
            bi.QBListId = ListID;

            if (bi != null)
            {
                db.SaveChanges();
            }
        }
Example #7
0
        private static void WalkJobTypeRet(XmlNode JobTypeRet)
        {
            if (JobTypeRet == null) return;

            JobType jt = null;
            RotoTrackDb db = new RotoTrackDb();

            string ListID = JobTypeRet.SelectSingleNode("./ListID").InnerText;
            if (db.JobTypes.Any(f => f.QBListId == ListID))
            {
                jt = db.JobTypes.First(f => f.QBListId == ListID);
            }
            else
            {
                jt = new JobType();
                db.JobTypes.Add(jt);
            }
            jt.QBListId = ListID;

            string Name = JobTypeRet.SelectSingleNode("./Name").InnerText;
            jt.Name = Name;

            string IsActive = "false";
            if (JobTypeRet.SelectSingleNode("./IsActive") != null)
            {
                IsActive = JobTypeRet.SelectSingleNode("./IsActive").InnerText;
            }
            jt.IsActive = (IsActive == "true") ? true : false;

            if (jt != null)
            {
                db.SaveChanges();
            }
        }
        public static XmlDocument BuildAddRq(ServiceEntry se, ServiceDetail sd)
        {
            try
            {
                XmlDocument doc = XmlUtils.MakeRequestDocument();
                XmlElement parent = XmlUtils.MakeRequestParentElement(doc);

                RotoTrackDb db = new RotoTrackDb();
                UserProfile u = db.UserProfiles.Find(sd.TechnicianId);
                Vehicle v = db.Vehicles.Find(sd.VehicleId);
                DSR dsr = db.DSRs.Include("WorkOrder").First(f => f.Id == se.DSRId);
                Customer c = db.Customers.Find(dsr.WorkOrder.CustomerId);
                MileageRate mr = db.MileageRates.Find(sd.MileageRateId);
                Area a = db.Areas.Find(u.AreaId);

                XmlElement Rq = doc.CreateElement("VehicleMileageAddRq");
                parent.AppendChild(Rq);

                XmlElement RqType = doc.CreateElement("VehicleMileageAdd");
                Rq.AppendChild(RqType);

                XmlElement VehicleRef = doc.CreateElement("VehicleRef");
                RqType.AppendChild(VehicleRef);
                VehicleRef.AppendChild(XmlUtils.MakeSimpleElem(doc, "ListID", v.QBListId));

                XmlElement CustomerRef = doc.CreateElement("CustomerRef");
                RqType.AppendChild(CustomerRef);
                CustomerRef.AppendChild(XmlUtils.MakeSimpleElem(doc, "ListID", dsr.WorkOrder.QBListId));

                XmlElement ItemRef = doc.CreateElement("ItemRef");
                RqType.AppendChild(ItemRef);
                ItemRef.AppendChild(XmlUtils.MakeSimpleElem(doc, "ListID", mr.QBListId));

                XmlElement ClassRef = doc.CreateElement("ClassRef");
                RqType.AppendChild(ClassRef);
                ClassRef.AppendChild(XmlUtils.MakeSimpleElem(doc, "ListID", a.QBListId));

                RqType.AppendChild(XmlUtils.MakeSimpleElem(doc, "TripStartDate", se.DateWorked.ToString("yyyy-MM-dd")));
                RqType.AppendChild(XmlUtils.MakeSimpleElem(doc, "TripEndDate", se.DateWorked.ToString("yyyy-MM-dd")));
                RqType.AppendChild(XmlUtils.MakeSimpleElem(doc, "TotalMiles", se.Mileage.ToString()));
                string fullName = "";
                if (!string.IsNullOrEmpty(u.FirstName)) fullName += u.FirstName;
                if (!string.IsNullOrEmpty(u.LastName)) fullName += (" " + u.LastName);
                fullName += " guid=";
                fullName += se.GUID;
                RqType.AppendChild(XmlUtils.MakeSimpleElem(doc, "Notes", fullName));
                RqType.AppendChild(XmlUtils.MakeSimpleElem(doc, "BillableStatus", "Billable"));

                return doc;
            }
            catch (Exception e)
            {
                string evLogTxt = "";
                evLogTxt = "Error building vehicle mileage add request! " + e.Message + "\r\n";
                Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + evLogTxt);
                return null;
            }
        }
Example #9
0
 public static void SetLastSyncTime(DateTime lastSync)
 {
     RotoTrackDb db = new RotoTrackDb();
     Config config = db.Configs.First();
     if (config != null)
     {
         config.LastFullRefreshQB = lastSync;
         db.SaveChanges();
     }
 }
Example #10
0
        private static void RemoveExistingLineItems(RotoTrackDb db, string TxnID)
        {
            List <VendorCreditLine> blList = db.VendorCreditLines.Where(f => f.VendorCreditTxnId == TxnID).ToList();

            foreach (VendorCreditLine vcl in blList.ToList())
            {
                db.VendorCreditLines.Remove(vcl);
            }
            db.SaveChanges();
        }
Example #11
0
        private static void RemoveExistingLineItems(RotoTrackDb db, string TxnID)
        {
            List <BillLine> blList = db.BillLines.Where(f => f.BillTxnId == TxnID).ToList();

            foreach (BillLine bl in blList.ToList())
            {
                db.BillLines.Remove(bl);
            }
            db.SaveChanges();
        }
Example #12
0
        public static void SetLastSyncTime(DateTime lastSync)
        {
            RotoTrackDb db     = new RotoTrackDb();
            Config      config = db.Configs.First();

            if (config != null)
            {
                config.LastFullRefreshQB = lastSync;
                db.SaveChanges();
            }
        }
Example #13
0
        private static void WalkVehicleRet(XmlNode VehicleRet)
        {
            if (VehicleRet == null)
            {
                return;
            }

            Vehicle     v  = null;
            RotoTrackDb db = new RotoTrackDb();

            string ListID = VehicleRet.SelectSingleNode("./ListID").InnerText;

            if (db.Vehicles.Any(f => f.QBListId == ListID))
            {
                v = db.Vehicles.First(f => f.QBListId == ListID);
            }
            else
            {
                v = new Vehicle();
                db.Vehicles.Add(v);
            }
            v.QBListId = ListID;

            if (VehicleRet.SelectSingleNode("./Name") != null)
            {
                string Name = VehicleRet.SelectSingleNode("./Name").InnerText;
                v.Name = Name;
            }

            string IsActive = "false";

            if (VehicleRet.SelectSingleNode("./IsActive") != null)
            {
                IsActive = VehicleRet.SelectSingleNode("./IsActive").InnerText;
            }
            v.IsActive = (IsActive == "true") ? true : false;

            if (VehicleRet.SelectSingleNode("./Desc") != null)
            {
                string Desc = VehicleRet.SelectSingleNode("./Desc").InnerText;
                v.Description = Desc;
            }

            if (v != null)
            {
                db.SaveChanges();
            }
        }
Example #14
0
        public static string GetLastSyncTime()
        {
            DateTime lastSync = DateTime.MinValue;
            RotoTrackDb db = new RotoTrackDb();
            Config config = db.Configs.First();
            if (config != null)
            {
                if (config.LastFullRefreshQB != null)
                {
                    lastSync = config.LastFullRefreshQB;
                }
            }
            string fromModifiedDate = lastSync.ToString("yyyy-MM-ddTHH:mm:ssK");

            return fromModifiedDate;
        }
Example #15
0
        public static string GetLastSyncTime()
        {
            DateTime    lastSync = DateTime.MinValue;
            RotoTrackDb db       = new RotoTrackDb();
            Config      config   = db.Configs.First();

            if (config != null)
            {
                if (config.LastFullRefreshQB != null)
                {
                    lastSync = config.LastFullRefreshQB;
                }
            }
            string fromModifiedDate = lastSync.ToString("yyyy-MM-ddTHH:mm:ssK");

            return(fromModifiedDate);
        }
Example #16
0
        private static BillLine FindOrCreateBillLine(RotoTrackDb db, string TxnLineID, string TxnID, string TimeCreated, string TimeModified, string EditSequence, string TxnDate, string AmountDue)
        {
            BillLine bl = null;

            if (db.BillLines.Any(f => f.TxnLineId == TxnLineID))
            {
                bl = db.BillLines.First(f => f.TxnLineId == TxnLineID);
            }
            else
            {
                bl = new BillLine();
                db.BillLines.Add(bl);
            }

            bl.TxnLineId = TxnLineID;
            bl.BillTxnId = TxnID;
            DateTime createdDate;

            if (DateTime.TryParse(TimeCreated, out createdDate))
            {
                bl.BillCreated = createdDate;
            }
            DateTime modifiedDate;

            if (DateTime.TryParse(TimeModified, out modifiedDate))
            {
                bl.BillModified = modifiedDate;
            }
            bl.BillEditSequence = EditSequence;
            DateTime txnDate;

            if (DateTime.TryParse(TxnDate, out txnDate))
            {
                bl.BillTxnDate = txnDate;
            }
            decimal amountDue;

            if (Decimal.TryParse(AmountDue, out amountDue))
            {
                bl.BillAmountDue = amountDue;
            }

            return(bl);
        }
Example #17
0
        private static VendorCreditLine FindOrCreateVendorCreditLine(RotoTrackDb db, string TxnLineID, string TxnID, string TimeCreated, string TimeModified, string EditSequence, string TxnDate, string AmountDue)
        {
            VendorCreditLine vcl = null;

            if (db.VendorCreditLines.Any(f => f.TxnLineId == TxnLineID))
            {
                vcl = db.VendorCreditLines.First(f => f.TxnLineId == TxnLineID);
            }
            else
            {
                vcl = new VendorCreditLine();
                db.VendorCreditLines.Add(vcl);
            }

            vcl.TxnLineId         = TxnLineID;
            vcl.VendorCreditTxnId = TxnID;
            DateTime createdDate;

            if (DateTime.TryParse(TimeCreated, out createdDate))
            {
                vcl.VendorCreditCreated = createdDate;
            }
            DateTime modifiedDate;

            if (DateTime.TryParse(TimeModified, out modifiedDate))
            {
                vcl.VendorCreditModified = modifiedDate;
            }
            vcl.VendorCreditEditSequence = EditSequence;
            DateTime txnDate;

            if (DateTime.TryParse(TxnDate, out txnDate))
            {
                vcl.VendorCreditTxnDate = txnDate;
            }
            decimal amountDue;

            if (Decimal.TryParse(AmountDue, out amountDue))
            {
                vcl.VendorCreditAmountDue = amountDue;
            }

            return(vcl);
        }
Example #18
0
        private static void WalkVehicleRet(XmlNode VehicleRet)
        {
            if (VehicleRet == null) return;

            Vehicle v = null;
            RotoTrackDb db = new RotoTrackDb();

            string ListID = VehicleRet.SelectSingleNode("./ListID").InnerText;
            if (db.Vehicles.Any(f => f.QBListId == ListID))
            {
                v = db.Vehicles.First(f => f.QBListId == ListID);
            }
            else
            {
                v = new Vehicle();
                db.Vehicles.Add(v);
            }
            v.QBListId = ListID;

            if (VehicleRet.SelectSingleNode("./Name") != null)
            {
                string Name = VehicleRet.SelectSingleNode("./Name").InnerText;
                v.Name = Name;
            }

            string IsActive = "false";
            if (VehicleRet.SelectSingleNode("./IsActive") != null)
            {
                IsActive = VehicleRet.SelectSingleNode("./IsActive").InnerText;
            }
            v.IsActive = (IsActive == "true") ? true : false;

            if (VehicleRet.SelectSingleNode("./Desc") != null)
            {
                string Desc = VehicleRet.SelectSingleNode("./Desc").InnerText;
                v.Description = Desc;
            }

            if (v != null)
            {
                db.SaveChanges();
            }
        }
Example #19
0
        private static void WalkCustomerRetForMod(XmlNode CustomerRet)
        {
            if (CustomerRet == null)
            {
                return;
            }

            RotoTrackDb db = new RotoTrackDb();

            string    ListID = CustomerRet.SelectSingleNode("./ListID").InnerText;
            WorkOrder wo     = null;

            if (db.WorkOrders.Any(f => f.QBListId == ListID))
            {
                wo = db.WorkOrders.First(f => f.QBListId == ListID);
                wo.NeedToUpdateQB = false;
                db.SaveChanges();
            }
        }
Example #20
0
        public static void UpdateAlreadyExistingWorkOrder(int woId)
        {
            RotoTrackDb db = new RotoTrackDb();
            WorkOrder   wo = db.WorkOrders.Find(woId);

            if (wo != null)
            {
                string response = QBUtils.DoRequest(CustomerDAL.BuildCustomerQueryByWorkorderNum(wo.WorkOrderNumber));
                string qbid     = CustomerDAL.GetQBIDFromResponse(response);
                string qbes     = CustomerDAL.GetQBEditSequenceFromResponse(response);
                if ((qbid != "") && (qbes != ""))
                {
                    wo.QBListId        = qbid;
                    wo.QBEditSequence  = qbes;
                    db.Entry(wo).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }
        }
        private static void WalkCustomerTypeRet(XmlNode CustomerTypeRet)
        {
            if (CustomerTypeRet == null)
            {
                return;
            }

            BillingInstruction bi = null;
            RotoTrackDb        db = new RotoTrackDb();

            string ListID = CustomerTypeRet.SelectSingleNode("./ListID").InnerText;

            if (db.BillingInstructions.Any(f => f.QBListId == ListID))
            {
                bi = db.BillingInstructions.First(f => f.QBListId == ListID);
            }
            else
            {
                bi = new BillingInstruction();
                db.BillingInstructions.Add(bi);
            }
            bi.QBListId = ListID;

            string Name = CustomerTypeRet.SelectSingleNode("./Name").InnerText;

            bi.Name = Name;

            string FullName = CustomerTypeRet.SelectSingleNode("./FullName").InnerText;

            string IsActive = "false";

            if (CustomerTypeRet.SelectSingleNode("./IsActive") != null)
            {
                IsActive = CustomerTypeRet.SelectSingleNode("./IsActive").InnerText;
            }
            bi.IsActive = (IsActive == "true") ? true : false;

            if (bi != null)
            {
                db.SaveChanges();
            }
        }
Example #22
0
        private static Area GetAreaFromEmployeeRet(XmlNode EmployeeRet)
        {
            RotoTrackDb db     = new RotoTrackDb();
            Area        area   = new Area();
            Config      config = db.Configs.First();

            string areaInitials = config.DefaultAreaInitials;

            if (db.Areas.Any(f => f.Name.StartsWith(areaInitials)))
            {
                area = db.Areas.First(f => f.Name.StartsWith(areaInitials));
            }
            else
            {
                Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + "Could not find the default " + areaInitials + " area!");
            }

            XmlNodeList DataExtRetList = EmployeeRet.SelectNodes("./DataExtRet");

            if (DataExtRetList != null)
            {
                for (int i = 0; i < DataExtRetList.Count; i++)
                {
                    XmlNode DataExtRet   = DataExtRetList.Item(i);
                    string  DataExtName  = DataExtRet.SelectSingleNode("./DataExtName").InnerText;
                    string  DataExtValue = DataExtRet.SelectSingleNode("./DataExtValue").InnerText;

                    if (DataExtName == "Roto Location")
                    {
                        string areaPrefix = DataExtValue;
                        if (db.Areas.Any(f => f.Name.StartsWith(areaPrefix)))
                        {
                            area = db.Areas.First(f => f.Name.StartsWith(areaPrefix));
                            return(area);
                        }
                    }
                }
            }

            return(area);
        }
        public static XmlDocument BuildUpdateSalesRepRq(WorkOrder wo)
        {
            RotoTrackDb db     = new RotoTrackDb();
            XmlDocument doc    = XmlUtils.MakeRequestDocument();
            XmlElement  parent = XmlUtils.MakeRequestParentElement(doc);

            string listID = wo.QBListId;
            Site   site   = db.Sites.Find(wo.SiteId);

            string      salesRep = "";
            UserProfile up       = db.UserProfiles.Find(wo.SalesRepId);

            if (up != null)
            {
                salesRep = up.FirstName + " " + up.LastName;
            }

            doc = BuildDataExtModOrDelRq(doc, parent, listID, "Work Order Sales Rep", salesRep);

            return(doc);
        }
Example #24
0
        private static void WalkClassRet(XmlNode ClassRet)
        {
            if (ClassRet == null)
            {
                return;
            }

            Area        area = null;
            RotoTrackDb db   = new RotoTrackDb();

            string ListID = ClassRet.SelectSingleNode("./ListID").InnerText;

            if (db.Areas.Any(a => a.QBListId == ListID))
            {
                area = db.Areas.First(a => a.QBListId == ListID);
            }
            else
            {
                area = new Area();
                db.Areas.Add(area);
            }
            area.QBListId = ListID;

            string Name = ClassRet.SelectSingleNode("./Name").InnerText;

            area.Name = Name;

            string IsActive = "false";

            if (ClassRet.SelectSingleNode("./IsActive") != null)
            {
                IsActive = ClassRet.SelectSingleNode("./IsActive").InnerText;
            }
            area.IsActive = (IsActive == "true") ? true : false;

            if (area != null)
            {
                db.SaveChanges();
            }
        }
        private static void WalkVehicleMileageRetForAdd(XmlNode VehicleMileageRet)
        {
            if (VehicleMileageRet == null)
            {
                return;
            }

            RotoTrackDb db = new RotoTrackDb();

            //Get value of Notes--we should have the ServiceEntry GUID encoded in it as well.
            string seGUID = "";

            if (VehicleMileageRet.SelectSingleNode("./Notes") != null)
            {
                string Notes = VehicleMileageRet.SelectSingleNode("./Notes").InnerText;
                seGUID = QBUtils.GetGuidFromNotes(Notes);
            }

            string TxnID = "";

            if (VehicleMileageRet.SelectSingleNode("./TxnID") != null)
            {
                TxnID = VehicleMileageRet.SelectSingleNode("./TxnID").InnerText;
            }

            if (seGUID != "" && TxnID != "")
            {
                ServiceEntry se = null;
                if (db.ServiceEntries.Any(f => f.GUID == seGUID))
                {
                    se = db.ServiceEntries.First(f => f.GUID == seGUID);
                }
                if (se != null)
                {
                    se.QBListIdForMileage = TxnID;
                    db.Entry(se).State    = EntityState.Modified;
                    db.SaveChanges();
                }
            }
        }
Example #26
0
        private static void WalkJobTypeRet(XmlNode JobTypeRet)
        {
            if (JobTypeRet == null)
            {
                return;
            }

            JobType     jt = null;
            RotoTrackDb db = new RotoTrackDb();

            string ListID = JobTypeRet.SelectSingleNode("./ListID").InnerText;

            if (db.JobTypes.Any(f => f.QBListId == ListID))
            {
                jt = db.JobTypes.First(f => f.QBListId == ListID);
            }
            else
            {
                jt = new JobType();
                db.JobTypes.Add(jt);
            }
            jt.QBListId = ListID;

            string Name = JobTypeRet.SelectSingleNode("./Name").InnerText;

            jt.Name = Name;

            string IsActive = "false";

            if (JobTypeRet.SelectSingleNode("./IsActive") != null)
            {
                IsActive = JobTypeRet.SelectSingleNode("./IsActive").InnerText;
            }
            jt.IsActive = (IsActive == "true") ? true : false;

            if (jt != null)
            {
                db.SaveChanges();
            }
        }
Example #27
0
        private static Vendor FindOrCreateVendor(RotoTrackDb db, string QBListId, string QBEditSequence, string TimeCreated, string TimeModified, string Name, string IsActive)
        {
            Vendor o = null;
            if (db.Vendors.Any(f => f.QBListId == QBListId))
            {
                o = db.Vendors.First(f => f.QBListId == QBListId);
            }
            else
            {
                o = new Vendor();
                db.Vendors.Add(o);
            }

            o.QBListId = QBListId;
            o.QBEditSequence = QBEditSequence;
            DateTime createdDate;
            if (DateTime.TryParse(TimeCreated, out createdDate)) o.TimeCreated = createdDate;
            DateTime modifiedDate;
            if (DateTime.TryParse(TimeModified, out modifiedDate)) o.TimeModified = modifiedDate;
            o.Name = Name;
            o.IsActive = (IsActive == "true") ? true : false;

            return o;
        }
Example #28
0
        private static string GetInitialsFromEmployeeRet(XmlNode EmployeeRet)
        {
            RotoTrackDb db       = new RotoTrackDb();
            string      initials = "UNKNOWN";

            XmlNodeList DataExtRetList = EmployeeRet.SelectNodes("./DataExtRet");

            if (DataExtRetList != null)
            {
                for (int i = 0; i < DataExtRetList.Count; i++)
                {
                    XmlNode DataExtRet   = DataExtRetList.Item(i);
                    string  DataExtName  = DataExtRet.SelectSingleNode("./DataExtName").InnerText;
                    string  DataExtValue = DataExtRet.SelectSingleNode("./DataExtValue").InnerText;

                    if (DataExtName == "Initials")
                    {
                        initials = DataExtValue;
                    }
                }
            }

            return(initials);
        }
Example #29
0
        private static void WalkVendorRet(XmlNode VendorRet)
        {
            if (VendorRet == null)
            {
                return;
            }

            RotoTrackDb db = new RotoTrackDb();

            //Go through all the elements of VendorRet
            //Get value of ListID
            string ListID = VendorRet.SelectSingleNode("./ListID").InnerText;
            //Get value of TimeCreated
            string TimeCreated = VendorRet.SelectSingleNode("./TimeCreated").InnerText;
            //Get value of TimeModified
            string TimeModified = VendorRet.SelectSingleNode("./TimeModified").InnerText;
            //Get value of EditSequence
            string EditSequence = VendorRet.SelectSingleNode("./EditSequence").InnerText;
            //Get value of Name
            string Name = VendorRet.SelectSingleNode("./Name").InnerText;
            //Get value of IsActive
            string IsActive = "";

            if (VendorRet.SelectSingleNode("./IsActive") != null)
            {
                IsActive = VendorRet.SelectSingleNode("./IsActive").InnerText;
            }

            Vendor vendor = FindOrCreateVendor(db, ListID, EditSequence, TimeCreated, TimeModified, Name, IsActive);

            db.SaveChanges();

            /*
             * //Get all field values for ClassRef aggregate
             * XmlNode ClassRef = VendorRet.SelectSingleNode("./ClassRef");
             * if (ClassRef != null)
             * {
             * //Get value of ListID
             * if (VendorRet.SelectSingleNode("./ClassRef/ListID") != null)
             * {
             *     string AreaListID = VendorRet.SelectSingleNode("./ClassRef/ListID").InnerText;
             * }
             * //Get value of FullName
             * if (VendorRet.SelectSingleNode("./ClassRef/FullName") != null)
             * {
             *     string FullName = VendorRet.SelectSingleNode("./ClassRef/FullName").InnerText;
             * }
             *
             * }
             * //Done with field values for ClassRef aggregate
             *
             * //Get value of CompanyName
             * if (VendorRet.SelectSingleNode("./CompanyName") != null)
             * {
             * string CompanyName = VendorRet.SelectSingleNode("./CompanyName").InnerText;
             *
             * }
             * //Get value of Salutation
             * if (VendorRet.SelectSingleNode("./Salutation") != null)
             * {
             * string Salutation = VendorRet.SelectSingleNode("./Salutation").InnerText;
             *
             * }
             * //Get value of FirstName
             * if (VendorRet.SelectSingleNode("./FirstName") != null)
             * {
             * string FirstName = VendorRet.SelectSingleNode("./FirstName").InnerText;
             *
             * }
             * //Get value of MiddleName
             * if (VendorRet.SelectSingleNode("./MiddleName") != null)
             * {
             * string MiddleName = VendorRet.SelectSingleNode("./MiddleName").InnerText;
             *
             * }
             * //Get value of LastName
             * if (VendorRet.SelectSingleNode("./LastName") != null)
             * {
             * string LastName = VendorRet.SelectSingleNode("./LastName").InnerText;
             *
             * }
             * //Get value of JobTitle
             * if (VendorRet.SelectSingleNode("./JobTitle") != null)
             * {
             * string JobTitle = VendorRet.SelectSingleNode("./JobTitle").InnerText;
             *
             * }
             * //Get all field values for VendorAddress aggregate
             * XmlNode VendorAddress = VendorRet.SelectSingleNode("./VendorAddress");
             * if (VendorAddress != null)
             * {
             * //Get value of Addr1
             * if (VendorRet.SelectSingleNode("./VendorAddress/Addr1") != null)
             * {
             *     string Addr1 = VendorRet.SelectSingleNode("./VendorAddress/Addr1").InnerText;
             *
             * }
             * //Get value of Addr2
             * if (VendorRet.SelectSingleNode("./VendorAddress/Addr2") != null)
             * {
             *     string Addr2 = VendorRet.SelectSingleNode("./VendorAddress/Addr2").InnerText;
             *
             * }
             * //Get value of Addr3
             * if (VendorRet.SelectSingleNode("./VendorAddress/Addr3") != null)
             * {
             *     string Addr3 = VendorRet.SelectSingleNode("./VendorAddress/Addr3").InnerText;
             *
             * }
             * //Get value of Addr4
             * if (VendorRet.SelectSingleNode("./VendorAddress/Addr4") != null)
             * {
             *     string Addr4 = VendorRet.SelectSingleNode("./VendorAddress/Addr4").InnerText;
             *
             * }
             * //Get value of Addr5
             * if (VendorRet.SelectSingleNode("./VendorAddress/Addr5") != null)
             * {
             *     string Addr5 = VendorRet.SelectSingleNode("./VendorAddress/Addr5").InnerText;
             *
             * }
             * //Get value of City
             * if (VendorRet.SelectSingleNode("./VendorAddress/City") != null)
             * {
             *     string City = VendorRet.SelectSingleNode("./VendorAddress/City").InnerText;
             *
             * }
             * //Get value of State
             * if (VendorRet.SelectSingleNode("./VendorAddress/State") != null)
             * {
             *     string State = VendorRet.SelectSingleNode("./VendorAddress/State").InnerText;
             *
             * }
             * //Get value of PostalCode
             * if (VendorRet.SelectSingleNode("./VendorAddress/PostalCode") != null)
             * {
             *     string PostalCode = VendorRet.SelectSingleNode("./VendorAddress/PostalCode").InnerText;
             *
             * }
             * //Get value of Country
             * if (VendorRet.SelectSingleNode("./VendorAddress/Country") != null)
             * {
             *     string Country = VendorRet.SelectSingleNode("./VendorAddress/Country").InnerText;
             *
             * }
             * //Get value of Note
             * if (VendorRet.SelectSingleNode("./VendorAddress/Note") != null)
             * {
             *     string Note = VendorRet.SelectSingleNode("./VendorAddress/Note").InnerText;
             *
             * }
             *
             * }
             * //Done with field values for VendorAddress aggregate
             *
             * //Get all field values for VendorAddressBlock aggregate
             * XmlNode VendorAddressBlock = VendorRet.SelectSingleNode("./VendorAddressBlock");
             * if (VendorAddressBlock != null)
             * {
             * //Get value of Addr1
             * if (VendorRet.SelectSingleNode("./VendorAddressBlock/Addr1") != null)
             * {
             *     string Addr1 = VendorRet.SelectSingleNode("./VendorAddressBlock/Addr1").InnerText;
             *
             * }
             * //Get value of Addr2
             * if (VendorRet.SelectSingleNode("./VendorAddressBlock/Addr2") != null)
             * {
             *     string Addr2 = VendorRet.SelectSingleNode("./VendorAddressBlock/Addr2").InnerText;
             *
             * }
             * //Get value of Addr3
             * if (VendorRet.SelectSingleNode("./VendorAddressBlock/Addr3") != null)
             * {
             *     string Addr3 = VendorRet.SelectSingleNode("./VendorAddressBlock/Addr3").InnerText;
             *
             * }
             * //Get value of Addr4
             * if (VendorRet.SelectSingleNode("./VendorAddressBlock/Addr4") != null)
             * {
             *     string Addr4 = VendorRet.SelectSingleNode("./VendorAddressBlock/Addr4").InnerText;
             *
             * }
             * //Get value of Addr5
             * if (VendorRet.SelectSingleNode("./VendorAddressBlock/Addr5") != null)
             * {
             *     string Addr5 = VendorRet.SelectSingleNode("./VendorAddressBlock/Addr5").InnerText;
             *
             * }
             *
             * }
             * //Done with field values for VendorAddressBlock aggregate
             *
             * //Get all field values for ShipAddress aggregate
             * XmlNode ShipAddress = VendorRet.SelectSingleNode("./ShipAddress");
             * if (ShipAddress != null)
             * {
             * //Get value of Addr1
             * if (VendorRet.SelectSingleNode("./ShipAddress/Addr1") != null)
             * {
             *     string Addr1 = VendorRet.SelectSingleNode("./ShipAddress/Addr1").InnerText;
             *
             * }
             * //Get value of Addr2
             * if (VendorRet.SelectSingleNode("./ShipAddress/Addr2") != null)
             * {
             *     string Addr2 = VendorRet.SelectSingleNode("./ShipAddress/Addr2").InnerText;
             *
             * }
             * //Get value of Addr3
             * if (VendorRet.SelectSingleNode("./ShipAddress/Addr3") != null)
             * {
             *     string Addr3 = VendorRet.SelectSingleNode("./ShipAddress/Addr3").InnerText;
             *
             * }
             * //Get value of Addr4
             * if (VendorRet.SelectSingleNode("./ShipAddress/Addr4") != null)
             * {
             *     string Addr4 = VendorRet.SelectSingleNode("./ShipAddress/Addr4").InnerText;
             *
             * }
             * //Get value of Addr5
             * if (VendorRet.SelectSingleNode("./ShipAddress/Addr5") != null)
             * {
             *     string Addr5 = VendorRet.SelectSingleNode("./ShipAddress/Addr5").InnerText;
             *
             * }
             * //Get value of City
             * if (VendorRet.SelectSingleNode("./ShipAddress/City") != null)
             * {
             *     string City = VendorRet.SelectSingleNode("./ShipAddress/City").InnerText;
             *
             * }
             * //Get value of State
             * if (VendorRet.SelectSingleNode("./ShipAddress/State") != null)
             * {
             *     string State = VendorRet.SelectSingleNode("./ShipAddress/State").InnerText;
             *
             * }
             * //Get value of PostalCode
             * if (VendorRet.SelectSingleNode("./ShipAddress/PostalCode") != null)
             * {
             *     string PostalCode = VendorRet.SelectSingleNode("./ShipAddress/PostalCode").InnerText;
             *
             * }
             * //Get value of Country
             * if (VendorRet.SelectSingleNode("./ShipAddress/Country") != null)
             * {
             *     string Country = VendorRet.SelectSingleNode("./ShipAddress/Country").InnerText;
             *
             * }
             * //Get value of Note
             * if (VendorRet.SelectSingleNode("./ShipAddress/Note") != null)
             * {
             *     string Note = VendorRet.SelectSingleNode("./ShipAddress/Note").InnerText;
             *
             * }
             *
             * }
             * //Done with field values for ShipAddress aggregate
             *
             * //Get value of Phone
             * if (VendorRet.SelectSingleNode("./Phone") != null)
             * {
             * string Phone = VendorRet.SelectSingleNode("./Phone").InnerText;
             *
             * }
             * //Get value of AltPhone
             * if (VendorRet.SelectSingleNode("./AltPhone") != null)
             * {
             * string AltPhone = VendorRet.SelectSingleNode("./AltPhone").InnerText;
             *
             * }
             * //Get value of Fax
             * if (VendorRet.SelectSingleNode("./Fax") != null)
             * {
             * string Fax = VendorRet.SelectSingleNode("./Fax").InnerText;
             *
             * }
             * //Get value of Email
             * if (VendorRet.SelectSingleNode("./Email") != null)
             * {
             * string Email = VendorRet.SelectSingleNode("./Email").InnerText;
             *
             * }
             * //Get value of Cc
             * if (VendorRet.SelectSingleNode("./Cc") != null)
             * {
             * string Cc = VendorRet.SelectSingleNode("./Cc").InnerText;
             *
             * }
             * //Get value of Contact
             * if (VendorRet.SelectSingleNode("./Contact") != null)
             * {
             * string Contact = VendorRet.SelectSingleNode("./Contact").InnerText;
             *
             * }
             * //Get value of AltContact
             * if (VendorRet.SelectSingleNode("./AltContact") != null)
             * {
             * string AltContact = VendorRet.SelectSingleNode("./AltContact").InnerText;
             *
             * }
             * //Get all field values for AdditionalContactRef aggregate
             * XmlNode AdditionalContactRef = VendorRet.SelectSingleNode("./AdditionalContactRef");
             * if (AdditionalContactRef != null)
             * {
             * //Get value of ContactName
             * string ContactName = VendorRet.SelectSingleNode("./AdditionalContactRef/ContactName").InnerText;
             * //Get value of ContactValue
             * string ContactValue = VendorRet.SelectSingleNode("./AdditionalContactRef/ContactValue").InnerText;
             *
             * }
             * //Done with field values for AdditionalContactRef aggregate
             *
             * //Walk list of ContactsRet aggregates
             * XmlNodeList ContactsRetList = VendorRet.SelectNodes("./ContactsRet");
             * if (ContactsRetList != null)
             * {
             * for (int i = 0; i < ContactsRetList.Count; i++)
             * {
             *     XmlNode ContactsRet = ContactsRetList.Item(i);
             *     //Get value of ListID
             *     string cListID = ContactsRet.SelectSingleNode("./ListID").InnerText;
             *     //Get value of TimeCreated
             *     string cTimeCreated = ContactsRet.SelectSingleNode("./TimeCreated").InnerText;
             *     //Get value of TimeModified
             *     string cTimeModified = ContactsRet.SelectSingleNode("./TimeModified").InnerText;
             *     //Get value of EditSequence
             *     string cEditSequence = ContactsRet.SelectSingleNode("./EditSequence").InnerText;
             *     //Get value of Contact
             *     if (ContactsRet.SelectSingleNode("./Contact") != null)
             *     {
             *         string Contact = ContactsRet.SelectSingleNode("./Contact").InnerText;
             *
             *     }
             *     //Get value of Salutation
             *     if (ContactsRet.SelectSingleNode("./Salutation") != null)
             *     {
             *         string Salutation = ContactsRet.SelectSingleNode("./Salutation").InnerText;
             *
             *     }
             *     //Get value of FirstName
             *     string FirstName = ContactsRet.SelectSingleNode("./FirstName").InnerText;
             *     //Get value of MiddleName
             *     if (ContactsRet.SelectSingleNode("./MiddleName") != null)
             *     {
             *         string MiddleName = ContactsRet.SelectSingleNode("./MiddleName").InnerText;
             *
             *     }
             *     //Get value of LastName
             *     if (ContactsRet.SelectSingleNode("./LastName") != null)
             *     {
             *         string LastName = ContactsRet.SelectSingleNode("./LastName").InnerText;
             *
             *     }
             *     //Get value of JobTitle
             *     if (ContactsRet.SelectSingleNode("./JobTitle") != null)
             *     {
             *         string JobTitle = ContactsRet.SelectSingleNode("./JobTitle").InnerText;
             *
             *     }
             *     //Get all field values for AdditionalContactRef aggregate
             *     XmlNode cAdditionalContactRef = ContactsRet.SelectSingleNode("./AdditionalContactRef");
             *     if (AdditionalContactRef != null)
             *     {
             *         //Get value of ContactName
             *         string ContactName = ContactsRet.SelectSingleNode("./AdditionalContactRef/ContactName").InnerText;
             *         //Get value of ContactValue
             *         string ContactValue = ContactsRet.SelectSingleNode("./AdditionalContactRef/ContactValue").InnerText;
             *
             *     }
             *     //Done with field values for AdditionalContactRef aggregate
             *
             *
             * }
             *
             * }
             *
             * //Get value of NameOnCheck
             * if (VendorRet.SelectSingleNode("./NameOnCheck") != null)
             * {
             * string NameOnCheck = VendorRet.SelectSingleNode("./NameOnCheck").InnerText;
             *
             * }
             * //Get value of AccountNumber
             * if (VendorRet.SelectSingleNode("./AccountNumber") != null)
             * {
             * string AccountNumber = VendorRet.SelectSingleNode("./AccountNumber").InnerText;
             *
             * }
             * //Get value of Notes
             * if (VendorRet.SelectSingleNode("./Notes") != null)
             * {
             * string Notes = VendorRet.SelectSingleNode("./Notes").InnerText;
             *
             * }
             * //Walk list of AdditionalNotesRet aggregates
             * XmlNodeList AdditionalNotesRetList = VendorRet.SelectNodes("./AdditionalNotesRet");
             * if (AdditionalNotesRetList != null)
             * {
             * for (int i = 0; i < AdditionalNotesRetList.Count; i++)
             * {
             *     XmlNode AdditionalNotesRet = AdditionalNotesRetList.Item(i);
             *     //Get value of NoteID
             *     string NoteID = AdditionalNotesRet.SelectSingleNode("./NoteID").InnerText;
             *     //Get value of Date
             *     string Date = AdditionalNotesRet.SelectSingleNode("./Date").InnerText;
             *     //Get value of Note
             *     string Note = AdditionalNotesRet.SelectSingleNode("./Note").InnerText;
             *
             * }
             *
             * }
             *
             * //Get all field values for VendorTypeRef aggregate
             * XmlNode VendorTypeRef = VendorRet.SelectSingleNode("./VendorTypeRef");
             * if (VendorTypeRef != null)
             * {
             * //Get value of ListID
             * if (VendorRet.SelectSingleNode("./VendorTypeRef/ListID") != null)
             * {
             *     string VendorTypeListID = VendorRet.SelectSingleNode("./VendorTypeRef/ListID").InnerText;
             *
             * }
             * //Get value of FullName
             * if (VendorRet.SelectSingleNode("./VendorTypeRef/FullName") != null)
             * {
             *     string FullName = VendorRet.SelectSingleNode("./VendorTypeRef/FullName").InnerText;
             *
             * }
             *
             * }
             * //Done with field values for VendorTypeRef aggregate
             *
             * //Get all field values for TermsRef aggregate
             * XmlNode TermsRef = VendorRet.SelectSingleNode("./TermsRef");
             * if (TermsRef != null)
             * {
             * //Get value of ListID
             * if (VendorRet.SelectSingleNode("./TermsRef/ListID") != null)
             * {
             *     string TermsListID = VendorRet.SelectSingleNode("./TermsRef/ListID").InnerText;
             *
             * }
             * //Get value of FullName
             * if (VendorRet.SelectSingleNode("./TermsRef/FullName") != null)
             * {
             *     string FullName = VendorRet.SelectSingleNode("./TermsRef/FullName").InnerText;
             *
             * }
             *
             * }
             * //Done with field values for TermsRef aggregate
             *
             * //Get value of CreditLimit
             * if (VendorRet.SelectSingleNode("./CreditLimit") != null)
             * {
             * string CreditLimit = VendorRet.SelectSingleNode("./CreditLimit").InnerText;
             *
             * }
             * //Get value of VendorTaxIdent
             * if (VendorRet.SelectSingleNode("./VendorTaxIdent") != null)
             * {
             * string VendorTaxIdent = VendorRet.SelectSingleNode("./VendorTaxIdent").InnerText;
             *
             * }
             * //Get value of IsVendorEligibleFor1099
             * if (VendorRet.SelectSingleNode("./IsVendorEligibleFor1099") != null)
             * {
             * string IsVendorEligibleFor1099 = VendorRet.SelectSingleNode("./IsVendorEligibleFor1099").InnerText;
             *
             * }
             * //Get value of Balance
             * if (VendorRet.SelectSingleNode("./Balance") != null)
             * {
             * string Balance = VendorRet.SelectSingleNode("./Balance").InnerText;
             *
             * }
             * //Get all field values for BillingRateRef aggregate
             * XmlNode BillingRateRef = VendorRet.SelectSingleNode("./BillingRateRef");
             * if (BillingRateRef != null)
             * {
             * //Get value of ListID
             * if (VendorRet.SelectSingleNode("./BillingRateRef/ListID") != null)
             * {
             *     string BillingRateListID = VendorRet.SelectSingleNode("./BillingRateRef/ListID").InnerText;
             *
             * }
             * //Get value of FullName
             * if (VendorRet.SelectSingleNode("./BillingRateRef/FullName") != null)
             * {
             *     string FullName = VendorRet.SelectSingleNode("./BillingRateRef/FullName").InnerText;
             *
             * }
             *
             * }
             * //Done with field values for BillingRateRef aggregate
             *
             * //Get value of ExternalGUID
             * if (VendorRet.SelectSingleNode("./ExternalGUID") != null)
             * {
             * string ExternalGUID = VendorRet.SelectSingleNode("./ExternalGUID").InnerText;
             *
             * }
             * //Get all field values for PrefillAccountRef aggregate
             * XmlNode PrefillAccountRef = VendorRet.SelectSingleNode("./PrefillAccountRef");
             * if (PrefillAccountRef != null)
             * {
             * //Get value of ListID
             * if (VendorRet.SelectSingleNode("./PrefillAccountRef/ListID") != null)
             * {
             *     string PrefillAccountListID = VendorRet.SelectSingleNode("./PrefillAccountRef/ListID").InnerText;
             *
             * }
             * //Get value of FullName
             * if (VendorRet.SelectSingleNode("./PrefillAccountRef/FullName") != null)
             * {
             *     string FullName = VendorRet.SelectSingleNode("./PrefillAccountRef/FullName").InnerText;
             *
             * }
             *
             * }
             * //Done with field values for PrefillAccountRef aggregate
             *
             * //Get all field values for CurrencyRef aggregate
             * XmlNode CurrencyRef = VendorRet.SelectSingleNode("./CurrencyRef");
             * if (CurrencyRef != null)
             * {
             * //Get value of ListID
             * if (VendorRet.SelectSingleNode("./CurrencyRef/ListID") != null)
             * {
             *     string CurrencyListID = VendorRet.SelectSingleNode("./CurrencyRef/ListID").InnerText;
             * }
             * //Get value of FullName
             * if (VendorRet.SelectSingleNode("./CurrencyRef/FullName") != null)
             * {
             *     string FullName = VendorRet.SelectSingleNode("./CurrencyRef/FullName").InnerText;
             * }
             * }
             * //Done with field values for CurrencyRef aggregate
             *
             * //Walk list of DataExtRet aggregates
             * XmlNodeList DataExtRetList = VendorRet.SelectNodes("./DataExtRet");
             * if (DataExtRetList != null)
             * {
             * for (int i = 0; i < DataExtRetList.Count; i++)
             * {
             *     XmlNode DataExtRet = DataExtRetList.Item(i);
             *     //Get value of OwnerID
             *     if (DataExtRet.SelectSingleNode("./OwnerID") != null)
             *     {
             *         string OwnerID = DataExtRet.SelectSingleNode("./OwnerID").InnerText;
             *     }
             *     //Get value of DataExtName
             *     string DataExtName = DataExtRet.SelectSingleNode("./DataExtName").InnerText;
             *     //Get value of DataExtType
             *     string DataExtType = DataExtRet.SelectSingleNode("./DataExtType").InnerText;
             *     //Get value of DataExtValue
             *     string DataExtValue = DataExtRet.SelectSingleNode("./DataExtValue").InnerText;
             * }
             * }
             */
        }
Example #30
0
        private static void WalkOR(XmlNode OR)
        {
            if (OR == null) return;

            RotoTrackDb db = new RotoTrackDb();

            //Go through all the elements of OR
            //Get all field values for ItemServiceRet aggregate
            //XmlNode ItemServiceRet = OR.SelectSingleNode("./ItemServiceRet");
            if (OR.Name == "ItemServiceRet")
            {
                //Get value of ListID
                string ListID = OR.SelectSingleNode("./ListID").InnerText;
                //Get value of TimeCreated
                string TimeCreated = OR.SelectSingleNode("./TimeCreated").InnerText;
                //Get value of TimeModified
                string TimeModified = OR.SelectSingleNode("./TimeModified").InnerText;
                //Get value of EditSequence
                string EditSequence = OR.SelectSingleNode("./EditSequence").InnerText;
                //Get value of Name
                string Name = OR.SelectSingleNode("./Name").InnerText;
                //Get value of FullName
                string FullName = OR.SelectSingleNode("./FullName").InnerText;
                //Get value of BarCodeValue
                if (OR.SelectSingleNode("./BarCodeValue") != null)
                {
                    string BarCodeValue = OR.SelectSingleNode("./BarCodeValue").InnerText;
                }
                //Get value of IsActive
                string IsActive = "false";
                if (OR.SelectSingleNode("./IsActive") != null)
                {
                    IsActive = OR.SelectSingleNode("./IsActive").InnerText;
                }

                Item o = ItemDAL.FindOrCreateItem(db, ListID, EditSequence, TimeCreated, TimeModified, Name, FullName, IsActive, "ItemService");
                db.SaveChanges();

                // Now call WalkItemServiceRet to store this in our service type table
                WalkItemServiceRet(OR);
                                /*
                //Get all field values for ClassRef aggregate
                XmlNode ClassRef = OR.SelectSingleNode("./ItemServiceRet/ClassRef");
                if (ClassRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemServiceRet/ClassRef/ListID") != null)
                    {
                        string ClassListID = OR.SelectSingleNode("./ItemServiceRet/ClassRef/ListID").InnerText;
                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemServiceRet/ClassRef/FullName") != null)
                    {
                        string ClassFullName = OR.SelectSingleNode("./ItemServiceRet/ClassRef/FullName").InnerText;
                    }
                }
                //Done with field values for ClassRef aggregate

                //Get all field values for ParentRef aggregate
                XmlNode ParentRef = OR.SelectSingleNode("./ItemServiceRet/ParentRef");
                if (ParentRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemServiceRet/ParentRef/ListID") != null)
                    {
                        string ParentListID = OR.SelectSingleNode("./ItemServiceRet/ParentRef/ListID").InnerText;
                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemServiceRet/ParentRef/FullName") != null)
                    {
                        string ParentFullName = OR.SelectSingleNode("./ItemServiceRet/ParentRef/FullName").InnerText;
                    }
                }
                //Done with field values for ParentRef aggregate

                //Get value of Sublevel
                string Sublevel = OR.SelectSingleNode("./ItemServiceRet/Sublevel").InnerText;
                //Get all field values for UnitOfMeasureSetRef aggregate
                XmlNode UnitOfMeasureSetRef = OR.SelectSingleNode("./ItemServiceRet/UnitOfMeasureSetRef");
                if (UnitOfMeasureSetRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemServiceRet/UnitOfMeasureSetRef/ListID") != null)
                    {
                        string UnitOfMeasureListID = OR.SelectSingleNode("./ItemServiceRet/UnitOfMeasureSetRef/ListID").InnerText;
                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemServiceRet/UnitOfMeasureSetRef/FullName") != null)
                    {
                        string UnitOfMeasureFullName = OR.SelectSingleNode("./ItemServiceRet/UnitOfMeasureSetRef/FullName").InnerText;
                    }
                }
                //Done with field values for UnitOfMeasureSetRef aggregate

                //Get all field values for SalesTaxCodeRef aggregate
                XmlNode SalesTaxCodeRef = OR.SelectSingleNode("./ItemServiceRet/SalesTaxCodeRef");
                if (SalesTaxCodeRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemServiceRet/SalesTaxCodeRef/ListID") != null)
                    {
                        string SalesTaxCodeListID = OR.SelectSingleNode("./ItemServiceRet/SalesTaxCodeRef/ListID").InnerText;
                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemServiceRet/SalesTaxCodeRef/FullName") != null)
                    {
                        string SalesTaxCodeFullName = OR.SelectSingleNode("./ItemServiceRet/SalesTaxCodeRef/FullName").InnerText;
                    }
                }
                //Done with field values for SalesTaxCodeRef aggregate

                XmlNodeList ORSalesPurchaseChildren = OR.SelectNodes("./ItemServiceRet/*");
                for (int i = 0; i < ORSalesPurchaseChildren.Count; i++)
                {
                    XmlNode Child = ORSalesPurchaseChildren.Item(i);
                    if (Child.Name == "SalesOrPurchase")
                    {
                        //Get value of Desc
                        if (Child.SelectSingleNode("./Desc") != null)
                        {
                            string Desc = Child.SelectSingleNode("./Desc").InnerText;

                        }
                        XmlNodeList ORPriceChildren = Child.SelectNodes("./*");
                        for (int i = 0; i < ORPriceChildren.Count; i++)
                        {
                            XmlNode Child = ORPriceChildren.Item(i);
                            if (Child.Name == "Price")
                            {
                            }

                            if (Child.Name == "PricePercent")
                            {
                            }

                        }

                        //Get all field values for AccountRef aggregate
                        XmlNode AccountRef = Child.SelectSingleNode("./AccountRef");
                        if (AccountRef != null)
                        {
                            //Get value of ListID
                            if (Child.SelectSingleNode("./AccountRef/ListID") != null)
                            {
                                string ListID = Child.SelectSingleNode("./AccountRef/ListID").InnerText;

                            }
                            //Get value of FullName
                            if (Child.SelectSingleNode("./AccountRef/FullName") != null)
                            {
                                string FullName = Child.SelectSingleNode("./AccountRef/FullName").InnerText;

                            }

                        }
                        //Done with field values for AccountRef aggregate

                    }

                    if (Child.Name == "SalesAndPurchase")
                    {
                        //Get value of SalesDesc
                        if (Child.SelectSingleNode("./SalesDesc") != null)
                        {
                            string SalesDesc = Child.SelectSingleNode("./SalesDesc").InnerText;

                        }
                        //Get value of SalesPrice
                        if (Child.SelectSingleNode("./SalesPrice") != null)
                        {
                            string SalesPrice = Child.SelectSingleNode("./SalesPrice").InnerText;

                        }
                        //Get all field values for IncomeAccountRef aggregate
                        XmlNode IncomeAccountRef = Child.SelectSingleNode("./IncomeAccountRef");
                        if (IncomeAccountRef != null)
                        {
                            //Get value of ListID
                            if (Child.SelectSingleNode("./IncomeAccountRef/ListID") != null)
                            {
                                string ListID = Child.SelectSingleNode("./IncomeAccountRef/ListID").InnerText;

                            }
                            //Get value of FullName
                            if (Child.SelectSingleNode("./IncomeAccountRef/FullName") != null)
                            {
                                string FullName = Child.SelectSingleNode("./IncomeAccountRef/FullName").InnerText;

                            }

                        }
                        //Done with field values for IncomeAccountRef aggregate

                        //Get value of PurchaseDesc
                        if (Child.SelectSingleNode("./PurchaseDesc") != null)
                        {
                            string PurchaseDesc = Child.SelectSingleNode("./PurchaseDesc").InnerText;

                        }
                        //Get value of PurchaseCost
                        if (Child.SelectSingleNode("./PurchaseCost") != null)
                        {
                            string PurchaseCost = Child.SelectSingleNode("./PurchaseCost").InnerText;

                        }
                        //Get all field values for ExpenseAccountRef aggregate
                        XmlNode ExpenseAccountRef = Child.SelectSingleNode("./ExpenseAccountRef");
                        if (ExpenseAccountRef != null)
                        {
                            //Get value of ListID
                            if (Child.SelectSingleNode("./ExpenseAccountRef/ListID") != null)
                            {
                                string ListID = Child.SelectSingleNode("./ExpenseAccountRef/ListID").InnerText;

                            }
                            //Get value of FullName
                            if (Child.SelectSingleNode("./ExpenseAccountRef/FullName") != null)
                            {
                                string FullName = Child.SelectSingleNode("./ExpenseAccountRef/FullName").InnerText;

                            }

                        }
                        //Done with field values for ExpenseAccountRef aggregate

                        //Get all field values for PrefVendorRef aggregate
                        XmlNode PrefVendorRef = Child.SelectSingleNode("./PrefVendorRef");
                        if (PrefVendorRef != null)
                        {
                            //Get value of ListID
                            if (Child.SelectSingleNode("./PrefVendorRef/ListID") != null)
                            {
                                string ListID = Child.SelectSingleNode("./PrefVendorRef/ListID").InnerText;

                            }
                            //Get value of FullName
                            if (Child.SelectSingleNode("./PrefVendorRef/FullName") != null)
                            {
                                string FullName = Child.SelectSingleNode("./PrefVendorRef/FullName").InnerText;

                            }

                        }
                        //Done with field values for PrefVendorRef aggregate

                    }

                }

                //Get value of ExternalGUID
                if (OR.SelectSingleNode("./ItemServiceRet/ExternalGUID") != null)
                {
                    string ExternalGUID = OR.SelectSingleNode("./ItemServiceRet/ExternalGUID").InnerText;

                }
                //Walk list of DataExtRet aggregates
                XmlNodeList DataExtRetList = OR.SelectNodes("./ItemServiceRet/DataExtRet");
                if (DataExtRetList != null)
                {
                    for (int i = 0; i < DataExtRetList.Count; i++)
                    {
                        XmlNode DataExtRet = DataExtRetList.Item(i);
                        //Get value of OwnerID
                        if (DataExtRet.SelectSingleNode("./OwnerID") != null)
                        {
                            string OwnerID = DataExtRet.SelectSingleNode("./OwnerID").InnerText;

                        }
                        //Get value of DataExtName
                        string DataExtName = DataExtRet.SelectSingleNode("./DataExtName").InnerText;
                        //Get value of DataExtType
                        string DataExtType = DataExtRet.SelectSingleNode("./DataExtType").InnerText;
                        //Get value of DataExtValue
                        string DataExtValue = DataExtRet.SelectSingleNode("./DataExtValue").InnerText;
                    }
                }
                */
            }
            //Done with field values for ItemServiceRet aggregate

            //Get all field values for ItemNonInventoryRet aggregate
            //XmlNode ItemNonInventoryRet = OR.SelectSingleNode("./ItemNonInventoryRet");
            if (OR.Name ==  "ItemNonInventoryRet")
            {
                //Get value of ListID
                string ListID = OR.SelectSingleNode("./ListID").InnerText;
                //Get value of TimeCreated
                string TimeCreated = OR.SelectSingleNode("./TimeCreated").InnerText;
                //Get value of TimeModified
                string TimeModified = OR.SelectSingleNode("./TimeModified").InnerText;
                //Get value of EditSequence
                string EditSequence = OR.SelectSingleNode("./EditSequence").InnerText;
                //Get value of Name
                string Name = OR.SelectSingleNode("./Name").InnerText;
                //Get value of FullName
                string FullName = OR.SelectSingleNode("./FullName").InnerText;
                //Get value of BarCodeValue
                if (OR.SelectSingleNode("./BarCodeValue") != null)
                {
                    string BarCodeValue = OR.SelectSingleNode("./BarCodeValue").InnerText;
                }
                //Get value of IsActive
                string IsActive = "false";
                if (OR.SelectSingleNode("./IsActive") != null)
                {
                    IsActive = OR.SelectSingleNode("./IsActive").InnerText;
                }

                Item o = ItemDAL.FindOrCreateItem(db, ListID, EditSequence, TimeCreated, TimeModified, Name, FullName, IsActive, "ItemNonInventory");
                db.SaveChanges();

                /*
                //Get all field values for ClassRef aggregate
                XmlNode ClassRef = OR.SelectSingleNode("./ItemNonInventoryRet/ClassRef");
                if (ClassRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemNonInventoryRet/ClassRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemNonInventoryRet/ClassRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemNonInventoryRet/ClassRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemNonInventoryRet/ClassRef/FullName").InnerText;

                    }

                }
                //Done with field values for ClassRef aggregate

                //Get all field values for ParentRef aggregate
                XmlNode ParentRef = OR.SelectSingleNode("./ItemNonInventoryRet/ParentRef");
                if (ParentRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemNonInventoryRet/ParentRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemNonInventoryRet/ParentRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemNonInventoryRet/ParentRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemNonInventoryRet/ParentRef/FullName").InnerText;

                    }

                }
                //Done with field values for ParentRef aggregate

                //Get value of Sublevel
                string Sublevel = OR.SelectSingleNode("./ItemNonInventoryRet/Sublevel").InnerText;
                //Get value of ManufacturerPartNumber
                if (OR.SelectSingleNode("./ItemNonInventoryRet/ManufacturerPartNumber") != null)
                {
                    string ManufacturerPartNumber = OR.SelectSingleNode("./ItemNonInventoryRet/ManufacturerPartNumber").InnerText;

                }
                //Get all field values for UnitOfMeasureSetRef aggregate
                XmlNode UnitOfMeasureSetRef = OR.SelectSingleNode("./ItemNonInventoryRet/UnitOfMeasureSetRef");
                if (UnitOfMeasureSetRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemNonInventoryRet/UnitOfMeasureSetRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemNonInventoryRet/UnitOfMeasureSetRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemNonInventoryRet/UnitOfMeasureSetRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemNonInventoryRet/UnitOfMeasureSetRef/FullName").InnerText;

                    }

                }
                //Done with field values for UnitOfMeasureSetRef aggregate

                //Get all field values for SalesTaxCodeRef aggregate
                XmlNode SalesTaxCodeRef = OR.SelectSingleNode("./ItemNonInventoryRet/SalesTaxCodeRef");
                if (SalesTaxCodeRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemNonInventoryRet/SalesTaxCodeRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemNonInventoryRet/SalesTaxCodeRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemNonInventoryRet/SalesTaxCodeRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemNonInventoryRet/SalesTaxCodeRef/FullName").InnerText;

                    }

                }
                //Done with field values for SalesTaxCodeRef aggregate

                XmlNodeList ORSalesPurchaseChildren = OR.SelectNodes("./ItemNonInventoryRet/*");
                for (int i = 0; i < ORSalesPurchaseChildren.Count; i++)
                {
                    XmlNode Child = ORSalesPurchaseChildren.Item(i);
                    if (Child.Name == "SalesOrPurchase")
                    {
                        //Get value of Desc
                        if (Child.SelectSingleNode("./Desc") != null)
                        {
                            string Desc = Child.SelectSingleNode("./Desc").InnerText;

                        }
                        XmlNodeList ORPriceChildren = Child.SelectNodes("./*");
                        for (int i = 0; i < ORPriceChildren.Count; i++)
                        {
                            XmlNode Child = ORPriceChildren.Item(i);
                            if (Child.Name == "Price")
                            {
                            }

                            if (Child.Name == "PricePercent")
                            {
                            }

                        }

                        //Get all field values for AccountRef aggregate
                        XmlNode AccountRef = Child.SelectSingleNode("./AccountRef");
                        if (AccountRef != null)
                        {
                            //Get value of ListID
                            if (Child.SelectSingleNode("./AccountRef/ListID") != null)
                            {
                                string ListID = Child.SelectSingleNode("./AccountRef/ListID").InnerText;

                            }
                            //Get value of FullName
                            if (Child.SelectSingleNode("./AccountRef/FullName") != null)
                            {
                                string FullName = Child.SelectSingleNode("./AccountRef/FullName").InnerText;

                            }

                        }
                        //Done with field values for AccountRef aggregate

                    }

                    if (Child.Name == "SalesAndPurchase")
                    {
                        //Get value of SalesDesc
                        if (Child.SelectSingleNode("./SalesDesc") != null)
                        {
                            string SalesDesc = Child.SelectSingleNode("./SalesDesc").InnerText;

                        }
                        //Get value of SalesPrice
                        if (Child.SelectSingleNode("./SalesPrice") != null)
                        {
                            string SalesPrice = Child.SelectSingleNode("./SalesPrice").InnerText;

                        }
                        //Get all field values for IncomeAccountRef aggregate
                        XmlNode IncomeAccountRef = Child.SelectSingleNode("./IncomeAccountRef");
                        if (IncomeAccountRef != null)
                        {
                            //Get value of ListID
                            if (Child.SelectSingleNode("./IncomeAccountRef/ListID") != null)
                            {
                                string ListID = Child.SelectSingleNode("./IncomeAccountRef/ListID").InnerText;

                            }
                            //Get value of FullName
                            if (Child.SelectSingleNode("./IncomeAccountRef/FullName") != null)
                            {
                                string FullName = Child.SelectSingleNode("./IncomeAccountRef/FullName").InnerText;

                            }

                        }
                        //Done with field values for IncomeAccountRef aggregate

                        //Get value of PurchaseDesc
                        if (Child.SelectSingleNode("./PurchaseDesc") != null)
                        {
                            string PurchaseDesc = Child.SelectSingleNode("./PurchaseDesc").InnerText;

                        }
                        //Get value of PurchaseCost
                        if (Child.SelectSingleNode("./PurchaseCost") != null)
                        {
                            string PurchaseCost = Child.SelectSingleNode("./PurchaseCost").InnerText;

                        }
                        //Get all field values for ExpenseAccountRef aggregate
                        XmlNode ExpenseAccountRef = Child.SelectSingleNode("./ExpenseAccountRef");
                        if (ExpenseAccountRef != null)
                        {
                            //Get value of ListID
                            if (Child.SelectSingleNode("./ExpenseAccountRef/ListID") != null)
                            {
                                string ListID = Child.SelectSingleNode("./ExpenseAccountRef/ListID").InnerText;

                            }
                            //Get value of FullName
                            if (Child.SelectSingleNode("./ExpenseAccountRef/FullName") != null)
                            {
                                string FullName = Child.SelectSingleNode("./ExpenseAccountRef/FullName").InnerText;

                            }

                        }
                        //Done with field values for ExpenseAccountRef aggregate

                        //Get all field values for PrefVendorRef aggregate
                        XmlNode PrefVendorRef = Child.SelectSingleNode("./PrefVendorRef");
                        if (PrefVendorRef != null)
                        {
                            //Get value of ListID
                            if (Child.SelectSingleNode("./PrefVendorRef/ListID") != null)
                            {
                                string ListID = Child.SelectSingleNode("./PrefVendorRef/ListID").InnerText;

                            }
                            //Get value of FullName
                            if (Child.SelectSingleNode("./PrefVendorRef/FullName") != null)
                            {
                                string FullName = Child.SelectSingleNode("./PrefVendorRef/FullName").InnerText;

                            }

                        }
                        //Done with field values for PrefVendorRef aggregate

                    }

                }

                //Get value of ExternalGUID
                if (OR.SelectSingleNode("./ItemNonInventoryRet/ExternalGUID") != null)
                {
                    string ExternalGUID = OR.SelectSingleNode("./ItemNonInventoryRet/ExternalGUID").InnerText;

                }
                //Walk list of DataExtRet aggregates
                XmlNodeList DataExtRetList = OR.SelectNodes("./ItemNonInventoryRet/DataExtRet");
                if (DataExtRetList != null)
                {
                    for (int i = 0; i < DataExtRetList.Count; i++)
                    {
                        XmlNode DataExtRet = DataExtRetList.Item(i);
                        //Get value of OwnerID
                        if (DataExtRet.SelectSingleNode("./OwnerID") != null)
                        {
                            string OwnerID = DataExtRet.SelectSingleNode("./OwnerID").InnerText;

                        }
                        //Get value of DataExtName
                        string DataExtName = DataExtRet.SelectSingleNode("./DataExtName").InnerText;
                        //Get value of DataExtType
                        string DataExtType = DataExtRet.SelectSingleNode("./DataExtType").InnerText;
                        //Get value of DataExtValue
                        string DataExtValue = DataExtRet.SelectSingleNode("./DataExtValue").InnerText;

                    }

                }

                */

            }
            //Done with field values for ItemNonInventoryRet aggregate

            //Get all field values for ItemOtherChargeRet aggregate
            //XmlNode ItemOtherChargeRet = OR.SelectSingleNode("./ItemOtherChargeRet");
            if (OR.Name == "ItemOtherChargeRet")
            {
                //Get value of ListID
                string ListID = OR.SelectSingleNode("./ListID").InnerText;
                //Get value of TimeCreated
                string TimeCreated = OR.SelectSingleNode("./TimeCreated").InnerText;
                //Get value of TimeModified
                string TimeModified = OR.SelectSingleNode("./TimeModified").InnerText;
                //Get value of EditSequence
                string EditSequence = OR.SelectSingleNode("./EditSequence").InnerText;
                //Get value of Name
                string Name = OR.SelectSingleNode("./Name").InnerText;
                //Get value of FullName
                string FullName = OR.SelectSingleNode("./FullName").InnerText;
                //Get value of BarCodeValue
                if (OR.SelectSingleNode("./BarCodeValue") != null)
                {
                    string BarCodeValue = OR.SelectSingleNode("./BarCodeValue").InnerText;
                }
                //Get value of IsActive
                string IsActive = "false";
                if (OR.SelectSingleNode("./IsActive") != null)
                {
                    IsActive = OR.SelectSingleNode("./IsActive").InnerText;
                }

                Item o = ItemDAL.FindOrCreateItem(db, ListID, EditSequence, TimeCreated, TimeModified, Name, FullName, IsActive, "ItemOtherCharge");
                db.SaveChanges();

                // Now call WalkItemOtherChargeRet to store data in our mileage rate table, if it applies.
                WalkItemOtherChargeRet(OR);

                /*
                //Get all field values for ClassRef aggregate
                XmlNode ClassRef = OR.SelectSingleNode("./ItemOtherChargeRet/ClassRef");
                if (ClassRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemOtherChargeRet/ClassRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemOtherChargeRet/ClassRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemOtherChargeRet/ClassRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemOtherChargeRet/ClassRef/FullName").InnerText;

                    }

                }
                //Done with field values for ClassRef aggregate

                //Get all field values for ParentRef aggregate
                XmlNode ParentRef = OR.SelectSingleNode("./ItemOtherChargeRet/ParentRef");
                if (ParentRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemOtherChargeRet/ParentRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemOtherChargeRet/ParentRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemOtherChargeRet/ParentRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemOtherChargeRet/ParentRef/FullName").InnerText;

                    }

                }
                //Done with field values for ParentRef aggregate

                //Get value of Sublevel
                string Sublevel = OR.SelectSingleNode("./ItemOtherChargeRet/Sublevel").InnerText;
                //Get all field values for SalesTaxCodeRef aggregate
                XmlNode SalesTaxCodeRef = OR.SelectSingleNode("./ItemOtherChargeRet/SalesTaxCodeRef");
                if (SalesTaxCodeRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemOtherChargeRet/SalesTaxCodeRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemOtherChargeRet/SalesTaxCodeRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemOtherChargeRet/SalesTaxCodeRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemOtherChargeRet/SalesTaxCodeRef/FullName").InnerText;

                    }

                }
                //Done with field values for SalesTaxCodeRef aggregate

                XmlNodeList ORSalesPurchaseChildren = OR.SelectNodes("./ItemOtherChargeRet/*");
                for (int i = 0; i < ORSalesPurchaseChildren.Count; i++)
                {
                    XmlNode Child = ORSalesPurchaseChildren.Item(i);
                    if (Child.Name == "SalesOrPurchase")
                    {
                        //Get value of Desc
                        if (Child.SelectSingleNode("./Desc") != null)
                        {
                            string Desc = Child.SelectSingleNode("./Desc").InnerText;

                        }
                        XmlNodeList ORPriceChildren = Child.SelectNodes("./*");
                        for (int i = 0; i < ORPriceChildren.Count; i++)
                        {
                            XmlNode Child = ORPriceChildren.Item(i);
                            if (Child.Name == "Price")
                            {
                            }

                            if (Child.Name == "PricePercent")
                            {
                            }

                        }

                        //Get all field values for AccountRef aggregate
                        XmlNode AccountRef = Child.SelectSingleNode("./AccountRef");
                        if (AccountRef != null)
                        {
                            //Get value of ListID
                            if (Child.SelectSingleNode("./AccountRef/ListID") != null)
                            {
                                string ListID = Child.SelectSingleNode("./AccountRef/ListID").InnerText;

                            }
                            //Get value of FullName
                            if (Child.SelectSingleNode("./AccountRef/FullName") != null)
                            {
                                string FullName = Child.SelectSingleNode("./AccountRef/FullName").InnerText;

                            }

                        }
                        //Done with field values for AccountRef aggregate

                    }

                    if (Child.Name == "SalesAndPurchase")
                    {
                        //Get value of SalesDesc
                        if (Child.SelectSingleNode("./SalesDesc") != null)
                        {
                            string SalesDesc = Child.SelectSingleNode("./SalesDesc").InnerText;

                        }
                        //Get value of SalesPrice
                        if (Child.SelectSingleNode("./SalesPrice") != null)
                        {
                            string SalesPrice = Child.SelectSingleNode("./SalesPrice").InnerText;

                        }
                        //Get all field values for IncomeAccountRef aggregate
                        XmlNode IncomeAccountRef = Child.SelectSingleNode("./IncomeAccountRef");
                        if (IncomeAccountRef != null)
                        {
                            //Get value of ListID
                            if (Child.SelectSingleNode("./IncomeAccountRef/ListID") != null)
                            {
                                string ListID = Child.SelectSingleNode("./IncomeAccountRef/ListID").InnerText;

                            }
                            //Get value of FullName
                            if (Child.SelectSingleNode("./IncomeAccountRef/FullName") != null)
                            {
                                string FullName = Child.SelectSingleNode("./IncomeAccountRef/FullName").InnerText;

                            }

                        }
                        //Done with field values for IncomeAccountRef aggregate

                        //Get value of PurchaseDesc
                        if (Child.SelectSingleNode("./PurchaseDesc") != null)
                        {
                            string PurchaseDesc = Child.SelectSingleNode("./PurchaseDesc").InnerText;

                        }
                        //Get value of PurchaseCost
                        if (Child.SelectSingleNode("./PurchaseCost") != null)
                        {
                            string PurchaseCost = Child.SelectSingleNode("./PurchaseCost").InnerText;

                        }
                        //Get all field values for ExpenseAccountRef aggregate
                        XmlNode ExpenseAccountRef = Child.SelectSingleNode("./ExpenseAccountRef");
                        if (ExpenseAccountRef != null)
                        {
                            //Get value of ListID
                            if (Child.SelectSingleNode("./ExpenseAccountRef/ListID") != null)
                            {
                                string ListID = Child.SelectSingleNode("./ExpenseAccountRef/ListID").InnerText;

                            }
                            //Get value of FullName
                            if (Child.SelectSingleNode("./ExpenseAccountRef/FullName") != null)
                            {
                                string FullName = Child.SelectSingleNode("./ExpenseAccountRef/FullName").InnerText;

                            }

                        }
                        //Done with field values for ExpenseAccountRef aggregate

                        //Get all field values for PrefVendorRef aggregate
                        XmlNode PrefVendorRef = Child.SelectSingleNode("./PrefVendorRef");
                        if (PrefVendorRef != null)
                        {
                            //Get value of ListID
                            if (Child.SelectSingleNode("./PrefVendorRef/ListID") != null)
                            {
                                string ListID = Child.SelectSingleNode("./PrefVendorRef/ListID").InnerText;

                            }
                            //Get value of FullName
                            if (Child.SelectSingleNode("./PrefVendorRef/FullName") != null)
                            {
                                string FullName = Child.SelectSingleNode("./PrefVendorRef/FullName").InnerText;

                            }

                        }
                        //Done with field values for PrefVendorRef aggregate

                    }

                }

                //Get value of SpecialItemType
                if (OR.SelectSingleNode("./ItemOtherChargeRet/SpecialItemType") != null)
                {
                    string SpecialItemType = OR.SelectSingleNode("./ItemOtherChargeRet/SpecialItemType").InnerText;

                }
                //Get value of ExternalGUID
                if (OR.SelectSingleNode("./ItemOtherChargeRet/ExternalGUID") != null)
                {
                    string ExternalGUID = OR.SelectSingleNode("./ItemOtherChargeRet/ExternalGUID").InnerText;

                }
                //Walk list of DataExtRet aggregates
                XmlNodeList DataExtRetList = OR.SelectNodes("./ItemOtherChargeRet/DataExtRet");
                if (DataExtRetList != null)
                {
                    for (int i = 0; i < DataExtRetList.Count; i++)
                    {
                        XmlNode DataExtRet = DataExtRetList.Item(i);
                        //Get value of OwnerID
                        if (DataExtRet.SelectSingleNode("./OwnerID") != null)
                        {
                            string OwnerID = DataExtRet.SelectSingleNode("./OwnerID").InnerText;

                        }
                        //Get value of DataExtName
                        string DataExtName = DataExtRet.SelectSingleNode("./DataExtName").InnerText;
                        //Get value of DataExtType
                        string DataExtType = DataExtRet.SelectSingleNode("./DataExtType").InnerText;
                        //Get value of DataExtValue
                        string DataExtValue = DataExtRet.SelectSingleNode("./DataExtValue").InnerText;

                    }

                }

                */
            }
            //Done with field values for ItemOtherChargeRet aggregate

            //Get all field values for ItemInventoryRet aggregate
            //XmlNode ItemInventoryRet = OR.SelectSingleNode("./ItemInventoryRet");
            if (OR.Name == "ItemInventoryRet")
            {
                //Get value of ListID
                string ListID = OR.SelectSingleNode("./ListID").InnerText;
                //Get value of TimeCreated
                string TimeCreated = OR.SelectSingleNode("./TimeCreated").InnerText;
                //Get value of TimeModified
                string TimeModified = OR.SelectSingleNode("./TimeModified").InnerText;
                //Get value of EditSequence
                string EditSequence = OR.SelectSingleNode("./EditSequence").InnerText;
                //Get value of Name
                string Name = OR.SelectSingleNode("./Name").InnerText;
                //Get value of FullName
                string FullName = OR.SelectSingleNode("./FullName").InnerText;
                //Get value of BarCodeValue
                if (OR.SelectSingleNode("./BarCodeValue") != null)
                {
                    string BarCodeValue = OR.SelectSingleNode("./BarCodeValue").InnerText;
                }
                //Get value of IsActive
                string IsActive = "false";
                if (OR.SelectSingleNode("./IsActive") != null)
                {
                    IsActive = OR.SelectSingleNode("./IsActive").InnerText;
                }

                Item o = ItemDAL.FindOrCreateItem(db, ListID, EditSequence, TimeCreated, TimeModified, Name, FullName, IsActive, "ItemInventory");
                //db.SaveChanges();

                /*
                //Get all field values for ClassRef aggregate
                XmlNode ClassRef = OR.SelectSingleNode("./ItemInventoryRet/ClassRef");
                if (ClassRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemInventoryRet/ClassRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemInventoryRet/ClassRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemInventoryRet/ClassRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemInventoryRet/ClassRef/FullName").InnerText;

                    }

                }
                //Done with field values for ClassRef aggregate

                //Get all field values for ParentRef aggregate
                XmlNode ParentRef = OR.SelectSingleNode("./ItemInventoryRet/ParentRef");
                if (ParentRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemInventoryRet/ParentRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemInventoryRet/ParentRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemInventoryRet/ParentRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemInventoryRet/ParentRef/FullName").InnerText;

                    }

                }
                //Done with field values for ParentRef aggregate

                //Get value of Sublevel
                string Sublevel = OR.SelectSingleNode("./ItemInventoryRet/Sublevel").InnerText;
                */

                //Get value of ManufacturerPartNumber
                if (OR.SelectSingleNode("./ManufacturerPartNumber") != null)
                {
                    string ManufacturerPartNumber = OR.SelectSingleNode("./ManufacturerPartNumber").InnerText;
                    o.ItemNumber = ManufacturerPartNumber;
                }

                //Get all field values for UnitOfMeasureSetRef aggregate
                XmlNode UnitOfMeasureSetRef = OR.SelectSingleNode("./UnitOfMeasureSetRef");
                if (UnitOfMeasureSetRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./UnitOfMeasureSetRef/ListID") != null)
                    {
                        string UOMListID = OR.SelectSingleNode("./UnitOfMeasureSetRef/ListID").InnerText;
                        o.UnitOfMeasure = UOMListID;
                    }
                    /*
                    //Get value of FullName
                    if (OR.SelectSingleNode("./UnitOfMeasureSetRef/FullName") != null)
                    {
                        string UOMFullName = OR.SelectSingleNode("./UnitOfMeasureSetRef/FullName").InnerText;
                    }
                    */
                }
                //Done with field values for UnitOfMeasureSetRef aggregate

                /*
                //Get all field values for SalesTaxCodeRef aggregate
                XmlNode SalesTaxCodeRef = OR.SelectSingleNode("./ItemInventoryRet/SalesTaxCodeRef");
                if (SalesTaxCodeRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemInventoryRet/SalesTaxCodeRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemInventoryRet/SalesTaxCodeRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemInventoryRet/SalesTaxCodeRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemInventoryRet/SalesTaxCodeRef/FullName").InnerText;

                    }

                }
                //Done with field values for SalesTaxCodeRef aggregate
                */
                //Get value of SalesDesc
                if (OR.SelectSingleNode("./SalesDesc") != null)
                {
                    string SalesDesc = OR.SelectSingleNode("./SalesDesc").InnerText;
                    o.Description = SalesDesc;
                }

                /*
                //Get value of SalesPrice
                if (OR.SelectSingleNode("./ItemInventoryRet/SalesPrice") != null)
                {
                    string SalesPrice = OR.SelectSingleNode("./ItemInventoryRet/SalesPrice").InnerText;

                }
                //Get all field values for IncomeAccountRef aggregate
                XmlNode IncomeAccountRef = OR.SelectSingleNode("./ItemInventoryRet/IncomeAccountRef");
                if (IncomeAccountRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemInventoryRet/IncomeAccountRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemInventoryRet/IncomeAccountRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemInventoryRet/IncomeAccountRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemInventoryRet/IncomeAccountRef/FullName").InnerText;

                    }

                }
                //Done with field values for IncomeAccountRef aggregate

                //Get value of PurchaseDesc
                if (OR.SelectSingleNode("./ItemInventoryRet/PurchaseDesc") != null)
                {
                    string PurchaseDesc = OR.SelectSingleNode("./ItemInventoryRet/PurchaseDesc").InnerText;

                }
                //Get value of PurchaseCost
                if (OR.SelectSingleNode("./ItemInventoryRet/PurchaseCost") != null)
                {
                    string PurchaseCost = OR.SelectSingleNode("./ItemInventoryRet/PurchaseCost").InnerText;

                }
                //Get all field values for COGSAccountRef aggregate
                XmlNode COGSAccountRef = OR.SelectSingleNode("./ItemInventoryRet/COGSAccountRef");
                if (COGSAccountRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemInventoryRet/COGSAccountRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemInventoryRet/COGSAccountRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemInventoryRet/COGSAccountRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemInventoryRet/COGSAccountRef/FullName").InnerText;

                    }

                }
                //Done with field values for COGSAccountRef aggregate

                //Get all field values for PrefVendorRef aggregate
                XmlNode PrefVendorRef = OR.SelectSingleNode("./ItemInventoryRet/PrefVendorRef");
                if (PrefVendorRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemInventoryRet/PrefVendorRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemInventoryRet/PrefVendorRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemInventoryRet/PrefVendorRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemInventoryRet/PrefVendorRef/FullName").InnerText;

                    }

                }
                //Done with field values for PrefVendorRef aggregate

                //Get all field values for AssetAccountRef aggregate
                XmlNode AssetAccountRef = OR.SelectSingleNode("./ItemInventoryRet/AssetAccountRef");
                if (AssetAccountRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemInventoryRet/AssetAccountRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemInventoryRet/AssetAccountRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemInventoryRet/AssetAccountRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemInventoryRet/AssetAccountRef/FullName").InnerText;

                    }

                }
                //Done with field values for AssetAccountRef aggregate

                //Get value of ReorderPoint
                if (OR.SelectSingleNode("./ItemInventoryRet/ReorderPoint") != null)
                {
                    string ReorderPoint = OR.SelectSingleNode("./ItemInventoryRet/ReorderPoint").InnerText;

                }
                //Get value of QuantityOnHand
                if (OR.SelectSingleNode("./ItemInventoryRet/QuantityOnHand") != null)
                {
                    string QuantityOnHand = OR.SelectSingleNode("./ItemInventoryRet/QuantityOnHand").InnerText;

                }
                */
                //Get value of AverageCost
                if (OR.SelectSingleNode("./AverageCost") != null)
                {
                    string AverageCost = OR.SelectSingleNode("./AverageCost").InnerText;
                    o.AverageCost = 0.0M;
                    decimal amount;
                    if (Decimal.TryParse(AverageCost, out amount))
                    {
                        o.AverageCost = amount;
                    }
                }

                /*
                //Get value of QuantityOnOrder
                if (OR.SelectSingleNode("./ItemInventoryRet/QuantityOnOrder") != null)
                {
                    string QuantityOnOrder = OR.SelectSingleNode("./ItemInventoryRet/QuantityOnOrder").InnerText;

                }
                //Get value of QuantityOnSalesOrder
                if (OR.SelectSingleNode("./ItemInventoryRet/QuantityOnSalesOrder") != null)
                {
                    string QuantityOnSalesOrder = OR.SelectSingleNode("./ItemInventoryRet/QuantityOnSalesOrder").InnerText;

                }
                //Get value of ExternalGUID
                if (OR.SelectSingleNode("./ItemInventoryRet/ExternalGUID") != null)
                {
                    string ExternalGUID = OR.SelectSingleNode("./ItemInventoryRet/ExternalGUID").InnerText;

                }
                //Walk list of DataExtRet aggregates
                XmlNodeList DataExtRetList = OR.SelectNodes("./ItemInventoryRet/DataExtRet");
                if (DataExtRetList != null)
                {
                    for (int i = 0; i < DataExtRetList.Count; i++)
                    {
                        XmlNode DataExtRet = DataExtRetList.Item(i);
                        //Get value of OwnerID
                        if (DataExtRet.SelectSingleNode("./OwnerID") != null)
                        {
                            string OwnerID = DataExtRet.SelectSingleNode("./OwnerID").InnerText;

                        }
                        //Get value of DataExtName
                        string DataExtName = DataExtRet.SelectSingleNode("./DataExtName").InnerText;
                        //Get value of DataExtType
                        string DataExtType = DataExtRet.SelectSingleNode("./DataExtType").InnerText;
                        //Get value of DataExtValue
                        string DataExtValue = DataExtRet.SelectSingleNode("./DataExtValue").InnerText;

                    }

                }
                */

                // Save DB Changes
                db.SaveChanges();
            }
            //Done with field values for ItemInventoryRet aggregate

            //Get all field values for ItemInventoryAssemblyRet aggregate
            //XmlNode ItemInventoryAssemblyRet = OR.SelectSingleNode("./ItemInventoryAssemblyRet");
            if (OR.Name == "ItemInventoryAssemblyRet")
            {
                //Get value of ListID
                string ListID = OR.SelectSingleNode("./ListID").InnerText;
                //Get value of TimeCreated
                string TimeCreated = OR.SelectSingleNode("./TimeCreated").InnerText;
                //Get value of TimeModified
                string TimeModified = OR.SelectSingleNode("./TimeModified").InnerText;
                //Get value of EditSequence
                string EditSequence = OR.SelectSingleNode("./EditSequence").InnerText;
                //Get value of Name
                string Name = OR.SelectSingleNode("./Name").InnerText;
                //Get value of FullName
                string FullName = OR.SelectSingleNode("./FullName").InnerText;
                //Get value of BarCodeValue
                if (OR.SelectSingleNode("./BarCodeValue") != null)
                {
                    string BarCodeValue = OR.SelectSingleNode("./BarCodeValue").InnerText;
                }
                //Get value of IsActive
                string IsActive = "false";
                if (OR.SelectSingleNode("./IsActive") != null)
                {
                    IsActive = OR.SelectSingleNode("./IsActive").InnerText;
                }

                Item o = ItemDAL.FindOrCreateItem(db, ListID, EditSequence, TimeCreated, TimeModified, Name, FullName, IsActive, "ItemInventoryAssembly");
                //db.SaveChanges();

                /*
                //Get all field values for ClassRef aggregate
                XmlNode ClassRef = OR.SelectSingleNode("./ItemInventoryAssemblyRet/ClassRef");
                if (ClassRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/ClassRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemInventoryAssemblyRet/ClassRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/ClassRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemInventoryAssemblyRet/ClassRef/FullName").InnerText;

                    }

                }
                //Done with field values for ClassRef aggregate

                //Get all field values for ParentRef aggregate
                XmlNode ParentRef = OR.SelectSingleNode("./ItemInventoryAssemblyRet/ParentRef");
                if (ParentRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/ParentRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemInventoryAssemblyRet/ParentRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/ParentRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemInventoryAssemblyRet/ParentRef/FullName").InnerText;

                    }

                }
                //Done with field values for ParentRef aggregate

                //Get value of Sublevel
                string Sublevel = OR.SelectSingleNode("./ItemInventoryAssemblyRet/Sublevel").InnerText;
                */

                //Get value of ManufacturerPartNumber
                if (OR.SelectSingleNode("./ManufacturerPartNumber") != null)
                {
                    string ManufacturerPartNumber = OR.SelectSingleNode("./ManufacturerPartNumber").InnerText;
                    o.ItemNumber = ManufacturerPartNumber;
                }

                //Get all field values for UnitOfMeasureSetRef aggregate
                XmlNode UnitOfMeasureSetRef = OR.SelectSingleNode("./UnitOfMeasureSetRef");
                if (UnitOfMeasureSetRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./UnitOfMeasureSetRef/ListID") != null)
                    {
                        string UOMListID = OR.SelectSingleNode("./UnitOfMeasureSetRef/ListID").InnerText;
                        o.UnitOfMeasure = UOMListID;
                    }
                    /*
                    //Get value of FullName
                    if (OR.SelectSingleNode("./UnitOfMeasureSetRef/FullName") != null)
                    {
                        string UOMFullName = OR.SelectSingleNode("./UnitOfMeasureSetRef/FullName").InnerText;
                    }
                    */
                }

                /*
                //Done with field values for UnitOfMeasureSetRef aggregate

                //Get all field values for SalesTaxCodeRef aggregate
                XmlNode SalesTaxCodeRef = OR.SelectSingleNode("./ItemInventoryAssemblyRet/SalesTaxCodeRef");
                if (SalesTaxCodeRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/SalesTaxCodeRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemInventoryAssemblyRet/SalesTaxCodeRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/SalesTaxCodeRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemInventoryAssemblyRet/SalesTaxCodeRef/FullName").InnerText;

                    }

                }
                //Done with field values for SalesTaxCodeRef aggregate
                */
                //Get value of SalesDesc
                if (OR.SelectSingleNode("./SalesDesc") != null)
                {
                    string SalesDesc = OR.SelectSingleNode("./SalesDesc").InnerText;
                    o.Description = SalesDesc;
                }
                /*
                //Get value of SalesPrice
                if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/SalesPrice") != null)
                {
                    string SalesPrice = OR.SelectSingleNode("./ItemInventoryAssemblyRet/SalesPrice").InnerText;

                }
                //Get all field values for IncomeAccountRef aggregate
                XmlNode IncomeAccountRef = OR.SelectSingleNode("./ItemInventoryAssemblyRet/IncomeAccountRef");
                if (IncomeAccountRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/IncomeAccountRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemInventoryAssemblyRet/IncomeAccountRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/IncomeAccountRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemInventoryAssemblyRet/IncomeAccountRef/FullName").InnerText;

                    }

                }
                //Done with field values for IncomeAccountRef aggregate

                //Get value of PurchaseDesc
                if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/PurchaseDesc") != null)
                {
                    string PurchaseDesc = OR.SelectSingleNode("./ItemInventoryAssemblyRet/PurchaseDesc").InnerText;

                }
                //Get value of PurchaseCost
                if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/PurchaseCost") != null)
                {
                    string PurchaseCost = OR.SelectSingleNode("./ItemInventoryAssemblyRet/PurchaseCost").InnerText;

                }
                //Get all field values for COGSAccountRef aggregate
                XmlNode COGSAccountRef = OR.SelectSingleNode("./ItemInventoryAssemblyRet/COGSAccountRef");
                if (COGSAccountRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/COGSAccountRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemInventoryAssemblyRet/COGSAccountRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/COGSAccountRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemInventoryAssemblyRet/COGSAccountRef/FullName").InnerText;

                    }

                }
                //Done with field values for COGSAccountRef aggregate

                //Get all field values for PrefVendorRef aggregate
                XmlNode PrefVendorRef = OR.SelectSingleNode("./ItemInventoryAssemblyRet/PrefVendorRef");
                if (PrefVendorRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/PrefVendorRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemInventoryAssemblyRet/PrefVendorRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/PrefVendorRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemInventoryAssemblyRet/PrefVendorRef/FullName").InnerText;

                    }

                }
                //Done with field values for PrefVendorRef aggregate

                //Get all field values for AssetAccountRef aggregate
                XmlNode AssetAccountRef = OR.SelectSingleNode("./ItemInventoryAssemblyRet/AssetAccountRef");
                if (AssetAccountRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/AssetAccountRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemInventoryAssemblyRet/AssetAccountRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/AssetAccountRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemInventoryAssemblyRet/AssetAccountRef/FullName").InnerText;

                    }

                }
                //Done with field values for AssetAccountRef aggregate

                //Get value of BuildPoint
                if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/BuildPoint") != null)
                {
                    string BuildPoint = OR.SelectSingleNode("./ItemInventoryAssemblyRet/BuildPoint").InnerText;

                }
                //Get value of QuantityOnHand
                if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/QuantityOnHand") != null)
                {
                    string QuantityOnHand = OR.SelectSingleNode("./ItemInventoryAssemblyRet/QuantityOnHand").InnerText;

                }

                */
                //Get value of AverageCost
                if (OR.SelectSingleNode("./AverageCost") != null)
                {
                    string AverageCost = OR.SelectSingleNode("./AverageCost").InnerText;
                    o.AverageCost = 0.0M;
                    decimal amount;
                    if (Decimal.TryParse(AverageCost, out amount))
                    {
                        o.AverageCost = amount;
                    }
                }

                /*
                //Get value of QuantityOnOrder
                if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/QuantityOnOrder") != null)
                {
                    string QuantityOnOrder = OR.SelectSingleNode("./ItemInventoryAssemblyRet/QuantityOnOrder").InnerText;

                }
                //Get value of QuantityOnSalesOrder
                if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/QuantityOnSalesOrder") != null)
                {
                    string QuantityOnSalesOrder = OR.SelectSingleNode("./ItemInventoryAssemblyRet/QuantityOnSalesOrder").InnerText;

                }
                //Get value of ExternalGUID
                if (OR.SelectSingleNode("./ItemInventoryAssemblyRet/ExternalGUID") != null)
                {
                    string ExternalGUID = OR.SelectSingleNode("./ItemInventoryAssemblyRet/ExternalGUID").InnerText;

                }
                //Walk list of ItemInventoryAssemblyLine aggregates
                XmlNodeList ItemInventoryAssemblyLineList = OR.SelectNodes("./ItemInventoryAssemblyRet/ItemInventoryAssemblyLine");
                if (ItemInventoryAssemblyLineList != null)
                {
                    for (int i = 0; i < ItemInventoryAssemblyLineList.Count; i++)
                    {
                        XmlNode ItemInventoryAssemblyLine = ItemInventoryAssemblyLineList.Item(i);
                        //Get all field values for ItemInventoryRef aggregate
                        //Get value of ListID
                        if (ItemInventoryAssemblyLine.SelectSingleNode("./ItemInventoryRef/ListID") != null)
                        {
                            string ListID = ItemInventoryAssemblyLine.SelectSingleNode("./ItemInventoryRef/ListID").InnerText;

                        }
                        //Get value of FullName
                        if (ItemInventoryAssemblyLine.SelectSingleNode("./ItemInventoryRef/FullName") != null)
                        {
                            string FullName = ItemInventoryAssemblyLine.SelectSingleNode("./ItemInventoryRef/FullName").InnerText;

                        }
                        //Done with field values for ItemInventoryRef aggregate

                        //Get value of Quantity
                        if (ItemInventoryAssemblyLine.SelectSingleNode("./Quantity") != null)
                        {
                            string Quantity = ItemInventoryAssemblyLine.SelectSingleNode("./Quantity").InnerText;

                        }

                    }

                }

                //Walk list of DataExtRet aggregates
                XmlNodeList DataExtRetList = OR.SelectNodes("./ItemInventoryAssemblyRet/DataExtRet");
                if (DataExtRetList != null)
                {
                    for (int i = 0; i < DataExtRetList.Count; i++)
                    {
                        XmlNode DataExtRet = DataExtRetList.Item(i);
                        //Get value of OwnerID
                        if (DataExtRet.SelectSingleNode("./OwnerID") != null)
                        {
                            string OwnerID = DataExtRet.SelectSingleNode("./OwnerID").InnerText;

                        }
                        //Get value of DataExtName
                        string DataExtName = DataExtRet.SelectSingleNode("./DataExtName").InnerText;
                        //Get value of DataExtType
                        string DataExtType = DataExtRet.SelectSingleNode("./DataExtType").InnerText;
                        //Get value of DataExtValue
                        string DataExtValue = DataExtRet.SelectSingleNode("./DataExtValue").InnerText;

                    }

                }

                */
                db.SaveChanges();
            }
            //Done with field values for ItemInventoryAssemblyRet aggregate

            //Get all field values for ItemFixedAssetRet aggregate
            //XmlNode ItemFixedAssetRet = OR.SelectSingleNode("./ItemFixedAssetRet");
            if (OR.Name == "ItemFixedAssetRet")
            {
                //Get value of ListID
                string ListID = OR.SelectSingleNode("./ListID").InnerText;
                //Get value of TimeCreated
                string TimeCreated = OR.SelectSingleNode("./TimeCreated").InnerText;
                //Get value of TimeModified
                string TimeModified = OR.SelectSingleNode("./TimeModified").InnerText;
                //Get value of EditSequence
                string EditSequence = OR.SelectSingleNode("./EditSequence").InnerText;
                //Get value of Name
                string Name = OR.SelectSingleNode("./Name").InnerText;
                //Get value of BarCodeValue
                if (OR.SelectSingleNode("./BarCodeValue") != null)
                {
                    string BarCodeValue = OR.SelectSingleNode("./BarCodeValue").InnerText;
                }
                //Get value of IsActive
                string IsActive = "false";
                if (OR.SelectSingleNode("./IsActive") != null)
                {
                    IsActive = OR.SelectSingleNode("./IsActive").InnerText;
                }

                Item o = ItemDAL.FindOrCreateItem(db, ListID, EditSequence, TimeCreated, TimeModified, Name, Name, IsActive, "ItemFixedAsset");
                db.SaveChanges();

                /*
                //Get all field values for ClassRef aggregate
                XmlNode ClassRef = OR.SelectSingleNode("./ItemFixedAssetRet/ClassRef");
                if (ClassRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemFixedAssetRet/ClassRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemFixedAssetRet/ClassRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemFixedAssetRet/ClassRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemFixedAssetRet/ClassRef/FullName").InnerText;

                    }

                }
                //Done with field values for ClassRef aggregate

                //Get value of AcquiredAs
                string AcquiredAs = OR.SelectSingleNode("./ItemFixedAssetRet/AcquiredAs").InnerText;
                //Get value of PurchaseDesc
                string PurchaseDesc = OR.SelectSingleNode("./ItemFixedAssetRet/PurchaseDesc").InnerText;
                //Get value of PurchaseDate
                string PurchaseDate = OR.SelectSingleNode("./ItemFixedAssetRet/PurchaseDate").InnerText;
                //Get value of PurchaseCost
                if (OR.SelectSingleNode("./ItemFixedAssetRet/PurchaseCost") != null)
                {
                    string PurchaseCost = OR.SelectSingleNode("./ItemFixedAssetRet/PurchaseCost").InnerText;

                }
                //Get value of VendorOrPayeeName
                if (OR.SelectSingleNode("./ItemFixedAssetRet/VendorOrPayeeName") != null)
                {
                    string VendorOrPayeeName = OR.SelectSingleNode("./ItemFixedAssetRet/VendorOrPayeeName").InnerText;

                }
                //Get all field values for AssetAccountRef aggregate
                XmlNode AssetAccountRef = OR.SelectSingleNode("./ItemFixedAssetRet/AssetAccountRef");
                if (AssetAccountRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemFixedAssetRet/AssetAccountRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemFixedAssetRet/AssetAccountRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemFixedAssetRet/AssetAccountRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemFixedAssetRet/AssetAccountRef/FullName").InnerText;

                    }

                }
                //Done with field values for AssetAccountRef aggregate

                //Get all field values for FixedAssetSalesInfo aggregate
                XmlNode FixedAssetSalesInfo = OR.SelectSingleNode("./ItemFixedAssetRet/FixedAssetSalesInfo");
                if (FixedAssetSalesInfo != null)
                {
                    //Get value of SalesDesc
                    string SalesDesc = OR.SelectSingleNode("./ItemFixedAssetRet/FixedAssetSalesInfo/SalesDesc").InnerText;
                    //Get value of SalesDate
                    string SalesDate = OR.SelectSingleNode("./ItemFixedAssetRet/FixedAssetSalesInfo/SalesDate").InnerText;
                    //Get value of SalesPrice
                    if (OR.SelectSingleNode("./ItemFixedAssetRet/FixedAssetSalesInfo/SalesPrice") != null)
                    {
                        string SalesPrice = OR.SelectSingleNode("./ItemFixedAssetRet/FixedAssetSalesInfo/SalesPrice").InnerText;

                    }
                    //Get value of SalesExpense
                    if (OR.SelectSingleNode("./ItemFixedAssetRet/FixedAssetSalesInfo/SalesExpense") != null)
                    {
                        string SalesExpense = OR.SelectSingleNode("./ItemFixedAssetRet/FixedAssetSalesInfo/SalesExpense").InnerText;

                    }

                }
                //Done with field values for FixedAssetSalesInfo aggregate

                //Get value of AssetDesc
                if (OR.SelectSingleNode("./ItemFixedAssetRet/AssetDesc") != null)
                {
                    string AssetDesc = OR.SelectSingleNode("./ItemFixedAssetRet/AssetDesc").InnerText;

                }
                //Get value of Location
                if (OR.SelectSingleNode("./ItemFixedAssetRet/Location") != null)
                {
                    string Location = OR.SelectSingleNode("./ItemFixedAssetRet/Location").InnerText;

                }
                //Get value of PONumber
                if (OR.SelectSingleNode("./ItemFixedAssetRet/PONumber") != null)
                {
                    string PONumber = OR.SelectSingleNode("./ItemFixedAssetRet/PONumber").InnerText;

                }
                //Get value of SerialNumber
                if (OR.SelectSingleNode("./ItemFixedAssetRet/SerialNumber") != null)
                {
                    string SerialNumber = OR.SelectSingleNode("./ItemFixedAssetRet/SerialNumber").InnerText;

                }
                //Get value of WarrantyExpDate
                if (OR.SelectSingleNode("./ItemFixedAssetRet/WarrantyExpDate") != null)
                {
                    string WarrantyExpDate = OR.SelectSingleNode("./ItemFixedAssetRet/WarrantyExpDate").InnerText;

                }
                //Get value of Notes
                if (OR.SelectSingleNode("./ItemFixedAssetRet/Notes") != null)
                {
                    string Notes = OR.SelectSingleNode("./ItemFixedAssetRet/Notes").InnerText;

                }
                //Get value of AssetNumber
                if (OR.SelectSingleNode("./ItemFixedAssetRet/AssetNumber") != null)
                {
                    string AssetNumber = OR.SelectSingleNode("./ItemFixedAssetRet/AssetNumber").InnerText;

                }
                //Get value of CostBasis
                if (OR.SelectSingleNode("./ItemFixedAssetRet/CostBasis") != null)
                {
                    string CostBasis = OR.SelectSingleNode("./ItemFixedAssetRet/CostBasis").InnerText;

                }
                //Get value of YearEndAccumulatedDepreciation
                if (OR.SelectSingleNode("./ItemFixedAssetRet/YearEndAccumulatedDepreciation") != null)
                {
                    string YearEndAccumulatedDepreciation = OR.SelectSingleNode("./ItemFixedAssetRet/YearEndAccumulatedDepreciation").InnerText;

                }
                //Get value of YearEndBookValue
                if (OR.SelectSingleNode("./ItemFixedAssetRet/YearEndBookValue") != null)
                {
                    string YearEndBookValue = OR.SelectSingleNode("./ItemFixedAssetRet/YearEndBookValue").InnerText;

                }
                //Get value of ExternalGUID
                if (OR.SelectSingleNode("./ItemFixedAssetRet/ExternalGUID") != null)
                {
                    string ExternalGUID = OR.SelectSingleNode("./ItemFixedAssetRet/ExternalGUID").InnerText;

                }
                //Walk list of DataExtRet aggregates
                XmlNodeList DataExtRetList = OR.SelectNodes("./ItemFixedAssetRet/DataExtRet");
                if (DataExtRetList != null)
                {
                    for (int i = 0; i < DataExtRetList.Count; i++)
                    {
                        XmlNode DataExtRet = DataExtRetList.Item(i);
                        //Get value of OwnerID
                        if (DataExtRet.SelectSingleNode("./OwnerID") != null)
                        {
                            string OwnerID = DataExtRet.SelectSingleNode("./OwnerID").InnerText;

                        }
                        //Get value of DataExtName
                        string DataExtName = DataExtRet.SelectSingleNode("./DataExtName").InnerText;
                        //Get value of DataExtType
                        string DataExtType = DataExtRet.SelectSingleNode("./DataExtType").InnerText;
                        //Get value of DataExtValue
                        string DataExtValue = DataExtRet.SelectSingleNode("./DataExtValue").InnerText;

                    }

                }
                */

            }
            //Done with field values for ItemFixedAssetRet aggregate

            //Get all field values for ItemSubtotalRet aggregate
            //XmlNode ItemSubtotalRet = OR.SelectSingleNode("./ItemSubtotalRet");
            if (OR.Name == "ItemSubtotalRet")
            {
                //Get value of ListID
                string ListID = OR.SelectSingleNode("./ListID").InnerText;
                //Get value of TimeCreated
                string TimeCreated = OR.SelectSingleNode("./TimeCreated").InnerText;
                //Get value of TimeModified
                string TimeModified = OR.SelectSingleNode("./TimeModified").InnerText;
                //Get value of EditSequence
                string EditSequence = OR.SelectSingleNode("./EditSequence").InnerText;
                //Get value of Name
                string Name = OR.SelectSingleNode("./Name").InnerText;
                //Get value of BarCodeValue
                if (OR.SelectSingleNode("./BarCodeValue") != null)
                {
                    string BarCodeValue = OR.SelectSingleNode("./BarCodeValue").InnerText;
                }
                //Get value of IsActive
                string IsActive = "false";
                if (OR.SelectSingleNode("./IsActive") != null)
                {
                    IsActive = OR.SelectSingleNode("./IsActive").InnerText;
                }

                Item o = ItemDAL.FindOrCreateItem(db, ListID, EditSequence, TimeCreated, TimeModified, Name, Name, IsActive, "ItemSubtotal");
                db.SaveChanges();

                /*
                //Get value of ItemDesc
                if (OR.SelectSingleNode("./ItemSubtotalRet/ItemDesc") != null)
                {
                    string ItemDesc = OR.SelectSingleNode("./ItemSubtotalRet/ItemDesc").InnerText;

                }
                //Get value of SpecialItemType
                if (OR.SelectSingleNode("./ItemSubtotalRet/SpecialItemType") != null)
                {
                    string SpecialItemType = OR.SelectSingleNode("./ItemSubtotalRet/SpecialItemType").InnerText;

                }
                //Get value of ExternalGUID
                if (OR.SelectSingleNode("./ItemSubtotalRet/ExternalGUID") != null)
                {
                    string ExternalGUID = OR.SelectSingleNode("./ItemSubtotalRet/ExternalGUID").InnerText;

                }
                //Walk list of DataExtRet aggregates
                XmlNodeList DataExtRetList = OR.SelectNodes("./ItemSubtotalRet/DataExtRet");
                if (DataExtRetList != null)
                {
                    for (int i = 0; i < DataExtRetList.Count; i++)
                    {
                        XmlNode DataExtRet = DataExtRetList.Item(i);
                        //Get value of OwnerID
                        if (DataExtRet.SelectSingleNode("./OwnerID") != null)
                        {
                            string OwnerID = DataExtRet.SelectSingleNode("./OwnerID").InnerText;

                        }
                        //Get value of DataExtName
                        string DataExtName = DataExtRet.SelectSingleNode("./DataExtName").InnerText;
                        //Get value of DataExtType
                        string DataExtType = DataExtRet.SelectSingleNode("./DataExtType").InnerText;
                        //Get value of DataExtValue
                        string DataExtValue = DataExtRet.SelectSingleNode("./DataExtValue").InnerText;

                    }

                }
                */

            }
            //Done with field values for ItemSubtotalRet aggregate

            //Get all field values for ItemDiscountRet aggregate
            //XmlNode ItemDiscountRet = OR.SelectSingleNode("./ItemDiscountRet");
            if (OR.Name == "ItemDiscountRet")
            {
                //Get value of ListID
                string ListID = OR.SelectSingleNode("./ListID").InnerText;
                //Get value of TimeCreated
                string TimeCreated = OR.SelectSingleNode("./TimeCreated").InnerText;
                //Get value of TimeModified
                string TimeModified = OR.SelectSingleNode("./TimeModified").InnerText;
                //Get value of EditSequence
                string EditSequence = OR.SelectSingleNode("./EditSequence").InnerText;
                //Get value of Name
                string Name = OR.SelectSingleNode("./Name").InnerText;
                //Get value of FullName
                string FullName = OR.SelectSingleNode("./FullName").InnerText;
                //Get value of BarCodeValue
                if (OR.SelectSingleNode("./BarCodeValue") != null)
                {
                    string BarCodeValue = OR.SelectSingleNode("./BarCodeValue").InnerText;
                }
                //Get value of IsActive
                string IsActive = "false";
                if (OR.SelectSingleNode("./IsActive") != null)
                {
                    IsActive = OR.SelectSingleNode("./IsActive").InnerText;
                }

                Item o = ItemDAL.FindOrCreateItem(db, ListID, EditSequence, TimeCreated, TimeModified, Name, FullName, IsActive, "ItemDiscount");
                db.SaveChanges();

                /*
                //Get all field values for ClassRef aggregate
                XmlNode ClassRef = OR.SelectSingleNode("./ItemDiscountRet/ClassRef");
                if (ClassRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemDiscountRet/ClassRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemDiscountRet/ClassRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemDiscountRet/ClassRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemDiscountRet/ClassRef/FullName").InnerText;

                    }

                }
                //Done with field values for ClassRef aggregate

                //Get all field values for ParentRef aggregate
                XmlNode ParentRef = OR.SelectSingleNode("./ItemDiscountRet/ParentRef");
                if (ParentRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemDiscountRet/ParentRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemDiscountRet/ParentRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemDiscountRet/ParentRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemDiscountRet/ParentRef/FullName").InnerText;

                    }

                }
                //Done with field values for ParentRef aggregate

                //Get value of Sublevel
                string Sublevel = OR.SelectSingleNode("./ItemDiscountRet/Sublevel").InnerText;
                //Get value of ItemDesc
                if (OR.SelectSingleNode("./ItemDiscountRet/ItemDesc") != null)
                {
                    string ItemDesc = OR.SelectSingleNode("./ItemDiscountRet/ItemDesc").InnerText;

                }
                //Get all field values for SalesTaxCodeRef aggregate
                XmlNode SalesTaxCodeRef = OR.SelectSingleNode("./ItemDiscountRet/SalesTaxCodeRef");
                if (SalesTaxCodeRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemDiscountRet/SalesTaxCodeRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemDiscountRet/SalesTaxCodeRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemDiscountRet/SalesTaxCodeRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemDiscountRet/SalesTaxCodeRef/FullName").InnerText;

                    }

                }
                //Done with field values for SalesTaxCodeRef aggregate

                XmlNodeList ORDiscountRateChildren = OR.SelectNodes("./ItemDiscountRet/*");
                for (int i = 0; i < ORDiscountRateChildren.Count; i++)
                {
                    XmlNode Child = ORDiscountRateChildren.Item(i);
                    if (Child.Name == "DiscountRate")
                    {
                    }

                    if (Child.Name == "DiscountRatePercent")
                    {
                    }

                }

                //Get all field values for AccountRef aggregate
                XmlNode AccountRef = OR.SelectSingleNode("./ItemDiscountRet/AccountRef");
                if (AccountRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemDiscountRet/AccountRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemDiscountRet/AccountRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemDiscountRet/AccountRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemDiscountRet/AccountRef/FullName").InnerText;

                    }

                }
                //Done with field values for AccountRef aggregate

                //Get value of ExternalGUID
                if (OR.SelectSingleNode("./ItemDiscountRet/ExternalGUID") != null)
                {
                    string ExternalGUID = OR.SelectSingleNode("./ItemDiscountRet/ExternalGUID").InnerText;

                }
                //Walk list of DataExtRet aggregates
                XmlNodeList DataExtRetList = OR.SelectNodes("./ItemDiscountRet/DataExtRet");
                if (DataExtRetList != null)
                {
                    for (int i = 0; i < DataExtRetList.Count; i++)
                    {
                        XmlNode DataExtRet = DataExtRetList.Item(i);
                        //Get value of OwnerID
                        if (DataExtRet.SelectSingleNode("./OwnerID") != null)
                        {
                            string OwnerID = DataExtRet.SelectSingleNode("./OwnerID").InnerText;

                        }
                        //Get value of DataExtName
                        string DataExtName = DataExtRet.SelectSingleNode("./DataExtName").InnerText;
                        //Get value of DataExtType
                        string DataExtType = DataExtRet.SelectSingleNode("./DataExtType").InnerText;
                        //Get value of DataExtValue
                        string DataExtValue = DataExtRet.SelectSingleNode("./DataExtValue").InnerText;

                    }

                }

                */
            }
            //Done with field values for ItemDiscountRet aggregate

            //Get all field values for ItemPaymentRet aggregate
            //XmlNode ItemPaymentRet = OR.SelectSingleNode("./ItemPaymentRet");
            if (OR.Name == "ItemPaymentRet")
            {
                //Get value of ListID
                string ListID = OR.SelectSingleNode("./ListID").InnerText;
                //Get value of TimeCreated
                string TimeCreated = OR.SelectSingleNode("./TimeCreated").InnerText;
                //Get value of TimeModified
                string TimeModified = OR.SelectSingleNode("./TimeModified").InnerText;
                //Get value of EditSequence
                string EditSequence = OR.SelectSingleNode("./EditSequence").InnerText;
                //Get value of Name
                string Name = OR.SelectSingleNode("./Name").InnerText;
                //Get value of BarCodeValue
                if (OR.SelectSingleNode("./BarCodeValue") != null)
                {
                    string BarCodeValue = OR.SelectSingleNode("./BarCodeValue").InnerText;
                }
                //Get value of IsActive
                string IsActive = "false";
                if (OR.SelectSingleNode("./IsActive") != null)
                {
                    IsActive = OR.SelectSingleNode("./IsActive").InnerText;
                }

                Item o = ItemDAL.FindOrCreateItem(db, ListID, EditSequence, TimeCreated, TimeModified, Name, Name, IsActive, "ItemPayment");
                db.SaveChanges();

                /*
                //Get all field values for ClassRef aggregate
                XmlNode ClassRef = OR.SelectSingleNode("./ItemPaymentRet/ClassRef");
                if (ClassRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemPaymentRet/ClassRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemPaymentRet/ClassRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemPaymentRet/ClassRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemPaymentRet/ClassRef/FullName").InnerText;

                    }

                }
                //Done with field values for ClassRef aggregate

                //Get value of ItemDesc
                if (OR.SelectSingleNode("./ItemPaymentRet/ItemDesc") != null)
                {
                    string ItemDesc = OR.SelectSingleNode("./ItemPaymentRet/ItemDesc").InnerText;

                }
                //Get all field values for DepositToAccountRef aggregate
                XmlNode DepositToAccountRef = OR.SelectSingleNode("./ItemPaymentRet/DepositToAccountRef");
                if (DepositToAccountRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemPaymentRet/DepositToAccountRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemPaymentRet/DepositToAccountRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemPaymentRet/DepositToAccountRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemPaymentRet/DepositToAccountRef/FullName").InnerText;

                    }

                }
                //Done with field values for DepositToAccountRef aggregate

                //Get all field values for PaymentMethodRef aggregate
                XmlNode PaymentMethodRef = OR.SelectSingleNode("./ItemPaymentRet/PaymentMethodRef");
                if (PaymentMethodRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemPaymentRet/PaymentMethodRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemPaymentRet/PaymentMethodRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemPaymentRet/PaymentMethodRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemPaymentRet/PaymentMethodRef/FullName").InnerText;

                    }

                }
                //Done with field values for PaymentMethodRef aggregate

                //Get value of ExternalGUID
                if (OR.SelectSingleNode("./ItemPaymentRet/ExternalGUID") != null)
                {
                    string ExternalGUID = OR.SelectSingleNode("./ItemPaymentRet/ExternalGUID").InnerText;

                }
                //Walk list of DataExtRet aggregates
                XmlNodeList DataExtRetList = OR.SelectNodes("./ItemPaymentRet/DataExtRet");
                if (DataExtRetList != null)
                {
                    for (int i = 0; i < DataExtRetList.Count; i++)
                    {
                        XmlNode DataExtRet = DataExtRetList.Item(i);
                        //Get value of OwnerID
                        if (DataExtRet.SelectSingleNode("./OwnerID") != null)
                        {
                            string OwnerID = DataExtRet.SelectSingleNode("./OwnerID").InnerText;

                        }
                        //Get value of DataExtName
                        string DataExtName = DataExtRet.SelectSingleNode("./DataExtName").InnerText;
                        //Get value of DataExtType
                        string DataExtType = DataExtRet.SelectSingleNode("./DataExtType").InnerText;
                        //Get value of DataExtValue
                        string DataExtValue = DataExtRet.SelectSingleNode("./DataExtValue").InnerText;

                    }

                }

                */
            }
            //Done with field values for ItemPaymentRet aggregate

            //Get all field values for ItemSalesTaxRet aggregate
            //XmlNode ItemSalesTaxRet = OR.SelectSingleNode("./ItemSalesTaxRet");
            if (OR.Name == "ItemSalesTaxRet")
            {
                //Get value of ListID
                string ListID = OR.SelectSingleNode("./ListID").InnerText;
                //Get value of TimeCreated
                string TimeCreated = OR.SelectSingleNode("./TimeCreated").InnerText;
                //Get value of TimeModified
                string TimeModified = OR.SelectSingleNode("./TimeModified").InnerText;
                //Get value of EditSequence
                string EditSequence = OR.SelectSingleNode("./EditSequence").InnerText;
                //Get value of Name
                string Name = OR.SelectSingleNode("./Name").InnerText;
                //Get value of BarCodeValue
                if (OR.SelectSingleNode("./BarCodeValue") != null)
                {
                    string BarCodeValue = OR.SelectSingleNode("./BarCodeValue").InnerText;
                }
                //Get value of IsActive
                string IsActive = "false";
                if (OR.SelectSingleNode("./IsActive") != null)
                {
                    IsActive = OR.SelectSingleNode("./IsActive").InnerText;
                }

                Item o = ItemDAL.FindOrCreateItem(db, ListID, EditSequence, TimeCreated, TimeModified, Name, Name, IsActive, "ItemSalesTax");
                db.SaveChanges();

                /*
                //Get all field values for ClassRef aggregate
                XmlNode ClassRef = OR.SelectSingleNode("./ItemSalesTaxRet/ClassRef");
                if (ClassRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemSalesTaxRet/ClassRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemSalesTaxRet/ClassRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemSalesTaxRet/ClassRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemSalesTaxRet/ClassRef/FullName").InnerText;

                    }

                }
                //Done with field values for ClassRef aggregate

                //Get value of ItemDesc
                if (OR.SelectSingleNode("./ItemSalesTaxRet/ItemDesc") != null)
                {
                    string ItemDesc = OR.SelectSingleNode("./ItemSalesTaxRet/ItemDesc").InnerText;

                }
                //Get value of TaxRate
                if (OR.SelectSingleNode("./ItemSalesTaxRet/TaxRate") != null)
                {
                    string TaxRate = OR.SelectSingleNode("./ItemSalesTaxRet/TaxRate").InnerText;

                }
                //Get all field values for TaxVendorRef aggregate
                XmlNode TaxVendorRef = OR.SelectSingleNode("./ItemSalesTaxRet/TaxVendorRef");
                if (TaxVendorRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemSalesTaxRet/TaxVendorRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemSalesTaxRet/TaxVendorRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemSalesTaxRet/TaxVendorRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemSalesTaxRet/TaxVendorRef/FullName").InnerText;

                    }

                }
                //Done with field values for TaxVendorRef aggregate

                //Get value of ExternalGUID
                if (OR.SelectSingleNode("./ItemSalesTaxRet/ExternalGUID") != null)
                {
                    string ExternalGUID = OR.SelectSingleNode("./ItemSalesTaxRet/ExternalGUID").InnerText;

                }
                //Walk list of DataExtRet aggregates
                XmlNodeList DataExtRetList = OR.SelectNodes("./ItemSalesTaxRet/DataExtRet");
                if (DataExtRetList != null)
                {
                    for (int i = 0; i < DataExtRetList.Count; i++)
                    {
                        XmlNode DataExtRet = DataExtRetList.Item(i);
                        //Get value of OwnerID
                        if (DataExtRet.SelectSingleNode("./OwnerID") != null)
                        {
                            string OwnerID = DataExtRet.SelectSingleNode("./OwnerID").InnerText;

                        }
                        //Get value of DataExtName
                        string DataExtName = DataExtRet.SelectSingleNode("./DataExtName").InnerText;
                        //Get value of DataExtType
                        string DataExtType = DataExtRet.SelectSingleNode("./DataExtType").InnerText;
                        //Get value of DataExtValue
                        string DataExtValue = DataExtRet.SelectSingleNode("./DataExtValue").InnerText;

                    }

                }

                */
            }
            //Done with field values for ItemSalesTaxRet aggregate

            //Get all field values for ItemSalesTaxGroupRet aggregate
            //XmlNode ItemSalesTaxGroupRet = OR.SelectSingleNode("./ItemSalesTaxGroupRet");
            if (OR.Name == "ItemSalesTaxGroupRet")
            {
                //Get value of ListID
                string ListID = OR.SelectSingleNode("./ListID").InnerText;
                //Get value of TimeCreated
                string TimeCreated = OR.SelectSingleNode("./TimeCreated").InnerText;
                //Get value of TimeModified
                string TimeModified = OR.SelectSingleNode("./TimeModified").InnerText;
                //Get value of EditSequence
                string EditSequence = OR.SelectSingleNode("./EditSequence").InnerText;
                //Get value of Name
                string Name = OR.SelectSingleNode("./Name").InnerText;
                //Get value of BarCodeValue
                if (OR.SelectSingleNode("./BarCodeValue") != null)
                {
                    string BarCodeValue = OR.SelectSingleNode("./BarCodeValue").InnerText;
                }
                //Get value of IsActive
                string IsActive = "false";
                if (OR.SelectSingleNode("./IsActive") != null)
                {
                    IsActive = OR.SelectSingleNode("./IsActive").InnerText;
                }

                Item o = ItemDAL.FindOrCreateItem(db, ListID, EditSequence, TimeCreated, TimeModified, Name, Name, IsActive, "ItemSalesTaxGroup");
                db.SaveChanges();

                /*
                //Get value of ItemDesc
                if (OR.SelectSingleNode("./ItemSalesTaxGroupRet/ItemDesc") != null)
                {
                    string ItemDesc = OR.SelectSingleNode("./ItemSalesTaxGroupRet/ItemDesc").InnerText;

                }
                //Get value of ExternalGUID
                if (OR.SelectSingleNode("./ItemSalesTaxGroupRet/ExternalGUID") != null)
                {
                    string ExternalGUID = OR.SelectSingleNode("./ItemSalesTaxGroupRet/ExternalGUID").InnerText;

                }
                //Walk list of ItemSalesTaxRef aggregates
                XmlNodeList ItemSalesTaxRefList = OR.SelectNodes("./ItemSalesTaxGroupRet/ItemSalesTaxRef");
                if (ItemSalesTaxRefList != null)
                {
                    for (int i = 0; i < ItemSalesTaxRefList.Count; i++)
                    {
                        XmlNode ItemSalesTaxRef = ItemSalesTaxRefList.Item(i);
                        //Get value of ListID
                        if (ItemSalesTaxRef.SelectSingleNode("./ListID") != null)
                        {
                            string ListID = ItemSalesTaxRef.SelectSingleNode("./ListID").InnerText;

                        }
                        //Get value of FullName
                        if (ItemSalesTaxRef.SelectSingleNode("./FullName") != null)
                        {
                            string FullName = ItemSalesTaxRef.SelectSingleNode("./FullName").InnerText;

                        }

                    }

                }

                //Walk list of DataExtRet aggregates
                XmlNodeList DataExtRetList = OR.SelectNodes("./ItemSalesTaxGroupRet/DataExtRet");
                if (DataExtRetList != null)
                {
                    for (int i = 0; i < DataExtRetList.Count; i++)
                    {
                        XmlNode DataExtRet = DataExtRetList.Item(i);
                        //Get value of OwnerID
                        if (DataExtRet.SelectSingleNode("./OwnerID") != null)
                        {
                            string OwnerID = DataExtRet.SelectSingleNode("./OwnerID").InnerText;

                        }
                        //Get value of DataExtName
                        string DataExtName = DataExtRet.SelectSingleNode("./DataExtName").InnerText;
                        //Get value of DataExtType
                        string DataExtType = DataExtRet.SelectSingleNode("./DataExtType").InnerText;
                        //Get value of DataExtValue
                        string DataExtValue = DataExtRet.SelectSingleNode("./DataExtValue").InnerText;

                    }

                }

                */
            }
            //Done with field values for ItemSalesTaxGroupRet aggregate

            //Get all field values for ItemGroupRet aggregate
            //XmlNode ItemGroupRet = OR.SelectSingleNode("./ItemGroupRet");
            if (OR.Name == "ItemGroupRet")
            {
                //Get value of ListID
                string ListID = OR.SelectSingleNode("./ListID").InnerText;
                //Get value of TimeCreated
                string TimeCreated = OR.SelectSingleNode("./TimeCreated").InnerText;
                //Get value of TimeModified
                string TimeModified = OR.SelectSingleNode("./TimeModified").InnerText;
                //Get value of EditSequence
                string EditSequence = OR.SelectSingleNode("./EditSequence").InnerText;
                //Get value of Name
                string Name = OR.SelectSingleNode("./Name").InnerText;
                //Get value of BarCodeValue
                if (OR.SelectSingleNode("./BarCodeValue") != null)
                {
                    string BarCodeValue = OR.SelectSingleNode("./BarCodeValue").InnerText;
                }
                //Get value of IsActive
                string IsActive = "false";
                if (OR.SelectSingleNode("./IsActive") != null)
                {
                    IsActive = OR.SelectSingleNode("./IsActive").InnerText;
                }

                Item o = ItemDAL.FindOrCreateItem(db, ListID, EditSequence, TimeCreated, TimeModified, Name, Name, IsActive, "ItemGroup");
                db.SaveChanges();

                /*
                //Get value of ItemDesc
                if (OR.SelectSingleNode("./ItemGroupRet/ItemDesc") != null)
                {
                    string ItemDesc = OR.SelectSingleNode("./ItemGroupRet/ItemDesc").InnerText;

                }
                //Get all field values for UnitOfMeasureSetRef aggregate
                XmlNode UnitOfMeasureSetRef = OR.SelectSingleNode("./ItemGroupRet/UnitOfMeasureSetRef");
                if (UnitOfMeasureSetRef != null)
                {
                    //Get value of ListID
                    if (OR.SelectSingleNode("./ItemGroupRet/UnitOfMeasureSetRef/ListID") != null)
                    {
                        string ListID = OR.SelectSingleNode("./ItemGroupRet/UnitOfMeasureSetRef/ListID").InnerText;

                    }
                    //Get value of FullName
                    if (OR.SelectSingleNode("./ItemGroupRet/UnitOfMeasureSetRef/FullName") != null)
                    {
                        string FullName = OR.SelectSingleNode("./ItemGroupRet/UnitOfMeasureSetRef/FullName").InnerText;

                    }

                }
                //Done with field values for UnitOfMeasureSetRef aggregate

                //Get value of IsPrintItemsInGroup
                if (OR.SelectSingleNode("./ItemGroupRet/IsPrintItemsInGroup") != null)
                {
                    string IsPrintItemsInGroup = OR.SelectSingleNode("./ItemGroupRet/IsPrintItemsInGroup").InnerText;

                }
                //Get value of SpecialItemType
                if (OR.SelectSingleNode("./ItemGroupRet/SpecialItemType") != null)
                {
                    string SpecialItemType = OR.SelectSingleNode("./ItemGroupRet/SpecialItemType").InnerText;

                }
                //Get value of ExternalGUID
                if (OR.SelectSingleNode("./ItemGroupRet/ExternalGUID") != null)
                {
                    string ExternalGUID = OR.SelectSingleNode("./ItemGroupRet/ExternalGUID").InnerText;

                }
                //Walk list of ItemGroupLine aggregates
                XmlNodeList ItemGroupLineList = OR.SelectNodes("./ItemGroupRet/ItemGroupLine");
                if (ItemGroupLineList != null)
                {
                    for (int i = 0; i < ItemGroupLineList.Count; i++)
                    {
                        XmlNode ItemGroupLine = ItemGroupLineList.Item(i);
                        //Get all field values for ItemRef aggregate
                        XmlNode ItemRef = ItemGroupLine.SelectSingleNode("./ItemRef");
                        if (ItemRef != null)
                        {
                            //Get value of ListID
                            if (ItemGroupLine.SelectSingleNode("./ItemRef/ListID") != null)
                            {
                                string ListID = ItemGroupLine.SelectSingleNode("./ItemRef/ListID").InnerText;

                            }
                            //Get value of FullName
                            if (ItemGroupLine.SelectSingleNode("./ItemRef/FullName") != null)
                            {
                                string FullName = ItemGroupLine.SelectSingleNode("./ItemRef/FullName").InnerText;

                            }

                        }
                        //Done with field values for ItemRef aggregate

                        //Get value of Quantity
                        if (ItemGroupLine.SelectSingleNode("./Quantity") != null)
                        {
                            string Quantity = ItemGroupLine.SelectSingleNode("./Quantity").InnerText;

                        }
                        //Get value of UnitOfMeasure
                        if (ItemGroupLine.SelectSingleNode("./UnitOfMeasure") != null)
                        {
                            string UnitOfMeasure = ItemGroupLine.SelectSingleNode("./UnitOfMeasure").InnerText;
                        }
                    }
                }

                //Walk list of DataExtRet aggregates
                XmlNodeList DataExtRetList = OR.SelectNodes("./ItemGroupRet/DataExtRet");
                if (DataExtRetList != null)
                {
                    for (int i = 0; i < DataExtRetList.Count; i++)
                    {
                        XmlNode DataExtRet = DataExtRetList.Item(i);
                        //Get value of OwnerID
                        if (DataExtRet.SelectSingleNode("./OwnerID") != null)
                        {
                            string OwnerID = DataExtRet.SelectSingleNode("./OwnerID").InnerText;
                        }
                        //Get value of DataExtName
                        string DataExtName = DataExtRet.SelectSingleNode("./DataExtName").InnerText;
                        //Get value of DataExtType
                        string DataExtType = DataExtRet.SelectSingleNode("./DataExtType").InnerText;
                        //Get value of DataExtValue
                        string DataExtValue = DataExtRet.SelectSingleNode("./DataExtValue").InnerText;
                    }
                }
                */
            }

            //Done with field values for ItemGroupRet aggregate
        }
Example #31
0
        private static void WalkItemServiceRet(XmlNode ItemServiceRet)
        {
            if (ItemServiceRet == null) return;

            ServiceType st = null;
            RotoTrackDb db = new RotoTrackDb();

            string ListID = ItemServiceRet.SelectSingleNode("./ListID").InnerText;
            if (db.ServiceTypes.Any(f => f.QBListId == ListID))
            {
                st = db.ServiceTypes.First(f => f.QBListId == ListID);
            }
            else
            {
                st = new ServiceType();
                db.ServiceTypes.Add(st);
            }
            st.QBListId = ListID;

            string Name = ItemServiceRet.SelectSingleNode("./FullName").InnerText;
            st.Name = Name;

            string IsActive = "false";
            if (ItemServiceRet.SelectSingleNode("./IsActive") != null)
            {
                IsActive = ItemServiceRet.SelectSingleNode("./IsActive").InnerText;
            }
            st.IsActive = (IsActive == "true") ? true : false;

            XmlNode UnitOfMeasureSetRef = ItemServiceRet.SelectSingleNode("./UnitOfMeasureSetRef");
            if (UnitOfMeasureSetRef != null)
            {
                if (ItemServiceRet.SelectSingleNode("./UnitOfMeasureSetRef/FullName") != null)
                {
                    string UOMFullName = ItemServiceRet.SelectSingleNode("./UnitOfMeasureSetRef/FullName").InnerText;
                    st.UnitOfMeasure = UOMFullName;
                }
            }

            XmlNodeList ORSalesPurchaseChildren = ItemServiceRet.SelectNodes("./*");
            for (int i = 0; i < ORSalesPurchaseChildren.Count; i++)
            {
                XmlNode Child = ORSalesPurchaseChildren.Item(i);

                if (Child.Name == "SalesOrPurchase")
                {
                    if (Child.SelectSingleNode("./Desc") != null)
                    {
                        string Desc = Child.SelectSingleNode("./Desc").InnerText;
                        st.Description = Desc;
                    }
                    XmlNodeList ORPriceChildren = Child.SelectNodes("./*");
                    for (int j = 0; j < ORPriceChildren.Count; j++)
                    {
                        XmlNode Child2 = ORPriceChildren.Item(j);
                        if (Child2.Name == "Price")
                        {
                            st.Price = Child2.InnerText;
                        }
                    }
                }

                if (Child.Name == "SalesAndPurchase")
                {
                    if (Child.SelectSingleNode("./SalesDesc") != null)
                    {
                        string SalesDesc = Child.SelectSingleNode("./SalesDesc").InnerText;
                        st.Description = SalesDesc;
                    }
                    if (Child.SelectSingleNode("./SalesPrice") != null)
                    {
                        string SalesPrice = Child.SelectSingleNode("./SalesPrice").InnerText;
                        st.Price = SalesPrice;
                    }
                }
            }

            if (st != null)
            {
                db.SaveChanges();
            }
        }
        public static XmlDocument BuildAddRq(ServiceEntry se, ServiceDetail sd, int serviceId, decimal hours)
        {
            try
            {
                XmlDocument doc    = XmlUtils.MakeRequestDocument();
                XmlElement  parent = XmlUtils.MakeRequestParentElement(doc);

                RotoTrackDb db  = new RotoTrackDb();
                UserProfile u   = db.UserProfiles.Find(sd.TechnicianId);
                ServiceType st  = db.ServiceTypes.Find(serviceId);
                DSR         dsr = db.DSRs.Include("WorkOrder").First(f => f.Id == se.DSRId);
                Customer    c   = db.Customers.Find(dsr.WorkOrder.CustomerId);
                Area        a   = db.Areas.Find(u.AreaId);

                XmlElement Rq = doc.CreateElement("TimeTrackingAddRq");
                parent.AppendChild(Rq);

                XmlElement RqType = doc.CreateElement("TimeTrackingAdd");
                Rq.AppendChild(RqType);

                RqType.AppendChild(XmlUtils.MakeSimpleElem(doc, "TxnDate", se.DateWorked.ToString("yyyy-MM-dd")));

                XmlElement EntityRef = doc.CreateElement("EntityRef");
                RqType.AppendChild(EntityRef);
                EntityRef.AppendChild(XmlUtils.MakeSimpleElem(doc, "ListID", u.QBListId));

                XmlElement CustomerRef = doc.CreateElement("CustomerRef");
                RqType.AppendChild(CustomerRef);
                CustomerRef.AppendChild(XmlUtils.MakeSimpleElem(doc, "ListID", dsr.WorkOrder.QBListId));

                XmlElement ItemServiceRef = doc.CreateElement("ItemServiceRef");
                RqType.AppendChild(ItemServiceRef);
                ItemServiceRef.AppendChild(XmlUtils.MakeSimpleElem(doc, "ListID", st.QBListId));

                HoursMinutes hrsMins        = GetHoursMinutesFromDecimal(hours);
                int          hoursInteger   = hrsMins.Hours;
                int          minutesInteger = hrsMins.Minutes;

                string duration = "PT" + hoursInteger.ToString() + "H" + minutesInteger.ToString() + "M" + "0S";
                RqType.AppendChild(XmlUtils.MakeSimpleElem(doc, "Duration", duration));

                XmlElement ClassRef = doc.CreateElement("ClassRef");
                RqType.AppendChild(ClassRef);
                ClassRef.AppendChild(XmlUtils.MakeSimpleElem(doc, "ListID", a.QBListId));

                string notes = "guid=" + se.GUID;
                RqType.AppendChild(XmlUtils.MakeSimpleElem(doc, "Notes", notes));

                if (st.Name.ToUpper().StartsWith("DIRECT"))
                {
                    RqType.AppendChild(XmlUtils.MakeSimpleElem(doc, "BillableStatus", "Billable"));
                }
                else
                {
                    RqType.AppendChild(XmlUtils.MakeSimpleElem(doc, "BillableStatus", "NotBillable"));
                }

                return(doc);
            }
            catch (Exception e)
            {
                string evLogTxt = "";
                evLogTxt = "Error building time tracking add request! " + e.Message + "\r\n";
                Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + evLogTxt);
                return(null);
            }
        }
        private static void WalkTimeTrackingRetForAdd(XmlNode TimeTrackingRet)
        {
            if (TimeTrackingRet == null)
            {
                return;
            }

            string       Duration = TimeTrackingRet.SelectSingleNode("./Duration").InnerText;
            HoursMinutes hrsMins  = GetHoursMinutesFromDuration(Duration);

            if (hrsMins == null)
            {
                return;
            }

            RotoTrackDb db = new RotoTrackDb();

            string TxnID             = "";
            string seGUID            = "";
            string ItemServiceListID = "";

            if (TimeTrackingRet.SelectSingleNode("./TxnID") != null)
            {
                TxnID = TimeTrackingRet.SelectSingleNode("./TxnID").InnerText;
            }
            if (TimeTrackingRet.SelectSingleNode("./Notes") != null)
            {
                string Notes = TimeTrackingRet.SelectSingleNode("./Notes").InnerText;
                seGUID = QBUtils.GetGuidFromNotes(Notes);
            }
            XmlNode ItemServiceRef = TimeTrackingRet.SelectSingleNode("./ItemServiceRef");

            if (ItemServiceRef != null)
            {
                if (ItemServiceRef.SelectSingleNode("./ListID") != null)
                {
                    ItemServiceListID = ItemServiceRef.SelectSingleNode("./ListID").InnerText;
                }
            }

            if (TxnID != null && seGUID != null && ItemServiceListID != null)
            {
                ServiceEntry se = null;
                if (db.ServiceEntries.Any(f => f.GUID == seGUID))
                {
                    se = db.ServiceEntries.First(f => f.GUID == seGUID);
                }
                if (se != null)
                {
                    ServiceDetail sd = db.ServiceDetails.Find(se.ServiceDetailId);
                    if (sd != null)
                    {
                        ServiceType regST = db.ServiceTypes.Find(sd.ServiceTypeId);
                        ServiceType otST  = db.ServiceTypes.Find(sd.OTServiceTypeId);
                        if (regST != null && otST != null)
                        {
                            // We always update the regular hours first, so if reg and OT both have the same service list ID, then we need to also check if we already
                            // wrote out the regular hours or not--else we will put both the reg and ot hours into regular hours since we match on reg hours first.
                            // I was going to also look at the actual hours and minutes, but if those are identical, too, then this reduces to the same problem we have
                            // solved here--we just have to assume reg hours are always written first, which they are.  Also, I don't want to compare on hours/minutes
                            // because that may fail due to rounding errors.
                            if (ItemServiceListID == regST.QBListId && se.QBListIdForRegularHours == null)
                            {
                                se.QBListIdForRegularHours = TxnID;
                                db.Entry(se).State         = EntityState.Modified;
                                db.SaveChanges();
                            }
                            else if (ItemServiceListID == otST.QBListId && se.QBListIdForOTHours == null)
                            {
                                se.QBListIdForOTHours = TxnID;
                                db.Entry(se).State    = EntityState.Modified;
                                db.SaveChanges();
                            }
                        }
                    }
                }
            }
        }
        private static void WalkTimeTrackingRetForQuery(XmlNode TimeTrackingRet)
        {
            if (TimeTrackingRet == null)
            {
                return;
            }

            string QBTxnID        = TimeTrackingRet.SelectSingleNode("./TxnID").InnerText;
            string QBEditSequence = TimeTrackingRet.SelectSingleNode("./EditSequence").InnerText;
            string TxnDate        = TimeTrackingRet.SelectSingleNode("./TxnDate").InnerText;

            string QBEmployeeListID = "";

            if (TimeTrackingRet.SelectSingleNode("./EntityRef/ListID") != null)
            {
                QBEmployeeListID = TimeTrackingRet.SelectSingleNode("./EntityRef/ListID").InnerText;
            }

            string  QBWorkOrderListID = "";
            XmlNode CustomerRef       = TimeTrackingRet.SelectSingleNode("./CustomerRef");

            if (CustomerRef != null)
            {
                if (TimeTrackingRet.SelectSingleNode("./CustomerRef/ListID") != null)
                {
                    QBWorkOrderListID = TimeTrackingRet.SelectSingleNode("./CustomerRef/ListID").InnerText;
                }
            }

            string  QBServiceTypeListID = "";
            XmlNode ItemServiceRef      = TimeTrackingRet.SelectSingleNode("./ItemServiceRef");

            if (ItemServiceRef != null)
            {
                if (TimeTrackingRet.SelectSingleNode("./ItemServiceRef/ListID") != null)
                {
                    QBServiceTypeListID = TimeTrackingRet.SelectSingleNode("./ItemServiceRef/ListID").InnerText;
                }
            }

            string Duration = TimeTrackingRet.SelectSingleNode("./Duration").InnerText;

            string  QBAreaListID = "";
            XmlNode ClassRef     = TimeTrackingRet.SelectSingleNode("./ClassRef");

            if (ClassRef != null)
            {
                if (TimeTrackingRet.SelectSingleNode("./ClassRef/ListID") != null)
                {
                    QBAreaListID = TimeTrackingRet.SelectSingleNode("./ClassRef/ListID").InnerText;
                }
            }

            string Notes = "";

            if (TimeTrackingRet.SelectSingleNode("./Notes") != null)
            {
                Notes = TimeTrackingRet.SelectSingleNode("./Notes").InnerText;
            }

            string BillableStatus = "";

            if (TimeTrackingRet.SelectSingleNode("./BillableStatus") != null)
            {
                BillableStatus = TimeTrackingRet.SelectSingleNode("./BillableStatus").InnerText;
            }

            RotoTrackDb db = new RotoTrackDb();

            TimeTracking tt = null;

            if (db.TimeTrackings.Any(j => j.QBTxnId == QBTxnID))
            {
                tt = db.TimeTrackings.First(j => j.QBTxnId == QBTxnID);
            }
            else
            {
                tt = new TimeTracking();
                db.TimeTrackings.Add(tt);
            }

            tt.QBTxnId        = QBTxnID;
            tt.QBEditSequence = QBEditSequence;
            DateTime dateWorked;

            if (DateTime.TryParse(TxnDate, out dateWorked))
            {
                tt.DateWorked = dateWorked;
            }
            tt.QBEmployeeListID    = QBEmployeeListID;
            tt.QBWorkOrderListID   = QBWorkOrderListID;
            tt.QBServiceTypeListID = QBServiceTypeListID;

            HoursMinutes hrsMins = GetHoursMinutesFromDuration(Duration);

            if (hrsMins != null)
            {
                tt.HoursWorked   = hrsMins.Hours;
                tt.MinutesWorked = hrsMins.Minutes;
            }

            tt.QBAreaListID   = QBAreaListID;
            tt.Notes          = Notes;
            tt.BillableStatus = BillableStatus;

            db.SaveChanges();
        }
        private static void WalkVehicleMileageRetForAdd(XmlNode VehicleMileageRet)
        {
            if (VehicleMileageRet == null) return;

            RotoTrackDb db = new RotoTrackDb();

            //Get value of Notes--we should have the ServiceEntry GUID encoded in it as well.
            string seGUID = "";
            if (VehicleMileageRet.SelectSingleNode("./Notes") != null)
            {
                string Notes = VehicleMileageRet.SelectSingleNode("./Notes").InnerText;
                seGUID = QBUtils.GetGuidFromNotes(Notes);
            }

            string TxnID = "";
            if (VehicleMileageRet.SelectSingleNode("./TxnID") != null)
            {
                TxnID = VehicleMileageRet.SelectSingleNode("./TxnID").InnerText;
            }

            if (seGUID != "" && TxnID != "")
            {
                ServiceEntry se = null;
                if (db.ServiceEntries.Any(f => f.GUID == seGUID))
                {
                    se = db.ServiceEntries.First(f => f.GUID == seGUID);
                }
                if (se != null)
                {
                    se.QBListIdForMileage = TxnID;
                    db.Entry(se).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }
        }
Example #36
0
        private static void WalkItemOtherChargeRet(XmlNode ItemOtherChargeRet)
        {
            if (ItemOtherChargeRet == null) return;

            MileageRate mr = null;
            RotoTrackDb db = new RotoTrackDb();

            string ListID = ItemOtherChargeRet.SelectSingleNode("./ListID").InnerText;
            string Name = ItemOtherChargeRet.SelectSingleNode("./FullName").InnerText;

            if (Name.StartsWith("MILE"))
            {
                if (db.MileageRates.Any(f => f.QBListId == ListID))
                {
                    mr = db.MileageRates.First(f => f.QBListId == ListID);
                }
                else
                {
                    mr = new MileageRate();
                    db.MileageRates.Add(mr);
                }
                mr.QBListId = ListID;
                mr.Name = Name;

                string IsActive = "false";
                if (ItemOtherChargeRet.SelectSingleNode("./IsActive") != null)
                {
                    IsActive = ItemOtherChargeRet.SelectSingleNode("./IsActive").InnerText;
                }
                mr.IsActive = (IsActive == "true") ? true : false;

                XmlNodeList ORSalesPurchaseChildren = ItemOtherChargeRet.SelectNodes("./*");
                for (int i = 0; i < ORSalesPurchaseChildren.Count; i++)
                {
                    XmlNode Child = ORSalesPurchaseChildren.Item(i);

                    if (Child.Name == "SalesAndPurchase")
                    {
                        if (Child.SelectSingleNode("./SalesDesc") != null)
                        {
                            string SalesDesc = Child.SelectSingleNode("./SalesDesc").InnerText;
                            mr.Description = SalesDesc;
                        }
                        if (Child.SelectSingleNode("./SalesPrice") != null)
                        {
                            string SalesPrice = Child.SelectSingleNode("./SalesPrice").InnerText;
                            try
                            {
                                mr.Rate = Convert.ToDecimal(SalesPrice);
                            }
                            catch (Exception)
                            {
                                mr.Rate = 0;
                            }
                        }
                    }
                }

                if (mr != null)
                {
                    db.SaveChanges();
                }
            }
        }
        private static VendorCreditLine FindOrCreateVendorCreditLine(RotoTrackDb db, string TxnLineID, string TxnID, string TimeCreated, string TimeModified, string EditSequence, string TxnDate, string AmountDue)
        {
            VendorCreditLine vcl = null;
            if (db.VendorCreditLines.Any(f => f.TxnLineId == TxnLineID))
            {
                vcl = db.VendorCreditLines.First(f => f.TxnLineId == TxnLineID);
            }
            else
            {
                vcl = new VendorCreditLine();
                db.VendorCreditLines.Add(vcl);
            }

            vcl.TxnLineId = TxnLineID;
            vcl.VendorCreditTxnId = TxnID;
            DateTime createdDate;
            if (DateTime.TryParse(TimeCreated, out createdDate)) vcl.VendorCreditCreated = createdDate;
            DateTime modifiedDate;
            if (DateTime.TryParse(TimeModified, out modifiedDate)) vcl.VendorCreditModified = modifiedDate;
            vcl.VendorCreditEditSequence = EditSequence;
            DateTime txnDate;
            if (DateTime.TryParse(TxnDate, out txnDate)) vcl.VendorCreditTxnDate = txnDate;
            decimal amountDue;
            if (Decimal.TryParse(AmountDue, out amountDue)) vcl.VendorCreditAmountDue = amountDue;

            return vcl;
        }
Example #38
0
        private static void WalkBillRetForQuery(XmlNode BillRet)
        {
            if (BillRet == null)
            {
                return;
            }

            RotoTrackDb db = new RotoTrackDb();

            //Go through all the elements of BillRet
            //Get value of TxnID
            string TxnID = BillRet.SelectSingleNode("./TxnID").InnerText;

            // New or modified objects will return all current line items, so remove any existing ones first and then recreate them.
            RemoveExistingLineItems(db, TxnID);

            //Get value of TimeCreated
            string TimeCreated = BillRet.SelectSingleNode("./TimeCreated").InnerText;
            //Get value of TimeModified
            string TimeModified = BillRet.SelectSingleNode("./TimeModified").InnerText;
            //Get value of EditSequence
            string EditSequence = BillRet.SelectSingleNode("./EditSequence").InnerText;

            //Get value of TxnNumber
            if (BillRet.SelectSingleNode("./TxnNumber") != null)
            {
                string TxnNumber = BillRet.SelectSingleNode("./TxnNumber").InnerText;
            }

            //Get all field values for APAccountRef aggregate
            XmlNode APAccountRef = BillRet.SelectSingleNode("./APAccountRef");

            if (APAccountRef != null)
            {
                //Get value of ListID
                if (BillRet.SelectSingleNode("./APAccountRef/ListID") != null)
                {
                    string ListID = BillRet.SelectSingleNode("./APAccountRef/ListID").InnerText;
                }
                //Get value of FullName
                if (BillRet.SelectSingleNode("./APAccountRef/FullName") != null)
                {
                    string FullName = BillRet.SelectSingleNode("./APAccountRef/FullName").InnerText;
                }
            }
            //Done with field values for APAccountRef aggregate

            //Get value of TxnDate
            string TxnDate = BillRet.SelectSingleNode("./TxnDate").InnerText;

            //Get value of DueDate
            if (BillRet.SelectSingleNode("./DueDate") != null)
            {
                string DueDate = BillRet.SelectSingleNode("./DueDate").InnerText;
            }

            //Get value of AmountDue
            string AmountDue = "";

            if (BillRet.SelectSingleNode("./AmountDue") != null)
            {
                AmountDue = BillRet.SelectSingleNode("./AmountDue").InnerText;
            }

            //Get all field values for CurrencyRef aggregate
            XmlNode CurrencyRef = BillRet.SelectSingleNode("./CurrencyRef");

            if (CurrencyRef != null)
            {
                //Get value of ListID
                if (BillRet.SelectSingleNode("./CurrencyRef/ListID") != null)
                {
                    string ListID = BillRet.SelectSingleNode("./CurrencyRef/ListID").InnerText;
                }
                //Get value of FullName
                if (BillRet.SelectSingleNode("./CurrencyRef/FullName") != null)
                {
                    string FullName = BillRet.SelectSingleNode("./CurrencyRef/FullName").InnerText;
                }
            }
            //Done with field values for CurrencyRef aggregate

            //Get all field values for VendorRef aggregate
            //Get value of ListID
            string VendorListID = "";

            if (BillRet.SelectSingleNode("./VendorRef/ListID") != null)
            {
                VendorListID = BillRet.SelectSingleNode("./VendorRef/ListID").InnerText;
            }
            //Get value of FullName
            if (BillRet.SelectSingleNode("./VendorRef/FullName") != null)
            {
                string FullName = BillRet.SelectSingleNode("./VendorRef/FullName").InnerText;
            }
            //Done with field values for VendorRef aggregate

            //Get value of ExchangeRate
            if (BillRet.SelectSingleNode("./ExchangeRate") != null)
            {
                string ExchangeRate = BillRet.SelectSingleNode("./ExchangeRate").InnerText;
            }
            //Get value of AmountDueInHomeCurrency
            if (BillRet.SelectSingleNode("./AmountDueInHomeCurrency") != null)
            {
                string AmountDueInHomeCurrency = BillRet.SelectSingleNode("./AmountDueInHomeCurrency").InnerText;
            }
            //Get value of RefNumber
            if (BillRet.SelectSingleNode("./RefNumber") != null)
            {
                string RefNumber = BillRet.SelectSingleNode("./RefNumber").InnerText;
            }
            //Get all field values for TermsRef aggregate
            XmlNode TermsRef = BillRet.SelectSingleNode("./TermsRef");

            if (TermsRef != null)
            {
                //Get value of ListID
                if (BillRet.SelectSingleNode("./TermsRef/ListID") != null)
                {
                    string ListID = BillRet.SelectSingleNode("./TermsRef/ListID").InnerText;
                }
                //Get value of FullName
                if (BillRet.SelectSingleNode("./TermsRef/FullName") != null)
                {
                    string FullName = BillRet.SelectSingleNode("./TermsRef/FullName").InnerText;
                }
            }
            //Done with field values for TermsRef aggregate

            //Get value of Memo
            if (BillRet.SelectSingleNode("./Memo") != null)
            {
                string Memo = BillRet.SelectSingleNode("./Memo").InnerText;
            }
            //Get value of IsPaid
            if (BillRet.SelectSingleNode("./IsPaid") != null)
            {
                string IsPaid = BillRet.SelectSingleNode("./IsPaid").InnerText;
            }
            //Get value of ExternalGUID
            if (BillRet.SelectSingleNode("./ExternalGUID") != null)
            {
                string ExternalGUID = BillRet.SelectSingleNode("./ExternalGUID").InnerText;
            }

            //Walk list of ExpenseLineRet aggregates
            XmlNodeList ExpenseLineRetList = BillRet.SelectNodes("./ExpenseLineRet");

            if (ExpenseLineRetList != null)
            {
                for (int i = 0; i < ExpenseLineRetList.Count; i++)
                {
                    XmlNode ExpenseLineRet = ExpenseLineRetList.Item(i);

                    //Get all field values for CustomerRef aggregate
                    string  CustomerListID = "";
                    XmlNode CustomerRef    = ExpenseLineRet.SelectSingleNode("./CustomerRef");
                    if (CustomerRef != null)
                    {
                        //Get value of ListID
                        if (ExpenseLineRet.SelectSingleNode("./CustomerRef/ListID") != null)
                        {
                            CustomerListID = ExpenseLineRet.SelectSingleNode("./CustomerRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (ExpenseLineRet.SelectSingleNode("./CustomerRef/FullName") != null)
                        {
                            string FullName = ExpenseLineRet.SelectSingleNode("./CustomerRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for CustomerRef aggregate

                    // Skip the rest of this iteration if no CustomerListID (associated work order)
                    if (CustomerListID == "")
                    {
                        continue;
                    }

                    //Get value of TxnLineID
                    string TxnLineID = ExpenseLineRet.SelectSingleNode("./TxnLineID").InnerText;

                    // Find existing or create new BillLine entry
                    BillLine bl = FindOrCreateBillLine(db, TxnLineID, TxnID, TimeCreated, TimeModified, EditSequence, TxnDate, AmountDue);
                    bl.WorkOrderListID = CustomerListID;
                    bl.VendorListID    = VendorListID;

                    string Description = "";

                    //Get all field values for AccountRef aggregate
                    XmlNode AccountRef = ExpenseLineRet.SelectSingleNode("./AccountRef");
                    if (AccountRef != null)
                    {
                        //Get value of ListID
                        if (ExpenseLineRet.SelectSingleNode("./AccountRef/ListID") != null)
                        {
                            string ListID = ExpenseLineRet.SelectSingleNode("./AccountRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (ExpenseLineRet.SelectSingleNode("./AccountRef/FullName") != null)
                        {
                            string FullName = ExpenseLineRet.SelectSingleNode("./AccountRef/FullName").InnerText;
                            Description = FullName + " - ";
                        }
                    }
                    //Done with field values for AccountRef aggregate

                    //Get value of Memo
                    if (ExpenseLineRet.SelectSingleNode("./Memo") != null)
                    {
                        string Memo = ExpenseLineRet.SelectSingleNode("./Memo").InnerText;
                        Description += Memo;
                    }
                    bl.Description = Description;

                    //Get value of Amount
                    if (ExpenseLineRet.SelectSingleNode("./Amount") != null)
                    {
                        string  Amount = ExpenseLineRet.SelectSingleNode("./Amount").InnerText;
                        decimal amount;
                        if (Decimal.TryParse(Amount, out amount))
                        {
                            bl.Amount   = amount;
                            bl.UnitCost = amount;
                            bl.Quantity = 1.0M;
                        }
                    }

                    //Get all field values for ClassRef aggregate
                    XmlNode ClassRef = ExpenseLineRet.SelectSingleNode("./ClassRef");
                    if (ClassRef != null)
                    {
                        //Get value of ListID
                        if (ExpenseLineRet.SelectSingleNode("./ClassRef/ListID") != null)
                        {
                            string ListID = ExpenseLineRet.SelectSingleNode("./ClassRef/ListID").InnerText;
                            bl.AreaListID = ListID;
                        }
                        //Get value of FullName
                        if (ExpenseLineRet.SelectSingleNode("./ClassRef/FullName") != null)
                        {
                            string FullName = ExpenseLineRet.SelectSingleNode("./ClassRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for ClassRef aggregate

                    //Get value of BillableStatus
                    if (ExpenseLineRet.SelectSingleNode("./BillableStatus") != null)
                    {
                        string BillableStatus = ExpenseLineRet.SelectSingleNode("./BillableStatus").InnerText;
                        bl.BillableStatus = BillableStatus;
                    }

                    db.SaveChanges();
                }
            }

            XmlNodeList ORItemLineRetListChildren = BillRet.SelectNodes("./*");

            for (int i = 0; i < ORItemLineRetListChildren.Count; i++)
            {
                XmlNode Child = ORItemLineRetListChildren.Item(i);
                if (Child.Name == "ItemLineRet")
                {
                    //Get all field values for CustomerRef aggregate
                    string  CustomerListID = "";
                    XmlNode CustomerRef    = Child.SelectSingleNode("./CustomerRef");
                    if (CustomerRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./CustomerRef/ListID") != null)
                        {
                            CustomerListID = Child.SelectSingleNode("./CustomerRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./CustomerRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./CustomerRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for CustomerRef aggregate

                    // Skip this entity if no associated customer (work order)
                    if (CustomerListID == "")
                    {
                        continue;
                    }

                    //Get value of TxnLineID
                    string TxnLineID = Child.SelectSingleNode("./TxnLineID").InnerText;

                    // Find existing or create new BillLine entry
                    BillLine bl = FindOrCreateBillLine(db, TxnLineID, TxnID, TimeCreated, TimeModified, EditSequence, TxnDate, AmountDue);
                    bl.WorkOrderListID = CustomerListID;
                    bl.VendorListID    = VendorListID;

                    //Get all field values for ItemRef aggregate
                    XmlNode ItemRef = Child.SelectSingleNode("./ItemRef");
                    if (ItemRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./ItemRef/ListID") != null)
                        {
                            string ListID = Child.SelectSingleNode("./ItemRef/ListID").InnerText;
                            bl.ItemListID = ListID;
                        }
                    }
                    //Done with field values for ItemRef aggregate

                    //Get all field values for InventorySiteRef aggregate
                    XmlNode InventorySiteRef = Child.SelectSingleNode("./InventorySiteRef");
                    if (InventorySiteRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./InventorySiteRef/ListID") != null)
                        {
                            string ListID = Child.SelectSingleNode("./InventorySiteRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./InventorySiteRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./InventorySiteRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for InventorySiteRef aggregate

                    //Get all field values for InventorySiteLocationRef aggregate
                    XmlNode InventorySiteLocationRef = Child.SelectSingleNode("./InventorySiteLocationRef");
                    if (InventorySiteLocationRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./InventorySiteLocationRef/ListID") != null)
                        {
                            string ListID = Child.SelectSingleNode("./InventorySiteLocationRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./InventorySiteLocationRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./InventorySiteLocationRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for InventorySiteLocationRef aggregate

                    //Get value of Desc
                    if (Child.SelectSingleNode("./Desc") != null)
                    {
                        string Desc = Child.SelectSingleNode("./Desc").InnerText;
                        bl.Description = Desc;
                    }
                    //Get value of Quantity
                    if (Child.SelectSingleNode("./Quantity") != null)
                    {
                        string  Quantity = Child.SelectSingleNode("./Quantity").InnerText;
                        decimal quantity;
                        if (Decimal.TryParse(Quantity, out quantity))
                        {
                            bl.Quantity = quantity;
                        }
                    }
                    //Get value of UnitOfMeasure
                    if (Child.SelectSingleNode("./UnitOfMeasure") != null)
                    {
                        string UnitOfMeasure = Child.SelectSingleNode("./UnitOfMeasure").InnerText;
                    }
                    //Get all field values for OverrideUOMSetRef aggregate
                    XmlNode OverrideUOMSetRef = Child.SelectSingleNode("./OverrideUOMSetRef");
                    if (OverrideUOMSetRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./OverrideUOMSetRef/ListID") != null)
                        {
                            string ListID = Child.SelectSingleNode("./OverrideUOMSetRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./OverrideUOMSetRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./OverrideUOMSetRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for OverrideUOMSetRef aggregate

                    //Get value of Cost
                    if (Child.SelectSingleNode("./Cost") != null)
                    {
                        string  Cost = Child.SelectSingleNode("./Cost").InnerText;
                        decimal unitCost;
                        if (Decimal.TryParse(Cost, out unitCost))
                        {
                            bl.UnitCost = unitCost;
                        }
                    }
                    //Get value of Amount
                    if (Child.SelectSingleNode("./Amount") != null)
                    {
                        string  Amount = Child.SelectSingleNode("./Amount").InnerText;
                        decimal amount;
                        if (Decimal.TryParse(Amount, out amount))
                        {
                            bl.Amount = amount;
                        }
                    }

                    //Get all field values for ClassRef aggregate
                    XmlNode ClassRef = Child.SelectSingleNode("./ClassRef");
                    if (ClassRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./ClassRef/ListID") != null)
                        {
                            string ListID = Child.SelectSingleNode("./ClassRef/ListID").InnerText;
                            bl.AreaListID = ListID;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./ClassRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./ClassRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for ClassRef aggregate

                    //Get value of BillableStatus
                    if (Child.SelectSingleNode("./BillableStatus") != null)
                    {
                        string BillableStatus = Child.SelectSingleNode("./BillableStatus").InnerText;
                        bl.BillableStatus = BillableStatus;
                    }

                    db.SaveChanges();
                }

                if (Child.Name == "ItemGroupLineRet")
                {
                    //Get value of TxnLineID
                    string TxnLineID = Child.SelectSingleNode("./TxnLineID").InnerText;

                    //Get all field values for ItemGroupRef aggregate
                    //Get value of ListID
                    if (Child.SelectSingleNode("./ItemGroupRef/ListID") != null)
                    {
                        string ListID = Child.SelectSingleNode("./ItemGroupRef/ListID").InnerText;
                    }
                    //Get value of FullName
                    if (Child.SelectSingleNode("./ItemGroupRef/FullName") != null)
                    {
                        string FullName = Child.SelectSingleNode("./ItemGroupRef/FullName").InnerText;
                    }
                    //Done with field values for ItemGroupRef aggregate

                    //Get value of Desc
                    if (Child.SelectSingleNode("./Desc") != null)
                    {
                        string Desc = Child.SelectSingleNode("./Desc").InnerText;
                    }
                    //Get value of Quantity
                    if (Child.SelectSingleNode("./Quantity") != null)
                    {
                        string Quantity = Child.SelectSingleNode("./Quantity").InnerText;
                    }
                    //Get value of UnitOfMeasure
                    if (Child.SelectSingleNode("./UnitOfMeasure") != null)
                    {
                        string UnitOfMeasure = Child.SelectSingleNode("./UnitOfMeasure").InnerText;
                    }
                    //Get all field values for OverrideUOMSetRef aggregate
                    XmlNode OverrideUOMSetRef = Child.SelectSingleNode("./OverrideUOMSetRef");
                    if (OverrideUOMSetRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./OverrideUOMSetRef/ListID") != null)
                        {
                            string ListID = Child.SelectSingleNode("./OverrideUOMSetRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./OverrideUOMSetRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./OverrideUOMSetRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for OverrideUOMSetRef aggregate

                    //Get value of TotalAmount
                    string TotalAmount = Child.SelectSingleNode("./TotalAmount").InnerText;
                    //Walk list of ItemLineRet aggregates
                    XmlNodeList ItemLineRetList = Child.SelectNodes("./ItemLineRet");
                    if (ItemLineRetList != null)
                    {
                        for (int j = 0; j < ItemLineRetList.Count; j++)
                        {
                            XmlNode ItemLineRet = ItemLineRetList.Item(j);

                            //Get all field values for CustomerRef aggregate
                            string  CustomerListID = "";
                            XmlNode CustomerRef    = ItemLineRet.SelectSingleNode("./CustomerRef");
                            if (CustomerRef != null)
                            {
                                //Get value of ListID
                                if (ItemLineRet.SelectSingleNode("./CustomerRef/ListID") != null)
                                {
                                    CustomerListID = ItemLineRet.SelectSingleNode("./CustomerRef/ListID").InnerText;
                                }
                                //Get value of FullName
                                if (ItemLineRet.SelectSingleNode("./CustomerRef/FullName") != null)
                                {
                                    string FullName = ItemLineRet.SelectSingleNode("./CustomerRef/FullName").InnerText;
                                }
                            }
                            //Done with field values for CustomerRef aggregate

                            // Skip the rest if no associated customer (work order)
                            if (CustomerListID == "")
                            {
                                continue;
                            }

                            //Get value of TxnLineID
                            string TxnLineID2 = ItemLineRet.SelectSingleNode("./TxnLineID").InnerText;

                            // Find existing or create new BillLine entry
                            BillLine bl = FindOrCreateBillLine(db, TxnLineID2, TxnID, TimeCreated, TimeModified, EditSequence, TxnDate, AmountDue);
                            bl.WorkOrderListID = CustomerListID;
                            bl.VendorListID    = VendorListID;

                            //Get all field values for ItemRef aggregate
                            XmlNode ItemRef = ItemLineRet.SelectSingleNode("./ItemRef");
                            if (ItemRef != null)
                            {
                                //Get value of ListID
                                if (ItemLineRet.SelectSingleNode("./ItemRef/ListID") != null)
                                {
                                    string ListID = ItemLineRet.SelectSingleNode("./ItemRef/ListID").InnerText;
                                    bl.ItemListID = ListID;
                                }
                                //Get value of FullName
                                if (ItemLineRet.SelectSingleNode("./ItemRef/FullName") != null)
                                {
                                    string FullName = ItemLineRet.SelectSingleNode("./ItemRef/FullName").InnerText;
                                }
                            }
                            //Done with field values for ItemRef aggregate

                            //Get all field values for InventorySiteRef aggregate
                            XmlNode InventorySiteRef = ItemLineRet.SelectSingleNode("./InventorySiteRef");
                            if (InventorySiteRef != null)
                            {
                                //Get value of ListID
                                if (ItemLineRet.SelectSingleNode("./InventorySiteRef/ListID") != null)
                                {
                                    string ListID = ItemLineRet.SelectSingleNode("./InventorySiteRef/ListID").InnerText;
                                }
                                //Get value of FullName
                                if (ItemLineRet.SelectSingleNode("./InventorySiteRef/FullName") != null)
                                {
                                    string FullName = ItemLineRet.SelectSingleNode("./InventorySiteRef/FullName").InnerText;
                                }
                            }
                            //Done with field values for InventorySiteRef aggregate

                            //Get all field values for InventorySiteLocationRef aggregate
                            XmlNode InventorySiteLocationRef = ItemLineRet.SelectSingleNode("./InventorySiteLocationRef");
                            if (InventorySiteLocationRef != null)
                            {
                                //Get value of ListID
                                if (ItemLineRet.SelectSingleNode("./InventorySiteLocationRef/ListID") != null)
                                {
                                    string ListID = ItemLineRet.SelectSingleNode("./InventorySiteLocationRef/ListID").InnerText;
                                }
                                //Get value of FullName
                                if (ItemLineRet.SelectSingleNode("./InventorySiteLocationRef/FullName") != null)
                                {
                                    string FullName = ItemLineRet.SelectSingleNode("./InventorySiteLocationRef/FullName").InnerText;
                                }
                            }
                            //Done with field values for InventorySiteLocationRef aggregate

                            //Get value of Desc
                            if (ItemLineRet.SelectSingleNode("./Desc") != null)
                            {
                                string Desc = ItemLineRet.SelectSingleNode("./Desc").InnerText;
                                bl.Description = Desc;
                            }
                            //Get value of Quantity
                            if (ItemLineRet.SelectSingleNode("./Quantity") != null)
                            {
                                string  Quantity = ItemLineRet.SelectSingleNode("./Quantity").InnerText;
                                decimal quantity;
                                if (Decimal.TryParse(Quantity, out quantity))
                                {
                                    bl.Quantity = quantity;
                                }
                            }
                            //Get value of UnitOfMeasure
                            if (ItemLineRet.SelectSingleNode("./UnitOfMeasure") != null)
                            {
                                string UnitOfMeasure = ItemLineRet.SelectSingleNode("./UnitOfMeasure").InnerText;
                            }
                            //Get all field values for OverrideUOMSetRef aggregate
                            XmlNode OverrideUOMSetRef2 = ItemLineRet.SelectSingleNode("./OverrideUOMSetRef");
                            if (OverrideUOMSetRef2 != null)
                            {
                                //Get value of ListID
                                if (ItemLineRet.SelectSingleNode("./OverrideUOMSetRef/ListID") != null)
                                {
                                    string ListID = ItemLineRet.SelectSingleNode("./OverrideUOMSetRef/ListID").InnerText;
                                }
                                //Get value of FullName
                                if (ItemLineRet.SelectSingleNode("./OverrideUOMSetRef/FullName") != null)
                                {
                                    string FullName = ItemLineRet.SelectSingleNode("./OverrideUOMSetRef/FullName").InnerText;
                                }
                            }
                            //Done with field values for OverrideUOMSetRef aggregate

                            //Get value of Cost
                            if (ItemLineRet.SelectSingleNode("./Cost") != null)
                            {
                                string  Cost = ItemLineRet.SelectSingleNode("./Cost").InnerText;
                                decimal cost;
                                if (Decimal.TryParse(Cost, out cost))
                                {
                                    bl.UnitCost = cost;
                                }
                            }
                            //Get value of Amount
                            if (ItemLineRet.SelectSingleNode("./Amount") != null)
                            {
                                string  Amount = ItemLineRet.SelectSingleNode("./Amount").InnerText;
                                decimal amount;
                                if (Decimal.TryParse(Amount, out amount))
                                {
                                    bl.Amount = amount;
                                }
                            }

                            //Get all field values for ClassRef aggregate
                            XmlNode ClassRef = ItemLineRet.SelectSingleNode("./ClassRef");
                            if (ClassRef != null)
                            {
                                //Get value of ListID
                                if (ItemLineRet.SelectSingleNode("./ClassRef/ListID") != null)
                                {
                                    string ListID = ItemLineRet.SelectSingleNode("./ClassRef/ListID").InnerText;
                                    bl.AreaListID = ListID;
                                }
                                //Get value of FullName
                                if (ItemLineRet.SelectSingleNode("./ClassRef/FullName") != null)
                                {
                                    string FullName = ItemLineRet.SelectSingleNode("./ClassRef/FullName").InnerText;
                                }
                            }
                            //Done with field values for ClassRef aggregate

                            //Get value of BillableStatus
                            if (ItemLineRet.SelectSingleNode("./BillableStatus") != null)
                            {
                                string BillableStatus = ItemLineRet.SelectSingleNode("./BillableStatus").InnerText;
                                bl.BillableStatus = BillableStatus;
                            }

                            db.SaveChanges();
                        }
                    }
                }
            }
        }
        private static void WalkVehicleMileageRetForQuery(XmlNode VehicleMileageRet)
        {
            if (VehicleMileageRet == null)
            {
                return;
            }

            string TxnID         = VehicleMileageRet.SelectSingleNode("./TxnID").InnerText;
            string TimeCreated   = VehicleMileageRet.SelectSingleNode("./TimeCreated").InnerText;
            string TimeModified  = VehicleMileageRet.SelectSingleNode("./TimeCreated").InnerText;
            string TripStartDate = "";

            if (VehicleMileageRet.SelectSingleNode("./TripStartDate") != null)
            {
                TripStartDate = VehicleMileageRet.SelectSingleNode("./TripStartDate").InnerText;
            }
            string EditSequence = VehicleMileageRet.SelectSingleNode("./EditSequence").InnerText;

            string  VehicleRefListID = "";
            XmlNode VehicleRef       = VehicleMileageRet.SelectSingleNode("./VehicleRef");

            if (VehicleRef != null)
            {
                if (VehicleMileageRet.SelectSingleNode("./VehicleRef/ListID") != null)
                {
                    VehicleRefListID = VehicleMileageRet.SelectSingleNode("./VehicleRef/ListID").InnerText;
                }
            }

            string  WorkOrderListID = "";
            XmlNode CustomerRef     = VehicleMileageRet.SelectSingleNode("./CustomerRef");

            if (CustomerRef != null)
            {
                if (VehicleMileageRet.SelectSingleNode("./CustomerRef/ListID") != null)
                {
                    WorkOrderListID = VehicleMileageRet.SelectSingleNode("./CustomerRef/ListID").InnerText;
                }
            }

            string  ItemRefListID = "";
            XmlNode ItemRef       = VehicleMileageRet.SelectSingleNode("./ItemRef");

            if (ItemRef != null)
            {
                if (VehicleMileageRet.SelectSingleNode("./ItemRef/ListID") != null)
                {
                    ItemRefListID = VehicleMileageRet.SelectSingleNode("./ItemRef/ListID").InnerText;
                }
            }

            string  AreaListID = "";
            XmlNode ClassRef   = VehicleMileageRet.SelectSingleNode("./ClassRef");

            if (ClassRef != null)
            {
                if (VehicleMileageRet.SelectSingleNode("./ClassRef/ListID") != null)
                {
                    AreaListID = VehicleMileageRet.SelectSingleNode("./ClassRef/ListID").InnerText;
                }
            }

            string TotalMiles = "";

            if (VehicleMileageRet.SelectSingleNode("./TotalMiles") != null)
            {
                TotalMiles = VehicleMileageRet.SelectSingleNode("./TotalMiles").InnerText;
            }

            string Notes = "";

            if (VehicleMileageRet.SelectSingleNode("./Notes") != null)
            {
                Notes = VehicleMileageRet.SelectSingleNode("./Notes").InnerText;
            }

            string BillableStatus = "";

            if (VehicleMileageRet.SelectSingleNode("./BillableStatus") != null)
            {
                BillableStatus = VehicleMileageRet.SelectSingleNode("./BillableStatus").InnerText;
            }

            string BillableRate = "";

            if (VehicleMileageRet.SelectSingleNode("./BillableRate") != null)
            {
                BillableRate = VehicleMileageRet.SelectSingleNode("./BillableRate").InnerText;
            }

            string BillableAmount = "";

            if (VehicleMileageRet.SelectSingleNode("./BillableAmount") != null)
            {
                BillableAmount = VehicleMileageRet.SelectSingleNode("./BillableAmount").InnerText;
            }

            RotoTrackDb db = new RotoTrackDb();

            MileageTracking mt = null;

            if (db.MileageTrackings.Any(j => j.QBTxnId == TxnID))
            {
                mt = db.MileageTrackings.First(j => j.QBTxnId == TxnID);
            }
            else
            {
                mt = new MileageTracking();
                db.MileageTrackings.Add(mt);
            }

            mt.QBTxnId = TxnID;
            DateTime created, modified, tripstartdate;

            if (DateTime.TryParse(TimeCreated, out created))
            {
                mt.Created = created;
            }
            if (DateTime.TryParse(TimeModified, out modified))
            {
                mt.Modified = modified;
            }
            mt.TripStartDate = DateTime.MinValue;
            if (DateTime.TryParse(TripStartDate, out tripstartdate))
            {
                mt.TripStartDate = tripstartdate;
            }

            mt.QBEditSequence      = EditSequence;
            mt.QBVehicleListID     = VehicleRefListID;
            mt.QBWorkOrderListID   = WorkOrderListID;
            mt.QBMileageRateListID = ItemRefListID;
            mt.QBAreaListID        = AreaListID;

            decimal totalMiles;

            if (Decimal.TryParse(TotalMiles, out totalMiles))
            {
                mt.TotalMiles = totalMiles;
            }

            mt.Notes          = Notes;
            mt.BillableStatus = BillableStatus;

            decimal billableRate, billableAmount;

            if (Decimal.TryParse(BillableRate, out billableRate))
            {
                mt.BillableRate = billableRate;
            }
            if (Decimal.TryParse(BillableAmount, out billableAmount))
            {
                mt.BillableAmount = billableAmount;
            }

            db.SaveChanges();
        }
Example #40
0
        private static void WalkTxnDeletedRet(XmlNode TxnDeletedRet)
        {
            if (TxnDeletedRet == null) return;

            //Go through all the elements of TxnDeletedRet
            //Get value of TxnDelType
            string TxnDelType = TxnDeletedRet.SelectSingleNode("./TxnDelType").InnerText;
            //Get value of TxnID
            string TxnID = TxnDeletedRet.SelectSingleNode("./TxnID").InnerText;
            //Get value of TimeCreated
            string TimeCreated = TxnDeletedRet.SelectSingleNode("./TimeCreated").InnerText;
            //Get value of TimeDeleted
            string TimeDeleted = TxnDeletedRet.SelectSingleNode("./TimeDeleted").InnerText;
            //Get value of RefNumber
            if (TxnDeletedRet.SelectSingleNode("./RefNumber") != null)
            {
                string RefNumber = TxnDeletedRet.SelectSingleNode("./RefNumber").InnerText;
            }

            RotoTrackDb db = new RotoTrackDb();
            List<BillLine> blList = db.BillLines.Where(f => f.BillTxnId == TxnID).ToList();
            foreach (BillLine bl in blList.ToList())
            {
                db.BillLines.Remove(bl);
            }
            db.SaveChanges();
        }
        private static void WalkCustomerTypeRet(XmlNode CustomerTypeRet)
        {
            if (CustomerTypeRet == null) return;

            BillingInstruction bi = null;
            RotoTrackDb db = new RotoTrackDb();

            string ListID = CustomerTypeRet.SelectSingleNode("./ListID").InnerText;
            if (db.BillingInstructions.Any(f => f.QBListId == ListID))
            {
                bi = db.BillingInstructions.First(f => f.QBListId == ListID);
            }
            else
            {
                bi = new BillingInstruction();
                db.BillingInstructions.Add(bi);
            }
            bi.QBListId = ListID;

            string Name = CustomerTypeRet.SelectSingleNode("./Name").InnerText;
            bi.Name = Name;

            string FullName = CustomerTypeRet.SelectSingleNode("./FullName").InnerText;

            string IsActive = "false";
            if (CustomerTypeRet.SelectSingleNode("./IsActive") != null)
            {
                IsActive = CustomerTypeRet.SelectSingleNode("./IsActive").InnerText;
            }
            bi.IsActive = (IsActive == "true") ? true : false;

            if (bi != null)
            {
                db.SaveChanges();
            }
        }
Example #42
0
        private static void WalkSalesOrderRetForQuery(XmlNode SalesOrderRet)
        {
            if (SalesOrderRet == null) return;

            RotoTrackDb db = new RotoTrackDb();

            //Go through all the elements of SalesOrderRet
            //Get value of TxnID
            string TxnID = SalesOrderRet.SelectSingleNode("./TxnID").InnerText;

            // New or modified objects will return all current line items, so remove any existing ones first and then recreate them.
            RemoveExistingLineItems(db, TxnID);

            //Get value of TimeCreated
            string TimeCreated = SalesOrderRet.SelectSingleNode("./TimeCreated").InnerText;
            //Get value of TimeModified
            string TimeModified = SalesOrderRet.SelectSingleNode("./TimeModified").InnerText;
            //Get value of EditSequence
            string EditSequence = SalesOrderRet.SelectSingleNode("./EditSequence").InnerText;
            //Get value of TxnNumber
            if (SalesOrderRet.SelectSingleNode("./TxnNumber") != null)
            {
                string TxnNumber = SalesOrderRet.SelectSingleNode("./TxnNumber").InnerText;
            }
            //Get all field values for CustomerRef aggregate
            //Get value of ListID
            string CustomerListID = "";
            if (SalesOrderRet.SelectSingleNode("./CustomerRef/ListID") != null)
            {
                CustomerListID = SalesOrderRet.SelectSingleNode("./CustomerRef/ListID").InnerText;
            }
            // Get out and do nothing if CustomerListID is empty
            if (CustomerListID == "")
            {
                return;
            }

            //Get value of FullName
            if (SalesOrderRet.SelectSingleNode("./CustomerRef/FullName") != null)
            {
                string FullName = SalesOrderRet.SelectSingleNode("./CustomerRef/FullName").InnerText;
            }
            //Done with field values for CustomerRef aggregate

            //Get all field values for ClassRef aggregate
            XmlNode ClassRef = SalesOrderRet.SelectSingleNode("./ClassRef");
            if (ClassRef != null)
            {
                //Get value of ListID
                if (SalesOrderRet.SelectSingleNode("./ClassRef/ListID") != null)
                {
                    string ListID = SalesOrderRet.SelectSingleNode("./ClassRef/ListID").InnerText;
                }
                //Get value of FullName
                if (SalesOrderRet.SelectSingleNode("./ClassRef/FullName") != null)
                {
                    string FullName = SalesOrderRet.SelectSingleNode("./ClassRef/FullName").InnerText;
                }
            }
            //Done with field values for ClassRef aggregate

            //Get all field values for TemplateRef aggregate
            XmlNode TemplateRef = SalesOrderRet.SelectSingleNode("./TemplateRef");
            if (TemplateRef != null)
            {
                //Get value of ListID
                if (SalesOrderRet.SelectSingleNode("./TemplateRef/ListID") != null)
                {
                    string ListID = SalesOrderRet.SelectSingleNode("./TemplateRef/ListID").InnerText;
                }
                //Get value of FullName
                if (SalesOrderRet.SelectSingleNode("./TemplateRef/FullName") != null)
                {
                    string FullName = SalesOrderRet.SelectSingleNode("./TemplateRef/FullName").InnerText;
                }
            }
            //Done with field values for TemplateRef aggregate

            //Get value of TxnDate
            string TxnDate = SalesOrderRet.SelectSingleNode("./TxnDate").InnerText;
            //Get value of RefNumber
            if (SalesOrderRet.SelectSingleNode("./RefNumber") != null)
            {
                string RefNumber = SalesOrderRet.SelectSingleNode("./RefNumber").InnerText;
            }
            //Get all field values for BillAddress aggregate
            XmlNode BillAddress = SalesOrderRet.SelectSingleNode("./BillAddress");
            if (BillAddress != null)
            {
                //Get value of Addr1
                if (SalesOrderRet.SelectSingleNode("./BillAddress/Addr1") != null)
                {
                    string Addr1 = SalesOrderRet.SelectSingleNode("./BillAddress/Addr1").InnerText;
                }
                //Get value of Addr2
                if (SalesOrderRet.SelectSingleNode("./BillAddress/Addr2") != null)
                {
                    string Addr2 = SalesOrderRet.SelectSingleNode("./BillAddress/Addr2").InnerText;
                }
                //Get value of Addr3
                if (SalesOrderRet.SelectSingleNode("./BillAddress/Addr3") != null)
                {
                    string Addr3 = SalesOrderRet.SelectSingleNode("./BillAddress/Addr3").InnerText;
                }
                //Get value of Addr4
                if (SalesOrderRet.SelectSingleNode("./BillAddress/Addr4") != null)
                {
                    string Addr4 = SalesOrderRet.SelectSingleNode("./BillAddress/Addr4").InnerText;
                }
                //Get value of Addr5
                if (SalesOrderRet.SelectSingleNode("./BillAddress/Addr5") != null)
                {
                    string Addr5 = SalesOrderRet.SelectSingleNode("./BillAddress/Addr5").InnerText;
                }
                //Get value of City
                if (SalesOrderRet.SelectSingleNode("./BillAddress/City") != null)
                {
                    string City = SalesOrderRet.SelectSingleNode("./BillAddress/City").InnerText;
                }
                //Get value of State
                if (SalesOrderRet.SelectSingleNode("./BillAddress/State") != null)
                {
                    string State = SalesOrderRet.SelectSingleNode("./BillAddress/State").InnerText;
                }
                //Get value of PostalCode
                if (SalesOrderRet.SelectSingleNode("./BillAddress/PostalCode") != null)
                {
                    string PostalCode = SalesOrderRet.SelectSingleNode("./BillAddress/PostalCode").InnerText;
                }
                //Get value of Country
                if (SalesOrderRet.SelectSingleNode("./BillAddress/Country") != null)
                {
                    string Country = SalesOrderRet.SelectSingleNode("./BillAddress/Country").InnerText;
                }
                //Get value of Note
                if (SalesOrderRet.SelectSingleNode("./BillAddress/Note") != null)
                {
                    string Note = SalesOrderRet.SelectSingleNode("./BillAddress/Note").InnerText;
                }
            }
            //Done with field values for BillAddress aggregate

            //Get all field values for BillAddressBlock aggregate
            XmlNode BillAddressBlock = SalesOrderRet.SelectSingleNode("./BillAddressBlock");
            if (BillAddressBlock != null)
            {
                //Get value of Addr1
                if (SalesOrderRet.SelectSingleNode("./BillAddressBlock/Addr1") != null)
                {
                    string Addr1 = SalesOrderRet.SelectSingleNode("./BillAddressBlock/Addr1").InnerText;
                }
                //Get value of Addr2
                if (SalesOrderRet.SelectSingleNode("./BillAddressBlock/Addr2") != null)
                {
                    string Addr2 = SalesOrderRet.SelectSingleNode("./BillAddressBlock/Addr2").InnerText;
                }
                //Get value of Addr3
                if (SalesOrderRet.SelectSingleNode("./BillAddressBlock/Addr3") != null)
                {
                    string Addr3 = SalesOrderRet.SelectSingleNode("./BillAddressBlock/Addr3").InnerText;
                }
                //Get value of Addr4
                if (SalesOrderRet.SelectSingleNode("./BillAddressBlock/Addr4") != null)
                {
                    string Addr4 = SalesOrderRet.SelectSingleNode("./BillAddressBlock/Addr4").InnerText;
                }
                //Get value of Addr5
                if (SalesOrderRet.SelectSingleNode("./BillAddressBlock/Addr5") != null)
                {
                    string Addr5 = SalesOrderRet.SelectSingleNode("./BillAddressBlock/Addr5").InnerText;
                }
            }
            //Done with field values for BillAddressBlock aggregate

            //Get all field values for ShipAddress aggregate
            XmlNode ShipAddress = SalesOrderRet.SelectSingleNode("./ShipAddress");
            if (ShipAddress != null)
            {
                //Get value of Addr1
                if (SalesOrderRet.SelectSingleNode("./ShipAddress/Addr1") != null)
                {
                    string Addr1 = SalesOrderRet.SelectSingleNode("./ShipAddress/Addr1").InnerText;
                }
                //Get value of Addr2
                if (SalesOrderRet.SelectSingleNode("./ShipAddress/Addr2") != null)
                {
                    string Addr2 = SalesOrderRet.SelectSingleNode("./ShipAddress/Addr2").InnerText;
                }
                //Get value of Addr3
                if (SalesOrderRet.SelectSingleNode("./ShipAddress/Addr3") != null)
                {
                    string Addr3 = SalesOrderRet.SelectSingleNode("./ShipAddress/Addr3").InnerText;
                }
                //Get value of Addr4
                if (SalesOrderRet.SelectSingleNode("./ShipAddress/Addr4") != null)
                {
                    string Addr4 = SalesOrderRet.SelectSingleNode("./ShipAddress/Addr4").InnerText;
                }
                //Get value of Addr5
                if (SalesOrderRet.SelectSingleNode("./ShipAddress/Addr5") != null)
                {
                    string Addr5 = SalesOrderRet.SelectSingleNode("./ShipAddress/Addr5").InnerText;
                }
                //Get value of City
                if (SalesOrderRet.SelectSingleNode("./ShipAddress/City") != null)
                {
                    string City = SalesOrderRet.SelectSingleNode("./ShipAddress/City").InnerText;
                }
                //Get value of State
                if (SalesOrderRet.SelectSingleNode("./ShipAddress/State") != null)
                {
                    string State = SalesOrderRet.SelectSingleNode("./ShipAddress/State").InnerText;
                }
                //Get value of PostalCode
                if (SalesOrderRet.SelectSingleNode("./ShipAddress/PostalCode") != null)
                {
                    string PostalCode = SalesOrderRet.SelectSingleNode("./ShipAddress/PostalCode").InnerText;
                }
                //Get value of Country
                if (SalesOrderRet.SelectSingleNode("./ShipAddress/Country") != null)
                {
                    string Country = SalesOrderRet.SelectSingleNode("./ShipAddress/Country").InnerText;
                }
                //Get value of Note
                if (SalesOrderRet.SelectSingleNode("./ShipAddress/Note") != null)
                {
                    string Note = SalesOrderRet.SelectSingleNode("./ShipAddress/Note").InnerText;
                }
            }
            //Done with field values for ShipAddress aggregate

            //Get all field values for ShipAddressBlock aggregate
            XmlNode ShipAddressBlock = SalesOrderRet.SelectSingleNode("./ShipAddressBlock");
            if (ShipAddressBlock != null)
            {
                //Get value of Addr1
                if (SalesOrderRet.SelectSingleNode("./ShipAddressBlock/Addr1") != null)
                {
                    string Addr1 = SalesOrderRet.SelectSingleNode("./ShipAddressBlock/Addr1").InnerText;
                }
                //Get value of Addr2
                if (SalesOrderRet.SelectSingleNode("./ShipAddressBlock/Addr2") != null)
                {
                    string Addr2 = SalesOrderRet.SelectSingleNode("./ShipAddressBlock/Addr2").InnerText;
                }
                //Get value of Addr3
                if (SalesOrderRet.SelectSingleNode("./ShipAddressBlock/Addr3") != null)
                {
                    string Addr3 = SalesOrderRet.SelectSingleNode("./ShipAddressBlock/Addr3").InnerText;
                }
                //Get value of Addr4
                if (SalesOrderRet.SelectSingleNode("./ShipAddressBlock/Addr4") != null)
                {
                    string Addr4 = SalesOrderRet.SelectSingleNode("./ShipAddressBlock/Addr4").InnerText;
                }
                //Get value of Addr5
                if (SalesOrderRet.SelectSingleNode("./ShipAddressBlock/Addr5") != null)
                {
                    string Addr5 = SalesOrderRet.SelectSingleNode("./ShipAddressBlock/Addr5").InnerText;
                }
            }
            //Done with field values for ShipAddressBlock aggregate

            //Get value of PONumber
            if (SalesOrderRet.SelectSingleNode("./PONumber") != null)
            {
                string PONumber = SalesOrderRet.SelectSingleNode("./PONumber").InnerText;
            }
            //Get all field values for TermsRef aggregate
            XmlNode TermsRef = SalesOrderRet.SelectSingleNode("./TermsRef");
            if (TermsRef != null)
            {
                //Get value of ListID
                if (SalesOrderRet.SelectSingleNode("./TermsRef/ListID") != null)
                {
                    string ListID = SalesOrderRet.SelectSingleNode("./TermsRef/ListID").InnerText;
                }
                //Get value of FullName
                if (SalesOrderRet.SelectSingleNode("./TermsRef/FullName") != null)
                {
                    string FullName = SalesOrderRet.SelectSingleNode("./TermsRef/FullName").InnerText;
                }
            }
            //Done with field values for TermsRef aggregate

            //Get value of DueDate
            if (SalesOrderRet.SelectSingleNode("./DueDate") != null)
            {
                string DueDate = SalesOrderRet.SelectSingleNode("./DueDate").InnerText;
            }
            //Get all field values for SalesRepRef aggregate
            XmlNode SalesRepRef = SalesOrderRet.SelectSingleNode("./SalesRepRef");
            if (SalesRepRef != null)
            {
                //Get value of ListID
                if (SalesOrderRet.SelectSingleNode("./SalesRepRef/ListID") != null)
                {
                    string ListID = SalesOrderRet.SelectSingleNode("./SalesRepRef/ListID").InnerText;
                }
                //Get value of FullName
                if (SalesOrderRet.SelectSingleNode("./SalesRepRef/FullName") != null)
                {
                    string FullName = SalesOrderRet.SelectSingleNode("./SalesRepRef/FullName").InnerText;
                }
            }
            //Done with field values for SalesRepRef aggregate

            //Get value of FOB
            if (SalesOrderRet.SelectSingleNode("./FOB") != null)
            {
                string FOB = SalesOrderRet.SelectSingleNode("./FOB").InnerText;
            }
            //Get value of ShipDate
            if (SalesOrderRet.SelectSingleNode("./ShipDate") != null)
            {
                string ShipDate = SalesOrderRet.SelectSingleNode("./ShipDate").InnerText;
            }
            //Get all field values for ShipMethodRef aggregate
            XmlNode ShipMethodRef = SalesOrderRet.SelectSingleNode("./ShipMethodRef");
            if (ShipMethodRef != null)
            {
                //Get value of ListID
                if (SalesOrderRet.SelectSingleNode("./ShipMethodRef/ListID") != null)
                {
                    string ListID = SalesOrderRet.SelectSingleNode("./ShipMethodRef/ListID").InnerText;
                }
                //Get value of FullName
                if (SalesOrderRet.SelectSingleNode("./ShipMethodRef/FullName") != null)
                {
                    string FullName = SalesOrderRet.SelectSingleNode("./ShipMethodRef/FullName").InnerText;
                }
            }
            //Done with field values for ShipMethodRef aggregate

            //Get value of Subtotal
            if (SalesOrderRet.SelectSingleNode("./Subtotal") != null)
            {
                string Subtotal = SalesOrderRet.SelectSingleNode("./Subtotal").InnerText;
            }
            //Get all field values for ItemSalesTaxRef aggregate
            XmlNode ItemSalesTaxRef = SalesOrderRet.SelectSingleNode("./ItemSalesTaxRef");
            if (ItemSalesTaxRef != null)
            {
                //Get value of ListID
                if (SalesOrderRet.SelectSingleNode("./ItemSalesTaxRef/ListID") != null)
                {
                    string ListID = SalesOrderRet.SelectSingleNode("./ItemSalesTaxRef/ListID").InnerText;
                }
                //Get value of FullName
                if (SalesOrderRet.SelectSingleNode("./ItemSalesTaxRef/FullName") != null)
                {
                    string FullName = SalesOrderRet.SelectSingleNode("./ItemSalesTaxRef/FullName").InnerText;
                }
            }
            //Done with field values for ItemSalesTaxRef aggregate

            //Get value of SalesTaxPercentage
            if (SalesOrderRet.SelectSingleNode("./SalesTaxPercentage") != null)
            {
                string SalesTaxPercentage = SalesOrderRet.SelectSingleNode("./SalesTaxPercentage").InnerText;
            }
            //Get value of SalesTaxTotal
            if (SalesOrderRet.SelectSingleNode("./SalesTaxTotal") != null)
            {
                string SalesTaxTotal = SalesOrderRet.SelectSingleNode("./SalesTaxTotal").InnerText;
            }
            //Get value of TotalAmount
            string TotalAmount = "";
            if (SalesOrderRet.SelectSingleNode("./TotalAmount") != null)
            {
                TotalAmount = SalesOrderRet.SelectSingleNode("./TotalAmount").InnerText;
            }
            //Get all field values for CurrencyRef aggregate
            XmlNode CurrencyRef = SalesOrderRet.SelectSingleNode("./CurrencyRef");
            if (CurrencyRef != null)
            {
                //Get value of ListID
                if (SalesOrderRet.SelectSingleNode("./CurrencyRef/ListID") != null)
                {
                    string ListID = SalesOrderRet.SelectSingleNode("./CurrencyRef/ListID").InnerText;
                }
                //Get value of FullName
                if (SalesOrderRet.SelectSingleNode("./CurrencyRef/FullName") != null)
                {
                    string FullName = SalesOrderRet.SelectSingleNode("./CurrencyRef/FullName").InnerText;
                }
            }
            //Done with field values for CurrencyRef aggregate

            //Get value of ExchangeRate
            if (SalesOrderRet.SelectSingleNode("./ExchangeRate") != null)
            {
                string ExchangeRate = SalesOrderRet.SelectSingleNode("./ExchangeRate").InnerText;
            }
            //Get value of TotalAmountInHomeCurrency
            if (SalesOrderRet.SelectSingleNode("./TotalAmountInHomeCurrency") != null)
            {
                string TotalAmountInHomeCurrency = SalesOrderRet.SelectSingleNode("./TotalAmountInHomeCurrency").InnerText;
            }
            //Get value of IsManuallyClosed
            string IsManuallyClosed = "";
            if (SalesOrderRet.SelectSingleNode("./IsManuallyClosed") != null)
            {
                IsManuallyClosed = SalesOrderRet.SelectSingleNode("./IsManuallyClosed").InnerText;
            }
            //Get value of IsFullyInvoiced
            string IsFullyInvoiced = "";
            if (SalesOrderRet.SelectSingleNode("./IsFullyInvoiced") != null)
            {
                IsFullyInvoiced = SalesOrderRet.SelectSingleNode("./IsFullyInvoiced").InnerText;
            }
            //Get value of Memo
            if (SalesOrderRet.SelectSingleNode("./Memo") != null)
            {
                string Memo = SalesOrderRet.SelectSingleNode("./Memo").InnerText;
            }
            //Get all field values for CustomerMsgRef aggregate
            XmlNode CustomerMsgRef = SalesOrderRet.SelectSingleNode("./CustomerMsgRef");
            if (CustomerMsgRef != null)
            {
                //Get value of ListID
                if (SalesOrderRet.SelectSingleNode("./CustomerMsgRef/ListID") != null)
                {
                    string ListID = SalesOrderRet.SelectSingleNode("./CustomerMsgRef/ListID").InnerText;
                }
                //Get value of FullName
                if (SalesOrderRet.SelectSingleNode("./CustomerMsgRef/FullName") != null)
                {
                    string FullName = SalesOrderRet.SelectSingleNode("./CustomerMsgRef/FullName").InnerText;
                }
            }
            //Done with field values for CustomerMsgRef aggregate

            //Get value of IsToBePrinted
            if (SalesOrderRet.SelectSingleNode("./IsToBePrinted") != null)
            {
                string IsToBePrinted = SalesOrderRet.SelectSingleNode("./IsToBePrinted").InnerText;
            }
            //Get value of IsToBeEmailed
            if (SalesOrderRet.SelectSingleNode("./IsToBeEmailed") != null)
            {
                string IsToBeEmailed = SalesOrderRet.SelectSingleNode("./IsToBeEmailed").InnerText;
            }
            //Get all field values for CustomerSalesTaxCodeRef aggregate
            XmlNode CustomerSalesTaxCodeRef = SalesOrderRet.SelectSingleNode("./CustomerSalesTaxCodeRef");
            if (CustomerSalesTaxCodeRef != null)
            {
                //Get value of ListID
                if (SalesOrderRet.SelectSingleNode("./CustomerSalesTaxCodeRef/ListID") != null)
                {
                    string ListID = SalesOrderRet.SelectSingleNode("./CustomerSalesTaxCodeRef/ListID").InnerText;
                }
                //Get value of FullName
                if (SalesOrderRet.SelectSingleNode("./CustomerSalesTaxCodeRef/FullName") != null)
                {
                    string FullName = SalesOrderRet.SelectSingleNode("./CustomerSalesTaxCodeRef/FullName").InnerText;
                }
            }
            //Done with field values for CustomerSalesTaxCodeRef aggregate

            //Get value of Other
            if (SalesOrderRet.SelectSingleNode("./Other") != null)
            {
                string Other = SalesOrderRet.SelectSingleNode("./Other").InnerText;
            }
            //Get value of ExternalGUID
            if (SalesOrderRet.SelectSingleNode("./ExternalGUID") != null)
            {
                string ExternalGUID = SalesOrderRet.SelectSingleNode("./ExternalGUID").InnerText;
            }
            //Walk list of LinkedTxn aggregates
            XmlNodeList LinkedTxnList = SalesOrderRet.SelectNodes("./LinkedTxn");
            if (LinkedTxnList != null)
            {
                for (int i = 0; i < LinkedTxnList.Count; i++)
                {
                    XmlNode LinkedTxn = LinkedTxnList.Item(i);
                    //Get value of TxnID
                    string TxnID2 = LinkedTxn.SelectSingleNode("./TxnID").InnerText;
                    //Get value of TxnType
                    string TxnType = LinkedTxn.SelectSingleNode("./TxnType").InnerText;
                    //Get value of TxnDate
                    string TxnDate2 = LinkedTxn.SelectSingleNode("./TxnDate").InnerText;
                    //Get value of RefNumber
                    if (LinkedTxn.SelectSingleNode("./RefNumber") != null)
                    {
                        string RefNumber = LinkedTxn.SelectSingleNode("./RefNumber").InnerText;
                    }
                    //Get value of LinkType
                    if (LinkedTxn.SelectSingleNode("./LinkType") != null)
                    {
                        string LinkType = LinkedTxn.SelectSingleNode("./LinkType").InnerText;
                    }
                    //Get value of Amount
                    string Amount = LinkedTxn.SelectSingleNode("./Amount").InnerText;
                }
            }

            XmlNodeList ORSalesOrderLineRetListChildren = SalesOrderRet.SelectNodes("./*");
            for (int i = 0; i < ORSalesOrderLineRetListChildren.Count; i++)
            {
                XmlNode Child = ORSalesOrderLineRetListChildren.Item(i);
                if (Child.Name == "SalesOrderLineRet")
                {
                    //Get value of TxnLineID
                    string TxnLineID = Child.SelectSingleNode("./TxnLineID").InnerText;

                    // Find existing or create new SalesOrderLine entry
                    SalesOrderLine sol = FindOrCreateSalesOrderLine(db, TxnLineID, TxnID, TimeCreated, TimeModified, EditSequence, TxnDate, TotalAmount, IsManuallyClosed, IsFullyInvoiced);

                    //Get all field values for ItemRef aggregate
                    XmlNode ItemRef = Child.SelectSingleNode("./ItemRef");
                    if (ItemRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./ItemRef/ListID") != null)
                        {
                            string ListID = Child.SelectSingleNode("./ItemRef/ListID").InnerText;
                            sol.ItemListID = ListID;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./ItemRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./ItemRef/FullName").InnerText;
                            sol.ItemName = FullName;
                        }
                    }
                    //Done with field values for ItemRef aggregate

                    //Get value of Desc
                    if (Child.SelectSingleNode("./Desc") != null)
                    {
                        string Desc = Child.SelectSingleNode("./Desc").InnerText;
                        sol.Description = Desc;
                    }
                    //Get value of Quantity
                    if (Child.SelectSingleNode("./Quantity") != null)
                    {
                        string Quantity = Child.SelectSingleNode("./Quantity").InnerText;
                        decimal quantity;
                        if (Decimal.TryParse(Quantity, out quantity))
                        {
                            sol.Quantity = quantity;
                        }
                    }
                    //Get value of UnitOfMeasure
                    if (Child.SelectSingleNode("./UnitOfMeasure") != null)
                    {
                        string UnitOfMeasure = Child.SelectSingleNode("./UnitOfMeasure").InnerText;
                    }
                    //Get all field values for OverrideUOMSetRef aggregate
                    XmlNode OverrideUOMSetRef = Child.SelectSingleNode("./OverrideUOMSetRef");
                    if (OverrideUOMSetRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./OverrideUOMSetRef/ListID") != null)
                        {
                            string ListID = Child.SelectSingleNode("./OverrideUOMSetRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./OverrideUOMSetRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./OverrideUOMSetRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for OverrideUOMSetRef aggregate
                    if (Child.SelectSingleNode("./Rate") != null)
                    {
                        string Rate = Child.SelectSingleNode("./Rate").InnerText;
                        decimal rate;
                        if (decimal.TryParse(Rate, out rate))
                        {
                            sol.UnitCost = rate;
                        }
                    }

                    //Get all field values for ClassRef aggregate
                    XmlNode ClassRef2 = Child.SelectSingleNode("./ClassRef");
                    if (ClassRef2 != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./ClassRef/ListID") != null)
                        {
                            string ListID = Child.SelectSingleNode("./ClassRef/ListID").InnerText;
                            sol.AreaListID = ListID;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./ClassRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./ClassRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for ClassRef aggregate

                    //Get value of Amount
                    if (Child.SelectSingleNode("./Amount") != null)
                    {
                        string Amount = Child.SelectSingleNode("./Amount").InnerText;
                        decimal amount;
                        if (decimal.TryParse(Amount, out amount))
                        {
                            sol.Amount = amount;
                        }
                    }
                    //Get all field values for InventorySiteRef aggregate
                    XmlNode InventorySiteRef = Child.SelectSingleNode("./InventorySiteRef");
                    if (InventorySiteRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./InventorySiteRef/ListID") != null)
                        {
                            string ListID = Child.SelectSingleNode("./InventorySiteRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./InventorySiteRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./InventorySiteRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for InventorySiteRef aggregate

                    //Get all field values for InventorySiteLocationRef aggregate
                    XmlNode InventorySiteLocationRef = Child.SelectSingleNode("./InventorySiteLocationRef");
                    if (InventorySiteLocationRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./InventorySiteLocationRef/ListID") != null)
                        {
                            string ListID = Child.SelectSingleNode("./InventorySiteLocationRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./InventorySiteLocationRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./InventorySiteLocationRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for InventorySiteLocationRef aggregate

                    //Get all field values for SalesTaxCodeRef aggregate
                    XmlNode SalesTaxCodeRef = Child.SelectSingleNode("./SalesTaxCodeRef");
                    if (SalesTaxCodeRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./SalesTaxCodeRef/ListID") != null)
                        {
                            string ListID = Child.SelectSingleNode("./SalesTaxCodeRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./SalesTaxCodeRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./SalesTaxCodeRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for SalesTaxCodeRef aggregate

                    //Get value of Invoiced
                    if (Child.SelectSingleNode("./Invoiced") != null)
                    {
                        string Invoiced = Child.SelectSingleNode("./Invoiced").InnerText;
                    }
                    //Get value of IsManuallyClosed
                    if (Child.SelectSingleNode("./IsManuallyClosed") != null)
                    {
                        string IsManuallyClosed2 = Child.SelectSingleNode("./IsManuallyClosed").InnerText;
                    }
                    //Get value of Other1
                    if (Child.SelectSingleNode("./Other1") != null)
                    {
                        string Other1 = Child.SelectSingleNode("./Other1").InnerText;
                    }
                    //Get value of Other2
                    if (Child.SelectSingleNode("./Other2") != null)
                    {
                        string Other2 = Child.SelectSingleNode("./Other2").InnerText;
                    }
                    //Walk list of DataExtRet aggregates
                    XmlNodeList DataExtRetList = Child.SelectNodes("./DataExtRet");
                    if (DataExtRetList != null)
                    {
                        for (int j = 0; j < DataExtRetList.Count; j++)
                        {
                            XmlNode DataExtRet = DataExtRetList.Item(j);
                            //Get value of OwnerID
                            if (DataExtRet.SelectSingleNode("./OwnerID") != null)
                            {
                                string OwnerID = DataExtRet.SelectSingleNode("./OwnerID").InnerText;
                            }
                            //Get value of DataExtName
                            string DataExtName = DataExtRet.SelectSingleNode("./DataExtName").InnerText;
                            //Get value of DataExtType
                            string DataExtType = DataExtRet.SelectSingleNode("./DataExtType").InnerText;
                            //Get value of DataExtValue
                            string DataExtValue = DataExtRet.SelectSingleNode("./DataExtValue").InnerText;
                        }
                    }

                    sol.WorkOrderListID = CustomerListID;
                    sol.BillableStatus = "Billable";
                    db.SaveChanges();
                }

                if (Child.Name == "SalesOrderLineGroupRet")
                {
                    //Get value of TxnLineID
                    string TxnLineID = Child.SelectSingleNode("./TxnLineID").InnerText;
                    //Get all field values for ItemGroupRef aggregate
                    //Get value of ListID
                    if (Child.SelectSingleNode("./ItemGroupRef/ListID") != null)
                    {
                        string ListID = Child.SelectSingleNode("./ItemGroupRef/ListID").InnerText;
                    }
                    //Get value of FullName
                    if (Child.SelectSingleNode("./ItemGroupRef/FullName") != null)
                    {
                        string FullName = Child.SelectSingleNode("./ItemGroupRef/FullName").InnerText;
                    }
                    //Done with field values for ItemGroupRef aggregate

                    //Get value of Desc
                    if (Child.SelectSingleNode("./Desc") != null)
                    {
                        string Desc = Child.SelectSingleNode("./Desc").InnerText;
                    }
                    //Get value of Quantity
                    if (Child.SelectSingleNode("./Quantity") != null)
                    {
                        string Quantity = Child.SelectSingleNode("./Quantity").InnerText;
                    }
                    //Get value of UnitOfMeasure
                    if (Child.SelectSingleNode("./UnitOfMeasure") != null)
                    {
                        string UnitOfMeasure = Child.SelectSingleNode("./UnitOfMeasure").InnerText;
                    }
                    //Get all field values for OverrideUOMSetRef aggregate
                    XmlNode OverrideUOMSetRef = Child.SelectSingleNode("./OverrideUOMSetRef");
                    if (OverrideUOMSetRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./OverrideUOMSetRef/ListID") != null)
                        {
                            string ListID = Child.SelectSingleNode("./OverrideUOMSetRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./OverrideUOMSetRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./OverrideUOMSetRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for OverrideUOMSetRef aggregate

                    //Get value of IsPrintItemsInGroup
                    string IsPrintItemsInGroup = Child.SelectSingleNode("./IsPrintItemsInGroup").InnerText;
                    //Get value of TotalAmount
                    string TotalAmount2 = Child.SelectSingleNode("./TotalAmount").InnerText;
                    //Walk list of SalesOrderLineRet aggregates
                    XmlNodeList SalesOrderLineRetList = Child.SelectNodes("./SalesOrderLineRet");
                    if (SalesOrderLineRetList != null)
                    {
                        for (int k = 0; k < SalesOrderLineRetList.Count; k++)
                        {
                            XmlNode SalesOrderLineRet = SalesOrderLineRetList.Item(k);
                            //Get value of TxnLineID
                            string TxnLineID2 = SalesOrderLineRet.SelectSingleNode("./TxnLineID").InnerText;

                            // Find existing or create new SalesOrderLine entry
                            SalesOrderLine sol = FindOrCreateSalesOrderLine(db, TxnLineID2, TxnID, TimeCreated, TimeModified, EditSequence, TxnDate, TotalAmount, IsManuallyClosed, IsFullyInvoiced);

                            //Get all field values for ItemRef aggregate
                            XmlNode ItemRef = SalesOrderLineRet.SelectSingleNode("./ItemRef");
                            if (ItemRef != null)
                            {
                                //Get value of ListID
                                if (SalesOrderLineRet.SelectSingleNode("./ItemRef/ListID") != null)
                                {
                                    string ListID = SalesOrderLineRet.SelectSingleNode("./ItemRef/ListID").InnerText;
                                    sol.ItemListID = ListID;
                                }
                                //Get value of FullName
                                if (SalesOrderLineRet.SelectSingleNode("./ItemRef/FullName") != null)
                                {
                                    string FullName = SalesOrderLineRet.SelectSingleNode("./ItemRef/FullName").InnerText;
                                    sol.ItemName = FullName;
                                }
                            }
                            //Done with field values for ItemRef aggregate

                            //Get value of Desc
                            if (SalesOrderLineRet.SelectSingleNode("./Desc") != null)
                            {
                                string Desc = SalesOrderLineRet.SelectSingleNode("./Desc").InnerText;
                                sol.Description = Desc;
                            }
                            //Get value of Quantity
                            if (SalesOrderLineRet.SelectSingleNode("./Quantity") != null)
                            {
                                string Quantity = SalesOrderLineRet.SelectSingleNode("./Quantity").InnerText;
                                decimal quantity;
                                if (Decimal.TryParse(Quantity, out quantity))
                                {
                                    sol.Quantity = quantity;
                                }
                            }
                            //Get value of UnitOfMeasure
                            if (SalesOrderLineRet.SelectSingleNode("./UnitOfMeasure") != null)
                            {
                                string UnitOfMeasure = SalesOrderLineRet.SelectSingleNode("./UnitOfMeasure").InnerText;
                            }
                            //Get all field values for OverrideUOMSetRef aggregate
                            XmlNode OverrideUOMSetRef2 = SalesOrderLineRet.SelectSingleNode("./OverrideUOMSetRef");
                            if (OverrideUOMSetRef2 != null)
                            {
                                //Get value of ListID
                                if (SalesOrderLineRet.SelectSingleNode("./OverrideUOMSetRef/ListID") != null)
                                {
                                    string ListID = SalesOrderLineRet.SelectSingleNode("./OverrideUOMSetRef/ListID").InnerText;
                                }
                                //Get value of FullName
                                if (SalesOrderLineRet.SelectSingleNode("./OverrideUOMSetRef/FullName") != null)
                                {
                                    string FullName = SalesOrderLineRet.SelectSingleNode("./OverrideUOMSetRef/FullName").InnerText;
                                }
                            }
                            //Done with field values for OverrideUOMSetRef aggregate

                            //Done with field values for OverrideUOMSetRef aggregate
                            if (SalesOrderLineRet.SelectSingleNode("./Rate") != null)
                            {
                                string Rate = SalesOrderLineRet.SelectSingleNode("./Rate").InnerText;
                                decimal rate;
                                if (decimal.TryParse(Rate, out rate))
                                {
                                    sol.UnitCost = rate;
                                }
                            }

                            //Get all field values for ClassRef aggregate
                            XmlNode ClassRef2 = SalesOrderLineRet.SelectSingleNode("./ClassRef");
                            if (ClassRef != null)
                            {
                                //Get value of ListID
                                if (SalesOrderLineRet.SelectSingleNode("./ClassRef/ListID") != null)
                                {
                                    string ListID = SalesOrderLineRet.SelectSingleNode("./ClassRef/ListID").InnerText;
                                    sol.AreaListID = ListID;
                                }
                                //Get value of FullName
                                if (SalesOrderLineRet.SelectSingleNode("./ClassRef/FullName") != null)
                                {
                                    string FullName = SalesOrderLineRet.SelectSingleNode("./ClassRef/FullName").InnerText;
                                }
                            }
                            //Done with field values for ClassRef aggregate

                            //Get value of Amount
                            if (SalesOrderLineRet.SelectSingleNode("./Amount") != null)
                            {
                                string Amount = SalesOrderLineRet.SelectSingleNode("./Amount").InnerText;
                                decimal amount;
                                if (decimal.TryParse(Amount, out amount))
                                {
                                    sol.Amount = amount;
                                }
                            }
                            //Get all field values for InventorySiteRef aggregate
                            XmlNode InventorySiteRef = SalesOrderLineRet.SelectSingleNode("./InventorySiteRef");
                            if (InventorySiteRef != null)
                            {
                                //Get value of ListID
                                if (SalesOrderLineRet.SelectSingleNode("./InventorySiteRef/ListID") != null)
                                {
                                    string ListID = SalesOrderLineRet.SelectSingleNode("./InventorySiteRef/ListID").InnerText;
                                }
                                //Get value of FullName
                                if (SalesOrderLineRet.SelectSingleNode("./InventorySiteRef/FullName") != null)
                                {
                                    string FullName = SalesOrderLineRet.SelectSingleNode("./InventorySiteRef/FullName").InnerText;
                                }
                            }
                            //Done with field values for InventorySiteRef aggregate

                            //Get all field values for InventorySiteLocationRef aggregate
                            XmlNode InventorySiteLocationRef = SalesOrderLineRet.SelectSingleNode("./InventorySiteLocationRef");
                            if (InventorySiteLocationRef != null)
                            {
                                //Get value of ListID
                                if (SalesOrderLineRet.SelectSingleNode("./InventorySiteLocationRef/ListID") != null)
                                {
                                    string ListID = SalesOrderLineRet.SelectSingleNode("./InventorySiteLocationRef/ListID").InnerText;
                                }
                                //Get value of FullName
                                if (SalesOrderLineRet.SelectSingleNode("./InventorySiteLocationRef/FullName") != null)
                                {
                                    string FullName = SalesOrderLineRet.SelectSingleNode("./InventorySiteLocationRef/FullName").InnerText;
                                }
                            }
                            //Done with field values for InventorySiteLocationRef aggregate

                            //Get all field values for SalesTaxCodeRef aggregate
                            XmlNode SalesTaxCodeRef = SalesOrderLineRet.SelectSingleNode("./SalesTaxCodeRef");
                            if (SalesTaxCodeRef != null)
                            {
                                //Get value of ListID
                                if (SalesOrderLineRet.SelectSingleNode("./SalesTaxCodeRef/ListID") != null)
                                {
                                    string ListID = SalesOrderLineRet.SelectSingleNode("./SalesTaxCodeRef/ListID").InnerText;
                                }
                                //Get value of FullName
                                if (SalesOrderLineRet.SelectSingleNode("./SalesTaxCodeRef/FullName") != null)
                                {
                                    string FullName = SalesOrderLineRet.SelectSingleNode("./SalesTaxCodeRef/FullName").InnerText;
                                }
                            }
                            //Done with field values for SalesTaxCodeRef aggregate

                            //Get value of Invoiced
                            if (SalesOrderLineRet.SelectSingleNode("./Invoiced") != null)
                            {
                                string Invoiced = SalesOrderLineRet.SelectSingleNode("./Invoiced").InnerText;
                            }
                            //Get value of IsManuallyClosed
                            if (SalesOrderLineRet.SelectSingleNode("./IsManuallyClosed") != null)
                            {
                                string IsManuallyClosed2 = SalesOrderLineRet.SelectSingleNode("./IsManuallyClosed").InnerText;
                            }
                            //Get value of Other1
                            if (SalesOrderLineRet.SelectSingleNode("./Other1") != null)
                            {
                                string Other1 = SalesOrderLineRet.SelectSingleNode("./Other1").InnerText;
                            }
                            //Get value of Other2
                            if (SalesOrderLineRet.SelectSingleNode("./Other2") != null)
                            {
                                string Other2 = SalesOrderLineRet.SelectSingleNode("./Other2").InnerText;
                            }
                            //Walk list of DataExtRet aggregates
                            XmlNodeList DataExtRetList = SalesOrderLineRet.SelectNodes("./DataExtRet");
                            if (DataExtRetList != null)
                            {
                                for (int l = 0; l < DataExtRetList.Count; l++)
                                {
                                    XmlNode DataExtRet = DataExtRetList.Item(l);
                                    //Get value of OwnerID
                                    if (DataExtRet.SelectSingleNode("./OwnerID") != null)
                                    {
                                        string OwnerID = DataExtRet.SelectSingleNode("./OwnerID").InnerText;
                                    }
                                    //Get value of DataExtName
                                    string DataExtName = DataExtRet.SelectSingleNode("./DataExtName").InnerText;
                                    //Get value of DataExtType
                                    string DataExtType = DataExtRet.SelectSingleNode("./DataExtType").InnerText;
                                    //Get value of DataExtValue
                                    string DataExtValue = DataExtRet.SelectSingleNode("./DataExtValue").InnerText;
                                }
                            }

                            sol.WorkOrderListID = CustomerListID;
                            sol.BillableStatus = "Billable";
                            db.SaveChanges();
                        }
                    }

                    //Walk list of DataExtRet aggregates
                    XmlNodeList DataExtRetList2 = Child.SelectNodes("./DataExtRet");
                    if (DataExtRetList2 != null)
                    {
                        for (int m = 0; m < DataExtRetList2.Count; m++)
                        {
                            XmlNode DataExtRet = DataExtRetList2.Item(m);
                            //Get value of OwnerID
                            if (DataExtRet.SelectSingleNode("./OwnerID") != null)
                            {
                                string OwnerID = DataExtRet.SelectSingleNode("./OwnerID").InnerText;
                            }
                            //Get value of DataExtName
                            string DataExtName = DataExtRet.SelectSingleNode("./DataExtName").InnerText;
                            //Get value of DataExtType
                            string DataExtType = DataExtRet.SelectSingleNode("./DataExtType").InnerText;
                            //Get value of DataExtValue
                            string DataExtValue = DataExtRet.SelectSingleNode("./DataExtValue").InnerText;
                        }
                    }
                }
            }
        }
 private static void RemoveExistingLineItems(RotoTrackDb db, string TxnID)
 {
     List<VendorCreditLine> blList = db.VendorCreditLines.Where(f => f.VendorCreditTxnId == TxnID).ToList();
     foreach (VendorCreditLine vcl in blList.ToList())
     {
         db.VendorCreditLines.Remove(vcl);
     }
     db.SaveChanges();
 }
Example #44
0
        private static void WalkEmployeeRet(XmlNode EmployeeRet)
        {
            if (EmployeeRet == null)
            {
                return;
            }

            Employee    emp = null;
            RotoTrackDb db  = new RotoTrackDb();

            string ListID = EmployeeRet.SelectSingleNode("./ListID").InnerText;

            if (db.Employees.Any(f => f.QBListId == ListID))
            {
                emp = db.Employees.First(f => f.QBListId == ListID);
            }
            else
            {
                emp = new Employee();
                db.Employees.Add(emp);
            }
            emp.QBListId = ListID;

            string Name = EmployeeRet.SelectSingleNode("./Name").InnerText;

            emp.Name = Name;

            if (EmployeeRet.SelectSingleNode("./IsActive") != null)
            {
                string IsActive = EmployeeRet.SelectSingleNode("./IsActive").InnerText;
                emp.IsActive = (IsActive == "true") ? true : false;
            }
            if (EmployeeRet.SelectSingleNode("./FirstName") != null)
            {
                string FirstName = EmployeeRet.SelectSingleNode("./FirstName").InnerText;
                emp.FirstName = FirstName;
            }
            if (EmployeeRet.SelectSingleNode("./MiddleName") != null)
            {
                string MiddleName = EmployeeRet.SelectSingleNode("./MiddleName").InnerText;
                emp.MiddleName = MiddleName;
            }
            if (EmployeeRet.SelectSingleNode("./LastName") != null)
            {
                string LastName = EmployeeRet.SelectSingleNode("./LastName").InnerText;
                emp.LastName = LastName;
            }
            if (EmployeeRet.SelectSingleNode("./JobTitle") != null)
            {
                string JobTitle = EmployeeRet.SelectSingleNode("./JobTitle").InnerText;
                emp.JobTitle = JobTitle;
            }
            if (EmployeeRet.SelectSingleNode("./Phone") != null)
            {
                string Phone = EmployeeRet.SelectSingleNode("./Phone").InnerText;
                emp.Phone = Phone;
            }
            if (EmployeeRet.SelectSingleNode("./Mobile") != null)
            {
                string Mobile = EmployeeRet.SelectSingleNode("./Mobile").InnerText;
                emp.Mobile = Mobile;
            }
            if (EmployeeRet.SelectSingleNode("./Email") != null)
            {
                string Email = EmployeeRet.SelectSingleNode("./Email").InnerText;
                emp.Email = Email;
            }
            if (EmployeeRet.SelectSingleNode("./HiredDate") != null)
            {
                string   HiredDate = EmployeeRet.SelectSingleNode("./HiredDate").InnerText;
                DateTime hDate;
                if (DateTime.TryParse(HiredDate, out hDate))
                {
                    emp.HireDate = hDate;
                }
            }

            //Get all field values for EmployeePayrollInfo aggregate
            XmlNode EmployeePayrollInfo = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo");

            if (EmployeePayrollInfo != null)
            {
                //Get value of PayPeriod
                if (EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/PayPeriod") != null)
                {
                    string PayPeriod = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/PayPeriod").InnerText;
                }
                //Get all field values for ClassRef aggregate
                XmlNode ClassRef = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/ClassRef");
                if (ClassRef != null)
                {
                    //Get value of ListID
                    if (EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/ClassRef/ListID") != null)
                    {
                        string ListID2 = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/ClassRef/ListID").InnerText;
                    }
                    //Get value of FullName
                    if (EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/ClassRef/FullName") != null)
                    {
                        string FullName = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/ClassRef/FullName").InnerText;
                    }
                }
                //Done with field values for ClassRef aggregate

                XmlNodeList OREarningsChildren = EmployeeRet.SelectNodes("./EmployeePayrollInfo/*");
                for (int i = 0; i < OREarningsChildren.Count; i++)
                {
                    XmlNode Child = OREarningsChildren.Item(i);
                    if (Child.Name == "ClearEarnings")
                    {
                    }

                    if (Child.Name == "Earnings")
                    {
                        //Get all field values for PayrollItemWageRef aggregate
                        //Get value of ListID
                        if (Child.SelectSingleNode("./PayrollItemWageRef/ListID") != null)
                        {
                            string ListID3 = Child.SelectSingleNode("./PayrollItemWageRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./PayrollItemWageRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./PayrollItemWageRef/FullName").InnerText;
                        }
                        //Done with field values for PayrollItemWageRef aggregate

                        XmlNodeList ORRateChildren = Child.SelectNodes("./*");
                        for (int j = 0; j < ORRateChildren.Count; j++)
                        {
                            XmlNode Child2 = ORRateChildren.Item(j);
                            if (Child2.Name == "Rate")
                            {
                            }

                            if (Child2.Name == "RatePercent")
                            {
                            }
                        }
                    }
                }

                //Get value of IsUsingTimeDataToCreatePaychecks
                if (EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/IsUsingTimeDataToCreatePaychecks") != null)
                {
                    string IsUsingTimeDataToCreatePaychecks = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/IsUsingTimeDataToCreatePaychecks").InnerText;
                }
                //Get value of UseTimeDataToCreatePaychecks
                if (EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/UseTimeDataToCreatePaychecks") != null)
                {
                    string UseTimeDataToCreatePaychecks = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/UseTimeDataToCreatePaychecks").InnerText;
                }
                //Get all field values for SickHours aggregate
                XmlNode SickHours = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/SickHours");
                if (SickHours != null)
                {
                    //Get value of HoursAvailable
                    if (EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/SickHours/HoursAvailable") != null)
                    {
                        string HoursAvailable = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/SickHours/HoursAvailable").InnerText;
                    }
                    //Get value of AccrualPeriod
                    if (EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/SickHours/AccrualPeriod") != null)
                    {
                        string AccrualPeriod = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/SickHours/AccrualPeriod").InnerText;
                    }
                    //Get value of HoursAccrued
                    if (EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/SickHours/HoursAccrued") != null)
                    {
                        string HoursAccrued = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/SickHours/HoursAccrued").InnerText;
                    }
                    //Get value of MaximumHours
                    if (EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/SickHours/MaximumHours") != null)
                    {
                        string MaximumHours = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/SickHours/MaximumHours").InnerText;
                    }
                    //Get value of IsResettingHoursEachNewYear
                    if (EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/SickHours/IsResettingHoursEachNewYear") != null)
                    {
                        string IsResettingHoursEachNewYear = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/SickHours/IsResettingHoursEachNewYear").InnerText;
                    }
                    //Get value of HoursUsed
                    if (EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/SickHours/HoursUsed") != null)
                    {
                        string HoursUsed = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/SickHours/HoursUsed").InnerText;
                    }
                    //Get value of AccrualStartDate
                    if (EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/SickHours/AccrualStartDate") != null)
                    {
                        string AccrualStartDate = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/SickHours/AccrualStartDate").InnerText;
                    }
                }
                //Done with field values for SickHours aggregate

                //Get all field values for VacationHours aggregate
                XmlNode VacationHours = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/VacationHours");
                if (VacationHours != null)
                {
                    //Get value of HoursAvailable
                    if (EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/VacationHours/HoursAvailable") != null)
                    {
                        string HoursAvailable = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/VacationHours/HoursAvailable").InnerText;
                        emp.VacationHoursOffer = 0;
                        int vacHoursOffer;
                        if (Int32.TryParse(HoursAvailable, out vacHoursOffer))
                        {
                            // mgruetzner-6/8/2015--Don't set this here any longer--it messes up the vacation calcs.  If we want to override the standard formula, do it in rototrack.
                            //emp.VacationHoursOffer = vacHoursOffer;
                        }
                    }
                    //Get value of AccrualPeriod
                    if (EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/VacationHours/AccrualPeriod") != null)
                    {
                        string AccrualPeriod = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/VacationHours/AccrualPeriod").InnerText;
                    }
                    //Get value of HoursAccrued
                    if (EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/VacationHours/HoursAccrued") != null)
                    {
                        string HoursAccrued = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/VacationHours/HoursAccrued").InnerText;
                    }
                    //Get value of MaximumHours
                    if (EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/VacationHours/MaximumHours") != null)
                    {
                        string MaximumHours = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/VacationHours/MaximumHours").InnerText;
                    }
                    //Get value of IsResettingHoursEachNewYear
                    if (EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/VacationHours/IsResettingHoursEachNewYear") != null)
                    {
                        string IsResettingHoursEachNewYear = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/VacationHours/IsResettingHoursEachNewYear").InnerText;
                    }
                    //Get value of HoursUsed
                    if (EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/VacationHours/HoursUsed") != null)
                    {
                        string HoursUsed = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/VacationHours/HoursUsed").InnerText;
                    }
                    //Get value of AccrualStartDate
                    if (EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/VacationHours/AccrualStartDate") != null)
                    {
                        string AccrualStartDate = EmployeeRet.SelectSingleNode("./EmployeePayrollInfo/VacationHours/AccrualStartDate").InnerText;
                    }
                }
                //Done with field values for VacationHours aggregate
            }
            //Done with field values for EmployeePayrollInfo aggregate

            Area area = GetAreaFromEmployeeRet(EmployeeRet);

            emp.AreaId = area.Id;

            emp.Initials = GetInitialsFromEmployeeRet(EmployeeRet);

            db.SaveChanges();

            AddOrUpdateUserProfile(emp);
        }
Example #45
0
        private static void AddOrUpdateUserProfile(Employee emp)
        {
            UserProfile u  = null;
            RotoTrackDb db = new RotoTrackDb();

            // If user already exists, simply update the attributes except for Username and password
            if (db.UserProfiles.Any(f => f.QBListId == emp.QBListId))
            {
                u = db.UserProfiles.First(f => f.QBListId == emp.QBListId);

                u.Email      = emp.Email;
                u.AreaId     = emp.AreaId;
                u.Initials   = emp.Initials;
                u.FirstName  = emp.FirstName;
                u.IsActive   = emp.IsActive;
                u.JobTitle   = emp.JobTitle;
                u.LastName   = emp.LastName;
                u.MiddleName = emp.MiddleName;
                u.Mobile     = emp.Mobile;
                u.Name       = emp.Name;
                u.Phone      = emp.Phone;

                db.SaveChanges();
            }
            // Else if employee is active, see if we can automatically create a new user profile
            else if (emp.IsActive)
            {
                string username = "";
                if ((emp.Email != null) && (emp.Email.Length > 0))
                {
                    username = emp.Email;
                }
                else if ((emp.FirstName.Length > 0) && (emp.LastName.Length > 0))
                {
                    username = emp.FirstName.ToLower() + "." + emp.LastName.ToLower() + "@roto-versal.com";
                }

                // If username is set, then we can create a new user.  Let's make them a Technician by default.  Password default to 'rototrack'
                if (username != "")
                {
                    try
                    {
                        RotoTrackDbUtils.CreateUserWithRoles(
                            username,
                            "rototrack",
                            new[] { "Technician" },
                            new
                        {
                            Email      = emp.Email,
                            AreaId     = emp.AreaId,
                            Initials   = emp.Initials,
                            FirstName  = emp.FirstName,
                            IsActive   = emp.IsActive,
                            JobTitle   = emp.JobTitle,
                            LastName   = emp.LastName,
                            MiddleName = emp.MiddleName,
                            Mobile     = emp.Mobile,
                            Name       = emp.Name,
                            Phone      = emp.Phone,
                            QBListID   = emp.QBListId
                        }
                            );
                    }
                    catch (Exception e)
                    {
                        string evLogTxt = "";
                        evLogTxt = "Error creating a new user! " + e.Message + "\r\n";
                        Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + evLogTxt);
                    }
                }
            }
        }
Example #46
0
        private static XmlDocument BuildAddOrModRq(WorkOrder wo)
        {
            RotoTrackDb db     = new RotoTrackDb();
            XmlDocument doc    = XmlUtils.MakeRequestDocument();
            XmlElement  parent = XmlUtils.MakeRequestParentElement(doc);

            BillingInstruction bi  = db.BillingInstructions.Find(wo.BillingInstructionsId);
            Area          area     = db.Areas.Find(wo.AreaId);
            Customer      customer = db.Customers.Find(wo.CustomerId);
            WorkOrderType wot      = db.WorkOrderTypes.Find(wo.WorkOrderTypeId);
            Contact       contact  = db.Contacts.Find(wo.ContactId);
            Site          site     = db.Sites.Find(wo.SiteId);
            JobType       jt       = db.JobTypes.Find(wo.JobTypeId);

            XmlElement CustomerAddOrModRq = null;
            XmlElement CustomerAddOrMod   = null;

            if (wo.QBListId == null)
            {
                CustomerAddOrModRq = doc.CreateElement("CustomerAddRq");
                parent.AppendChild(CustomerAddOrModRq);
                CustomerAddOrMod = doc.CreateElement("CustomerAdd");
                CustomerAddOrModRq.AppendChild(CustomerAddOrMod);
            }
            else
            {
                CustomerAddOrModRq = doc.CreateElement("CustomerModRq");
                parent.AppendChild(CustomerAddOrModRq);
                CustomerAddOrMod = doc.CreateElement("CustomerMod");
                CustomerAddOrModRq.AppendChild(CustomerAddOrMod);

                CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "ListID", wo.QBListId));
                CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "EditSequence", wo.QBEditSequence));
            }

            CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "Name", wo.WorkOrderNumber));

            string isActive = (wo.statusValue != (int)WorkOrderStatus.Inactive) ? "1" : "0";

            CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "IsActive", isActive));

            XmlElement ParentRef = doc.CreateElement("ParentRef");

            CustomerAddOrMod.AppendChild(ParentRef);
            ParentRef.AppendChild(XmlUtils.MakeSimpleElem(doc, "ListID", customer.QBListId));

            CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "CompanyName", customer.CompanyName));

            if (contact != null)
            {
                string[] namePieces = contact.Name.Split(' ');
                string   firstName;
                string   lastName;
                string   middleName;
                if (namePieces.Count() == 2)
                {
                    firstName = namePieces[0];
                    lastName  = namePieces[1];

                    if (firstName.Length > 15)
                    {
                        firstName = firstName.Substring(0, 15);
                    }
                    if (lastName.Length > 18)
                    {
                        lastName = lastName.Substring(0, 18);
                    }
                    contact.Name = firstName + " " + lastName;

                    CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "FirstName", firstName));
                    CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "LastName", lastName));
                }
                else if (namePieces.Count() == 3)
                {
                    firstName  = namePieces[0];
                    middleName = namePieces[1];
                    lastName   = namePieces[2];

                    if (firstName.Length > 15)
                    {
                        firstName = firstName.Substring(0, 15);
                    }
                    if (middleName.Length > 5)
                    {
                        middleName = middleName.Substring(0, 5);
                    }
                    if (lastName.Length > 18)
                    {
                        lastName = lastName.Substring(0, 18);
                    }
                    contact.Name = firstName + " " + middleName + " " + lastName;

                    CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "FirstName", firstName));
                    CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "MiddleName", middleName));
                    CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "LastName", lastName));
                }
                else if (namePieces.Count() == 1)
                {
                    firstName = namePieces[0];

                    if (firstName.Length > 15)
                    {
                        firstName = firstName.Substring(0, 15);
                    }
                    contact.Name = firstName;

                    CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "FirstName", firstName));
                }
            }

            XmlElement BillAddress = doc.CreateElement("BillAddress");

            CustomerAddOrMod.AppendChild(BillAddress);

            BillAddress.AppendChild(XmlUtils.MakeSimpleElem(doc, "Addr1", customer.Address.Address1));
            BillAddress.AppendChild(XmlUtils.MakeSimpleElem(doc, "Addr2", customer.Address.Address2));
            BillAddress.AppendChild(XmlUtils.MakeSimpleElem(doc, "Addr3", customer.Address.Address3));
            BillAddress.AppendChild(XmlUtils.MakeSimpleElem(doc, "Addr4", customer.Address.Address4));
            BillAddress.AppendChild(XmlUtils.MakeSimpleElem(doc, "Addr5", customer.Address.Address5));
            BillAddress.AppendChild(XmlUtils.MakeSimpleElem(doc, "City", customer.Address.City));
            BillAddress.AppendChild(XmlUtils.MakeSimpleElem(doc, "State", customer.Address.State));
            BillAddress.AppendChild(XmlUtils.MakeSimpleElem(doc, "PostalCode", customer.Address.Zip));

            if (contact != null)
            {
                if (contact.Name.Length > 40)
                {
                    contact.Name = contact.Name.Substring(0, 40);
                }
                CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "Contact", contact.Name));

                if (contact.Phone != null && contact.Phone != "")
                {
                    XmlElement AdditionalContactRef1 = doc.CreateElement("AdditionalContactRef");
                    CustomerAddOrMod.AppendChild(AdditionalContactRef1);
                    AdditionalContactRef1.AppendChild(XmlUtils.MakeSimpleElem(doc, "ContactName", "Main Phone"));
                    AdditionalContactRef1.AppendChild(XmlUtils.MakeSimpleElem(doc, "ContactValue", contact.Phone));
                }

                if (contact.Email != null && contact.Email != "")
                {
                    XmlElement AdditionalContactRef2 = doc.CreateElement("AdditionalContactRef");
                    CustomerAddOrMod.AppendChild(AdditionalContactRef2);
                    AdditionalContactRef2.AppendChild(XmlUtils.MakeSimpleElem(doc, "ContactName", "Main Email"));
                    AdditionalContactRef2.AppendChild(XmlUtils.MakeSimpleElem(doc, "ContactValue", contact.Email));
                }
            }

            XmlElement CustomerTypeRef = doc.CreateElement("CustomerTypeRef");

            CustomerAddOrMod.AppendChild(CustomerTypeRef);
            CustomerTypeRef.AppendChild(XmlUtils.MakeSimpleElem(doc, "ListID", bi.QBListId));

            switch (wo.JobStatus)
            {
            case JobStatus.Awarded:
                CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "JobStatus", "Awarded"));
                break;

            case JobStatus.Complete:
                CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "JobStatus", "Closed"));
                break;

            case JobStatus.InProgress:
                CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "JobStatus", "InProgress"));
                break;

            case JobStatus.NotApplicable:
                CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "JobStatus", "None"));
                break;

            case JobStatus.NotAwarded:
                CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "JobStatus", "NotAwarded"));
                break;

            case JobStatus.Pending:
                CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "JobStatus", "Pending"));
                break;

            default:
                break;
            }

            CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "JobStartDate", wo.EstStartDate.ToString("yyyy-MM-dd")));
            CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "JobProjectedEndDate", wo.EstEndDate.ToString("yyyy-MM-dd")));
            if (wo.ActualEndDate != DateTime.Parse("1900-01-01 00:00:00.000"))
            {
                CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "JobEndDate", wo.ActualEndDate.ToString("yyyy-MM-dd")));
            }

            if (wo.JobDescription != null)
            {
                CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "JobDesc", wo.JobDescription));
            }
            if (jt != null)
            {
                XmlElement JobTypeRef = doc.CreateElement("JobTypeRef");
                CustomerAddOrMod.AppendChild(JobTypeRef);
                JobTypeRef.AppendChild(XmlUtils.MakeSimpleElem(doc, "ListID", jt.QBListId));
            }
            if (wo.BillingNotes != null)
            {
                CustomerAddOrMod.AppendChild(XmlUtils.MakeSimpleElem(doc, "Notes", wo.BillingNotes));
            }

            return(doc);
        }
Example #47
0
 private static void RemoveExistingLineItems(RotoTrackDb db, string TxnID)
 {
     List<BillLine> blList = db.BillLines.Where(f => f.BillTxnId == TxnID).ToList();
     foreach (BillLine bl in blList.ToList())
     {
         db.BillLines.Remove(bl);
     }
     db.SaveChanges();
 }
        public static XmlDocument BuildAddRq(ServiceEntry se, ServiceDetail sd)
        {
            try
            {
                XmlDocument doc    = XmlUtils.MakeRequestDocument();
                XmlElement  parent = XmlUtils.MakeRequestParentElement(doc);

                RotoTrackDb db  = new RotoTrackDb();
                UserProfile u   = db.UserProfiles.Find(sd.TechnicianId);
                Vehicle     v   = db.Vehicles.Find(sd.VehicleId);
                DSR         dsr = db.DSRs.Include("WorkOrder").First(f => f.Id == se.DSRId);
                Customer    c   = db.Customers.Find(dsr.WorkOrder.CustomerId);
                MileageRate mr  = db.MileageRates.Find(sd.MileageRateId);
                Area        a   = db.Areas.Find(u.AreaId);

                XmlElement Rq = doc.CreateElement("VehicleMileageAddRq");
                parent.AppendChild(Rq);

                XmlElement RqType = doc.CreateElement("VehicleMileageAdd");
                Rq.AppendChild(RqType);

                XmlElement VehicleRef = doc.CreateElement("VehicleRef");
                RqType.AppendChild(VehicleRef);
                VehicleRef.AppendChild(XmlUtils.MakeSimpleElem(doc, "ListID", v.QBListId));

                XmlElement CustomerRef = doc.CreateElement("CustomerRef");
                RqType.AppendChild(CustomerRef);
                CustomerRef.AppendChild(XmlUtils.MakeSimpleElem(doc, "ListID", dsr.WorkOrder.QBListId));

                XmlElement ItemRef = doc.CreateElement("ItemRef");
                RqType.AppendChild(ItemRef);
                ItemRef.AppendChild(XmlUtils.MakeSimpleElem(doc, "ListID", mr.QBListId));

                XmlElement ClassRef = doc.CreateElement("ClassRef");
                RqType.AppendChild(ClassRef);
                ClassRef.AppendChild(XmlUtils.MakeSimpleElem(doc, "ListID", a.QBListId));

                RqType.AppendChild(XmlUtils.MakeSimpleElem(doc, "TripStartDate", se.DateWorked.ToString("yyyy-MM-dd")));
                RqType.AppendChild(XmlUtils.MakeSimpleElem(doc, "TripEndDate", se.DateWorked.ToString("yyyy-MM-dd")));
                RqType.AppendChild(XmlUtils.MakeSimpleElem(doc, "TotalMiles", se.Mileage.ToString()));
                string fullName = "";
                if (!string.IsNullOrEmpty(u.FirstName))
                {
                    fullName += u.FirstName;
                }
                if (!string.IsNullOrEmpty(u.LastName))
                {
                    fullName += (" " + u.LastName);
                }
                fullName += " guid=";
                fullName += se.GUID;
                RqType.AppendChild(XmlUtils.MakeSimpleElem(doc, "Notes", fullName));
                RqType.AppendChild(XmlUtils.MakeSimpleElem(doc, "BillableStatus", "Billable"));

                return(doc);
            }
            catch (Exception e)
            {
                string evLogTxt = "";
                evLogTxt = "Error building vehicle mileage add request! " + e.Message + "\r\n";
                Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + evLogTxt);
                return(null);
            }
        }
        private static void WalkVehicleMileageRetForQuery(XmlNode VehicleMileageRet)
        {
            if (VehicleMileageRet == null) return;

            string TxnID = VehicleMileageRet.SelectSingleNode("./TxnID").InnerText;
            string TimeCreated = VehicleMileageRet.SelectSingleNode("./TimeCreated").InnerText;
            string TimeModified = VehicleMileageRet.SelectSingleNode("./TimeCreated").InnerText;
            string TripStartDate = "";
            if (VehicleMileageRet.SelectSingleNode("./TripStartDate") != null)
            {
                TripStartDate = VehicleMileageRet.SelectSingleNode("./TripStartDate").InnerText;
            }
            string EditSequence = VehicleMileageRet.SelectSingleNode("./EditSequence").InnerText;

            string VehicleRefListID = "";
            XmlNode VehicleRef = VehicleMileageRet.SelectSingleNode("./VehicleRef");
            if (VehicleRef != null)
            {
                if (VehicleMileageRet.SelectSingleNode("./VehicleRef/ListID") != null)
                {
                    VehicleRefListID = VehicleMileageRet.SelectSingleNode("./VehicleRef/ListID").InnerText;
                }
            }

            string WorkOrderListID = "";
            XmlNode CustomerRef = VehicleMileageRet.SelectSingleNode("./CustomerRef");
            if (CustomerRef != null)
            {
                if (VehicleMileageRet.SelectSingleNode("./CustomerRef/ListID") != null)
                {
                    WorkOrderListID = VehicleMileageRet.SelectSingleNode("./CustomerRef/ListID").InnerText;
                }
            }

            string ItemRefListID = "";
            XmlNode ItemRef = VehicleMileageRet.SelectSingleNode("./ItemRef");
            if (ItemRef != null)
            {
                if (VehicleMileageRet.SelectSingleNode("./ItemRef/ListID") != null)
                {
                    ItemRefListID = VehicleMileageRet.SelectSingleNode("./ItemRef/ListID").InnerText;
                }
            }

            string AreaListID = "";
            XmlNode ClassRef = VehicleMileageRet.SelectSingleNode("./ClassRef");
            if (ClassRef != null)
            {
                if (VehicleMileageRet.SelectSingleNode("./ClassRef/ListID") != null)
                {
                    AreaListID = VehicleMileageRet.SelectSingleNode("./ClassRef/ListID").InnerText;
                }
            }

            string TotalMiles = "";
            if (VehicleMileageRet.SelectSingleNode("./TotalMiles") != null)
            {
                TotalMiles = VehicleMileageRet.SelectSingleNode("./TotalMiles").InnerText;
            }

            string Notes = "";
            if (VehicleMileageRet.SelectSingleNode("./Notes") != null)
            {
                Notes = VehicleMileageRet.SelectSingleNode("./Notes").InnerText;
            }

            string BillableStatus = "";
            if (VehicleMileageRet.SelectSingleNode("./BillableStatus") != null)
            {
                BillableStatus = VehicleMileageRet.SelectSingleNode("./BillableStatus").InnerText;
            }

            string BillableRate = "";
            if (VehicleMileageRet.SelectSingleNode("./BillableRate") != null)
            {
                BillableRate = VehicleMileageRet.SelectSingleNode("./BillableRate").InnerText;
            }

            string BillableAmount = "";
            if (VehicleMileageRet.SelectSingleNode("./BillableAmount") != null)
            {
                BillableAmount = VehicleMileageRet.SelectSingleNode("./BillableAmount").InnerText;
            }

            RotoTrackDb db = new RotoTrackDb();

            MileageTracking mt = null;
            if (db.MileageTrackings.Any(j => j.QBTxnId == TxnID))
            {
                mt = db.MileageTrackings.First(j => j.QBTxnId == TxnID);
            }
            else
            {
                mt = new MileageTracking();
                db.MileageTrackings.Add(mt);
            }

            mt.QBTxnId = TxnID;
            DateTime created, modified, tripstartdate;
            if (DateTime.TryParse(TimeCreated, out created))
            {
                mt.Created = created;
            }
            if (DateTime.TryParse(TimeModified, out modified))
            {
                mt.Modified = modified;
            }
            mt.TripStartDate = DateTime.MinValue;
            if (DateTime.TryParse(TripStartDate, out tripstartdate))
            {
                mt.TripStartDate = tripstartdate;
            }

            mt.QBEditSequence = EditSequence;
            mt.QBVehicleListID = VehicleRefListID;
            mt.QBWorkOrderListID = WorkOrderListID;
            mt.QBMileageRateListID = ItemRefListID;
            mt.QBAreaListID = AreaListID;

            decimal totalMiles;
            if (Decimal.TryParse(TotalMiles, out totalMiles))
            {
                mt.TotalMiles = totalMiles;
            }

            mt.Notes = Notes;
            mt.BillableStatus = BillableStatus;

            decimal billableRate, billableAmount;
            if (Decimal.TryParse(BillableRate, out billableRate))
            {
                mt.BillableRate = billableRate;
            }
            if (Decimal.TryParse(BillableAmount, out billableAmount))
            {
                mt.BillableAmount = billableAmount;
            }

            db.SaveChanges();
        }
Example #50
0
        private int GetNumUnsyncedWorkOrders()
        {
            RotoTrackDb db = new RotoTrackDb();

            int count = 0;
            var workorders = db.Database.SqlQuery<int>("select ID from WorkOrders where NeedToUpdateQB=1").ToList();
            count += workorders.Count();

            workorders = db.Database.SqlQuery<int>("select ID from WorkOrders where QBListId is null").ToList();
            count += workorders.Count();

            return count;
        }
        private static void WalkCustomerTypeRetForAdd(XmlNode CustomerTypeRet)
        {
            // Update the QBListID for the newly added BillingInstruction
            if (CustomerTypeRet == null) return;

            BillingInstruction bi = null;
            RotoTrackDb db = new RotoTrackDb();

            string ListID = CustomerTypeRet.SelectSingleNode("./ListID").InnerText;
            string Name = CustomerTypeRet.SelectSingleNode("./Name").InnerText;

            if (db.BillingInstructions.Any(f => f.Name == Name))
            {
                bi = db.BillingInstructions.First(f => f.Name == Name);
            }
            bi.QBListId = ListID;

            if (bi != null)
            {
                db.SaveChanges();
            }
        }
Example #52
0
        private void RemoveDSRTimeAndMileage()
        {
            AppendStatus("Removing Deleted DSR Time and Mileage...");

            RotoTrackDb db = new RotoTrackDb();

            List<DeletedTimeTracking> deletedTimeList = db.DeletedTimeTrackings.Where(f => f.IsSynchronizedWithQB == false).ToList();
            foreach (DeletedTimeTracking deletedTime in deletedTimeList)
            {
                if (RemoveTimeTracking(deletedTime.Id))
                {
                    deletedTime.IsSynchronizedWithQB = true;
                    db.Entry(deletedTime).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }

            List<DeletedMileageTracking> deletedMileageList = db.DeletedMileageTrackings.Where(f => f.IsSynchronizedWithQB == false).ToList();
            foreach (DeletedMileageTracking deletedMileage in deletedMileageList)
            {
                if (RemoveVehicleMileage(deletedMileage.Id))
                {
                    deletedMileage.IsSynchronizedWithQB = true;
                    db.Entry(deletedMileage).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }

            // Due to buggy time and  mileage handling in QB, remove any deleted time or mileage trackings that still exist.
            db.Database.ExecuteSqlCommand("delete from MileageTrackings where QBTxnId in (select QBTxnId from DeletedMileageTrackings)");
            db.Database.ExecuteSqlCommand("delete from TimeTrackings where QBTxnId in (select QBTxnId from DeletedTimeTrackings)");

            AppendStatus("Done");
            AppendStatus(Environment.NewLine);
        }
Example #53
0
 private static void RemoveExistingLineItems(RotoTrackDb db, string TxnID)
 {
     List<SalesOrderLine> solList = db.SalesOrderLines.Where(f => f.SalesOrderTxnId == TxnID).ToList();
     foreach (SalesOrderLine sol in solList.ToList())
     {
         db.SalesOrderLines.Remove(sol);
     }
     db.SaveChanges();
 }
Example #54
0
        private bool RemoveTimeTracking(int ttID)
        {
            RotoTrackDb db = new RotoTrackDb();
            DeletedTimeTracking tt = db.DeletedTimeTrackings.Find(ttID);

            XmlDocument doc = TimeTrackingDAL.BuildRemoveRq(tt.QBTxnId);
            string response = QBUtils.DoRequest(doc);
            return TimeTrackingDAL.HandleRemoveResponse(response);
        }
Example #55
0
        private static SalesOrderLine FindOrCreateSalesOrderLine(RotoTrackDb db, string TxnLineID, string TxnID, string TimeCreated, string TimeModified, string EditSequence, string TxnDate, string AmountDue, string IsManuallyClosed, string IsFullyInvoiced)
        {
            SalesOrderLine sol = null;
            if (db.SalesOrderLines.Any(f => f.TxnLineId == TxnLineID))
            {
                sol = db.SalesOrderLines.First(f => f.TxnLineId == TxnLineID);
            }
            else
            {
                sol = new SalesOrderLine();
                db.SalesOrderLines.Add(sol);
            }

            sol.TxnLineId = TxnLineID;
            sol.SalesOrderTxnId = TxnID;
            DateTime createdDate;
            if (DateTime.TryParse(TimeCreated, out createdDate)) sol.SalesOrderCreated = createdDate;
            DateTime modifiedDate;
            if (DateTime.TryParse(TimeModified, out modifiedDate)) sol.SalesOrderModified = modifiedDate;
            sol.SalesOrderEditSequence = EditSequence;
            DateTime txnDate;
            if (DateTime.TryParse(TxnDate, out txnDate)) sol.SalesOrderTxnDate = txnDate;
            decimal amountDue;
            if (Decimal.TryParse(AmountDue, out amountDue)) sol.SalesOrderTotalAmount = amountDue;

            bool isManuallyClosed;
            if (bool.TryParse(IsManuallyClosed, out isManuallyClosed))
            {
                sol.SalesOrderIsManuallyClosed = isManuallyClosed;
            }
            bool isFullyInvoiced;
            if (bool.TryParse(IsFullyInvoiced, out isFullyInvoiced))
            {
                sol.SalesOrderIsFullyInvoiced = isFullyInvoiced;
            }

            return sol;
        }
Example #56
0
        private bool RemoveVehicleMileage(int mtID)
        {
            RotoTrackDb db = new RotoTrackDb();
            DeletedMileageTracking mt = db.DeletedMileageTrackings.Find(mtID);

            XmlDocument doc = VehicleMileageDAL.BuildRemoveRq(mt.QBTxnId);
            string response = QBUtils.DoRequest(doc);
            return VehicleMileageDAL.HandleRemoveResponse(response);
        }
Example #57
0
        private static void WalkBillRetForQuery(XmlNode BillRet)
        {
            if (BillRet == null) return;

            RotoTrackDb db = new RotoTrackDb();

            //Go through all the elements of BillRet
            //Get value of TxnID
            string TxnID = BillRet.SelectSingleNode("./TxnID").InnerText;

            // New or modified objects will return all current line items, so remove any existing ones first and then recreate them.
            RemoveExistingLineItems(db, TxnID);

            //Get value of TimeCreated
            string TimeCreated = BillRet.SelectSingleNode("./TimeCreated").InnerText;
            //Get value of TimeModified
            string TimeModified = BillRet.SelectSingleNode("./TimeModified").InnerText;
            //Get value of EditSequence
            string EditSequence = BillRet.SelectSingleNode("./EditSequence").InnerText;
            //Get value of TxnNumber
            if (BillRet.SelectSingleNode("./TxnNumber") != null)
            {
                string TxnNumber = BillRet.SelectSingleNode("./TxnNumber").InnerText;
            }

            //Get all field values for APAccountRef aggregate
            XmlNode APAccountRef = BillRet.SelectSingleNode("./APAccountRef");
            if (APAccountRef != null)
            {
                //Get value of ListID
                if (BillRet.SelectSingleNode("./APAccountRef/ListID") != null)
                {
                    string ListID = BillRet.SelectSingleNode("./APAccountRef/ListID").InnerText;
                }
                //Get value of FullName
                if (BillRet.SelectSingleNode("./APAccountRef/FullName") != null)
                {
                    string FullName = BillRet.SelectSingleNode("./APAccountRef/FullName").InnerText;
                }
            }
            //Done with field values for APAccountRef aggregate

            //Get value of TxnDate
            string TxnDate = BillRet.SelectSingleNode("./TxnDate").InnerText;
            //Get value of DueDate
            if (BillRet.SelectSingleNode("./DueDate") != null)
            {
                string DueDate = BillRet.SelectSingleNode("./DueDate").InnerText;
            }

            //Get value of AmountDue
            string AmountDue = "";
            if (BillRet.SelectSingleNode("./AmountDue") != null)
            {
                AmountDue = BillRet.SelectSingleNode("./AmountDue").InnerText;
            }

            //Get all field values for CurrencyRef aggregate
            XmlNode CurrencyRef = BillRet.SelectSingleNode("./CurrencyRef");
            if (CurrencyRef != null)
            {
                //Get value of ListID
                if (BillRet.SelectSingleNode("./CurrencyRef/ListID") != null)
                {
                    string ListID = BillRet.SelectSingleNode("./CurrencyRef/ListID").InnerText;
                }
                //Get value of FullName
                if (BillRet.SelectSingleNode("./CurrencyRef/FullName") != null)
                {
                    string FullName = BillRet.SelectSingleNode("./CurrencyRef/FullName").InnerText;
                }
            }
            //Done with field values for CurrencyRef aggregate

            //Get all field values for VendorRef aggregate
            //Get value of ListID
            string VendorListID = "";
            if (BillRet.SelectSingleNode("./VendorRef/ListID") != null)
            {
                VendorListID = BillRet.SelectSingleNode("./VendorRef/ListID").InnerText;
            }
            //Get value of FullName
            if (BillRet.SelectSingleNode("./VendorRef/FullName") != null)
            {
                string FullName = BillRet.SelectSingleNode("./VendorRef/FullName").InnerText;
            }
            //Done with field values for VendorRef aggregate

            //Get value of ExchangeRate
            if (BillRet.SelectSingleNode("./ExchangeRate") != null)
            {
                string ExchangeRate = BillRet.SelectSingleNode("./ExchangeRate").InnerText;
            }
            //Get value of AmountDueInHomeCurrency
            if (BillRet.SelectSingleNode("./AmountDueInHomeCurrency") != null)
            {
                string AmountDueInHomeCurrency = BillRet.SelectSingleNode("./AmountDueInHomeCurrency").InnerText;
            }
            //Get value of RefNumber
            if (BillRet.SelectSingleNode("./RefNumber") != null)
            {
                string RefNumber = BillRet.SelectSingleNode("./RefNumber").InnerText;
            }
            //Get all field values for TermsRef aggregate
            XmlNode TermsRef = BillRet.SelectSingleNode("./TermsRef");
            if (TermsRef != null)
            {
                //Get value of ListID
                if (BillRet.SelectSingleNode("./TermsRef/ListID") != null)
                {
                    string ListID = BillRet.SelectSingleNode("./TermsRef/ListID").InnerText;
                }
                //Get value of FullName
                if (BillRet.SelectSingleNode("./TermsRef/FullName") != null)
                {
                    string FullName = BillRet.SelectSingleNode("./TermsRef/FullName").InnerText;
                }
            }
            //Done with field values for TermsRef aggregate

            //Get value of Memo
            if (BillRet.SelectSingleNode("./Memo") != null)
            {
                string Memo = BillRet.SelectSingleNode("./Memo").InnerText;
            }
            //Get value of IsPaid
            if (BillRet.SelectSingleNode("./IsPaid") != null)
            {
                string IsPaid = BillRet.SelectSingleNode("./IsPaid").InnerText;
            }
            //Get value of ExternalGUID
            if (BillRet.SelectSingleNode("./ExternalGUID") != null)
            {
                string ExternalGUID = BillRet.SelectSingleNode("./ExternalGUID").InnerText;
            }

            //Walk list of ExpenseLineRet aggregates
            XmlNodeList ExpenseLineRetList = BillRet.SelectNodes("./ExpenseLineRet");
            if (ExpenseLineRetList != null)
            {
                for (int i = 0; i < ExpenseLineRetList.Count; i++)
                {
                    XmlNode ExpenseLineRet = ExpenseLineRetList.Item(i);

                    //Get all field values for CustomerRef aggregate
                    string CustomerListID = "";
                    XmlNode CustomerRef = ExpenseLineRet.SelectSingleNode("./CustomerRef");
                    if (CustomerRef != null)
                    {
                        //Get value of ListID
                        if (ExpenseLineRet.SelectSingleNode("./CustomerRef/ListID") != null)
                        {
                            CustomerListID = ExpenseLineRet.SelectSingleNode("./CustomerRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (ExpenseLineRet.SelectSingleNode("./CustomerRef/FullName") != null)
                        {
                            string FullName = ExpenseLineRet.SelectSingleNode("./CustomerRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for CustomerRef aggregate

                    // Skip the rest of this iteration if no CustomerListID (associated work order)
                    if (CustomerListID == "") continue;

                    //Get value of TxnLineID
                    string TxnLineID = ExpenseLineRet.SelectSingleNode("./TxnLineID").InnerText;

                    // Find existing or create new BillLine entry
                    BillLine bl = FindOrCreateBillLine(db, TxnLineID, TxnID, TimeCreated, TimeModified, EditSequence, TxnDate, AmountDue);
                    bl.WorkOrderListID = CustomerListID;
                    bl.VendorListID = VendorListID;

                    string Description = "";

                    //Get all field values for AccountRef aggregate
                    XmlNode AccountRef = ExpenseLineRet.SelectSingleNode("./AccountRef");
                    if (AccountRef != null)
                    {
                        //Get value of ListID
                        if (ExpenseLineRet.SelectSingleNode("./AccountRef/ListID") != null)
                        {
                            string ListID = ExpenseLineRet.SelectSingleNode("./AccountRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (ExpenseLineRet.SelectSingleNode("./AccountRef/FullName") != null)
                        {
                            string FullName = ExpenseLineRet.SelectSingleNode("./AccountRef/FullName").InnerText;
                            Description = FullName + " - ";
                        }
                    }
                    //Done with field values for AccountRef aggregate

                    //Get value of Memo
                    if (ExpenseLineRet.SelectSingleNode("./Memo") != null)
                    {
                        string Memo = ExpenseLineRet.SelectSingleNode("./Memo").InnerText;
                        Description += Memo;
                    }
                    bl.Description = Description;

                    //Get value of Amount
                    if (ExpenseLineRet.SelectSingleNode("./Amount") != null)
                    {
                        string Amount = ExpenseLineRet.SelectSingleNode("./Amount").InnerText;
                        decimal amount;
                        if (Decimal.TryParse(Amount, out amount))
                        {
                            bl.Amount = amount;
                            bl.UnitCost = amount;
                            bl.Quantity = 1.0M;
                        }
                    }

                    //Get all field values for ClassRef aggregate
                    XmlNode ClassRef = ExpenseLineRet.SelectSingleNode("./ClassRef");
                    if (ClassRef != null)
                    {
                        //Get value of ListID
                        if (ExpenseLineRet.SelectSingleNode("./ClassRef/ListID") != null)
                        {
                            string ListID = ExpenseLineRet.SelectSingleNode("./ClassRef/ListID").InnerText;
                            bl.AreaListID = ListID;
                        }
                        //Get value of FullName
                        if (ExpenseLineRet.SelectSingleNode("./ClassRef/FullName") != null)
                        {
                            string FullName = ExpenseLineRet.SelectSingleNode("./ClassRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for ClassRef aggregate

                    //Get value of BillableStatus
                    if (ExpenseLineRet.SelectSingleNode("./BillableStatus") != null)
                    {
                        string BillableStatus = ExpenseLineRet.SelectSingleNode("./BillableStatus").InnerText;
                        bl.BillableStatus = BillableStatus;
                    }

                    db.SaveChanges();
                }
            }

            XmlNodeList ORItemLineRetListChildren = BillRet.SelectNodes("./*");
            for (int i = 0; i < ORItemLineRetListChildren.Count; i++)
            {
                XmlNode Child = ORItemLineRetListChildren.Item(i);
                if (Child.Name == "ItemLineRet")
                {
                    //Get all field values for CustomerRef aggregate
                    string CustomerListID = "";
                    XmlNode CustomerRef = Child.SelectSingleNode("./CustomerRef");
                    if (CustomerRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./CustomerRef/ListID") != null)
                        {
                            CustomerListID = Child.SelectSingleNode("./CustomerRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./CustomerRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./CustomerRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for CustomerRef aggregate

                    // Skip this entity if no associated customer (work order)
                    if (CustomerListID == "") continue;

                    //Get value of TxnLineID
                    string TxnLineID = Child.SelectSingleNode("./TxnLineID").InnerText;

                    // Find existing or create new BillLine entry
                    BillLine bl = FindOrCreateBillLine(db, TxnLineID, TxnID, TimeCreated, TimeModified, EditSequence, TxnDate, AmountDue);
                    bl.WorkOrderListID = CustomerListID;
                    bl.VendorListID = VendorListID;

                    //Get all field values for ItemRef aggregate
                    XmlNode ItemRef = Child.SelectSingleNode("./ItemRef");
                    if (ItemRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./ItemRef/ListID") != null)
                        {
                            string ListID = Child.SelectSingleNode("./ItemRef/ListID").InnerText;
                            bl.ItemListID = ListID;
                        }
                    }
                    //Done with field values for ItemRef aggregate

                    //Get all field values for InventorySiteRef aggregate
                    XmlNode InventorySiteRef = Child.SelectSingleNode("./InventorySiteRef");
                    if (InventorySiteRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./InventorySiteRef/ListID") != null)
                        {
                            string ListID = Child.SelectSingleNode("./InventorySiteRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./InventorySiteRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./InventorySiteRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for InventorySiteRef aggregate

                    //Get all field values for InventorySiteLocationRef aggregate
                    XmlNode InventorySiteLocationRef = Child.SelectSingleNode("./InventorySiteLocationRef");
                    if (InventorySiteLocationRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./InventorySiteLocationRef/ListID") != null)
                        {
                            string ListID = Child.SelectSingleNode("./InventorySiteLocationRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./InventorySiteLocationRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./InventorySiteLocationRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for InventorySiteLocationRef aggregate

                    //Get value of Desc
                    if (Child.SelectSingleNode("./Desc") != null)
                    {
                        string Desc = Child.SelectSingleNode("./Desc").InnerText;
                        bl.Description = Desc;
                    }
                    //Get value of Quantity
                    if (Child.SelectSingleNode("./Quantity") != null)
                    {
                        string Quantity = Child.SelectSingleNode("./Quantity").InnerText;
                        decimal quantity;
                        if (Decimal.TryParse(Quantity, out quantity))
                        {
                            bl.Quantity = quantity;
                        }
                    }
                    //Get value of UnitOfMeasure
                    if (Child.SelectSingleNode("./UnitOfMeasure") != null)
                    {
                        string UnitOfMeasure = Child.SelectSingleNode("./UnitOfMeasure").InnerText;
                    }
                    //Get all field values for OverrideUOMSetRef aggregate
                    XmlNode OverrideUOMSetRef = Child.SelectSingleNode("./OverrideUOMSetRef");
                    if (OverrideUOMSetRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./OverrideUOMSetRef/ListID") != null)
                        {
                            string ListID = Child.SelectSingleNode("./OverrideUOMSetRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./OverrideUOMSetRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./OverrideUOMSetRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for OverrideUOMSetRef aggregate

                    //Get value of Cost
                    if (Child.SelectSingleNode("./Cost") != null)
                    {
                        string Cost = Child.SelectSingleNode("./Cost").InnerText;
                        decimal unitCost;
                        if (Decimal.TryParse(Cost, out unitCost))
                        {
                            bl.UnitCost = unitCost;
                        }
                    }
                    //Get value of Amount
                    if (Child.SelectSingleNode("./Amount") != null)
                    {
                        string Amount = Child.SelectSingleNode("./Amount").InnerText;
                        decimal amount;
                        if (Decimal.TryParse(Amount, out amount))
                        {
                            bl.Amount = amount;
                        }
                    }

                    //Get all field values for ClassRef aggregate
                    XmlNode ClassRef = Child.SelectSingleNode("./ClassRef");
                    if (ClassRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./ClassRef/ListID") != null)
                        {
                            string ListID = Child.SelectSingleNode("./ClassRef/ListID").InnerText;
                            bl.AreaListID = ListID;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./ClassRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./ClassRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for ClassRef aggregate

                    //Get value of BillableStatus
                    if (Child.SelectSingleNode("./BillableStatus") != null)
                    {
                        string BillableStatus = Child.SelectSingleNode("./BillableStatus").InnerText;
                        bl.BillableStatus = BillableStatus;
                    }

                    db.SaveChanges();
                }

                if (Child.Name == "ItemGroupLineRet")
                {
                    //Get value of TxnLineID
                    string TxnLineID = Child.SelectSingleNode("./TxnLineID").InnerText;

                    //Get all field values for ItemGroupRef aggregate
                    //Get value of ListID
                    if (Child.SelectSingleNode("./ItemGroupRef/ListID") != null)
                    {
                        string ListID = Child.SelectSingleNode("./ItemGroupRef/ListID").InnerText;
                    }
                    //Get value of FullName
                    if (Child.SelectSingleNode("./ItemGroupRef/FullName") != null)
                    {
                        string FullName = Child.SelectSingleNode("./ItemGroupRef/FullName").InnerText;
                    }
                    //Done with field values for ItemGroupRef aggregate

                    //Get value of Desc
                    if (Child.SelectSingleNode("./Desc") != null)
                    {
                        string Desc = Child.SelectSingleNode("./Desc").InnerText;
                    }
                    //Get value of Quantity
                    if (Child.SelectSingleNode("./Quantity") != null)
                    {
                        string Quantity = Child.SelectSingleNode("./Quantity").InnerText;
                    }
                    //Get value of UnitOfMeasure
                    if (Child.SelectSingleNode("./UnitOfMeasure") != null)
                    {
                        string UnitOfMeasure = Child.SelectSingleNode("./UnitOfMeasure").InnerText;
                    }
                    //Get all field values for OverrideUOMSetRef aggregate
                    XmlNode OverrideUOMSetRef = Child.SelectSingleNode("./OverrideUOMSetRef");
                    if (OverrideUOMSetRef != null)
                    {
                        //Get value of ListID
                        if (Child.SelectSingleNode("./OverrideUOMSetRef/ListID") != null)
                        {
                            string ListID = Child.SelectSingleNode("./OverrideUOMSetRef/ListID").InnerText;
                        }
                        //Get value of FullName
                        if (Child.SelectSingleNode("./OverrideUOMSetRef/FullName") != null)
                        {
                            string FullName = Child.SelectSingleNode("./OverrideUOMSetRef/FullName").InnerText;
                        }
                    }
                    //Done with field values for OverrideUOMSetRef aggregate

                    //Get value of TotalAmount
                    string TotalAmount = Child.SelectSingleNode("./TotalAmount").InnerText;
                    //Walk list of ItemLineRet aggregates
                    XmlNodeList ItemLineRetList = Child.SelectNodes("./ItemLineRet");
                    if (ItemLineRetList != null)
                    {
                        for (int j = 0; j < ItemLineRetList.Count; j++)
                        {
                            XmlNode ItemLineRet = ItemLineRetList.Item(j);

                            //Get all field values for CustomerRef aggregate
                            string CustomerListID = "";
                            XmlNode CustomerRef = ItemLineRet.SelectSingleNode("./CustomerRef");
                            if (CustomerRef != null)
                            {
                                //Get value of ListID
                                if (ItemLineRet.SelectSingleNode("./CustomerRef/ListID") != null)
                                {
                                    CustomerListID = ItemLineRet.SelectSingleNode("./CustomerRef/ListID").InnerText;
                                }
                                //Get value of FullName
                                if (ItemLineRet.SelectSingleNode("./CustomerRef/FullName") != null)
                                {
                                    string FullName = ItemLineRet.SelectSingleNode("./CustomerRef/FullName").InnerText;
                                }
                            }
                            //Done with field values for CustomerRef aggregate

                            // Skip the rest if no associated customer (work order)
                            if (CustomerListID == "") continue;

                            //Get value of TxnLineID
                            string TxnLineID2 = ItemLineRet.SelectSingleNode("./TxnLineID").InnerText;

                            // Find existing or create new BillLine entry
                            BillLine bl = FindOrCreateBillLine(db, TxnLineID2, TxnID, TimeCreated, TimeModified, EditSequence, TxnDate, AmountDue);
                            bl.WorkOrderListID = CustomerListID;
                            bl.VendorListID = VendorListID;

                            //Get all field values for ItemRef aggregate
                            XmlNode ItemRef = ItemLineRet.SelectSingleNode("./ItemRef");
                            if (ItemRef != null)
                            {
                                //Get value of ListID
                                if (ItemLineRet.SelectSingleNode("./ItemRef/ListID") != null)
                                {
                                    string ListID = ItemLineRet.SelectSingleNode("./ItemRef/ListID").InnerText;
                                    bl.ItemListID = ListID;
                                }
                                //Get value of FullName
                                if (ItemLineRet.SelectSingleNode("./ItemRef/FullName") != null)
                                {
                                    string FullName = ItemLineRet.SelectSingleNode("./ItemRef/FullName").InnerText;
                                }
                            }
                            //Done with field values for ItemRef aggregate

                            //Get all field values for InventorySiteRef aggregate
                            XmlNode InventorySiteRef = ItemLineRet.SelectSingleNode("./InventorySiteRef");
                            if (InventorySiteRef != null)
                            {
                                //Get value of ListID
                                if (ItemLineRet.SelectSingleNode("./InventorySiteRef/ListID") != null)
                                {
                                    string ListID = ItemLineRet.SelectSingleNode("./InventorySiteRef/ListID").InnerText;
                                }
                                //Get value of FullName
                                if (ItemLineRet.SelectSingleNode("./InventorySiteRef/FullName") != null)
                                {
                                    string FullName = ItemLineRet.SelectSingleNode("./InventorySiteRef/FullName").InnerText;
                                }
                            }
                            //Done with field values for InventorySiteRef aggregate

                            //Get all field values for InventorySiteLocationRef aggregate
                            XmlNode InventorySiteLocationRef = ItemLineRet.SelectSingleNode("./InventorySiteLocationRef");
                            if (InventorySiteLocationRef != null)
                            {
                                //Get value of ListID
                                if (ItemLineRet.SelectSingleNode("./InventorySiteLocationRef/ListID") != null)
                                {
                                    string ListID = ItemLineRet.SelectSingleNode("./InventorySiteLocationRef/ListID").InnerText;
                                }
                                //Get value of FullName
                                if (ItemLineRet.SelectSingleNode("./InventorySiteLocationRef/FullName") != null)
                                {
                                    string FullName = ItemLineRet.SelectSingleNode("./InventorySiteLocationRef/FullName").InnerText;
                                }
                            }
                            //Done with field values for InventorySiteLocationRef aggregate

                            //Get value of Desc
                            if (ItemLineRet.SelectSingleNode("./Desc") != null)
                            {
                                string Desc = ItemLineRet.SelectSingleNode("./Desc").InnerText;
                                bl.Description = Desc;
                            }
                            //Get value of Quantity
                            if (ItemLineRet.SelectSingleNode("./Quantity") != null)
                            {
                                string Quantity = ItemLineRet.SelectSingleNode("./Quantity").InnerText;
                                decimal quantity;
                                if (Decimal.TryParse(Quantity, out quantity))
                                {
                                    bl.Quantity = quantity;
                                }
                            }
                            //Get value of UnitOfMeasure
                            if (ItemLineRet.SelectSingleNode("./UnitOfMeasure") != null)
                            {
                                string UnitOfMeasure = ItemLineRet.SelectSingleNode("./UnitOfMeasure").InnerText;
                            }
                            //Get all field values for OverrideUOMSetRef aggregate
                            XmlNode OverrideUOMSetRef2 = ItemLineRet.SelectSingleNode("./OverrideUOMSetRef");
                            if (OverrideUOMSetRef2 != null)
                            {
                                //Get value of ListID
                                if (ItemLineRet.SelectSingleNode("./OverrideUOMSetRef/ListID") != null)
                                {
                                    string ListID = ItemLineRet.SelectSingleNode("./OverrideUOMSetRef/ListID").InnerText;
                                }
                                //Get value of FullName
                                if (ItemLineRet.SelectSingleNode("./OverrideUOMSetRef/FullName") != null)
                                {
                                    string FullName = ItemLineRet.SelectSingleNode("./OverrideUOMSetRef/FullName").InnerText;
                                }
                            }
                            //Done with field values for OverrideUOMSetRef aggregate

                            //Get value of Cost
                            if (ItemLineRet.SelectSingleNode("./Cost") != null)
                            {
                                string Cost = ItemLineRet.SelectSingleNode("./Cost").InnerText;
                                decimal cost;
                                if (Decimal.TryParse(Cost, out cost))
                                {
                                    bl.UnitCost = cost;
                                }
                            }
                            //Get value of Amount
                            if (ItemLineRet.SelectSingleNode("./Amount") != null)
                            {
                                string Amount = ItemLineRet.SelectSingleNode("./Amount").InnerText;
                                decimal amount;
                                if (Decimal.TryParse(Amount, out amount))
                                {
                                    bl.Amount = amount;
                                }
                            }

                            //Get all field values for ClassRef aggregate
                            XmlNode ClassRef = ItemLineRet.SelectSingleNode("./ClassRef");
                            if (ClassRef != null)
                            {
                                //Get value of ListID
                                if (ItemLineRet.SelectSingleNode("./ClassRef/ListID") != null)
                                {
                                    string ListID = ItemLineRet.SelectSingleNode("./ClassRef/ListID").InnerText;
                                    bl.AreaListID = ListID;
                                }
                                //Get value of FullName
                                if (ItemLineRet.SelectSingleNode("./ClassRef/FullName") != null)
                                {
                                    string FullName = ItemLineRet.SelectSingleNode("./ClassRef/FullName").InnerText;
                                }
                            }
                            //Done with field values for ClassRef aggregate

                            //Get value of BillableStatus
                            if (ItemLineRet.SelectSingleNode("./BillableStatus") != null)
                            {
                                string BillableStatus = ItemLineRet.SelectSingleNode("./BillableStatus").InnerText;
                                bl.BillableStatus = BillableStatus;
                            }

                            db.SaveChanges();
                        }
                    }
                }
            }
        }
Example #58
0
 private void SetRegularHoursToNA(int seID)
 {
     RotoTrackDb db = new RotoTrackDb();
     ServiceEntry se = db.ServiceEntries.Find(seID);
     se.QBListIdForRegularHours = "N/A";
     db.Entry(se).State = EntityState.Modified;
     db.SaveChanges();
 }
Example #59
0
        private static BillLine FindOrCreateBillLine(RotoTrackDb db, string TxnLineID, string TxnID, string TimeCreated, string TimeModified, string EditSequence, string TxnDate, string AmountDue)
        {
            BillLine bl = null;
            if (db.BillLines.Any(f => f.TxnLineId == TxnLineID))
            {
                bl = db.BillLines.First(f => f.TxnLineId == TxnLineID);
            }
            else
            {
                bl = new BillLine();
                db.BillLines.Add(bl);
            }

            bl.TxnLineId = TxnLineID;
            bl.BillTxnId = TxnID;
            DateTime createdDate;
            if (DateTime.TryParse(TimeCreated, out createdDate)) bl.BillCreated = createdDate;
            DateTime modifiedDate;
            if (DateTime.TryParse(TimeModified, out modifiedDate)) bl.BillModified = modifiedDate;
            bl.BillEditSequence = EditSequence;
            DateTime txnDate;
            if (DateTime.TryParse(TxnDate, out txnDate)) bl.BillTxnDate = txnDate;
            decimal amountDue;
            if (Decimal.TryParse(AmountDue, out amountDue)) bl.BillAmountDue = amountDue;

            return bl;
        }
Example #60
0
        private void SyncDSRs()
        {
            AppendStatus("Syncing DSRs...");

            RotoTrackDb db = new RotoTrackDb();

            int approvedVal = (int)DSRStatus.Approved;
            List<DSRLite> dsrList = db.DSRs.Where(f => f.IsSynchronizedWithQB == false && f.statusValue == approvedVal).Select(f => new DSRLite { Id = f.Id, WorkOrderId = f.WorkOrderId, WorkOrderGUID = f.WorkOrderGUID, Created = f.Created, Modified = f.Modified, DateWorked = f.DateWorked, TechnicianId = f.TechnicianId, IsSynchronizedWithQB = f.IsSynchronizedWithQB, statusValue = f.statusValue }).ToList();
            foreach (DSRLite dsr in dsrList)
            {
                List<ServiceEntry> serviceEntryList = db.ServiceEntries.Where(f => f.DSRId == dsr.Id).ToList();
                foreach (ServiceEntry se in serviceEntryList.ToList())
                {
                    ServiceDetail sd = db.ServiceDetails.Find(se.ServiceDetailId);
                    if (se.QBListIdForMileage == null)
                    {
                        if (se.Mileage == 0)
                        {
                            SetMileageToNA(se.Id);
                        }
                        else
                        {
                            AddVehicleMileage(se.Id, se.ServiceDetailId);
                        }
                    }
                    if (se.QBListIdForRegularHours == null)
                    {
                        if (se.RegularHours == 0)
                        {
                            SetRegularHoursToNA(se.Id);
                        }
                        else
                        {
                            AddTimeTracking(se.Id, se.ServiceDetailId, sd.ServiceTypeId, se.RegularHours);
                        }
                    }
                    if (se.QBListIdForOTHours == null)
                    {
                        if (se.OTHours == 0)
                        {
                            SetOTHoursToNA(se.Id);
                        }
                        else
                        {
                            AddTimeTracking(se.Id, se.ServiceDetailId, sd.OTServiceTypeId, se.OTHours);
                        }
                    }
                }

                // Update status of DSR
                DSR dsrToUpdate = db.DSRs.Find(dsr.Id);
                dsrToUpdate.IsSynchronizedWithQB = true;
                db.Entry(dsrToUpdate).State = EntityState.Modified;
                db.SaveChanges();

            }

            AppendStatus("Done");
            AppendStatus(Environment.NewLine);
        }