Exemplo n.º 1
0
        private string CheckStatusForHistory(Data.Models.Task task)
        {
            string result      = "#N/A";
            var    currentDate = DateTime.Now;

            switch (task.periodType)
            {
            case Data.Enum.PeriodType.Daily:
                result = currentDate.CompareTo(task.DueDateTime) <= 0 ? "On time" : "Late";
                break;

            case Data.Enum.PeriodType.Weekly:
                result = currentDate.CompareTo(task.DueDateTime) <= 0 ? "On time" : "Late";
                break;

            case Data.Enum.PeriodType.Monthly:
                result = currentDate.CompareTo(task.DueDateTime) <= 0 ? "On time" : "Late";
                break;

            case Data.Enum.PeriodType.SpecificDate:
                result = currentDate.CompareTo(task.DueDateTime) <= 0 ? "On time" : "Late";
                break;

            default:
                break;
            }
            return(result);
        }
Exemplo n.º 2
0
        private async System.Threading.Tasks.Task CloneTask(List <Data.Models.Task> tasks, int projectId)
        {
            int parentID = 0;

            foreach (var item in tasks)
            {
                if (item.JobTypeID == (int)Data.Enum.JobType.Project)
                {
                    if (item.Level == 1)
                    {
                        parentID = 0;
                    }
                    var itemAdd = new Data.Models.Task
                    {
                        JobName    = item.JobName,
                        JobTypeID  = item.JobTypeID,
                        periodType = item.periodType,
                        OCID       = item.OCID,
                        CreatedBy  = item.CreatedBy,
                        FromWhoID  = item.FromWhoID,
                        Priority   = item.Priority,
                        Level      = item.Level,
                        ProjectID  = projectId,
                        ParentID   = parentID
                    };
                    itemAdd.CreatedDate = DateTime.Now.Date.AddDays(1);
                    await _context.AddAsync(itemAdd);

                    await _context.SaveChangesAsync();

                    parentID = itemAdd.ID;
                }
            }
        }
Exemplo n.º 3
0
        private string PeriodYearly(Data.Models.Task task)
        {
            var duedateYearly   = task.DueDateYearly.ToParseIso8601();
            var newDueDateYealy = new DateTime(duedateYearly.Year + 1, duedateYearly.Month, duedateYearly.Day).ToParseDatetimeToStringISO8061();

            return(newDueDateYealy);
        }
Exemplo n.º 4
0
        private string PeriodQuarterly(Data.Models.Task task)
        {
            var quarter          = task.DueDateQuarterly.Split(",");
            var duedatequarterly = quarter[0].ToSafetyString().GetLastDateOfNextQuarter();

            return(duedatequarterly);
        }
Exemplo n.º 5
0
        private string PeriodMonthly(Data.Models.Task task)
        {
            var duedateMonthly = task.CreatedDateForEachTask;
            var day            = task.DueDateMonthly.ToInt();
            var currentYear    = duedateMonthly.Year;
            var month          = duedateMonthly.Month + 1;

            if (month == 12)
            {
                currentYear = currentYear + 1;
                month       = 1;
                currentYear = currentYear + 1;
            }
            var newDueDate = new DateTime(currentYear, month, day).ToParseDatetimeToStringISO8061();

            return(newDueDate);
        }
Exemplo n.º 6
0
        private string PeriodWeekly(Data.Models.Task task)
        {
            string result        = string.Empty;
            int    year          = DateTime.Now.Year;
            var    dateOfWeek    = task.DateOfWeekly;  //30 mar
            var    duedateweekly = task.DueDateWeekly; //Mon
            //Tim dayofweek
            var monthWeekly         = dateOfWeek.ToParseStringDateTime().Month;
            var allDateInMonth      = monthWeekly.AllDatesInMonth(year);
            var listdayOfWeek       = allDateInMonth.Where(x => x.DayOfWeek.ToString().Equals(duedateweekly));
            var listdayOfWeekString = listdayOfWeek.Select(x => x.ToString("d MMM, yyyy")).ToArray(); //2,9,16,23,30 mar
            int index = Array.IndexOf(listdayOfWeekString, dateOfWeek);

            if (index < listdayOfWeekString.Count() - 1)
            {
                result = listdayOfWeekString[index + 1];
            }
            else
            {
                if (monthWeekly == 12)
                {
                    year                = year + 1;
                    allDateInMonth      = 1.AllDatesInMonth(year);
                    listdayOfWeek       = allDateInMonth.Where(x => x.DayOfWeek.ToString().Equals(duedateweekly));
                    listdayOfWeekString = listdayOfWeek.Select(x => x.ToString("MMM d, yyyy")).ToArray(); //6,13,20,27 apr
                    result              = listdayOfWeekString.FirstOrDefault();
                }
                else
                {
                    monthWeekly         = monthWeekly + 1;
                    allDateInMonth      = monthWeekly.AllDatesInMonth(year);
                    listdayOfWeek       = allDateInMonth.Where(x => x.DayOfWeek.ToString().Equals(duedateweekly));
                    listdayOfWeekString = listdayOfWeek.Select(x => x.ToString("MMM d, yyyy")).ToArray(); //6,13,20,27 apr
                    result = listdayOfWeekString.FirstOrDefault();
                }
            }
            return(result);
        }