Example #1
0
        //Event handler for path subjects notifications
        public void Update(Guid id, string path, ChangeType.Type changeType, params object[] list)
        {
            try
            {
                //Delay execution to prevent "File in use..." error
                Thread.Sleep(delay);
                switch (changeType)
                {
                case ChangeType.Type.Changed:
                {
                    manager.ProcessChanged(id, path);
                    break;
                }

                case ChangeType.Type.Created:
                {
                    manager.ProcessCreated(id, path);
                    break;
                }

                case ChangeType.Type.Deleted:
                {
                    manager.ProcessDeleted(id, path);
                    break;
                }

                case ChangeType.Type.Renamed:
                {
                    manager.ProcessRenamed(id, path, list[0].ToString());
                    break;
                }

                case ChangeType.Type.Error:
                {
                    var msg = "The file backup has failed for path: " + path;
                    logger.Log(System.Diagnostics.EventLogEntryType.Error, msg, (Exception)list[0]);
                    break;
                }

                case ChangeType.Type.Disposed:
                {
                    var msg = "The file backup binding was disposed for path: " + path;
                    logger.Log(System.Diagnostics.EventLogEntryType.Warning, msg);

                    break;
                }
                }
            }
            catch (Exception ex)
            {
                var msg = "The file backup has failed for path: " + path;
                logger.Log(System.Diagnostics.EventLogEntryType.Error, msg, ex);
            }
        }
Example #2
0
 //Notify observer on event
 private void Notify(string path, ChangeType.Type eventType, params object[] list)
 {
     observer.Update(id: id, path: path, changeType: eventType, list: list);
 }