コード例 #1
0
        public ScheduleItem()
            : base()
        {
            _scheduleId                = Null.NullInteger;
            _title                     = null;
            _enabled                   = Null.NullBoolean;
            _typeFullName              = null;
            _catchUpEnabled            = Null.NullBoolean;
            _timeLapse                 = Null.NullInteger;
            _timeLapseMeasurement      = null;
            _retryTimeLapse            = Null.NullInteger;
            _retryTimeLapseMeasurement = null;
            _retainHistoryNum          = Null.NullInteger;
            _attachToEvent             = null;
            _objectDependencies        = null;
            _servers                   = null;
            _nextStart                 = Null.NullDate;
            _lastUpdateTime            = Null.NullDate;

            _scheduleSource = ScheduleSource.NOT_SET;
            _threadId       = -1;
            _processGroup   = -1;

            _status     = Null.NullInteger;
            _createTime = Null.NullDate;
        }
コード例 #2
0
        private async void ShowTimePickerAsync()
        {
            var picker = new TimePickerFlyout();

            picker.TimePicked += (sender, e) =>
            {
                TimeLabelContent.Text = picker.Time.ToString();
                ScheduleSource.SetLocalTimeWithTimeSpan(picker.Time);

                if (EnabledCheckBox.IsChecked == false)
                {
                    EnabledCheckBox.IsChecked = true;
                }
                else
                {
                    UpdateScheduleAsync();
                }
            };

            picker.Closed += (sender, e) =>
            {
                if (EnabledCheckBox.IsChecked == true && ScheduleSource.LocalTime == null)
                {
                    EnabledCheckBox.IsChecked = false;
                }
            };

            await picker.ShowAtAsync(TimeLabel);
        }
コード例 #3
0
        public void InsertSchedule(ScheduleTrain train, ScheduleSource source = ScheduleSource.CIF)
        {
            using (var ts = GetTransactionScope())
            {
                if (train.AtocCode == null || string.IsNullOrEmpty(train.AtocCode.Code))
                {
                    const string atocCodeLookup = @"
                        SELECT TOP 1
                            [AtocCode]
                        FROM [ScheduleTrain]
                        WHERE [TrainUid] = @trainUid
                            AND [AtocCode] IS NOT NULL";

                    string atocCode = ExecuteScalar<string>(atocCodeLookup, new { trainUid = train.TrainUid });
                    train.AtocCode = new AtocCode
                    {
                        Code = atocCode
                    };
                }

                const string sql = @"
                INSERT INTO [natrail].[dbo].[ScheduleTrain]
                       ([TrainUid]
                       ,[Headcode]
                       ,[StartDate]
                       ,[EndDate]
                       ,[AtocCode]
                       ,[RunsMonday]
                       ,[RunsTuesday]
                       ,[RunsWednesday]
                       ,[RunsThursday]
                       ,[RunsFriday]
                       ,[RunsSaturday]
                       ,[RunsSunday]
                       ,[RunsBankHoliday]
                       ,[STPIndicatorId]
                       ,[ScheduleStatusId]
                       ,[OriginStopTiplocId]
                       ,[DestinationStopTiplocId]
                       ,[Source]
                       ,[PowerTypeId]
                       ,[CategoryTypeId]
                       ,[Speed])
                    OUTPUT [inserted].[ScheduleId]
                    VALUES
                       (@TrainUid
                       ,@Headcode
                       ,@StartDate
                       ,@EndDate
                       ,@Code
                       ,@Monday
                       ,@Tuesday
                       ,@Wednesday
                       ,@Thursday
                       ,@Friday
                       ,@Saturday
                       ,@Sunday
                       ,@BankHoliday
                       ,@STPIndicator
                       ,@Status
                       ,@OriginTiplocId
                       ,@DestinationTiplocId
                       ,@Source
                       ,@PowerTypeId
                       ,@CategoryTypeId
                       ,@Speed)";

                Guid id = ExecuteInsert(sql, new
                {
                    train.TrainUid,
                    train.Headcode,
                    train.StartDate,
                    train.EndDate,
                    train.AtocCode.Code,
                    train.Schedule.Monday,
                    train.Schedule.Tuesday,
                    train.Schedule.Wednesday,
                    train.Schedule.Thursday,
                    train.Schedule.Friday,
                    train.Schedule.Saturday,
                    train.Schedule.Sunday,
                    train.Schedule.BankHoliday,
                    train.STPIndicator,
                    train.Status,
                    OriginTiplocId = train.Origin != null ? new short?(train.Origin.TiplocId) : default(short?),
                    DestinationTiplocId = train.Destination != null ? new short?(train.Destination.TiplocId) : default(short?),
                    Source = source,
                    PowerTypeId = train.PowerType != null ? (byte)train.PowerType : default(byte?),
                    CategoryTypeId = train.TrainCategory != null ? (byte)train.TrainCategory : default(byte?),
                    Speed = train.Speed != null ? (byte)train.Speed : default(byte?)
                });
                if (source == ScheduleSource.VSTP)
                {
                    Trace.TraceInformation("Saving VSTP Schedule for UID: {0} with ID {1}",
                        train.TrainUid, id);
                }

                InsertScheduleStops(id, train.Stops);
                ts.Complete();
            }
        }