public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext = null, params object[] data) { _log = Sitecore.Diagnostics.LoggerFactory.GetLogger("LogFileAppender"); var name = adaptedFields.GetEntryByName("Full Name"); var contactno = adaptedFields.GetEntryByName("Contact Number"); var email = adaptedFields.GetEntryByName("Email Address"); var Age = adaptedFields.GetEntryByName("Age"); var Company = adaptedFields.GetEntryByName("Company"); var Designation = adaptedFields.GetEntryByName("Designation"); _log.Info("Writing comment to database"); HttpContext.Current.Session["Email"] = email; /// var goal = new PageEventData("My Custom Goal", Guid.Parse("{47FF654B-76B2-49EF-A6AA-C61AE6093768}")); // Tracker.Current.CurrentPage.Register(goal); LockAttemptResult <Contact> lockResult; ContactRepository contactRepository = Sitecore.Configuration.Factory.CreateObject("tracking/contactRepository", true) as ContactRepository; ContactManager contactManager = Sitecore.Configuration.Factory.CreateObject("tracking/contactManager", true) as ContactManager; var contact = Tracker.Current?.Contact; if (contact == null) { lockResult = new LockAttemptResult <Contact>(LockAttemptStatus.NotFound, null, null); contact = contactRepository.CreateContact(Sitecore.Data.ID.NewID); contact.Identifiers.AuthenticationLevel = Sitecore.Analytics.Model.AuthenticationLevel.None; contact.Identifiers.Identifier = "*****@*****.**"; contact.Identifiers.IdentificationLevel = ContactIdentificationLevel.Known; contact.System.Value = 0; contact.System.VisitCount = 0; contact.ContactSaveMode = ContactSaveMode.AlwaysSave; contactManager.FlushContactToXdb(contact); // VisitorIdentification s = new VisitorIdentification(); } else { lockResult = contactManager.TryLoadContact(contact.ContactId); contact = lockResult.Object; } if (contact != null) { var contactEmailAddresses = contact.GetFacet <IContactCommentsFacet>("Contact Details"); if (!contactEmailAddresses.CustomerDetails.Contains("Contact Details")) { contactEmailAddresses.CustomerDetails.Create("Contact Details"); contactEmailAddresses.CustomerDetails["Contact Details"].Age = "18"; contactEmailAddresses.CustomerDetails["Contact Details"].Company = "Companyemarr"; contactEmailAddresses.CustomerDetails["Contact Details"].FullName = "Designationdsddf"; contactEmailAddresses.CustomerDetails["Contact Details"].Email = "Emailaddress"; } var leaseOwner = new LeaseOwner(GetType() + Guid.NewGuid().ToString(), LeaseOwnerType.OutOfRequestWorker); contactManager.SaveAndReleaseContactToXdb(contact); } }
public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext = null, params object[] data) { try { if (Tracker.Current == null) { return; } ID id = Sitecore.Data.ID.NewID; ID interactionId = Sitecore.Data.ID.NewID; ID contactId = Sitecore.Data.ID.NewID; // definition item for Marketing Lead var definitionId = Site.Foundation.Analytics.FoundationAnalyticsConstants.Outcomes.MarketingLeadOutcomeId; var outcome = new Sitecore.Analytics.Outcome.Model.ContactOutcome(id, definitionId, contactId) { DateTime = DateTime.UtcNow.Date, MonetaryValue = 0, InteractionId = interactionId }; Tracker.Current.RegisterContactOutcome(outcome); Log.Audit("WFFMTriggerOutcome : Outcome recorded ", this); } catch (Exception e) { Log.Error("WFFMTriggerOutcome : Exception occured while triggering outcome " + e.Message, this); } }
public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext = null, params object[] data) { Assert.ArgumentNotNull(adaptedFields, "adaptedFields"); Assert.IsNotNullOrEmpty(this.ContactsLists, "Empty contact list."); //Assert.IsNotNull(this.analyticsTracker.CurrentContact, "Tracker.Current.Contact"); Log.Info("[Wheelbarrowex] Save action triggered", this); //identify the user if it is not if (this.analyticsTracker.CurrentContact.Identifiers.Identifier == null) { identifyCurrentUser(adaptedFields); } //Now Let's add the contact to the list if (!adaptedFields.IsTrueStatement(this.ExecuteWhen)) { return; } List <string> list = (from x in this.ContactsLists.Split(new char[] { ',' }) select ID.Parse(x).ToString()).ToList <string>(); using (new SecurityDisabler()) { Contact currentContact = this.analyticsTracker.CurrentContact; foreach (string current in list) { currentContact.Tags.Set("ContactLists", current); } this.contactRepository.SaveContact(currentContact, true, null, new TimeSpan?(new TimeSpan(1000L))); } }
private static object GenerateForEmbeddedRule(EntityRule rule, IActionConfiguration actionConfiguration, Dictionary <string, List <string> > routeRelations, object originalObject) { var actionExecutedContext = ActionCallContext.Get <HttpActionExecutedContext>(); var entityActionConfiguration = HypermediaControllerConfiguration.Instance.GetcontrollerActionConfiguration(rule.ControllerType, rule.ControllerAction, actionExecutedContext.Request.Headers.Accept); if (entityActionConfiguration == null) { return(null); } var referencedObject = rule.GetReferencedObjectInstance(originalObject); if (referencedObject == null) { return(null); } var transformed = ActionResponseTransformer.TransformPayload(entityActionConfiguration, referencedObject); if (transformed == null) { return(null); } if (transformed is IEnumerable) { throw new Exception(string.Format("Unable to generate enumerable entity object from controller {0} action {1}. Consider using outer object.", actionConfiguration.ControllerType.FullName, actionConfiguration.ActionMethodInfo)); } AssignRelName(transformed, rule.Rel); return(transformed); }
public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext = null, params object[] data) { Assert.ArgumentNotNull(adaptedFields, nameof(adaptedFields)); var requestor = new Requestor(); var fields = GetFieldsJson(adaptedFields); Task.Run(() => requestor.PostRequest(TriggerAddress, fields)); }
public void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext = null, params object[] data) { string FirstName = adaptedFields.GetEntryByName("FirstName").Value; string LastName = adaptedFields.GetEntryByName("LastName").Value; string Message = adaptedFields.GetEntryByName("Message").Value; string Date = adaptedFields.GetEntryByName("Date").Value; string Email = adaptedFields.GetEntryByName("Email").Value; Log.Info("New Form has been submited", this); }
public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext = null, params object[] data) { HttpCookie cookie = new HttpCookie(Constants.GatedAccessCookeName) { Value = Constants.AccessGrantedCookieValue, Expires = DateTime.Now.AddDays(Utility.GetCookieLifeSpan()) }; HttpContext.Current.Response.Cookies.Add(cookie); }
public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext = null, params object[] data) { _log = Sitecore.Diagnostics.LoggerFactory.GetLogger("LogFileAppender"); var name = adaptedFields.GetEntryByName("Name"); var email = adaptedFields.GetEntryByName("Email"); var comment = adaptedFields.GetEntryByName("Comment"); _log.Info("Writing comment to database"); HttpContext.Current.Session["Email"] = email; var goal = new PageEventData("My Custom Goal", Guid.Parse("{47FF654B-76B2-49EF-A6AA-C61AE6093768}")); Tracker.Current.CurrentPage.Register(goal); var contact = Tracker.Current?.Contact; if (contact != null) { var commentCounterTag = contact.Tags.Find("CommentCounter"); if (commentCounterTag == null) { contact.Tags.Set("CommentCounter", "1"); } else { int originalValue = 0; int newValue = 0; var counter = commentCounterTag.Values.FirstOrDefault(); if (counter != null) { if (Int32.TryParse(counter.Value, out originalValue)) { newValue = originalValue + 1; contact.Tags.Remove("CommentCounter", originalValue.ToString()); contact.Tags.Set("CommentCounter", newValue.ToString()); } } if (originalValue < 10 && newValue >= 10) { contact.Extensions.SimpleValues["ContributionLevel"] = "Fanboy"; } } } }
public static string MakeAbsolutePath(string relativePath) { var virtualRoot = System.Web.Http.GlobalConfiguration.Configuration.VirtualPathRoot ?? string.Empty; var builder = new UriBuilder(); if (!relativePath.StartsWith("/")) { builder.Path = virtualRoot; } var actionExecutedContext = ActionCallContext.Get <HttpActionExecutedContext>(); if (actionExecutedContext != null) { var requestUri = actionExecutedContext.Request.RequestUri; builder.Scheme = requestUri.Scheme; builder.Host = requestUri.Host; if (!requestUri.IsDefaultPort) { builder.Port = requestUri.Port; } } var result = builder.ToString(); if (string.IsNullOrEmpty(relativePath)) { return(result); } if (!result.EndsWith("/")) { result += "/"; } if (relativePath.StartsWith("/")) { relativePath = relativePath.Remove(0, 1); } result += relativePath; return(result); }
public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext = null, params object[] data) { if (string.IsNullOrEmpty(this.Outcome) || !ID.IsID(this.Outcome)) { Log.Warn("Can't register an outcome. Outcome isn't set",this); return; } var outcomeItem = Context.Database.GetItem(new ID(this.Outcome)); if (outcomeItem == null || outcomeItem.TemplateID != Constants.OutcomeTemplateId) { Log.Warn("Can't register an outcome. Wrong outcome definition", this); return; } this.trackerService.TrackOutcome(new ID(this.Outcome)); }
public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext = null, params object[] data) { if (string.IsNullOrEmpty(Level)) { Log.Error("The level of Gated Access has not been set on the Save Action - " + ActionID.ToString() + ". Please ensure it is set correct i.e. <Level>1</Level> in the parameters field", this); Level = string.Empty; } HttpCookie cookie = new HttpCookie(Utility.DefineCookieName()) { Value = Level, Expires = DateTime.Now.AddDays(Utility.GetCookieLifeSpan()) }; HttpContext.Current.Response.Cookies.Add(cookie); }
private static object GenerateForLinkedRule(EntityRule rule, IActionConfiguration actionConfiguration, Dictionary <string, List <string> > routeRelations, object originalObject) { var actionExecutedContext = ActionCallContext.Get <HttpActionExecutedContext>(); var entityActionConfiguration = HypermediaControllerConfiguration.Instance.GetcontrollerActionConfiguration(rule.ControllerType, rule.ControllerAction, actionExecutedContext.Request.Headers.Accept); if (entityActionConfiguration == null) { return(null); } var referencedObject = rule.GetReferencedObjectInstance(originalObject); if (referencedObject == null) { return(null); } var selfRule = entityActionConfiguration.MappingRules.FirstOrDefault(r => r.Names.Contains("self")); if (selfRule == null) { throw new Exception(string.Format("Unable to generate link to entity object from controller {0} action {1}. Can't find self rel.", actionConfiguration.ControllerType.FullName, actionConfiguration.ActionMethodInfo)); } var selfApi = selfRule.ApiDescriptions.OrderBy(d => d.RelativePath.Length).FirstOrDefault(); if (selfApi == null) { throw new Exception(string.Format("Unable to generate link to entity object from controller {0} action {1}. Can't find self API.", actionConfiguration.ControllerType.FullName, actionConfiguration.ActionMethodInfo)); } var routeNameSubstitution = new DefaultRouteValueSubstitution(); var absolutePath = LinkHelper.MakeAbsolutePath(routeNameSubstitution.Substitute(selfApi.RelativePath, selfRule, referencedObject)); return(new LinkedEntity() { Rels = rule.Rel, ClassName = entityActionConfiguration.Class, Href = absolutePath }); }
public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext = null, params object[] data) { if (string.IsNullOrEmpty(this.Outcome) || !ID.IsID(this.Outcome)) { Log.Warn("Can't register an outcome. Outcome isn't set", this); return; } var outcomeItem = Context.Database.GetItem(new ID(this.Outcome)); if (outcomeItem == null || outcomeItem.TemplateID != Constants.OutcomeTemplateId) { Log.Warn("Can't register an outcome. Wrong outcome definition", this); return; } this.trackerService.TrackOutcome(new ID(this.Outcome)); }
public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext = null, params object[] data) { if (!adaptedFields.IsTrueStatement(ExecuteWhen)) { return; } var lists = ContactsLists.Split(',').Select(x => ID.Parse(x).ToString()).ToArray(); using (new SecurityDisabler()) { Contact currentContact = _analyticsTracker.CurrentContact; if (currentContact.Identifiers.IdentificationLevel != ContactIdentificationLevel.Known) { var emailAddresses = currentContact.GetFacet <Sitecore.Analytics.Model.Entities.IContactEmailAddresses>("Emails"); if (emailAddresses.Entries.Contains("Preferred")) { var email = emailAddresses.Entries["Preferred"]; _analyticsTracker.Current.Session.Identify(email.SmtpAddress); } } // //var recipientId = new Sitecore.Modules.EmailCampaign.Xdb.XdbContactId(currentContact.ContactId); // var rootList = (Sitecore.Context.ContentDatabase ?? Sitecore.Context.Database).GetItem(RootListPath); //Assert.IsNotNull(rootList, "Empty root list."); // var managerRootId = (rootList[ManagerRootsFieldName] ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(); // Assert.IsNotNullOrEmpty(managerRootId, "Empty manager root id."); // Log.Info($"AddContactToContactList [{currentContact.ContactId}, {ContactsLists}, {managerRootId}]", this); // ClientApi.UpdateSubscriptions(recipientId, lists, new string[] { }, managerRootId, false); } }
public HelloAction(ActionCallContext context, string text) : base(context) { Text = text; }
public ListRoleAction(ActionCallContext context) : base(context) { }
public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext = null, params object[] data) { Assert.ArgumentNotNull(formId, "formId"); Assert.ArgumentNotNull(adaptedFields, "fields"); this.Result = adaptedFields; this.formId = formId; Guid undoEntityCreation = Guid.Empty; try { if (this.EntitySettings != null && (this.PrimaryField != null || !this.CanBeOverwritten)) { ICrmEntity entity = null; if (this.CanBeOverwritten) { string keyValue = this.GetValue(this.PrimaryField, adaptedFields); if (string.IsNullOrEmpty(keyValue)) { throw new ArgumentException(this.KeyFieldUndefinedMessage); } entity = this.Get(this.EntityName, this.EntitySettings.PrimaryFieldName, keyValue, this.EntitySettings.SupportStateCode, this.GetColumns()); } Guid entityId; if (entity == null) { entity = this.EntityRepository.NewEntity(this.EntityName); this.isCreated = true; this.InitEntityState(entity); this.SetProperties(entity, adaptedFields); this.SetCustomCrmProperties(this.formId, adaptedFields, entity); undoEntityCreation = this.Create(entity); entityId = undoEntityCreation; actionCallContext.Parameters.Add(this.UniqueKey, new FormsCrmEntity { Name = this.EntitySettings.EntityName, ID = entityId }); if (Guid.Empty == undoEntityCreation) { throw new InvalidOperationException(this.CannotBeCreatedMessage); } return; } entityId = new Guid(this.GetPropertyValue(entity, this.EntitySettings.PrimaryKey)); this.SetProperties(entity, adaptedFields); this.SetCustomCrmProperties(this.formId, adaptedFields, entity); this.Update(entity); actionCallContext.Parameters.Add(this.UniqueKey, new FormsCrmEntity { Name = this.EntitySettings.EntityName, ID = entityId }); } else { Log.Warn( "'The Create CRM {0}' action is not customized.".FormatWith( this.EntitySettings != null ? this.EntitySettings.EntityName : "entity"), this); } } catch (SoapException ex) { var exception = new Exception(ex.GetFormatedMessage(), ex); this.UndoAction(undoEntityCreation); throw exception; } catch (Exception) { this.UndoAction(undoEntityCreation); throw; } }
protected AbstractAction(ActionCallContext context) { Context = context; }
public BaseApiController(ClaimsPrincipal claimsPrincipal) { _actionCallContext = new ActionCallContext(claimsPrincipal); }