Пример #1
0
        protected virtual DailyReportCollection ConvertToMonthDayResult(DateTime month, DailyReportCollection reports)
        {
            DailyReportCollection rv = new DailyReportCollection();
            DateTime today           = DateTime.Today;
            int      days;

            if (today.Year == month.Year &&
                today.Month == month.Month)
            {
                days = today.Day;
            }
            else
            {
                days = DateTime.DaysInMonth(month.Year, month.Month);
            }

            for (int i = days; i > 0; i--)
            {
                DailyReport report = reports.TryGetItem(month.Year, month.Month, i);
                if (report == null)
                {
                    report         = new DailyReport();
                    report.IsEmpty = true;
                    report.ItemID  = -i;
                    report.TaskID  = -1;
                    report.Date    = new DateTime(month.Year, month.Month, i);
                }
                rv.Add(report);

                report["Day"] = i;
            }

            return(rv);
        }
Пример #2
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);
                        }
                    }
                }

                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);
            }
        }