Exemplo n.º 1
0
        private void PopulateFromPublic(int srcTimetableId)
        {
            var tableName = DatabaseUtils.GetQualifiedTableName(MiscSchema.MiscSchemaName, "TIMETABLE_CONFIG");

            var sb = new SqlBuilder();

            sb.AppendFormat("select * from {0}", tableName);
            sb.AppendFormat("where timetable_id={0}", srcTimetableId);

            DatabaseUtils.GetSingleResult(_connectionString, sb.ToString(), _timeoutSecs, r =>
            {
                var dates = new WeekDatesForTimetable();

                int numWeeks = (int)r["no_weeks"];
                for (int wk = 0; wk < numWeeks; ++wk)
                {
                    var colName = $"week{wk + 1}_date";

                    if (wk == 0)
                    {
                        dates.StartingDayOfWeek = ((DateTime)r[colName]).DayOfWeek;
                    }

                    dates.StartingDates.Add((DateTime)r[colName]);
                }

                _data.Add(srcTimetableId, dates);
            });
        }
Exemplo n.º 2
0
        private bool PopulateFromStage(int srcTimetableId)
        {
            bool found = false;

            string tableName = DatabaseUtils.GetQualifiedTableName(PublicStagingSchema.StagingSchemaName, "CT_CONFIG");

            SqlBuilder sb = new SqlBuilder();

            sb.AppendFormat("select * from {0}", tableName);
            sb.AppendFormat("where src_timetable_id={0}", srcTimetableId);
            sb.AppendFormat(
                "and {0} in ('{1}', '{2}')",
                HistorySchema.HistoryStatusColumnName,
                HistorySchema.HistoryStatusInsert,
                HistorySchema.HistoryStatusUpdate);

            DatabaseUtils.GetSingleResult(_connectionString, sb.ToString(), _timeoutSecs, r =>
            {
                var dates = new WeekDatesForTimetable();

                var numWeeks = (int)r["no_weeks"];
                for (int wk = 0; wk < numWeeks; ++wk)
                {
                    var colName = $"week{wk + 1}_date";

                    if (wk == 0)
                    {
                        dates.StartingDayOfWeek = ((DateTime)r[colName]).DayOfWeek;
                    }

                    dates.StartingDates.Add((DateTime)r[colName]);
                }

                _data.Add(srcTimetableId, dates);

                found = true;
            });

            return(found);
        }