Ejemplo n.º 1
0
        /// <summary>
        /// 修改是否显示的状态
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void sbUse_Click(object sender, EventArgs e)
        {
            StateButton ub    = (StateButton)sender;
            int         index = ((GridViewRow)(ub.Parent.Parent)).RowIndex;
            int         id    = int.Parse(this.GridView1.DataKeys[index].Value.ToString());

            //
            Song.Entities.SingleSignOn entity = Business.Do <ISSO>().GetSingle(id);
            entity.SSO_IsUse = !entity.SSO_IsUse;
            Business.Do <ISSO>().Save(entity);
            BindData(null, null);
        }
Ejemplo n.º 2
0
 private void fill()
 {
     Song.Entities.SingleSignOn entity = id == 0 ? new Song.Entities.SingleSignOn() : Business.Do <ISSO>().GetSingle(id);
     if (entity == null)
     {
         return;
     }
     if (id == 0)
     {
         entity.SSO_APPID = WeiSha.Common.Request.UniqueID();
     }
     this.EntityBind(entity);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnEnter_Click(object sender, EventArgs e)
 {
     Song.Entities.SingleSignOn entity = id == 0 ? new Song.Entities.SingleSignOn() : Business.Do <ISSO>().GetSingle(id);
     entity           = this.EntityFill(entity) as Song.Entities.SingleSignOn;
     entity.SSO_APPID = SSO_APPID.Text;
     //域名全部转小写
     entity.SSO_Domain = entity.SSO_Domain.ToLower();
     try
     {
         if (id == 0)
         {
             Business.Do <ISSO>().Add(entity);
         }
         if (id > 0)
         {
             Business.Do <ISSO>().Save(entity);
         }
         Master.AlertCloseAndRefresh("操作完成");
     }
     catch (Exception ex)
     {
         this.Alert(ex.Message);
     }
 }
Ejemplo n.º 4
0
        string goto_url = WeiSha.Common.Request.QueryString["goto"].UrlDecode;          //成功后的跳转地址

        public void ProcessRequest(HttpContext context)
        {
            SSO_State state = null;

            try
            {
                if (string.IsNullOrWhiteSpace(user))
                {
                    throw new Exception("1.账号不得为空");
                }
                if (string.IsNullOrWhiteSpace(appid))
                {
                    throw new Exception("2.APPID不得为空");
                }
                if (string.IsNullOrWhiteSpace(domain))
                {
                    throw new Exception("3.请求域不得为空");
                }
                //接口是否存在或正确
                Song.Entities.SingleSignOn entity = Business.Do <ISSO>().GetSingle(appid);
                if (entity == null)
                {
                    throw new Exception("2.接口对象不存在");
                }
                if (!entity.SSO_Domain.Equals(domain, StringComparison.CurrentCultureIgnoreCase))
                {
                    throw new Exception("3.该请求来自的域不合法");
                }
                //通过验证,进入登录状态
                Song.Entities.Accounts emp = Business.Do <IAccounts>().IsAccountsExist(user);
                if (emp == null)
                {
                    if (!"add".Equals(action, StringComparison.CurrentCultureIgnoreCase))
                    {
                        throw new Exception(string.Format("4.当前账号({0})不存在", user));
                    }
                    Song.Entities.Accounts tmp = new Entities.Accounts();
                    tmp.Ac_AccName = user;
                    tmp.Ac_Name    = name;
                    tmp.Ac_IsPass  = tmp.Ac_IsUse = true;
                    Business.Do <IAccounts>().AccountsAdd(tmp);
                    LoginState.Accounts.Write(tmp);
                    state = new SSO_State(true, 10, string.Format("新建账号({0})", user));
                }
                else
                {
                    if (!emp.Ac_IsPass || !emp.Ac_IsUse)
                    {
                        throw new Exception(string.Format("5.当前账号({0})被禁用或未通过审核", user));
                    }
                    switch (action)
                    {
                    //退出登录
                    case "logout":
                        LoginState.Accounts.Logout();
                        state = new SSO_State(true, 7, string.Format("当前账号({0})退出登录", user));
                        break;

                    //验证密码
                    case "verify":
                        Song.Entities.Accounts acc = Business.Do <IAccounts>().AccountsLogin(emp.Ac_ID, pw, true);
                        if (acc == null)
                        {
                            throw new Exception(string.Format("8.当前账号({0})与密码不匹配", user));
                        }
                        state = new SSO_State(true, 9, string.Format("当前账号({0})与密码校验成功", user));
                        break;

                    //登录
                    case "login":
                    default:
                        LoginState.Accounts.Write(emp);
                        //登录成功
                        Business.Do <IAccounts>().PointAdd4Login(emp, "协同站点登录", domain, "");      //增加登录积分
                        Business.Do <IStudent>().LogForLoginAdd(emp);
                        state = new SSO_State(true, 6, string.Format("当前账号({0})登录成功", user));
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                int    s   = 0;
                string msg = string.Empty;
                if (ex.Message.IndexOf(".") > 0)
                {
                    string str = ex.Message.Substring(0, ex.Message.IndexOf("."));
                    int.TryParse(str, out s);
                    msg = ex.Message.Substring(ex.Message.IndexOf(".") + 1);
                }
                state = new SSO_State(false, s, msg);
            }
            //如果成功,且转向地址不为空,则跳转
            if (state != null && state.success && !string.IsNullOrWhiteSpace(goto_url))
            {
                context.Response.Redirect(goto_url);
            }
            else
            {
                string reslut = state.ToReturn(ret);
                context.Response.Write(reslut);
                context.Response.End();
            }
        }
Ejemplo n.º 5
0
        string goto_url = WeiSha.Common.Request.QueryString["goto"].String;      //成功后的跳转地址

        public void ProcessRequest(HttpContext context)
        {
            SSO_State state = null;

            try
            {
                if (string.IsNullOrWhiteSpace(user))
                {
                    state = new SSO_State(false, 1, "账号不得为空");
                }
                else
                {
                    Song.Entities.SingleSignOn entity = Business.Do <ISSO>().GetSingle(appid);
                    if (entity == null)
                    {
                        state = new SSO_State(false, 2, "接口对象不存在");
                    }
                    if (entity != null)
                    {
                        if (entity.SSO_Domain != domain.ToLower())
                        {
                            state = new SSO_State(false, 3, "该请求来自的域不合法");
                        }
                        else
                        {
                            //通过验证,进入登录状态
                            Song.Entities.Accounts emp = Business.Do <IAccounts>().IsAccountsExist(user);
                            if (emp == null)
                            {
                                state = new SSO_State(false, 4, string.Format("当前账号({0})不存在", user));
                            }
                            else
                            {
                                if (!emp.Ac_IsPass || !emp.Ac_IsUse)
                                {
                                    state = new SSO_State(false, 5, string.Format("当前账号({0})被禁用或未通过审核", user));
                                }
                                else
                                {
                                    if (action == "logout")
                                    {
                                        LoginState.Accounts.Logout();
                                        state = new SSO_State(true, 7, string.Format("当前账号({0})退出登录", user));
                                    }
                                    else
                                    {
                                        LoginState.Accounts.Write(emp);
                                        //登录成功
                                        Business.Do <IAccounts>().PointAdd4Login(emp, "协同站点登录", domain, "");   //增加登录积分
                                        Business.Do <IStudent>().LogForLoginAdd(emp);
                                        state = new SSO_State(true, 6, string.Format("当前账号({0})登录成功", user));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                state = new SSO_State(false, 0, ex.Message);
            }
            //如果成功,且转向地址不为空,则跳转
            if (state.success && !string.IsNullOrWhiteSpace(goto_url))
            {
                context.Response.Redirect(goto_url);
            }
            else
            {
                string reslut = state.ToReturn(ret);
                context.Response.Write(reslut);
                context.Response.End();
            }
        }