Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //loads the demo plugin library
            using (AssemblyPlugin plugin = new AssemblyPlugin("../../../Plugin/bin/debug/Plugin.dll"))
            {
                Console.Write("Searching for types... ");

                //gets an array of types deriving from PluginBaseClass
                PluginTypeIdentifier[] types = plugin.GetTypes<PluginBaseClass>();

                Console.WriteLine(string.Format("{0} found", types.Length));
                Console.WriteLine();

                //print all types out
                foreach (PluginTypeIdentifier id in types)
                {
                    Console.WriteLine(string.Format("Name: {0}", id.Name));
                    Console.WriteLine(string.Format("Full name: {0}", id.FullName));
                    Console.WriteLine(string.Format("Display name: {0}", id.DisplayName));
                    Console.WriteLine(string.Format("Description: {0}", id.Description));
                    Console.WriteLine();
                }

                Console.WriteLine("Testing first plugin with string arguments...");

                //creates instance of Plugin.StringConcat converted to base-type:
                PluginBaseClass instance = plugin.CreateInstance<PluginBaseClass>(types[0].FullName);
                //calls the StringConcat.Process method which concatenates the strings:
                Console.WriteLine(string.Format("Result: {0}", instance.Process("Hello", " ", "World", "!")));
            }

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        private void GenerateSolutionName(string filePath)
        {
            AssemblyPlugin = Assembly.LoadFrom(filePath);
            SolutionName   = solutionPreFix + AssemblyPlugin.GetName().Name.Replace(".", "").Replace("_", "").Replace("-", "");

            if (SolutionName.Length > 50)
            {
                SolutionName = SolutionName.Substring(0, 50);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates destination system according to arguments
        /// Could delete plugins / steps / images
        /// </summary>
        /// <param name="parsedArgs"></param>
        /// <param name="destPluginAssembly"></param>
        public void UpdateSystem(CmdArgs parsedArgs, PluginAssembly destPluginAssembly)
        {
            if (!parsedArgs.Sync)
            {
                try
                {
                    // Update Assembly
                    destPluginAssembly = UploadPluginAssemblyToDestination(destPluginAssembly);
                    // Create NEW PluginTypes/Workflows
                    CreateNewPluginTypesInDestination(destPluginAssembly);
                }
                catch (Exception exception)
                {
                    logger.Error("Exception on Update of Assembly occured:\n", exception);
                    logger.Error(
                        "Your Assembly differs from Assembly on Destination-System: PluginTypes or Steps do not fit. Please contact colleagues or try Sync Option");
                }
            }
            else
            {
                if (parsedArgs.SourceSystem == null)
                {
                    // Deletion of old PluginSteps and PluginTypes
                    DeleteOldPluginTypeStepsOfAssembly(destPluginAssembly);
                    // Assembly Update
                    destPluginAssembly = UploadPluginAssemblyToDestination(destPluginAssembly);
                    // Create NEW PluginTypes/Workflows
                    CreateNewPluginTypesInDestination(destPluginAssembly);
                }
                else
                {
                    var sourcePluginAssembly = RetrievePluginAssembly(sourceSystem, AssemblyPlugin.GetName().Name);

                    logger.Log($"SourceSystem is \'{parsedArgs.SourceSystem}\'");
                    // Delete all Steps in Destination
                    DeleteOldPluginTypeStepsOfAssembly(destPluginAssembly);
                    // Assembly Update or Create
                    destPluginAssembly = UploadPluginAssemblyToDestination(destPluginAssembly);
                    // Create NEW PluginTypes/Workflows
                    CreateNewPluginTypesInDestination(destPluginAssembly);
                    // Sync Steps from Source to Destination
                    SyncPluginStepsViaSolution(sourcePluginAssembly, destPluginAssembly, parsedArgs.Publisher);

                    logger.Log("Successfully imported solution");
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create plugins / steps / images of an assembly from scratch
        /// Based on VS project
        /// </summary>
        /// <param name="parsedArgs"></param>
        /// <param name="destPluginAssembly"></param>
        public void CreateFromScratch(CmdArgs parsedArgs, PluginAssembly destPluginAssembly)
        {
            var uow = new CrmUnitOfWork(destinationSystem);

            // Delete destination assembly
            DeleteAllPluginTypeStepsOfAssembly(destPluginAssembly);

            // Create / Update assembly
            destPluginAssembly = UploadPluginAssemblyToDestination(destPluginAssembly);

            // Create NEW PluginTypes/Workflows
            CreateNewPluginTypesInDestination(destPluginAssembly);

            // Create Steps
            var file         = new FileInfo(parsedArgs.AssemblyPath);
            var assemblyName = file.Name.Substring(0, file.Name.Length - 4);

            var plugin = (from pl in uow.PluginAssemblies.GetQuery()
                          where pl.Name == assemblyName
                          select pl).SingleOrDefault();

            var steps = (from st in uow.SdkMessageProcessingSteps.GetQuery()
                         join pt in uow.PluginTypes.GetQuery() on st.EventHandler.Id equals pt.PluginTypeId
                         where pt.PluginAssemblyId.Id == plugin.PluginAssemblyId
                         select st).ToArray().ToDictionary(s => s.UniqueName);

            var stepsToCreate = CreateStepsModel(assemblyName);

            CreateSteps(uow, plugin, steps, stepsToCreate);

            // Create Images
            var allImages = (from im in uow.SdkMessageProcessingStepImages.GetQuery()
                             join st in uow.SdkMessageProcessingSteps.GetQuery() on im.SdkMessageProcessingStepId.Id equals st.SdkMessageProcessingStepId
                             join pl in uow.PluginTypes.GetQuery() on st.EventHandler.Id equals pl.PluginTypeId
                             where pl.PluginAssemblyId.Id == plugin.PluginAssemblyId
                             select im).ToList();

            CreateImages(uow, stepsToCreate, allImages, steps);

            logger.Log(
                $"Successfully created steps and images of Plugin '{AssemblyPlugin.GetName().Name}'");
        }
Ejemplo n.º 5
0
 public void removeAssemblyPlugin(AssemblyPlugin assembly)
 {
     PluginManager.assemblyPlugins.Remove(assembly);
 }
Ejemplo n.º 6
0
 public void addAssemblyPlugin(AssemblyPlugin assembly)
 {
     PluginManager.assemblyPlugins.Add(assembly);
 }