예제 #1
0
        /// <summary>
        /// This is the CSVRowItem constructor.
        /// </summary>
        /// <param name="item">The row item.</param>
        public CalendarDate(CSVRowItem item)
        {
            //service_id,date,exception_type
            mServiceID = item.ValidateNotEmptyOrNull("service_id");

            mDate = item["date"].ToDate();

            mExceptionType = item["exception_type"].ToCalendarExceptionType();
        }
예제 #2
0
        /// <summary>
        /// This is the CSVRowItem constructor.
        /// </summary>
        /// <param name="item">The row item.</param>
        public CalendarDate(CSVRowItem item)
        {
            //service_id,date,exception_type
            mServiceID = item.ValidateNotEmptyOrNull("service_id");

            mDate = item["date"].ToDate();

            mExceptionType=item["exception_type"].ToCalendarExceptionType();
        }
예제 #3
0
 /// <summary>
 /// The struct constructor.
 /// </summary>
 /// <param name="ServiceID"></param>
 /// <param name="Date"></param>
 /// <param name="ExceptionType"></param>
 public CalendarDate(
     string ServiceID,
     DateTime Date,
     CalendarExceptionType ExceptionType
     )
 {
     mServiceID     = ServiceID;
     mDate          = Date;
     mExceptionType = ExceptionType;
 }
예제 #4
0
 /// <summary>
 /// The struct constructor.
 /// </summary>
 /// <param name="ServiceID"></param>
 /// <param name="Date"></param>
 /// <param name="ExceptionType"></param>
 public CalendarDate(
     string ServiceID,
     DateTime Date,
     CalendarExceptionType ExceptionType
     )
 {
     mServiceID = ServiceID;
     mDate=Date ;
     mExceptionType = ExceptionType;
 }
        private static void CacheExceptionsTable(ref SQLiteDataReader reader,
                                                 ref int processedRowCount, Stopwatch timeSoFar, ref string current_table_name,
                                                 Action displayTableName, Action <int, Stopwatch> updateTimeUI,
                                                 ref Dictionary <string, Dictionary <DateTime, CalendarExceptionType> > calExceptions)
        {
            // Update the table name shown on the progress form
            if (displayTableName != null)
            {
                displayTableName();
            }

            // Loop through the calendar_dates table and add the information to a dictionary keyed by service_id
            try
            {
                while (reader.Read())
                {
                    ++processedRowCount;
                    if (updateTimeUI != null)
                    {
                        updateTimeUI(processedRowCount, timeSoFar);
                    }

                    String   sDate = reader["date"].ToString();
                    DateTime Date  = DateTime.ParseExact(sDate,
                                                         "yyyyMMdd",
                                                         System.Globalization.CultureInfo.InvariantCulture,
                                                         System.Globalization.DateTimeStyles.None);
                    Int16 exception_type_int             = Convert.ToInt16(reader["exception_type"].ToString());
                    CalendarExceptionType exception_type = (CalendarExceptionType)exception_type_int;

                    string service_id = reader["service_id"].ToString();

                    // Add the exception to the dictionary under the appropriate service_id.
                    if (calExceptions.ContainsKey(service_id))
                    {
                        calExceptions[service_id].Add(Date, exception_type);
                    }
                    else
                    {
                        calExceptions.Add(service_id, new Dictionary <DateTime, CalendarExceptionType> {
                            { Date, exception_type }
                        });
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error caching calendar exceptions. Error: " + e.Message, e);
            }
        }