public void Sync(Model.Local.Customer Customer) { this.Semaphore.WaitOne(); try { #region Module CustomerInfo if (Core.Global.ExistCustomerInfoModule()) { Model.Sage.F_COMPTETRepository F_COMPTETRepository = new Model.Sage.F_COMPTETRepository(); Model.Prestashop.PsCustomerRepository PsCustomerRepository = new Model.Prestashop.PsCustomerRepository(); if (F_COMPTETRepository.ExistId(Customer.Sag_Id) && PsCustomerRepository.ExistCustomer((uint)Customer.Pre_Id)) { Model.Sage.F_COMPTET F_COMPTET = F_COMPTETRepository.Read(Customer.Sag_Id); Model.Prestashop.PsCustomer PsCustomer = PsCustomerRepository.ReadCustomer((uint)Customer.Pre_Id); Core.Module.CustomerInfo gestioninfo = new Core.Module.CustomerInfo(); gestioninfo.Exec(F_COMPTET, PsCustomer); } } #endregion } 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 SearchCustomerBToB() { List <Model.Sage.F_COMPTET_BtoB> ListF_COMPTET = new Model.Sage.F_COMPTETRepository().ListBtoB((short)ABSTRACTION_SAGE.F_COMPTET.Obj._Enum_CT_Type.Client); if (!Core.Global.GetConfig().ConfigClientMultiMappageBtoB) { ListF_COMPTET = ListF_COMPTET.Where(s => Core.Temp.ListLocalCustomer.Count(l => l.Sag_Id == s.cbMarq) == 0).ToList(); } if (!string.IsNullOrWhiteSpace(this.TextBoxBTOBCustomerBegin.Text) || !string.IsNullOrWhiteSpace(this.TextBoxBTOBCustomerIntitule.Text) || !string.IsNullOrWhiteSpace(this.TextBoxBTOBCustomerEmail.Text)) { string intitule = this.TextBoxBTOBCustomerIntitule.Text.ToLower().Trim(); string mail = this.TextBoxBTOBCustomerEmail.Text.ToLower().Trim(); ListF_COMPTET = ListF_COMPTET.Where(s => s.CT_Num.StartsWith(this.TextBoxBTOBCustomerBegin.Text.ToUpper()) && s.CT_Intitule.ToLower().Contains(intitule) && (s.CT_EMail.ToLower().Contains(mail) || s.F_LIVRAISON().Count(l => l.LI_EMail.ToLower().Contains(mail)) > 0)).ToList(); } int count = ListF_COMPTET.Count; if (count > 500) { MessageBox.Show("Nombre de clients trouvés : " + count + ".\n\rVeuillez effectuer une recherche plus précise !", "Client", MessageBoxButton.OK); } else { this.listBoxBTOBCustomerSage.ItemsSource = ListF_COMPTET; } }
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(); }
public AECInvoiceHistory(DateTime?PeriodeDebut, DateTime?PeriodeFin, bool ClearMode = false) { this.InitializeComponent(); this._PeriodeDebut = PeriodeDebut; this._PeriodeFin = PeriodeFin; this._ClearMode = ClearMode; if (this._ClearMode) { this.LabelOperation.Content = "Nettoyage des données !"; } this.ProgressBar.ToolTip = "Nombre de coeurs processeurs utilisés : " + MaximumThreadCount; // récupération de la liste des comptes client mappés Model.Local.CustomerRepository CustomerRepository = new Model.Local.CustomerRepository(); List <Model.Local.Customer> ListCustomer = CustomerRepository.List(); // récupération de la liste des comptes Sage existants Model.Sage.F_COMPTETRepository F_COMPTETRepository = new Model.Sage.F_COMPTETRepository(); //List<int> ListSage = F_COMPTETRepository.ListIdTypeSommeil((short)ABSTRACTION_SAGE.F_COMPTET.Obj._Enum_CT_Type.Client, (short)ABSTRACTION_SAGE.F_COMPTET.Obj._Enum_Boolean.Non); List <Model.Sage.F_COMPTET_Light> ListSage = F_COMPTETRepository.ListLight((short)ABSTRACTION_SAGE.F_COMPTET.Obj._Enum_CT_Type.Client, (short)ABSTRACTION_SAGE.F_COMPTET.Obj._Enum_Boolean.Non); // filtrage des comptes qui sont centralisés ListCustomer = ListCustomer.Where(c => ListSage.Count(s => s.cbMarq == c.Sag_Id) == 1).ToList(); // filtres clients de l'interface if (Core.Global.UILaunch) { if (!string.IsNullOrWhiteSpace(Core.Temp.ModuleAECInvoiceHistory_Numero)) { Core.Temp.LoadF_COMPTET_BtoBIfEmpty(); ListCustomer = ListCustomer.Where(c => c.Sag_Numero.StartsWith(Core.Temp.ModuleAECInvoiceHistory_Numero)).ToList(); } if (!string.IsNullOrWhiteSpace(Core.Temp.ModuleAECInvoiceHistory_Intitule)) { Core.Temp.LoadF_COMPTET_BtoBIfEmpty(); ListCustomer = ListCustomer.Where(c => c.Sag_Name.ToLower().Contains(Core.Temp.ModuleAECInvoiceHistory_Intitule.ToLower())).ToList(); } } this.ListCount = ListCustomer.Count; Context = SynchronizationContext.Current; this.ParallelOptions.MaxDegreeOfParallelism = MaximumThreadCount; this.ReportProgress(0); Task.Factory.StartNew(() => { Parallel.ForEach(ListCustomer, this.ParallelOptions, Exec); }); }
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 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) { Model.Prestashop.PsAECCustomerCollaborateurRepository PsAECCollaborateurRepository = new Model.Prestashop.PsAECCustomerCollaborateurRepository(); Model.Prestashop.PsAEcCustomerCollaborateur PsAEcCollaborateur = new Model.Prestashop.PsAEcCustomerCollaborateur(); if (PsAECCollaborateurRepository.ExistCollaborateur((uint)Customer.Pre_Id)) { PsAEcCollaborateur = PsAECCollaborateurRepository.ReadCollaborateur((uint)Customer.Pre_Id); PsAEcCollaborateur.NomCollaborateur = F_COMPTET.F_COLLABORATEUR.CO_Nom; PsAEcCollaborateur.PrenomCollaborateur = F_COMPTET.F_COLLABORATEUR.CO_Prenom; PsAEcCollaborateur.TelephoneCollaborateur = F_COMPTET.F_COLLABORATEUR.CO_Telephone; PsAECCollaborateurRepository.Save(); } else { PsAEcCollaborateur = new Model.Prestashop.PsAEcCustomerCollaborateur(); PsAEcCollaborateur.IDCustomer = (uint)Customer.Pre_Id; PsAEcCollaborateur.NomCollaborateur = F_COMPTET.F_COLLABORATEUR.CO_Nom; PsAEcCollaborateur.PrenomCollaborateur = F_COMPTET.F_COLLABORATEUR.CO_Prenom; PsAEcCollaborateur.TelephoneCollaborateur = F_COMPTET.F_COLLABORATEUR.CO_Telephone; PsAECCollaborateurRepository.Add(PsAEcCollaborateur); } } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } lock (this) { this.CurrentCount += 1; } this.ReportProgress(this.CurrentCount * 100 / this.ListCount); this.Semaphore.Release(); }
public ImportSageFournisseur() { this.InitializeComponent(); Model.Sage.F_COMPTETRepository F_COMPTETRepository = new Model.Sage.F_COMPTETRepository(); List <Int32> ListF_COMPTET = F_COMPTETRepository.ListIdType(1); this.ListCount = ListF_COMPTET.Count; Context = SynchronizationContext.Current; this.ParallelOptions.MaxDegreeOfParallelism = MaximumThreadCount; this.ReportProgress(0); Task.Factory.StartNew(() => { Parallel.ForEach(ListF_COMPTET, this.ParallelOptions, Sync); }); }
private void LoadComboBoxFournisseur() { Core.Temp.ListSupplier = new Model.Local.SupplierRepository().List(); //this.ListBoxFournisseur.Items.Clear(); Model.Sage.F_COMPTETRepository F_COMPTETRepository = new Model.Sage.F_COMPTETRepository(); List <Model.Sage.F_COMPTET> List = F_COMPTETRepository.ListTypeSommeil(1, 0); List = List.Where(frs => frs.F_ARTFOURNISS != null && frs.F_ARTFOURNISS.Count > 0).ToList(); this.ListBoxFournisseur.ItemsSource = List; //foreach (Model.Sage.F_COMPTET F_COMPTET in List) //{ // this.ListBoxFournisseur.Items.Add(F_COMPTET.cbMarq + " - " + F_COMPTET.CT_Intitule); //} }
private void DataGridBTOBCustomerButtonDelete_Click(object sender, RoutedEventArgs e) { Model.Local.Customer Customer = this.DataGridCustomerBTOB.SelectedItem as Model.Local.Customer; Model.Local.CustomerRepository CustomerRepository = new Model.Local.CustomerRepository(); bool delete = false; if (CustomerRepository.ExistPrestashopSage(Customer.Pre_Id, Customer.Sag_Id)) { Model.Sage.F_COMPTETRepository F_COMPTETRepository = new Model.Sage.F_COMPTETRepository(); if (F_COMPTETRepository.ExistId(Customer.Sag_Id) == false) { delete = true; } else if (MessageBox.Show("Êtes-vous sûr de vouloir supprimer le mappage entre le compte PrestaShop : " + Customer.Pre_Name + "\n" + "et le compte Sage : " + Customer.Sag_Name + " ?", "Suppression mappage", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { delete = true; } //else //{ // MessageBox.Show("Votre client Prestashop a déjà été synchronisé. \n Pour pouvoir le supprimer, il faut préalablement supprimer le compte Sage associé : " + Customer.Sag_Name, "Client", MessageBoxButton.OK, MessageBoxImage.Exclamation); //} if (delete) { Model.Local.Customer CustomerDelete = CustomerRepository.ReadPrestashopSage(Customer.Pre_Id, Customer.Sag_Id); CustomerRepository.Delete(CustomerDelete); // suppression mappage adresse Model.Sage.F_LIVRAISONRepository F_LIVRAISONRepository = new Model.Sage.F_LIVRAISONRepository(); Model.Local.AddressRepository AddressRepository = new Model.Local.AddressRepository(); foreach (Model.Sage.F_LIVRAISON F_LIVRAISON in F_LIVRAISONRepository.ListComptet(Customer.Sag_Numero)) { if (AddressRepository.ExistSage(F_LIVRAISON.cbMarq)) { AddressRepository.Delete(AddressRepository.ReadSage(F_LIVRAISON.cbMarq)); } } this.RefreshBtoB(); } } }
public void Sync(Model.Local.Customer Customer) { this.Semaphore.WaitOne(); try { Model.Prestashop.PsCustomerRepository PsCustomerRepository = new Model.Prestashop.PsCustomerRepository(); Model.Sage.F_COMPTETRepository F_COMPTETRepository = new Model.Sage.F_COMPTETRepository(); if (F_COMPTETRepository.ExistId(Customer.Sag_Id) && PsCustomerRepository.ExistCustomer((uint)Customer.Pre_Id)) { Model.Sage.F_COMPTET F_COMPTET = F_COMPTETRepository.Read(Customer.Sag_Id); Model.Prestashop.PsCustomer PsCustomer = PsCustomerRepository.ReadCustomer((uint)Customer.Pre_Id); Model.Local.Employee_CollaborateurRepository Employee_CollaborateurRepository = new Model.Local.Employee_CollaborateurRepository(); Model.Prestashop.PsEmployeeRepository PsEmployeeRepository = new Model.Prestashop.PsEmployeeRepository(); Model.Prestashop.PsPortfolioCustomerEmployeeRepository PsPortfolioCustomerEmployeeRepository = new Model.Prestashop.PsPortfolioCustomerEmployeeRepository(); if (F_COMPTET.CO_No == null) { lock (this.logs) logs.Add("SP30- Le client [ " + F_COMPTET.NumIntitule + " ] ne possède pas de collaborateur dans Sage !"); } else if (!Employee_CollaborateurRepository.ExistCollaborateur((int)F_COMPTET.CO_No)) { lock (this.logs) logs.Add("SP40- Aucun compte employé PrestaShop affecté au collaborateur du client [ " + F_COMPTET.NumIntitule + " ]"); if (PsPortfolioCustomerEmployeeRepository.ExistCustomer(PsCustomer.IDCustomer)) { List <Model.Prestashop.PsPortfolioCustomerEmployee> ListPsPortfolioCustomerEmployee = PsPortfolioCustomerEmployeeRepository.ListCustomer(PsCustomer.IDCustomer); foreach (Model.Prestashop.PsPortfolioCustomerEmployee PsPortfolioCustomerEmployee in ListPsPortfolioCustomerEmployee) { if (PsPortfolioCustomerEmployee.IDEmployee != null) { string name = (PsEmployeeRepository.Exist(PsPortfolioCustomerEmployee.IDEmployee.Value)) ? PsEmployeeRepository.Read(PsPortfolioCustomerEmployee.IDEmployee.Value).EmployeeName : string.Empty; PsPortfolioCustomerEmployeeRepository.Delete(PsPortfolioCustomerEmployee); lock (this.logs) logs.Add("SP12- Détachement du compte employé [" + (!string.IsNullOrWhiteSpace(name) ? name : PsPortfolioCustomerEmployee.IDEmployee.Value.ToString()) + "] pour le client Sage [ " + F_COMPTET.NumIntitule + " ] / PrestaShop ID : " + PsCustomer.IDCustomer); } } } } else { uint IdEmployee = (uint)Employee_CollaborateurRepository.ReadCollaborateur((int)F_COMPTET.CO_No).IdEmployee; List <Model.Prestashop.PsPortfolioCustomerEmployee> ListPsPortfolioCustomerEmployee = PsPortfolioCustomerEmployeeRepository.ListCustomer(PsCustomer.IDCustomer); if (ListPsPortfolioCustomerEmployee.Count(pce => pce.IDEmployee != IdEmployee) > 0) { foreach (Model.Prestashop.PsPortfolioCustomerEmployee PsPortfolioCustomerEmployee in ListPsPortfolioCustomerEmployee.Where(pce => pce.IDEmployee != IdEmployee)) { if (PsPortfolioCustomerEmployee.IDEmployee != null) { string name = (PsEmployeeRepository.Exist(PsPortfolioCustomerEmployee.IDEmployee.Value)) ? PsEmployeeRepository.Read(PsPortfolioCustomerEmployee.IDEmployee.Value).EmployeeName : string.Empty; PsPortfolioCustomerEmployeeRepository.Delete(PsPortfolioCustomerEmployee); lock (this.logs) logs.Add("SP11- Détachement du compte employé [" + (!string.IsNullOrWhiteSpace(name) ? name : PsPortfolioCustomerEmployee.IDEmployee.Value.ToString()) + "] pour le client Sage [ " + F_COMPTET.NumIntitule + " ] / PrestaShop ID : " + PsCustomer.IDCustomer); } } } if (IdEmployee == 0) { lock (this.logs) logs.Add("SP50- Aucun compte employé PrestaShop affecté au collaborateur du client [ " + F_COMPTET.NumIntitule + " ]"); } else if (PsPortfolioCustomerEmployeeRepository.Exist(PsCustomer.IDCustomer, IdEmployee) == false) { if (PsEmployeeRepository.Exist(IdEmployee)) { PsPortfolioCustomerEmployeeRepository.Add(new Model.Prestashop.PsPortfolioCustomerEmployee() { IDCustomer = PsCustomer.IDCustomer, IDEmployee = IdEmployee, }); string name = (PsEmployeeRepository.Exist(IdEmployee)) ? PsEmployeeRepository.Read(IdEmployee).EmployeeName : string.Empty; lock (this.logs) logs.Add("SP10- Rattachement au compte employé [" + (!string.IsNullOrWhiteSpace(name) ? name : IdEmployee.ToString()) + "] pour le client Sage [ " + F_COMPTET.NumIntitule + " ] / PrestaShop ID : " + PsCustomer.IDCustomer); } else { lock (this.logs) logs.Add("SP60- Le compte employé affecté au collaborateur du client [ " + F_COMPTET.NumIntitule + " ] est invalide"); } } } } } catch (Exception ex) { lock (this.logs) logs.Add("SC20- Erreur affecation client/employé : " + ex.ToString()); Core.Error.SendMailError("[SP20] " + ex.ToString()); } lock (this) { this.CurrentCount += 1; } this.ReportProgress(this.CurrentCount * 100 / this.ListCount); this.Semaphore.Release(); }
// <JG> 06/09/2012 ajout filtre de recherche // <JG> 28/02/2013 modification transfert client avec utilisation des paramètre de la fonctionnalité automatique private void ButtonSearchSageToPrestashop_Click(object sender, RoutedEventArgs e) { this.CBClientSage.ItemsSource = new List <Model.Sage.F_COMPTET_Light>(); // <JG> 04/12/2012 Correction utilisation des champs de recherche if (this.CbGroupeClient.SelectedItem != null) { //this.CBClientSage.Items.Clear(); this.IsEnabled = false; Mouse.OverrideCursor = Cursors.Wait; Model.Sage.F_COMPTETRepository F_COMPTETRepository = new Model.Sage.F_COMPTETRepository(); List <Model.Sage.F_COMPTET_Light> ListF_COMPTET; ListF_COMPTET = F_COMPTETRepository.ListLight(0, 0); if (this.TextBoxSageToPrestashopNumero.Text.ToUpper() != "") { ListF_COMPTET = ListF_COMPTET.Where(s => s.CT_Num.StartsWith(this.TextBoxSageToPrestashopNumero.Text.ToUpper())).ToList(); } //// <JG> 26/12/2012 ajout filtre catégorie tarifaire //Model.Local.GroupRepository GroupRepository = new Model.Local.GroupRepository(); //if (GroupRepository.ListCatTarifSage().Count > 0) //{ // List<Model.Sage.F_COMPTET> temp = new List<Model.Sage.F_COMPTET>(); // foreach (Int32 CatTarifID in GroupRepository.ListCatTarifSage()) // { // temp.AddRange(ListF_COMPTET.Where(c => c.N_CatTarif == CatTarifID)); // ListF_COMPTET.RemoveAll(c => c.N_CatTarif == CatTarifID); // } // ListF_COMPTET = temp; // <JG> 19/02/2013 correction filtrage des clients sur le groupe sélectionné if (((Model.Local.Group) this.CbGroupeClient.SelectedItem).Grp_CatTarifId != null) { ListF_COMPTET = ListF_COMPTET.Where(c => c.N_CatTarif == (int)((Model.Local.Group) this.CbGroupeClient.SelectedItem).Grp_CatTarifId).ToList(); // <JG> 06/09/2012 ajout filtre sur l'intitulé if (this.TextBoxSageToPrestashopIntitule.Text != null && this.TextBoxSageToPrestashopIntitule.Text.ToUpper().Trim() != "") { ListF_COMPTET = ListF_COMPTET.Where(cpt => cpt.CT_Intitule.ToUpper().Contains(this.TextBoxSageToPrestashopIntitule.Text.ToUpper().Trim())).ToList(); } //ListF_COMPTET = ListF_COMPTET.Where(cpt => cpt.CT_EMail != null && cpt.CT_EMail.Trim() != "").ToList(); ListF_COMPTET = ListF_COMPTET.Where(cpt => cpt.CT_EMail.Trim() != "" || cpt.F_LIVRAISON_Principale().Count(a => a.LI_EMail != "") > 0).ToList(); List <Model.Local.Customer> LocalCustomer = new Model.Local.CustomerRepository().List(); ListF_COMPTET = ListF_COMPTET.Where(s => LocalCustomer.Count(l => l.Sag_Id == s.cbMarq) == 0).ToList(); if (ListF_COMPTET.Count == 0) { if (sender != this.BtTransfert) { MessageBox.Show("Aucun client dans le résultat de votre recherche !", "", MessageBoxButton.OK, MessageBoxImage.Information); } } else if (ListF_COMPTET.Count <= 200) { Model.Local.CustomerRepository CustomerRepository = new Model.Local.CustomerRepository(); Model.Sage.F_LIVRAISONRepository F_LIVRAISONRepository = new Model.Sage.F_LIVRAISONRepository(); this.CBClientSage.ItemsSource = ListF_COMPTET; //foreach (Model.Sage.F_COMPTET_Light F_COMPTET in ListF_COMPTET) // if (CustomerRepository.ExistSage(F_COMPTET.cbMarq) == false) // && F_LIVRAISONRepository.ExistComptetPrincipal(F_COMPTET.CT_Num, 1)) // this.CBClientSage.Items.Add(F_COMPTET.ComboText); } else { MessageBox.Show("Le nombre de résultats de la recherche est trop important, veuillez préciser d'avantage votre recherche !", "", MessageBoxButton.OK, MessageBoxImage.Information); } } Mouse.OverrideCursor = Cursors.Arrow; this.IsEnabled = true; } else { MessageBox.Show("Veuillez sélectionner un groupe de client !", "Groupe de client", MessageBoxButton.OK, MessageBoxImage.Stop); } }
private void LoadComponent() { // <JG> 26/12/2012 this.CbGroupeClient.ItemsSource = new Model.Local.GroupRepository().ListGroupesLies(); this.ButtonOustanding.IsEnabled = Core.Global.GetConfig().ModuleAECCustomerOutstandingActif; if (Core.Global.GetConfig().ConfigBToB) { this.TabItemClientBToB.IsEnabled = true; this.TabItemClientBToC.IsEnabled = false; this.TabItemClientBToB.IsSelected = true; this.GroupBoxSageCustomer.Header = (Core.Global.GetConfig().ConfigClientMultiMappageBtoB) ? "Client(s) Sage" : "Client(s) Sage non mappé(s)"; this.LoadBTOBCustomer(); } else if (Core.Global.GetConfig().ConfigBToC) { this.TabItemClientBToC.IsEnabled = true; this.TabItemClientBToB.IsEnabled = false; this.TabItemClientBToC.IsSelected = true; Model.Prestashop.PsCustomerRepository PsCustomerRepository = new Model.Prestashop.PsCustomerRepository(); this.DataGridClient.ItemsSource = (Core.Global.GetConfig().ConfigClientFiltreCommande) ? PsCustomerRepository.ListTopActiveOrderByDateAdd(60, 1, Core.Global.CurrentShop.IDShop) : PsCustomerRepository.ListTopActiveOrderByDateAddWithOrder(60, 1, Core.Global.CurrentShop.IDShop); this.TabItemClientBToB.IsEnabled = false; #region centralisation clients Model.Local.Config Config = new Model.Local.Config(); Model.Local.ConfigRepository ConfigRepository = new Model.Local.ConfigRepository(); if (ConfigRepository.ExistName(Core.Global.ConfigClientTypeLien) && ConfigRepository.ReadName(Core.Global.ConfigClientTypeLien).Con_Value == Core.Global.ConfigClientTypeLienEnum.CompteCentralisateur.ToString()) { if (ConfigRepository.ExistName(Core.Global.ConfigClientCompteCentralisateur)) { Config = ConfigRepository.ReadName(Core.Global.ConfigClientCompteCentralisateur); if (Core.Global.IsInteger(Config.Con_Value)) { Int32 cbMarqCentralisateur = Int32.Parse(Config.Con_Value); Model.Sage.F_COMPTETRepository F_COMPTETRepositoryCentralisateur = new Model.Sage.F_COMPTETRepository(); Model.Sage.F_COMPTET F_COMPTETCentralisateur; if (F_COMPTETRepositoryCentralisateur.ExistId(cbMarqCentralisateur)) { F_COMPTETCentralisateur = F_COMPTETRepositoryCentralisateur.Read(cbMarqCentralisateur); this.LabelClientCentralisateur.Content = "Commandes et adresses des clients Prestashop centralisées vers le compte Sage " + F_COMPTETCentralisateur.CT_Num + " " + F_COMPTETCentralisateur.CT_Intitule; } } } } #endregion } else { this.BtTransfert.IsEnabled = false; } LoadModules(); }
public void Exec(Model.Local.Customer CustomerSend) { this.Semaphore.WaitOne(); int invoice_count_transfert = 0; bool send_mail_notif = false; Model.Prestashop.PsOrders MailDatas = new Model.Prestashop.PsOrders(); try { Model.Prestashop.PsCustomerRepository PsCustomerRepository = new Model.Prestashop.PsCustomerRepository(); uint IDCustomer = (uint)CustomerSend.Pre_Id; if (PsCustomerRepository.ExistCustomer(IDCustomer)) { MailDatas.IDCustomer = IDCustomer; Model.Sage.F_COMPTETRepository F_COMPTETRepository = new Model.Sage.F_COMPTETRepository(); Model.Sage.F_COMPTET F_COMPTET = F_COMPTETRepository.Read(CustomerSend.Sag_Id); if (F_COMPTET != null) { // <JG> 03/08/2017 gestion rafraichissement progression Model.Local.Customer_Progress datas_progress = new Model.Local.Customer_Progress() { CT_Num = F_COMPTET.CT_Num, CT_Intitule = F_COMPTET.CT_Intitule, Comment = string.Empty, }; ReportInfosSynchro(datas_progress, Core.Temp._action_information_synchro.debut); Model.Sage.F_DOCENTETERepository F_DOCENTETERepository = new Model.Sage.F_DOCENTETERepository(); // <JG> 22/01/2016 send_mail_notif = (!string.IsNullOrWhiteSpace(Core.Global.GetConfig().ModuleAECInvoiceHistoryInfoLibreClientSendMail) && F_COMPTETRepository.ExistArticleInformationLibreText(Core.Global.GetConfig().ModuleAECInvoiceHistoryInfoLibreClientSendMail, F_COMPTET.CT_Num) && F_COMPTETRepository.ReadArticleInformationLibreText(Core.Global.GetConfig().ModuleAECInvoiceHistoryInfoLibreClientSendMail, F_COMPTET.CT_Num) == Core.Global.GetConfig().ModuleAECInvoiceHistoryInfoLibreClientSendMailValue); Model.Prestashop.PsAECInvoiceHistoryRepository PsAECInvoiceHistoryRepository = new Model.Prestashop.PsAECInvoiceHistoryRepository(); // <JG> 04/03/2015 ajout gestion envoi des bons de commandes Sage dans PrestaShop string order_path = System.IO.Path.Combine(Core.Global.GetConfig().Folders.RootReport, "AEC_Order.rpt"); if (System.IO.File.Exists(order_path)) { uint TypeDocOrder = (uint)ABSTRACTION_SAGE.F_DOCENTETE.Obj._Enum_DO_Type.Bon_Commande_Vente; datas_progress.Comment = GetComment(TypeDocOrder); ReportInfosSynchro(datas_progress, Core.Temp._action_information_synchro.refresh); ClearData(PsAECInvoiceHistoryRepository, IDCustomer, TypeDocOrder); if (!_ClearMode) { datas_progress.Comment = GetComment(TypeDocOrder); ReportInfosSynchro(datas_progress, Core.Temp._action_information_synchro.refresh); List <Model.Sage.Piece> ListBC = F_DOCENTETERepository.ListPieceTiers(F_COMPTET.CT_Num, ABSTRACTION_SAGE.F_DOCENTETE.Obj._Enum_DO_Domaine.Vente, ABSTRACTION_SAGE.F_DOCENTETE.Obj._Enum_DO_Type.Bon_Commande_Vente, this._PeriodeDebut, this._PeriodeFin); foreach (Model.Sage.Piece Piece in ListBC) { TransfertPiece(order_path, PsAECInvoiceHistoryRepository, Piece, IDCustomer, TypeDocOrder, F_COMPTET.CT_Num); datas_progress.Comment = Piece.DO_Piece + " " + ListBC.IndexOf(Piece) + "/" + ListBC.Count; ReportInfosSynchro(datas_progress, Core.Temp._action_information_synchro.refresh); } } } string invoice_path = System.IO.Path.Combine(Core.Global.GetConfig().Folders.RootReport, "AEC_Invoice.rpt"); if (System.IO.File.Exists(invoice_path)) { uint TypeDocInvoice = (uint)ABSTRACTION_SAGE.F_DOCENTETE.Obj._Enum_DO_Type.Facture_Comptabilisee_Vente; if (!_ClearMode) { datas_progress.Comment = GetComment(TypeDocInvoice); ReportInfosSynchro(datas_progress, Core.Temp._action_information_synchro.refresh); List <Model.Sage.Piece> ListFacturesCompta = F_DOCENTETERepository.ListPieceTiers(F_COMPTET.CT_Num, ABSTRACTION_SAGE.F_DOCENTETE.Obj._Enum_DO_Domaine.Vente, ABSTRACTION_SAGE.F_DOCENTETE.Obj._Enum_DO_Type.Facture_Comptabilisee_Vente, this._PeriodeDebut, this._PeriodeFin); List <Model.Prestashop.PsAEcInvoiceHistory_Light> ListTransfert = PsAECInvoiceHistoryRepository.ListLight(IDCustomer, TypeDocInvoice); ListFacturesCompta = ListFacturesCompta.Where(d => ListTransfert.Count(i => i.invoice_number == d.DO_Piece) == 0).ToList(); foreach (Model.Sage.Piece Piece in ListFacturesCompta) { if (TransfertPiece(invoice_path, PsAECInvoiceHistoryRepository, Piece, IDCustomer, TypeDocInvoice, F_COMPTET.CT_Num)) { invoice_count_transfert++; if (string.IsNullOrEmpty(MailDatas.Mail_Invoice_numbers)) { MailDatas.Mail_Invoice_numbers = Piece.DO_Piece; } else { MailDatas.Mail_Invoice_numbers += ", " + Piece.DO_Piece; } } datas_progress.Comment = Piece.DO_Piece + " " + ListFacturesCompta.IndexOf(Piece) + "/" + ListFacturesCompta.Count; ReportInfosSynchro(datas_progress, Core.Temp._action_information_synchro.refresh); } } else { datas_progress.Comment = GetComment(TypeDocInvoice); ReportInfosSynchro(datas_progress, Core.Temp._action_information_synchro.refresh); ClearData(PsAECInvoiceHistoryRepository, IDCustomer, TypeDocInvoice); } } ReportInfosSynchro(datas_progress, Core.Temp._action_information_synchro.fin); } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } // <JG> 22/01/2016 ajout mail notification try { if (send_mail_notif && invoice_count_transfert > 0) { Core.Sync.SynchronisationCommande.SendMail(40, MailDatas); } } 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 Sync(Model.Local.Customer Customer) { this.Semaphore.WaitOne(); try { Model.Prestashop.PsCustomerRepository PsCustomerRepository = new Model.Prestashop.PsCustomerRepository(); Model.Prestashop.PsCustomerGroupRepository PsCustomerGroupRepository = new Model.Prestashop.PsCustomerGroupRepository(); Model.Sage.F_COMPTETRepository F_COMPTETRepository = new Model.Sage.F_COMPTETRepository(); if (F_COMPTETRepository.ExistId(Customer.Sag_Id) && PsCustomerRepository.ExistCustomer((uint)Customer.Pre_Id)) { Model.Sage.F_COMPTET F_COMPTET = F_COMPTETRepository.Read(Customer.Sag_Id); Model.Prestashop.PsCustomer PsCustomer = PsCustomerRepository.ReadCustomer((uint)Customer.Pre_Id); Model.Local.GroupRepository GroupRepository = new Model.Local.GroupRepository(); if (GroupRepository.CatTarifSageMonoGroupe((int)F_COMPTET.N_CatTarif)) { uint IdPsGroup = (uint)GroupRepository.SearchIdGroupCatTarifSage((int)F_COMPTET.N_CatTarif); if (IdPsGroup != PsCustomer.IDDefaultGroup) { uint old_group = PsCustomer.IDDefaultGroup; PsCustomer.IDDefaultGroup = IdPsGroup; PsCustomerRepository.Save(); lock (this.logs) logs.Add("SG10- Modification du groupe pour le client [ " + PsCustomer.IDCustomer + " - " + PsCustomer.LastName + " " + PsCustomer.FirstName + " ]"); if (PsCustomerGroupRepository.Exist(PsCustomer.IDCustomer, IdPsGroup) == false) { PsCustomerGroupRepository.Add(new Model.Prestashop.PsCustomerGroup() { IDCustomer = PsCustomer.IDCustomer, IDGroup = IdPsGroup, }); } // détachement ancien groupe if (PsCustomerGroupRepository.Exist(PsCustomer.IDCustomer, old_group)) { PsCustomerGroupRepository.Delete(PsCustomer.IDCustomer, old_group); } } } //else if (GroupRepository.ExistCatTarif((int)F_COMPTET.N_CatTarif) == false) //{ // PsCustomer.Active = 0; // PsCustomerRepository.Save(); // logs.Add("SG10- La catégorie tarifaire n'a pas de lien avec un groupe. Désactivation du compte client [ " + PsCustomer.IDCustomer + " - " + PsCustomer.LastName + " " + PsCustomer.FirstName + " ]"); //} } } catch (Exception ex) { lock (this.logs) logs.Add("SG20- Erreur synchronisation groupe/catégorie tarifaire : " + ex.ToString()); Core.Error.SendMailError("[SG20] " + ex.ToString()); } lock (this) { this.CurrentCount += 1; } this.ReportProgress(this.CurrentCount * 100 / this.ListCount); this.Semaphore.Release(); }
public void Sync(Model.Local.Customer Customer) { this.Semaphore.WaitOne(); try { Model.Prestashop.PsCustomerRepository PsCustomerRepository = new Model.Prestashop.PsCustomerRepository(); Model.Prestashop.PsCustomerGroupRepository PsCustomerGroupRepository = new Model.Prestashop.PsCustomerGroupRepository(); Model.Sage.F_COMPTETRepository F_COMPTETRepository = new Model.Sage.F_COMPTETRepository(); Model.Prestashop.PsGroupLangRepository PsGroupLangRepository = new Model.Prestashop.PsGroupLangRepository(); Model.Prestashop.PsGroupRepository PsGroupRepository = new Model.Prestashop.PsGroupRepository(); if (F_COMPTETRepository.ExistId(Customer.Sag_Id) && PsCustomerRepository.ExistCustomer((uint)Customer.Pre_Id)) { Model.Sage.F_COMPTET F_COMPTET = F_COMPTETRepository.Read(Customer.Sag_Id); Model.Prestashop.PsCustomer PsCustomer = PsCustomerRepository.ReadCustomer((uint)Customer.Pre_Id); Model.Local.Group_CRisqueRepository Group_CRisqueRepository = new Model.Local.Group_CRisqueRepository(); if (F_COMPTET.N_Risque == null) { lock (this.logs) logs.Add("SC30- Le client [ " + F_COMPTET.NumIntitule + " ] ne possède pas de code risque dans Sage !"); } else if (!Group_CRisqueRepository.ExistCRisque((int)F_COMPTET.N_Risque)) { lock (this.logs) logs.Add("SC40- Aucun groupe affecté au code risque du client [ " + F_COMPTET.NumIntitule + " ]"); } else { Model.Local.Group_CRisque Group_CRisque = Group_CRisqueRepository.ReadCRisque((int)F_COMPTET.N_Risque); if (F_COMPTET.CT_ControlEnc != null && F_COMPTET.CT_ControlEnc == (short)ABSTRACTION_SAGE.F_COMPTET.Obj._Enum_CT_ControlEnc.Compte_Bloque && Group_CRisque.Grp_LockCondition) { // si compte bloqué dans Sage et indication à PrestaConnect de détacher le client uint IdPsGroup = (uint)Group_CRisque.Grp_Pre_Id; if (PsCustomerGroupRepository.Exist(PsCustomer.IDCustomer, IdPsGroup)) { PsCustomerGroupRepository.Delete(PsCustomer.IDCustomer, IdPsGroup); string name = PsGroupLangRepository.Read(Core.Global.Lang, IdPsGroup).Name; lock (this.logs) logs.Add("SC11- Détachement du groupe [" + (!string.IsNullOrWhiteSpace(name) ? name : IdPsGroup.ToString()) + "] pour le client Sage [ " + F_COMPTET.NumIntitule + " ] / PrestaShop ID : " + PsCustomer.IDCustomer); } uint IdDefaultGroup = (uint)Group_CRisque.Grp_PreId_Default; if (PsGroupRepository.ExistGroup((int)IdDefaultGroup) && PsCustomerGroupRepository.Exist(PsCustomer.IDCustomer, IdDefaultGroup) == false) { PsCustomerGroupRepository.Add(new Model.Prestashop.PsCustomerGroup() { IDCustomer = PsCustomer.IDCustomer, IDGroup = IdDefaultGroup, }); string name = PsGroupLangRepository.Read(Core.Global.Lang, IdDefaultGroup).Name; lock (this.logs) logs.Add("SC12- Rattachement au groupe par défaut [" + (!string.IsNullOrWhiteSpace(name) ? name : IdDefaultGroup.ToString()) + "] pour le client Sage [ " + F_COMPTET.NumIntitule + " ] / PrestaShop ID : " + PsCustomer.IDCustomer); } // si groupe du code risque défini par défaut sur le client - rattachement au groupe défaut du code risque if (IdPsGroup == PsCustomer.IDDefaultGroup) { PsCustomer.IDDefaultGroup = IdDefaultGroup; PsCustomerRepository.Save(); } } else { uint IdPsGroup = (uint)Group_CRisque.Grp_Pre_Id; if (PsCustomerGroupRepository.Exist(PsCustomer.IDCustomer, IdPsGroup) == false) { if (PsGroupRepository.ExistGroup((int)IdPsGroup)) { //uint old_group = PsCustomer.IDDefaultGroup; //PsCustomer.IDDefaultGroup = IdPsGroup; //PsCustomerRepository.Save(); if (PsCustomerGroupRepository.Exist(PsCustomer.IDCustomer, IdPsGroup) == false) { PsCustomerGroupRepository.Add(new Model.Prestashop.PsCustomerGroup() { IDCustomer = PsCustomer.IDCustomer, IDGroup = IdPsGroup, }); string name = PsGroupLangRepository.Read(Core.Global.Lang, IdPsGroup).Name; lock (this.logs) logs.Add("SC10- Rattachement au groupe [" + (!string.IsNullOrWhiteSpace(name) ? name : IdPsGroup.ToString()) + "] pour le client Sage [ " + F_COMPTET.NumIntitule + " ] / PrestaShop ID : " + PsCustomer.IDCustomer); } // détachement ancien groupe //if (PsCustomerGroupRepository.Exist(PsCustomer.IDCustomer, old_group)) // PsCustomerGroupRepository.Delete(PsCustomer.IDCustomer, old_group); } else { lock (this.logs) logs.Add("SC50- Le groupe affecté au code risque du client [ " + F_COMPTET.NumIntitule + " ] est invalide"); } } } } } } catch (Exception ex) { lock (this.logs) logs.Add("SC20- Erreur synchronisation groupe/code risque : " + ex.ToString()); Core.Error.SendMailError("[SC20] " + ex.ToString()); } lock (this) { this.CurrentCount += 1; } this.ReportProgress(this.CurrentCount * 100 / this.ListCount); this.Semaphore.Release(); }