Esempio n. 1
0
        public IActionResult WorkGroupSort()
        {
            List <Model.WorkGroup> workGroups = new Business.WorkGroup().GetAll();

            ViewData["queryString"] = Request.UrlQuery();
            return(View(workGroups));
        }
Esempio n. 2
0
        public IActionResult WorkGroup()
        {
            string workgroupid = Request.Querys("workgroupid");
            string type        = Request.Querys("type");
            string showtype    = Request.Querys("showtype");
            string appid       = Request.Querys("appid");
            string tabid       = Request.Querys("tabid");
            string query       = "type=" + type + "&showtype=" + showtype + "&appid=" + appid + "&tabid=" + tabid;

            Model.WorkGroup    workGroupModel = null;
            Business.WorkGroup workGroup      = new Business.WorkGroup();
            if (workgroupid.IsGuid(out Guid wid))
            {
                workGroupModel = workGroup.Get(wid);
            }
            if (null == workGroupModel)
            {
                workGroupModel = new Model.WorkGroup()
                {
                    Id   = Guid.NewGuid(),
                    Sort = workGroup.GetMaxSort()
                };
                workGroupModel.IntId = workGroupModel.Id.ToInt();
            }

            ViewData["query"]       = query;
            ViewData["queryString"] = Request.UrlQuery();
            ViewData["prevUrl"]     = ("WorkGroup" + Request.UrlQuery()).UrlEncode();
            return(View(workGroupModel));
        }
Esempio n. 3
0
        public string DeleteWorkGroup()
        {
            string workgroupid = Request.Querys("workgroupid");

            if (!workgroupid.IsGuid(out Guid wid))
            {
                return("ID错误");
            }
            Business.WorkGroup workGroup = new Business.WorkGroup();
            var workGroupModel           = workGroup.Get(wid);

            if (null == workGroupModel)
            {
                return("未找到要删除的工作组");
            }
            workGroup.Delete(workGroupModel);
            Business.Log.Add("删除了工作组-" + workGroupModel.Name, workGroupModel.ToString(), Business.Log.Type.系统管理);
            return("删除成功!");
        }
Esempio n. 4
0
        public string WorkGroupSortSave()
        {
            Business.WorkGroup workGroup = new Business.WorkGroup();
            var    all   = workGroup.GetAll();
            string sorts = Request.Forms("sort");
            int    i     = 0;

            foreach (string sort in sorts.Split(','))
            {
                if (!sort.IsGuid(out Guid wid))
                {
                    continue;
                }
                var workGroupModel = all.Find(p => p.Id == wid);
                if (null != workGroupModel)
                {
                    workGroupModel.Sort = i += 5;
                }
            }
            workGroup.Update(all.ToArray());
            return("排序成功!");
        }
Esempio n. 5
0
        public string SaveWorkGroup(Model.WorkGroup workGroupModel)
        {
            if (!ModelState.IsValid)
            {
                return(Tools.GetValidateErrorMessag(ModelState));
            }
            Business.WorkGroup workGroup   = new Business.WorkGroup();
            string             workgroupid = Request.Querys("workgroupid");

            if (workgroupid.IsGuid(out Guid wid))
            {
                var    oldModel = workGroup.Get(wid);
                string oldJSON  = null == oldModel ? "" : oldModel.ToString();
                workGroup.Update(workGroupModel);
                Business.Log.Add("修改了工作组-" + workGroupModel.Name, "", Business.Log.Type.系统管理, oldJSON, workGroupModel.ToString());
            }
            else
            {
                workGroup.Add(workGroupModel);
                Business.Log.Add("添加了工作组-" + workGroupModel.Name, workGroupModel.ToString(), Business.Log.Type.系统管理);
            }
            return("保存成功!");
        }
Esempio n. 6
0
        public string Tree1()
        {
            int    showType   = Request.Querys("showtype").ToString().ToInt(0);//显示类型 0组织架构 1角色组
            string rootId     = Request.Querys("rootid");
            string searchWord = Request.Querys("searchword");
            bool   showUser   = !"0".Equals(Request.Querys("shouser"));

            Business.Organize     organize     = new Business.Organize();
            Business.User         user         = new Business.User();
            Business.WorkGroup    workGroup    = new Business.WorkGroup();
            Business.OrganizeUser organizeUser = new Business.OrganizeUser();
            var  organizeUserList = organizeUser.GetAll();
            Guid orgRootId        = organize.GetRootId();

            Newtonsoft.Json.Linq.JArray jArray = new Newtonsoft.Json.Linq.JArray();

            #region 搜索
            if (!searchWord.IsNullOrWhiteSpace())
            {
                Guid parentId = Guid.NewGuid();
                if (1 == showType)//搜索工作组
                {
                    var workGroups = workGroup.GetAll().FindAll(p => p.Name.ContainsIgnoreCase(searchWord.Trim()));
                    Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                    {
                        { "id", parentId },
                        { "parentID", Guid.Empty },
                        { "title", "查询“" + searchWord + "”的结果" },
                        { "ico", "fa-search" },
                        { "link", "" },
                        { "type", 1 },
                        { "hasChilds", workGroups.Count }
                    };
                    jArray.Add(jObject);
                    Newtonsoft.Json.Linq.JArray jArray1 = new Newtonsoft.Json.Linq.JArray();
                    foreach (var group in workGroups)
                    {
                        Newtonsoft.Json.Linq.JObject jObject1 = new Newtonsoft.Json.Linq.JObject()
                        {
                            { "id", group.Id },
                            { "parentID", parentId },
                            { "title", group.Name },
                            { "ico", "fa-slideshare" },
                            { "link", "" },
                            { "type", 5 },
                            { "hasChilds", 0 }
                        };
                        jArray1.Add(jObject1);
                    }
                    jObject.Add("childs", jArray1);
                }
                else //搜索组织和人员
                {
                    var organizes = organize.GetAll().FindAll(p => p.Name.ContainsIgnoreCase(searchWord.Trim()));
                    var users     = user.GetAll().FindAll(p => p.Name.ContainsIgnoreCase(searchWord.Trim()));
                    Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                    {
                        { "id", parentId },
                        { "parentID", Guid.Empty },
                        { "title", "查询“" + searchWord + "”的结果" },
                        { "ico", "fa-search" },
                        { "link", "" },
                        { "type", 1 },
                        { "hasChilds", organizes.Count + users.Count }
                    };
                    jArray.Add(jObject);
                    Newtonsoft.Json.Linq.JArray jArray1 = new Newtonsoft.Json.Linq.JArray();
                    foreach (var organizeModel in organizes)
                    {
                        Newtonsoft.Json.Linq.JObject jObject1 = new Newtonsoft.Json.Linq.JObject()
                        {
                            { "id", organizeModel.Id },
                            { "parentID", parentId },
                            { "title", organizeModel.Name },
                            { "ico", "" },
                            { "link", "" },
                            { "type", organizeModel.Type },
                            { "hasChilds", organize.HasChilds(organizeModel.Id) ? 1 : 0 }
                        };
                        jArray1.Add(jObject1);
                    }
                    foreach (var userModel in users)
                    {
                        Newtonsoft.Json.Linq.JObject jObject1 = new Newtonsoft.Json.Linq.JObject()
                        {
                            { "id", userModel.Id },
                            { "parentID", parentId },
                            { "title", userModel.Name },
                            { "ico", "fa-user" },
                            { "link", "" },
                            { "userID", userModel.Id },
                            { "type", 4 },
                            { "hasChilds", 0 }
                        };
                        jArray1.Add(jObject1);
                    }
                    jObject.Add("childs", jArray1);
                }
                return(jArray.ToString());
            }
            #endregion

            #region 显示角色组
            if (1 == showType)
            {
                var workgroups = workGroup.GetAll();
                foreach (var workgroupModel in workgroups)
                {
                    Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                    {
                        { "id", workgroupModel.Id },
                        { "parentID", Guid.Empty },
                        { "title", workgroupModel.Name },
                        { "ico", "fa-slideshare" },
                        { "link", "" },
                        { "type", 5 },
                        { "hasChilds", 0 }
                    };
                    jArray.Add(jObject);
                }
                return(jArray.ToString());
            }
            #endregion

            if (rootId.IsNullOrWhiteSpace())
            {
                rootId = orgRootId.ToString();
            }
            #region 添加根节点
            string[] rootIdArray = rootId.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string root in rootIdArray)
            {
                if (root.IsGuid(out Guid guid))//组织机构
                {
                    var organizeModel = organize.Get(guid);
                    if (null != organizeModel)
                    {
                        Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                        {
                            { "id", organizeModel.Id },
                            { "parentID", organizeModel.ParentId },
                            { "title", organizeModel.Name },
                            { "ico", organizeModel.Id == orgRootId ? "fa-sitemap" : "" },
                            { "link", "" },
                            { "type", organizeModel.Type },
                            { "hasChilds", organize.HasChilds(organizeModel.Id) ? 1 : showUser?organize.HasUsers(organizeModel.Id) ? 1 : 0 : 0 }
                        };
                        jArray.Add(jObject);
                    }
                }
                else if (root.StartsWith(Business.Organize.PREFIX_USER))//人员
                {
                    var userModel = user.Get(root.RemoveUserPrefix().ToGuid());
                    if (null != userModel)
                    {
                        Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                        {
                            { "id", userModel.Id },
                            { "parentID", Guid.Empty },
                            { "title", userModel.Name },
                            { "ico", "fa-user" },
                            { "link", "" },
                            { "type", 4 },
                            { "hasChilds", 0 }
                        };
                        jArray.Add(jObject);
                    }
                }
                else if (root.StartsWith(Business.Organize.PREFIX_RELATION))//兼职人员
                {
                    var organizeUserModel = organizeUser.Get(root.RemoveUserRelationPrefix().ToGuid());
                    if (null != organizeUserModel)
                    {
                        var userModel = user.Get(organizeUserModel.UserId);
                        if (null != userModel)
                        {
                            Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                            {
                                { "id", organizeUserModel.Id },
                                { "parentID", Guid.Empty },
                                { "title", userModel.Name + "<span style='color:#666;'>[兼任]</span>" },
                                { "ico", "fa-user" },
                                { "link", "" },
                                { "type", 6 },
                                { "userID", userModel.Id },
                                { "hasChilds", 0 }
                            };
                            jArray.Add(jObject);
                        }
                    }
                }
                else if (root.StartsWith(Business.Organize.PREFIX_WORKGROUP))//工作组
                {
                    var workgroupModel = workGroup.Get(root.RemoveWorkGroupPrefix().ToGuid());
                    if (null != workgroupModel)
                    {
                        Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                        {
                            { "id", workgroupModel.Id },
                            { "parentID", Guid.Empty },
                            { "title", workgroupModel.Name },
                            { "ico", "fa-slideshare" },
                            { "link", "" },
                            { "type", 5 },
                            { "hasChilds", workGroup.GetAllUsers(workgroupModel.Id).Count }
                        };
                        jArray.Add(jObject);
                    }
                }
            }
            #endregion

            #region 只有一个根时显示二级
            if (rootIdArray.Length == 1)
            {
                string rootIdString = rootIdArray[0];
                if (rootIdString.IsGuid(out Guid guid))
                {
                    var jObject0 = (Newtonsoft.Json.Linq.JObject)jArray[0];
                    Newtonsoft.Json.Linq.JArray jArray0 = new Newtonsoft.Json.Linq.JArray();
                    var childs        = organize.GetChilds(guid);
                    var organizeUser1 = organizeUserList.FindAll(p => p.OrganizeId == guid);
                    foreach (var child in childs)
                    {
                        Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                        {
                            { "id", child.Id },
                            { "parentID", child.ParentId },
                            { "title", child.Name },
                            { "ico", "" },
                            { "link", "" },
                            { "type", child.Type },
                            { "hasChilds", organize.HasChilds(child.Id) ? 1 : showUser?organize.HasUsers(child.Id) ? 1 : 0 : 0 }
                        };
                        jArray0.Add(jObject);
                    }
                    if (showUser)
                    {
                        var users = organize.GetUsers(guid);
                        foreach (var userModel in users)
                        {
                            var  organizeUserModel1 = organizeUser1.Find(p => p.UserId == userModel.Id);
                            bool isPartTime         = organizeUserModel1.IsMain != 1;//是否是兼职
                            Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                            {
                                { "id", isPartTime ? organizeUserModel1.Id : userModel.Id },
                                { "parentID", guid },
                                { "title", userModel.Name + (isPartTime ? "<span style='color:#666;'>[兼任]</span>" : "") },
                                { "ico", "fa-user" },
                                { "link", "" },
                                { "userID", userModel.Id },
                                { "type", isPartTime ? 6 : 4 },
                                { "hasChilds", 0 }
                            };
                            jArray0.Add(jObject);
                        }
                    }
                    jObject0.Add("childs", jArray0);
                }
                else if (rootIdString.StartsWith(Business.Organize.PREFIX_WORKGROUP))
                {
                    var jObject0 = (Newtonsoft.Json.Linq.JObject)jArray[0];
                    Newtonsoft.Json.Linq.JArray jArray0 = new Newtonsoft.Json.Linq.JArray();
                    var users = workGroup.GetAllUsers(rootIdString.RemoveWorkGroupPrefix().ToGuid());
                    foreach (var userModel in users)
                    {
                        Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                        {
                            { "id", userModel.Id },
                            { "parentID", rootIdString.RemoveWorkGroupPrefix() },
                            { "title", userModel.Name },
                            { "ico", "fa-user" },
                            { "link", "" },
                            { "type", 4 },
                            { "hasChilds", 0 }
                        };
                        jArray0.Add(jObject);
                    }
                    jObject0.Add("childs", jArray0);
                }
            }
            #endregion

            return(jArray.ToString());
        }