Esempio n. 1
0
 /// <summary>
 /// Initializes the client tracked item.
 /// </summary>
 /// <param name="authUser">The user who is creating the data.</param>
 /// <param name="clientID">The client ID to override the user with.</param>
 public void Initialize(BaseSessionAuthUser authUser, int? clientID)
 {
     if (clientID.HasValue)
         ClientID = clientID.Value;
     else if (authUser != null)
         ClientID = authUser.ClientID;
 }
        /// <summary>
        /// Finds the total days given amount of working days after a start date.
        /// </summary>
        /// <param name="authUser">The user who is accessing the data.</param>
        /// <param name="countryID">The country ID to check.</param>
        /// <param name="startDate">The start date within the range.</param>
        /// <param name="workingDaysCount">Count of working days.</param>
        /// <returns>The number of weekdays that have transpired.</returns>
        public static int FindTotalDaysFromWorkingDaysCount(BaseSessionAuthUser authUser, int countryID, DateTime startDate, int workingDaysCount)
        {
            int count = 0;

            DateTimeList holidays = GetHolidays(authUser, countryID, startDate, startDate.AddDays(workingDaysCount * 2));
            while (workingDaysCount > 0)
            {
                DateTime date = startDate.AddDays(count);
                if ((date.DayOfWeek != DayOfWeek.Saturday) &&
                    (date.DayOfWeek != DayOfWeek.Sunday) &&
                    (!date.IsInCollection(holidays)))
                {
                    workingDaysCount--;
                }

                count++;
            }

            return count;
        }
 /// <summary>
 /// Gets the nubmer of the quarter in a fiscal year.
 /// </summary>
 public static int GetFiscalQuarterNumber(BaseSessionAuthUser authUser, DateTime date)
 {
     return DateTimeUtil.GetQuarterNumber(date);
 }
 /// <summary>
 /// Gets the expiration date for a fiscal quarter.
 /// </summary>
 /// <param name="authUser">The session auth user to get the fiscal year information for.</param>
 /// <param name="date">A date in the fiscal quarter.</param>
 /// <returns>The effective date to use.</returns>
 public static DateTime GetFiscalQuarterExpirationDate(BaseSessionAuthUser authUser, DateTime date)
 {
     return DateTimeUtil.GetQuarterExpirationDate(date);
 }
 /// <summary>
 /// Gets the dates for the current fiscal expiration date.
 /// </summary>
 /// <param name="authUser">The session auth user to get the fiscal year information for.</param>
 /// <returns>The expiration date to use.</returns>
 public static DateTime GetCurrentFiscalExpirationDate(BaseSessionAuthUser authUser)
 {
     return DateTimeUtil.GetExpirationDate(DateTime.UtcNow.Year, 12, 31);
 }
 /// <summary>
 /// Gets the dates for the current fiscal effective date.
 /// </summary>
 /// <param name="authUser">The session auth user to get the fiscal year information for.</param>
 /// <returns>The effective date to use.</returns>
 public static DateTime GetCurrentFiscalEffectiveDate(BaseSessionAuthUser authUser)
 {
     return DateTimeUtil.GetEffectiveDate(DateTime.UtcNow.Year, 1, 1);
 }
 /// <summary>
 /// Gets a list of working days, based upon the organization defined days.
 /// </summary>
 public static DayOfWeek[] GetWorkingDays(BaseSessionAuthUser authUser)
 {
     List<DayOfWeek> daysOfWeek = new List<DayOfWeek>();
     daysOfWeek.Add(DayOfWeek.Monday);
     daysOfWeek.Add(DayOfWeek.Tuesday);
     daysOfWeek.Add(DayOfWeek.Wednesday);
     daysOfWeek.Add(DayOfWeek.Thursday);
     daysOfWeek.Add(DayOfWeek.Friday);
     return daysOfWeek.ToArray();
 }
        /// <summary>
        /// Gets the next date that is for the day of week requested.
        /// </summary>
        /// <param name="authUser">The session auth user to get the fiscal year information for.</param>
        /// <param name="daysOfWeek">The days of the week to allow. If null, uses authUser organization working days.</param>
        /// <param name="date">The date to check.</param>
        /// <returns>The correct date.</returns>
        public static DateTime GetPreviousWeekday(BaseSessionAuthUser authUser, DateTime date, params DayOfWeek[] daysOfWeek)
        {
            if ((daysOfWeek == null) || (daysOfWeek.Length == 0))
                daysOfWeek = GetWorkingDays(authUser);

            date = date.AddDays(-1);
            if (daysOfWeek.Length > 0)
            {
                while (!daysOfWeek.Contains(date.DayOfWeek))
                    date = date.AddDays(-1);
            }

            return date;
        }
 /// <summary>
 /// Gets the next date that is for the day of week requested.
 /// </summary>
 /// <param name="authUser">The session auth user to get the fiscal year information for.</param>
 /// <param name="daysOfWeek">The days of the week to allow. If null, uses authUser organization working days.</param>
 /// <returns>The correct date.</returns>
 public static DateTime GetPreviousWeekday(BaseSessionAuthUser authUser, params DayOfWeek[] daysOfWeek)
 {
     return GetPreviousWeekday(authUser, DateTime.Today, daysOfWeek);
 }
Esempio n. 10
0
 /// <summary>
 /// Gets a list of non-working days, based upon the organization defined days.
 /// </summary>
 public static DayOfWeek[] GetNonWorkingDays(BaseSessionAuthUser authUser)
 {
     List<DayOfWeek> daysOfWeek = new List<DayOfWeek>();
     daysOfWeek.Add(DayOfWeek.Saturday);
     daysOfWeek.Add(DayOfWeek.Sunday);
     return daysOfWeek.ToArray();
 }
Esempio n. 11
0
 /// <summary>
 /// Gets an expiration date for the next date that is for the day of week requested.
 /// </summary>
 /// <param name="authUser">The session auth user to get the fiscal year information for.</param>
 /// <returns>The correct date.</returns>
 public static DateTime GetNextWeekdayExpirationDate(BaseSessionAuthUser authUser)
 {
     return DateTimeUtil.GetExpirationDate(GetNextWeekday(authUser));
 }
Esempio n. 12
0
        /// <summary>
        /// Gets a list of holidays that fall on or between the start and end date.
        /// </summary>
        /// <param name="authUser">The user who is requesting the data.</param>
        /// <param name="countryID">The country to get holidays for.</param>
        /// <param name="startDate">The first date to check.</param>
        /// <param name="endDate">The last date to check.</param>
        /// <returns>A list of holiday dates.</returns>
        public static DateTimeList GetHolidays(BaseSessionAuthUser authUser, int countryID, DateTime startDate, DateTime endDate)
        {
            if (startDate > endDate)
                throw new ArgumentOutOfRangeException("endDate", endDate, "End date must be greater than start date");

            return new DateTimeList(true);
        }
Esempio n. 13
0
 /// <summary>
 /// Gets the expiration date for a fiscal year.
 /// </summary>
 /// <param name="authUser">The session auth user to get the fiscal year information for.</param>
 /// <param name="year">The fiscal year you want the date in</param>
 /// <returns>The expiration date to use.</returns>
 public static DateTime GetFiscalYearExpirationDate(BaseSessionAuthUser authUser, int year)
 {
     return DateTimeUtil.GetExpirationDate(year, 12, 31);
 }
Esempio n. 14
0
 /// <summary>
 /// Gets the effective date for a fiscal year.
 /// </summary>
 /// <param name="authUser">The session auth user to get the fiscal year information for.</param>
 /// <param name="year">The fiscal year you want the date in</param>
 /// <returns>The effective date to use.</returns>
 public static DateTime GetFiscalYearEffectiveDate(BaseSessionAuthUser authUser, int year)
 {
     return DateTimeUtil.GetEffectiveDate(new DateTime(year, 1, 1));
 }
Esempio n. 15
0
 /// <summary>
 /// A delegate to return an initialized data context.
 /// </summary>
 public static MultiTenantDataContext GetDataContext(BaseSessionAuthUser authUser)
 {
     return new TestDataContext(authUser as SessionAuthUser);
 }