Ejemplo n.º 1
0
        public CombinationPayData SearchPays(bool needTimeRange,SearchPayTimeType timeType,
            DateTime startTime,
            DateTime endTime,
            bool? isFinished,
            string xiakeName,
            long lastId)
        {

            lock (LockObject)
            {
                Init();
                return mClient.Service.SearchPays(needTimeRange, timeType,startTime,endTime,isFinished,xiakeName,lastId);
            }
        }
Ejemplo n.º 2
0
        public CombinationPayData SearchPays (bool needTimeRange, SearchPayTimeType timeType, DateTime startTime, DateTime endTime, bool? isFinished, string xiakeName, long lastId)
        {
            var result = new CombinationPayData();
            using(var db = DbContextFactory.CreateDbContext())
            {
                var xk = db.Xiakes.FirstOrDefault(a => a.XiakeName == Thread.CurrentPrincipal.Identity.Name);
                if(xk == null ||
                   (xk.UserType != XiakeType.Mengzhu && xk.UserType != XiakeType.Tangzhu &&
                    xk.UserType != XiakeType.Xiaoer))
                    throw new FaultException("非管理员不可调用");
                IQueryable<Pay> pays = db.Pays.Include(a => a.Xiake)
                   .OrderByDescending(a => a.Id);

                if (lastId != 0)
                    pays = pays.Where(a => a.Id < lastId);
                if(needTimeRange)
                {
                    if(timeType == SearchPayTimeType.CreateTime)
                    {
                        pays = pays.Where(a => a.CreateTime >= startTime);
                        pays = pays.Where(a => a.CreateTime <= endTime);
                    } else
                    {
                        pays = pays.Where(a => a.FinishTime >= startTime);
                        pays = pays.Where(a => a.FinishTime <= endTime);
                    }
                }

                if(isFinished.HasValue)
                {
                    pays = pays.Where(a => a.IsFinished == isFinished);
                }
                if(!string.IsNullOrEmpty(xiakeName))
                {
                    pays = pays.Where(a => a.Xiake.XiakeName == xiakeName);
                }

                if (lastId == 0)
                    result.TotalCount = pays.Count();

                pays = pays.Take(DomainDefinition.PAGE_SIZE);
                foreach (var pay in pays )
                {
                    result.Items.Add(new PayData()
                    {
                         Id = pay.Id,
                         Account = pay.Account,
                         AccountTitle = pay.AccountTitle ,
                         CreateTime =pay.CreateTime,
                         Credits = pay.Credits,
                         IsFinished = pay.IsFinished,
                         Organization = pay.Organization,
                         Price = pay.Price,
                         Xiake = pay.Xiake.XiakeName, 
                         XiakeId = pay.Xiake.Id ,
                         FinishTime = pay.FinishTime
                    });
                }

                if (result.Items.Count < DomainDefinition.PAGE_SIZE)
                    result.IsLoadedAllData = true;

            }
            return result;
        }