Esempio n. 1
0
        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();
                }
            }
        }
Esempio n. 2
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 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();
            }
        }
Esempio n. 4
0
 public static void SetLastSyncTime(DateTime lastSync)
 {
     RotoTrackDb db = new RotoTrackDb();
     Config config = db.Configs.First();
     if (config != null)
     {
         config.LastFullRefreshQB = lastSync;
         db.SaveChanges();
     }
 }
Esempio n. 5
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();
        }
Esempio n. 6
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();
        }
Esempio n. 7
0
        public static void SetLastSyncTime(DateTime lastSync)
        {
            RotoTrackDb db     = new RotoTrackDb();
            Config      config = db.Configs.First();

            if (config != null)
            {
                config.LastFullRefreshQB = lastSync;
                db.SaveChanges();
            }
        }
Esempio n. 8
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();
            }
        }
Esempio n. 9
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();
            }
        }
Esempio n. 10
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();
                }
            }
        }
Esempio n. 11
0
        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();
            }
        }
Esempio n. 12
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();
                }
            }
        }
Esempio n. 14
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();
            }
        }
Esempio n. 15
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();
 }
Esempio n. 16
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);
                    }
                }
            }
        }
Esempio n. 17
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);
        }
Esempio n. 18
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();
                }
            }
        }
Esempio n. 19
0
        private static void WalkCustomerRetForUpdate(XmlNode CustomerRet)
        {
            if (CustomerRet == null) return;

            RotoTrackDb db = new RotoTrackDb();

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

            if (db.WorkOrders.Any(f => f.QBListId == ListID))
            {
                WorkOrder wo = db.WorkOrders.First(f => f.QBListId == ListID);
                wo.QBEditSequence = EditSequence;
                db.Entry(wo).State = EntityState.Modified;
                if (wo != null)
                {
                    db.SaveChanges();
                }
            }
        }
Esempio n. 20
0
        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();
        }
Esempio n. 21
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();
            }
        }
Esempio n. 22
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);
        }
Esempio n. 23
0
        private static void WalkUnitOfMeasureSetRet(XmlNode UnitOfMeasureSetRet)
        {
            if (UnitOfMeasureSetRet == null)
            {
                return;
            }

            UnitOfMeasure uom = null;
            RotoTrackDb   db  = new RotoTrackDb();

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

            if (db.UnitOfMeasures.Any(f => f.QBListId == ListID))
            {
                uom = db.UnitOfMeasures.First(f => f.QBListId == ListID);
            }
            else
            {
                uom = new UnitOfMeasure();
                db.UnitOfMeasures.Add(uom);
            }
            uom.QBListId = ListID;

            string IsActive = "false";

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

            /*
             * //Go through all the elements of UnitOfMeasureSetRet
             * //Get value of ListID
             * if (UnitOfMeasureSetRet.SelectSingleNode("./ListID") != null)
             * {
             *  string ListID = UnitOfMeasureSetRet.SelectSingleNode("./ListID").InnerText;
             * }
             * //Get value of TimeCreated
             * if (UnitOfMeasureSetRet.SelectSingleNode("./TimeCreated") != null)
             * {
             *  string TimeCreated = UnitOfMeasureSetRet.SelectSingleNode("./TimeCreated").InnerText;
             * }
             * //Get value of TimeModified
             * if (UnitOfMeasureSetRet.SelectSingleNode("./TimeModified") != null)
             * {
             *  string TimeModified = UnitOfMeasureSetRet.SelectSingleNode("./TimeModified").InnerText;
             * }
             * //Get value of EditSequence
             * if (UnitOfMeasureSetRet.SelectSingleNode("./EditSequence") != null)
             * {
             *  string EditSequence = UnitOfMeasureSetRet.SelectSingleNode("./EditSequence").InnerText;
             * }
             * //Get value of Name
             * if (UnitOfMeasureSetRet.SelectSingleNode("./Name") != null)
             * {
             *  string Name = UnitOfMeasureSetRet.SelectSingleNode("./Name").InnerText;
             * }
             * //Get value of IsActive
             * if (UnitOfMeasureSetRet.SelectSingleNode("./IsActive") != null)
             * {
             *  string IsActive = UnitOfMeasureSetRet.SelectSingleNode("./IsActive").InnerText;
             * }
             * //Get value of UnitOfMeasureType
             * if (UnitOfMeasureSetRet.SelectSingleNode("./UnitOfMeasureType") != null)
             * {
             *  string UnitOfMeasureType = UnitOfMeasureSetRet.SelectSingleNode("./UnitOfMeasureType").InnerText;
             * }
             */
            //Get all field values for BaseUnit aggregate
            XmlNode BaseUnit = UnitOfMeasureSetRet.SelectSingleNode("./BaseUnit");

            if (BaseUnit != null)
            {
                //Get value of Name
                string Name = UnitOfMeasureSetRet.SelectSingleNode("./BaseUnit/Name").InnerText;
                //Get value of Abbreviation
                string Abbreviation = UnitOfMeasureSetRet.SelectSingleNode("./BaseUnit/Abbreviation").InnerText;
                uom.Name = Name + " (" + Abbreviation + ")";
            }
            //Done with field values for BaseUnit aggregate

            /*
             * //Walk list of RelatedUnit aggregates
             * XmlNodeList RelatedUnitList = UnitOfMeasureSetRet.SelectNodes("./RelatedUnit");
             * if (RelatedUnitList != null)
             * {
             *  for (int i = 0; i < RelatedUnitList.Count; i++)
             *  {
             *      XmlNode RelatedUnit = RelatedUnitList.Item(i);
             *      //Get value of Name
             *      string Name = RelatedUnit.SelectSingleNode("./Name").InnerText;
             *      //Get value of Abbreviation
             *      string Abbreviation = RelatedUnit.SelectSingleNode("./Abbreviation").InnerText;
             *      //Get value of ConversionRatio
             *      string ConversionRatio = RelatedUnit.SelectSingleNode("./ConversionRatio").InnerText;
             *  }
             * }
             *
             * //Walk list of DefaultUnit aggregates
             * XmlNodeList DefaultUnitList = UnitOfMeasureSetRet.SelectNodes("./DefaultUnit");
             * if (DefaultUnitList != null)
             * {
             *  for (int i = 0; i < DefaultUnitList.Count; i++)
             *  {
             *      XmlNode DefaultUnit = DefaultUnitList.Item(i);
             *      //Get value of UnitUsedFor
             *      string UnitUsedFor = DefaultUnit.SelectSingleNode("./UnitUsedFor").InnerText;
             *      //Get value of Unit
             *      string Unit = DefaultUnit.SelectSingleNode("./Unit").InnerText;
             *  }
             * }
             */

            if (uom != null)
            {
                db.SaveChanges();
            }
        }
Esempio n. 24
0
        private static void WalkUnitOfMeasureSetRet(XmlNode UnitOfMeasureSetRet)
        {
            if (UnitOfMeasureSetRet == null) return;

            UnitOfMeasure uom = null;
            RotoTrackDb db = new RotoTrackDb();

            string ListID = UnitOfMeasureSetRet.SelectSingleNode("./ListID").InnerText;
            if (db.UnitOfMeasures.Any(f => f.QBListId == ListID))
            {
                uom = db.UnitOfMeasures.First(f => f.QBListId == ListID);
            }
            else
            {
                uom = new UnitOfMeasure();
                db.UnitOfMeasures.Add(uom);
            }
            uom.QBListId = ListID;

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

            /*
            //Go through all the elements of UnitOfMeasureSetRet
            //Get value of ListID
            if (UnitOfMeasureSetRet.SelectSingleNode("./ListID") != null)
            {
                string ListID = UnitOfMeasureSetRet.SelectSingleNode("./ListID").InnerText;
            }
            //Get value of TimeCreated
            if (UnitOfMeasureSetRet.SelectSingleNode("./TimeCreated") != null)
            {
                string TimeCreated = UnitOfMeasureSetRet.SelectSingleNode("./TimeCreated").InnerText;
            }
            //Get value of TimeModified
            if (UnitOfMeasureSetRet.SelectSingleNode("./TimeModified") != null)
            {
                string TimeModified = UnitOfMeasureSetRet.SelectSingleNode("./TimeModified").InnerText;
            }
            //Get value of EditSequence
            if (UnitOfMeasureSetRet.SelectSingleNode("./EditSequence") != null)
            {
                string EditSequence = UnitOfMeasureSetRet.SelectSingleNode("./EditSequence").InnerText;
            }
            //Get value of Name
            if (UnitOfMeasureSetRet.SelectSingleNode("./Name") != null)
            {
                string Name = UnitOfMeasureSetRet.SelectSingleNode("./Name").InnerText;
            }
            //Get value of IsActive
            if (UnitOfMeasureSetRet.SelectSingleNode("./IsActive") != null)
            {
                string IsActive = UnitOfMeasureSetRet.SelectSingleNode("./IsActive").InnerText;
            }
            //Get value of UnitOfMeasureType
            if (UnitOfMeasureSetRet.SelectSingleNode("./UnitOfMeasureType") != null)
            {
                string UnitOfMeasureType = UnitOfMeasureSetRet.SelectSingleNode("./UnitOfMeasureType").InnerText;
            }
            */
            //Get all field values for BaseUnit aggregate
            XmlNode BaseUnit = UnitOfMeasureSetRet.SelectSingleNode("./BaseUnit");
            if (BaseUnit != null)
            {
                //Get value of Name
                string Name = UnitOfMeasureSetRet.SelectSingleNode("./BaseUnit/Name").InnerText;
                //Get value of Abbreviation
                string Abbreviation = UnitOfMeasureSetRet.SelectSingleNode("./BaseUnit/Abbreviation").InnerText;
                uom.Name = Name + " (" + Abbreviation + ")";
            }
            //Done with field values for BaseUnit aggregate

            /*
            //Walk list of RelatedUnit aggregates
            XmlNodeList RelatedUnitList = UnitOfMeasureSetRet.SelectNodes("./RelatedUnit");
            if (RelatedUnitList != null)
            {
                for (int i = 0; i < RelatedUnitList.Count; i++)
                {
                    XmlNode RelatedUnit = RelatedUnitList.Item(i);
                    //Get value of Name
                    string Name = RelatedUnit.SelectSingleNode("./Name").InnerText;
                    //Get value of Abbreviation
                    string Abbreviation = RelatedUnit.SelectSingleNode("./Abbreviation").InnerText;
                    //Get value of ConversionRatio
                    string ConversionRatio = RelatedUnit.SelectSingleNode("./ConversionRatio").InnerText;
                }
            }

            //Walk list of DefaultUnit aggregates
            XmlNodeList DefaultUnitList = UnitOfMeasureSetRet.SelectNodes("./DefaultUnit");
            if (DefaultUnitList != null)
            {
                for (int i = 0; i < DefaultUnitList.Count; i++)
                {
                    XmlNode DefaultUnit = DefaultUnitList.Item(i);
                    //Get value of UnitUsedFor
                    string UnitUsedFor = DefaultUnit.SelectSingleNode("./UnitUsedFor").InnerText;
                    //Get value of Unit
                    string Unit = DefaultUnit.SelectSingleNode("./Unit").InnerText;
                }
            }
            */

            if (uom != null)
            {
                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();
        }
Esempio n. 26
0
        private static void WalkCustomerRet(XmlNode CustomerRet)
        {
            if (CustomerRet == null) return;

            RotoTrackDb db = new RotoTrackDb();

            //Get value of Sublevel.  If it is not set to 0 or 1, then return (we only care about parents with sublevel of 0, and their direct descendents, sublevel of 1)
            string Sublevel = CustomerRet.SelectSingleNode("./Sublevel").InnerText;
            if (Sublevel != "0" && Sublevel != "1")
            {
                return;
            }

            // Archive all parent and child customers in a JobArchive table.  We use this for time and mileage and for debugging.
            string JobSublevel = Sublevel;
            string JobFullName = CustomerRet.SelectSingleNode("./FullName").InnerText;
            string JobName = CustomerRet.SelectSingleNode("./Name").InnerText;
            string JobListID = CustomerRet.SelectSingleNode("./ListID").InnerText;
            string JobEditSequence = CustomerRet.SelectSingleNode("./EditSequence").InnerText;
            string JobIsActive = CustomerRet.SelectSingleNode("./IsActive").InnerText;

            JobArchive ja = null;
            if (db.JobArchives.Any(j => j.QBListId == JobListID))
            {
                ja = db.JobArchives.First(j => j.QBListId == JobListID);
            }
            else
            {
                ja = new JobArchive();
                db.JobArchives.Add(ja);
            }

            ja.QBListId = JobListID;
            ja.QBEditSequence = JobEditSequence;
            ja.IsActive = (JobIsActive == "true") ? true : false;
            ja.Name = JobName;
            ja.FullName = JobFullName;
            ja.Sublevel = JobSublevel;

            db.SaveChanges();

            // Note that those that have a parent are actually jobs
            bool IsJob = false;
            string parentListID = "";
            XmlNode ParentRef = CustomerRet.SelectSingleNode("./ParentRef");
            if (ParentRef != null)
            {
                IsJob = true;
                parentListID = ParentRef.SelectSingleNode("./ListID").InnerText;
            }

            // If this is a Customer record (not a job record), add/update Customer information, first.
            Customer c = null;
            if (!IsJob)
            {
                string ListID = CustomerRet.SelectSingleNode("./ListID").InnerText;
                if (db.Customers.Any(f => f.QBListId == ListID))
                {
                    c = db.Customers.First(f => f.QBListId == ListID);
                }
                else
                {
                    c = new Customer();
                    db.Customers.Add(c);
                }
                c.QBListId = ListID;

                //Get value of Name
                string Name = CustomerRet.SelectSingleNode("./Name").InnerText;
                c.Name = Name;

                //Get value of IsActive
                string IsActive = "false";
                if (CustomerRet.SelectSingleNode("./IsActive") != null)
                {
                    IsActive = CustomerRet.SelectSingleNode("./IsActive").InnerText;
                }
                c.IsActive = (IsActive == "true") ? true : false;
            }
            // Else, update IsActive for the associated WorkOrder and then get the parent customer record so we can update info for the parent
            else
            {
                // Get associated work order and update the IsActive flag in case someone marked it inactive in QuickBooks.
                // Also, update some additional info that the user may set in QuickBooks that we need to sync back over.
                string ListID = CustomerRet.SelectSingleNode("./ListID").InnerText;
                if (db.WorkOrders.Any(f => f.QBListId == ListID))
                {
                    WorkOrder wo = db.WorkOrders.First(f => f.QBListId == ListID);

                    string IsActive = "false";
                    if (CustomerRet.SelectSingleNode("./IsActive") != null)
                    {
                        IsActive = CustomerRet.SelectSingleNode("./IsActive").InnerText;
                        if (IsActive == "false")
                        {
                            wo.Status = WorkOrderStatus.Inactive;
                        }
                    }
                    // Leave wo.Status alone if not marked Inactive.

                    //<DataExtName>Invoice Delivery Status</DataExtName><DataExtType>STR255TYPE</DataExtType><DataExtValue>Warranty</DataExtValue></DataExtRet><DataExtRet><OwnerID>0</OwnerID><DataExtName>Invoice Delivery Status Date</DataExtName><DataExtType>STR255TYPE</DataExtType><DataExtValue>09/12/2014</DataExtValue></DataExtRet>
                    bool gotInvoiceDeliveryStatus = false;
                    bool gotInvoiceDeliveryStatusDate = false;
                    XmlNodeList DataExtRetList = CustomerRet.SelectNodes("./DataExtRet");
                    if (DataExtRetList != null)
                    {
                        for (int i = 0; i < DataExtRetList.Count; i++)
                        {
                            XmlNode DataExtRet = DataExtRetList.Item(i);
                            //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;

                            if (DataExtName == "Invoice Delivery Status")
                            {
                                //wo.InvoiceDeliveryStatus
                                switch (DataExtValue)
                                {
                                    case "Closed at Zero $":
                                        wo.InvoiceDeliveryStatus = InvoiceDeliveryStatus.ClosedAtZeroDollars;
                                        break;

                                    case "Warranty":
                                        wo.InvoiceDeliveryStatus = InvoiceDeliveryStatus.Warranty;
                                        break;

                                    case "Invoice Hold-Coding/Signature":
                                        wo.InvoiceDeliveryStatus = InvoiceDeliveryStatus.InvoiceHoldCodingSignature;
                                        break;

                                    case "Invoice Mailed":
                                        wo.InvoiceDeliveryStatus = InvoiceDeliveryStatus.InvoiceMailed;
                                        break;

                                    case "Invoice Emailed":
                                        wo.InvoiceDeliveryStatus = InvoiceDeliveryStatus.InvoiceEmailed;
                                        break;

                                    case "Invoice Thru ADP":
                                        wo.InvoiceDeliveryStatus = InvoiceDeliveryStatus.InvoiceThruADP;
                                        break;

                                    case "Invoice Hand Delivered":
                                        wo.InvoiceDeliveryStatus = InvoiceDeliveryStatus.InvoiceHandDelivered;
                                        break;

                                    case "Filed":
                                        wo.InvoiceDeliveryStatus = InvoiceDeliveryStatus.Filed;
                                        break;

                                    default:
                                        Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + "Unknown Invoice Delivery Status:" + DataExtValue);
                                        break;
                                }

                                gotInvoiceDeliveryStatus = true;
                            }

                            else if (DataExtName == "Invoice Delivery Status Date")
                            {
                                if (DataExtValue.Length > 0)
                                {
                                    DateTime invoiceDeliveryStatusDate;
                                    if (DateTime.TryParse(DataExtValue, out invoiceDeliveryStatusDate))
                                    {
                                        wo.InvoiceDeliveryStatusDate = invoiceDeliveryStatusDate;
                                    }
                                    gotInvoiceDeliveryStatusDate = true;
                                }
                            }

                            else if (DataExtName == "Reason for Lost Quote")
                            {
                                switch (DataExtValue)
                                {
                                    case "Price Level":
                                        wo.ReasonForLostQuote = ReasonForLostQuote.PriceLevel;
                                        break;

                                    case "Delivery of Service":
                                        wo.ReasonForLostQuote = ReasonForLostQuote.DeliveryOfService;
                                        break;

                                        case "Slow Quote Response":
                                        wo.ReasonForLostQuote = ReasonForLostQuote.SlowQuoteResponse;
                                        break;

                                        case "Relationship w Competitor":
                                        wo.ReasonForLostQuote = ReasonForLostQuote.RelationshipWithCompetitor;
                                        break;

                                        case "Billing/ Invoicing":
                                        wo.ReasonForLostQuote = ReasonForLostQuote.BillingInvoicing;
                                        break;

                                        case "Warranty":
                                        wo.ReasonForLostQuote = ReasonForLostQuote.Warranty;
                                        break;

                                        case "Lack of Knowledge":
                                        wo.ReasonForLostQuote = ReasonForLostQuote.LackOfKnowledge;
                                        break;

                                        case "Lack of Product Choice":
                                        wo.ReasonForLostQuote = ReasonForLostQuote.LackOfProductChoice;
                                        break;

                                        case "In-House (Customer)":
                                        wo.ReasonForLostQuote = ReasonForLostQuote.InHouseCustomer;
                                        break;

                                        case "None":
                                        wo.ReasonForLostQuote = ReasonForLostQuote.None;
                                        break;

                                        case "Budgetary Estimate":
                                        wo.ReasonForLostQuote = ReasonForLostQuote.BudgetaryEstimate;
                                        break;

                                    default:
                                        Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + "Unknown Reason for Lost Quote");
                                        break;
                                }
                            }

                            else if (DataExtName == "Collection Status")
                            {
                                switch (DataExtValue)
                                {
                                    case "Dispute - Labor Rate":
                                        wo.CollectionStatus = CollectionStatus.DisputeLaborRate;
                                        break;

                                    case "Dispute - Parts Rate":
                                        wo.CollectionStatus = CollectionStatus.DisputePartsRate;
                                        break;

                                    case "Missing - Codes":
                                        wo.CollectionStatus = CollectionStatus.MissingCodes;
                                        break;

                                    case "Missing - PO/ AFE #":
                                        wo.CollectionStatus = CollectionStatus.MissingPOAFE;
                                        break;

                                    case "Missing - Signature":
                                        wo.CollectionStatus = CollectionStatus.MissingSignature;
                                        break;

                                    case "Request - Approver Name":
                                        wo.CollectionStatus = CollectionStatus.RequestApproverName;
                                        break;

                                    case "Request - DSR Copies":
                                        wo.CollectionStatus = CollectionStatus.RequestDSRCopies;
                                        break;

                                    case "Request - Parts Receipts":
                                        wo.CollectionStatus = CollectionStatus.RequestPartsReceipts;
                                        break;

                                    case "Request - Resubmit":
                                        wo.CollectionStatus = CollectionStatus.RequestResubmit;
                                        break;

                                    case "Request - Revision per Quote":
                                        wo.CollectionStatus = CollectionStatus.RequestRevisionPerQuote;
                                        break;

                                    case "In Process":
                                        wo.CollectionStatus = CollectionStatus.InProcess;
                                        break;

                                    case "In Process - Customer Queue":
                                        wo.CollectionStatus = CollectionStatus.InProcessCustomerQueue;
                                        break;

                                    case "In Process-Cust  Approve Paym":
                                        wo.CollectionStatus = CollectionStatus.InProcessCustomerApprovePayment;
                                        break;

                                    case "Paid":
                                        wo.CollectionStatus = CollectionStatus.Paid;
                                        break;

                                    case "Write-off":
                                        wo.CollectionStatus = CollectionStatus.WriteOff;
                                        break;

                                    default:
                                        Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + "Unknown Collection Status");
                                        break;
                                }
                            }

                        }
                    }

                    if (gotInvoiceDeliveryStatus && gotInvoiceDeliveryStatusDate)
                    {
                        // Don't update if we set it to Inactive above or if it was already set to Inactive
                        if (wo.Status != WorkOrderStatus.Inactive)
                        {
                            wo.Status = WorkOrderStatus.Invoiced;
                        }
                    }

                    db.SaveChanges();
                }

                // Get parent customer
                c = db.Customers.First(f => f.QBListId == parentListID);
            }

            string EditSequence = CustomerRet.SelectSingleNode("./EditSequence").InnerText;
            c.QBEditSequence = EditSequence;

            if (CustomerRet.SelectSingleNode("./CompanyName") != null)
            {
                string CompanyName = CustomerRet.SelectSingleNode("./CompanyName").InnerText;
                c.CompanyName = CompanyName;
            }

            XmlNode BillAddress = CustomerRet.SelectSingleNode("./BillAddress");
            if (BillAddress != null)
            {
                //Get value of Addr1
                if (CustomerRet.SelectSingleNode("./BillAddress/Addr1") != null)
                {
                    string Addr1 = CustomerRet.SelectSingleNode("./BillAddress/Addr1").InnerText;
                    c.Address.Address1 = Addr1;
                }
                //Get value of Addr2
                if (CustomerRet.SelectSingleNode("./BillAddress/Addr2") != null)
                {
                    string Addr2 = CustomerRet.SelectSingleNode("./BillAddress/Addr2").InnerText;
                    c.Address.Address2 = Addr2;
                }
                //Get value of Addr3
                if (CustomerRet.SelectSingleNode("./BillAddress/Addr3") != null)
                {
                    string Addr3 = CustomerRet.SelectSingleNode("./BillAddress/Addr3").InnerText;
                    c.Address.Address3 = Addr3;
                }
                //Get value of Addr4
                if (CustomerRet.SelectSingleNode("./BillAddress/Addr4") != null)
                {
                    string Addr4 = CustomerRet.SelectSingleNode("./BillAddress/Addr4").InnerText;
                    c.Address.Address4 = Addr4;
                }
                //Get value of Addr5
                if (CustomerRet.SelectSingleNode("./BillAddress/Addr5") != null)
                {
                    string Addr5 = CustomerRet.SelectSingleNode("./BillAddress/Addr5").InnerText;
                    c.Address.Address5 = Addr5;
                }
                //Get value of City
                if (CustomerRet.SelectSingleNode("./BillAddress/City") != null)
                {
                    string City = CustomerRet.SelectSingleNode("./BillAddress/City").InnerText;
                    c.Address.City = City;
                }
                //Get value of State
                if (CustomerRet.SelectSingleNode("./BillAddress/State") != null)
                {
                    string State = CustomerRet.SelectSingleNode("./BillAddress/State").InnerText;
                    c.Address.State = State;
                }
                //Get value of PostalCode
                if (CustomerRet.SelectSingleNode("./BillAddress/PostalCode") != null)
                {
                    string PostalCode = CustomerRet.SelectSingleNode("./BillAddress/PostalCode").InnerText;
                    c.Address.Zip = PostalCode;
                }

            }
            //Done with field values for BillAddress aggregate

            // Add any new contacts (that were added to QB, or existed initially)
            AddNewContactsFromQB(c, CustomerRet);

            // Save changes to the database
            if (c != null)
            {
                db.SaveChanges();
            }
        }
Esempio n. 27
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);
        }
Esempio n. 28
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();
                        }
                    }
                }
            }
        }
Esempio n. 29
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();
            }
        }
Esempio n. 30
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);
        }
Esempio n. 31
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;
             * }
             * }
             */
        }
Esempio n. 32
0
        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();
            }
        }
Esempio n. 33
0
        private static void WalkCustomerRet(XmlNode CustomerRet)
        {
            if (CustomerRet == null)
            {
                return;
            }

            RotoTrackDb db = new RotoTrackDb();

            //Get value of Sublevel.  If it is not set to 0 or 1, then return (we only care about parents with sublevel of 0, and their direct descendents, sublevel of 1)
            string Sublevel = CustomerRet.SelectSingleNode("./Sublevel").InnerText;

            if (Sublevel != "0" && Sublevel != "1")
            {
                return;
            }

            // Archive all parent and child customers in a JobArchive table.  We use this for time and mileage and for debugging.
            string JobSublevel     = Sublevel;
            string JobFullName     = CustomerRet.SelectSingleNode("./FullName").InnerText;
            string JobName         = CustomerRet.SelectSingleNode("./Name").InnerText;
            string JobListID       = CustomerRet.SelectSingleNode("./ListID").InnerText;
            string JobEditSequence = CustomerRet.SelectSingleNode("./EditSequence").InnerText;
            string JobIsActive     = CustomerRet.SelectSingleNode("./IsActive").InnerText;

            JobArchive ja = null;

            if (db.JobArchives.Any(j => j.QBListId == JobListID))
            {
                ja = db.JobArchives.First(j => j.QBListId == JobListID);
            }
            else
            {
                ja = new JobArchive();
                db.JobArchives.Add(ja);
            }

            ja.QBListId       = JobListID;
            ja.QBEditSequence = JobEditSequence;
            ja.IsActive       = (JobIsActive == "true") ? true : false;
            ja.Name           = JobName;
            ja.FullName       = JobFullName;
            ja.Sublevel       = JobSublevel;

            db.SaveChanges();

            // Note that those that have a parent are actually jobs
            bool    IsJob        = false;
            string  parentListID = "";
            XmlNode ParentRef    = CustomerRet.SelectSingleNode("./ParentRef");

            if (ParentRef != null)
            {
                IsJob        = true;
                parentListID = ParentRef.SelectSingleNode("./ListID").InnerText;
            }

            // If this is a Customer record (not a job record), add/update Customer information, first.
            Customer c = null;

            if (!IsJob)
            {
                string ListID = CustomerRet.SelectSingleNode("./ListID").InnerText;
                if (db.Customers.Any(f => f.QBListId == ListID))
                {
                    c = db.Customers.First(f => f.QBListId == ListID);
                }
                else
                {
                    c = new Customer();
                    db.Customers.Add(c);
                }
                c.QBListId = ListID;

                //Get value of Name
                string Name = CustomerRet.SelectSingleNode("./Name").InnerText;
                c.Name = Name;

                //Get value of IsActive
                string IsActive = "false";
                if (CustomerRet.SelectSingleNode("./IsActive") != null)
                {
                    IsActive = CustomerRet.SelectSingleNode("./IsActive").InnerText;
                }
                c.IsActive = (IsActive == "true") ? true : false;
            }
            // Else, update IsActive for the associated WorkOrder and then get the parent customer record so we can update info for the parent
            else
            {
                // Get associated work order and update the IsActive flag in case someone marked it inactive in QuickBooks.
                // Also, update some additional info that the user may set in QuickBooks that we need to sync back over.
                string ListID = CustomerRet.SelectSingleNode("./ListID").InnerText;
                if (db.WorkOrders.Any(f => f.QBListId == ListID))
                {
                    WorkOrder wo = db.WorkOrders.First(f => f.QBListId == ListID);

                    string IsActive = "false";
                    if (CustomerRet.SelectSingleNode("./IsActive") != null)
                    {
                        IsActive = CustomerRet.SelectSingleNode("./IsActive").InnerText;
                        if (IsActive == "false")
                        {
                            wo.Status = WorkOrderStatus.Inactive;
                        }
                    }
                    // Leave wo.Status alone if not marked Inactive.

                    //<DataExtName>Invoice Delivery Status</DataExtName><DataExtType>STR255TYPE</DataExtType><DataExtValue>Warranty</DataExtValue></DataExtRet><DataExtRet><OwnerID>0</OwnerID><DataExtName>Invoice Delivery Status Date</DataExtName><DataExtType>STR255TYPE</DataExtType><DataExtValue>09/12/2014</DataExtValue></DataExtRet>
                    bool        gotInvoiceDeliveryStatus     = false;
                    bool        gotInvoiceDeliveryStatusDate = false;
                    XmlNodeList DataExtRetList = CustomerRet.SelectNodes("./DataExtRet");
                    if (DataExtRetList != null)
                    {
                        for (int i = 0; i < DataExtRetList.Count; i++)
                        {
                            XmlNode DataExtRet = DataExtRetList.Item(i);
                            //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;


                            if (DataExtName == "Invoice Delivery Status")
                            {
                                //wo.InvoiceDeliveryStatus
                                switch (DataExtValue)
                                {
                                case "Closed at Zero $":
                                    wo.InvoiceDeliveryStatus = InvoiceDeliveryStatus.ClosedAtZeroDollars;
                                    break;

                                case "Warranty":
                                    wo.InvoiceDeliveryStatus = InvoiceDeliveryStatus.Warranty;
                                    break;

                                case "Invoice Hold-Coding/Signature":
                                    wo.InvoiceDeliveryStatus = InvoiceDeliveryStatus.InvoiceHoldCodingSignature;
                                    break;

                                case "Invoice Mailed":
                                    wo.InvoiceDeliveryStatus = InvoiceDeliveryStatus.InvoiceMailed;
                                    break;

                                case "Invoice Emailed":
                                    wo.InvoiceDeliveryStatus = InvoiceDeliveryStatus.InvoiceEmailed;
                                    break;

                                case "Invoice Thru ADP":
                                    wo.InvoiceDeliveryStatus = InvoiceDeliveryStatus.InvoiceThruADP;
                                    break;

                                case "Invoice Hand Delivered":
                                    wo.InvoiceDeliveryStatus = InvoiceDeliveryStatus.InvoiceHandDelivered;
                                    break;

                                case "Filed":
                                    wo.InvoiceDeliveryStatus = InvoiceDeliveryStatus.Filed;
                                    break;

                                default:
                                    Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + "Unknown Invoice Delivery Status:" + DataExtValue);
                                    break;
                                }

                                gotInvoiceDeliveryStatus = true;
                            }

                            else if (DataExtName == "Invoice Delivery Status Date")
                            {
                                if (DataExtValue.Length > 0)
                                {
                                    DateTime invoiceDeliveryStatusDate;
                                    if (DateTime.TryParse(DataExtValue, out invoiceDeliveryStatusDate))
                                    {
                                        wo.InvoiceDeliveryStatusDate = invoiceDeliveryStatusDate;
                                    }
                                    gotInvoiceDeliveryStatusDate = true;
                                }
                            }

                            else if (DataExtName == "Reason for Lost Quote")
                            {
                                switch (DataExtValue)
                                {
                                case "Price Level":
                                    wo.ReasonForLostQuote = ReasonForLostQuote.PriceLevel;
                                    break;

                                case "Delivery of Service":
                                    wo.ReasonForLostQuote = ReasonForLostQuote.DeliveryOfService;
                                    break;

                                case "Slow Quote Response":
                                    wo.ReasonForLostQuote = ReasonForLostQuote.SlowQuoteResponse;
                                    break;

                                case "Relationship w Competitor":
                                    wo.ReasonForLostQuote = ReasonForLostQuote.RelationshipWithCompetitor;
                                    break;

                                case "Billing/ Invoicing":
                                    wo.ReasonForLostQuote = ReasonForLostQuote.BillingInvoicing;
                                    break;

                                case "Warranty":
                                    wo.ReasonForLostQuote = ReasonForLostQuote.Warranty;
                                    break;

                                case "Lack of Knowledge":
                                    wo.ReasonForLostQuote = ReasonForLostQuote.LackOfKnowledge;
                                    break;

                                case "Lack of Product Choice":
                                    wo.ReasonForLostQuote = ReasonForLostQuote.LackOfProductChoice;
                                    break;

                                case "In-House (Customer)":
                                    wo.ReasonForLostQuote = ReasonForLostQuote.InHouseCustomer;
                                    break;

                                case "None":
                                    wo.ReasonForLostQuote = ReasonForLostQuote.None;
                                    break;

                                case "Budgetary Estimate":
                                    wo.ReasonForLostQuote = ReasonForLostQuote.BudgetaryEstimate;
                                    break;


                                default:
                                    Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + "Unknown Reason for Lost Quote");
                                    break;
                                }
                            }

                            else if (DataExtName == "Collection Status")
                            {
                                switch (DataExtValue)
                                {
                                case "Dispute - Labor Rate":
                                    wo.CollectionStatus = CollectionStatus.DisputeLaborRate;
                                    break;

                                case "Dispute - Parts Rate":
                                    wo.CollectionStatus = CollectionStatus.DisputePartsRate;
                                    break;

                                case "Missing - Codes":
                                    wo.CollectionStatus = CollectionStatus.MissingCodes;
                                    break;

                                case "Missing - PO/ AFE #":
                                    wo.CollectionStatus = CollectionStatus.MissingPOAFE;
                                    break;

                                case "Missing - Signature":
                                    wo.CollectionStatus = CollectionStatus.MissingSignature;
                                    break;

                                case "Request - Approver Name":
                                    wo.CollectionStatus = CollectionStatus.RequestApproverName;
                                    break;

                                case "Request - DSR Copies":
                                    wo.CollectionStatus = CollectionStatus.RequestDSRCopies;
                                    break;

                                case "Request - Parts Receipts":
                                    wo.CollectionStatus = CollectionStatus.RequestPartsReceipts;
                                    break;

                                case "Request - Resubmit":
                                    wo.CollectionStatus = CollectionStatus.RequestResubmit;
                                    break;

                                case "Request - Revision per Quote":
                                    wo.CollectionStatus = CollectionStatus.RequestRevisionPerQuote;
                                    break;

                                case "In Process":
                                    wo.CollectionStatus = CollectionStatus.InProcess;
                                    break;

                                case "In Process - Customer Queue":
                                    wo.CollectionStatus = CollectionStatus.InProcessCustomerQueue;
                                    break;

                                case "In Process-Cust  Approve Paym":
                                    wo.CollectionStatus = CollectionStatus.InProcessCustomerApprovePayment;
                                    break;

                                case "Paid":
                                    wo.CollectionStatus = CollectionStatus.Paid;
                                    break;

                                case "Write-off":
                                    wo.CollectionStatus = CollectionStatus.WriteOff;
                                    break;

                                default:
                                    Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + "Unknown Collection Status");
                                    break;
                                }
                            }
                        }
                    }

                    if (gotInvoiceDeliveryStatus && gotInvoiceDeliveryStatusDate)
                    {
                        // Don't update if we set it to Inactive above or if it was already set to Inactive
                        if (wo.Status != WorkOrderStatus.Inactive)
                        {
                            wo.Status = WorkOrderStatus.Invoiced;
                        }
                    }

                    db.SaveChanges();
                }

                // Get parent customer
                c = db.Customers.First(f => f.QBListId == parentListID);
            }

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

            c.QBEditSequence = EditSequence;

            if (CustomerRet.SelectSingleNode("./CompanyName") != null)
            {
                string CompanyName = CustomerRet.SelectSingleNode("./CompanyName").InnerText;
                c.CompanyName = CompanyName;
            }

            XmlNode BillAddress = CustomerRet.SelectSingleNode("./BillAddress");

            if (BillAddress != null)
            {
                //Get value of Addr1
                if (CustomerRet.SelectSingleNode("./BillAddress/Addr1") != null)
                {
                    string Addr1 = CustomerRet.SelectSingleNode("./BillAddress/Addr1").InnerText;
                    c.Address.Address1 = Addr1;
                }
                //Get value of Addr2
                if (CustomerRet.SelectSingleNode("./BillAddress/Addr2") != null)
                {
                    string Addr2 = CustomerRet.SelectSingleNode("./BillAddress/Addr2").InnerText;
                    c.Address.Address2 = Addr2;
                }
                //Get value of Addr3
                if (CustomerRet.SelectSingleNode("./BillAddress/Addr3") != null)
                {
                    string Addr3 = CustomerRet.SelectSingleNode("./BillAddress/Addr3").InnerText;
                    c.Address.Address3 = Addr3;
                }
                //Get value of Addr4
                if (CustomerRet.SelectSingleNode("./BillAddress/Addr4") != null)
                {
                    string Addr4 = CustomerRet.SelectSingleNode("./BillAddress/Addr4").InnerText;
                    c.Address.Address4 = Addr4;
                }
                //Get value of Addr5
                if (CustomerRet.SelectSingleNode("./BillAddress/Addr5") != null)
                {
                    string Addr5 = CustomerRet.SelectSingleNode("./BillAddress/Addr5").InnerText;
                    c.Address.Address5 = Addr5;
                }
                //Get value of City
                if (CustomerRet.SelectSingleNode("./BillAddress/City") != null)
                {
                    string City = CustomerRet.SelectSingleNode("./BillAddress/City").InnerText;
                    c.Address.City = City;
                }
                //Get value of State
                if (CustomerRet.SelectSingleNode("./BillAddress/State") != null)
                {
                    string State = CustomerRet.SelectSingleNode("./BillAddress/State").InnerText;
                    c.Address.State = State;
                }
                //Get value of PostalCode
                if (CustomerRet.SelectSingleNode("./BillAddress/PostalCode") != null)
                {
                    string PostalCode = CustomerRet.SelectSingleNode("./BillAddress/PostalCode").InnerText;
                    c.Address.Zip = PostalCode;
                }
            }
            //Done with field values for BillAddress aggregate

            // Add any new contacts (that were added to QB, or existed initially)
            AddNewContactsFromQB(c, CustomerRet);

            // Save changes to the database
            if (c != null)
            {
                db.SaveChanges();
            }
        }
Esempio n. 34
0
        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();
                }
            }
        }
Esempio n. 35
0
        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();
                            }
                        }
                    }
                }
            }
        }
Esempio n. 36
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();
            }
        }
Esempio n. 37
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
        }
Esempio n. 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();
                        }
                    }
                }
            }
        }
Esempio n. 39
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();
 }
Esempio n. 40
0
        private bool UpdateWorkOrder(int woID)
        {
            RotoTrackDb db = new RotoTrackDb();
            WorkOrder wo = db.WorkOrders.Find(woID);

            XmlDocument doc = WorkOrderDAL.BuildModRq(wo);
            string response = QBUtils.DoRequest(doc);
            bool status = WorkOrderDAL.HandleModResponse(response);

            if (!status)
            {
                //Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + "Failed to update work order for WO#: " + wo.WorkOrderNumber + " ListID: " + wo.QBListId + ".  Setting NeedToUpdateQB flag to true to try again.");
                wo.NeedToUpdateQB = true;
                db.Entry(wo).State = EntityState.Modified;
                db.SaveChanges();
                return false;
            }
            else
            {
                return true;
            }
        }
Esempio n. 41
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;
                        }
                    }
                }
            }
        }
Esempio n. 42
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);
                    }
                }
            }
        }
Esempio n. 43
0
        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();
        }
Esempio n. 44
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();
            }
        }
Esempio n. 45
0
        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();
            }
        }
Esempio n. 46
0
        private void SyncVacationAndSickTime()
        {
            AppendStatus("Syncing Vacation and Sick Time...");

            RotoTrackDb db = new RotoTrackDb();

            List<Employee> employees = db.Employees.Where(f => f.IsActive == true).ToList();
            foreach (Employee e in employees)
            {
                RotoTrackDbUtils.ComputeVacationFields(e);
                db.Entry(e).State = EntityState.Modified;
                db.SaveChanges();
            }

            AppendStatus("Done");
            AppendStatus(Environment.NewLine);
        }
Esempio n. 47
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();
 }
Esempio n. 48
0
        private void UpdateEstDollarAmountForWorkOrder(int woID)
        {
            RotoTrackDb db = new RotoTrackDb();

            WorkOrder wo = db.WorkOrders.Find(woID);
            string woListID = wo.QBListId;

            List<TimeTracking> timetrackings;
            timetrackings = db.TimeTrackings.Where(f => f.QBWorkOrderListID == woListID).ToList();

            List<MileageTracking> mileagetrackings;
            mileagetrackings = db.MileageTrackings.Where(f => f.QBWorkOrderListID == woListID).ToList();

            List<BillLine> billLines;
            billLines = db.BillLines.Where(f => f.WorkOrderListID == woListID).ToList();

            List<VendorCreditLine> vendorCreditLines;
            vendorCreditLines = db.VendorCreditLines.Where(f => f.WorkOrderListID == woListID).ToList();

            List<SalesOrderLine> soLines;
            soLines = db.SalesOrderLines.Where(f => f.WorkOrderListID == woListID).ToList();

            var workorders = db.WorkOrders.ToList();
            var users = db.UserProfiles.ToList();
            var servicetypes = db.ServiceTypes.ToList();
            var customers = db.Customers.ToList();
            var vehicles = db.Vehicles.ToList();
            var mileagerates = db.MileageRates.ToList();
            var vendors = db.Vendors.ToList();
            var items = db.Items.ToList();

            var tt_results =
                from tt in timetrackings
                from workorder in workorders.Where(f => f.QBListId == tt.QBWorkOrderListID).DefaultIfEmpty()
                from customer in customers.Where(f => f.Id == (workorder == null ? -1 : workorder.CustomerId)).DefaultIfEmpty()
                from user in users.Where(f => f.QBListId == tt.QBEmployeeListID).DefaultIfEmpty()
                from servicetype in servicetypes.Where(f => f.QBListId == tt.QBServiceTypeListID).DefaultIfEmpty()
                select new
                {
                    Id = tt.Id,
                    Job = ((workorder == null) || (customer == null)) ? "" : (customer.Name + ":" + workorder.WorkOrderNumber),
                    Type = "Time",
                    BillableStatus = tt.BillableStatus,
                    Date = tt.DateWorked,
                    Item = (servicetype == null) ? "" : servicetype.Name,
                    Description = (user == null) ? "" : user.FirstName + " " + user.LastName,
                    Unit = tt.HoursWorked + (tt.MinutesWorked / 60.0M),
                    Rate = (servicetype == null) ? 0M : decimal.Parse(servicetype.Price) * 1.0M,
                    Amount = (servicetype == null) ? 0M : decimal.Parse(servicetype.Price) * (tt.HoursWorked + (tt.MinutesWorked / 60.0M)) * 1.0M,
                    SalePrice = (servicetype == null) ? 0M : decimal.Parse(servicetype.Price) * (tt.HoursWorked + (tt.MinutesWorked / 60.0M)) * 1.0M,
                    Comments = ""
                };

            var mileage_results =
                from mileagetracking in mileagetrackings
                from workorder in workorders.Where(f => f.QBListId == mileagetracking.QBWorkOrderListID).DefaultIfEmpty()
                from customer in customers.Where(f => f.Id == (workorder == null ? -1 : workorder.CustomerId)).DefaultIfEmpty()
                from vehicle in vehicles.Where(f => f.QBListId == mileagetracking.QBVehicleListID).DefaultIfEmpty()
                from mileagerate in mileagerates.Where(f => f.QBListId == mileagetracking.QBMileageRateListID).DefaultIfEmpty()
                select new
                {
                    Id = mileagetracking.Id,
                    Job = ((workorder == null) || (customer == null)) ? "" : (customer.Name + ":" + workorder.WorkOrderNumber),
                    Type = "Mileage",
                    BillableStatus = mileagetracking.BillableStatus,
                    Date = mileagetracking.TripStartDate,
                    Item = (mileagerate == null) ? "" : mileagerate.Name,
                    Description = (vehicle == null) ? "" : vehicle.Name,
                    Unit = mileagetracking.TotalMiles * 1.0M,
                    Rate = (mileagerate == null) ? 0.0M : (mileagerate.Rate * 1.0M),
                    Amount = mileagetracking.BillableAmount * 1.0M,
                    SalePrice = mileagetracking.BillableAmount * 1.0M,
                    Comments = mileagetracking.Notes
                };

            var bill_results =
                from billline in billLines
                from workorder in workorders.Where(f => f.QBListId == billline.WorkOrderListID).DefaultIfEmpty()
                from customer in customers.Where(f => f.Id == (workorder == null ? -1 : workorder.CustomerId)).DefaultIfEmpty()
                from item in items.Where(f => f.QBListId == billline.ItemListID).DefaultIfEmpty()
                from vendor in vendors.Where(f => f.QBListId == billline.VendorListID).DefaultIfEmpty()
                select new
                {
                    Id = billline.Id,
                    Job = ((workorder == null) || (customer == null)) ? "" : (customer.Name + ":" + workorder.WorkOrderNumber),
                    Type = ((billline.Amount < 0) ? "Credit" : "Bill"),
                    BillableStatus = billline.BillableStatus,
                    Date = billline.BillTxnDate,
                    Item = (item == null) ? "" : item.Name,
                    Description = billline.Description,
                    Unit = ((billline.Quantity == 0 && billline.Amount > 0 && billline.UnitCost > 0) ? (billline.Amount / billline.UnitCost) : billline.Quantity * 1.0M),
                    Rate = billline.UnitCost * 1.0M,
                    Amount = billline.Amount * 1.0M,
                    //SalePrice = ((billline.Amount < 0) ? billline.Amount * 1.0M : 0.0M),
                    SalePrice = CalculateSalePrice(billline, item),
                    Comments = (vendor == null) ? "" : vendor.Name
                };

            var vendor_credit_results =
                from vendorcreditline in vendorCreditLines
                from workorder in workorders.Where(f => f.QBListId == vendorcreditline.WorkOrderListID).DefaultIfEmpty()
                from customer in customers.Where(f => f.Id == (workorder == null ? -1 : workorder.CustomerId)).DefaultIfEmpty()
                from item in items.Where(f => f.QBListId == vendorcreditline.ItemListID).DefaultIfEmpty()
                from vendor in vendors.Where(f => f.QBListId == vendorcreditline.VendorListID).DefaultIfEmpty()
                select new
                {
                    Id = vendorcreditline.Id,
                    Job = ((workorder == null) || (customer == null)) ? "" : (customer.Name + ":" + workorder.WorkOrderNumber),
                    Type = "Credit",
                    BillableStatus = vendorcreditline.BillableStatus,
                    Date = vendorcreditline.VendorCreditTxnDate,
                    Item = (item == null) ? "" : item.Name,
                    Description = vendorcreditline.Description,
                    Unit = ((vendorcreditline.Quantity == 0 && vendorcreditline.Amount > 0 && vendorcreditline.UnitCost > 0) ? (vendorcreditline.Amount / vendorcreditline.UnitCost) : vendorcreditline.Quantity * 1.0M),
                    Rate = vendorcreditline.UnitCost * -1.0M,
                    Amount = vendorcreditline.Amount * -1.0M,
                    //SalePrice = ((billline.Amount < 0) ? billline.Amount * 1.0M : 0.0M),
                    SalePrice = CalculateSalePrice(vendorcreditline, item) * -1.0M,
                    Comments = (vendor == null) ? "" : vendor.Name
                };

            var so_results =
                from soline in soLines
                from workorder in workorders.Where(f => f.QBListId == soline.WorkOrderListID).DefaultIfEmpty()
                from customer in customers.Where(f => f.Id == (workorder == null ? -1 : workorder.CustomerId)).DefaultIfEmpty()
                select new
                {
                    Id = soline.Id,
                    Job = ((workorder == null) || (customer == null)) ? "" : (customer.Name + ":" + workorder.WorkOrderNumber),
                    Type = "Sales Order",
                    BillableStatus = soline.BillableStatus,
                    Date = soline.SalesOrderTxnDate,
                    Item = soline.ItemName,
                    Description = soline.Description,
                    Unit = soline.Quantity * 1.0M,
                    Rate = soline.UnitCost * 1.0M,
                    Amount = soline.Amount * 1.0M,
                    SalePrice = soline.Amount * 1.0M,
                    Comments = ""
                };

            var workordersummaryAll = tt_results
                .Concat(mileage_results)
                .Concat(bill_results)
                .Concat(vendor_credit_results)
                .Concat(so_results)
                .AsQueryable();

            decimal totalAmount = workordersummaryAll.Sum(f => f.Amount);
            decimal totalSalePrice = workordersummaryAll.Sum(f => f.SalePrice);

            wo.EstDollarAmount = (double)totalSalePrice;

            if ((wo.CloseStatus == CloseStatus.Warranty) && (wo.EstDollarAmount > 0))
            {
                wo.EstDollarAmount *= -1.0;
            }

            db.Entry(wo).State = EntityState.Modified;
            db.SaveChanges();
        }
Esempio n. 49
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();
 }
Esempio n. 50
0
        private void UpdateInvoiceSubtotal(int woID)
        {
            RotoTrackDb db = new RotoTrackDb();

            WorkOrder wo = db.WorkOrders.Find(woID);

            // Do invoice subtotal
            double invoiceSubtotal = 0.0;
            if (db.Invoices.Any(f => f.WorkOrderListID == wo.QBListId))
            {
                string query = "select i.TxnId, i.TxnDate, i.WorkOrderListID, i.Subtotal from invoices i inner join (select max(i.id) as id from Invoices i inner join WorkOrders w on w.QBListId = i.WorkOrderListID where i.TxnDate <> '1900-01-01 00:00:00.000' and i.WorkOrderListID = '" + wo.QBListId + "' group by i.TxnId, i.WorkOrderListID) iv on iv.id = i.Id";

                List<DistinctInvoice> invoices = db.Database.SqlQuery<DistinctInvoice>(query).ToList();

                //List<Invoice> invoiceList = db.Invoices.Where(f => f.WorkOrderListID == wo.QBListId).ToList();
                foreach (DistinctInvoice invoice in invoices)
                {
                    invoiceSubtotal += invoice.Subtotal;
                    wo.InvoiceCreated = invoice.TxnDate;
                }
            }

            wo.InvoiceSubtotal = invoiceSubtotal;

            if ((wo.CloseStatus == CloseStatus.Warranty) && (wo.InvoiceSubtotal > 0))
            {
                wo.InvoiceSubtotal *= -1.0;
            }

            db.Entry(wo).State = EntityState.Modified;
            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + "Exception occurred: " + ex.ToString() + wo.Id.ToString() + "," + wo.InvoiceCreated.ToShortDateString() + "," + wo.InvoiceSubtotal.ToString() + db.GetValidationErrors().ToString());
                throw (ex);
            }
        }
Esempio n. 51
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();
        }
Esempio n. 52
0
        private void UpdateSiteAndAdditionalInfo(int woID)
        {
            RotoTrackDb db = new RotoTrackDb();
            WorkOrder wo = db.WorkOrders.Find(woID);

            XmlDocument doc = SiteAndAdditionalInfoDAL.BuildUpdateRq(wo);
            string response = QBUtils.DoRequest(doc);
            bool status = SiteAndAdditionalInfoDAL.HandleResponse(response);

            if (!status)
            {
                //Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + "Failed to update site and additional info for WO#: " + wo.WorkOrderNumber + " ListID: " + wo.QBListId + ".  Setting NeedToUpdateQB flag to true to try again.");
                wo.NeedToUpdateQB = true;
                db.Entry(wo).State = EntityState.Modified;
                db.SaveChanges();
            }
        }