Exemplo n.º 1
0
        private void LoadPlugins()
        {
            RetrievePluginTypes retrievePluginTypes = new RetrievePluginTypes();
            WorkAsync(new WorkAsyncInfo
            {
                Message = "Loading the plugins",
                Work = (worker, args) =>
                {
                    SetLoading(true);
                    EntityCollection pluginAssemblies = retrievePluginTypes.GetPluginAssemblies(Service);
                    args.Result = pluginAssemblies;


                },
                PostWorkCallBack = (args) =>
                {
                    if (args.Error != null)
                    {
                        MessageBox.Show(args.Error.ToString(), "Error",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        var result = args.Result as EntityCollection;
                        PopulateData(result, retrievePluginTypes);
                        if (result.Entities.Count == 0)
                        {
                            MessageBox.Show("No plugins available to show");
                        }
                        SetLoading(false);
                    }
                }
            });
        }
Exemplo n.º 2
0
 private void PopulateData(EntityCollection pluginAssemblies, RetrievePluginTypes retrievePluginTypes)
 {
     treeView1.Nodes.Clear();
     foreach (Entity assembly in pluginAssemblies.Entities)
     {
         TreeNode treeNode = new TreeNode(assembly["name"].ToString());
         treeView1.Nodes.Add(treeNode);
         EntityCollection pluginTypesColl = retrievePluginTypes.GetPluginTypes(assembly.Id, Service);
         foreach (Entity pluginTypeEntity in pluginTypesColl.Entities)
         {
             TreeNode pluginTypeNode = new TreeNode(pluginTypeEntity["name"].ToString());
             treeNode.Nodes.Add(pluginTypeNode);
             EntityCollection pluginStepsColl = retrievePluginTypes.GetSdkProcessingStep(pluginTypeEntity.Id, Service);
             foreach (Entity pluginStep in pluginStepsColl.Entities)
             {
                 TreeNode pluginstepNode = new TreeNode(pluginStep["name"].ToString());
                 pluginTypeNode.Nodes.Add(pluginstepNode);
                 EntityCollection stepImageColl = retrievePluginTypes.GetSdkProcessingStepImage(pluginStep.Id, Service);
                 foreach (Entity stepImage in stepImageColl.Entities)
                 {
                     string imageAttributes = "(All)";
                     if (stepImage.Attributes.Contains("attributes"))
                     {
                         imageAttributes = "(" + stepImage["attributes"] + ")";
                     }
                     TreeNode pluginstepImageNode = new TreeNode(stepImage["name"].ToString() + " " + imageAttributes);
                     pluginstepNode.Nodes.Add(pluginstepImageNode);
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
        private void GenerateRegistrationFile()
        {
            XmlDocument xmlDoc = new XmlDocument();
            WorkAsync(new WorkAsyncInfo
            {
                Message = "Generating the registration xml file",
                Work = (worker, args) =>
                {
                    args.Result = "";
                    RetrievePluginTypes retrievePluginTypes = new RetrievePluginTypes();
                    EntityCollection pluginAssemblies = retrievePluginTypes.GetPluginAssemblies(Service);
                    XmlNode rootNode = xmlDoc.CreateElement("Register");
                    xmlDoc.AppendChild(rootNode);
                    XmlNode solutions = xmlDoc.CreateElement("Solutions");
                    rootNode.AppendChild(solutions);
                    foreach (Entity pluginAssembly in pluginAssemblies.Entities)
                    {
                        XmlNode solution = xmlDoc.CreateElement("Solution");
                        solutions.AppendChild(solution);
                        XmlAttribute assembly = xmlDoc.CreateAttribute("Assembly");
                        assembly.Value = pluginAssembly["name"].ToString() + ".dll";
                        solution.Attributes.Append(assembly);
                        XmlAttribute Id = xmlDoc.CreateAttribute("Id");
                        Id.Value = pluginAssembly.Id.ToString();
                        solution.Attributes.Append(Id);
                        XmlAttribute IsolationMode = xmlDoc.CreateAttribute("IsolationMode");
                        IsolationMode.Value = ((OptionSetValue)pluginAssembly["isolationmode"]).Value.ToString();
                        solution.Attributes.Append(IsolationMode);
                        XmlAttribute SourceType = xmlDoc.CreateAttribute("SourceType");
                        SourceType.Value = ((OptionSetValue)pluginAssembly["sourcetype"]).Value.ToString();
                        solution.Attributes.Append(SourceType);

                        //Plugin-Types
                        EntityCollection pluginTypesorWorkflowColl = retrievePluginTypes.GetPluginTypes(pluginAssembly.Id, Service);
                        List<Entity> pluginTypesColl = pluginTypesorWorkflowColl.Entities.Where(x => Convert.ToBoolean(x.Attributes["isworkflowactivity"]) == false).ToList();
                        List<Entity> workflowTypesColl = pluginTypesorWorkflowColl.Entities.Where(x => Convert.ToBoolean(x.Attributes["isworkflowactivity"]) == true).ToList();
                        GenerateRegistrationFile generateRegistrationFile = new GenerateRegistrationFile();
                        generateRegistrationFile.GeneratePluginOrWorkflowTypes(false, pluginTypesColl, ref solution, ref xmlDoc, Service);
                        generateRegistrationFile.GeneratePluginOrWorkflowTypes(true, workflowTypesColl, ref solution, ref xmlDoc, Service);
                        args.Result = "success";
                    }
                },
                PostWorkCallBack = (args) =>
                {
                    if (args.Error != null)
                    {
                        MessageBox.Show(args.Error.ToString(), "Error",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        using (var fbd = new FolderBrowserDialog())
                        {
                            DialogResult result = fbd.ShowDialog();
                            if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
                            {
                                xmlDoc.Save(fbd.SelectedPath + "\\RegisterFile.xml");
                                MessageBox.Show("File generated successfully!");
                            }
                        }
                    }

                }
            });




        }