Exemplo n.º 1
0
        public ActionResult EditUserInfo(FormCollection collection)
        {
            RoadFlow.Platform.Users users = new RoadFlow.Platform.Users();
            Guid currentUserId            = RoadFlow.Platform.Users.CurrentUserID;

            RoadFlow.Data.Model.Users model = users.Get(currentUserId);
            if (collection != null)
            {
                string str1 = this.Request.Form["Tel"];
                string str2 = this.Request.Form["MobilePhone"];
                string str3 = this.Request.Form["WeiXin"];
                string str4 = this.Request.Form["Email"];
                string str5 = this.Request.Form["QQ"];
                string str6 = this.Request.Form["OtherTel"];
                string str7 = this.Request.Form["Note"];
                int    num  = 0;
                model.Tel      = str1;
                model.Mobile   = str2;
                model.WeiXin   = str3;
                model.Email    = str4;
                model.QQ       = str5;
                model.OtherTel = str6;
                model.Note     = str7;
                if (num != 0)
                {
                    users.Add(model);
                }
                else
                {
                    users.Update(model);
                }
                // ISSUE: reference to a compiler-generated field
                if (UserInfoController.\u003C\u003Eo__2.\u003C\u003Ep__0 == null)
                {
                    // ISSUE: reference to a compiler-generated field
                    UserInfoController.\u003C\u003Eo__2.\u003C\u003Ep__0 = CallSite <Func <CallSite, object, string, object> > .Create(Binder.SetMember(CSharpBinderFlags.None, "script", typeof(UserInfoController), (IEnumerable <CSharpArgumentInfo>) new CSharpArgumentInfo[2]
                    {
                        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, (string)null),
                        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, (string)null)
                    }));
                }
                // ISSUE: reference to a compiler-generated field
                // ISSUE: reference to a compiler-generated field
                object obj = UserInfoController.\u003C\u003Eo__2.\u003C\u003Ep__0.Target((CallSite)UserInfoController.\u003C\u003Eo__2.\u003C\u003Ep__0, this.ViewBag, "alert('保存成功!');window.location=window.location;");
            }
            return((ActionResult)this.View((object)model));
        }
Exemplo n.º 2
0
        public string SaveUserHead()
        {
            string str1          = this.Request.Form["x"];
            string str2          = this.Request.Form["y"];
            string str3          = this.Request.Form["x2"];
            string str4          = this.Request.Form["y2"];
            string str5          = this.Request.Form["w"];
            string str6          = this.Request.Form["h"];
            string str7          = (this.Request.Form["img"] ?? "").DesDecrypt();
            Guid   currentUserId = RoadFlow.Platform.Users.CurrentUserID;

            if (!str7.IsNullOrEmpty())
            {
                if (File.Exists(str7))
                {
                    try
                    {
                        string str8 = ImgHelper.CutAvatar(str7, WebMvc.Common.Tools.BaseUrl + "/Content/UserHeads/" + (object)currentUserId + ".jpg", str1.ToInt(), str2.ToInt(), str5.ToInt(), str6.ToInt());
                        if (str8.IsNullOrEmpty())
                        {
                            return("保存失败!");
                        }
                        RoadFlow.Platform.Users   users = new RoadFlow.Platform.Users();
                        RoadFlow.Data.Model.Users model = users.Get(currentUserId);
                        if (model != null)
                        {
                            model.HeadImg = str8;
                            users.Update(model);
                        }
                        return("保存成功!");
                    }
                    catch
                    {
                        return("保存失败!");
                    }
                }
            }
            return("文件不存在!");
        }
Exemplo n.º 3
0
        public ActionResult User(FormCollection collection)
        {
            RoadFlow.Platform.Organize      borganize     = new RoadFlow.Platform.Organize();
            RoadFlow.Platform.Users         busers        = new RoadFlow.Platform.Users();
            RoadFlow.Platform.UsersRelation buserRelation = new RoadFlow.Platform.UsersRelation();
            RoadFlow.Data.Model.Users       user          = null;
            RoadFlow.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 RoadFlow.Platform.UsersRole().GetByUserIDFromCache(userID);
                    RoadFlow.Platform.Role    brole  = new RoadFlow.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);
                    RoadFlow.Platform.Log.Add("修改了用户", "", RoadFlow.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 RoadFlow.Platform.UsersInfo().Delete(user.ID);
                        new RoadFlow.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;
                    }
                    RoadFlow.Platform.Log.Add("删除了用户", user.Serialize(), RoadFlow.Platform.Log.Types.组织机构);
                    ViewBag.Script = "alert('删除成功');parent.frames[0].reLoad('" + refreshID + "');window.location='" + url + "'";
                    new RoadFlow.Platform.AppLibrary().ClearUseMemberCache();
                }

                //初始化密码
                if (!Request.Form["InitPass"].IsNullOrEmpty() && user != null)
                {
                    string initpass = busers.GetInitPassword();
                    busers.InitPassword(user.ID);
                    RoadFlow.Platform.Log.Add("初始化了用户密码", user.Serialize(), RoadFlow.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);
                            }

                            RoadFlow.Data.Model.UsersRelation ur = new RoadFlow.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 + "')";
                        }

                        RoadFlow.Platform.Log.Add(("1" == movetostationjz ? "兼职" : "全职") + "调动了人员的岗位", "将人员调往岗位(" + moveto + ")", RoadFlow.Platform.Log.Types.组织机构);
                        new RoadFlow.Platform.AppLibrary().ClearUseMemberCache();
                    }
                }
            }
            ViewBag.StatusRadios = borganize.GetStatusRadio("Status", status, "validate=\"radio\"");
            return(View(user));
        }
Exemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string rootid   = context.Request.QueryString["rootid"] ?? "";
            string showtype = context.Request.QueryString["showtype"] ?? "";

            RoadFlow.Platform.Organize  BOrganize  = new RoadFlow.Platform.Organize();
            RoadFlow.Platform.Users     busers     = new RoadFlow.Platform.Users();
            RoadFlow.Platform.WorkGroup BWorkGroup = new RoadFlow.Platform.WorkGroup();
            System.Text.StringBuilder   json       = new System.Text.StringBuilder("[", 1000);

            if ("1" == showtype)
            {
                #region 显示工作组

                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}\",", Common.Tools.BaseUrl + "/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("]");
                context.Response.Write(json.ToString());
                context.Response.End();
                #endregion
            }
            if (rootid.IsNullOrEmpty())
            {
                rootid = BOrganize.GetRoot().ID.ToString();
            }
            string[] rootIDArray = rootid.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            int      m           = 0;
            foreach (string rootID in rootIDArray)
            {
                List <RoadFlow.Data.Model.Users> users = new List <RoadFlow.Data.Model.Users>();
                Guid rootGuid = Guid.Empty;
                if (rootID.IsGuid(out rootGuid))
                {
                    var root = BOrganize.Get(rootGuid);
                    if (root != null)
                    {
                        users = busers.GetAllByOrganizeID(rootGuid);
                        json.Append("{");
                        json.AppendFormat("\"id\":\"{0}\",", root.ID);
                        json.AppendFormat("\"parentID\":\"{0}\",", root.ParentID);
                        json.AppendFormat("\"title\":\"{0}\",", root.Name);
                        json.AppendFormat("\"ico\":\"{0}\",", rootIDArray.Length == 1 ? Common.Tools.BaseUrl + "/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\":[");
                    }
                }
                else if (rootID.StartsWith(RoadFlow.Platform.Users.PREFIX))
                {
                    var root = busers.Get(busers.RemovePrefix1(rootID).ToGuid());
                    if (root != null)
                    {
                        json.Append("{");
                        json.AppendFormat("\"id\":\"{0}\",", root.ID);
                        json.AppendFormat("\"parentID\":\"{0}\",", Guid.Empty);
                        json.AppendFormat("\"title\":\"{0}\",", root.Name);
                        json.AppendFormat("\"ico\":\"{0}\",", Common.Tools.BaseUrl + "/images/ico/contact_grey.png");
                        json.AppendFormat("\"link\":\"{0}\",", "");
                        json.AppendFormat("\"type\":\"{0}\",", "4");
                        json.AppendFormat("\"hasChilds\":\"{0}\",", "0");
                        json.Append("\"childs\":[");
                    }
                }
                else if (rootID.StartsWith(RoadFlow.Platform.WorkGroup.PREFIX))
                {
                    var root = BWorkGroup.Get(BWorkGroup.RemovePrefix1(rootID).ToGuid());
                    if (root != null)
                    {
                        users = BOrganize.GetAllUsers(rootID);
                        json.Append("{");
                        json.AppendFormat("\"id\":\"{0}\",", root.ID);
                        json.AppendFormat("\"parentID\":\"{0}\",", Guid.Empty);
                        json.AppendFormat("\"title\":\"{0}\",", root.Name);
                        json.AppendFormat("\"ico\":\"{0}\",", "");
                        json.AppendFormat("\"link\":\"{0}\",", "");
                        json.AppendFormat("\"type\":\"{0}\",", "5");
                        json.AppendFormat("\"hasChilds\":\"{0}\",", users.Count > 0 ? "1" : "0");
                        json.Append("\"childs\":[");
                    }
                }

                #region 只有一个根时显示二级
                if (rootIDArray.Length == 1)
                {
                    List <RoadFlow.Data.Model.Organize> orgs = rootID.IsGuid() ? BOrganize.GetChilds(rootGuid)
                        : new List <RoadFlow.Data.Model.Organize>();
                    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 RoadFlow.Platform.UsersRelation().GetAllByOrganizeID(rootGuid);
                        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}\",", rootGuid);
                            json.AppendFormat("\"title\":\"{0}{1}\",", user.Name, ur != null && ur.IsMain == 0 ? "<span style='color:#999;'>[兼职]</span>" : "");
                            json.AppendFormat("\"ico\":\"{0}\",", Common.Tools.BaseUrl + "/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(",");
                            }
                        }
                    }
                }
                #endregion

                json.Append("]");
                json.Append("}");
                if (m++ < rootIDArray.Length - 1)
                {
                    json.Append(",");
                }
            }
            json.Append("]");

            context.Response.Write(json.ToString());
        }