internal static List<FiscalUnit> GetProjectStatusPeriods(DateTime? date) { List<FiscalUnit> months = new List<FiscalUnit>(); if (!date.HasValue) { return months; } using (OperationContextScope scope = new OperationContextScope(adminClient.InnerChannel)) { WcfHelpers.UseCorrectHeaders(isImpersonated); SvcAdmin.FiscalPeriodDataSet fiscalPeriods = adminClient.ReadFiscalPeriods(date.Value.Year); if (fiscalPeriods.FiscalPeriods.Rows.Count > 0) { for (int count = 0; count < fiscalPeriods.FiscalPeriods.Rows.Count; count++) { DataRow row = fiscalPeriods.FiscalPeriods.Rows[count]; SvcAdmin.FiscalPeriodDataSet.FiscalPeriodsRow fiscalRow = (SvcAdmin.FiscalPeriodDataSet.FiscalPeriodsRow)row; int noOfWeeks = 0; if (date >= fiscalRow.WFISCAL_PERIOD_START_DATE && date <= fiscalRow.WFISCAL_PERIOD_FINISH_DATE) { for (int i = 3; i > 0; i--) { if (count >= 0) { DataRow row1 = fiscalPeriods.FiscalPeriods.Rows[count - i]; SvcAdmin.FiscalPeriodDataSet.FiscalPeriodsRow fiscalRow1 = (SvcAdmin.FiscalPeriodDataSet.FiscalPeriodsRow)row1; FiscalUnit fiscalMonth = new FiscalUnit(fiscalRow1.WFISCAL_PERIOD_START_DATE, fiscalRow1.WFISCAL_PERIOD_FINISH_DATE, fiscalRow1.WFISCAL_MONTH, fiscalRow1.WFISCAL_YEAR, false, 0); months.Add(fiscalMonth); } } //count += 3; FiscalUnit fiscalMonth1 = new FiscalUnit(fiscalRow.WFISCAL_PERIOD_START_DATE, fiscalRow.WFISCAL_PERIOD_START_DATE.AddDays(7), fiscalRow.WFISCAL_MONTH, fiscalRow.WFISCAL_YEAR, true, (1)); FiscalUnit fiscalMonth2 = new FiscalUnit(fiscalRow.WFISCAL_PERIOD_START_DATE.AddDays(7), fiscalRow.WFISCAL_PERIOD_START_DATE.AddDays(14), fiscalRow.WFISCAL_MONTH, fiscalRow.WFISCAL_YEAR, true, (2)); FiscalUnit fiscalMonth3 = new FiscalUnit(fiscalRow.WFISCAL_PERIOD_START_DATE.AddDays(14), fiscalRow.WFISCAL_PERIOD_START_DATE.AddDays(21), fiscalRow.WFISCAL_MONTH, fiscalRow.WFISCAL_YEAR, true, (3)); FiscalUnit fiscalMonth4 = new FiscalUnit(fiscalRow.WFISCAL_PERIOD_START_DATE.AddDays(21), fiscalRow.WFISCAL_PERIOD_START_DATE.AddDays(28), fiscalRow.WFISCAL_MONTH, fiscalRow.WFISCAL_YEAR, true, (4)); months.Add(fiscalMonth1); months.Add(fiscalMonth2); months.Add(fiscalMonth3); months.Add(fiscalMonth4); if (new FiscalUnit(fiscalRow.WFISCAL_PERIOD_START_DATE, fiscalRow.WFISCAL_PERIOD_FINISH_DATE, fiscalRow.WFISCAL_MONTH, fiscalRow.WFISCAL_YEAR, false, 0).GetNoOfWeeks() > 4) { FiscalUnit fiscalMonth5 = new FiscalUnit(fiscalRow.WFISCAL_PERIOD_START_DATE.AddDays(28), fiscalRow.WFISCAL_PERIOD_START_DATE.AddDays(35), fiscalRow.WFISCAL_MONTH, fiscalRow.WFISCAL_YEAR, true, (5)); months.Add(fiscalMonth5); } for (int i = 0; i < 3; i++) { count++; if (count < fiscalPeriods.FiscalPeriods.Rows.Count) { DataRow row1 = fiscalPeriods.FiscalPeriods.Rows[count]; SvcAdmin.FiscalPeriodDataSet.FiscalPeriodsRow fiscalRow1 = (SvcAdmin.FiscalPeriodDataSet.FiscalPeriodsRow)row1; FiscalUnit fiscalMonth = new FiscalUnit(fiscalRow1.WFISCAL_PERIOD_START_DATE, fiscalRow1.WFISCAL_PERIOD_FINISH_DATE, fiscalRow1.WFISCAL_MONTH, fiscalRow1.WFISCAL_YEAR, false, 0); months.Add(fiscalMonth); } } break; } noOfWeeks += new FiscalUnit(fiscalRow.WFISCAL_PERIOD_START_DATE, fiscalRow.WFISCAL_PERIOD_FINISH_DATE, fiscalRow.WFISCAL_MONTH, fiscalRow.WFISCAL_YEAR, false, 0).GetNoOfWeeks(); } } } return months; }
internal static List<FiscalUnit> GetProjectStatusWeekPeriods(DateTime? date) { List<FiscalUnit> weekly = new List<FiscalUnit>(); if (!date.HasValue) { return weekly; } FiscalUnit fiscalMonth1 = new FiscalUnit(date.Value.AddDays(-35), date.Value.AddDays(-28),date.Value.Month, date.Value.Year, true); FiscalUnit fiscalMonth2 = new FiscalUnit(date.Value.AddDays(-28), date.Value.AddDays(-21), date.Value.Month, date.Value.Year, true); FiscalUnit fiscalMonth3 = new FiscalUnit(date.Value.AddDays(-21), date.Value.AddDays(-14), date.Value.Month, date.Value.Year, true); FiscalUnit fiscalMonth4 = new FiscalUnit(date.Value.AddDays(-14), date.Value.AddDays(-7), date.Value.Month, date.Value.Year, true); FiscalUnit fiscalMonth5 = new FiscalUnit(date.Value.AddDays(-7), date.Value, date.Value.Month, date.Value.Year, true); FiscalUnit fiscalMonth6 = new FiscalUnit(date.Value, date.Value.AddDays(7), date.Value.Month, date.Value.Year, true); FiscalUnit fiscalMonth7 = new FiscalUnit(date.Value.AddDays(7), date.Value.AddDays(14), date.Value.Month, date.Value.Year, true); FiscalUnit fiscalMonth8 = new FiscalUnit(date.Value.AddDays(14), date.Value.AddDays(21), date.Value.Month, date.Value.Year, true); FiscalUnit fiscalMonth9 = new FiscalUnit(date.Value.AddDays(21), date.Value.AddDays(28), date.Value.Month, date.Value.Year, true); FiscalUnit fiscalMonth10 = new FiscalUnit(date.Value.AddDays(28), date.Value.AddDays(25), date.Value.Month, date.Value.Year, true); weekly.Add(fiscalMonth1); weekly.Add(fiscalMonth2); weekly.Add(fiscalMonth3); weekly.Add(fiscalMonth4); weekly.Add(fiscalMonth5); weekly.Add(fiscalMonth6); weekly.Add(fiscalMonth7); weekly.Add(fiscalMonth8); weekly.Add(fiscalMonth9); weekly.Add(fiscalMonth10); return weekly; }
private static IList<TaskItemGroup> GetupComingTasksData(DataTable tasksDataTable, FiscalUnit month, CustomFieldDataSet dataSet) { if (month.From == DateTime.MinValue && month.To == DateTime.MaxValue) return new List<TaskItemGroup>(); FiscalUnit fiscalUnit = new FiscalUnit() { From = month.From, To = month.To.AddMonths(1) }; Repository.Utility.WriteLog("GetupComingTasksData started", System.Diagnostics.EventLogEntryType.Information); int count = -1; int upComingTaskCount = 0; IList<TaskItemGroup> retVal = new List<TaskItemGroup>(); TaskItemGroup taskData = new TaskItemGroup() { TaskItems = new List<TaskItem>() }; IList<TaskItem> items = new List<TaskItem>(); EnumerableRowCollection<DataRow> collection = tasksDataTable.AsEnumerable() .Where((t => t.Field<bool>("TASK_IS_SUMMARY") == false && t.Field<int>("TASK_PCT_COMP") < 100 && t.Field<DateTime?>("TASK_FINISH_DATE").HasValue && t.Field<DateTime?>("TASK_FINISH_DATE").Value.InCurrentFiscalMonth(fiscalUnit) )).OrderBy(t => t.Field<int>("TASK_ID")); foreach (DataRow item in collection) { count++; upComingTaskCount++; TaskItem taskItem = BuildTaskItem("", item, dataSet); if (count == 10) { retVal.Add(taskData); taskData = new TaskItemGroup { TaskItems = new List<TaskItem>() }; count = -1; taskData.TaskItems.Add(BuildTaskItem("", item, dataSet)); } else { taskData.TaskItems.Add(BuildTaskItem("", item, dataSet)); } } if (count % 10 != 0) { retVal.Add(taskData); } Repository.Utility.WriteLog("GetupComingTasksData completed successfully", System.Diagnostics.EventLogEntryType.Information); return retVal; }