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(); }
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(); }
// <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); } }