Exemple #1
0
        private void CalcGroups(List<WorkLogDataRow> fileData, ObservableCollection<TaskGroup> groups, TaskGroup summary, DateTime dateFrom, DateTime dateTo, ModelSettings settings)
        {
            foreach (WorkLogDataRow row in fileData)
            {
                if (row.Key == null)
                    continue;

                DateTime bookDate = GetDate(row.WorkDateStr, settings.SourceFileSettings.DateField);

                if (bookDate >= dateFrom && bookDate <= dateTo)
                {
                    TaskGroup group = groups.FirstOrDefault(x => x.Id == row.UserName);
                    if (group == null)
                    {
                        group = new TaskGroup();
                        group.Id = row.UserName;
                        group.Title = row.UserName;
                        groups.Add(group);
                    }

                    Task task = CreateTask(row, settings);
                    AddTaskToGroup(group, task);
                    AddTaskToGroup(summary, task);
                }
            }
        }
Exemple #2
0
 private void AddTaskToGroup(TaskGroup group, Task task)
 {
     Task taskCopy = task.ShallowCopy();
     if (group.IsSummary)
         taskCopy.IsTaskAssigned = true;
     Task groupExistingTask = group.Tasks.FirstOrDefault(x => x.Key == taskCopy.Key);
     if (groupExistingTask == null)
     {
         group.Tasks.Add(taskCopy);
     }
     else
     {
         AddDataToTask(groupExistingTask, taskCopy);
     }
 }
Exemple #3
0
        public ObservableCollection<TaskGroup> LoadTimeSheetReport(string fileName, DateTime dateFrom, DateTime dateTo, ModelSettings settings)
        {
            if (!File.Exists(fileName))
                return null;
            List<WorkLogDataRow> fileData = ReadFile(fileName, settings);
            if (fileData == null)
                return null;

            ObservableCollection<TaskGroup> groups = new ObservableCollection<TaskGroup>();
            TaskGroup summary = new TaskGroup { IsSummary = true, Title = "All" };
            groups.Add(summary);

            CalcGroups(fileData, groups, summary, dateFrom, dateTo, settings);

            CalcTotals(groups, settings);
            return groups;
        }
Exemple #4
0
        public static ObservableCollection<TaskGroup> CreateTestData()
        {
            ModelSettings settings = new ModelSettings();
            TaskGroup group1 =  new TaskGroup();
            group1.Title = "Test 1";
            group1.Tasks.Add(CreateTestTask());
            group1.Tasks.Add(CreateTestTask());
            group1.CalculateTotals(settings);

            TaskGroup group2 =  new TaskGroup();
            group2.Title = "Test 2";
            group2.Tasks.Add(CreateTestTask());
            group2.Tasks.Add(CreateTestTask());
            group2.CalculateTotals(settings);
            ObservableCollection<TaskGroup> groups = new ObservableCollection<TaskGroup>();
            groups.Add(group1);
            groups.Add(group2);

            return groups;
        }
Exemple #5
0
        private void WriteTasksForGroups(ExcelWorksheet ws, IEnumerable<TaskGroup> groups, TaskGroup summary, ref int row)
        {
            if (summary != null)
            {
                WriteTasksForGroup(ws, summary, ref row);
                row++;
            }

            foreach (TaskGroup group in groups)
            {
                if (group != summary)
                {
                    WriteTasksForGroup(ws, group, ref row);
                    row++;
                }
            }
        }
Exemple #6
0
 private void WriteTasksForGroup(ExcelWorksheet ws, TaskGroup group, ref int row)
 {
     row++;
     ws.Cells[row, 1].Value = group.Title;
     row++;
     foreach (Task task in group.Tasks)
     {
         WriteTaskData(ws, task, row);
         row++;
     }
 }
Exemple #7
0
        private int WriteGroups(ExcelWorksheet ws, IEnumerable<TaskGroup> groups, TaskGroup summary, ref int row)
        {
            if (summary != null)
            {
                WriteGroupData(ws, summary, row);
                row++;
            }

            foreach (TaskGroup group in groups)
            {
                if (group != summary)
                {
                    WriteGroupData(ws, group, row);
                    row++;
                }
            }
            return row;
        }
Exemple #8
0
        private void WriteGroupData(ExcelWorksheet ws, TaskGroup group, int row)
        {
            ws.Cells[row, (int)TaskGroupDataPosition.Title].Value = group.Title;

            ws.Cells[row, (int)TaskGroupDataPosition.TotalEstimationDevelopment].Value = PrepareDouble(group.TotalEstimationDevelopment);
            ws.Cells[row, (int)TaskGroupDataPosition.TotalEstimationDevelopment].Style.NumberFormat = DOUBLE_FORMAT;

            ws.Cells[row, (int)TaskGroupDataPosition.TotalDoneEstimationDevelopment].Value = PrepareDouble(group.TotalDoneEstimationDevelopment);
            ws.Cells[row, (int)TaskGroupDataPosition.TotalDoneEstimationDevelopment].Style.NumberFormat = DOUBLE_FORMAT;

            ws.Cells[row, (int)TaskGroupDataPosition.TotalDoneBookedDevelopment].Value = PrepareDouble(group.TotalDoneBookedDevelopment);
            ws.Cells[row, (int)TaskGroupDataPosition.TotalDoneBookedDevelopment].Style.NumberFormat = DOUBLE_FORMAT;

            ws.Cells[row, (int)TaskGroupDataPosition.TotalTimeBooked].Value = PrepareDouble(group.TotalTimeBooked);
            ws.Cells[row, (int)TaskGroupDataPosition.TotalTimeBooked].Style.NumberFormat = DOUBLE_FORMAT;

            ws.Cells[row, (int)TaskGroupDataPosition.TotalBookedDevelopment].Value = PrepareDouble(group.TotalBookedDevelopment);
            ws.Cells[row, (int)TaskGroupDataPosition.TotalBookedDevelopment].Style.NumberFormat = DOUBLE_FORMAT;

            ws.Cells[row, (int)TaskGroupDataPosition.TotalBookedMeetings].Value = PrepareDouble(group.TotalBookedMeetings);
            ws.Cells[row, (int)TaskGroupDataPosition.TotalBookedMeetings].Style.NumberFormat = DOUBLE_FORMAT;

            ws.Cells[row, (int)TaskGroupDataPosition.TotalUnderEstimate].Value = PrepareDouble(group.TotalUnderEstimate);
            ws.Cells[row, (int)TaskGroupDataPosition.TotalUnderEstimate].Style.NumberFormat = DOUBLE_FORMAT;

            ws.Cells[row, (int)TaskGroupDataPosition.RateDoneBookedToBookedDevelopment].Value = PrepareDouble(group.RateDoneBookedToBookedDevelopment);
            ws.Cells[row, (int)TaskGroupDataPosition.RateDoneBookedToBookedDevelopment].Style.NumberFormat = DOUBLE_FORMAT;
        }