public void Sync(Model.Sage.F_COLLABORATEUR F_COLLABORATEUR)
        {
            this.Semaphore.WaitOne();

            try
            {
                Model.Prestashop.PsAECRepresentativeRepository PsAECRepresentativeRepository = new Model.Prestashop.PsAECRepresentativeRepository();
                Model.Prestashop.PsAEcRepresentative           PsAECRepresentative;
                if (PsAECRepresentativeRepository.ExistSage((uint)F_COLLABORATEUR.CO_No))
                {
                    PsAECRepresentative = PsAECRepresentativeRepository.ReadSage((uint)F_COLLABORATEUR.CO_No);
                    Affect(F_COLLABORATEUR, PsAECRepresentative);
                    PsAECRepresentativeRepository.Save();
                }
                else
                {
                    PsAECRepresentative        = new Model.Prestashop.PsAEcRepresentative();
                    PsAECRepresentative.IDSage = (uint)F_COLLABORATEUR.CO_No;
                    Affect(F_COLLABORATEUR, PsAECRepresentative);
                    PsAECRepresentativeRepository.Add(PsAECRepresentative);
                }
            }
            catch (Exception ex)
            {
                Core.Error.SendMailError(ex.ToString());
            }
            lock (this)
            {
                this.CurrentCount += 1;
            }
            this.ReportProgress(this.CurrentCount * 100 / this.ListCount);
            this.Semaphore.Release();
        }
 private void Affect(Model.Sage.F_COLLABORATEUR F_COLLABORATEUR, Model.Prestashop.PsAEcRepresentative PsAECRepresentative)
 {
     PsAECRepresentative.LastName  = F_COLLABORATEUR.CO_Nom;
     PsAECRepresentative.FirstName = F_COLLABORATEUR.CO_Prenom;
     PsAECRepresentative.Email     = F_COLLABORATEUR.CO_EMail;
     PsAECRepresentative.Phone     = F_COLLABORATEUR.CO_Telephone;
     PsAECRepresentative.Mobile    = F_COLLABORATEUR.CO_TelPortable;
     PsAECRepresentative.Fax       = F_COLLABORATEUR.CO_Telecopie;
 }
        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(PsAEcRepresentative Obj)
 {
     this.DBPrestashop.PsAEcRepresentative.InsertOnSubmit(Obj);
     this.Save();
 }