public void Login(String username, String password, String url, String path) { this.mLoggedIn = false; if (mConfiguration != null) { mConfiguration = null; } //Authorize(username, password, type) type=XML Hashtable parameters = new Hashtable(); parameters.Add("username", username); parameters.Add("password", password); parameters.Add("type", "XML"); try { NResultAuthorize resultAuthorize = new NResultAuthorize(); WebRequest requestAuthorize = WebRequest.Create(url + NTransport.BulildWebRequestQuery("XMLAuthorize", parameters)); HttpWebResponse responseRequestAuthorize = (HttpWebResponse)requestAuthorize.GetResponse(); Stream dataStream = responseRequestAuthorize.GetResponseStream(); XmlSerializer des = new XmlSerializer(typeof(NResultAuthorize)); resultAuthorize = (NResultAuthorize)des.Deserialize(new System.Xml.XmlTextReader(dataStream)); dataStream.Close(); if (resultAuthorize.Success) { mStorage.InitializeStorage(path); mConfiguration = new Configuration(path); mConfiguration.Username = username; mConfiguration.Password = password; mConfiguration.LastMessageID = mStorage.InboxIndex.LastMessageId; #if (DEBUG) mConfiguration.Url = url; #else mConfiguration.Url = resultAuthorize.WebServiceUrl; #endif mSettings = new NSettings(path); InitializeViews(mStorage); this.mLoggedIn = true; } else { this.mLoggedIn = false; } } catch (Exception ex) { #if (DEBUG) throw; #endif } }
public void Login(String username, String password, String url, String path) { this.mLoggedIn = false; if(mConfiguration!=null) mConfiguration=null; //Authorize(username, password, type) type=XML Hashtable parameters = new Hashtable(); parameters.Add("username", username); parameters.Add("password", password); parameters.Add("type", "XML"); try { NResultAuthorize resultAuthorize = new NResultAuthorize(); WebRequest requestAuthorize = WebRequest.Create(url + NTransport.BulildWebRequestQuery("XMLAuthorize", parameters)); HttpWebResponse responseRequestAuthorize = (HttpWebResponse)requestAuthorize.GetResponse(); Stream dataStream = responseRequestAuthorize.GetResponseStream(); XmlSerializer des = new XmlSerializer(typeof(NResultAuthorize)); resultAuthorize = (NResultAuthorize)des.Deserialize(new System.Xml.XmlTextReader(dataStream)); dataStream.Close(); if (resultAuthorize.Success) { mStorage.InitializeStorage(path); mConfiguration = new Configuration(path); mConfiguration.Username = username; mConfiguration.Password = password; mConfiguration.LastMessageID = mStorage.InboxIndex.LastMessageId; #if(DEBUG) mConfiguration.Url = url; #else mConfiguration.Url = resultAuthorize.WebServiceUrl; #endif mSettings = new NSettings(path); InitializeViews(mStorage); this.mLoggedIn = true; } else { this.mLoggedIn = false; } } catch (Exception ex) { #if(DEBUG) throw; #endif } }