public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { APIResult <FidelityReward> res = (APIResult <FidelityReward>)(workflowContext.Tokens["result"]); if (res.success) { FidelityReward rew = res.data; workflowContext.SetState <string>("rewardId", rew.Id); if (!string.IsNullOrWhiteSpace(rew.Description)) { workflowContext.SetState <string>("rewardDescription", rew.Description); } if (!string.IsNullOrWhiteSpace(rew.Name)) { workflowContext.SetState <string>("rewardName", rew.Name); } else { workflowContext.SetState <string>("rewardName", ""); } yield return(T("Success")); } else { yield return(T("Error")); } }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { LocalizedString messageout = null; var elencoTypeId = ((string)activityContext.GetState <string>("ReactionClickedActivity_reactionTypes")).Split(',').Select(Int32.Parse).ToList(); int reactionId = Convert.ToInt32(workflowContext.Tokens["ReactionId"]); int action = Convert.ToInt32(workflowContext.Tokens["Action"]); int userId = Convert.ToInt32(workflowContext.Tokens["UserId"]); workflowContext.SetState <int>("ReactionId", reactionId); workflowContext.SetState <int>("Action", action); workflowContext.SetState <string>("ReactionUserEmail", workflowContext.Tokens["UserEmail"].ToString()); workflowContext.SetState <int>("ReactionUserId", userId); if (elencoTypeId.Contains(reactionId)) { if (action == 1) { messageout = T("Clicked"); } else { messageout = T("Unclicked"); } } else { messageout = T("NothingToDo"); } yield return(messageout); }
/// <summary> /// usando un token es: {Workflow.State:text} recupero il valore /// </summary> public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { LocalizedString messageout = T("Interaction"); string text = workflowContext.Tokens["text"].ToString(); string sourceType = workflowContext.Tokens["sourceType"].ToString(); int count = Convert.ToInt32(workflowContext.Tokens["count"]); int UserId = Convert.ToInt32(workflowContext.Tokens["UserId"]); workflowContext.SetState <int>("UserId", UserId); workflowContext.SetState <int>("count", count); workflowContext.SetState <string>("sourceType", sourceType); workflowContext.SetState <string>("text", text); yield return(messageout); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var url = activityContext.GetState <string>("Url"); var verb = (activityContext.GetState <string>("Verb") ?? "GET").ToUpper(); var headers = activityContext.GetState <string>("Headers"); var formValues = activityContext.GetState <string>("FormValues") ?? ""; using (var httpClient = new HttpClient { BaseAddress = new Uri(url) }) { HttpResponseMessage response; httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); if (!String.IsNullOrWhiteSpace(headers)) { foreach (var header in ParseKeyValueString(headers)) { httpClient.DefaultRequestHeaders.Add(header.Key, header.Value); } } switch (verb) { default: case "GET": response = httpClient.GetAsync("").Result; break; case "POST": var format = activityContext.GetState <string>("FormFormat"); switch (format) { default: case "KeyValue": var form = ParseKeyValueString(formValues); response = httpClient.PostAsync("", new FormUrlEncodedContent(form)).Result; break; case "Json": var json = formValues.Replace("((", "{").Replace("))", "}"); response = httpClient.PostAsync("", new StringContent(json, Encoding.UTF8, "application/json")).Result; break; } break; } workflowContext.SetState("WebRequestResponse", response.Content.ReadAsStringAsync().Result); if (response.IsSuccessStatusCode) { yield return(T("Success")); } yield return(T("Error")); } }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { APIResult <CardPointsCampaign> res = (APIResult <CardPointsCampaign>)(workflowContext.Tokens["result"]); CardPointsCampaign card = res.data; if (res.success) { workflowContext.SetState <string>("customerId", card.idCustomer); workflowContext.SetState <string>("campaignId", card.idCampaign); workflowContext.SetState <double>("points", card.points); yield return(T("Success")); } else { yield return(T("Error")); } }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { LocalizedString messageout = null; bool syncronized = workflowContext.Tokens["Syncronized"] == null ? false : (bool)workflowContext.Tokens["Syncronized"]; workflowContext.SetState("Syncronized", syncronized); workflowContext.SetState("APICallEdit", workflowContext.Tokens["APICallEdit"]); workflowContext.SetState("Email", workflowContext.Tokens["Email"]); if (syncronized) { messageout = T("Succeeded"); } else { messageout = T("Failed"); } yield return(messageout); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { // copy workflow tokens in workflow state so they are // accessible by {Workflow.State:*} workflowContext.SetState("Context", workflowContext.Tokens.ContainsKey("Context") ? (AttributesValidationContext)workflowContext.Tokens["Context"] : (AttributesValidationContext)null); yield return(T("Done")); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { if (!workflowContext.Tokens.ContainsKey(NewActivityStreamActivity.ActivityStreamRecordKey)) { return(new[] { T("Failed") }); } ActivityStreamRecord activityStreamRecord = (ActivityStreamRecord )workflowContext.Tokens[NewActivityStreamActivity.ActivityStreamRecordKey]; workflowContext.SetState <int>("ActivityStreamId", activityStreamRecord.Id); return(new[] { T("Done") }); }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var url = activityContext.GetState<string>("Url"); var verb = (activityContext.GetState<string>("Verb") ?? "GET").ToUpper(); var headers = activityContext.GetState<string>("Headers"); var formValues = activityContext.GetState<string>("FormValues") ?? ""; using (var httpClient = new HttpClient {BaseAddress = new Uri(url)}) { HttpResponseMessage response; httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); if (!String.IsNullOrWhiteSpace(headers)) { foreach (var header in ParseKeyValueString(headers)) { httpClient.DefaultRequestHeaders.Add(header.Key, header.Value); } } switch (verb) { default: case "GET": response = httpClient.GetAsync("").Result; break; case "POST": var format = activityContext.GetState<string>("FormFormat"); switch (format) { default: case "KeyValue": var form = ParseKeyValueString(formValues); response = httpClient.PostAsync("", new FormUrlEncodedContent(form)).Result; break; case "Json": var json = formValues.Replace("((", "{").Replace("))", "}"); response = httpClient.PostAsync("", new StringContent(json, Encoding.UTF8, "application/json")).Result; break; } break; } workflowContext.SetState("WebRequestResponse", response.Content.ReadAsStringAsync().Result); if (response.IsSuccessStatusCode) yield return T("Success"); else yield return T("Error"); } }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { LocalizedString messageout = null; PaymentRecord payment = (PaymentRecord)(workflowContext.Tokens["Payment"]); workflowContext.SetState <PaymentRecord>("Payment", payment); if (payment.Success) { messageout = T("Succeeded"); } else { messageout = T("Failed"); } yield return(messageout); }
public override IEnumerable <LocalizedString> Execute( WorkflowContext workflowContext, ActivityContext activityContext) { // Get the ContentItems form the context var contentItems = GetItems(workflowContext, activityContext); if (!contentItems.Any()) { yield return(T("NoItem")); } var errorMessages = workflowContext.GetState <string>("ErrorMessage"); errorMessages = string.IsNullOrWhiteSpace(errorMessages) ? "" : errorMessages + Environment.NewLine; var error = false; foreach (var item in contentItems) { try { // for each ContentItem, invoke the process GDPRProcess(item); } catch (Exception ex) { error = true; var msg = T("Error during the execution of {0} for ContentItem with Id {1}", Name, item.Id).Text; // log the exception Logger.Error(ex, msg); // add information on the error to the WorkflowContext errorMessages += msg + Environment.NewLine; } } if (error) { workflowContext.SetState("ErrorMessage", errorMessages); yield return(T("Error")); } yield return(T("OK")); }