// Static Members // -------------------------------------------------------------------------- #region Static Members static public string GetTimesheetWeekString(Timesheet timesheet) { lock (m_syncRoot) { TimesheetMonth timesheetMonth = timesheet.MonthlyTimesheets.TimesheetMonth; string fromDate = Helpers.Dates.GetMMDDYYYY(timesheet.StartDate.Date, '-'); string toDate = Helpers.Dates.GetMMDDYYYY(timesheet.EndDate.Date, '-'); const string formatString = "Week {0} ({1} Through {2})"; return(string.Format(formatString, timesheet.WeekNumber.ToString(), fromDate, toDate)); } }
static public bool WouldTimesheetSplit(TimesheetMonth timesheetMonth, DateTime startDate, DateTime endDate) { lock (m_syncRoot) { if (startDate > endDate) { throw new ArgumentOutOfRangeException("startDate cannot be greater than endDate"); } else if (startDate.AddDays(6) != endDate) { throw new ArgumentOutOfRangeException("startDate through endDate must span exactly 7 days"); } else { int startYear = startDate.Year; int startMonth = startDate.Month; int endYear = endDate.Year; int endMonth = endDate.Month; if ((startYear != timesheetMonth.Year || startMonth != timesheetMonth.Month) && (endYear != timesheetMonth.Year || endMonth != timesheetMonth.Month)) { throw new ArgumentOutOfRangeException("startDate and/or endDate's year and month must equal timesheetMonth's year and month."); } } DateTime fifteenthOfMonth = new DateTime(timesheetMonth.Year, timesheetMonth.Month, 15); if (fifteenthOfMonth.DayOfWeek == DayOfWeek.Saturday || fifteenthOfMonth.DayOfWeek == DayOfWeek.Sunday) { return(false); } else { DateTime[] dates = Helpers.Dates.ToDateRange(startDate, endDate); return(dates.Count(p => p.Day == 15) > 0); } } }
/// <summary> /// Returns the proposed file name based on the timesheet year, month, unique indicator e.g. /// Timesheet 2011-03 Week 1 (02-28-2011 Through 03-06-2011) /// </summary> /// <returns>The proposed file name for this timesheet e.g. Timesheet 2010-05 A.xlsx</returns> public virtual string GetFileName() { TimesheetMonth timesheetMonth = this.MonthlyTimesheets.TimesheetMonth; int year = timesheetMonth.Year; int month = timesheetMonth.Month; string shortMonthName = timesheetMonth.SortName; string fromDate = Helpers.Dates.GetMMDDYYYY(this.StartDate.Date, '-'); string toDate = Helpers.Dates.GetMMDDYYYY(this.EndDate.Date, '-'); const string fileNameFormatString = "Timesheet {0}-{1:00} Week {2} ({3} Through {4}"; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat(fileNameFormatString, year, month, this.WeekNumber.ToString(), fromDate, toDate); if (this.IsSplitTimesheet) { if (this.SplitIndex < 0 || this.SplitIndex > 1) { throw new Exception("SplitIndex for split timesheet was out of range (must be 0 or 1)."); } else { stringBuilder.Append(", "); stringBuilder.AppendFormat("{0} of 2", this.SplitIndex + 1); } } stringBuilder.Append(")"); stringBuilder.Append(".xlsx"); return(stringBuilder.ToString()); }
protected virtual void Add(TimesheetMonth timesheetMonth) { MonthlyTimesheets monthlyTimesheets = new MonthlyTimesheets(timesheetMonth); this.MonthlyTimesheets.Add(monthlyTimesheets); }
protected virtual void Add(TimesheetMonth timesheetMonth) { MonthlyTimesheets monthlyTimesheets = new MonthlyTimesheets(timesheetMonth); this.MonthlyTimesheets.Add(monthlyTimesheets); }