コード例 #1
0
ファイル: PlanService.cs プロジェクト: Lincoln007/DotNet.ERP
        public object MyReplyIndexPageList(System.Collections.Specialized.NameValueCollection nvl, out int recordCount)
        {
            var type   = nvl["Type"].ToType <short>();
            var status = nvl["Status"].ToType <short>();
            var begin  = nvl["CreateDT_begin"].ToType <DateTime?>();
            var end    = nvl["CreateDT_end"].ToType <DateTime?>();

            if (end.HasValue)
            {
                end = end.Value.AddDays(1);
            }
            var search    = (nvl["SearchText"] ?? "").Trim();
            var detail    = nvl["detail"];//是否已批复
            var queryUser = UserRepository.GetQuery();
            var queryDict = DictRepository.GetQuery();

            var where = DynamicallyLinqHelper.Empty <Plans>().And(o => o.Type == type, type == 0).And(o => o.Status == status, status == 0)
                        .And(o => o.CreateDT >= begin, !begin.HasValue).And(o => o.CreateDT < end, !end.HasValue).And(o => o.Content.Contains(search), search.IsNullOrEmpty())
                        .And(o => o.LeaderUID.Contains(CurrentUser.UID)).And(o => !(o.Summary == null || o.Summary == ""));
            if (detail.IsNullOrEmpty())
            {
                where = where.And(o => !o.Replys.Any());
            }
            else
            {
                where = where.And(o => o.Replys.Any());
            }
            var query = PlanRepository.GetQuery(where).Include(o => o.Attachments).Include(o => o.Replys);
            var q     = from x in query
                        select new
            {
                x.Id,
                x.AssignerUID,
                Assigner = queryUser.Where(o => o.UserId == x.AssignerUID).Select(o => o.FullName).FirstOrDefault(),
                Creater  = queryUser.Where(o => o.UserId == x.CreateUID).Select(o => o.FullName).FirstOrDefault(),
                x.Content,
                AttachCount = x.Attachments.Count,
                x.CreateDT,
                x.CreateUID,
                x.StartDate,
                x.EndDate,
                ReplyCount = x.Replys.Count,
                x.Status,
                x.Type,
                x.Summary,
                StatuTitle = queryDict.Where(o => o.DicSN == x.Status).Select(o => o.Title).FirstOrDefault(),
                TypeTitle  = queryDict.Where(o => o.DicSN == x.Type).Select(o => o.Title).FirstOrDefault(),
            };

            recordCount = q.Count();
            var list = q.ToPageList();

            return(list);
        }
コード例 #2
0
        public OpResult UpdateData()
        {
            ProductPublishVer ver = null;

            try
            {
                using (TransactionScope tran = new TransactionScope())
                {
                    ver = PublishVerService.UpdatePublish(0, 1, CurrentUser.FullName);
                    if (ver.ProductModuleVer != null)
                    {
                        var menus  = new List <SysMenus>();
                        var limits = new List <SysLimits>();
                        ver.ProductModuleVer.ProductMenuLimits.Each(o =>
                        {
                            switch (o.Type)
                            {
                            case 1:
                                menus.Add(new SysMenus()
                                {
                                    MenuId = o.MenuId, PMenuId = o.PMenuId, SortOrder = o.SortOrder, Status = o.Status, Title = o.Title, URL = o.Url
                                });
                                break;

                            case 3:
                                limits.Add(new SysLimits()
                                {
                                    LimitId = o.MenuId, PLimitId = o.PMenuId, SortOrder = o.SortOrder, Status = o.Status, Title = o.Title
                                });
                                break;

                            default:
                                break;
                            }
                        });
                        if (menus.Any())
                        {
                            var list = MenuRepository.GetQuery().ToList();
                            MenuRepository.RemoveRange(list);
                            MenuRepository.AddRange(menus);
                        }
                        if (limits.Any())
                        {
                            LimitRepository.RemoveRange(LimitRepository.GetQuery().ToList());
                            LimitRepository.AddRange(limits);
                        }
                    }
                    if (ver.ProductRoleVer != null)
                    {
                        var roles = new List <SysRoles>();
                        ver.ProductRoleVer.ProductRoles.Each(o =>
                        {
                            var role          = new SysRoles();
                            role.CreateDT     = DateTime.Now;
                            role.CreateUID    = CurrentUser.UID;
                            role.RoleId       = o.RoleId.GetValueOrDefault();
                            role.Title        = o.Title;
                            role.Limitids     = o.Limitids;
                            role.Type         = 0;
                            role.Status       = true;
                            role.UpdateDT     = role.CreateDT;
                            role.UpdateUID    = role.CreateUID;
                            role.SysRoleDatas = new List <SysRoleData>();
                            o.ProductRoleDatas.Each(i =>
                            {
                                role.SysRoleDatas.Add(new SysRoleData()
                                {
                                    HasSelected = i.HasSelected,
                                    MenuId      = i.MenuId,
                                    PMenuId     = i.PMenuId,
                                    SortOrder   = i.SortOrder
                                });
                            });
                            roles.Add(role);
                        });
                        if (roles.Any())
                        {
                            var list = RoleRepository.GetQuery(o => o.Type == 0).Include(o => o.SysRoleDatas).ToList();
                            roles.Each(o => {
                                var r = list.FirstOrDefault(i => i.RoleId == o.RoleId);
                                if (r != null)
                                {
                                    o.DeptId = r.DeptId;
                                    if (!r.Memo.IsNullOrEmpty())
                                    {
                                        o.Memo = r.Memo;
                                    }
                                    o.Status    = r.Status;
                                    o.CreateDT  = r.CreateDT;
                                    o.CreateUID = r.CreateUID;
                                }
                            });
                            RoleDataRepository.RemoveRange(list.SelectMany(o => o.SysRoleDatas).ToList());
                            RoleRepository.RemoveRange(list);
                            RoleRepository.AddRange(roles);
                        }
                    }
                    if (ver.ProductDictionaryVer != null)
                    {
                        var dicts = new List <SysDataDictionary>();
                        ver.ProductDictionaryVer.ProductDictionaryDatas.Each(o =>
                        {
                            dicts.Add(new SysDataDictionary()
                            {
                                CreateDT  = DateTime.Now,
                                CreateUID = CurrentUser.UID,
                                Depth     = o.Depth,
                                DicPSN    = o.DicPSN,
                                DicSN     = o.DicSN,
                                HasChild  = o.HasChild,
                                SortOrder = o.SortOrder,
                                Status    = Convert.ToBoolean(o.Status),
                                Title     = o.Title
                            });
                        });
                        if (dicts.Any())
                        {
                            var list = DictRepository.GetQuery().ToList();
                            DictRepository.RemoveRange(list);
                            DictRepository.AddRange(dicts);
                        }
                    }
                    var sqls = new Dictionary <int, string>();
                    var db   = new DBFramework.DBHelper();
                    if (ver.ProductDataVer != null)
                    {
                        ver.ProductDataVer.ProductDataSqls.OrderBy(o => o.RunSort).Each(o =>
                        {
                            sqls[o.MenuId] = o.RunSql;
                        });
                        foreach (var de in sqls)
                        {
                            try
                            {
                                db.ExecuteNonQueryText(de.Value, null);
                            }
                            catch (Exception ex)
                            {
                                throw new Exception("更新初始化数据失败!MenuId:" + de.Key + ";" + LogEngine.ToInnerException(ex).Message);
                            }
                        }
                        sqls.Clear();
                    }
                    ver.ProductPublishSqls.OrderBy(o => o.RunSort).Each(o =>
                    {
                        sqls[o.MenuId] = o.RunSql;
                    });
                    foreach (var de in sqls)
                    {
                        try
                        {
                            db.ExecuteNonQueryText(de.Value, null);
                        }
                        catch (Exception ex)
                        {
                            throw new Exception("历史数据处理失败!MenuId:" + de.Key + ";" + LogEngine.ToInnerException(ex).Message);
                        }
                    }
                    tran.Complete();
                }
            }catch (Exception e)
            {
                LogEngine.WriteError(e);
                if (ver != null)
                {
                    PublishVerService.AddUpdateLog(ver.PublishId, 0, false, LogEngine.ToInnerException(e).Message, CurrentUser.FullName);
                }
                return(OpResult.Fail());
            }
            return(OpResult.Success());
        }
コード例 #3
0
ファイル: PlanService.cs プロジェクト: Lincoln007/DotNet.ERP
        public object IndexPageList(System.Collections.Specialized.NameValueCollection nvl, out int recordCount)
        {
            var type   = nvl["Type"].ToType <short>();
            var status = nvl["Status"].ToType <short>();
            var begin  = nvl["CreateDT_begin"].ToType <DateTime?>();
            var end    = nvl["CreateDT_end"].ToType <DateTime?>();

            if (end.HasValue)
            {
                end = end.Value.AddDays(1);
            }
            var search      = (nvl["SearchText"] ?? "").Trim();
            var assignerUID = (nvl["AssignerUID"] ?? "").Trim();
            var all         = nvl["all"];//是否所有计划
            var assigers    = assignerUID.Split(',').ToList();
            var queryUser   = UserRepository.GetQuery();
            var queryDict   = DictRepository.GetQuery();

            var where = DynamicallyLinqHelper.Empty <Plans>().And(o => o.Type == type, type == 0).And(o => o.Status == status, status == 0)
                        .And(o => o.CreateDT >= begin, !begin.HasValue).And(o => o.CreateDT < end, !end.HasValue).And(o => o.Content.Contains(search), search.IsNullOrEmpty());


            if (all.IsNullOrEmpty())
            {
                where = where.And(o => (o.CreateUID == CurrentUser.UID || o.AssignerUID == CurrentUser.UID));
            }
            else
            {
                if (CurrentUser.HasPermiss(255))//查看所有人员
                {
                    where = where.And(o => (o.Summary == null || o.Summary == ""));
                }
                else if (CurrentUser.HasPermiss(99))//查看本部门及以下
                {
                    var users = CurrentUser.GetAllCreateUIDByDeptId(CurrentUser.DeptId);
                    where = where.And(o => (users.Contains(o.CreateUID) || o.LeaderUID.Contains(CurrentUser.UID)) && (o.Summary == null || o.Summary == ""));
                }
                else
                {
                    where = where.And(o => o.LeaderUID.Contains(CurrentUser.UID)).And(o => (o.Summary == null || o.Summary == ""));
                }
                where = where.And(o => assigers.Contains(o.AssignerUID), assignerUID.IsNullOrEmpty());
            }
            var query = PlanRepository.GetQuery(where).Include(o => o.Attachments).Include(o => o.Replys);
            var q     = from x in query
                        select new
            {
                x.Id,
                x.AssignerUID,
                Assigner = queryUser.Where(o => o.UserId == x.AssignerUID).Select(o => o.FullName).FirstOrDefault(),
                Creater  = queryUser.Where(o => o.UserId == x.CreateUID).Select(o => o.FullName).FirstOrDefault(),
                x.Content,
                AttachCount = x.Attachments.Count,
                x.CreateDT,
                x.CreateUID,
                x.StartDate,
                x.EndDate,
                ReplyCount = x.Replys.Count,
                x.Status,
                x.Type,
                x.Summary,
                StatuTitle = queryDict.Where(o => o.DicSN == x.Status).Select(o => o.Title).FirstOrDefault(),
                TypeTitle  = queryDict.Where(o => o.DicSN == x.Type).Select(o => o.Title).FirstOrDefault(),
            };

            recordCount = q.Count();
            var list = q.ToPageList();

            return(list);
        }
コード例 #4
0
        public IEnumerable <dynamic> GetPageList(System.Collections.Specialized.NameValueCollection nvl, out int recordCount)
        {
            var text        = nvl["searchText"];
            var category    = nvl["category"];
            var assigner    = nvl["assigner"];
            var searchField = nvl["searchField"];
            var state       = nvl["state"];
            var queryDev    = DevicesRepository.GetQuery();
            var queryDict   = DictRepository.GetQuery();
            var queryUser   = UserRepository.GetQuery();

            var where = DynamicallyLinqHelper.Empty <DeviceAuthorize>();
            if (!text.IsNullOrEmpty())
            {
                int cid = 0;
                text = text.Trim();
                int.TryParse(text, out cid);
                if (searchField == "Cid")
                {
                    where = where.And(o => o.CID == cid);
                }
                else if (searchField == "DeviceNo")
                {
                    where = where.And(o => o.DeviceNo != null && o.DeviceNo.StartsWith(text));
                }
                else if (searchField == "ContractNo")
                {
                    where = where.And(o => o.ContractNo != null && o.ContractNo.StartsWith(text));
                }
            }
            if (!state.IsNullOrEmpty())
            {
                var st = short.Parse(state);
                where = where.And(o => o.Status == st);
            }
            if (!assigner.IsNullOrEmpty())
            {
                where = where.And(o => o.AssignerUID == assigner);
            }
            var queryDevAuth = DeviceAuthorRepository.GetQuery(where);
            var query        = from x in queryDevAuth
                               join y in queryDev on x.DeviceId equals y.DeviceId
                               select new
            {
                x.Id,
                x.CID,
                x.Title,
                x.Source,
                Category = queryDict.Where(o => o.DicSN == y.CategoryId).Select(o => o.Title).FirstOrDefault(),
                y.Spec,
                y.Brand,
                x.DeviceNo,
                x.StoreName,
                x.EffectiveDT,
                x.ValidityNum,
                x.ExpirationDT,
                x.ContractNo,
                x.Status,
                y.CategoryId,
                x.CreateDT,
                x.MachineNo,
                Assigner = queryUser.Where(o => o.UserId == x.AssignerUID).Select(o => o.FullName).FirstOrDefault()
            };

            if (!category.IsNullOrEmpty())
            {
                var st = short.Parse(category);
                query = query.Where(o => o.CategoryId == st);
            }
            recordCount = query.Count();
            return(query.ToPageList());
        }