Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            // Initiation
            var    itemComparator = new ItemComparator();
            string outputDirPath  = routineDirPath + productCompareDirName + outputDirName;

            itemComparator.SetOutFilesPath(outputDirPath, toWayneDirName);

            // Clean old files
            //itemComparator.CleanFiles();

            // Get M2 products
            string M2Url   = "<Magento Site URL>";
            string M2Token = "<Magento Token>";

            var m2 = new MagentoConnector(M2Url, M2Token);

            var m2products   = m2.SearchAllProducts();
            var m2attributes = m2.GetAttributes(ItemComparator.magento_custom_attributes);

            itemComparator.InsertAttributeMaps(m2attributes);
            itemComparator.InsertMProducts(m2products);
            itemComparator.GenerateEffectiveMagentoList();

            // Get NetSuite items
            var ns = new SuiteTalkConnector();

            var netsuite_items = ns.executeSavedSearch("customsearch_magento_item_list");

            itemComparator.InsertNSItems(netsuite_items);
            var nsGetList = ns.GetItems(itemComparator.GetNSGetList(itemComparator.in_magento_not_ns_items));

            itemComparator.InsertNSGetList(nsGetList);

            // Generate all the output lists
            itemComparator.GenerateOutputLists();

            // Write Files
            itemComparator.WriteOutputCSVs();

            stopWatch.Stop();

            Console.WriteLine("");
            Console.WriteLine("*** Run Time: {0}s ***", stopWatch.Elapsed.ToString("hh\\:mm\\:ss"));
            Console.WriteLine("");

            Console.WriteLine("");
            Console.WriteLine("*** Product Compare Finish! ***");
            Console.WriteLine("");

            Console.ReadLine();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            double orderDuration = 1.1;

#if DEBUG
            Console.Write("Please enter orders duration(hrs) from now: ");
            orderDuration = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("");
#endif

            Stopwatch stopWatch = new Stopwatch();
            stopWatch.Start();

            /* Initiation */
            var orderInjector  = new OrderInjector();
            var itemComparator = new ItemComparator();
            var m2             = new MagentoConnector(M2Url, M2Token);
            var ns             = new SuiteTalkConnector();

            /* Get all Magento products */
            var m2products   = m2.SearchAllProducts();
            var m2attributes = m2.GetAttributes(ItemComparator.magento_custom_attributes);
            itemComparator.InsertAttributeMaps(m2attributes);
            itemComparator.InsertMProducts(m2products);

            /* Get all uninjected orders */
            var m2Orders = m2.SearchUnsyncOrders(orderDuration);

            /* Get NetSuite Inventory Info */
            var netsuite_items = ns.ExecuteSavedSearch("customsearch_magento_inv_qty");
            itemComparator.InsertNSItems(netsuite_items);
            Console.WriteLine("");
            Console.WriteLine("*** Inventory Inserted ***");
            Console.WriteLine("");

            /* Pre-process Orders */
            orderInjector.orderCreator.InsertMOrders(m2Orders);
            orderInjector.orderCreator.PickToInjectOrders();
            orderInjector.orderCreator.FixTotal();
            orderInjector.orderCreator.FixItems(itemComparator.magentoProductInfoMap);
            orderInjector.orderCreator.DecideWarehouse(itemComparator.netsuiteItemInfoMap);
            Console.WriteLine("");
            Console.WriteLine("*** Orders Pre-processed ***");
            Console.WriteLine("");

            /* Create Sales Orders */
            orderInjector.orderCreator.CreateSalesOrders();
            //orderInjector.orderCreator.CreateApproveSalesOrders();
            orderInjector.orderCreator.CreateInvoices();

            /* Inject orders */
            orderInjector.SetNSConnector(ns);
            orderInjector.InjectToNS();

            /* Get Upserted SO */
            orderInjector.GetSOs();

            /* Compare and print */
            orderInjector.CompareSOs();

            /* Write Files */
            WriteListToCSV(orderInjector.orderComparisons, outputFilePath);

            /* Update synced to Magento */
            var getSuccessOrders = orderInjector.GetSuccessOrders();
            //m2.UpdateSyncedOrders(getSuccessOrders);

            /* Report */
            orderInjector.ReportResult();

            stopWatch.Stop();

            Console.WriteLine("");
            Console.WriteLine("*** Run Time: {0}s ***", stopWatch.Elapsed.ToString("hh\\:mm\\:ss"));
            Console.WriteLine("");

            Console.WriteLine("");
            Console.WriteLine("*** Orders Injection Finish! {0}***", GetDateTime());
            Console.WriteLine("");
#if DEBUG
            Console.ReadLine();
#endif
        }