Example #1
0
        public void Login(string url, string username, string password, string company)
        {
            _progress.Report(String.Format("[{0}] Logging in to {1}...", System.Threading.Thread.CurrentThread.ManagedThreadId, url));

            _orderScreen     = new SO301000.Screen();
            _orderScreen.Url = url + "/Soap/SO301000.asmx";
            _orderScreen.EnableDecompression = true;
            _orderScreen.CookieContainer     = new System.Net.CookieContainer();
            _orderScreen.Login(username, password);

            _progress.Report(String.Format("[{0}] Logged in to {1}.", System.Threading.Thread.CurrentThread.ManagedThreadId, url));

            _customersScreen     = new AR303000.Screen();
            _customersScreen.Url = url + "/Soap/AR303000.asmx";
            _customersScreen.EnableDecompression = true;
            _customersScreen.CookieContainer     = _orderScreen.CookieContainer;

            lock (_orderSchemaLock)
            {
                // Threads can share the same schema.
                if (_orderSchema == null)
                {
                    _progress.Report(String.Format("[{0}] Retrieving SO301000 schema...", System.Threading.Thread.CurrentThread.ManagedThreadId));
                    _orderSchema = _orderScreen.GetSchema();
                    if (_orderSchema == null)
                    {
                        throw new Exception("SO301000 GetSchema returned null. See AC-73433.");
                    }
                }
            }

            lock (_customersSchemaLock)
            {
                if (_customersSchema == null)
                {
                    _progress.Report(String.Format("[{0}] Retrieving AR303000 schema...", System.Threading.Thread.CurrentThread.ManagedThreadId));
                    _customersSchema = _customersScreen.GetSchema();
                    if (_customersSchema == null)
                    {
                        throw new Exception("AR303000 GetSchema returned null. See AC-73433.");
                    }
                }
            }

            lock (_inventoryItemMapLock)
            {
                if (_inventoryItemMap == null)
                {
                    _progress.Report(String.Format("[{0}] Initializing inventory item map...", System.Threading.Thread.CurrentThread.ManagedThreadId));
                    InitInventoryItemMap(url);
                }
            }
        }
        private static void LoadAR303000Schema()
        {
            AR303000.Screen screen = new AR303000.Screen();
            screen.CookieContainer = new System.Net.CookieContainer();
            screen.Login(Login, Password);

            System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(AR303000.Content));
            using (System.IO.FileStream file = System.IO.File.Open(typeof(AR303000.Content).FullName + ".xml", System.IO.FileMode.OpenOrCreate))
            {
                var schema = screen.GetSchema();
                serializer.Serialize(file, schema);
            }
        }