Ejemplo n.º 1
0
        /// <summary>
        /// EachMonth
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public static IEnumerable EachMonth(this DateTime start, DateTime end)
        {
            DateTime startMonth = CoreUtilities.GetFirstDayOfMonth(start);
            DateTime endMonth   = CoreUtilities.GetFirstDayOfMonth(end);

            while (startMonth <= endMonth)
            {
                yield return(startMonth);

                startMonth = startMonth.AddMonths(1);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Build History Request Criteria
        /// </summary>
        /// <param name="pRequestDateTime"></param>
        /// <param name="pHistortyMonthsCount"></param>
        /// <returns></returns>
        public static RequestCriteriaInfo BuildHistoryRequestCriteria(DateTime pRequestDateTime, int pHistortyMonthsCount)
        {
            DateTime dtHistoryMonth = pRequestDateTime;

            if (pHistortyMonthsCount > 0)
            {
                dtHistoryMonth = pRequestDateTime.AddMonths(CoreUtilities.GetNegativeNumber(pHistortyMonthsCount));
            }

            DateTime dtStart = CoreUtilities.GetFirstDayOfMonth(dtHistoryMonth);
            DateTime dtEnd   = CoreUtilities.GetLastSecondOfDay(CoreUtilities.GetLastDayOfMonth(pRequestDateTime.AddMonths(-1)));

            return(new RequestCriteriaInfo(dtStart, dtEnd));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get Last Day Of Month
        /// </summary>
        /// <param name="pDateTime"></param>
        /// <param name="pGetLastSecond"></param>
        /// <returns></returns>
        public static DateTime GetLastDayOfMonth(DateTime pDateTime, bool pGetLastSecond = false)
        {
            DateTime dtTo = pDateTime;

            dtTo = dtTo.AddMonths(1);

            dtTo = dtTo.AddDays(-(dtTo.Day));

            if (pGetLastSecond)
            {
                dtTo = CoreUtilities.GetLastSecondOfDay(dtTo);
            }

            return(dtTo);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Safe Dispose
        /// </summary>
        /// <param name="pObject"></param>
        public static void SafeDispose <T>(ref T pObject) where T : class
        {
            if (pObject != null && !pObject.GetType().IsValueType)
            {
                if (pObject is IList)
                {
                    IList list = pObject as IList;

                    for (int i = 0; i < list.Count; i++)
                    {
                        var item = list[i];
                        CoreUtilities.SafeDispose(ref item);
                        list[i] = item;
                    }
                }

                else if (pObject is IDisposable)
                {
                    (pObject as IDisposable).Dispose();
                }

                pObject = null;
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Get Negative Number
 /// </summary>
 /// <param name="pNumber"></param>
 /// <returns></returns>
 public static int GetNegativeNumber(int?pNumber)
 {
     return(CoreUtilities.GetNegativeNumber(pNumber.GetValueOrDefault(0)));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Used to get Settings Item from the Configuration file
 /// </summary>
 /// <param name="pKey">Settings Item Key</param>
 /// <returns>Settings Item Value</returns>
 public static string GetSettingsItemValue(SettingsKey pSettingsKey)
 {
     return(CoreUtilities.GetSettingsItemValue(pSettingsKey.GetDescription()));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Build Price Date BPC Key
 /// </summary>
 /// <param name="pDateTime"></param>
 /// <returns></returns>
 public static long BuildPriceDateBPCKey(DateTime pDateTime)
 {
     return(CoreUtilities.BuildPriceDateBPCKey(pDateTime, false));
 }