示例#1
0
        private static void CopyRecordFromMyob(AMSDbContext connect, MYOBCustomer jtItem, Customer item)
        {
            jtItem.CompanyName  = item.IsIndividual ? HandyContactFunctions.FormattedLastAndFirstName(item.LastName, item.FirstName) : item.CompanyName;
            jtItem.DisplayID    = item.DisplayID;
            jtItem.FirstName    = item.FirstName;
            jtItem.LastName     = item.LastName;
            jtItem.IsIndividual = item.IsIndividual;
            jtItem.IsActive     = item.IsActive;
            jtItem.RowVersion   = item.RowVersion;
            jtItem.Uid          = item.UID;
            jtItem.LastModified = item.LastModified;
            jtItem.URI          = item.URI.ToString();



            if (item.SellingDetails?.InvoiceDelivery != null)
            {
                jtItem.DocumentAction = (DocumentAction)item.SellingDetails.InvoiceDelivery;
            }
            SyncAddresses(connect, jtItem, item);
        }
示例#2
0
        private static void CopyRecordFromMYOB(AMSDbContext connect, MYOBSupplier jtItem, Supplier item)
        {
            jtItem.CompanyName = HandyContactFunctions.MakeKey(
                item.IsIndividual,
                item.LastName,
                item.FirstName,
                item.CompanyName);

            jtItem.DisplayID    = item.DisplayID;
            jtItem.FirstName    = item.FirstName;
            jtItem.LastName     = item.LastName;
            jtItem.IsIndividual = item.IsIndividual;
            jtItem.IsActive     = item.IsActive;
            jtItem.RowVersion   = item.RowVersion;
            jtItem.Uid          = item.UID;
            jtItem.LastModified = item.LastModified;
            jtItem.URI          = item.URI.ToString();
            jtItem.IsActive     = item.IsActive;

            SyncAddresses(connect, jtItem, item);
        }
示例#3
0
        private static void AddNewUpdateExistingRecords(
            Supplier[] ar,
            AMSDbContext connect,
            IProgress <int> progressCallback)
        {
            var info     = "";
            var stepNum  = 1;
            var numSteps = ar.Count();

            foreach (var item in ar)
            {
                var key = HandyContactFunctions.MakeKey(
                    item.IsIndividual,
                    item.LastName,
                    item.FirstName,
                    item.CompanyName);
                if (key == info)
                {
                    throw new ExceptionDuplicateKey($"{info}");
                }
                info = key;
                HandyFunctions.Log(info);
                var jtSupplier = connect.MYOBSuppliers.SingleOrDefault(x => x.Uid == item.UID);

                //unique idex should ensure only 1
                if (jtSupplier == null)
                {
                    jtSupplier = new MYOBSupplier();
                    connect.MYOBSuppliers.Add(jtSupplier);
                }
                CopyRecordFromMYOB(connect, jtSupplier, item);
                progressCallback.Report((100 * stepNum) / numSteps);
                stepNum++;
            }
            connect.SaveChanges();
        }
示例#4
0
 private static string MakeAlternateKey(Customer customer)
 {
     return(customer.IsIndividual ? customer.CompanyName : HandyContactFunctions.FormattedLastAndFirstName(customer.LastName, customer.FirstName));
 }