Ejemplo n.º 1
0
        public static string BuildReport(ReportType reportType, TaskFilter filter, ReportViewType viewType, int templateID)
        {
            //prepare filter
            if (templateID != 0 && !filter.FromDate.Equals(DateTime.MinValue))
            {
                var interval = filter.ToDate.DayOfYear - filter.FromDate.DayOfYear;

                switch (reportType)
                {
                case ReportType.TasksByUsers:
                case ReportType.TasksByProjects:
                {
                    filter.FromDate = TenantUtil.DateTimeNow().Date.AddDays(-interval);
                    filter.ToDate   = TenantUtil.DateTimeNow().Date;
                }
                break;

                case ReportType.MilestonesNearest:
                {
                    filter.FromDate = TenantUtil.DateTimeNow().Date;
                    filter.ToDate   = TenantUtil.DateTimeNow().Date.AddDays(interval);
                }
                break;
                }
            }

            //exec

            var report = Report.CreateNewReport(reportType, filter);
            var data   = report.BuildReport().ToList();

            if (!data.Any())
            {
                report = Report.CreateNewReport(ReportType.EmptyReport, filter);
            }

            return(ReportTransformer.Transform(data.ToList(), report, filter.ViewType, viewType, templateID));
        }
Ejemplo n.º 2
0
        public static string BuildReport(ReportType reportType, ReportFilter filter, ReportViewType viewType)
        {
            //prepare filter
            if (reportType == ReportType.MilestonesExpired)
            {
                filter.ToDate = TenantUtil.DateTimeNow();
            }
            if (reportType == ReportType.TasksExpired)
            {
                filter.ToDate = TenantUtil.DateTimeNow();
                filter.TaskStatuses.Add(TaskStatus.Open);
            }

            //exec
            IList <object[]> result = null;

            if (reportType == ReportType.UsersActivity)
            {
                result = BuildUserActivityReport(filter);
            }
            else
            {
                result = Global.EngineFactory.GetReportEngine().BuildReport(reportType, filter);
                if (reportType == ReportType.TasksExpired)
                {
                    var tmp = new List <object[]>();
                    foreach (var row in result)
                    {
                        if (row[10] != null)//task has due date
                        {
                            tmp.Add(row);
                        }
                    }
                    result = tmp;
                }
            }

            if (result == null || result.Count == 0)
            {
                return(null);
            }

            //add user info
            switch (reportType)
            {
            case ReportType.UsersWithoutActiveTasks:
            case ReportType.UsersWorkload:
            case ReportType.TimeSpend:
            case ReportType.UsersActivity:
                result = AddUserInfo(result, 0);
                result = result
                         .OrderBy(r => CoreContext.UserManager.GetUsers((Guid)r[0]), UserInfoComparer.Default)
                         .ToList();
                break;

            case ReportType.ProjectsWithoutActiveMilestones:
            case ReportType.ProjectsWithoutActiveTasks:
            case ReportType.ProjectsList:
                result = AddUserInfo(result, 2);
                result = result
                         .OrderBy(r => (string)r[1])
                         .ToList();
                break;

            case ReportType.TasksByProjects:
            case ReportType.TasksByUsers:
            case ReportType.TasksExpired:
                result = AddUserInfo(result, 8);
                result = AddStatusCssClass(result);
                break;
            }

            return(ReportTransformer.Transform(result, reportType, filter.ViewType, viewType));
        }