Ejemplo n.º 1
0
        private static HoursMinutes GetHoursMinutesFromDuration(string Duration)
        {
            HoursMinutes hrsMins = null;

            try
            {
                var parts = Duration.Split('T');
                if (parts.Length == 2)
                {
                    if (parts[0] == "P")
                    {
                        var parts2 = parts[1].Split('H');
                        if (parts2.Length == 2)
                        {
                            int hours  = Convert.ToInt32(parts2[0]);
                            var parts3 = parts2[1].Split('M');
                            if (parts3.Length == 2)
                            {
                                int minutes = Convert.ToInt32(parts3[0]);
                                hrsMins         = new HoursMinutes();
                                hrsMins.Hours   = hours;
                                hrsMins.Minutes = minutes;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + e.ToString());
            }

            return(hrsMins);
        }
Ejemplo n.º 2
0
 public static void CheckStatus(string statusCode, string statusSeverity, string statusMessage)
 {
     if (Convert.ToInt32(statusCode) != 0)
     {
         Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + "Error: " + statusMessage);
     }
 }
Ejemplo n.º 3
0
        public static string DoRequest(XmlDocument doc)
        {
            RequestProcessor2 rp       = null;
            string            ticket   = null;
            string            response = null;
            bool errorOccurred         = false;
            int  maxTries = 1;
            int  tries    = 0;

            do
            {
                try
                {
                    tries++;
                    rp = new RequestProcessor2();
                    rp.OpenConnection("QBMT1", "QBMigrationTool");
                    ticket = rp.BeginSession("", QBFileMode.qbFileOpenDoNotCare);
                    CheckIfBuildTypeAndQuickBooksFileMatch(rp.GetCurrentCompanyFileName(ticket));
                    response = rp.ProcessRequest(ticket, doc.OuterXml);

                    if (errorOccurred)
                    {
                        Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + "DoRequest Retry succeeded.");
                        errorOccurred = false;
                    }
                }
                catch (System.Runtime.InteropServices.COMException e)
                {
                    Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + "Error in DoRequest.  Retrying.  Details: " + e.ToString());
                    //MessageBox.Show("Outer: " + doc.OuterXml);
                    errorOccurred = true;
                }
                catch (Exception e)
                {
                    Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + "Error in DoRequest.  Retrying.  Details: " + e.ToString());
                    break;
                }
                finally
                {
                    if (ticket != null)
                    {
                        rp.EndSession(ticket);
                    }
                    if (rp != null)
                    {
                        rp.CloseConnection();
                    }
                }
            } while (errorOccurred && tries <= maxTries);

            return(response);
        }
Ejemplo n.º 4
0
        private static void CheckIfBuildTypeAndQuickBooksFileMatch(string filename)
        {
            string buildType  = RototrackConfig.GetBuildType();
            bool   validMatch = false;

            if (filename.Contains("Roto-Versal") && buildType.Contains("ROTO"))
            {
                validMatch = true;
            }
            else if (filename.Contains("Guardiant") && buildType.Contains("GUARD"))
            {
                validMatch = true;
            }

            if (!validMatch)
            {
                throw new Exception("Build type is: " + buildType + " but open Quickbooks file is " + filename + "!");
            }
        }
Ejemplo n.º 5
0
        private static Area GetAreaFromEmployeeRet(XmlNode EmployeeRet)
        {
            RotoTrackDb db     = new RotoTrackDb();
            Area        area   = new Area();
            Config      config = db.Configs.First();

            string areaInitials = config.DefaultAreaInitials;

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

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

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

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

            return(area);
        }
Ejemplo n.º 6
0
        public static string DoRequestRaw(string rawXML)
        {
            RequestProcessor2 rp       = null;
            string            ticket   = null;
            string            response = null;

            try
            {
                rp = new RequestProcessor2();
                rp.OpenConnection("QBMT1", "QBMigrationTool");
                ticket = rp.BeginSession("", QBFileMode.qbFileOpenDoNotCare);
                CheckIfBuildTypeAndQuickBooksFileMatch(rp.GetCurrentCompanyFileName(ticket));
                response = rp.ProcessRequest(ticket, rawXML);
                return(response);
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                MessageBox.Show("COM Error Description = " + ex.Message, "COM error");
                return(ex.Message);
            }
            catch (Exception e)
            {
                MessageBox.Show("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + "Error in DoRequestRaw.  Details: " + e.ToString(), "Exception");
                return(e.Message);
            }
            finally
            {
                if (ticket != null)
                {
                    rp.EndSession(ticket);
                }
                if (rp != null)
                {
                    rp.CloseConnection();
                }
            }
        }
Ejemplo n.º 7
0
        public static XmlDocument BuildAddRq(ServiceEntry se, ServiceDetail sd, int serviceId, decimal hours)
        {
            try
            {
                XmlDocument doc    = XmlUtils.MakeRequestDocument();
                XmlElement  parent = XmlUtils.MakeRequestParentElement(doc);

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

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

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

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

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

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

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

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

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

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

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

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

                return(doc);
            }
            catch (Exception e)
            {
                string evLogTxt = "";
                evLogTxt = "Error building time tracking add request! " + e.Message + "\r\n";
                Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + evLogTxt);
                return(null);
            }
        }
Ejemplo n.º 8
0
        public static XmlDocument BuildAddRq(ServiceEntry se, ServiceDetail sd)
        {
            try
            {
                XmlDocument doc    = XmlUtils.MakeRequestDocument();
                XmlElement  parent = XmlUtils.MakeRequestParentElement(doc);

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

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

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

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

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

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

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

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

                return(doc);
            }
            catch (Exception e)
            {
                string evLogTxt = "";
                evLogTxt = "Error building vehicle mileage add request! " + e.Message + "\r\n";
                Logging.RototrackErrorLog("QBMigrationTool: " + RototrackConfig.GetBuildType() + ": " + evLogTxt);
                return(null);
            }
        }
Ejemplo n.º 9
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);
                    }
                }
            }
        }
Ejemplo n.º 10
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();
            }
        }