Ejemplo n.º 1
0
        private void Sync(bool Sage, bool Prestashop)
        {
            PRESTACONNECT.Loading Loading = new PRESTACONNECT.Loading();
            Loading.Show();

            DateTime?filtre = null, old_config = Core.Global.GetConfig().ConfigCommandeFiltreDate;

            if (DataContext.SyncDay)
            {
                filtre = DateTime.Now.Date;
            }
            else if (DataContext.SyncWeek)
            {
                filtre = DateTime.Now.Date.AddDays(-7);
            }
            else if (DataContext.SyncMonth)
            {
                filtre = DateTime.Now.Date.AddMonths(-1);
            }

            if (filtre != null)
            {
                Core.Global.GetConfig().UpdateConfigCommandeFiltreDate(filtre, true);
            }

            if (Sage)
            {
                if (Core.Global.GetConfig().ConfigBToC)
                {
                    PRESTACONNECT.SynchronisationClient SynchronisationClient = new SynchronisationClient();
                    SynchronisationClient.ShowDialog();
                }

                PRESTACONNECT.SynchronisationLivraison SynchronisationLivraison = new SynchronisationLivraison();
                SynchronisationLivraison.ShowDialog();

                PRESTACONNECT.SynchronisationCommande Sync = new SynchronisationCommande(filtre);
                Sync.ShowDialog();
            }

            if (Prestashop && Core.Global.GetConfig().HasPrestaShopStateToChange())
            {
                int NJours = 0;
                if (DataContext.SyncDay)
                {
                    NJours = 1;
                }
                else if (DataContext.SyncWeek)
                {
                    NJours = 7;
                }
                else if (DataContext.SyncMonth)
                {
                    NJours = 30;
                }
                PRESTACONNECT.SynchronisationStatutCommande SyncStatut = new SynchronisationStatutCommande(NJours);
                SyncStatut.ShowDialog();
            }

            Loading.Close();

            if (filtre != null)
            {
                Core.Global.GetConfig().UpdateConfigCommandeFiltreDate(old_config, true);
            }

            Actualiser();
        }
Ejemplo n.º 2
0
        private void ButtonSync_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                PRESTACONNECT.Loading Loading = new PRESTACONNECT.Loading();
                Loading.Show();


                DateTime?filtre = null, old_config = Core.Global.GetConfig().ConfigCommandeFiltreDate;
                if (DataContext.SyncDay)
                {
                    filtre = DateTime.Now.Date;
                }
                else if (DataContext.SyncWeek)
                {
                    filtre = DateTime.Now.Date.AddDays(-7);
                }
                else if (DataContext.SyncMonth)
                {
                    filtre = DateTime.Now.Date.AddMonths(-1);
                }

                if (filtre != null)
                {
                    Core.Global.GetConfig().UpdateConfigCommandeFiltreDate(filtre, true);
                }


                if (Core.Global.GetConfig().ConfigBToC)
                {
                    PRESTACONNECT.SynchronisationClient SynchronisationClient = new SynchronisationClient();
                    SynchronisationClient.ShowDialog();
                }

                PRESTACONNECT.SynchronisationLivraison SynchronisationLivraison = new SynchronisationLivraison();
                SynchronisationLivraison.ShowDialog();


                if (filtre != null)
                {
                    Core.Global.GetConfig().UpdateConfigCommandeFiltreDate(old_config, true);
                }

                Loading.Close();

                if (this.TabItemClientBToC.IsEnabled)
                {
                    Core.Temp.ListLocalCustomer  = new Model.Local.CustomerRepository().List();
                    Core.Temp.ListF_COMPTET_BtoB = new Model.Sage.F_COMPTETRepository().ListBtoB((short)ABSTRACTION_SAGE.F_COMPTET.Obj._Enum_CT_Type.Client);

                    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);
                }
            }
            catch (Exception ex)
            {
                Core.Error.SendMailError(ex.ToString());
            }
        }