Beispiel #1
0
        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();
                    Model.Prestashop.PsAECCustomerPayementRepository PsAECPayementRepository = new Model.Prestashop.PsAECCustomerPayementRepository();
                    Model.Prestashop.PsAEcCustomerPayement           PsAEcPayement           = new Model.Prestashop.PsAEcCustomerPayement();
                    F_COMPTET = F_COMPTETRepository.Read(Customer.Sag_Id);
                    List <Model.Sage.F_REGLEMENTT> ListF_REGLEMENTT = new Model.Sage.F_REGLEMENTTRepository().ListCLient(F_COMPTET.CT_Num);

                    // <JG> 05/03/2015 ajout suppression de prestashop ni modèle n'existe plus dans Sage
                    IQueryable <Model.Prestashop.PsAEcCustomerPayement> ListCustomerPayement = PsAECPayementRepository.ListCustomer((uint)Customer.Pre_Id);

                    foreach (Model.Prestashop.PsAEcCustomerPayement PsAEcCustomerPayement in ListCustomerPayement)
                    {
                        if (ListF_REGLEMENTT.Count(rg => rg.cbMarq == (int)PsAEcCustomerPayement.IDSage) == 0)
                        {
                            PsAECPayementRepository.Delete(PsAEcCustomerPayement);
                        }
                    }

                    foreach (Model.Sage.F_REGLEMENTT F_REGLEMENTT in ListF_REGLEMENTT)
                    {
                        PsAEcPayement           = new Model.Prestashop.PsAEcCustomerPayement();
                        PsAECPayementRepository = new Model.Prestashop.PsAECCustomerPayementRepository();

                        if (PsAECPayementRepository.ExistCustomerPayement((uint)Customer.Pre_Id, (uint)F_REGLEMENTT.cbMarq))
                        {
                            PsAEcPayement          = PsAECPayementRepository.ReadCustomerPayement((uint)Customer.Pre_Id, (uint)F_REGLEMENTT.cbMarq);
                            PsAEcPayement.Payement = ReadPayement(F_REGLEMENTT.cbMarq);
                            PsAECPayementRepository.Save();
                        }
                        else
                        {
                            PsAEcPayement.IDCustomer = (uint)Customer.Pre_Id;
                            PsAEcPayement.IDSage     = (uint)F_REGLEMENTT.cbMarq;
                            PsAEcPayement.Payement   = ReadPayement(F_REGLEMENTT.cbMarq);
                            PsAECPayementRepository.Add(PsAEcPayement);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Core.Error.SendMailError(ex.ToString());
            }
            lock (this)
            {
                this.CurrentCount += 1;
            }
            this.ReportProgress(this.CurrentCount * 100 / this.ListCount);
            this.Semaphore.Release();
        }
Beispiel #2
0
        public void Delete(PsAEcCustomerPayement Obj)
        {
            String TxtSQL = "delete from ps_aec_customer_payement where id_customer = " + Obj.IDCustomer + " AND Sag_Id = " + Obj.IDSage;

            this.DBPrestashop.ExecuteCommand(TxtSQL);
            // not working ...
            //this.DBPrestashop.PsAEcCustomerPayement.DeleteOnSubmit(Obj);
        }
Beispiel #3
0
 public void Add(PsAEcCustomerPayement Obj)
 {
     this.DBPrestashop.PsAEcCustomerPayement.InsertOnSubmit(Obj);
     this.Save();
 }