public override void Execute(ICrmContext crmContext, string keyName) { var target = crmContext.PluginExecutionContext.InputParameters["Target"] as Entity; if (target != null && target.Contains("firstname")) target["firstname"] = "Nicolas"; else if (target != null) target.Attributes.Add(new KeyValuePair<string, object>("firstname","Nicolas")); }
public CustomerDataProvider(ICrmContext context) { _context = context; var config = new MapperConfiguration(cfg => { cfg.CreateMap <CustomerData, CustomerCrmData>(); cfg.CreateMap <CustomerCrmData, CustomerData>(); }); _mapper = config.CreateMapper(); }
/// <summary> /// Remove note from the contact. /// </summary> /// <param name="context"></param> /// <param name="note"></param> /// <param name="modifiedBy"></param> /// <returns></returns> public Result RemoveNote(ICrmContext context, ContactNote note, Guid modifiedBy) { //Fail pushed onto the CQRS pipeline execution var existingNotes = JsonConvert.DeserializeObject <ICollection <ContactNote> >(_notes); if (!existingNotes.Any(x => x.Equals(note))) { existingNotes.Remove(note); _notes = JsonConvert.SerializeObject(existingNotes); context.ClientContacts.Update(this); return(Result.Ok()); } return(Result.Fail($"Trying to remove inexistent note {note.Note}")); }
public VocabulariesService(ICrmContext context, IMapper mapper) { _context = context; _mapper = mapper; }
private bool SkipPluginValidation(ICrmContext crmContext, ILogging logging) { logging.Write("ThinkCrmPlugin: SkipPluginValidation Executed"); var attrs = System.Attribute.GetCustomAttributes(this.GetType()); if (!attrs.OfType<SkipValidationAttribute>().Any()) return logging.WriteAndReturn(false, "ThinkCrmPlugin: No SkipValidationAttribute Attribute Found"); var skipBool = attrs.OfType<SkipValidationAttribute>().First().SkipValidation; return logging.WriteAndReturn(skipBool, "ThinkCrmPlugin: SkipPluginValidation Attribute Found, Skip={0}", skipBool.ToString()); }
protected virtual bool ValidatePluginExecution(ICrmContext crmContext, ILogging logging, out string keyName) { logging.Write("ThinkCrmPlugin: Default ValidatePluginExecution Executed"); var attrs = System.Attribute.GetCustomAttributes(this.GetType()); var preImageName = crmContext.PluginExecutionContext.PreEntityImages.Count > 0 ? crmContext.PluginExecutionContext.PreEntityImages.First().Key : string.Empty; var preImage = crmContext.PluginExecutionContext.PreEntityImages.Count > 0 ? crmContext.PluginExecutionContext.PreEntityImages.First().Value : null; var postImageName = crmContext.PluginExecutionContext.PostEntityImages.Count > 0 ? crmContext.PluginExecutionContext.PostEntityImages.First().Key : string.Empty; var postImage = crmContext.PluginExecutionContext.PostEntityImages.Count > 0 ? crmContext.PluginExecutionContext.PostEntityImages.First().Value : null; foreach (var pAtt in attrs.OfType<PluginRegistrationAttribute>().Select(att => att as PluginRegistrationAttribute)) { logging.Write("ThinkCrmPlugin: Validating Key Name: {0}", pAtt.KeyName); if (pAtt.MatchesExecutingPlugin(crmContext.Message, crmContext.PluginExecutionContext.PrimaryEntityName, crmContext.PluginExecutionContext.SecondaryEntityName, crmContext.PipelineStage, crmContext.ExecutionMode, crmContext.PluginExecutionContext.IsExecutingOffline, preImageName, preImage, postImageName, postImage)) { keyName = pAtt.KeyName; logging.WriteAndReturn(true, "ThinkCrmPlugin: Validated Key Name: {0}", keyName); } else { logging.Write("ThinkCrmPlugin: Validation Failed for Key Name: {0}", pAtt.KeyName); } } logging.Write("ThinkCrmPlugin: No PluginRegistrationAttribute was Validated"); keyName = string.Empty; return false; }
public abstract void Execute(ICrmContext crmContext, string keyName);
public CrmService(ICrmContext context) { _context = context; }