public string GetNote()
        {
            string id = Request.QueryString["id"];
            Guid   gid;

            if (id.IsNullOrEmpty())
            {
                return("");
            }
            BizProcess.Platform.Organize borg  = new BizProcess.Platform.Organize();
            BizProcess.Platform.Users    buser = new BizProcess.Platform.Users();
            if (id.StartsWith(BizProcess.Platform.Users.PREFIX))
            {
                Guid uid = buser.RemovePrefix1(id).ToGuid();
                return(string.Concat(borg.GetAllParentNames(buser.GetMainStation(uid)), " / ", buser.GetName(uid)));
            }
            else if (id.StartsWith(BizProcess.Platform.WorkGroup.PREFIX))
            {
                return(new BizProcess.Platform.WorkGroup().GetUsersNames(BizProcess.Platform.WorkGroup.RemovePrefix(id).ToGuid(), '、'));
            }
            else if (id.IsGuid(out gid))
            {
                return(borg.GetAllParentNames(gid));
            }
            return("");
        }
        public ActionResult UserAdd(FormCollection collection)
        {
            BizProcess.Platform.Organize borganize = new BizProcess.Platform.Organize();
            BizProcess.Platform.Users    busers    = new BizProcess.Platform.Users();

            string id = Request.QueryString["id"];

            string name    = string.Empty;
            string account = string.Empty;
            string status  = string.Empty;
            string note    = string.Empty;
            Guid   parentID;

            if (collection != null && id.IsGuid(out parentID))
            {
                name    = Request.Form["Name"];
                account = Request.Form["Account"];
                status  = Request.Form["Status"];
                note    = Request.Form["Note"];

                Guid   userID  = Guid.NewGuid();
                string userXML = string.Empty;
                using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
                {
                    //添加人员
                    BizProcess.Data.Model.Users user = new BizProcess.Data.Model.Users();
                    user.Account  = account.Trim();
                    user.Name     = name.Trim();
                    user.Note     = note.IsNullOrEmpty() ? null : note;
                    user.Password = busers.GetUserEncryptionPassword(userID.ToString(), busers.GetInitPassword());
                    user.Sort     = 1;
                    user.Status   = status.IsInt() ? status.ToInt() : 0;
                    user.ID       = userID;
                    busers.Add(user);

                    //添加关系
                    BizProcess.Data.Model.UsersRelation userRelation = new BizProcess.Data.Model.UsersRelation();
                    userRelation.IsMain     = 1;
                    userRelation.OrganizeID = parentID;
                    userRelation.Sort       = new BizProcess.Platform.UsersRelation().GetMaxSort(parentID);
                    userRelation.UserID     = userID;
                    new BizProcess.Platform.UsersRelation().Add(userRelation);

                    //更新父级[ChildsLength]字段
                    borganize.UpdateChildsLength(parentID);

                    //更新角色
                    new BizProcess.Platform.UsersRole().UpdateByUserID(userID);

                    userXML = user.Serialize();
                    scope.Complete();
                }

                BizProcess.Platform.Log.Add("添加了人员", userXML, BizProcess.Platform.Log.Types.组织机构);
                ViewBag.Script = "alert('添加成功!');parent.frames[0].reLoad('" + id + "');window.location=window.location;";
            }
            ViewBag.StatusRadios = borganize.GetStatusRadio("Status", "0", "validate=\"radio\"");
            return(View());
        }
        public ActionResult Index(FormCollection collection)
        {
            BizProcess.Platform.WorkFlowDelegation bworkFlowDelegation = new BizProcess.Platform.WorkFlowDelegation();
            BizProcess.Platform.Organize           borganize           = new BizProcess.Platform.Organize();
            BizProcess.Platform.Users    busers    = new BizProcess.Platform.Users();
            BizProcess.Platform.WorkFlow bworkFlow = new BizProcess.Platform.WorkFlow();
            IEnumerable <BizProcess.Data.Model.WorkFlowDelegation> workFlowDelegationList;

            string startTime = string.Empty;
            string endTime   = string.Empty;
            string query1    = string.Format("&appid={0}&tabid={1}&isoneself={2}", Request.QueryString["appid"], Request.QueryString["tabid"], Request.QueryString["isoneself"]);

            if (collection != null)
            {
                if (!Request.Form["DeleteBut"].IsNullOrEmpty())
                {
                    string ids = Request.Form["checkbox_app"];
                    foreach (string id in ids.Split(','))
                    {
                        Guid bid;
                        if (!id.IsGuid(out bid))
                        {
                            continue;
                        }
                        var comment = bworkFlowDelegation.Get(bid);
                        if (comment != null)
                        {
                            bworkFlowDelegation.Delete(bid);
                            BizProcess.Platform.Log.Add("删除了流程意见", comment.Serialize(), BizProcess.Platform.Log.Types.流程相关);
                        }
                    }
                    bworkFlowDelegation.RefreshCache();
                }
            }

            string pager;
            bool   isOneSelf = "1" == Request.QueryString["isoneself"];

            if (isOneSelf)
            {
                workFlowDelegationList = bworkFlowDelegation.GetPagerData(out pager, query1, BizProcess.Platform.Users.CurrentUserID.ToString(), startTime, endTime);
            }
            else
            {
                workFlowDelegationList = bworkFlowDelegation.GetPagerData(out pager, query1, "", startTime, endTime);
            }
            ViewBag.Query1 = query1;
            return(View(workFlowDelegationList));
        }
        public ActionResult EditPass(FormCollection collection)
        {
            string oldpass = Request.Form["oldpass"];
            string newpass = Request.Form["newpass"];

            BizProcess.Platform.Users busers = new BizProcess.Platform.Users();
            var user = BizProcess.Platform.Users.CurrentUser;

            if (user != null)
            {
                if (string.Compare(user.Password, busers.GetUserEncryptionPassword(user.ID.ToString(), oldpass.Trim()), false) != 0)
                {
                    BizProcess.Platform.Log.Add("修改密码失败", string.Concat("用户:", user.Name, "(", user.ID, ")修改密码失败,旧密码错误!"), BizProcess.Platform.Log.Types.用户登录);
                    ViewBag.Script = "alert('旧密码错误!');";
                }
                else
                {
                    busers.UpdatePassword(newpass.Trim(), user.ID);
                    BizProcess.Platform.Log.Add("修改密码成功", string.Concat("用户:", user.Name, "(", user.ID, ")修改密码成功!"), BizProcess.Platform.Log.Types.用户登录);
                    ViewBag.Script = "alert('密码修改成功!');new BPUI.Window().close();";
                }
            }
            return(View());
        }
        public ActionResult SortUsers(FormCollection collection)
        {
            string parentID = Request.QueryString["parentid"];

            if (collection != null)
            {
                string   sort      = Request.Form["sort"] ?? "";
                string[] sortArray = sort.Split(',');
                BizProcess.Platform.Users busers = new BizProcess.Platform.Users();
                for (int i = 0; i < sortArray.Length; i++)
                {
                    Guid gid;
                    if (!sortArray[i].IsGuid(out gid))
                    {
                        continue;
                    }
                    busers.UpdateSort(gid, i + 1);
                }
                ViewBag.Script = "parent.frames[0].reLoad('" + parentID + "');";
            }
            var users = new BizProcess.Platform.Organize().GetAllUsers(parentID.ToGuid());

            return(View(users));
        }
        public ActionResult User(FormCollection collection)
        {
            BizProcess.Platform.Organize      borganize     = new BizProcess.Platform.Organize();
            BizProcess.Platform.Users         busers        = new BizProcess.Platform.Users();
            BizProcess.Platform.UsersRelation buserRelation = new BizProcess.Platform.UsersRelation();
            BizProcess.Data.Model.Users       user          = null;
            BizProcess.Data.Model.Organize    organize      = null;
            string id       = Request.QueryString["id"];
            string parentID = Request.QueryString["parentid"];

            string name    = string.Empty;
            string account = string.Empty;
            string status  = string.Empty;
            string note    = string.Empty;

            string parentString = string.Empty;

            Guid userID, organizeID;

            if (id.IsGuid(out userID))
            {
                user = busers.Get(userID);
                if (user != null)
                {
                    name    = user.Name;
                    account = user.Account;
                    status  = user.Status.ToString();
                    note    = user.Note;

                    //所在组织字符串
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    var userRelations            = buserRelation.GetAllByUserID(user.ID).OrderByDescending(p => p.IsMain);
                    foreach (var userRelation in userRelations)
                    {
                        sb.Append("<div style='margin:3px 0;'>");
                        sb.Append(borganize.GetAllParentNames(userRelation.OrganizeID, true));
                        if (userRelation.IsMain == 0)
                        {
                            sb.Append("<span style='color:#999'> [兼职]</span>");
                        }
                        sb.Append("</div>");
                    }
                    ViewBag.ParentString = sb.ToString();
                    var roles = new BizProcess.Platform.UsersRole().GetByUserIDFromCache(userID);
                    BizProcess.Platform.Role  brole  = new BizProcess.Platform.Role();
                    System.Text.StringBuilder rolesb = new System.Text.StringBuilder();
                    foreach (var role in roles)
                    {
                        var role1 = brole.Get(role.RoleID);
                        if (role1 == null)
                        {
                            continue;
                        }
                        rolesb.Append(role1.Name);
                        rolesb.Append(",");
                    }
                    ViewBag.RoleString = rolesb.ToString().TrimEnd(',');
                }
            }
            if (parentID.IsGuid(out organizeID))
            {
                organize = borganize.Get(organizeID);
            }

            if (collection != null)
            {
                //保存
                if (!Request.Form["Save"].IsNullOrEmpty() && user != null)
                {
                    name    = Request.Form["Name"];
                    account = Request.Form["Account"];
                    status  = Request.Form["Status"];
                    note    = Request.Form["Note"];

                    string oldXML = user.Serialize();

                    user.Name    = name.Trim();
                    user.Account = account.Trim();
                    user.Status  = status.ToInt(1);
                    user.Note    = note.IsNullOrEmpty() ? null : note.Trim();

                    busers.Update(user);
                    BizProcess.Platform.Log.Add("修改了用户", "", BizProcess.Platform.Log.Types.组织机构, oldXML, user.Serialize());
                    ViewBag.Script = "alert('保存成功!');parent.frames[0].reLoad('" + parentID + "');";
                }

                //删除用户
                if (!Request.Form["DeleteBut"].IsNullOrEmpty() && user != null && organize != null)
                {
                    using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
                    {
                        var urs = buserRelation.GetAllByUserID(user.ID);
                        busers.Delete(user.ID);

                        buserRelation.DeleteByUserID(user.ID);

                        new BizProcess.Platform.UsersInfo().Delete(user.ID);
                        new BizProcess.Platform.UsersRole().DeleteByUserID(user.ID);

                        //更新父级[ChildsLength]字段
                        foreach (var ur in urs)
                        {
                            borganize.UpdateChildsLength(ur.OrganizeID);
                        }

                        scope.Complete();
                    }

                    string refreshID = parentID;
                    string url       = string.Empty;
                    var    users     = borganize.GetAllUsers(refreshID.ToGuid());
                    if (users.Count > 0)
                    {
                        url = "User?id=" + users.Last().ID + "&appid=" + Request.QueryString["appid"] + "&tabid=" + Request.QueryString["tabid"] + "&parentid=" + parentID;
                    }
                    else
                    {
                        refreshID = organize.ParentID == Guid.Empty ? organize.ID.ToString() : organize.ParentID.ToString();
                        url       = "Body?id=" + parentID + "&appid=" + Request.QueryString["appid"] + "&tabid=" + Request.QueryString["tabid"] + "&parentid=" + organize.ParentID;
                    }
                    BizProcess.Platform.Log.Add("删除了用户", user.Serialize(), BizProcess.Platform.Log.Types.组织机构);
                    ViewBag.Script = "alert('删除成功');parent.frames[0].reLoad('" + refreshID + "');window.location='" + url + "'";
                    new BizProcess.Platform.AppLibrary().ClearUseMemberCache();
                }

                //初始化密码
                if (!Request.Form["InitPass"].IsNullOrEmpty() && user != null)
                {
                    string initpass = busers.GetInitPassword();
                    busers.InitPassword(user.ID);
                    BizProcess.Platform.Log.Add("初始化了用户密码", user.Serialize(), BizProcess.Platform.Log.Types.组织机构);
                    ViewBag.Script = "alert('密码已初始化为:" + initpass + "');";
                }

                //调动
                if (!Request.Form["Move1"].IsNullOrEmpty() && user != null)
                {
                    string moveto          = Request.Form["movetostation"];
                    string movetostationjz = Request.Form["movetostationjz"];
                    Guid   moveToID;
                    if (moveto.IsGuid(out moveToID))
                    {
                        using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
                        {
                            var us = buserRelation.GetAllByUserID(user.ID);
                            if ("1" != movetostationjz)
                            {
                                buserRelation.DeleteByUserID(user.ID);
                            }

                            BizProcess.Data.Model.UsersRelation ur = new BizProcess.Data.Model.UsersRelation();
                            ur.UserID     = user.ID;
                            ur.OrganizeID = moveToID;
                            ur.IsMain     = "1" == movetostationjz ? 0 : 1;
                            ur.Sort       = buserRelation.GetMaxSort(moveToID);
                            buserRelation.Add(ur);

                            foreach (var u in us)
                            {
                                borganize.UpdateChildsLength(u.OrganizeID);
                            }

                            borganize.UpdateChildsLength(organizeID);
                            borganize.UpdateChildsLength(moveToID);

                            scope.Complete();
                            ViewBag.Script = "alert('调动成功!');parent.frames[0].reLoad('" + parentID + "');parent.frames[0].reLoad('" + moveto + "')";
                        }

                        BizProcess.Platform.Log.Add(("1" == movetostationjz ? "兼职" : "全职") + "调动了人员的岗位", "将人员调往岗位(" + moveto + ")", BizProcess.Platform.Log.Types.组织机构);
                        new BizProcess.Platform.AppLibrary().ClearUseMemberCache();
                    }
                }
            }
            ViewBag.StatusRadios = borganize.GetStatusRadio("Status", status, "validate=\"radio\"");
            return(View(user));
        }
        public string Tree1()
        {
            string rootid   = Request.QueryString["rootid"];
            string showtype = Request.QueryString["showtype"];

            BizProcess.Platform.Organize BOrganize = new BizProcess.Platform.Organize();
            System.Text.StringBuilder    json      = new System.Text.StringBuilder("[", 1000);

            if ("1" == showtype)//显示工作组
            {
                BizProcess.Platform.WorkGroup BWorkGroup = new BizProcess.Platform.WorkGroup();
                var workGroups = BWorkGroup.GetAll();

                json.Append("{");
                json.AppendFormat("\"id\":\"{0}\",", Guid.Empty);
                json.AppendFormat("\"parentID\":\"{0}\",", Guid.Empty);
                json.AppendFormat("\"title\":\"{0}\",", "工作组");
                json.AppendFormat("\"ico\":\"{0}\",", Url.Content("~/images/ico/group.gif"));
                json.AppendFormat("\"link\":\"{0}\",", "");
                json.AppendFormat("\"type\":\"{0}\",", 5);
                json.AppendFormat("\"hasChilds\":\"{0}\",", workGroups.Count);
                json.Append("\"childs\":[");

                int countwg = workGroups.Count;
                int iwg     = 0;
                foreach (var wg in workGroups)
                {
                    json.Append("{");
                    json.AppendFormat("\"id\":\"{0}\",", wg.ID);
                    json.AppendFormat("\"parentID\":\"{0}\",", Guid.Empty);
                    json.AppendFormat("\"title\":\"{0}\",", wg.Name);
                    json.AppendFormat("\"ico\":\"{0}\",", "");
                    json.AppendFormat("\"link\":\"{0}\",", "");
                    json.AppendFormat("\"type\":\"{0}\",", 5);
                    json.AppendFormat("\"hasChilds\":\"{0}\",", 0);
                    json.Append("\"childs\":[");
                    json.Append("]");
                    json.Append("}");
                    if (iwg++ < countwg - 1)
                    {
                        json.Append(",");
                    }
                }

                json.Append("]");
                json.Append("}");
                json.Append("]");
                Response.Write(json.ToString());
                Response.End();
            }


            Guid rootID;

            BizProcess.Data.Model.Organize root;
            if (rootid.IsGuid(out rootID))
            {
                root = BOrganize.Get(rootID);
            }
            else
            {
                root = BOrganize.GetRoot();
            }

            List <BizProcess.Data.Model.Users> users = new List <BizProcess.Data.Model.Users>();

            BizProcess.Platform.Users busers = new BizProcess.Platform.Users();
            users = busers.GetAllByOrganizeID(root.ID);

            json.Append("{");
            json.AppendFormat("\"id\":\"{0}\",", root.ID);
            json.AppendFormat("\"parentID\":\"{0}\",", root.ParentID);
            json.AppendFormat("\"title\":\"{0}\",", root.Name);
            json.AppendFormat("\"ico\":\"{0}\",", Url.Content("~/images/ico/icon_site.gif"));
            json.AppendFormat("\"link\":\"{0}\",", "");
            json.AppendFormat("\"type\":\"{0}\",", root.Type);
            json.AppendFormat("\"hasChilds\":\"{0}\",", root.ChildsLength == 0 && users.Count == 0 ? "0" : "1");
            json.Append("\"childs\":[");

            var orgs  = BOrganize.GetChilds(root.ID);
            int count = orgs.Count;

            int i = 0;

            foreach (var org in orgs)
            {
                json.Append("{");
                json.AppendFormat("\"id\":\"{0}\",", org.ID);
                json.AppendFormat("\"parentID\":\"{0}\",", org.ParentID);
                json.AppendFormat("\"title\":\"{0}\",", org.Name);
                json.AppendFormat("\"ico\":\"{0}\",", "");
                json.AppendFormat("\"link\":\"{0}\",", "");
                json.AppendFormat("\"type\":\"{0}\",", org.Type);
                json.AppendFormat("\"hasChilds\":\"{0}\",", org.ChildsLength);
                json.Append("\"childs\":[");
                json.Append("]");
                json.Append("}");
                if (i++ < count - 1 || users.Count > 0)
                {
                    json.Append(",");
                }
            }

            if (users.Count > 0)
            {
                var userRelations = new BizProcess.Platform.UsersRelation().GetAllByOrganizeID(root.ID);
                int count1        = users.Count;
                int j             = 0;
                foreach (var user in users)
                {
                    var ur = userRelations.Find(p => p.UserID == user.ID);
                    json.Append("{");
                    json.AppendFormat("\"id\":\"{0}\",", user.ID);
                    json.AppendFormat("\"parentID\":\"{0}\",", root.ID);
                    json.AppendFormat("\"title\":\"{0}{1}\",", user.Name, ur != null && ur.IsMain == 0 ? "<span style='color:#999;'>[兼职]</span>" : "");
                    json.AppendFormat("\"ico\":\"{0}\",", "");
                    json.AppendFormat("\"link\":\"{0}\",", "");
                    json.AppendFormat("\"type\":\"{0}\",", "4");
                    json.AppendFormat("\"hasChilds\":\"{0}\",", "0");
                    json.Append("\"childs\":[");
                    json.Append("]");
                    json.Append("}");
                    if (j++ < count1 - 1)
                    {
                        json.Append(",");
                    }
                }
            }


            json.Append("]");
            json.Append("}");
            json.Append("]");

            return(json.ToString());
        }
        public string TreeRefresh()
        {
            string id       = Request.QueryString["refreshid"];
            string showtype = Request.QueryString["showtype"];

            System.Text.StringBuilder json = new System.Text.StringBuilder("[", 1000);

            if ("1" == showtype)//显示工作组
            {
                BizProcess.Platform.WorkGroup BWorkGroup = new BizProcess.Platform.WorkGroup();
                var workGroups = BWorkGroup.GetAll();

                int countwg = workGroups.Count;
                int iwg     = 0;
                foreach (var wg in workGroups)
                {
                    json.Append("{");
                    json.AppendFormat("\"id\":\"{0}\",", wg.ID);
                    json.AppendFormat("\"parentID\":\"{0}\",", Guid.Empty);
                    json.AppendFormat("\"title\":\"{0}\",", wg.Name);
                    json.AppendFormat("\"ico\":\"{0}\",", "");
                    json.AppendFormat("\"link\":\"{0}\",", "");
                    json.AppendFormat("\"type\":\"{0}\",", 5);
                    json.AppendFormat("\"hasChilds\":\"{0}\",", 0);
                    json.Append("\"childs\":[");
                    json.Append("]");
                    json.Append("}");
                    if (iwg++ < countwg - 1)
                    {
                        json.Append(",");
                    }
                }

                json.Append("]");
                json.Append("}");
                Response.Write(json.ToString());
                Response.End();
            }


            Guid orgID;

            if (!id.IsGuid(out orgID))
            {
                json.Append("]");
                Response.Write(json.ToString());
            }

            BizProcess.Platform.Organize BOrganize = new BizProcess.Platform.Organize();
            var childOrgs = BOrganize.GetChilds(orgID);

            int count = childOrgs.Count;
            int i     = 0;

            foreach (var org in childOrgs)
            {
                json.Append("{");
                json.AppendFormat("\"id\":\"{0}\",", org.ID);
                json.AppendFormat("\"parentID\":\"{0}\",", id);
                json.AppendFormat("\"title\":\"{0}\",", org.Name);
                json.AppendFormat("\"ico\":\"{0}\",", "");
                json.AppendFormat("\"link\":\"{0}\",", "");
                json.AppendFormat("\"type\":\"{0}\",", org.Type);
                json.AppendFormat("\"hasChilds\":\"{0}\",", org.ChildsLength);
                json.Append("\"childs\":[");
                json.Append("]");
                json.Append("}");
                if (i++ < count - 1)
                {
                    json.Append(",");
                }
            }

            var userRelations = new BizProcess.Platform.UsersRelation().GetAllByOrganizeID(orgID);
            var users         = new BizProcess.Platform.Users().GetAllByOrganizeID(orgID);
            int count1        = users.Count;

            if (count1 > 0 && count > 0)
            {
                json.Append(",");
            }
            int j = 0;

            foreach (var user in users)
            {
                var ur = userRelations.Find(p => p.UserID == user.ID);
                json.Append("{");
                json.AppendFormat("\"id\":\"{0}\",", user.ID);
                json.AppendFormat("\"parentID\":\"{0}\",", id);
                json.AppendFormat("\"title\":\"{0}{1}\",", user.Name, ur != null && ur.IsMain == 0 ? "<span style='color:#999;'>[兼职]</span>" : "");
                json.AppendFormat("\"ico\":\"{0}\",", Url.Content("~/images/ico/contact_grey.png"));
                json.AppendFormat("\"link\":\"{0}\",", "");
                json.AppendFormat("\"type\":\"{0}\",", "4");
                json.AppendFormat("\"hasChilds\":\"{0}\",", "0");
                json.Append("\"childs\":[");
                json.Append("]");
                json.Append("}");
                if (j++ < count1 - 1)
                {
                    json.Append(",");
                }
            }
            json.Append("]");
            return(json.ToString());
        }
        public string Login(FormCollection collection)
        {
            //string isVcodeSessionKey = BizProcess.Utility.Keys.SessionKeys.IsValidateCode.ToString();
            //string vcodeSessionKey = BizProcess.Utility.Keys.SessionKeys.ValidateCode.ToString();
            ViewBag.Forcescript = "";
            //ViewBag.IsVcodeSessionKey = isVcodeSessionKey;
            ViewBag.ErrMsg = "";
            string account  = collection["Account"];
            string password = collection["Password"];
            string force    = collection["Force"];
            //string vcode = collection["VCode"];
            bool isSessionLost = "1" == Request.QueryString["session"];//是否是超时后再登录

            /*
             * if (System.Web.HttpContext.Current.Session[isVcodeSessionKey] != null
             *  && "1" == System.Web.HttpContext.Current.Session[isVcodeSessionKey].ToString()
             *  && (System.Web.HttpContext.Current.Session[vcodeSessionKey] == null
             || string.Compare(System.Web.HttpContext.Current.Session[vcodeSessionKey].ToString(), vcode.Trim(), true) != 0))
             ||{
             || ViewBag.ErrMsg = "alert('验证码错误!');";
             ||}
             ||else if
             * */
            if (account.IsNullOrEmpty() || password.IsNullOrEmpty())
            {
                //Session[isVcodeSessionKey] = "1";
                BizProcess.Platform.Log.Add("用户登录失败", string.Concat("用户:", account, "登录失败,帐号或密码为空"), BizProcess.Platform.Log.Types.用户登录);
                ViewBag.ErrMsg = "alert('帐号或密码不能为空!');";
            }
            else
            {
                BizProcess.Platform.Users busers = new BizProcess.Platform.Users();
                var user = busers.GetByAccount(account.Trim());
                if (user == null || string.Compare(user.Password, busers.GetUserEncryptionPassword(user.ID.ToString(), password.Trim()), false) != 0)
                {
                    //System.Web.HttpContext.Current.Session[isVcodeSessionKey] = "1";
                    BizProcess.Platform.Log.Add("用户登录失败", string.Concat("用户:", account, "登录失败,帐号或密码错误"), BizProcess.Platform.Log.Types.用户登录);
                    ViewBag.ErrMsg = "alert('帐号或密码错误!');";
                }
                else if (user.Status == 1)
                {
                    //System.Web.HttpContext.Current.Session[isVcodeSessionKey] = "1";
                    BizProcess.Platform.Log.Add("用户登录失败", string.Concat("用户:", account, "登录失败,帐号已被冻结"), BizProcess.Platform.Log.Types.用户登录);
                    ViewBag.ErrMsg = "alert('帐号已被冻结!');";
                }
                else
                {
                    BizProcess.Platform.OnlineUsers bou = new BizProcess.Platform.OnlineUsers();
                    var onUser = bou.Get(user.ID);
                    if (onUser != null && "1" != force)
                    {
                        string ip = onUser.IP;
                        //System.Web.HttpContext.Current.Session.Remove(isVcodeSessionKey);
                        ViewBag.Forcescript = "if(confirm('当前帐号已经在" + ip + "登录,您要强行登录吗?')){$('#Account').val('" + account + "');$('#Password').val('" + password + "');$('#Force').val('1');$('#form1').submit();}";
                    }
                    else
                    {
                        Guid uniqueID = Guid.NewGuid();
                        System.Web.HttpContext.Current.Session[BizProcess.Utility.Keys.SessionKeys.UserID.ToString()]       = user.ID;
                        System.Web.HttpContext.Current.Session[BizProcess.Utility.Keys.SessionKeys.UserUniqueID.ToString()] = uniqueID;
                        System.Web.HttpContext.Current.Session[BizProcess.Utility.Keys.SessionKeys.BaseUrl.ToString()]      = Url.Content("~/");
                        bou.Add(user, uniqueID);
                        //System.Web.HttpContext.Current.Session.Remove(isVcodeSessionKey);
                        BizProcess.Platform.Log.Add("用户登录成功", string.Concat("用户:", user.Name, "(", user.ID, ")登录成功"), BizProcess.Platform.Log.Types.用户登录);
                        if (isSessionLost)
                        {
                            ViewBag.Forcescript = "alert('登录成功!');new BPUI.Window().close();";
                        }
                        else
                        {
                            ViewBag.Forcescript = "location.replace('" + Url.Content("~/Home") + "');";
                            //return RedirectToAction("Index", "Home");
                        }
                    }
                }
            }
            return(ViewBag.Forcescript);
            //return View();
        }