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); } } }
public void Logout() { if (_orderScreen != null) { try { _orderScreen.Logout(); _orderScreen = null; } catch { // In real-life we would need to properly log and process the exceptions and only ignore those that can be attributed to network issues and temporary problems. } } }