예제 #1
0
        private static void OnWorkflowCreated(object source, FileSystemEventArgs e)
        {
            try
            {
                if (WexflowEngine.IsFileLocked(e.FullPath))
                {
                    Logger.Info($"File lock detected on file {e.FullPath}");

                    while (WexflowEngine.IsFileLocked(e.FullPath))
                    {
                        Thread.Sleep(1000);
                    }
                }
                if (!WexflowEngine.IsDirectory(e.FullPath))
                {
                    Logger.Info("Workflow.FileSystemWatcher.OnCreated");

                    var admin = WexflowEngine.GetUser(superAdminUsername);
                    WexflowEngine.SaveWorkflowFromFile(admin.GetDbId(), Core.Db.UserProfile.SuperAdministrator, e.FullPath, true);
                }
            }
            catch (Exception ex)
            {
                Logger.ErrorFormat("Error while creating the workflow {0}", ex, e.FullPath);
            }
        }
예제 #2
0
 private static void OnCreated(object source, FileSystemEventArgs e)
 {
     Logger.Info("FileSystemWatcher.OnCreated");
     try
     {
         var admin = WexflowEngine.GetUser(superAdminUsername);
         WexflowEngine.SaveWorkflowFromFile(admin.GetId(), Core.Db.UserProfile.SuperAdministrator, e.FullPath, true);
     }
     catch (Exception ex)
     {
         Logger.ErrorFormat("Error while creating the workflow {0}", ex, e.FullPath);
     }
 }
예제 #3
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;
                }
            }
        }