/// <summary>
        /// Constructor for the view model.
        /// </summary>
        public BackupInfoViewModel()
        {
            // Set a ref to self for static member usage.
            _ActiveViewModel = this;

            // For testing purposes.
            //_BackupInfo = new ObservableCollection<BackupItem>();

            // Actiovate the
            TaskManager.InitScheduler();

            // Prep the backupinfo for consumption.
            InitBackupInfo();
            // Prep the list of backup periods for consumption.
            InitBackupPeriodList();
            // Reactivate any previously active jobs from the serialized data.
            QueueAllJobs();
            // Check and toggle startup settings.
            ProgramOptionsManager.ToggleRunOnStartup(IsRunOnStartupEnabled);

            // Prep the commands for use.
            DeleteItemCmd               = new DeleteBackupItemCommand(this);
            AddItemCmd                  = new AddBackupItemCommand(this);
            SelectOriginFileDialogCmd   = new SelectOriginFileDialogCommand(this);
            SelectOriginFolderDialogCmd = new SelectOriginFolderDialogCommand(this);
            SelectBackupFolderDialogCmd = new SelectBackupFolderDialogCommand(this);
            SaveConfigCmd               = new SaveConfigCommand();
            LoadConfigCmd               = new LoadConfigCommand(this);
            ResetConfigCmd              = new ResetConfigCommand(this);
            ToggleRunOnStartupCmd       = new ToggleRunOnStartupCommand(this);

            // For testing purposes.
            //TestTasks();
        }
Example #2
0
        /* TIA 102.AACD-A 3.7.2.22 */
        public RspRsiInfo LoadConfig(int kmfRsi, int mnp)
        {
            //cg
            RspRsiInfo result = new RspRsiInfo();

            Begin();

            try
            {
                LoadConfigCommand cmdKmmBody = new LoadConfigCommand();
                cmdKmmBody.KmfRsi = kmfRsi;
                cmdKmmBody.MessageNumberPeriod = mnp;
                KmmBody rspKmmBody = TxRxKmm(cmdKmmBody);
                if (rspKmmBody is LoadConfigResponse)
                {
                    LoadConfigResponse kmm = rspKmmBody as LoadConfigResponse;
                    result.RSI    = kmm.RSI;
                    result.MN     = kmm.MN;
                    result.Status = kmm.Status;
                    //Console.WriteLine("response status: {0}", kmm.Status);
                }
                else if (rspKmmBody is NegativeAcknowledgment)
                {
                    NegativeAcknowledgment kmm = rspKmmBody as NegativeAcknowledgment;

                    string statusDescr  = OperationStatusExtensions.ToStatusString(kmm.Status);
                    string statusReason = OperationStatusExtensions.ToReasonString(kmm.Status);
                    throw new Exception(string.Format("received negative acknowledgment{0}status: {1} (0x{2:X2}){0}{3}", Environment.NewLine, statusDescr, kmm.Status, statusReason));
                }
                else
                {
                    throw new Exception("unexpected kmm");
                }
            }
            catch
            {
                End();

                throw;
            }

            End();

            return(result);
        }