Exemplo n.º 1
0
        private void PopulateFromStagingTable()
        {
            var stagingTableName = DatabaseUtils.GetQualifiedTableName(
                PublicStagingSchema.StagingSchemaName, EntityUtils.ToCtTableName(Entity.Event));

            string federatedEventIdCol = EntityUtils.GetFederatedFieldName("event_id");

            var s = new SqlBuilder();

            s.AppendFormat("select {0}, day_of_week, start_time, end_time from {1}", federatedEventIdCol, stagingTableName);
            s.AppendFormat(
                "where {0} in ('{1}', '{2}')",
                HistorySchema.HistoryStatusColumnName,
                HistorySchema.HistoryStatusInsert,
                HistorySchema.HistoryStatusUpdate);

            DatabaseUtils.EnumerateResults(_connectionString, s.ToString(), _timeoutSecs, r =>
            {
                var times = new EventStartEndTime
                {
                    Start     = (DateTime)r["start_time"],
                    End       = (DateTime)r["end_time"],
                    DayOfWeek = Utils.ConvertFromCt7DayOfWeek((int)r["day_of_week"])
                };

                var eventId = (long)r[federatedEventIdCol];
                _eventTimes.Add(eventId, times);
            });
        }
Exemplo n.º 2
0
        private void PopulateFromPublicTable()
        {
            string publicEventTable = DatabaseUtils.GetQualifiedTableName(EventSchema.EventSchemaName, EntityUtils.ToFederationTableName(Entity.Event));

            var s = new SqlBuilder();

            s.AppendFormat("select event_id, day_of_week, start_time, end_time from {0}", publicEventTable);

            DatabaseUtils.EnumerateResults(_connectionString, s.ToString(), _timeoutSecs, r =>
            {
                var eventId = (long)r["event_id"];

                if (!_eventTimes.ContainsKey(eventId))
                {
                    var times = new EventStartEndTime
                    {
                        Start     = (DateTime)r["start_time"],
                        End       = (DateTime)r["end_time"],
                        DayOfWeek = Utils.ConvertFromCt7DayOfWeek((int)r["day_of_week"])
                    };

                    _eventTimes.Add(eventId, times);
                }
            });
        }