Beispiel #1
0
        private static void OnChanged(object source, PollingFileSystemEventArgs e)
        {
            foreach (var change in e.Changes)
            {
                var path = Path.Combine(change.Directory, change.Name);
                switch (change.ChangeType)
                {
                case WatcherChangeTypes.Created:
                    Logger.Info("PollingFileSystemWatcher.OnCreated");
                    try
                    {
                        var admin = WexflowEngine.GetUser(superAdminUsername);
                        WexflowEngine.SaveWorkflowFromFile(admin.GetId(), Core.Db.UserProfile.SuperAdministrator, path, true);
                    }
                    catch (Exception ex)
                    {
                        Logger.ErrorFormat("Error while creating the workflow {0}", ex, path);
                    }
                    break;

                case WatcherChangeTypes.Changed:
                    Logger.Info("PollingFileSystemWatcher.OnChanged");
                    try
                    {
                        var admin = WexflowEngine.GetUser(superAdminUsername);
                        WexflowEngine.SaveWorkflowFromFile(admin.GetId(), Core.Db.UserProfile.SuperAdministrator, path, true);
                    }
                    catch (Exception ex)
                    {
                        Logger.ErrorFormat("Error while updating the workflow {0}", ex, path);
                    }
                    break;

                case WatcherChangeTypes.Deleted:
                    Logger.Info("PollingFileSystemWatcher.OnDeleted");
                    try
                    {
                        var removedWorkflow = WexflowEngine.Workflows.SingleOrDefault(wf => wf.FilePath == path);
                        if (removedWorkflow != null)
                        {
                            WexflowEngine.DeleteWorkflow(removedWorkflow.DbId);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.ErrorFormat("Error while deleting the workflow {0}", ex, path);
                    }
                    break;
                }
            }
        }
Beispiel #2
0
 private static void OnDeleted(object source, FileSystemEventArgs e)
 {
     Logger.Info("FileSystemWatcher.OnDeleted");
     try
     {
         var removedWorkflow = WexflowEngine.Workflows.SingleOrDefault(wf => wf.FilePath == e.FullPath);
         if (removedWorkflow != null)
         {
             WexflowEngine.DeleteWorkflow(removedWorkflow.DbId);
         }
     }
     catch (Exception ex)
     {
         Logger.ErrorFormat("Error while deleting the workflow {0}", ex, e.FullPath);
     }
 }