Exemplo n.º 1
0
        public async Task <List <UserEnterReport> > GetAsync(DateTime startTime, DateTime endTime, int UserID)
        {
            List <UserEnterReport> list = new List <UserEnterReport>();

            try
            {
                await Task.Run(() =>
                {
                    DataContext dataContext = new DataContext();
                    var query = dataContext.EnterCustPhaseLogs.Where(x => x.CreateTime > startTime && x.CreateTime < endTime);
                    if (UserID > 0)
                    {
                        query = query.Where(x => x.UserID == UserID);
                    }
                    var report = from q in query.ToList()
                                 group q by q.UserID into g
                                 select new
                    {
                        UserID = g.Key,
                        Total  = g.Count()
                    };
                    if (report != null)
                    {
                        foreach (var r in report)
                        {
                            UserEnterReport uer = new UserEnterReport();
                            uer.Total           = r.Total;
                            uer.UserID          = r.UserID;
                            list.Add(uer);
                        }
                    }
                });
            } catch (Exception ex)
            {
                ClassLoger.Error("EnterCustPhaseLogDal.GetAsync", ex);
            }
            return(list);
        }
Exemplo n.º 2
0
        public async Task <List <UserEnterReport> > GetAsync(DateTime startTime, DateTime endTime, int userid)
        {
            List <UserEnterReport> list = new List <UserEnterReport>();

            try
            {
                await Task.Run(() => {
                    DataContext dataContext = new DataContext();
                    var query = dataContext.SalesProjects.Where(x => x.ProjectTime > startTime && x.ProjectTime < endTime);
                    if (userid > 0)
                    {
                        query = query.Where(x => x.HeadID == userid);
                    }
                    var report = from q in query.ToList()
                                 group q by q.HeadID into g
                                 select new
                    {
                        UserID = g.Key,
                        Total  = g.Count()
                    };
                    if (report != null)
                    {
                        foreach (var r in report)
                        {
                            UserEnterReport userEnterReport = new UserEnterReport();
                            userEnterReport.UserID          = r.UserID;
                            userEnterReport.Total           = r.Total;
                            list.Add(userEnterReport);
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                ClassLoger.Error("SalesProjectDal.GetAsync", ex);
            }
            return(list);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 统计用户录入客户数量
        /// </summary>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="userid"></param>
        /// <returns></returns>
        public async Task <List <UserEnterReport> > GetAsync(DateTime startTime, DateTime endTime, int userid)
        {
            try
            {
                List <UserEnterReport> list = new List <UserEnterReport>();
                await Task.Run(() => {
                    DataContext dataContext = new DataContext();
                    var query = dataContext.EnterCustomers.Where(x => x.CreateTime > startTime && x.CreateTime < endTime);
                    if (userid > 0)
                    {
                        query = query.Where(x => x.UserID == userid);
                    }
                    var report = from en in query.ToList()
                                 group en by en.UserID into g
                                 select new {
                        UserID = g.Key,
                        Total  = g.Count()
                    };
                    if (report != null)
                    {
                        foreach (var r in report)
                        {
                            UserEnterReport enterReport = new UserEnterReport();
                            enterReport.Total           = r.Total;
                            enterReport.UserID          = r.UserID;
                            list.Add(enterReport);
                        }
                    }
                });

                return(list);
            } catch (Exception ex)
            {
                ClassLoger.Error("EnterCustomerDal.GetAsync", ex);
            }
            return(null);
        }