Example #1
0
            private static void CreateActivity(object source, ActivityType type, string path1, string path2)
            {
                try
                {
                    // find relevant folder
                    FoldersRow folder = Context.Model.FindFolder(source as FileSystemWatcher);
                    if (folder == null)
                    {
                        throw new Exception("Expected folder not found for activity: " + path1);
                    }

                    // test folder ignore filter
                    MatchReason reason = new MatchReason();
                    bool        passed = folder.PassesFilters(path1, reason);
                    if (type == Model.ActivityType.Renamed)
                    {
                        // when renaming be more tolerant and see also final names
                        passed = passed || folder.PassesFilters(path2, reason);
                    }

                    // create and register activity
                    Activity activity = new Activity(type, DateTime.Now, path1, path2, passed, reason.text);
                    folder.AddActivity(activity);

                    // signal worker to process new activity
                    Worker.Current.Signal();
                }
                catch (Exception e)
                {
                    // add error into log
                    ActivityLog.Current.AddEventLog(Properties.Resources.Error, e.Message);
                }
            }