Esempio n. 1
0
        private void NewView(PluginInfo pluginInfo)
        {
            IViewPlugin  plugin = WorkflowManager.Instance.GetViewPlugin(pluginInfo.Class);
            WorkFlowView view   = plugin.CreateView();

            view.Instance   = plugin;
            view.PluginInfo = pluginInfo;
            view.Name       = pluginInfo.Name;
            view.Parent     = CurrentWorkFlow;
            CurrentWorkFlow.Views.Add(view);
            SelectedView = view;
        }
        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);
        }