public RestorePlanViewControl() { InitializeComponent(); AttachEventHandlers(); /* * EventDispatcher dispatcher = new EventDispatcher(); * * Watcher.Subscribe((RestoreUpdateMsg msg) => * { * if (this.Model == null) * return; * * Models.RestorePlan plan = this.Model as Models.RestorePlan; * * // Only process messages that are related to the plan associated with this control. * if (msg.PlanId != plan.Id.Value) * return; * * // IMPORTANT: Always invoke from Main thread! * dispatcher.Invoke(() => { ProcessRemoteMessage(msg); }); * }); */ this.ModelChangedEvent += (sender, args) => { if (Model == null) { return; } Models.RestorePlan plan = Model as Models.RestorePlan; if (CurrentOperation != null) { CurrentOperation.Dispose(); } CurrentOperation = new RemoteOperation(DurationTimer_Tick); CurrentOperation.Status = Commands.OperationStatus.NOT_RUNNING; CurrentOperation.LastRunAt = plan.LastRunAt; CurrentOperation.LastSuccessfulRunAt = plan.LastSuccessfulRunAt; this.lblSources.Text = plan.SelectedSourcesAsDelimitedString(", ", 50, "..."); // Duplicate from RestoreOperation.cs - Sources property this.llblRunNow.Text = LBL_RUNNOW_STOPPED; this.llblRunNow.Enabled = false; this.lblStatus.Text = "Querying status...";; this.lblDuration.Text = "Unknown";; this.lblFilesTransferred.Text = "Unknown";; this.llblEditPlan.Enabled = false; this.llblDeletePlan.Enabled = false; this.lblLastRun.Text = PlanCommon.Format(CurrentOperation.LastRunAt); this.lblLastSuccessfulRun.Text = PlanCommon.Format(CurrentOperation.LastSuccessfulRunAt); this.lblTitle.Text = PlanCommon.FormatTitle(plan.Name); this.lblSchedule.Text = plan.ScheduleType.ToString(); CurrentOperation.RequestedInitialInfo = true; Provider.Handler.Send(Commands.ServerQueryPlan("restore", plan.Id.Value)); }; }
private static void Fetch(string remote) { IDataProvider remoteDataProvider = new LocalDataProvider(new PhysicalFileOperator(new FileSystem()), remote); ICommitOperation remoteCommitOperation = new CommitOperation(remoteDataProvider, new TreeOperation(remoteDataProvider)); IRemoteOperation remoteOperation = new RemoteOperation( DataProvider, CommitOperation, remoteDataProvider, remoteCommitOperation); remoteOperation.Fetch(); }
private static void Push(string remote, string branch) { IDataProvider remoteDataProvider = new LocalDataProvider(new PhysicalFileOperator(new FileSystem()), remote); ICommitOperation remoteCommitOperation = new CommitOperation(remoteDataProvider, new TreeOperation(remoteDataProvider)); IRemoteOperation remoteOperation = new RemoteOperation( DataProvider, CommitOperation, remoteDataProvider, remoteCommitOperation); string refName = Path.Join("refs", "heads", branch); remoteOperation.Push(refName); }
//private void eventLog1_EntryWritten(object sender, System.Diagnostics.EntryWrittenEventArgs e) //{ // string message = string.Format("{0:o} {1} {2}", // e.Entry.TimeWritten, e.Entry.EntryType.ToString().ToUpper(), // e.Entry.Message); // listBox1.Items.Add(message); // // Auto-scroll // listBox1.TopIndex = listBox1.Items.Count - 1; //} #region Dispose Pattern Implementation /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); DetachEventHandlers(); if (CurrentOperation != null) { CurrentOperation.Dispose(); CurrentOperation = null; } } base.Dispose(disposing); }
/// <summary> /// Signals the start of a long-running operation. /// </summary> /// <param name="operation">The <b>neon-cli</b> operation information.</param> public void OnRemoteStartOperation(RemoteOperation operation) { InvokeOnUIThread( () => { if (operationInProgress) { // Another operation is already in progress. If the current // operation was initiated by the same [neon-cli] process then // we'll just substitute the new operation info otherwise // we'll start a new operation. // // If the current operation was initiated by the Desktop app // then we'll ignore the new operation. if (remoteOperation != null && remoteOperation.ProcessId == operation.ProcessId) { remoteOperation = operation; PostUpdateUIState(); } else { remoteOperation = operation; //StartOperation(workingAnimation); // $todo(jeff.lill): Notification status is a bit of a mess. } SetBalloonText(operation.Summary); } else { // Remove any transient notification. if (notifyStack.Count > 0 && notifyStack.Peek().IsTransient) { //StopNotifyAnimation(); } remoteOperation = operation; //StartOperation(workingAnimation); PostUpdateUIState(); } }); }
private void EnforceConsistencyDelay(RemoteOperation lastop) { if (m_lastOperation == RemoteOperation.First) { m_lastOperation = lastop; } if (lastop == m_lastOperation) { return; } m_lastOperation = lastop; var wait = m_waitUntil - DateTime.Now; if (wait.Ticks > 0) { System.Threading.Thread.Sleep(wait); } }
/// <summary> /// Signals the end of a long-running operation. /// </summary> /// <param name="operation">The <b>neon-cli</b> operation information.</param> public void OnEndOperation(RemoteOperation operation) { InvokeOnUIThread( () => { if (operationInProgress) { remoteOperation = null; StopOperation(); if (!string.IsNullOrEmpty(operation.CompletedToast)) { ShowToast(operation.CompletedToast); } if (operation.Failed) { StartNotifyAnimation(errorAnimation, operation.CompletedToast, isError: true); } } }); }