Ejemplo n.º 1
0
        public JsonResult LoginUser(string tokenId, string congresscode, string username, string password)
        {
            try
            {
                var obj = CongressComponent.Instance.BaseInfoComponents.ConfigurationFacade.FirstOrDefault(c => c.CongressCode == congresscode);
                if (obj == null)
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                var congressId = obj.CongressId;
                var login      = CongressComponent.Instance.BaseInfoComponents.UserFacade.Login(username, password, congressId);
                if (login == null)
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                var pass    = login.Password;
                var objuser = CongressComponent.Instance.BaseInfoComponents.UserFacade.FirstOrDefault(c => c.Username == username & c.Password == pass);
                objuser.FbTokenId = tokenId;
                CongressComponent.Instance.BaseInfoComponents.UserFacade.Update(objuser);
                //return Content(new
                //{
                //    Id = objuser.Id.ToString(),


                //})

                var objLogined = new Logined()
                {
                    UserId    = objuser.Id.ToString(),
                    FirstName = objuser.EnterpriseNode.RealEnterpriseNode.FirstName,
                    LastName  = objuser.EnterpriseNode.RealEnterpriseNode.LastName
                };
                return(Json(objLogined, JsonRequestBehavior.AllowGet));



                //return Content(objuser.Id.ToString());
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 2
0
            public void Close()
            {
                var tmp = Socket;

                lock (this)
                {
                    // 简单保护一下,Close 正常程序退出的时候才调用这个,应该不用保护。
                    if (null == Socket)
                    {
                        return;
                    }

                    Socket = null; // 正常关闭,先设置这个,以后 OnSocketClose 的时候判断做不同的处理。
                }
                if (Logined.Task.IsCompletedSuccessfully)
                {
                    var normalClose = new GlobalCacheManager.NormalClose();
                    var future      = new TaskCompletionSource <int>();
                    normalClose.Send(tmp,
                                     (_) =>
                    {
                        if (normalClose.IsTimeout)
                        {
                            future.SetResult(-100);     // 关闭错误就不抛异常了。
                        }
                        else
                        {
                            future.SetResult(normalClose.ResultCode);
                            if (normalClose.ResultCode != 0)
                            {
                                logger.Error("GlobalAgent:NormalClose ResultCode={0}", normalClose.ResultCode);
                            }
                        }
                        return(0);
                    });
                    future.Task.Wait();
                }
                Logined.TrySetException(new Exception("GlobalAgent.Close")); // 这个,,,,
                tmp.Dispose();
            }
Ejemplo n.º 3
0
 public void OnSocketClose(GlobalClient client, Exception ex)
 {
     lock (this)
     {
         if (null == Socket)
         {
             // active close
             return;
         }
         Socket = null;
     }
     if (Logined.Task.IsCompletedSuccessfully)
     {
         foreach (var database in client.Zeze.Databases.Values)
         {
             foreach (var table in database.Tables)
             {
                 table.ReduceInvalidAllLocalOnly(GlobalCacheManagerHashIndex);
             }
         }
         client.Zeze.CheckpointRun();
     }
     Logined.TrySetException(ex); // 连接关闭,这个继续保持。仅在Connect里面需要时创建。
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 发送登录完成事件
 /// </summary>
 public static void SendLogined(LoginDataV2Model data)
 {
     Logined?.Invoke(null, data);
 }
Ejemplo n.º 5
0
 public static void Login(string token, User user)
 {
     Token = token;
     User  = user;
     Logined?.Invoke(user);
 }
Ejemplo n.º 6
0
    protected void imgBtnLogin_Click1(object sender, EventArgs e)
    {
        string usersId = txtUserID.Text.Trim();
        string pwdMd5  = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtPwd.Text.Trim(), "MD5").ToString();

        Users u = new Users();

        u.UserID  = usersId;
        u.UserPwd = pwdMd5;


        //新代码
        Logined lg = new Logined();

        lg = UserManager.Logined(ref u);
        if (lg.login_status)
        {
            if (this.cbxRemeberUser.Checked)
            {
                if (object.Equals(Request.Cookies["UsersID"], null))
                {
                    CreateCookie();
                }
                else
                {
                    CreateCookie();
                }
            }
            Session["userID"] = txtUserID.Text.Trim(); //存储用户编号
            Response.Redirect("Default.aspx");         //转向管理员操作界面
        }
        else
        {
            lblMessage.Text = lg.login_errstr;
        }


        //bool success = UserManager.Login(ref u);
        //if (success)
        //{
        //    //如果成功

        //    if (u.UserPwd == pwdMd5)//输入密码与用户密码相同
        //    {
        //        if (this.cbxRemeberUser.Checked)
        //        {
        //            if (object.Equals(Request.Cookies["UsersID"], null))
        //            {
        //                CreateCookie();
        //            }
        //            else
        //            {
        //                CreateCookie();
        //            }
        //        }
        //        Session["userID"] = txtUserID.Text.Trim();//存储用户编号
        //        Response.Redirect("Default.aspx");//转向管理员操作界面
        //    }
        //    else//密码错误,给出提示
        //    {
        //        lblMessage.Text = "您输入的密码错误!";
        //    }
        //}
        //else//用户不存在,给出提示
        //{
        //    lblMessage.Text = "该用户不存在或密码不正确!";
        //}
    }
Ejemplo n.º 7
0
        private void Login()
        {
            string greeningURL = "http://10.1.1.163/greening2/shared";
            string moduleURL   = "http://10.1.1.163/modules/shared";

            XmlDocument doc      = new XmlDocument();
            string      filename = Path.Combine(Environment.CurrentDirectory, "Setup.config");

            this.ShowMessage("載入設定檔");

            if (File.Exists(filename))
            {
                doc.Load(filename);
                XmlHelper config = new XmlHelper(doc.DocumentElement);
                greeningURL = config.GetText("GreeningAccessPoint");
                moduleURL   = config.GetText("ModuleAccessPoint");
            }

            try
            {
                this.ShowMessage("登入 ischool ....");
                Connection greenCon = new Connection();
                greenCon.EnableSecureTunnel = true;
                greenCon.EnableSession      = false;
                try
                {
                    greenCon.Connect(greeningURL, "user", txtUser.Text.Trim(), txtPassword.Text);
                }
                catch (Exception ex)
                {
                    throw new Exception("ischool Account 認證失敗" + ex.Message);
                }

                Envelope rsp = greenCon.SendRequest("DS.Base.GetPassportToken", new Envelope());
                PassportSecurityToken stt = new PassportSecurityToken(rsp.Body.XmlString);

                XmlHelper h1 = new XmlHelper(rsp.Body);
                string    id = h1.GetText("Content/Attributes/ID");

                string     ftpUser     = string.Empty;
                string     ftpPassword = string.Empty;
                string     ftpUrl      = string.Empty;
                bool       succeedLoginModuleService = false;
                Connection modCon = null;
                try
                {
                    this.ShowMessage("載入線上儲存空間設定...");

                    modCon = new Connection();
                    modCon.EnableSession      = true;
                    modCon.EnableSecureTunnel = true;

                    modCon.Connect(moduleURL, "developer", stt);

                    Envelope  env = modCon.SendRequest("GetFTPInfo", new Envelope());
                    XmlHelper h   = new XmlHelper(env.Body);
                    ftpUser     = TripleDESHelper.Decrypt(h.GetText("User"), USE_KEY);
                    ftpPassword = TripleDESHelper.Decrypt(h.GetText("Password"), USE_KEY);
                    ftpUrl      = TripleDESHelper.Decrypt(h.GetText("FTP"), USE_KEY);
                    succeedLoginModuleService = true;
                }
                catch
                {
                    this.ShowMessage("載入失敗!");
                    succeedLoginModuleService = false;
                }
                string pwd = string.Empty;
                if (chkRemember.Checked)
                {
                    pwd = txtPassword.Text;
                }
                MainForm.Storage.SetPropertyValues("LoginName", txtUser.Text, pwd);
                MainForm.Storage.SetProperty("LastLoginName", txtUser.Text);
                MainForm.Storage.SetProperty("LastLoginPassword", pwd);
                MainForm.Storage.SetProperty("RememberPassword", chkRemember.Checked.ToString().ToLower());

                if (Logined != null)
                {
                    this.ShowMessage("登入開發站台...");
                    LoginEventArgs arg = new LoginEventArgs();
                    arg.FtpPassword        = ftpPassword;
                    arg.FtpUser            = ftpUser;
                    arg.FtpURL             = ftpUrl;
                    arg.GreeningConnection = greenCon;
                    arg.ModuleConnection   = modCon;
                    arg.SetModuleConnectionInfo(moduleURL);
                    arg.LoginUser          = txtUser.Text;
                    arg.GreeningID         = id;
                    arg.SucceedModuleLogin = succeedLoginModuleService;

                    this.ShowMessage("載入開發站台資訊");
                    Logined.Invoke(this, arg);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.ShowMessage("※請輸入 ischool Account 密碼");
            }
        }
Ejemplo n.º 8
0
 protected virtual void OnLogined()
 {
     Logined?.Invoke(this, EventArgs.Empty);
 }