private void CoreEventHub_ProcessingProgress(object sender, ProcessingEventArgs ev)
 {
     Task.Run(() => {
         Dispatcher.Invoke(() => {
             if (_notification != null)
             {
                 _notification.Message = ev.StateMessage;
             }
         });
     });
 }
예제 #2
0
 private static async void OnProcessing(object sender, ProcessingEventArgs e)
 {
     try
     {
         if (_debug)
         {
             await _log.WriteLineAsync($"Processing started.");
         }
     }
     catch (Exception)
     {
     }
 }
예제 #3
0
        /// <summary>
        /// Handels the processing events.
        /// </summary>
        /// <param name="s">
        /// The sender of this event.
        /// </param>
        /// <param name="e">
        /// The <see cref="ProcessingEventArgs"/> of this event.
        /// </param>
        /// <exception cref="ProcessAbortException">
        /// if the property <see cref="Cancel"/> is true
        /// </exception>
        private void HandleProcessingEvent(object s, ProcessingEventArgs e)
        {
            if (this.Cancel)
            {
                this.ProcessingEvent(this, new ProcessingEventArgs("Process aborted"));
                this.Cancel = false;
                throw new ProcessAbortException();
            }

            if (this.ProcessingEvent != null)
            {
                this.ProcessingEvent(s, e);
            }
        }
예제 #4
0
        /// <summary>
        /// Handels the processing events
        /// </summary>
        /// <param name="entity"> The entity that is being processed at the moment (may be null). </param>
        /// <param name="eventArgs"> The event arguments with some additional information. </param>
        private void ProcessingEventHandler(object entity, ProcessingEventArgs eventArgs)
        {
            this.Invoke(
                new MethodInvoker(
                    () =>
            {
                var currentObject  = entity ?? eventArgs.Item;
                var currentContact = entity as StdContact ?? eventArgs.Item as StdContact;
                var message        = eventArgs.Message + " " +
                                     (currentObject == null || currentObject.GetType() == typeof(SyncEngine) ||
                                      currentObject as StdClient != null
                                               ? string.Empty
                                               : currentObject.ToString());

                this.lblProgressStatus.Text = message;
                this.LogList.Items.Add(message);
                this.LogList.TopIndex = this.LogList.Items.Count > 10 ? this.LogList.Items.Count - 10 : 0;
                this.lblProgressStatus.Refresh();
                if (currentContact != null)
                {
                    // update image, if there is one and image display is switched on.
                    if (this.chkShowImage.Checked && currentContact.PictureData != null &&
                        currentContact.PictureData.Length > 10)
                    {
                        using (var imageStream = new MemoryStream(currentContact.PictureData))
                        {
                            try
                            {
                                this.currentPersonImage.Image = new Bitmap(imageStream);
                            }
                            catch (ArgumentException)
                            {
                            }
                        }

                        this.currentPersonImage.Visible = true;
                        this.currentPersonImage.Refresh();

                        // !!! HERE WE EXIT THE METHOD !!!
                        return;
                    }
                }

                // hide the image if we need to.
                if (this.currentPersonImage.Visible)
                {
                    this.currentPersonImage.Visible = false;
                }
            }));
        }
예제 #5
0
        /// <summary>
        /// Event handler for the log event
        /// </summary>
        /// <param name="sender">
        /// the instance that requests a logging action
        /// </param>
        /// <param name="args">
        /// the event arguments containing the information to be logged
        /// </param>
        private void LogMessage(object sender, ProcessingEventArgs args)
        {
            var logEntry = new StringBuilder();

            var client = sender as IClientBase;

            if (client != null)
            {
                logEntry.Append(client.FriendlyClientName);
                logEntry.Append(": ");
            }

            logEntry.Append(args.Message);
            if (args.Item != null)
            {
                logEntry.Append(" (");
                logEntry.Append(args.Item.ToString());
                logEntry.Append(")");
            }

            this.StatusLabel.Text = args.Message;
            this.LogList.Items.Add(logEntry.ToString());
            this.LogList.TopIndex = this.LogList.Items.Count - 1;
        }
예제 #6
0
 /// <summary>
 /// handels logging events
 /// </summary>
 /// <param name="sender">
 /// The sender of this event.
 /// </param>
 /// <param name="e">
 /// The <see cref="ProcessingEventArgs"/> containing event information about the current processing step.
 /// </param>
 private void LogThis(object sender, ProcessingEventArgs e)
 {
     this.listLog.Items.Add(e.Message + ((StdContact)e.Item).NewIfNull().GetFullName());
     this.listLog.TopIndex = this.listLog.Items.Count - 1;
 }
예제 #7
0
 /// <summary>
 /// logs an event by specifying the current element that is related to the event and a message about the current event
 ///   use this overload to prevent preformatting the parameters for the message.
 /// </summary>
 /// <param name="sender"> The sender of the event. </param>
 /// <param name="args"> The processing arguments. </param>
 protected void LogProcessingEvent(object sender, ProcessingEventArgs args)
 {
     this.LogProcessingEvent((StdElement)args.Item, args.Message);
 }
예제 #8
0
 /// <summary>
 /// Logs the processing event
 /// </summary>
 /// <param name="sender">
 /// The sender of the event.
 /// </param>
 /// <param name="e">
 /// The processing event arguments that do include the message to be logged.
 /// </param>
 private static void ProcessingEvent(object sender, ProcessingEventArgs e)
 {
     Console.WriteLine(e.Message + (e.Item == null ? string.Empty : " " + e.Item));
 }
예제 #9
0
 public static void OnProcessingProgress(object sender, ProcessingEventArgs e)
 {
     ProcessingProgress?.Invoke(sender, e);
 }
예제 #10
0
 protected void OnProcessingProgress(ProcessingEventArgs e) =>
 CoreEventHub.OnProcessingProgress(this, e);
예제 #11
0
 protected void OnProcessingStart(ProcessingEventArgs e) =>
 CoreEventHub.OnProcessingStart(this, e);