public virtual object GetTeamReports(HttpContext context) { YZRequest request = new YZRequest(context); string myaccount = request.GetString("account", YZAuthHelper.LoginUserAccount); DateTime date = request.GetDateTime("date"); BPMObjectNameCollection accounts = new BPMObjectNameCollection(); accounts.Add(myaccount); using (BPMConnection bpmcn = new BPMConnection()) { bpmcn.WebOpen(); MemberCollection positions = OrgSvr.GetUserPositions(bpmcn, myaccount); foreach (Member position in positions) { DirectXSCollection xss = position.GetDirectXSs(bpmcn); foreach (DirectXS xs in xss) { if (!accounts.Contains(xs.UserAccount)) { accounts.Add(xs.UserAccount); } } } DailyReportCollection rv = new DailyReportCollection(); foreach (string account in accounts) { DailyReport dailyReport; using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { dailyReport = DailyReportManager.TryGetReport(provider, cn, account, date); if (dailyReport == null) { dailyReport = new DailyReport(); dailyReport.Account = account; dailyReport.Date = date; } rv.Add(dailyReport); } } User user = User.TryGetUser(bpmcn, account); dailyReport["ShortName"] = user == null ? "" : user.ShortName; } return(rv); } }
public virtual object TryGetReport(HttpContext context) { YZRequest request = new YZRequest(context); string account = request.GetString("account", YZAuthHelper.LoginUserAccount); DateTime date = request.GetDateTime("date"); using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { return(new { report = DailyReportManager.TryGetReport(provider, cn, account, date) }); } } }