Example #1
0
 public void Login()
 {
     bool bLoginned = false;
     Dictionary<string, string> data = new Dictionary<string, string>();
     try
     {
         //string strRequestURL = Properties.Settings.Default.URL_ROOTSERVER.Replace("http://", "https://") + Properties.Settings.Default.URI_LOGINHANDLER + "?op=oauth&email=" + this.Email + "&password="******"&from=" + DeviceTypes.MSWordWin.ToString();
         string strRequestURL = Properties.Settings.Default.URL_ROOTSERVER + Properties.Settings.Default.URI_LOGINHANDLER + "?op=oauth&email=" + this.Email + "&password="******"&from=" + DeviceTypes.MSWordWin.ToString();
         CustomHttpRequest req = new CustomHttpRequest(strRequestURL);
         JavaScriptSerializer js = new JavaScriptSerializer();
         data = js.Deserialize<Dictionary<string, string>>(Regex.Replace(req.GetResponseWithNetworkConnHandler(), @"^\(|\)$", ""));
     }
     catch(Exception ex)
     {
         Globals.ThisAddIn.log.WriteLine(LogType.Error, "LoginThread::Login", ex.ToString());
     }
     if (data != null && data.ContainsKey("Result"))
     {
         bLoginned = data["Result"] == "1";
     }
     if (bLoginned)
         loginControl.Invoke(loginControl.LoginSucceedEvent, new Object[] { data });
     else
         loginControl.Invoke(loginControl.LoginFailedEvent, new Object[] { Lang.en_US.Status_Login_Failed });
 }
Example #2
0
 public void LoginByAuthentication()
 {
     bool bLoginned = false;
     Dictionary<string, string> data = new Dictionary<string, string>();
     try
     {
         //string strRequestURL = Properties.Settings.Default.URL_ROOTSERVER.Replace("http://", "https://") + Properties.Settings.Default.URI_LOGINHANDLER + "?op=oauthalt&authstr=" + Properties.Settings.Default.USER_AUTHENTICATION;
         string strRequestURL = Properties.Settings.Default.URL_ROOTSERVER + Properties.Settings.Default.URI_LOGINHANDLER + "?op=oauthalt&authstr=" + Properties.Settings.Default.USER_AUTHENTICATION;
         CustomHttpRequest req = new CustomHttpRequest(strRequestURL);
         JavaScriptSerializer js = new JavaScriptSerializer();
         data = js.Deserialize<Dictionary<string, string>>(System.Text.RegularExpressions.Regex.Replace(req.GetResponseWithNetworkConnHandler(), @"^\(|\)$", ""));
     }
     catch (Exception ex)
     {
         Globals.ThisAddIn.log.WriteLine(LogType.Error, "LoginThread::Login", ex.ToString());
     }
     if (data != null && data.ContainsKey("Result"))
         bLoginned = data["Result"] == "1";
     if (bLoginned)
         loginControl.Invoke(loginControl.LoginSucceedEvent, new Object[] { data });
     else
         loginControl.Invoke(loginControl.LoginFailedEvent, new Object[] { Lang.en_US.Status_Login_Failed });
 }
Example #3
0
        /// <summary>
        /// WebBrowser load complete event
        /// </summary>
        private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            string strURL = this.wBLogin.Document.Url.ToString();
            Regex.Replace(strURL, @"^\s+|\s$", "");
            if (strURL.Contains("citeidentity="))
            {
                bool bLoginned = false;
                Dictionary<string, string> data = new Dictionary<string, string>();
                string[] strUserInfo = Regex.Split(strURL, "citeidentity=");
                string strDesDecrypt = desDecryptBase64(strUserInfo[1]);//DesDecrypt user's information
                string strEmail = strDesDecrypt.Split('|')[0];//Get Email
                string strPassword = strDesDecrypt.Split('|')[1];//Get PW

                try
                {
                    string strRequestURL = Properties.Settings.Default.URL_ROOTSERVER + Properties.Settings.Default.URI_LOGINHANDLER + "?op=oauth&email=" + strEmail + "&password="******"&from=" + DeviceTypes.MSWordWin.ToString();
                    CustomHttpRequest req = new CustomHttpRequest(strRequestURL);
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    data = js.Deserialize<Dictionary<string, string>>(Regex.Replace(req.GetResponseWithNetworkConnHandler(), @"^\(|\)$", ""));
                }
                catch (Exception ex)
                {
                    Globals.ThisAddIn.log.WriteLine(LogType.Error, "ThirdPartyLoginForm::ThirdPartyLogin", ex.ToString());
                }
                if (data != null && data.ContainsKey("Result"))
                {
                    bLoginned = data["Result"] == "1";
                }
                Form lastOpenedForm = Application.OpenForms[Application.OpenForms.Count - 1];
                if (lastOpenedForm.Name == "ThirdPartyLoginForm")
                {
                    lastOpenedForm.Activate();
                    Form.ActiveForm.Close();//Close the login form to complete the login process
                }
                Globals.ThisAddIn.user = new User(data["UserID"], data["LastName"], data["ForeName"], data["Authentication"], data["ServerAddress"], int.Parse(data["AccountType"]));
                Globals.ThisAddIn.iTempHeight = this.Height;
                Globals.ThisAddIn.iTempWidth = this.Width;
                Globals.ThisAddIn.ShowMasterControl();
                Globals.ThisAddIn.ShowCustomPanel();
            }
        }