コード例 #1
0
 public void EnterAction(BackupAction action)
 {
     lock (actions)
     {
         if (action == BackupAction.ListingLocal || action == BackupAction.ListingBucket)
         {
             if (state == BackupState.Backup)
             {
                 throw new InvalidOperationException();
             }
             State = BackupState.Listing;
             actions.Add(action);
         }
         else if (action == BackupAction.RunningBackup)
         {
             if (state != BackupState.Idle)
             {
                 throw new InvalidOperationException();
             }
             State = BackupState.Backup;
             actions.Add(action);
         }
     }
     NotifyPropertyChanged("StatusMessage");
 }
コード例 #2
0
        private async Task <TResult> RunServicesAsync <TResult>(BackupAction action, RecurringSchedule schedule, Func <string[], TResult> onCompleted)
        {
            if (action.services == null || !action.services.Any())
            {
                return(onCompleted(new string[] { $"no services for {action.tag}" }));
            }
            if (!action.GetSourceAccount(out CloudStorageAccount sourceAccount))
            {
                return(onCompleted(new[] { $"bad SOURCE connection string for {action.tag}" }));
            }
            if (!schedule.GetTargetAccount(out CloudStorageAccount targetAccount))
            {
                return(onCompleted(new[] { $"bad TARGET connection string for {schedule.tag}" }));
            }

            var errors = new string[] { };

            if (action.services.Contains(StorageService.Table))
            {
                errors = errors
                         .Concat(await action.serviceSettings.table.CopyAccountAsync(sourceAccount, targetAccount, StopCalled, msgs => msgs))
                         .ToArray();
            }

            if (action.services.Contains(StorageService.Blob))
            {
                errors = errors
                         .Concat(await action.serviceSettings.blob.CopyAccountAsync(sourceAccount, targetAccount, StopCalled, msgs => msgs))
                         .ToArray();
            }

            return(onCompleted(errors));
        }
コード例 #3
0
 public BackupActionEventArgs(BackupAction action, IReadOnlyList <string> path, IFileSystemInfo sourceItem, IFileSystemInfo targetItem, FileInfoEqualityMethods method = FileInfoEqualityMethods.None)
 {
     SourceItem = sourceItem;
     TargetItem = targetItem;
     Action     = action;
     Path       = path;
     Method     = method;
 }
コード例 #4
0
 private string GetActionPath(BackupAction action)
 {
     if (action is CopyFileAction)
     {
         return(((CopyFileAction)action).Source);
     }
     if (action is DirectAction)
     {
         return(((DirectAction)action).Path);
     }
     return(string.Empty);
 }
コード例 #5
0
        private UIElement GetActionContent(BackupAction backupAction)
        {
            Uri actionContentUri   = new Uri($"pack://application:,,,/Windows/BackupActions/{backupAction.ToString()}BackupActionContent.xaml", UriKind.Absolute);
            var resourceStreamInfo = Application.GetResourceStream(actionContentUri);
            //TODO investigate LoadAsync but no awaiter implemented...
            // It seems because I have not applied the `x:SynchronouseMode="Async"` attribute to the root element of my xaml, it is being loaded synchronously. However this is good because If I was loading
            // it asyncrhonously, I would have to use the LoadCompleted event or otherwise my attaching of event handlers would be in trouble...
            // var xamlReader = new XamlReader();
            var uiElement = XamlReader.Load(resourceStreamInfo.Stream) as UIElement;

            AttachEventHandlersAndDataBinding(uiElement, backupAction);
            return(uiElement);
        }
コード例 #6
0
        private string GetHeader(BackupAction backupAction)
        {
            switch (backupAction)
            {
            case BackupAction.Create:
                return("Create new backup");

            case BackupAction.Delete:
                return($"Delete existing backup: {_backupWithCount?.Name ?? string.Empty}");

            case BackupAction.Inspect:
                return($"Inspect existing backup: {_backupWithCount?.Name ?? string.Empty}");

            case BackupAction.Restore:
                return($"Restore from backup: {_backupWithCount?.Name ?? string.Empty}");

            default:
                throw new ArgumentException(nameof(backupAction));
            }
        }
コード例 #7
0
ファイル: BackuperFixture.cs プロジェクト: dobriyeeh/simpkup
        public void TestEncryptedArchives()
        {
            var newConfig = _config;

            newConfig.usePassword   = true;
            newConfig.password      = "******";
            newConfig.backupToPath += "\\test.zip";


            var backupRule   = new BackupRule(_dataPlace, newConfig);
            var backupAction = new BackupAction(_dataPlace, newConfig);

            var backuper = new Backuper(backupAction, backupRule);

            backupAction.Backup();

            var verificator = new DataVerificator(_testedData);

            Assert.Catch <InvalidDataException>(() => verificator.testArchive(newConfig.backupToPath));
            Assert.IsTrue(verificator.testEncryptedArchive(newConfig.backupToPath, newConfig.password));
        }
コード例 #8
0
ファイル: RestoreWizard.cs プロジェクト: yimng/xenconsole
        /// <summary>
        /// Get machine backups list
        /// </summary>
        /// <returns></returns>
        private bool InitRestoreTree(ref BackupRestoreConfig.RestoreListInfo restoreList)
        {
            bool isActionSucceed = false;

            Dictionary <string, string> dconf = new Dictionary <string, string>
            {
                { "ip", this.page_SetStorage.StorageIP },
                { "username", this.page_SetStorage.UserName },
                { "password", this.page_SetStorage.Password }
            };
            BackupAction action = new BackupAction(Messages.GET_RESTORE_LIST, BackupRestoreConfig.BackupActionKind.RestoreFileList, this._xenModelObject, dconf);

            const ProgressBarStyle progressBarStyle = ProgressBarStyle.Marquee;
            ActionProgressDialog   dialog           = new ActionProgressDialog(action, progressBarStyle);

            dialog.ShowCancel = true;
            dialog.ShowDialog(this);

            try
            {
                if (!(action.Succeeded || ((action.Exception == null) || (action.Exception.Message.Equals("")))))
                {
                    Program.MainWindow.BringToFront();
                }
                else
                {
                    restoreList     = action.RestoreList;
                    isActionSucceed = true;
                }
            }
            catch
            {
                Program.MainWindow.BringToFront();
            }


            return(isActionSucceed);
        }
コード例 #9
0
        private void AttachEventHandlersAndDataBinding(UIElement uiElement, BackupAction backupAction)
        {
            switch (backupAction)
            {
            case BackupAction.Create:
                AttachCreateEventHandlersAndDataBinding(uiElement);
                break;

            case BackupAction.Delete:
                AttachDeleteEventHandlersAndDataBinding(uiElement);
                break;

            case BackupAction.Inspect:
                AttachInspectEventHandlersAndDataBinding(uiElement);
                break;

            case BackupAction.Restore:
                AttachRestoreEventHandlers(uiElement);
                break;

            default:
                throw new ArgumentException(nameof(backupAction));
            }
        }
コード例 #10
0
 public static void Log(string logFilePath, BackupAction backupAction, string text, params object[] args)
 {
     Log(logFilePath, text, args);
     Utils.SendPushbulletMessage("Backup - " + System.Enum.GetName(typeof(BackupAction), backupAction), string.Format(text, args));
 }
コード例 #11
0
        private void SummeryInfoCheck()
        {
            String str_rules = "";
            String str_job   = "";
            String c         = "";

            BackupRestoreConfig.BrSchedule schedule = new BackupRestoreConfig.BrSchedule();
            schedule.current_full_count = 0;
            if (this.scheduleBackupPage.NowRadioButtonIsChecked())
            {
                schedule.jobName      = this.optionsBackupPage._JobNameTextBox;
                schedule.scheduleType = 0;
                schedule.scheduleDate = "";
                str_rules             = HalsignUtil.ToJson(schedule);
            }
            if (this.scheduleBackupPage.OnceRadioButtonIsChecked() && !this.scheduleBackupPage.IsFullBackup)
            {
                schedule.jobName      = this.optionsBackupPage._JobNameTextBox;
                schedule.scheduleType = 1;
                schedule.scheduleDate = this.scheduleBackupPage.StartDatePickerText;
                schedule.scheduleTime = this.scheduleBackupPage.StartTimePickerText;
                str_rules             = HalsignUtil.ToJson(schedule);
                c = "s";
            }

            if (this.scheduleBackupPage.OnceRadioButtonIsChecked() && this.scheduleBackupPage.IsFullBackup)
            {
                schedule.jobName      = this.optionsBackupPage._JobNameTextBox;
                schedule.scheduleType = 5;
                schedule.scheduleDate = this.scheduleBackupPage.StartDatePickerText;
                schedule.scheduleTime = this.scheduleBackupPage.StartTimePickerText;
                str_rules             = HalsignUtil.ToJson(schedule);
                c = "q";
            }

            if (this.scheduleBackupPage.DailyRadioButtonIsChecked())
            {
                schedule.jobName           = this.optionsBackupPage._JobNameTextBox;
                schedule.scheduleType      = 2;
                schedule.scheduleDate      = this.scheduleBackupPage.StartDatePickerText;
                schedule.scheduleTime      = this.scheduleBackupPage.StartTimePickerText;
                schedule.recur             = this.scheduleBackupPage._RecurTextBox == "" ? 0 : Int32.Parse(this.scheduleBackupPage._RecurTextBox);
                schedule.expect_full_count = this.scheduleBackupPage._expectFullCheckBox?this.scheduleBackupPage._expectFullCountTextBox:0;
                str_rules = HalsignUtil.ToJson(schedule);
                c         = "t";
            }
            if (this.scheduleBackupPage.CircleRadioButtonIsChecked())
            {
                schedule.jobName           = this.optionsBackupPage._JobNameTextBox;
                schedule.scheduleType      = 4;
                schedule.scheduleDate      = this.scheduleBackupPage.StartDatePickerText;
                schedule.scheduleTime      = this.scheduleBackupPage.StartTimePickerText;
                schedule.recur             = this.scheduleBackupPage._RecurTextBox == "" ? 1 : Int32.Parse(this.scheduleBackupPage._RecurTextBox);
                schedule.expect_full_count = this.scheduleBackupPage._expectFullCheckBox ? this.scheduleBackupPage._expectFullCountTextBox : 0;
                str_rules = HalsignUtil.ToJson(schedule);
                c         = "h";
            }
            if (this.scheduleBackupPage.WeeklyRadioButtonIsChecked())
            {
                schedule.jobName      = this.optionsBackupPage._JobNameTextBox;
                schedule.scheduleType = 3;
                schedule.scheduleDate = this.scheduleBackupPage.StartDatePickerText;
                schedule.scheduleTime = this.scheduleBackupPage.StartTimePickerText;
                c = "w";
                schedule.recur             = this.scheduleBackupPage._RecurTextBox == "" ? 0 : Int32.Parse(this.scheduleBackupPage._RecurTextBox);
                schedule.expect_full_count = this.scheduleBackupPage._expectFullCheckBox ? this.scheduleBackupPage._expectFullCountTextBox : 0;
                List <int> list = new List <int>();
                if (this.scheduleBackupPage._MondayCheckBoxIsChecked())
                {
                    list.Add(1);
                }
                if (this.scheduleBackupPage._TuesdayCheckBoxIsChecked())
                {
                    list.Add(2);
                }
                if (this.scheduleBackupPage._WednesdayCheckBoxIsChecked())
                {
                    list.Add(3);
                }
                if (this.scheduleBackupPage._ThursdayCheckBoxIsChecked())
                {
                    list.Add(4);
                }
                if (this.scheduleBackupPage._FridayCheckBoxIsChecked())
                {
                    list.Add(5);
                }
                if (this.scheduleBackupPage._SaturdayCheckBoxIsChecked())
                {
                    list.Add(6);
                }
                if (this.scheduleBackupPage._SundayCheckBoxIsChecked())
                {
                    list.Add(0);
                }
                schedule.weeklyDays = list;
                str_rules           = HalsignUtil.ToJson(schedule);
            }
            str_rules = str_rules.Replace("\\/", "/");

            if (!c.Equals(""))
            {
                BackupRestoreConfig.Job job = new BackupRestoreConfig.Job();
                job.job_name = this.optionsBackupPage._JobNameTextBox;
                job.host     = "";
                job.key      = "halsign_br_job_s";
                job.request  = c + this.optionsBackupPage._JobNameTextBox.TrimEnd().TrimStart() + "|";
                TimeSpan ts = DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0));
                ts = new DateTime(this.scheduleBackupPage.StartDatePickerValue.Year, this.scheduleBackupPage.StartDatePickerValue.Month,
                                  this.scheduleBackupPage.StartDatePickerValue.Day, this.scheduleBackupPage.StartTimePickerValue.Hour, this.scheduleBackupPage.StartTimePickerValue.Minute,
                                  this.scheduleBackupPage.StartTimePickerValue.Second).Subtract(new DateTime(1970, 1, 1, 0, 0, 0).ToLocalTime());
                job.start_time         = "";
                job.progress           = -1;
                job.total_storage      = -1;
                job.modify_time        = "";
                job.pid                = -1;
                job.retry              = -1;
                job.speed              = -1;
                job.status             = 0;
                job.current_full_count = 0;
                if (c.Equals("s"))
                {
                    job.schedule_type = 1;
                }
                else if (c.Equals("q"))
                {
                    job.schedule_type = 5;
                }
                else if (c.Equals("t"))
                {
                    job.schedule_type = 2;
                }
                else if (c.Equals("h"))
                {
                    job.schedule_type = 4;
                }
                else if (c.Equals("w"))
                {
                    job.schedule_type = 3;
                }
                job.expect_full_count = this.scheduleBackupPage.IsFullBackup ? 0 : (this.scheduleBackupPage._expectFullCheckBox ? this.scheduleBackupPage._expectFullCountTextBox : 0);
                str_job = HalsignUtil.ToJson(job);
            }
            Dictionary <string, string> _dconf = new Dictionary <string, string>();

            _dconf.Add("job_name", this.optionsBackupPage._JobNameTextBox.TrimEnd().TrimStart());
            //_dconf.Add("command", this.optionsBackupPage.IsFullBackup ? "b" : "i");
            _dconf.Add("command", this.scheduleBackupPage.IsFullBackup ? "b" : "i");
            _dconf.Add("is_now", this.scheduleBackupPage.NowRadioButtonIsChecked().ToString());
            _dconf.Add("backup_rules", str_rules);
            _dconf.Add("backup_job", str_job);

            BackupAction action = new BackupAction(Messages.BACKUP_VM, BackupRestoreConfig.BackupActionKind.Backup, this._xenModelObject, this.vmCheckedList, _dconf, this.vdi_dictionary);

            if (action != null)
            {
                ProgressBarStyle     progressBarStyle = ProgressBarStyle.Marquee;
                ActionProgressDialog dialog           = new ActionProgressDialog(action, progressBarStyle);
                dialog.ShowCancel = false;
                dialog.ShowDialog(this);
                if (!action.Succeeded || !string.IsNullOrEmpty(action.Result))
                {
                    base.FinishCanceled();
                }
                else
                {
                    base.FinishWizard();
                }
            }

            if (!(this._xenModelObject is Host))
            {
                // todo Program.MainWindow.SwitchToTab(MainWindow.Tab.BR);
                if (this._xenModelObject is VM)
                {
                    VM vm = this._xenModelObject as VM;
                    vm.NotifyPropertyChanged("other_config");
                }
            }
        }
コード例 #12
0
ファイル: Utils.cs プロジェクト: andy-reeves/BackupManager
        public static void LogWithPushover(string pushoverUserKey, string pushoverAppToken, string logFilePath, BackupAction backupAction, PushoverPriority priority, string text, params object[] args)
        {
            Log(logFilePath, System.Enum.GetName(typeof(BackupAction), backupAction) + " " + text, args);

            if (!string.IsNullOrEmpty(pushoverAppToken))
            {
                Utils.SendPushoverMessage(pushoverUserKey, pushoverAppToken, System.Enum.GetName(typeof(BackupAction), backupAction), priority, string.Format(text, args));
            }
        }
コード例 #13
0
ファイル: RestoreWizard.cs プロジェクト: yimng/xenconsole
        /// <summary>
        /// Update by Dalei.Shou on 2013/8/16, remove the last "|0" parameter
        /// </summary>
        private void ScheduleRestoreJob()
        {
            int rowCount = this.page_VMSettings.DataGridViewRestoreInfo.RowCount;

            for (int i = 0; i < this.page_VMSettings.DataGridViewRestoreInfo.RowCount; i++)
            {
                if (this.page_VMSettings.DataGridViewRestoreInfo.Rows[i].Cells[0].Value.ToString().ToLowerInvariant() == "true")
                {
                    string[] uuidTag = this.page_VMSettings.DataGridViewRestoreInfo.Rows[i].Tag.ToString().Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                    if (!restore_vdi_list.ContainsKey(uuidTag[0]))
                    {
                        restore_vdi_list.Add(uuidTag[0], uuidTag[1]);
                    }
                    else
                    {
                        string temp = string.Concat(restore_vdi_list[uuidTag[0]], "@", uuidTag[1]);
                        restore_vdi_list[uuidTag[0]] = temp;
                    }
                }
            }
            List <string> list = new List <string>();
            List <Dictionary <string, string> > listSchedule = new List <Dictionary <string, string> >();
            string schedule     = "";
            int    milliseconds = 0;

            foreach (AgentParamDataModel item in this.vmCheckedList)
            {
                string uuid_spend = "|";
                if (restore_vdi_list.ContainsKey(item.VMRestoreInfo.Substring(37, 36)))
                {
                    int l = restore_vdi_list[item.VMRestoreInfo.Substring(37, 36)].Split('@').Length;
                    if (l == 1)
                    {
                        uuid_spend += "halsign_vdi_all";
                    }
                    else
                    {
                        if (l - 1 == restore_vdi_info_list[item.VMRestoreInfo].Count)
                        {
                            uuid_spend += "halsign_vdi_all";
                        }
                        else if (l - 1 < restore_vdi_info_list[item.VMRestoreInfo].Count)
                        {
                            for (int y = 1; y < l; y++)
                            {
                                if (y == 1)
                                {
                                    uuid_spend = uuid_spend + restore_vdi_list[item.VMRestoreInfo.Substring(37, 36)].Split('@')[y];
                                }
                                else
                                {
                                    uuid_spend = uuid_spend + "@" +
                                                 restore_vdi_list[item.VMRestoreInfo.Substring(37, 36)].Split('@')[y];
                                }
                            }
                        }
                    }
                }

                list.Add(this.restore_job_name.TrimEnd().TrimStart() + "|" + this.set_storage_ip.Trim() + "|"
                         + this.set_storage_username + "|" + this.set_storage_password + "|" + item.RootPath + "|" +
                         item.VMRestoreInfo + "|"
                         + this.restore_vm_name + "|" + this.restoreDataModel.choice_sr_uuid + "|"
                         + (this._isBackupNetworkSettingChecked ? "1" : "0") + "|" +
                         (this._isNewMacAddressChecked ? "1" : "0")
                         + "|" + this.restore_network_uuid + uuid_spend);

                if (this._isOnceScheduleChecked)
                {
                    Dictionary <string, string> dconfTemp = new Dictionary <string, string>();
                    BackupRestoreConfig.Job     job       = new BackupRestoreConfig.Job();
                    job.job_name = this.restore_job_name.TrimEnd().TrimStart();

                    if (this._xenModelObject is VM)
                    {
                        VM _xenVM = this._xenModelObject as VM;
                        job.host = HalsignHelpers.VMHome(_xenVM).uuid;
                    }
                    else if (this._xenModelObject is Host)
                    {
                        Host _xenHost = _xenModelObject as Host;
                        job.host = _xenHost.uuid;
                    }
                    else
                    {
                        job.host = Helpers.GetMaster(this._xenModelObject.Connection).uuid;
                    }

                    TimeSpan ts = DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, 0));
                    job.key = "halsign_br_job_s_" + (Math.Floor(ts.TotalMilliseconds) + milliseconds++);

                    job.request = "o" + this.restore_job_name.TrimEnd().TrimStart() + "|" + this.set_storage_ip.Trim() +
                                  "|" + this.set_storage_username + "|" + this.set_storage_password + "|" +
                                  item.RootPath +
                                  "|" + item.VMRestoreInfo + "|" + restore_vm_name + "|" +
                                  this.restoreDataModel.choice_sr_uuid + "|"
                                  + (this._isBackupNetworkSettingChecked ? "1" : "0") + "|" +
                                  (this._isNewMacAddressChecked ? "1" : "0") + "|" + this.restore_network_uuid +
                                  uuid_spend;
                    ts = new DateTime(this.scheduleDate.Year, this.scheduleDate.Month, this.scheduleDate.Day, this.scheduleTime.Hour, this.scheduleTime.Minute,
                                      this.scheduleTime.Second).Subtract(new DateTime(1970, 1, 1, 0, 0, 0).ToLocalTime());
                    job.start_time    = Math.Floor(ts.TotalSeconds).ToString();
                    job.progress      = -1;
                    job.total_storage = -1;
                    job.modify_time   = "";
                    job.pid           = -1;
                    job.retry         = -1;
                    job.speed         = -1;
                    job.status        = 0;
                    schedule          = HalsignUtil.ToJson(job);
                    schedule          = schedule.Replace("\\/", "/");
                    dconfTemp.Add("schedule", schedule);
                    dconfTemp.Add("config_name", job.key);
                    listSchedule.Add(dconfTemp);
                }
            }

            BackupAction action = new BackupAction(_Message, BackupRestoreConfig.BackupActionKind.Restore, this._xenModelObject, list, listSchedule);

            if (action != null)
            {
                ProgressBarStyle     progressBarStyle = ProgressBarStyle.Marquee;
                ActionProgressDialog dialog           = new ActionProgressDialog(action, progressBarStyle);
                dialog.ShowCancel = false;
                dialog.ShowDialog(this);
                try
                {
                    if (!string.IsNullOrEmpty(action.Result))
                    {
                        Program.MainWindow.BringToFront();
                    }
                }
                catch
                {
                    Program.MainWindow.BringToFront();
                }
            }
        }
コード例 #14
0
 public void ExitAction(BackupAction action)
 {
     lock (actions)
     {
         if (!actions.Contains(action))
         {
             throw new InvalidOperationException();
         }
         actions.Remove(action);
         if (actions.Count == 0)
         {
             State = BackupState.Idle;
         }
     }
     NotifyPropertyChanged("StatusMessage");
 }
コード例 #15
0
ファイル: ReplicationWizard.cs プロジェクト: yimng/xenconsole
        protected override void FinishWizard()
        {
            List <Dictionary <string, string> >         listParam     = new List <Dictionary <string, string> >();
            List <Dictionary <string, List <string> > > listParamTemp = new List <Dictionary <string, List <string> > >();

            BackupRestoreConfig.BrSchedule schedule = new BackupRestoreConfig.BrSchedule();
            BackupRestoreConfig.Job        job      = new BackupRestoreConfig.Job();
            string str_rules   = "";
            String str_job     = "";
            string str_command = "";

            schedule.jobName = this.repJobSettingPage.JobNameText;
            job.job_name     = this.repJobSettingPage.JobNameText;
            if (this.schedulePage.NowChecked)
            {
                str_command           = "f";
                schedule.scheduleType = 0;
                job.schedule_type     = 0;
                schedule.scheduleDate = "";
            }
            if (this.schedulePage.OnceChecked)
            {
                str_command           = "y";
                schedule.scheduleType = 1;
                job.schedule_type     = 1;
                schedule.scheduleDate = this.schedulePage.StartDateText;
                schedule.scheduleTime = this.schedulePage.StartTimeText;
            }
            if (this.schedulePage.DailyChecked)
            {
                str_command           = "a";
                schedule.scheduleType = 2;
                job.schedule_type     = 2;
                schedule.scheduleDate = this.schedulePage.StartDateText;
                schedule.scheduleTime = this.schedulePage.StartTimeText;
                schedule.recur        = this.schedulePage.RecurText;
            }
            if (this.schedulePage.CircleChecked)
            {
                str_command           = "u";
                schedule.scheduleType = 4;
                job.schedule_type     = 4;
                schedule.scheduleDate = this.schedulePage.StartDateText;
                schedule.scheduleTime = this.schedulePage.StartTimeText;
                schedule.recur        = this.schedulePage.RecurText;
            }
            if (this.schedulePage.WeeklyChecked)
            {
                str_command           = "z";
                schedule.scheduleType = 3;
                job.schedule_type     = 3;
                schedule.scheduleDate = this.schedulePage.StartDateText;
                schedule.scheduleTime = this.schedulePage.StartTimeText;
                schedule.recur        = this.schedulePage.RecurText;
                List <int> listDays = new List <int>();
                if (this.schedulePage.MondayChecked)
                {
                    listDays.Add(1);
                }
                if (this.schedulePage.TuesdayChecked)
                {
                    listDays.Add(2);
                }
                if (this.schedulePage.WednesdayChecked)
                {
                    listDays.Add(3);
                }
                if (this.schedulePage.ThursdayChecked)
                {
                    listDays.Add(4);
                }
                if (this.schedulePage.FridayChecked)
                {
                    listDays.Add(5);
                }
                if (this.schedulePage.SaturdayChecked)
                {
                    listDays.Add(6);
                }
                if (this.schedulePage.SundayChecked)
                {
                    listDays.Add(0);
                }
                schedule.weeklyDays = listDays;
            }
            if (scheduleDetails != null && !scheduleDetails.Equals(""))
            {
                schedule.details = scheduleDetails;
            }
            else
            {
                schedule.details = this.repJobSettingPage.Choice_sr_ip + "|"
                                   + this.repJobSettingPage.DestUsernameText + "|" + this.repJobSettingPage.DestPasswordText + "|"
                                   + this.repJobSettingPage.VMNameText + "|" + this.repJobSettingPage.Choice_sr_uuid + "|0|"
                                   + this.repJobSettingPage.MacText + "|" + this.repJobSettingPage.NetworkValue + "|"
                                   + Helpers.GetMaster(this.repJobSettingPage.Selected_xenConnection).address + "|" + this.repJobSettingPage.Selected_xenConnection.Username + "|"
                                   + this.repJobSettingPage.Selected_xenConnection.Password + "|" + this.repJobSettingPage.Selected_host.uuid;
            }
            str_rules = HalsignUtil.ToJson(schedule);
            str_rules = str_rules.Replace("\\/", "/");


            job.host    = "";
            job.key     = "halsign_br_job_r";
            job.request = str_command + this.repJobSettingPage.JobNameText.TrimEnd().TrimStart() + "|";
            TimeSpan ts = DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0));

            ts = new DateTime(this.schedulePage.StartDateValue.Year, this.schedulePage.StartDateValue.Month,
                              this.schedulePage.StartDateValue.Day, this.schedulePage.StartTimeValue.Hour, this.schedulePage.StartTimeValue.Minute,
                              this.schedulePage.StartTimeValue.Second).Subtract(new DateTime(1970, 1, 1, 0, 0, 0).ToLocalTime());
            if (jobs != null)
            {
                jobs.request       = str_command + jobs.request.Substring(1, jobs.request.Length - 1);
                jobs.schedule_type = job.schedule_type;
                str_job            = HalsignUtil.ToJson(jobs);
            }
            else
            {
                job.start_time         = "";
                job.progress           = -1;
                job.total_storage      = -1;
                job.modify_time        = "";
                job.pid                = -1;
                job.retry              = -1;
                job.speed              = -1;
                job.status             = 0;
                job.current_full_count = 0;
                job.expect_full_count  = 0;//this.scheduleBackupPage.IsFullBackup ? 0 : (this.scheduleBackupPage._expectFullCheckBox ? this.scheduleBackupPage._expectFullCountTextBox : 0);
                str_job                = HalsignUtil.ToJson(job);
            }


            //string a = this.repJobSettingPage.Selected_xenConnection.Hostname;

            Dictionary <string, string> _dconf = new Dictionary <string, string>();

            _dconf.Add("command", str_command);
            _dconf.Add("is_now", this.schedulePage.NowChecked.ToString());
            _dconf.Add("replication_rules", str_rules);
            _dconf.Add("replication_job", str_job);
            if (jobs != null)
            {
                _dconf.Add("replication_editjob", "true");
            }
            else
            {
                _dconf.Add("replication_editjob", "false");
            }

            foreach (VM item in this.repChoseVmPage.VmCheckedList)
            {
                Dictionary <string, string>         _dconf_param      = new Dictionary <string, string>();
                Dictionary <string, List <string> > _dconf_param_temp = new Dictionary <string, List <string> >();
                string host_ip = " ";
                if (!HalsignHelpers.VMHome(item).address.Equals(this.repJobSettingPage.Choice_sr_ip))
                {
                    host_ip = this.repJobSettingPage.Choice_sr_ip;
                }
                List <string> syncCheckedList = new List <string>();
                foreach (Dictionary <string, string> dRepChecked in this.synchronizationPage.RepCheckedList)
                {
                    if (dRepChecked.ContainsKey(item.uuid))
                    {
                        string request_expend = "";
                        if (this.repChoseVmPage.vdi_expand_list.ContainsKey(item.uuid))
                        {
                            int vdiNo = 0;
                            foreach (VBD vbd in item.Connection.ResolveAll <VBD>(item.VBDs))
                            {
                                if (HalsignHelpers.IsCDROM(vbd))
                                {
                                    continue;
                                }

                                if (vbd.type.Equals(XenAPI.vbd_type.Disk))
                                {
                                    vdiNo++;
                                }
                            }
                            if (vdiNo == this.repChoseVmPage.vdi_expand_list[item.uuid].Split('@').Length)
                            {
                                request_expend = "|" + "halsign_vdi_all";
                            }
                            else
                            {
                                request_expend = "|" + this.repChoseVmPage.vdi_expand_list[item.uuid];
                            }
                        }
                        if ("new".Equals(dRepChecked[item.uuid]))
                        {
                            syncCheckedList.Add(this.repJobSettingPage.JobNameText + "|" + item.uuid + "|" + host_ip + "|"
                                                + this.repJobSettingPage.DestUsernameText + "|" + this.repJobSettingPage.DestPasswordText + "|"
                                                + this.repJobSettingPage.VMNameText + "|" + this.repJobSettingPage.Choice_sr_uuid + "|0|"
                                                + this.repJobSettingPage.MacText + "|" + this.repJobSettingPage.NetworkValue + "|"
                                                + Helpers.GetMaster(this.repJobSettingPage.Selected_xenConnection).address + "|" + this.repJobSettingPage.Selected_xenConnection.Username + "|"
                                                + this.repJobSettingPage.Selected_xenConnection.Password + "|" + this.repJobSettingPage.Selected_host.uuid + request_expend);
                        }
                        else
                        {
                            syncCheckedList.Add(this.repJobSettingPage.JobNameText + "|" + item.uuid + "|" + host_ip + "|"
                                                + this.repJobSettingPage.DestUsernameText + "|" + this.repJobSettingPage.DestPasswordText + "|"
                                                + dRepChecked[item.uuid] + "|" + Helpers.GetMaster(this.repJobSettingPage.Selected_xenConnection).address + "|"
                                                + this.repJobSettingPage.Selected_xenConnection.Username + "|" + this.repJobSettingPage.Selected_xenConnection.Password + request_expend);
                        }
                    }
                }
                _dconf_param_temp.Add(item.uuid, syncCheckedList);
                listParamTemp.Add(_dconf_param_temp);
            }

            BackupAction action = new BackupAction(Messages.COPY_VM, BackupRestoreConfig.BackupActionKind.Replication, this._xenModelObject, this.repChoseVmPage.VmCheckedList, _dconf, listParamTemp, this.repChoseVmPage.vdi_expand_list);

            if (action != null)
            {
                ProgressBarStyle     progressBarStyle = ProgressBarStyle.Marquee;
                ActionProgressDialog dialog           = new ActionProgressDialog(action, progressBarStyle);
                dialog.ShowCancel = false;
                dialog.ShowDialog(this);
                if (!action.Succeeded || !string.IsNullOrEmpty(action.Result))
                {
                    base.FinishCanceled();
                    //Program.MainWindow.BringToFront();
                    //e.PageIndex = e.PageIndex - 1;
                }
                else
                {
                    base.FinishWizard();
                }

                if (!(this._xenModelObject is Host))
                {
                    // todo Program.MainWindow.SwitchToTab(MainWindow.Tab.BR);
                    if (this._xenModelObject is VM)
                    {
                        VM vm = this._xenModelObject as VM;
                        vm.NotifyPropertyChanged("other_config");
                    }
                }
            }
        }
コード例 #16
0
 public ActionLogItemViewModel(BackupAction backupAction)
 {
     _backupAction = backupAction;
     _backupAction.PropertyChanged += BackupActionPropertyChanged;
 }
コード例 #17
0
ファイル: Utils.cs プロジェクト: andy-reeves/BackupManager
 public static void LogWithPushover(string pushoverUserKey, string pushoverAppToken, string logFilePath, BackupAction backupAction, string text, params object[] args)
 {
     LogWithPushover(pushoverUserKey, pushoverAppToken, logFilePath, backupAction, PushoverPriority.Normal, text, args);
 }