async private void Notifier_OnJobStatusChanged(object sender, ClusterEventArgs <JobStatusChanged> e) { await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { var content = e.Content; JobViewModel vm = null; if ((vm = Undone.FirstOrDefault(x => x.Index == content.Index)) != null) { if (content.Status == JobStatus.Done || content.Status == JobStatus.Error) { Undone.Remove(vm); Done.Add(vm); } vm.Status = content.Status; } else if ((vm = Done.FirstOrDefault(x => x.Index == content.Index)) != null) { if (content.Status == JobStatus.Waiting || content.Status == JobStatus.Running) { Done.Remove(vm); Undone.Add(vm); } vm.Status = content.Status; } }); }
async void Notifier_OnJobStatusChanged(object sender, ClusterEventArgs <JobStatusChanged> e) { await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { string m = null; switch (e.Content.Status) { case JobStatus.Done: m = String.Format("Задача {0} выполнена", e.Content.Index); break; case JobStatus.Error: m = String.Format("Выполнение задачи {0} прервано возникновением ошибки", e.Content.Index); break; case JobStatus.Waiting: m = String.Format("Задача {0} ожидает начала выполнения", e.Content.Index); break; case JobStatus.Running: m = String.Format("Задача {0} выполняется", e.Content.Index); break; } if (m != null) { Messages.Add( new LogMessageViewModel(m, e.Time) ); } }); }
async void Notifier_OnLogMessage(object sender, ClusterEventArgs <LogMessage> e) { await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Messages.Add(new LogMessageViewModel(e.Content.Body, e.Time)); }); }
async void Notifier_OnClusterFinalized(object sender, ClusterEventArgs <ClusterFinalized> e) { await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Nodes.Clear(); }); }
async void Notifier_OnProcessingStarted(object sender, ClusterEventArgs <ProcessingStarted> e) { await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Messages.Add( new LogMessageViewModel("Старт обработки задач", e.Time) ); }); }
async void Notifier_OnProcessingDone(object sender, ClusterEventArgs <ProcessingDone> e) { await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Messages.Add(new LogMessageViewModel( "Обработка задач завершена", e.Time )); }); }
async void Notifier_OnClusterCreated(object sender, ClusterEventArgs <ClusterCreated> e) { await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { for (int i = 0; i < e.Content.Size; i++) { Nodes.Add(new NodeStateViewModel(dispatcher, notifier, i)); } }); }
async void Notifier_OnProcessingDone(object sender, ClusterEventArgs <ProcessingDone> e) { await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { foreach (var n in Nodes) { n.Done.Clear(); n.Undone.Clear(); } }); }
async void Notifier_OnProcessingStarted(object sender, ClusterEventArgs <ProcessingStarted> e) { await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { var nodeLoad = new int[Nodes.Count]; foreach (var j in e.Content.Info) { nodeLoad[j.Node] += j.Weight; } var maxLoad = nodeLoad.Max(); foreach (var j in e.Content.Info) { Nodes[j.Node].Undone.Add(new JobViewModel(j.Index, j.Weight, maxLoad)); } }); }
async void ClusterInfoPage_OnTerminated(object sender, ClusterEventArgs <Terminated> e) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { if (e.Content.Succeed == true) { await new MessageDialog("Выполнение завершено") .ShowAsync(); Frame.GoBack(); } else { await new MessageDialog("Выполнение завершено c ошибкой\n" + e.Content.Message, "Ошибка") .ShowAsync(); Frame.GoBack(); } }); }
protected virtual void OnClusterInfoReload(ClusterEventArgs args) { ClusterInfoReload?.Invoke(this, args); }
protected virtual void OnNewNodeDiscovered(ClusterEventArgs args) { NewNodeDiscovered?.Invoke(this, args); }
protected virtual void OnHitMaxRetriesLocatingMovedSlot(ClusterEventArgs args) { HitMaxRetriesLocatingMovedSlot?.Invoke(this, args); }
protected virtual void OnHashSlotMoved(ClusterEventArgs args) { HashSlotMoved?.Invoke(this, args); }