public WorkFlowEvent CreateEvent()
        {
            WorkFlowEvent workFlowEvent = new WorkFlowEvent();

            workFlowEvent.Properties.Items.Add(new CustomProperty()
            {
                Name         = "Key",
                PropertyType = CustomPropertyType.ValueList,
                ValueList    = Enum.GetNames(typeof(Keys)).ToList()
            });
            workFlowEvent.Properties.Items.Add(new CustomProperty()
            {
                Name         = "Alt",
                PropertyType = CustomPropertyType.Bool
            });
            workFlowEvent.Properties.Items.Add(new CustomProperty()
            {
                Name         = "Ctrl",
                PropertyType = CustomPropertyType.Bool
            });
            workFlowEvent.Properties.Items.Add(new CustomProperty()
            {
                Name         = "Shift",
                PropertyType = CustomPropertyType.Bool
            });
            return(workFlowEvent);
        }
        public WorkFlowEvent CreateEvent()
        {
            WorkFlowEvent workFlowEvent = GetEvent();

            workFlowEvent.Properties.Items.Add(new CustomProperty()
            {
                Name         = "Event",
                PropertyType = CustomPropertyType.String
            });
            return(workFlowEvent);
        }
Example #3
0
        public WorkFlowEvent CreateEvent()
        {
            WorkFlowEvent workFlowEvent = GetEvent();

            workFlowEvent.Properties.Items.Add(new CustomProperty()
            {
                Name         = "Variable",
                PropertyType = CustomPropertyType.Variable,
            });
            return(workFlowEvent);
        }
 private void DeleteEvent(WorkFlowEvent flowEvent)
 {
     if (flowEvent != null)
     {
         CurrentWorkFlow.Events.Remove(flowEvent);
         if (CurrentWorkFlow.Events.Count > 0)
         {
             SelectedEvent = CurrentWorkFlow.Events[0];
         }
     }
 }
        public void RegisterEvent(WorkFlowEvent flowEvent)
        {
            _flowEvent = flowEvent;
            var contex = WorkflowManager.Instance.Context;

            if (CheckCondition(_flowEvent, contex))
            {
                WorkflowManager.ExecuteAsync(_flowEvent.CommandCollection, contex);
            }

            ServiceProvider.Instance.DeviceManager.CameraConnected += DeviceManager_CameraConnected;
        }
Example #6
0
        private void NewEvent(PluginInfo pluginInfo)
        {
            IEventPlugin  plugin = WorkflowManager.Instance.GetEventPlugin(pluginInfo.Class);
            WorkFlowEvent event_ = plugin.CreateEvent();

            event_.Parent     = CurrentWorkFlow;
            event_.Instance   = plugin;
            event_.PluginInfo = pluginInfo;
            event_.Name       = pluginInfo.Name;
            CurrentWorkFlow.Events.Add(event_);
            SelectedEvent = event_;
        }
Example #7
0
        public WorkFlowEvent GetEvent()
        {
            WorkFlowEvent workFlowEvent = new WorkFlowEvent();

            workFlowEvent.Properties.Items.Add(new CustomProperty()
            {
                Name         = "(Name)",
                PropertyType = CustomPropertyType.String
            });
            workFlowEvent.Properties.Items.Add(new CustomProperty()
            {
                Name         = "Condition",
                PropertyType = CustomPropertyType.Code
            });
            return(workFlowEvent);
        }
Example #8
0
        public bool CheckCondition(WorkFlowEvent _event, Context context)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(_event.Properties["Condition"].ToString(context)))
                {
                    return(true);
                }

                return(ScriptEngine.Instance.Evaluate(_event.Properties["Condition"].ToString(context), context));
            }
            catch (Exception e)
            {
                Log.Error("Event CheckCondition error " + _event.Name, e);
            }
            return(false);
        }
Example #9
0
        public bool CheckCondition(WorkFlowEvent _event, Context context)
        {
            if (string.IsNullOrWhiteSpace(_event.Properties["Condition"].ToString(context)))
            {
                return(true);
            }

            var var = new Engine();

            foreach (var variable in context.WorkFlow.Variables.Items)
            {
                var.SetValue(variable.Name, variable.GetAsObject());
            }
            try
            {
                return(var.Execute(_event.Properties["Condition"].ToString(context)).GetCompletionValue().AsBoolean());
            }
            catch (Exception e)
            {
                Log.Error("Evaluation error " + _event.Name, e);
            }
            return(false);
        }
        public WorkFlow Load(Stream myFileStream)
        {
            XmlSerializer mySerializer =
                new XmlSerializer(typeof(WorkFlow));
            WorkFlow flow = (WorkFlow)mySerializer.Deserialize(myFileStream);

            WorkFlow resflow = Instance.CreateWorkFlow();

            resflow.Id          = flow.Id;
            resflow.Name        = flow.Name;
            resflow.Description = flow.Description;
            resflow.Version     = flow.Version;
            resflow.Properties.CopyValuesFrom(flow.Properties);

            foreach (Variable variable in flow.Variables.Items)
            {
                if (resflow.Variables[variable.Name] != null)
                {
                    resflow.Variables[variable.Name].Value = variable.Value;
                }
                else
                {
                    resflow.Variables.Items.Add(variable);
                }
            }

            foreach (var flowEvent in flow.Events)
            {
                IEventPlugin plugin = Instance.GetEventPlugin(flowEvent.PluginInfo.Class);

                WorkFlowEvent event_ = plugin.CreateEvent();
                event_.Parent     = resflow;
                event_.Instance   = plugin;
                event_.PluginInfo = flowEvent.PluginInfo;
                event_.Name       = flowEvent.Name;
                event_.Properties.CopyValuesFrom(flowEvent.Properties);
                LoadPluginInfo(event_.PluginInfo);

                foreach (var flowCommand in flowEvent.CommandCollection.Items)
                {
                    IWorkflowCommand commandPlugin = Instance.GetCommandPlugin(flowCommand.PluginInfo.Class);
                    var wCommand = commandPlugin.CreateCommand();
                    wCommand.Instance   = commandPlugin;
                    wCommand.PluginInfo = flowCommand.PluginInfo;
                    wCommand.Name       = flowCommand.Name;
                    wCommand.Properties.CopyValuesFrom(flowCommand.Properties);
                    event_.CommandCollection.Items.Add(wCommand);
                    LoadPluginInfo(flowCommand.PluginInfo);
                }
                resflow.Events.Add(event_);
            }

            foreach (var _view in flow.Views)
            {
                IViewPlugin  plugin = Instance.GetViewPlugin(_view.PluginInfo.Class);
                WorkFlowView view   = plugin.CreateView();
                view.Parent     = resflow;
                view.Instance   = plugin;
                view.PluginInfo = _view.PluginInfo;
                view.Name       = _view.Name;
                view.Properties.CopyValuesFrom(_view.Properties);
                LoadPluginInfo(view.PluginInfo);
                foreach (var viewElement in _view.Elements)
                {
                    IViewElementPlugin  elementplugin = Instance.GetElementPlugin(viewElement.PluginInfo.Class);
                    WorkFlowViewElement element       = elementplugin.CreateElement(view);
                    element.Parent     = view;
                    element.Instance   = elementplugin;
                    element.PluginInfo = viewElement.PluginInfo;
                    element.Name       = viewElement.Name;
                    element.Properties.CopyValuesFrom(viewElement.Properties);
                    view.Elements.Add(element);
                    LoadPluginInfo(element.PluginInfo);
                    foreach (var commandCollection in element.Events)
                    {
                        CommandCollection loadedcommand = null;
                        foreach (var collection in viewElement.Events)
                        {
                            if (collection.Name == commandCollection.Name)
                            {
                                loadedcommand = collection;
                            }
                        }
                        if (loadedcommand != null)
                        {
                            foreach (var flowCommand in loadedcommand.Items)
                            {
                                IWorkflowCommand commandPlugin =
                                    Instance.GetCommandPlugin(flowCommand.PluginInfo.Class);
                                var wCommand = commandPlugin.CreateCommand();
                                wCommand.Instance   = commandPlugin;
                                wCommand.PluginInfo = flowCommand.PluginInfo;
                                wCommand.Name       = flowCommand.Name;
                                wCommand.Properties.CopyValuesFrom(flowCommand.Properties);
                                commandCollection.Items.Add(wCommand);
                                LoadPluginInfo(wCommand.PluginInfo);
                            }
                        }
                    }
                }
                foreach (var commandCollection in view.Events)
                {
                    CommandCollection loadedcommand = null;
                    foreach (var collection in _view.Events)
                    {
                        if (collection.Name == commandCollection.Name)
                        {
                            loadedcommand = collection;
                        }
                    }
                    if (loadedcommand != null)
                    {
                        foreach (var flowCommand in loadedcommand.Items)
                        {
                            IWorkflowCommand commandPlugin = Instance.GetCommandPlugin(flowCommand.PluginInfo.Class);
                            var wCommand = commandPlugin.CreateCommand();
                            wCommand.Instance   = commandPlugin;
                            wCommand.PluginInfo = flowCommand.PluginInfo;
                            wCommand.Name       = flowCommand.Name;
                            wCommand.Properties.CopyValuesFrom(flowCommand.Properties);
                            commandCollection.Items.Add(wCommand);
                            LoadPluginInfo(wCommand.PluginInfo);
                        }
                    }
                }
                resflow.Views.Add(view);
            }
            LoadVariables(resflow);
            return(resflow);
        }
 public void UnRegisterEvent(WorkFlowEvent flowEvent)
 {
     ServiceProvider.Instance.DeviceManager.CameraConnected -= DeviceManager_CameraConnected;
 }
 public void UnRegisterEvent(WorkFlowEvent flowEvent)
 {
     WorkflowManager.Instance.Message -= Instance_Message;
 }
 public void RegisterEvent(WorkFlowEvent flowEvent)
 {
     _flowEvent = flowEvent;
     WorkflowManager.Instance.Message += Instance_Message;
 }
        public WorkFlowEvent CreateEvent()
        {
            WorkFlowEvent workFlowEvent = GetEvent();

            return(workFlowEvent);
        }