示例#1
0
        private void syncBtn_Click(object sender, EventArgs e)
        {
            //string syncChoice = syncComboBox.Text;
            Cursor.Current    = Cursors.WaitCursor;
            successLabel.Text = "Syncing...";
            errorLabel.Text   = "";

            //switch (syncChoice)
            //{
            //    case "RFS":
            //        if (RFS.SyncRfs("Rayons"))
            //         {

            //            if (RFS.SyncRfs("Familles"))
            //            {
            //                if (RFS.SyncRfs("SousFamilles"))
            //                {
            //                    successLabel.Text = "RSF succesfully sync";
            //                }
            //                else
            //                {
            //                    errorLabel.Text = "Sous-Familles - Sync Failed";
            //                }
            //            }
            //            else
            //            {
            //                errorLabel.Text = "Familles - Sync Failed";
            //            }
            //        } else
            //         {
            //            errorLabel.Text = "Rayons - Sync Failed";
            //            successLabel.Text = "";
            //        }

            //        break;

            //    case "Catégories Articles":
            //        if (SCat.SyncSCat())
            //        {
            //            successLabel.Text = "Catégories successfully sync";
            //        } else
            //        {
            //            errorLabel.Text = "Catégories - Sync Failed";
            //            successLabel.Text = "";
            //        }
            //        break;

            //    case "Tarifs Articles":
            //        if (Tarifs.SyncTarifs())
            //        {
            //            successLabel.Text = "Tarifs successfully sync";
            //        }
            //        else
            //        {
            //            errorLabel.Text = "Tarifs - Sync Failed";
            //            successLabel.Text = "";
            //        }
            //        break;

            //    case "Produits":
            //        if (Stock.SyncStock())
            //        {
            //            successLabel.Text = "Produits succesfully sync";
            //        }
            //        else
            //        {
            //            errorLabel.Text = "Produits - Sync Failed";
            //            successLabel.Text = "";
            //        }
            //        break;

            //    //case "Baremes":
            //    //    if(Baremes.syncBaremes())
            //    //    {
            //    //        successLabel.Text = "Baremes successfully sync";
            //    //    } else
            //    //    {
            //    //        errorLabel.Text = "Baremes - Sync Failed";
            //    //        successLabel.Text = "";
            //    //    }
            //    //    break;
            //    default:
            //        successLabel.Text = "";
            //        errorLabel.Text = "Please chose a table to sync";
            //        break;
            //}

            //TODO DISPO
            //if (Dispo.SyncDispo())
            //{
            //    Console.WriteLine("Update des stocks - OK");
            //}
            //else
            //{
            //    Console.WriteLine("Une erreur est survenue durant l'update des stocks");
            //}
            RFSSyncer rfs = new RFSSyncer();

            rfs.Sync();

            Console.WriteLine("Syncing SCat...");
            SCatSyncer scat = new SCatSyncer();

            if (scat.Sync())
            {
                Console.WriteLine("SCat Sync Ok");
            }
            else
            {
                Console.WriteLine("SCat - Sync Failed");
            }
            Console.WriteLine("Syncing Tarifs...");
            //if (Tarifs.SyncTarifs())
            //{
            //    Console.WriteLine("Tarifs Sync Ok");
            //}
            //else
            //{
            //    Console.WriteLine("Tarifs - Sync Failed");
            //}

            Console.WriteLine("Syncing Products...");
            StockSyncer s = new StockSyncer();

            if (s.Sync())
            {
                Console.WriteLine("Product Sync Ok");
                successLabel.Text = "Sync OK";
            }
            else
            {
                Console.WriteLine("Product - Sync Failed");
            }

            Console.WriteLine("Syncing Additional Infos...");
            //Additional infos : promos folders, catalogues, ...


            Cursor.Current = Cursors.Default;
            //Program.createLog();
        }
示例#2
0
        private static bool Sync(string[] arguments, bool result, TextWriter w)
        {
            string currentDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data");

            int  index = 0;
            bool stop  = false;

            WriteLine("Syncing...");
            while (index < arguments.Length && !stop)
            {
                try
                {
                    switch (arguments[index].ToLower())
                    {
                    case "rfs":
                        RFSSyncer rfs = new RFSSyncer();
                        rfs.Sync();
                        break;

                    case "scat":
                        SCatSyncer scat = new SCatSyncer();
                        if (scat.Sync())
                        {
                            WriteLine("SCat Sync Ok");
                        }
                        else
                        {
                            WriteLine("SCat - Sync Failed");
                        }
                        break;

                    //case "tarifs":
                    //    if (Tarifs.SyncTarifs())
                    //    {
                    //        WriteLine("Tarifs Sync Ok");
                    //    }
                    //    else
                    //    {
                    //        WriteLine("Tarifs - Sync Failed");
                    //    }
                    //    break;

                    case "prods":
                        StockSyncer s = new StockSyncer();
                        if (s.Sync())
                        {
                            WriteLine("Product Sync Ok");
                        }
                        else
                        {
                            log("Product - Sync Failed");
                        }
                        break;

                    case "dispo":
                        DispoSyncer di = new DispoSyncer();
                        if (di.Sync())
                        {
                            WriteLine("Dispo Sync Ok");
                        }
                        else
                        {
                            log("Dispo - Sync Failed");
                        }
                        break;

                    case "mclients":
                        ClientMToNSyncer cmn = new ClientMToNSyncer();
                        if (cmn.Sync())
                        {
                            WriteLine("Clients Sync Mercator->Nop Ok");
                        }
                        else
                        {
                            log("Clients Sync Mercator -> Nop Sync Failed");
                        }
                        break;

                    //case "discounts":
                    //    RemiseSyncer r  = new RemiseSyncer();
                    //    if (r.Sync())
                    //    {
                    //        WriteLine("Discounts Sync Ok");
                    //    }
                    //    else
                    //    {
                    //        log("Discounts Sync Failed");
                    //    }
                    //    break;
                    case "clients":
                        ClientNToMSyncer cnm = new ClientNToMSyncer();
                        if (cnm.Sync())
                        {
                            WriteLine("Clients Sync Nop->Mercator Ok");
                        }
                        else
                        {
                            log("Clients Sync Nop->Mercator Sync Failed");
                        }
                        break;

                    case "orders":
                        CommandeSyncer co = new CommandeSyncer();
                        if (co.Sync())
                        {
                            WriteLine("Commandes Sync Ok");
                        }
                        else
                        {
                            log("Commandes - Sync Failed");
                        }
                        break;

                    case "urls":
                        UrlsSyncer u = new UrlsSyncer();
                        if (u.Sync())
                        {
                            WriteLine("Urls Sync Ok");
                        }
                        else
                        {
                            log("Urls Sync failed");
                        }
                        break;

                    case "stocks":
                        DispoSyncer d = new DispoSyncer();
                        if (d.Sync())
                        {
                            WriteLine("Stocks udpate Ok");
                        }
                        else
                        {
                            log("Stocks update failed");
                        }
                        break;

                    default:
                        //unknow command
                        WriteLine("Unknown argument");
                        result = false;
                        stop   = true;
                        break;
                    }
                }
                catch (Exception e)
                {
                    WriteLine("Error while syncing " + arguments[index].ToLower());
                    WriteLine(e.Message);
                    WriteLine(e.StackTrace);
                    log("Error while syncing " + arguments[index].ToLower());
                    log(e.Message);
                    log(e.StackTrace);
                }
                index++;
            }
            //End with clearing cache
            WebService.Get(WebApiEntities.clearCache);
            return(result);
        }