示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="member">Member to sync.</param>
        /// <param name="customer">Customer to sync.</param>
        /// <param name="forceSync"></param>
        public void SyncItem(DojoMember member, RHCustomer customer)
        {
            if (member.Customer == null)
            {
                if (member.PrivateContact.FirstName ==
                    customer.PrivateContact.FirstName &
                    member.PrivateContact.LastName ==
                    customer.PrivateContact.LastName &
                    member.PrivateContact.MiddleName ==
                    customer.PrivateContact.MiddleName)
                {
                    member.Customer = customer;

                    if (member.ModifyDate > customer.ModifyDate)
                    {
                        if (customer.PrivateContact == null)
                        {
                            customer.PrivateContact =
                                new GreyFoxContact(RHCustomerManager.PrivateContactTable);
                        }

                        customer.PrivateContact.DisplayName =
                            member.PrivateContact.ConstructName("L S, F Mi.");

                        customer.PrivateContact.Prefix =
                            member.PrivateContact.Prefix;
                        customer.PrivateContact.FirstName =
                            member.PrivateContact.FirstName;
                        customer.PrivateContact.MiddleName =
                            member.PrivateContact.MiddleName;
                        customer.PrivateContact.LastName =
                            member.PrivateContact.LastName;
                        customer.PrivateContact.Suffix =
                            member.PrivateContact.Suffix;
                        customer.PrivateContact.SuffixCommaEnabled =
                            member.PrivateContact.SuffixCommaEnabled;

                        customer.PrivateContact.HomePhone =
                            member.PrivateContact.HomePhone;
                        customer.PrivateContact.WorkPhone =
                            member.PrivateContact.WorkPhone;
                        customer.PrivateContact.MobilePhone =
                            member.PrivateContact.MobilePhone;
                        customer.PrivateContact.Email1 =
                            member.PrivateContact.Email1;
                        customer.PrivateContact.Url =
                            member.PrivateContact.Url;
                        customer.PrivateContact.BusinessName =
                            member.PrivateContact.BusinessName;
                        customer.PrivateContact.BirthDate =
                            member.PrivateContact.BirthDate;

                        customer.PrivateContact.Address1 =
                            member.PrivateContact.Address1;
                        customer.PrivateContact.Address2 =
                            member.PrivateContact.Address2;
                        customer.PrivateContact.City =
                            member.PrivateContact.City;
                        customer.PrivateContact.StateProvince =
                            member.PrivateContact.StateProvince;
                        customer.PrivateContact.PostalCode =
                            member.PrivateContact.PostalCode;
                        customer.PrivateContact.Country =
                            member.PrivateContact.Country;

                        if (!customer.PrivateContact.IsSynced)
                        {
                            customer.IsSynced = false;
                        }

                        customer.PrivateContact.Save();
                        customer.Save();
                    }
                    else
                    {
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Syncs the Members List to the Customer List. If a Member does not
        /// have an associated Customer, the Customer List is checked for an
        /// existing customer with the same name. If a matching customer is not
        /// found, a new customer is created.
        /// </summary>
        /// <param name="forceSync"></param>
        public void SyncCustomers()
        {
            DojoMemberCollection members;
            RHCustomerCollection customers;

            bool addCustomer;
            bool skipChildren;

            members = new DojoMemberManager().GetCollection(string.Empty, string.Empty,
                                                            DojoMemberFlags.PrivateContact);

            customers = new RHCustomerManager().GetCollection(string.Empty, string.Empty,
                                                              RHCustomerFlags.PrivateContact,
                                                              RHCustomerFlags.BillingContact,
                                                              RHCustomerFlags.ShippingContact);

            skipChildren = customerExportMode == RHCustomerExportMode.ExportParentsOnly;

            foreach (DojoMember member in members)
            {
                if (skipChildren && member.Parent != null)
                {
                    continue;
                }

                // Reset addcustomer flag to keep track of customers
                // that need to be added.
                addCustomer = true;

                foreach (RHCustomer customer in customers)
                {
                    if (member.Customer == null)
                    {
                        if (member.PrivateContact.FirstName == customer.PrivateContact.FirstName &
                            member.PrivateContact.LastName == customer.PrivateContact.LastName &
                            member.PrivateContact.MiddleName == customer.PrivateContact.MiddleName)
                        {
                            member.Customer = customer;
                        }
                    }

                    if (member.Customer.ID == customer.ID)
                    {
                        SyncItem(member, customer);
                        addCustomer = false;
                        break;
                    }
                }

                if (addCustomer)
                {
                    RHCustomer newCustomer = new RHCustomer();

                    newCustomer.PrivateContact  = new GreyFoxContact(RHCustomerManager.PrivateContactTable);
                    newCustomer.BillingContact  = new GreyFoxContact(RHCustomerManager.BillingContactTable);
                    newCustomer.ShippingContact = new GreyFoxContact(RHCustomerManager.ShippingContactTable);

                    member.PrivateContact.CopyValuesTo(newCustomer.PrivateContact, false);
                    member.PrivateContact.CopyValuesTo(newCustomer.BillingContact, false);
                    member.PrivateContact.CopyValuesTo(newCustomer.ShippingContact, false);

                    newCustomer.PrivateContact.Save();
                    newCustomer.BillingContact.Save();
                    newCustomer.ShippingContact.Save();

                    newCustomer.Save();
                }
            }
        }