private Entities.SdkMessageProcessingStep Create(Models.Plugin plugin, Models.Step step, string name) { var next = new Entities.SdkMessageProcessingStep { SdkMessageProcessingStepId = Guid.NewGuid(), Name = name, Mode = step.IsAsync ? new Microsoft.Xrm.Sdk.OptionSetValue(1) : new Microsoft.Xrm.Sdk.OptionSetValue(0), Rank = step.ExecutionOrder <= 0 ? 1 : step.ExecutionOrder, Stage = new Microsoft.Xrm.Sdk.OptionSetValue(step.Stage), SupportedDeployment = new Microsoft.Xrm.Sdk.OptionSetValue(0), EventHandler = new Microsoft.Xrm.Sdk.EntityReference(Entities.PluginType.EntityLogicalName, plugin.CurrentCrmInstance.PluginTypeId.Value), SdkMessageId = this.GetSdkMessage(step.Message).ToEntityReference(), SdkMessageFilterId = this.GetFilterFor(this.GetSdkMessage(step.Message), step.PrimaryEntityLogicalName) }; if (next.Mode.Value == 1) { next.AsyncAutoDelete = true; } if (step.FilteringAttributes != null && step.FilteringAttributes.Length > 0) { next.FilteringAttributes = string.Join(",", step.FilteringAttributes); } uow.Create(next); this.messageService.Inform($"Created step: {next.Name}"); if (step.PreImage != null) { CreateImage(next, 1, step.Stage, step.IsAsync, step.Message, step.PreImage); } if (step.PostImage != null) { CreateImage(next, 2, step.Stage, step.IsAsync, step.Message, step.PostImage); } return(next); }
public PluginAssembly FindOrCreate(string assemblyfilename) { this.code = System.IO.File.ReadAllBytes(assemblyfilename); this.Assembly = System.Reflection.Assembly.Load(code); var publickeytoken = this.GetPublicKeyTokenFromAssembly(); var name = assemblyfilename.Split(new char[] { '\\', '/' }).Last(); if (name.ToUpper().EndsWith(".DLL")) { name = name.Substring(0, name.Length - 4); } var r = (from p in uow.PluginAssemblies.GetQuery() where p.Name == name select p).SingleOrDefault(); if (r != null) { this.pluginAssembly = r; this.isNew = false; return(r); } r = new PluginAssembly { PluginAssemblyId = Guid.NewGuid(), Content = System.Convert.ToBase64String(code), Description = name, IsolationMode = new Microsoft.Xrm.Sdk.OptionSetValue(2), Name = name, SourceType = new Microsoft.Xrm.Sdk.OptionSetValue(0), Culture = "neutral", PublicKeyToken = publickeytoken, Version = "1.0" }; uow.Create(r); this.messageService.Inform("Assembly code was created"); this.pluginAssembly = r; this.isNew = true; return(r); }
public void CreateAnJoinMissing(Guid pluginassemblyId, Models.Plugin[] tobees) { foreach (var tobee in tobees) { if (tobee.CurrentCrmInstance == null) { var next = new Entities.PluginType { PluginTypeId = Guid.NewGuid(), PluginAssemblyId = new Microsoft.Xrm.Sdk.EntityReference(Entities.PluginAssembly.EntityLogicalName, pluginassemblyId), FriendlyName = tobee.Type.FullName, Name = tobee.Type.FullName, TypeName = tobee.Type.FullName }; uow.Create(next); tobee.CurrentCrmInstance = next; } } }