Exemple #1
0
        public void BusinessPartnerMapping(IList <CustomerMappingDTO> pLstObjMapping)
        {
            foreach (CustomerMappingDTO lObjMapping in pLstObjMapping.Where(x => x.Autorize))
            {
                Partner lObjPartner = LocalBusinessPartnerService.GetEntity(lObjMapping.LocalPartnerId);

                if (lObjMapping.Type == UGRS.Core.SDK.DI.Auctions.Enum.MappingTypeEnum.NEW)
                {
                    ExportBusinessPartner(lObjPartner);
                }
                else if (lObjMapping.Type == UGRS.Core.SDK.DI.Auctions.Enum.MappingTypeEnum.EXISTING)
                {
                    if (!CustomerHasBeenImported(lObjMapping.SapPartnerCardCode))
                    {
                        ImportCustomer(lObjMapping.SapPartnerCardCode);
                    }

                    Partner lObjMappedPartner = mObjLocalBusinessPartnerService.GetList().Where(x => x.Code == lObjMapping.SapPartnerCardCode).FirstOrDefault();

                    if (lObjMappedPartner != null)
                    {
                        UpdateAllDocuments(lObjPartner.Id, lObjMappedPartner.Id);
                        LocalBusinessPartnerService.Remove(lObjPartner.Id);
                    }
                }
            }
        }
Exemple #2
0
        private void ExportBusinessPartner(Partner pObjPartner)
        {
            SAPbobsCOM.BusinessPartners lObjCustomer = null;

            try
            {
                lObjCustomer              = SapBusinessPartnerService.GetBusinessPartnerObject();
                lObjCustomer.CardCode     = pObjPartner.Code;
                lObjCustomer.CardName     = pObjPartner.Name;
                lObjCustomer.FederalTaxID = pObjPartner.TaxCode;

                if (lObjCustomer.Add() == 0)
                {
                    pObjPartner.Temporary = false;
                    LocalBusinessPartnerService.SaveOrUpdate(pObjPartner);
                }
                else
                {
                    LogUtility.Write(string.Format("[ERROR] {0}", DIApplication.Company.GetLastErrorDescription()));
                }
            }
            catch (Exception lObjException)
            {
                LogUtility.Write(string.Format("[ERROR] {0}", lObjException.ToString()));
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjCustomer);
            }
        }
Exemple #3
0
        public void ImportCustomers()
        {
            IList <string> lLstStrLocalCardCodes = LocalBusinessPartnerService.GetList().Select(x => x.Code).ToList();

            foreach (string lStrCardCode in SapBusinessPartnerService.GetCardCodesList().Where(x => !lLstStrLocalCardCodes.Contains(x)))
            {
                ImportCustomer(lStrCardCode);
            }
        }
Exemple #4
0
 private void ImportCustomer(string pStrCardCode)
 {
     try
     {
         LocalBusinessPartnerService.SaveOrUpdate(GetBusinessPartnerByCode(pStrCardCode));
     }
     catch (Exception lObjException)
     {
         LogUtility.Write(string.Format("[ERROR] {0}", lObjException.ToString()));
     }
 }
Exemple #5
0
        private void UpdateCustomer(string pStrCardCode)
        {
            Partner lObjCurrentPartner = null;
            Partner lObjNewPartner     = null;

            try
            {
                lObjCurrentPartner = LocalBusinessPartnerService.GetList().FirstOrDefault(x => x.Code == pStrCardCode);
                lObjNewPartner     = GetBusinessPartnerByCode(pStrCardCode);

                lObjCurrentPartner.Name             = lObjNewPartner.Name;
                lObjCurrentPartner.ForeignName      = lObjNewPartner.ForeignName;
                lObjCurrentPartner.TaxCode          = lObjNewPartner.TaxCode;
                lObjCurrentPartner.PartnerStatus    = lObjNewPartner.PartnerStatus;
                lObjCurrentPartner.CreationDate     = lObjNewPartner.CreationDate;
                lObjCurrentPartner.ModificationDate = lObjNewPartner.ModificationDate;

                LocalBusinessPartnerService.SaveOrUpdate(lObjCurrentPartner);
            }
            catch (Exception lObjException)
            {
                LogUtility.Write(string.Format("[ERROR] {0}", lObjException.ToString()));
            }
        }
Exemple #6
0
 private bool CustomerHasChanges(CustomerDTO pObjCustomer)
 {
     return(LocalBusinessPartnerService.GetList().Where(x => x.Code == pObjCustomer.CardCode && x.ModificationDate != pObjCustomer.UpdateHour).Count() > 0 ? true : false);
 }
Exemple #7
0
 private bool CustomerHasBeenImported(string pStrCardCode)
 {
     return(LocalBusinessPartnerService.GetList().Where(x => x.Code == pStrCardCode).Count() > 0 ? true : false);
 }
Exemple #8
0
 private DateTime GetLastModificationDate()
 {
     return(LocalBusinessPartnerService.GetList().Where(b => !b.Temporary).Count() > 0 ?
            LocalBusinessPartnerService.GetList().Where(b => !b.Temporary).Max(x => x.CreationDate) : DateTime.Today.AddYears(-10));
 }