示例#1
0
        /// <summary>
        /// 获取所有分组 树形结构
        /// </summary>
        /// <param name="groups"></param>
        /// <returns></returns>
        private GroupDTOList GetGroupChild(List <Group> groups)
        {
            GroupDTOList gdtolist = new GroupDTOList();

            if (groups == null)
            {
                return(gdtolist);
            }
            else
            {
                groups.OrderByDescending(g => g.Index);
                groups.ForEach(g =>
                {
                    GroupDTO dto    = new GroupDTO();
                    dto.CreateDate  = g.CreateDate;
                    dto.Creator     = g.Creator;
                    dto.Description = g.Description;
                    dto.EditDate    = g.EditDate;
                    dto.ID          = g.ID.ToString();
                    dto.Name        = g.Name;
                    dto.Index       = g.Index;
                    dto.ParentID    = g.ParentGroup != null ? g.ParentGroup.ID : Guid.Empty;
                    dto.ParentName  = g.ParentGroup != null ? g.ParentGroup.Name : string.Empty;
                    dto.Status      = (Wings.DataObjects.Status)g.Status;

                    if (g.ChildGroup != null && g.ChildGroup.Count > 0)
                    {
                        dto.ChildGroup = GetGroupChild(g.ChildGroup);
                    }
                    gdtolist.Add(dto);
                });
            }
            return(gdtolist);
        }
示例#2
0
        /// <summary>
        /// 获取所有分组信息
        /// </summary>
        /// <returns></returns>
        public GroupDTOList GetAllGroups()
        {
            var          groups   = groupRespository.FindAll().ToList();
            GroupDTOList gdtolist = GetGroupChild(groups);

            return(gdtolist);
        }
示例#3
0
 public void DeleteGroup(GroupDTOList groups)
 {
     PerformUpdateObjects <GroupDTOList, GroupDTO, Group>(groups, groupRespository, g => g.ID, (g, gdto) =>
     {
         g.Status = Wings.Domain.Model.Status.Deleted;
     });
 }
示例#4
0
        /// <summary>
        /// 根据父id获取分组
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>

        public GroupDTOList GetGroupParentID(Guid?id)
        {
            var          groups   = groupRespository.FindAll(Specification <Group> .Eval(g => g.ParentGroup.ID.Equals(id))).ToList();
            GroupDTOList gdtolist = GetGroupChild(groups);

            return(gdtolist);
        }
示例#5
0
        public GroupDTOList CreateGroup(GroupDTOList groups)
        {
            GroupDTOList result = PerformCreateObjects <GroupDTOList, GroupDTO, Group>(groups, groupRespository);

            return(PerformUpdateObjects <GroupDTOList, GroupDTO, Group>(result, groupRespository, g => g.ID, (g, gdto) =>
            {
                var thisdto = groups[result.IndexOf(gdto)];
                g.ParentGroup = !thisdto._parentId.HasValue ? null : groupRespository.Find(Specification <Group> .Eval(gg => gg.ID.Equals(thisdto._parentId.Value)));
            }).ToViewModel());
        }
示例#6
0
 public GroupDTOList EditGroup(GroupDTOList groups)
 {
     return(PerformUpdateObjects <GroupDTOList, GroupDTO, Group>(groups, groupRespository, g => g.ID, (g, gdto) =>
     {
         g.Index = gdto.Index;
         g.Name = gdto.Name;
         g.Description = gdto.Description;
         g.EditDate = DateTime.Now;
         g.ParentGroup = !gdto._parentId.HasValue ? null : groupRespository.Find(Specification <Group> .Eval(gg => gg.ID.Equals(gdto._parentId.Value)));
     }).ToViewModel());
 }
示例#7
0
        public ActionResult GetDataGrid(Pagination p)
        {
            GroupDTOList groupdata = new GroupDTOList();

            using (ServiceProxy <IUserService> proxy = new ServiceProxy <IUserService>())
            {
                groupdata = proxy.Channel.GetAllGroups();
            }
            groupdata.ForEach(g => g.ChildGroup = null);
            var result = new DataGrid()
            {
                total = groupdata.Count, rows = groupdata
            };

            //Log.OperaInstance.SaveMessage(1, string.Format("操作:{0};结果:{1};信息:{2}", "获取分组数据表", true, ""));
            return(Json(result));
        }
示例#8
0
        public ActionResult Delete(IDList idlist)
        {
            Result result = new Result();

            result.message = "删除部门失败";


            if (idlist == null || idlist.Count == 0)
            {
                result.message = "您提交的数据为空,请重新选择!";
                return(Json(result));
            }
            GroupDTOList dtolist = new GroupDTOList();

            idlist.Where(f => !string.IsNullOrEmpty(f)).ToList().ForEach(s =>
            {
                Guid temp = Guid.Empty;
                s.Split(',').ToList().ForEach(g =>
                {
                    if (Guid.TryParse(g, out temp))
                    {
                        dtolist.Add(new GroupDTO()
                        {
                            ID = g
                        });;
                    }
                }
                                              );
            });
            using (ServiceProxy <IUserService> proxy = new ServiceProxy <IUserService>())
            {
                try
                {
                    proxy.Channel.DeleteGroup(dtolist);
                    result.success = true;
                    result.message = "删除成功";
                }
                catch (Exception ex)
                {
                    result.message = ex.Message;
                }
            }
            //Log.OperaInstance.SaveMessage(1, string.Format("操作:{0};结果:{1};信息:{2}", "删除分组(禁用)", true, ""));
            return(Json(result));
        }
示例#9
0
        public ActionResult Edit(GroupDTO group)
        {
            Result result = new Result();

            result.message = "修改部门失败";
            using (ServiceProxy <IUserService> proxy = new ServiceProxy <IUserService>())
            {
                group.EditDate = DateTime.Now;
                GroupDTOList dtolist = new GroupDTOList();
                dtolist.Add(group);
                proxy.Channel.EditGroup(dtolist);
                if (!string.IsNullOrEmpty(group.ID))
                {
                    result.success = true;
                    result.message = "修改部门成功";
                }
            }
            //Log.OperaInstance.SaveMessage(1, string.Format("操作:{0};结果:{1};信息:{2}", "分组编辑", true, ""));
            return(Json(result));
        }