예제 #1
0
        private ChartInfo GetWorkedTimeVsDayData(GenerateChartArguments args)
        {
            ChartPointsList workedTimeList   = new ChartPointsList();
            ChartPointsList activeTimeList   = new ChartPointsList();
            ChartPointsList inactiveTimeList = new ChartPointsList();
            ChartInfo       info             = new ChartInfo();

            info.Arguments = args;

            DateTime curDate = args.FromDate;
            DateTime toDate  = args.ToDate;

            while (curDate <= toDate)
            {
                if (worker.CancellationPending)
                {
                    return(null);
                }
                int workedTime = TasksSummaries.GetWorkedTime(curDate, curDate);
                if (workedTime != 0)
                {
                    int    activeTime   = TasksSummaries.GetActiveTime(curDate, curDate);
                    int    inactiveTime = workedTime - activeTime;
                    string date         = curDate.ToShortDateString();
                    info.AddX(date);
                    workedTimeList.Add(Convert.ToDouble(workedTime * 1.0 / 3600));
                    activeTimeList.Add(Convert.ToDouble(activeTime * 1.0 / 3600));
                    inactiveTimeList.Add(Convert.ToDouble(inactiveTime * 1.0 / 3600));
                }
                curDate = curDate.AddDays(1);
            }
            info.PointsList = new ChartPointsList[] { workedTimeList, activeTimeList, inactiveTimeList };
            return(info);
        }
예제 #2
0
 private ChartInfo GetChartData(GenerateChartArguments args)
 {
     if (args.SelectedChart == 1)
     {
         return(GetWorkedTimeVsDayData(args));
     }
     else if (args.SelectedChart == 2)
     {
         return(GetWorkedTimeVsWeekData(args));
     }
     else if (args.SelectedChart == 3)
     {
         return(GetWorkedTimeVsMonthData(args));
     }
     else if (args.SelectedChart == 4)
     {
         return(GetPercentActiveTimeVsDayData(args));
     }
     else if (args.SelectedChart == 5)
     {
         return(GetPercentActiveTimeVsWeekData(args));
     }
     else if (args.SelectedChart == 6)
     {
         return(GetPercentActiveTimeVsMonthData(args));
     }
     throw new NotImplementedException("Selected chart is not implemented yet");
 }
예제 #3
0
        private ChartInfo GetPercentActiveTimeVsMonthData(GenerateChartArguments args)
        {
            ChartPointsList activeTimeList   = new ChartPointsList();
            ChartPointsList inactiveTimeList = new ChartPointsList();
            ChartInfo       info             = new ChartInfo();

            info.Arguments = args;

            DateTime curDate = args.FromDate;
            DateTime toDate  = args.ToDate;

            while (curDate <= toDate)
            {
                if (worker.CancellationPending)
                {
                    return(null);
                }

                DateTime endcurDate = curDate.AddMonths(1).AddSeconds(-1);
                int      workedTime = TasksSummaries.GetWorkedTime(curDate, endcurDate);
                if (workedTime != 0)
                {
                    int    activeTime   = TasksSummaries.GetActiveTime(curDate, endcurDate);
                    int    inactiveTime = workedTime - activeTime;
                    string month        = curDate.ToString("MMM-yyyy");
                    info.AddX(month);
                    activeTimeList.Add(Convert.ToDouble(activeTime * 100.0 / workedTime));
                    inactiveTimeList.Add(Convert.ToDouble(inactiveTime * 100.0 / workedTime));
                }
                curDate = curDate.AddMonths(1);
            }
            info.PointsList = new ChartPointsList[] { activeTimeList, inactiveTimeList };
            return(info);
        }
예제 #4
0
        private void CallGenerateChartAsync()
        {
            if (this.chartComboBox.SelectedIndex == 0)
            {
                MessageBox.Show(this, "Select a chart first.", this.ParentForm.Text, MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                this.chartComboBox.Focus();
                return;
            }

            if (this.chartComboBox.SelectedIndex == 2 || this.chartComboBox.SelectedIndex == 5)
            {
                //fix from date to the beggining of the week
                this.fromDateTimePicker.Value =
                    this.fromDateTimePicker.Value.AddDays(-(int)this.fromDateTimePicker.Value.DayOfWeek);
                //fix to date to the end of the week
                this.toDateTimePicker.Value =
                    this.toDateTimePicker.Value.AddDays(6 - (int)this.toDateTimePicker.Value.DayOfWeek);
            }

            if (this.chartComboBox.SelectedIndex == 3 || this.chartComboBox.SelectedIndex == 6)
            {
                //fix from date to the beggining of the month
                this.fromDateTimePicker.Value =
                    this.fromDateTimePicker.Value.AddDays(-this.fromDateTimePicker.Value.Day + 1);
                //fix to date to the end of the month
                this.toDateTimePicker.Value = this.toDateTimePicker.Value.AddMonths(1).AddDays(-this.toDateTimePicker.Value.Day);
            }

            SetWaitState();
            if (worker.IsBusy)
            {
                worker.CancelAsync();
            }
            while (worker.IsBusy)
            {
                Application.DoEvents();
            }
            GenerateChartArguments arg = new GenerateChartArguments();

            arg.SelectedChart = this.chartComboBox.SelectedIndex;
            arg.ChartTitle    = this.chartComboBox.Text;
            arg.FromDate      = this.fromDateTimePicker.Value.Date;
            arg.ToDate        = this.toDateTimePicker.Value.Date;
            worker.RunWorkerAsync(arg);
        }
예제 #5
0
파일: DataCharts.cs 프로젝트: ckolumbus/ptm
        private void CallGenerateChartAsync()
        {
            if(this.chartComboBox.SelectedIndex == 0)
            {
                MessageBox.Show(this, "Select a chart first.", this.ParentForm.Text, MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                this.chartComboBox.Focus();
                return;
            }

            if (this.chartComboBox.SelectedIndex == 2 || this.chartComboBox.SelectedIndex == 5)
            {
                //fix from date to the beggining of the week
                this.fromDateTimePicker.Value =
                    this.fromDateTimePicker.Value.AddDays(-(int)this.fromDateTimePicker.Value.DayOfWeek);
                //fix to date to the end of the week
                this.toDateTimePicker.Value =
                    this.toDateTimePicker.Value.AddDays(6 - (int)this.toDateTimePicker.Value.DayOfWeek);
            }

            if (this.chartComboBox.SelectedIndex == 3 || this.chartComboBox.SelectedIndex == 6)
            {
                //fix from date to the beggining of the month
                this.fromDateTimePicker.Value =
                    this.fromDateTimePicker.Value.AddDays(-this.fromDateTimePicker.Value.Day+1);
                //fix to date to the end of the month
                this.toDateTimePicker.Value = this.toDateTimePicker.Value.AddMonths(1).AddDays(-this.toDateTimePicker.Value.Day);
            }

            SetWaitState();
            if (worker.IsBusy) worker.CancelAsync();
            while (worker.IsBusy) Application.DoEvents();
            GenerateChartArguments arg = new GenerateChartArguments();
            arg.SelectedChart = this.chartComboBox.SelectedIndex;
            arg.ChartTitle = this.chartComboBox.Text;
            arg.FromDate = this.fromDateTimePicker.Value.Date;
            arg.ToDate = this.toDateTimePicker.Value.Date;
            worker.RunWorkerAsync(arg);
        }
예제 #6
0
파일: DataCharts.cs 프로젝트: ckolumbus/ptm
        private ChartInfo GetWorkedTimeVsWeekData(GenerateChartArguments args)
        {
            ChartPointsList workedTimeList = new ChartPointsList();
            ChartPointsList activeTimeList = new ChartPointsList();
            ChartPointsList inactiveTimeList = new ChartPointsList();
            ChartInfo info = new ChartInfo();
            info.Arguments = args;

            DateTime curDate = args.FromDate;
            DateTime toDate = args.ToDate;

            while (curDate <= toDate)
            {
                if (worker.CancellationPending)
                    return null;

                DateTime endcurDate = curDate.AddDays(7).AddSeconds(-1);
                int workedTime = TasksSummaries.GetWorkedTime(curDate, endcurDate);
                if (workedTime != 0)
                {
                    int activeTime = TasksSummaries.GetActiveTime(curDate, endcurDate);
                    int inactiveTime = workedTime - activeTime;
                    string week = curDate.ToShortDateString() + "-" + endcurDate.ToShortDateString();
                    info.AddX(week);
                    workedTimeList.Add(Convert.ToDouble(workedTime * 1.0 / 3600));
                    activeTimeList.Add(Convert.ToDouble(activeTime * 1.0 / 3600));
                    inactiveTimeList.Add(Convert.ToDouble(inactiveTime * 1.0 / 3600));
                }
                curDate = curDate.AddDays(7);
            }
            info.PointsList = new ChartPointsList[] { workedTimeList, activeTimeList, inactiveTimeList };
            return info;
        }
예제 #7
0
파일: DataCharts.cs 프로젝트: ckolumbus/ptm
        private ChartInfo GetPercentActiveTimeVsMonthData(GenerateChartArguments args)
        {
            ChartPointsList activeTimeList = new ChartPointsList();
            ChartPointsList inactiveTimeList = new ChartPointsList();
            ChartInfo info = new ChartInfo();
            info.Arguments = args;

            DateTime curDate = args.FromDate;
            DateTime toDate = args.ToDate;

            while (curDate <= toDate)
            {
                if (worker.CancellationPending)
                    return null;

                DateTime endcurDate = curDate.AddMonths(1).AddSeconds(-1);
                int workedTime = TasksSummaries.GetWorkedTime(curDate, endcurDate);
                if (workedTime != 0)
                {
                    int activeTime = TasksSummaries.GetActiveTime(curDate, endcurDate);
                    int inactiveTime = workedTime - activeTime;
                    string month = curDate.ToString("MMM-yyyy");
                    info.AddX(month);
                    activeTimeList.Add(Convert.ToDouble(activeTime * 100.0 / workedTime));
                    inactiveTimeList.Add(Convert.ToDouble(inactiveTime * 100.0 / workedTime));
                }
                curDate = curDate.AddMonths(1);
            }
            info.PointsList = new ChartPointsList[] { activeTimeList, inactiveTimeList };
            return info;
        }
예제 #8
0
파일: DataCharts.cs 프로젝트: ckolumbus/ptm
        private ChartInfo GetPercentActiveTimeVsDayData(GenerateChartArguments args)
        {
            ChartPointsList activeTimeList = new ChartPointsList();
            ChartPointsList inactiveTimeList = new ChartPointsList();
            ChartInfo info = new ChartInfo();
            info.Arguments = args;

            DateTime curDate = args.FromDate;
            DateTime toDate = args.ToDate;
            while (curDate <= toDate)
            {
                if (worker.CancellationPending)
                    return null;
                int workedTime = TasksSummaries.GetWorkedTime(curDate, curDate);
                if (workedTime != 0)
                {
                    int activeTime = TasksSummaries.GetActiveTime(curDate, curDate);
                    int inactiveTime = workedTime - activeTime;
                    string date = curDate.ToShortDateString();
                    info.AddX(date);
                    activeTimeList.Add(Convert.ToDouble(activeTime * 100.0 / workedTime));
                    inactiveTimeList.Add(Convert.ToDouble(inactiveTime * 100.0 / workedTime));
                }
                curDate = curDate.AddDays(1);
            }

            info.PointsList = new ChartPointsList[] { activeTimeList, inactiveTimeList };
            return info;
        }
예제 #9
0
파일: DataCharts.cs 프로젝트: ckolumbus/ptm
 private ChartInfo GetChartData(GenerateChartArguments args)
 {
     if (args.SelectedChart == 1)
         return GetWorkedTimeVsDayData(args);
     else if (args.SelectedChart == 2)
         return GetWorkedTimeVsWeekData(args);
     else if (args.SelectedChart == 3)
         return GetWorkedTimeVsMonthData(args);
     else if (args.SelectedChart == 4)
         return GetPercentActiveTimeVsDayData(args);
     else if (args.SelectedChart == 5)
         return GetPercentActiveTimeVsWeekData(args);
     else if (args.SelectedChart == 6)
         return GetPercentActiveTimeVsMonthData(args);
     throw new NotImplementedException("Selected chart is not implemented yet");
 }