public void Sync(Model.Local.Customer Customer)
        {
            this.Semaphore.WaitOne();

            try
            {
                Model.Sage.F_COMPTETRepository F_COMPTETRepository = new Model.Sage.F_COMPTETRepository();
                if (F_COMPTETRepository.ExistId(Customer.Sag_Id))
                {
                    Model.Sage.F_COMPTET F_COMPTET = new Model.Sage.F_COMPTET();

                    F_COMPTET = F_COMPTETRepository.Read(Customer.Sag_Id);
                    if (F_COMPTET.F_COLLABORATEUR != null && F_COMPTET.F_COLLABORATEUR.CO_No.HasValue)
                    {
                        Model.Prestashop.PsAECRepresentativeRepository PsAECRepresentativeRepository = new Model.Prestashop.PsAECRepresentativeRepository();
                        if (PsAECRepresentativeRepository.ExistSage((uint)F_COMPTET.F_COLLABORATEUR.CO_No))
                        {
                            Model.Prestashop.PsAEcRepresentative PsAECRepresentative = PsAECRepresentativeRepository.ReadSage((uint)F_COMPTET.F_COLLABORATEUR.CO_No);

                            Model.Prestashop.PsAECRepresentativeCustomerRepository PsAECRepresentativeCustomerRepository = new Model.Prestashop.PsAECRepresentativeCustomerRepository();
                            Model.Prestashop.PsAEcRepresentativeCustomer           PsAEcRepresentativeCustomer           = new Model.Prestashop.PsAEcRepresentativeCustomer();

                            if (PsAECRepresentativeCustomerRepository.Exist((uint)Customer.Pre_Id))
                            {
                                PsAEcRepresentativeCustomer = PsAECRepresentativeCustomerRepository.Read((uint)Customer.Pre_Id);
                                PsAEcRepresentativeCustomer.IDRepresentative = PsAECRepresentative.IDRepresentative;
                                PsAECRepresentativeCustomerRepository.Save();
                            }
                            else
                            {
                                PsAEcRepresentativeCustomer                  = new Model.Prestashop.PsAEcRepresentativeCustomer();
                                PsAEcRepresentativeCustomer.IDCustomer       = (uint)Customer.Pre_Id;
                                PsAEcRepresentativeCustomer.IDRepresentative = PsAECRepresentative.IDRepresentative;
                                PsAECRepresentativeCustomerRepository.Add(PsAEcRepresentativeCustomer);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Core.Error.SendMailError(ex.ToString());
            }
            lock (this)
            {
                this.CurrentCount += 1;
            }
            this.ReportProgress(this.CurrentCount * 100 / this.ListCount);
            this.Semaphore.Release();
        }
 public void Add(PsAEcRepresentativeCustomer Obj)
 {
     this.DBPrestashop.PsAEcRepresentativeCustomer.InsertOnSubmit(Obj);
     this.Save();
 }