Exemple #1
0
        public CombinationRenwuData2 SearchRenwusByMgmt(JubenType[] jubenTypes, BangpaiType[] bangpaiTypes
            , DateTime startTime, DateTime endTime, bool isTimeRangeRequired, long lastId)
        {
            var result = new CombinationRenwuData2();
            using (var db = DbContextFactory.CreateDbContext())
            {
                var xiake = db.Xiakes.Include(a => a.Credits).FirstOrDefault(a => a.XiakeName == Thread.CurrentPrincipal.Identity.Name);
                if (xiake.UserType != XiakeType.Xiaoer && xiake.UserType != XiakeType.Tangzhu && xiake.UserType != XiakeType.Mengzhu)
                    throw new FaultException("非管理账号不可调用");

                IQueryable<Renwu> renws = db.Renwus.OrderByDescending(a => a.Id);

                if (lastId != 0)
                {
                    renws = renws.Where(a => a.Id < lastId);
                }

                renws = renws.Where(a => jubenTypes.Contains(a.NextStep.Value ));
                renws = renws.Where(a => bangpaiTypes.Contains(a.Bangpai));

                if (isTimeRangeRequired)
                {

                    renws = renws.Where(a => a.RunTime >= startTime && a.RunTime <= endTime);

                }
                if (lastId == 0)
                {
                    result.TotalCount = renws.Count();
                }
                renws = renws.Include(a => a.Biao).Include(a => a.Biaoshi).Include(a=>a.Biaoju).Include(a=>a.Biao.Dianpu).Include(a=>a.Biao.Zhanggui);
                renws = renws.Take(DomainDefinition.PAGE_SIZE);
                
                foreach (var dp in renws)
                {
                    var x = new RenwuData2()
                    {
                        ID = dp.Id, 
                        BiaoshiName = dp.Biaoshi.Title,
                        BangpaiType = dp.Bangpai,
                        Price = dp.Biao.Price,
                        RunningTime = dp.RunTime,
                        SearchWord = dp.Biao.SearchWord,
                        NextStep = dp.NextStep.Value ,
                        Steps = dp.Steps,
                        Salary = dp.Biao.Salary,
                        Biaoju = dp.Biaoju.XiakeName, 
                        BiaojuId = dp.Biaoju.Id,
                        ZhangguiId = dp.Biao.Zhanggui.Id,
                        ZhangguiName = dp.Biao.Zhanggui.XiakeName,
                        ZhangguiQQ = dp.Biao.Zhanggui.QQ,
                        Dianpu  = dp.Biao.Dianpu.Name,
                        BiaojuQQ = dp.Biaoju.QQ ,
                        IsDisabled = dp.IsDisabled
                    };
                    result.Items.Add(x);
                }
                if (result.Items.Count < DomainDefinition.PAGE_SIZE)
                {
                    result.IsLoadedAllData = true;
                }


            }
            return result;
        }
        public CombinationJubenErrorLogData SearchLogsByMgmt (JubenType[] jubenTypes,
            JubenErrorType[] errorTypes,
            DateTime startTime,
            DateTime endTime,
            bool isTimeRangeRequired,
            long lastId)
        {
            var result = new CombinationJubenErrorLogData();
            using (var db = DbContextFactory.CreateDbContext())
            {

                var xiake = db.Xiakes.FirstOrDefault(a => a.XiakeName == Thread.CurrentPrincipal.Identity.Name);
                if (xiake.UserType != XiakeType.Tangzhu && xiake.UserType != XiakeType.Mengzhu)
                    throw new FaultException("非管理账号不可调用");

                IQueryable<JubenErrorLog> logs = db.JubenErrorLogs.OrderByDescending(a => a.Id);

                if (lastId != 0)
                {
                    logs = logs.Where(a => a.Id < lastId);
                }

                logs = logs.Where(a => jubenTypes.Contains(a.JubenType));
                logs = logs.Where(a => errorTypes.Contains(a.JubenErrorType));

                if (isTimeRangeRequired)
                {

                    logs = logs.Where(a => a.CreateTime >= startTime && a.CreateTime <= endTime);

                }
                if (lastId == 0)
                {
                    result.TotalCount = logs.Count();
                }
                logs = logs.Include(a => a.Xiake);
                logs = logs.Take(DomainDefinition.PAGE_SIZE);

                foreach (var dp in logs)
                {
                    var x = new JubenErrorLogData()
                    {
                        Id = dp.Id,
                        CreateTime = dp.CreateTime,
                        JubenType = dp.JubenType,
                        JubenErrorType = dp.JubenErrorType,
                        Logs = dp.Logs,
                        Xiake  = dp.Xiake.XiakeName,
                        XiakeId = dp.Xiake.Id,
                        JubenName = dp.JubenName
                    };
                    result.Items.Add(x);
                }
                if (result.Items.Count < DomainDefinition.PAGE_SIZE)
                {
                    result.IsLoadedAllData = true;
                }


            }
            return result;
        }