Beispiel #1
0
        public void Login(string url, string username, string password, string company)
        {
            Console.WriteLine("[{0}] Logging in to {1}...", System.Threading.Thread.CurrentThread.ManagedThreadId, url);

            _itemsScreen     = new IN202500.Screen();
            _itemsScreen.Url = url + "/Soap/IN202500.asmx";
            _itemsScreen.EnableDecompression = true;
            _itemsScreen.CookieContainer     = new System.Net.CookieContainer();
            _itemsScreen.Timeout             = 36000;
            _itemsScreen.Login(username, password);

            Console.WriteLine("[{0}] Logged in to {1}.", System.Threading.Thread.CurrentThread.ManagedThreadId, url);

            lock (_itemsSchemaLock)
            {
                // Threads can share the same schema.
                if (_itemsSchema == null)
                {
                    Console.WriteLine("[{0}] Retrieving IN202500 schema...", System.Threading.Thread.CurrentThread.ManagedThreadId);
                    _itemsSchema = _itemsScreen.GetSchema();
                    if (_itemsSchema == null)
                    {
                        throw new Exception("IN202500 GetSchema returned null. See AC-73433.");
                    }
                }
            }
        }
Beispiel #2
0
        private void InitInventoryItemMap(string url)
        {
            if (System.IO.File.Exists("InventoryMap.dat"))
            {
                //We cache it to disk for performance
                using (var stream = System.IO.File.OpenRead("InventoryMap.dat"))
                {
                    _inventoryItemMap = DeserializeInventoryMap(stream);
                }
            }
            else
            {
                //The Shopify orders CSV file doesn't contain any foreign key reference to items - we must match by description.
                var screen = new IN202500.Screen();
                screen.Url = url + "/Soap/IN202500.asmx";
                screen.EnableDecompression = true;
                screen.CookieContainer     = _orderScreen.CookieContainer;

                var schema = screen.GetSchema();
                if (schema == null)
                {
                    throw new Exception("IN303000 GetSchema returned null.");
                }

                var result = screen.Export(new IN202500.Command[]
                {
                    schema.StockItemSummary.ServiceCommands.EveryInventoryID,
                    schema.StockItemSummary.InventoryID,
                    schema.StockItemSummary.Description,
                }, null, 0, false, false);

                _inventoryItemMap = new Dictionary <string, string>();
                for (int i = 0; i < result.Length; i++)
                {
                    _inventoryItemMap[result[i][1]] = result[i][0].TrimEnd();
                }

                using (var stream = System.IO.File.OpenWrite("InventoryMap.dat"))
                {
                    SerializeInventoryMap(_inventoryItemMap, stream);
                }
            }
        }