Beispiel #1
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);
            }
        }
Beispiel #2
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");
                }
            }
        }
Beispiel #3
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}'");
        }