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); }); }
private void BtTransfert_Click(object sender, RoutedEventArgs e) { if (this.CBClientSage.SelectedItem != null) { try { List <String> log; if (!string.IsNullOrWhiteSpace(Core.Global.GetConfig().TransfertPrestashopCookieKey)) { if (this.CBClientSage.SelectedItem != null && this.CBClientSage.SelectedItem is Model.Sage.F_COMPTET_Light) { Model.Sage.F_COMPTET_Light F_COMPTET = (Model.Sage.F_COMPTET_Light) this.CBClientSage.SelectedItem; Model.Local.CustomerRepository CustomerRepository = new Model.Local.CustomerRepository(); if (CustomerRepository.ExistSage(F_COMPTET.cbMarq) == false) { Loading loadscreen = new Loading(); loadscreen.Show(); Core.Transfert.TransfertSageClient Sync = new Core.Transfert.TransfertSageClient(); Sync.Exec(F_COMPTET.cbMarq, out log); loadscreen.Close(); if (log.Count > 0) { Core.Log.SendLog(log, Core.Log.LogIdentifier.TransfertClient); } this.ButtonSearchSageToPrestashop_Click(this.BtTransfert, new RoutedEventArgs()); } else { MessageBox.Show("Compte client déjà transféré !", "", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Erreur de sélection du compte client Sage !", "", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("La clé cookie de votre site Prestashop n'est pas renseignée dans la configuration de Prestaconnect, création du compte client dans Prestashop impossible !", "Clé cookie non renseignée", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } } }
public SynchroPortfolioCustomerEmployee(List <Model.Local.Customer> ListCustomer = null) { this.InitializeComponent(); if (ListCustomer == null) { Model.Local.CustomerRepository CustomerRepository = new Model.Local.CustomerRepository(); ListCustomer = CustomerRepository.List(); } this.ListCount = ListCustomer.Count; Context = SynchronizationContext.Current; this.ParallelOptions.MaxDegreeOfParallelism = MaximumThreadCount; this.ReportProgress(0); Task.Factory.StartNew(() => { Parallel.ForEach(ListCustomer, this.ParallelOptions, Sync); }); }
public CustomerInfo(List <Model.Local.Customer> ListCustomer = null) { this.InitializeComponent(); if (ListCustomer == null) { Model.Local.CustomerRepository CustomerRepository = new Model.Local.CustomerRepository(); ListCustomer = CustomerRepository.List(); } this.ListCount = ListCustomer.Count; Context = SynchronizationContext.Current; this.ParallelOptions.MaxDegreeOfParallelism = System.Environment.ProcessorCount; this.ReportProgress(0); Task.Factory.StartNew(() => { Parallel.ForEach(ListCustomer, this.ParallelOptions, Sync); }); }
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(); } } }
private void LinkAccounts() { Model.Sage.F_COMPTET_BtoB F_COMPTET = (Model.Sage.F_COMPTET_BtoB)listBoxBTOBCustomerSage.SelectedItem; Model.Prestashop.btob_customer PsCustomer = (Model.Prestashop.btob_customer)listBoxBTOBCustomerPrestashop.SelectedItem; if (F_COMPTET != null && PsCustomer != null) { Model.Local.CustomerRepository CustomerRepository = new Model.Local.CustomerRepository(); if (!CustomerRepository.ExistPrestashop((int)PsCustomer.id_customer)) { if (!CustomerRepository.ExistSage(F_COMPTET.cbMarq)) { CustomerRepository.Add(new Model.Local.Customer() { Pre_Id = (int)PsCustomer.id_customer, Sag_Id = F_COMPTET.cbMarq, }); this.RefreshBtoB(); } else if (Core.Global.GetConfig().ConfigClientMultiMappageBtoB) { if (MessageBox.Show("Le client Sage " + F_COMPTET.CT_Intitule + " est déjà mappé avec un ou plusieurs comptes PrestaShop." + "\nÊtes-vous sûr de vouloir y associer le compte :\n" + PsCustomer.BtoBString, "Multi-Mappage", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { CustomerRepository.Add(new Model.Local.Customer() { Pre_Id = (int)PsCustomer.id_customer, Sag_Id = F_COMPTET.cbMarq, }); this.RefreshBtoB(); } } } } }
public SynchronisationLivraison() { this.InitializeComponent(); this.LabelInformation.Content = "Recherche des adresses à créer ..."; this.worker.WorkerReportsProgress = true; this.worker.DoWork += delegate(object s, DoWorkEventArgs args) { Model.Prestashop.PsAddressRepository PsAddressRepository = new Model.Prestashop.PsAddressRepository(); List <Model.Prestashop.PsAddress_Light> ListPsAddress = (Core.Global.GetConfig().ConfigClientFiltreCommande) ? PsAddressRepository.List() : PsAddressRepository.ListWithOrder(); // filtrage des adresses par rapport aux clients déjà synchronisés List <Model.Local.Customer> listCustomer = new Model.Local.CustomerRepository().List(); ListPsAddress = ListPsAddress.Where(a => listCustomer.Count(c => c.Pre_Id == a.id_customer) > 0).ToList(); List <Model.Local.Address> listLocal = new Model.Local.AddressRepository().List(); ListPsAddress = ListPsAddress.Where(a => listLocal.Count(l => l.Pre_Id == a.id_address) == 0).ToList(); if (ListPsAddress.Count > 0) { this.worker.ReportProgress(-42); Connexion = Core.Global.GetODBC(); Core.Temp.ListAddressOnCurrentSync = new List <uint>(); foreach (Model.Prestashop.PsAddress_Light PsAddress_Light in ListPsAddress) { if (Connexion != null) { Core.Sync.SynchronisationLivraison SynchronisationLivraison = new Core.Sync.SynchronisationLivraison(); SynchronisationLivraison.Exec(Connexion, PsAddress_Light.id_address); } lock (this) { this.CurrentCount += 1; } this.worker.ReportProgress((this.CurrentCount * 100 / ListPsAddress.Count)); } } }; this.worker.ProgressChanged += delegate(object s, ProgressChangedEventArgs args) { if (args.ProgressPercentage >= 0) { this.ProgressBarLivraison.Value = args.ProgressPercentage; this.LabelInformation.Content = "Informations : " + args.ProgressPercentage + " %"; } else if (args.ProgressPercentage == -42) { this.LabelInformation.Content = "Ouverture connexion ODBC Sage..."; } }; this.worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args) { if (Connexion != null) { Connexion.Close_Connexion(); } this.Close(); }; // Insérez le code requis pour la création d’objet sous ce point. this.worker.RunWorkerAsync(); }
public SynchronisationClient() { this.InitializeComponent(); this.worker.WorkerReportsProgress = true; this.LabelInformation.Content = "Recherche des clients à créer ..."; this.worker.DoWork += delegate(object s, DoWorkEventArgs args) { if (Core.Global.GetConfig().ConfigBToC) { Model.Prestashop.PsCustomerRepository PsCustomerRepository = new Model.Prestashop.PsCustomerRepository(); List <Model.Prestashop.idcustomer> ListCustomer = (Core.Global.GetConfig().ConfigClientFiltreCommande) ? PsCustomerRepository.ListIDActive(1, Core.Global.CurrentShop.IDShop) : PsCustomerRepository.ListIDActiveWithOrder(1, Core.Global.CurrentShop.IDShop); // <JG> ajout filtre clients déjà mappés List <Model.Local.Customer> listLocal = new Model.Local.CustomerRepository().List(); ListCustomer = ListCustomer.Where(c => listLocal.Count(l => l.Pre_Id == c.id_customer) == 0).ToList(); this.worker.ReportProgress(0); if (ListCustomer.Count > 0) { this.worker.ReportProgress(-42); Connexion = Core.Global.GetODBC(); foreach (Model.Prestashop.idcustomer Customer in ListCustomer) { if (Connexion != null) { Core.Sync.SynchronisationClient SynchronisationClient = new Core.Sync.SynchronisationClient(); SynchronisationClient.Exec(Connexion, Customer.id_customer); } lock (this) { this.CurrentCount += 1; } this.worker.ReportProgress((this.CurrentCount * 100 / ListCustomer.Count)); } } } }; this.worker.ProgressChanged += delegate(object s, ProgressChangedEventArgs args) { if (args.ProgressPercentage >= 0) { this.ProgressBarClient.Value = args.ProgressPercentage; this.LabelInformation.Content = "Informations : " + args.ProgressPercentage + " %"; } else if (args.ProgressPercentage == -42) { this.LabelInformation.Content = "Ouverture connexion ODBC Sage..."; } }; this.worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args) { if (Connexion != null) { Connexion.Close_Connexion(); } this.Close(); }; // Insérez le code requis pour la création d’objet sous ce point. this.worker.RunWorkerAsync(); }
// <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); } }