Ejemplo n.º 1
0
        public ActionResult _ProjectResearchIndex(int?month)
        {
            var md = MonthDuration.GetMonthInstance(month);

            //权限控制
            var ps       = CRM_Logical.GetUserInvolveProject().Select(s => s.ID);
            var projects = Query.AliveProjects();
            var prs      = from p in projects.Where(w => ps.Contains(w.ID))
                           select new _ProjectResearch()
            {
                ProjectName            = p.Name_CH,
                MemberCount            = p.Members.Count,
                ProjectCode            = p.ProjectCode,
                ProjectID              = p.ID,
                FirstWeekCompanyCount  = p.CompanyRelationships.Count(w => w.CreatedDate >= md.StartDate1 && w.CreatedDate < md.EndDate1),
                SecondWeekCompanyCount = p.CompanyRelationships.Count(w => w.CreatedDate >= md.StartDate2 && w.CreatedDate < md.EndDate2),
                ThirdWeekCompanyCount  = p.CompanyRelationships.Count(w => w.CreatedDate >= md.StartDate3 && w.CreatedDate < md.EndDate3),
                FourthWeekCompanyCount = p.CompanyRelationships.Count(w => w.CreatedDate >= md.StartDate4 && w.CreatedDate < md.EndDate4),
                FivethWeekCompanyCount = p.CompanyRelationships.Count(w => w.CreatedDate >= md.StartDate5 && w.CreatedDate < md.EndDate5),
            };

            ViewBag.ProjectId = prs.FirstOrDefault().ProjectID;

            return(View(new GridModel(prs)));
        }
Ejemplo n.º 2
0
        public ActionResult ResearchIndex(int?month)
        {
            ViewBag.SelectedMonth = month;
            var md = MonthDuration.GetMonthInstance(month);

            return(View(md));
        }
Ejemplo n.º 3
0
        public ActionResult _UserResearchIndex(int?month)
        {
            var md = MonthDuration.GetMonthInstance(month);

            var           users     = Query.AliveMemberNames();
            List <string> saleslist = new List <string>();

            foreach (var d in CH.GetAllData <EmployeeRole>())
            {
                if (d.RoleID == 12)
                {
                    saleslist.Add(d.AccountName);
                }
            }

            if (Employee.CurrentRole.Level == ChinaTLRequired.LVL)
            {
                List <string> namelist = CRM_Logical.GetUserInvolveProject().SelectMany(w => w.Members).Select(f => f.Name).ToList();
                users = users.Where(w => saleslist.Contains(w) && namelist.Contains(w));
            }

            //权限控制
            var mems = CRM_Logical.GetUserInvolveProject().Select(s => s.Members.Where(w => w.IsActivated));

            var prs = //from c in CH.DB.CompanyRelationships group c by new {c.Creator} into cg
                      //from l in CH.DB.Leads group c by new {c.companyid} into lg
                      from l in CH.DB.Leads
                      group l by new { l.Creator } into lg
            from u in users
            where lg.Key.Creator == u

                select new _UserResearch()
            {
                UserName            = u,
                FirstWeekLeadCount  = lg.Count(w => w.CreatedDate >= md.StartDate2 && w.CreatedDate < md.EndDate2),
                SecondWeekLeadCount = lg.Count(w => w.CreatedDate >= md.StartDate2 && w.CreatedDate < md.EndDate2),
                ThirdWeekLeadCount  = lg.Count(w => w.CreatedDate >= md.StartDate3 && w.CreatedDate < md.EndDate3),
                FourthWeekLeadCount = lg.Count(w => w.CreatedDate >= md.StartDate4 && w.CreatedDate < md.EndDate4),
                FivethWeekLeadCount = lg.Count(w => w.CreatedDate >= md.StartDate5 && w.CreatedDate < md.EndDate5)
            };

            //var list = prs.ToList();
            //var lg = CH.DB.Leads.Where(w=>w.Creator==Employee.CurrentUserName);
            //foreach (var v in list)
            //{
            //        v.FirstWeekLeadCount = lg.Count(w => w.CreatedDate >= md.StartDate1 && w.CreatedDate < md.EndDate1);
            //        v.SecondWeekLeadCount = lg.Count(w => w.CreatedDate >= md.StartDate2 && w.CreatedDate < md.EndDate2);
            //        v.ThirdWeekLeadCount = lg.Count(w => w.CreatedDate >= md.StartDate3 && w.CreatedDate < md.EndDate3);
            //        v.FourthWeekLeadCount = lg.Count(w => w.CreatedDate >= md.StartDate4 && w.CreatedDate < md.EndDate4);
            //        v.FivethWeekLeadCount = lg.Count(w => w.CreatedDate >= md.StartDate5 && w.CreatedDate < md.EndDate5);
            //}

            //var nprs = from  l in CH.DB.Leads group l by new { l.Creator } into lg
            //           from p in list
            //           where p.UserName == lg.Key.Creator
            //           select new _UserResearch()
            //           {
            //               UserName = p.UserName,
            //               FirstWeekCompanyCount = p.FirstWeekCompanyCount,
            //               SecondWeekCompanyCount = p.SecondWeekCompanyCount,
            //               ThirdWeekCompanyCount = p.ThirdWeekCompanyCount,
            //               FourthWeekCompanyCount = p.FourthWeekCompanyCount,
            //               FivethWeekCompanyCount = p.FivethWeekCompanyCount,


            //           };

            return(View(new GridModel(prs)));
        }