Ejemplo n.º 1
0
        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);
                        }
                    }
                }

                MonthlyReportCollection rv = new MonthlyReportCollection();
                foreach (string account in accounts)
                {
                    MonthlyReport monthlyReport;

                    using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
                    {
                        using (IDbConnection cn = provider.OpenConnection())
                        {
                            monthlyReport = MonthlyReportManager.TryGetReport(provider, cn, account, date);

                            if (monthlyReport == null)
                            {
                                monthlyReport         = new MonthlyReport();
                                monthlyReport.Account = account;
                                monthlyReport.Date    = date;
                            }

                            rv.Add(monthlyReport);
                        }
                    }

                    User user = User.TryGetUser(bpmcn, account);
                    monthlyReport["ShortName"] = user == null ? "" : user.ShortName;
                }

                return(rv);
            }
        }
Ejemplo n.º 2
0
        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 = MonthlyReportManager.TryGetReport(provider, cn, account, date)
                    });
                }
            }
        }