public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var userName = activityContext.GetState<string>("UserName"); var email = activityContext.GetState<string>("Email"); var password = activityContext.GetState<string>("Password"); var approved = activityContext.GetState<bool>("Approved"); if (String.IsNullOrWhiteSpace(userName) || String.IsNullOrWhiteSpace(email)) { yield return T("InvalidUserNameOrEmail"); yield break; } if (String.IsNullOrWhiteSpace(password)) { yield return T("InvalidPassword"); yield break; } if (!_userService.VerifyUserUnicity(userName, email)) { yield return T("UserNameOrEmailNotUnique"); yield break; } var user = _membershipService.CreateUser( new CreateUserParams( userName, password, email, isApproved: approved, passwordQuestion: null, passwordAnswer: null)); workflowContext.Content = user; yield return T("Done"); }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var part = workflowContext.Content.As<WXMsgPart>(); var apiUrl = activityContext.GetState<string>("api_url"); var apiToken = activityContext.GetState<string>("api_token"); var timestamp = HttpContext.Current.Request.QueryString["timestamp"]; var nonce = HttpContext.Current.Request.QueryString["nonce"]; string[] arr = { apiToken, timestamp, nonce }; Array.Sort(arr); //字典排序 string tmpStr = string.Join("", arr); var signature = _winXinService.GetSHA1(tmpStr); signature = signature.ToLower(); var client = new System.Net.WebClient(); client.Encoding = System.Text.Encoding.UTF8; var url = string.Format("{0}?timestamp={1}&nonce={2}&signature={3}" , apiUrl, timestamp, nonce, signature); string postData = part.XML; //using (var stream = HttpContext.Current.Request.InputStream) //{ // var reader = new StreamReader(stream); // postData = reader.ReadToEnd(); //} string result = null; try { result = client.UploadString(url, postData); } catch (System.Net.WebException ex) { string msg = null; using (var stream = ex.Response.GetResponseStream()) { var reader = new StreamReader(stream); msg = reader.ReadToEnd(); } Logger.Warning(ex, ex.Message); } catch (Exception ex) { var innerEx = ex; while (innerEx.InnerException != null) innerEx = innerEx.InnerException; Logger.Warning(ex, innerEx.Message); } if (result == null) { yield return T("Error"); } else { HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(result); HttpContext.Current.Response.End(); yield return T("Success"); } }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var notification = activityContext.GetState<string>("Notification"); var message = activityContext.GetState<string>("Message"); var notificationType = (NotifyType)Enum.Parse(typeof(NotifyType), notification); _notifier.Add(notificationType, T(message)); yield return T("Done"); }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var key = activityContext.GetState<string>("Key"); var message = activityContext.GetState<string>("ErrorMessage"); var updater = (IUpdateModel) workflowContext.Tokens["Updater"]; updater.AddModelError(key, T(message)); return new[] { T("Done") }; }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var levelString = activityContext.GetState<string>("Level"); var message = activityContext.GetState<string>("Message"); LogLevel level; Enum.TryParse(levelString, true, out level); Logger.Log(level, null, message); yield return T("Done"); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var key = activityContext.GetState <string>("Key"); var message = activityContext.GetState <string>("ErrorMessage"); var updater = (IUpdateModel)workflowContext.Tokens["Updater"]; updater.AddModelError(key, T(message)); return(new[] { T("Done") }); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var body = activityContext.GetState <string>("Body"); var subject = activityContext.GetState <string>("Subject"); var recipients = activityContext.GetState <string>("Recipients"); var replyTo = activityContext.GetState <string>("ReplyTo"); var bcc = activityContext.GetState <string>("Bcc"); var cc = activityContext.GetState <string>("CC"); var notifyReadEmail = activityContext.GetState <bool>("NotifyReadEmail"); var parameters = new Dictionary <string, object> { { "Subject", subject }, { "Body", body }, { "Recipients", recipients }, { "ReplyTo", replyTo }, { "Bcc", bcc }, { "CC", cc }, { "NotifyReadEmail", notifyReadEmail } }; var queued = activityContext.GetState <bool>("Queued"); if (!queued) { _messageService.Send(SmtpMessageChannel.MessageType, parameters); } else { var priority = activityContext.GetState <int>("Priority"); _jobsQueueService.Enqueue("IMessageService.Send", new { type = SmtpMessageChannel.MessageType, parameters = parameters }, priority); } yield return(T("Done")); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { LocalizedString messageout = null; string result = ""; HttpVerbs verb = HttpVerbs.Get; var model = new APICallEdit { Url = activityContext.GetState <string>("Url"), RequestType = activityContext.GetState <string>("RequestType"), HttpVerb = activityContext.GetState <string>("HttpVerb"), Payload = activityContext.GetState <string>("Payload").ToString(), RequiredPolicies = activityContext.GetState <string>("RequiredPolicies") }; Enum.TryParse <HttpVerbs>(model.HttpVerb.ToString(), true, out verb); JObject payload = JObject.Parse("{" + model.Payload + "}"); // In case in the url we kept the "default" fake tokens {list-id} and {member-id} // we can try to replace them by checking the site settings and the payload var urlApiCall = _service.TryReplaceTokenInUrl(model.Url, payload); // updated model with replaced parameters at the url model.Url = urlApiCall; var done = _apiservice.TryApiCall(verb, urlApiCall, payload, ref result); // this trigger is only valid for the member's put and delete if (verb == HttpVerbs.Put && model.RequestType.ToLower() == RequestTypes.Member.ToString().ToLower()) { _workflowManager.TriggerEvent("UserCreatedOnMailchimp", null, () => new Dictionary <string, object> { { "Syncronized", done }, { "APICallEdit", model }, { "Email", payload["email_address"] == null ? "" : payload["email_address"].ToString() } }); } else if (verb == HttpVerbs.Delete && model.RequestType.ToLower() == RequestTypes.Member.ToString().ToLower()) { _workflowManager.TriggerEvent("UserDeletedOnMailchimp", null, () => new Dictionary <string, object> { { "Syncronized", done }, { "APICallEdit", model }, { "Email", payload["email_address"] == null ? "" : payload["email_address"].ToString() } }); } if (done) { messageout = T("Succeeded"); } else { messageout = T("Failed"); } yield return(messageout); }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var userName = activityContext.GetState<string>("UserName"); var email = activityContext.GetState<string>("Email"); if (_userService.VerifyUserUnicity(userName, email)) { yield return T("Unique"); } else { yield return T("NotUnique"); } }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var body = activityContext.GetState <string>("Body"); var recipients = activityContext.GetState <string>("Recipients"); foreach (var recipient in recipients.Split(',')) { _twilioService.SendSms(recipient, body); } yield return(T("Done")); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var notification = activityContext.GetState <string>("Notification"); var message = activityContext.GetState <string>("Message"); NotifyType notificationType; Enum.TryParse(notification, true, out notificationType); _notifier.Add(notificationType, T(message)); yield return(T("Done")); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var levelString = activityContext.GetState <string>("Level"); var message = activityContext.GetState <string>("Message"); LogLevel level; Enum.TryParse(levelString, true, out level); Logger.Log(level, null, message); yield return(T("Done")); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { string recipient = activityContext.GetState <string>("Recipient"); var properties = new Dictionary <string, string> { { "Body", activityContext.GetState <string>("Body") }, { "Subject", activityContext.GetState <string>("Subject") }, { "RecipientOther", activityContext.GetState <string>("RecipientOther") } }; if (recipient == "owner") { var content = workflowContext.Content; if (content.Has <CommonPart>()) { var owner = content.As <CommonPart>().Owner; if (owner != null && owner.ContentItem != null && owner.ContentItem.Record != null) { _messageManager.Send(owner.ContentItem.Record, MessageType, "email", properties); } _messageManager.Send( SplitEmail(owner.As <IUser>().Email), MessageType, "email", properties); } } else if (recipient == "author") { var user = _orchardServices.WorkContext.CurrentUser; // can be null if user is anonymous if (user != null && !String.IsNullOrWhiteSpace(user.Email)) { _messageManager.Send(user.ContentItem.Record, MessageType, "email", properties); } } else if (recipient == "admin") { var username = _orchardServices.WorkContext.CurrentSite.SuperUser; var user = _membershipService.GetUser(username); // can be null if user is no super user is defined if (user != null && !String.IsNullOrWhiteSpace(user.Email)) { _messageManager.Send(user.ContentItem.Record, MessageType, "email", properties); } } else if (recipient == "other") { _messageManager.Send(SplitEmail(activityContext.GetState <string>("RecipientOther")), MessageType, "email", properties); } yield return(T("Sent")); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var userName = activityContext.GetState <string>("UserName"); var email = activityContext.GetState <string>("Email"); if (_userService.VerifyUserUnicity(userName, email)) { yield return(T("Unique")); } else { yield return(T("NotUnique")); } }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var body = activityContext.GetState<string>("Body"); var subject = activityContext.GetState<string>("Subject"); var recipients = activityContext.GetState<string>("Recipients"); var replyTo = activityContext.GetState<string>("ReplyTo"); var bcc = activityContext.GetState<string>("Bcc"); var cc = activityContext.GetState<string>("CC"); var parameters = new Dictionary<string, object> { {"Subject", subject}, {"Body", body}, {"Recipients", recipients}, {"ReplyTo", replyTo}, {"Bcc", bcc}, {"CC", cc} }; var queued = activityContext.GetState<bool>("Queued"); if (!queued) { _messageService.Send(SmtpMessageChannel.MessageType, parameters); } else { var priority = activityContext.GetState<int>("Priority"); _jobsQueueService.Enqueue("IMessageService.Send", new { type = SmtpMessageChannel.MessageType, parameters = parameters }, priority); } yield return T("Done"); }
private bool IsExpired(WorkflowContext workflowContext, ActivityContext activityContext) { DateTime started; if (!workflowContext.HasStateFor(activityContext.Record, "StartedUtc")) { workflowContext.SetStateFor(activityContext.Record, "StartedUtc", started = _clock.UtcNow); } else { started = workflowContext.GetStateFor<DateTime>(activityContext.Record, "StartedUtc"); } var amount = activityContext.GetState<int>("Amount"); var type = activityContext.GetState<string>("Unity"); return _clock.UtcNow > When(started, amount, type); }
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 bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) { try { // Recupero il bottone associato all'evento var buttonSelected = activityContext.GetState <string>("DynamicButton"); // Verifico che all'evento sia effettivamente associato un bottone e di avere le informazioni sul bottone cliccato nel workflowContext if (!string.IsNullOrWhiteSpace(buttonSelected) && workflowContext.Tokens.ContainsKey("ButtonName")) { // Recupero il bottone che è stato cliccato. Se esiste, ne ottengo il Guid e lo confronto con quello del bottone selezionato. var clickedButtonName = workflowContext.Tokens["ButtonName"].ToString(); if (!string.IsNullOrWhiteSpace(clickedButtonName)) { var clickedButtonIdentifier = _dynamicButtonToWorkflowsService.GetButtons().Where(w => w.ButtonName == clickedButtonName).Select(s => s.GlobalIdentifier).FirstOrDefault(); return(clickedButtonIdentifier.ToString() == buttonSelected); } } return(false); } catch { return(false); } }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var script = activityContext.GetState <string>("Script"); if (!String.IsNullOrWhiteSpace(script)) { var submission = (FormSubmissionTokenContext)workflowContext.Tokens["FormSubmission"]; // Start the script with the new token syntax. script = "// #{ }" + System.Environment.NewLine + script; if (workflowContext.Content != null) { _csharpService.SetParameter("ContentItem", (dynamic)workflowContext.Content.ContentItem); } _csharpService.SetParameter("Services", _orchardServices); _csharpService.SetParameter("WorkContext", _workContextAccessor.GetContext()); _csharpService.SetParameter("Workflow", workflowContext); _csharpService.SetFunction("T", (Func <string, string>)(x => T(x).Text)); _csharpService.SetFunction("AddModelError", (Action <string, LocalizedString>)((key, message) => submission.ModelState.AddModelError(key, message.Text))); _csharpService.Run(script); } return(base.Execute(workflowContext, activityContext)); }
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) { try { var state = activityContext.GetState <string>("CustomForms"); // "" means 'any' if (String.IsNullOrEmpty(state)) { return(true); } var content = workflowContext.Content; if (content == null) { return(false); } var contentManager = content.ContentItem.ContentManager; var identities = state.Split(',').Select(x => new ContentIdentity(x)); var customForms = identities.Select(contentManager.ResolveIdentity); return(customForms.Any(x => x == content)); } catch { return(false); } }
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) { try { var contentTypesState = activityContext.GetState<string>("ContentTypes"); // "" means 'any' if (String.IsNullOrEmpty(contentTypesState)) { return true; } string[] contentTypes = contentTypesState.Split(','); var content = workflowContext.Content; if (content == null) { return false; } return contentTypes.Any(contentType => content.ContentItem.TypeDefinition.Name == contentType); } catch { return false; } }
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) { try { var identityValues = activityContext.GetState <string>("IdentityValues"); // "" means 'any' if (String.IsNullOrEmpty(identityValues)) { return(true); } string[] contentIdentities = identityValues.Split(','); var content = workflowContext.Content; if (content == null) { return(false); } return(contentIdentities.Any(identity => _orchardServices.ContentManager.GetItemMetadata(content).Identity.ToString() == identity)); } catch { return(false); } }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var commonPart = workflowContext.Content.As <CommonPart>(); if (commonPart == null || commonPart.Owner == null) { return(new[] { T(No) }); } string specifiedTag = activityContext.GetState <string>(CheckUserTagActivityForm.TagFieldName); if (string.IsNullOrEmpty(specifiedTag)) { return(new[] { T(Yes) }); } var userTags = ProjectHelper.GetUserField(commonPart.Owner, FieldNames.UserTags); if (userTags.ToLower(CultureInfo.InvariantCulture).Contains(specifiedTag.ToLower(CultureInfo.InvariantCulture))) { return(new[] { T(Yes) }); } return(new[] { T(No) }); }
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) { try { var state = activityContext.GetState<string>("CustomForms"); // "" means 'any' if (String.IsNullOrEmpty(state)) { return true; } var content = workflowContext.Tokens["CustomForm"] as ContentItem; if (content == null) { return false; } var contentManager = content.ContentManager; var identities = state.Split(',').Select(x => new ContentIdentity(x)); var customForms = identities.Select(contentManager.ResolveIdentity); return customForms.Any(x => x == content); } catch { return false; } }
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); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var url = activityContext.GetState <string>("Url"); _wca.GetContext().HttpContext.Response.Redirect(url); yield return(T("Done")); }
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) { try { var contentTypesState = activityContext.GetState <string>("ContentTypes"); // "" means 'any' if (String.IsNullOrEmpty(contentTypesState)) { return(true); } string[] contentTypes = contentTypesState.Split(','); var content = workflowContext.Content; if (content == null) { return(false); } return(contentTypes.Any(contentType => content.ContentItem.TypeDefinition.Name == contentType)); } catch { return(false); } }
private int?GetValueFromActivityContext(ActivityContext activityContext, string key) { string valueString = activityContext.GetState <string>(key); int value; return(int.TryParse(valueString, out value) ? (int?)value : null); }
// Implementing what the activity actually does. public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { // What was previously saved via the form can be fetched from the Workflow's state here. var message = activityContext.GetState <string>(MessageFieldName); _notifier.Warning(T(message)); yield return(T("Done")); }
private IEnumerable<string> GetBranches(ActivityContext context) { var branches = context.GetState<string>("Branches"); if (String.IsNullOrEmpty(branches)) { return Enumerable.Empty<string>(); } return branches.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToList(); }
private bool IsExpired(WorkflowContext workflowContext, ActivityContext activityContext) { DateTime started; if (!workflowContext.HasStateFor(activityContext.Record, "StartedUtc")) { workflowContext.SetStateFor(activityContext.Record, "StartedUtc", started = _clock.UtcNow); } else { started = workflowContext.GetStateFor <DateTime>(activityContext.Record, "StartedUtc"); } var amount = activityContext.GetState <int>("Amount"); var type = activityContext.GetState <string>("Type"); return(_clock.UtcNow > When(started, amount, type)); }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { string recipient = activityContext.GetState<string>("Recipient"); var properties = new Dictionary<string, string> { {"Body", activityContext.GetState<string>("Body")}, {"Subject", activityContext.GetState<string>("Subject")} }; if (recipient == "owner") { var content = workflowContext.Content; if (content.Has<CommonPart>()) { var owner = content.As<CommonPart>().Owner; if (owner != null && owner.ContentItem != null && owner.ContentItem.Record != null) { _messageManager.Send(owner.ContentItem.Record, MessageType, "email", properties); } _messageManager.Send( SplitEmail(owner.As<IUser>().Email), MessageType, "email", properties); } } else if (recipient == "author") { var user = _orchardServices.WorkContext.CurrentUser; // can be null if user is anonymous if (user != null && String.IsNullOrWhiteSpace(user.Email)) { _messageManager.Send(user.ContentItem.Record, MessageType, "email", properties); } } else if (recipient == "admin") { var username = _orchardServices.WorkContext.CurrentSite.SuperUser; var user = _membershipService.GetUser(username); // can be null if user is no super user is defined if (user != null && !String.IsNullOrWhiteSpace(user.Email)) { _messageManager.Send(user.ContentItem.Record, MessageType, "email", properties); } } else if (recipient == "other") { var email = properties["RecipientOther"]; _messageManager.Send(SplitEmail(email), MessageType, "email", properties); } yield return T("Sent"); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var userName = activityContext.GetState <string>("UserName"); var email = activityContext.GetState <string>("Email"); var password = activityContext.GetState <string>("Password"); var approved = activityContext.GetState <bool>("Approved"); if (String.IsNullOrWhiteSpace(userName) || String.IsNullOrWhiteSpace(email)) { yield return(T("InvalidUserNameOrEmail")); yield break; } if (String.IsNullOrWhiteSpace(password)) { yield return(T("InvalidPassword")); yield break; } if (!_userService.VerifyUserUnicity(userName, email)) { yield return(T("UserNameOrEmailNotUnique")); yield break; } userName = userName.Trim(); var user = _membershipService.CreateUser( new CreateUserParams( userName, password, email, isApproved: approved, passwordQuestion: null, passwordAnswer: null)); workflowContext.Content = user; yield return(T("Done")); }
private bool IsExpired(WorkflowContext workflowContext, ActivityContext activityContext) { DateTime started; if (!workflowContext.HasStateFor(activityContext.Record, "StartedUtc")) { var dateString = activityContext.GetState<string>("Date"); var date = _dateServices.ConvertFromLocalizedString(dateString); started = date ?? _clock.UtcNow; workflowContext.SetStateFor(activityContext.Record, "StartedUtc", started); } else { started = workflowContext.GetStateFor<DateTime>(activityContext.Record, "StartedUtc"); } var amount = activityContext.GetState<int>("Amount"); var type = activityContext.GetState<string>("Unity"); return _clock.UtcNow > When(started, amount, type); }
private bool GetBooleanValue(ActivityContext activityContext, string name) { bool returnValue = false; string fieldValue = activityContext.GetState <string>(name); bool.TryParse(fieldValue, out returnValue); return(returnValue); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { LocalizedString messageout = T("Success"); try { var newterm = ((string)activityContext.GetState <string>("allterms")).Split(',').Select(Int32.Parse).ToList(); if (newterm.Count() == 0) { messageout = T("Error"); } var content = workflowContext.Content; // List<TermPart> termParts = _contentManager //.Query<TermPart, TermPartRecord>() //.Where(x =>newterm.Contains( x.Id)).List(); // List<Int32> termsId=termParts.Select(x=>x.Id).ToList(); var taxonomieList = content.ContentItem.Parts.SelectMany(x => x.Fields.Where(f => f.FieldDefinition.Name == typeof(TaxonomyField).Name)).Cast <TaxonomyField>(); foreach (var singletaxo in taxonomieList) { var thetaxonomy_field = _taxonomyService.GetTaxonomyByName(singletaxo.PartFieldDefinition.Settings["TaxonomyFieldSettings.Taxonomy"]); List <TaxonomyPart> taxonomies_localized = new List <TaxonomyPart>(); taxonomies_localized.Add(thetaxonomy_field); foreach (var tax_local in _localizationService.GetLocalizations(thetaxonomy_field)) { taxonomies_localized.Add(tax_local.ContentItem.As <TaxonomyPart>()); } List <TermPart> nuovitermini = new List <TermPart>(); foreach (var thetaxonomy in taxonomies_localized) { IEnumerable <TermPart> termini = _taxonomyService.GetTerms(thetaxonomy.Id); foreach (var singleTerm in termini) { if (newterm.Contains(singleTerm.Id) || newterm.Contains(thetaxonomy.Id)) { nuovitermini.Add(singleTerm); } } } _taxonomyService.UpdateTerms(content.ContentItem, nuovitermini, singletaxo.Name.ToString()); } // .Parts.FirstOrDefault(x => x.Fields.Any(y => y.Name == "Website")); //var websiteLinkField = websitePart .Fields.FirstOrDefault(x => x.Name == "Website") as LinkField; //websiteLinkField.Value = "http://www.google.com"; //websiteLinkField.Text = "Link to google"; //_orchardServices.ContentManager.Publish(myItem); // ((dynamic)content.ContentItem).CommonPart.Owner = userpart; } catch { messageout = T("Error"); } yield return(messageout); }
private IEnumerable <string> GetRoles(ActivityContext context) { string roles = context.GetState <string>("Roles"); if (String.IsNullOrEmpty(roles)) { return(Enumerable.Empty <string>()); } return(roles.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToList()); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var url = activityContext.GetState <string>("Url"); // Redirect is going to terminate the request, which will cause any pending updates to get rolled back, // so we force a commit in case anything has changed _tm.RequireNew(); _wca.GetContext().HttpContext.Response.Redirect(url); yield return(T("Done")); }
private IEnumerable <string> GetActions(ActivityContext context) { var actions = context.GetState <string>("Actions"); if (String.IsNullOrEmpty(actions)) { return(Enumerable.Empty <string>()); } return(actions.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToList()); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { LocalizedString messageout = T("Success"); try { var context = new SyncContext { Source = workflowContext.Content.ContentItem, //TODO: Source should be choosen by Form tokenized field Target = new Target { Type = activityContext.GetState <string>("TargetType"), EnsureCreating = activityContext.GetState <bool>("Creating"), EnsurePublishing = activityContext.GetState <bool>("Publishing"), EnsureVersioning = activityContext.GetState <bool>("Versioning"), ForceOwnerUpdate = activityContext.GetState <bool>("ForceOwnerUpdate") } }; _syncService.Synchronize(context); //TODO: Add the result ContentItem as WorkflowState and Token in order to have it in next steps; } catch { messageout = T("Error"); } yield return(messageout); }
private bool IsExpired(WorkflowContext workflowContext, ActivityContext activityContext) { DateTime started; if (!workflowContext.HasStateFor(activityContext.Record, "StartedUtc")) { var dateString = activityContext.GetState <string>("Date"); var date = _dateServices.ConvertFromLocalizedString(dateString); started = date ?? _clock.UtcNow; workflowContext.SetStateFor(activityContext.Record, "StartedUtc", started); } else { started = workflowContext.GetStateFor <DateTime>(activityContext.Record, "StartedUtc"); } var amount = activityContext.GetState <int>("Amount"); var type = activityContext.GetState <string>("Unity"); return(_clock.UtcNow > When(started, amount, type)); }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var properties = new Dictionary<string, string> { {"Script", activityContext.GetState<string>("Script")} }; _csharpService.SetParameter("Services", _orchardServices); _csharpService.SetParameter("ContentItem", (dynamic)workflowContext.Content.ContentItem); _csharpService.SetParameter("WorkContext", _workContextAccessor.GetContext()); _csharpService.SetFunction("T", (Func<string, string>)(x => T(x).Text)); var scriptResult = _csharpService.Evaluate(properties["Script"]).ToString(); yield return T(scriptResult); }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var script = activityContext.GetState<string>("Script"); object outcome = null; _csharpService.SetParameter("Services", _orchardServices); _csharpService.SetParameter("ContentItem", (dynamic)workflowContext.Content.ContentItem); _csharpService.SetParameter("WorkContext", _workContextAccessor.GetContext()); _csharpService.SetFunction("T", (Func<string, string>)(x => T(x).Text)); _csharpService.SetFunction("SetOutcome", (Action<object>)(x => outcome = x)); _csharpService.Run(script); yield return T(Convert.ToString(outcome)); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var result = _razorExecuteService.Execute(activityContext.GetState <string>("RazorExecuteActivity_RazorView"), workflowContext.Content, workflowContext.Tokens).Trim(); if (result == null) { result = "Error"; } else if (result == "") { result = "Empty"; } yield return(T(result)); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var body = activityContext.GetState <string>("Body"); var subject = activityContext.GetState <string>("Subject"); var recipients = activityContext.GetState <string>("Recipients"); var replyTo = activityContext.GetState <string>("ReplyTo"); var bcc = activityContext.GetState <string>("Bcc"); var cc = activityContext.GetState <string>("CC"); var notifyReadEmail = activityContext.GetState <bool>("NotifyReadEmail"); var parameters = new Dictionary <string, object> { { "Subject", subject }, { "Body", body }, { "Recipients", recipients }, { "ReplyTo", replyTo }, { "Bcc", bcc }, { "CC", cc }, { "NotifyReadEmail", notifyReadEmail } }; if (string.IsNullOrWhiteSpace(recipients)) { Logger.Error("Email message doesn't have any recipient for Workflow {0}", workflowContext.Record.WorkflowDefinitionRecord.Name); yield return(T("Failed")); } else { var queued = activityContext.GetState <bool>("Queued"); if (!queued) { _messageService.Send(SmtpMessageChannel.MessageType, parameters); } else { var priority = activityContext.GetState <int>("Priority"); _jobsQueueService.Enqueue("IMessageService.Send", new { type = SmtpMessageChannel.MessageType, parameters = parameters }, priority); } yield return(T("Done")); } }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var part = workflowContext.Content.As <WXMsgPart>(); var contentId = activityContext.GetState <int>("contentId"); var contentItem = _contentManager.Get(contentId); switch (contentItem.TypeDefinition.Name) { case "WXImageMsg": Process(() => ((dynamic)contentItem).WXImageMsg.WXMsgImageMediaIdField.Value , () => ((dynamic)contentItem).WXImageMsg.WXMsgImageField.MediaParts[0] , () => ((dynamic)contentItem).WXImageMsg.WXMsgImageMediaCreateAtField.Value , (val) => ((dynamic)contentItem).WXImageMsg.WXMsgImageMediaIdField.Value = val , (val) => ((dynamic)contentItem).WXImageMsg.WXMsgImageMediaCreateAtField.Value = val.ToString() , "image"); break; case "WXMusicMsg": Process(() => ((dynamic)contentItem).WXMusicMsg.WXMsgMusicThumbMediaIdField.Value , () => ((dynamic)contentItem).WXMusicMsg.WXMsgMusicThumbField.MediaParts[0] , () => ((dynamic)contentItem).WXMusicMsg.WXMsgMusicThumbMediaCreateAtField.Value , (val) => ((dynamic)contentItem).WXMusicMsg.WXMsgMusicThumbMediaIdField.Value = val , (val) => ((dynamic)contentItem).WXMusicMsg.WXMsgMusicThumbMediaCreateAtField.Value = val.ToString() , "thumb"); break; case "WXVideoMsg": Process(() => ((dynamic)contentItem).WXVideoMsg.WXMsgVideoMediaIdField.Value , () => ((dynamic)contentItem).WXVideoMsg.WXMsgVideoField.MediaParts[0] , () => ((dynamic)contentItem).WXVideoMsg.WXMsgVideoMediaCreateAtField.Value , (val) => ((dynamic)contentItem).WXVideoMsg.WXMsgVideoMediaIdField.Value = val , (val) => ((dynamic)contentItem).WXVideoMsg.WXMsgVideoMediaCreateAtField.Value = val.ToString() , "video"); break; case "WXVoiceMsg": Process(() => ((dynamic)contentItem).WXVoiceMsg.WXMsgVoiceMediaIdField.Value , () => ((dynamic)contentItem).WXVoiceMsg.WXMsgVoiceField.MediaParts[0] , () => ((dynamic)contentItem).WXVoiceMsg.WXMsgVoiceMediaCreateAtField.Value , (val) => ((dynamic)contentItem).WXVoiceMsg.WXMsgVoiceMediaIdField.Value = val , (val) => ((dynamic)contentItem).WXVoiceMsg.WXMsgVoiceMediaCreateAtField.Value = val.ToString() , "voice"); break; } _weiXinResp.Add(new Tuple <ContentItem, string>(contentItem, part.FromUserName)); yield return(T("Done")); }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var userNameOrEmail = activityContext.GetState<string>("UserNameOrEmail"); var password = activityContext.GetState<string>("Password"); var createPersistentCookie = IsTrueish(activityContext.GetState<string>("CreatePersistentCookie")); var user = workflowContext.Content != null ? workflowContext.Content.As<IUser>() : default(IUser); if (user == null) { if (String.IsNullOrWhiteSpace(userNameOrEmail) || String.IsNullOrWhiteSpace(password)) { yield return T("IncorrectUserNameOrPassword"); yield break; } user = _membershipService.ValidateUser(userNameOrEmail, password); } if (user == null) { yield return T("IncorrectUserNameOrPassword"); yield break; } _authenticationService.SignIn(user, createPersistentCookie); yield return T("Done"); }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var part = workflowContext.Content.As<WXMsgPart>(); var contentId = activityContext.GetState<int>("contentId"); var contentItem = _contentManager.Get(contentId); switch (contentItem.TypeDefinition.Name) { case "WXImageMsg": Process(() => ((dynamic)contentItem).WXImageMsg.WXMsgImageMediaIdField.Value , () => ((dynamic)contentItem).WXImageMsg.WXMsgImageField.MediaParts[0] , () => ((dynamic)contentItem).WXImageMsg.WXMsgImageMediaCreateAtField.Value , (val) => ((dynamic)contentItem).WXImageMsg.WXMsgImageMediaIdField.Value = val , (val) => ((dynamic)contentItem).WXImageMsg.WXMsgImageMediaCreateAtField.Value = val.ToString() , "image"); break; case "WXMusicMsg": Process(() => ((dynamic)contentItem).WXMusicMsg.WXMsgMusicThumbMediaIdField.Value , () => ((dynamic)contentItem).WXMusicMsg.WXMsgMusicThumbField.MediaParts[0] , () => ((dynamic)contentItem).WXMusicMsg.WXMsgMusicThumbMediaCreateAtField.Value , (val) => ((dynamic)contentItem).WXMusicMsg.WXMsgMusicThumbMediaIdField.Value = val , (val) => ((dynamic)contentItem).WXMusicMsg.WXMsgMusicThumbMediaCreateAtField.Value = val.ToString() , "thumb"); break; case "WXVideoMsg": Process(() => ((dynamic)contentItem).WXVideoMsg.WXMsgVideoMediaIdField.Value , () => ((dynamic)contentItem).WXVideoMsg.WXMsgVideoField.MediaParts[0] , () => ((dynamic)contentItem).WXVideoMsg.WXMsgVideoMediaCreateAtField.Value , (val) => ((dynamic)contentItem).WXVideoMsg.WXMsgVideoMediaIdField.Value = val , (val) => ((dynamic)contentItem).WXVideoMsg.WXMsgVideoMediaCreateAtField.Value = val.ToString() , "video"); break; case "WXVoiceMsg": Process(() => ((dynamic)contentItem).WXVoiceMsg.WXMsgVoiceMediaIdField.Value , () => ((dynamic)contentItem).WXVoiceMsg.WXMsgVoiceField.MediaParts[0] , () => ((dynamic)contentItem).WXVoiceMsg.WXMsgVoiceMediaCreateAtField.Value , (val) => ((dynamic)contentItem).WXVoiceMsg.WXMsgVoiceMediaIdField.Value = val , (val) => ((dynamic)contentItem).WXVoiceMsg.WXMsgVoiceMediaCreateAtField.Value = val.ToString() , "voice"); break; } _weiXinResp.Add(new Tuple<ContentItem, string>(contentItem, part.FromUserName)); yield return T("Done"); }
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) { var forms = activityContext.GetState<string>("DynamicForms"); // "" means 'any'. if (String.IsNullOrEmpty(forms)) { return true; } var submission = (FormSubmissionTokenContext)workflowContext.Tokens["FormSubmission"]; if (submission == null) { return false; } var formNames = forms.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); return formNames.Any(x => x == submission.Form.Name); }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var script = activityContext.GetState<string>("Script"); object outcome = null; // Start the script with the new token syntax. script = "// #{ }" + System.Environment.NewLine + script; if (workflowContext.Content != null) _csharpService.SetParameter("ContentItem", (dynamic)workflowContext.Content.ContentItem); _csharpService.SetParameter("Services", _orchardServices); _csharpService.SetParameter("WorkContext", _workContextAccessor.GetContext()); _csharpService.SetParameter("Workflow", workflowContext); _csharpService.SetFunction("T", (Func<string, string>)(x => T(x).Text)); _csharpService.SetFunction("SetOutcome", (Action<object>)(x => outcome = x)); _csharpService.Run(script); yield return T(Convert.ToString(outcome)); }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var script = activityContext.GetState<string>("Script"); if (!String.IsNullOrWhiteSpace(script)) { var submission = (FormSubmissionTokenContext) workflowContext.Tokens["FormSubmission"]; // Start the script with the new token syntax. script = "// #{ }" + System.Environment.NewLine + script; if (workflowContext.Content != null) _csharpService.SetParameter("ContentItem", (dynamic) workflowContext.Content.ContentItem); _csharpService.SetParameter("Services", _orchardServices); _csharpService.SetParameter("WorkContext", _workContextAccessor.GetContext()); _csharpService.SetParameter("Workflow", workflowContext); _csharpService.SetFunction("T", (Func<string, string>) (x => T(x).Text)); _csharpService.SetFunction("AddModelError", (Action<string, LocalizedString>) ((key, message) => submission.ModelState.AddModelError(key, message.Text))); _csharpService.Run(script); } return base.Execute(workflowContext, activityContext); }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var url = activityContext.GetState<string>("Url"); _wca.GetContext().HttpContext.Response.Redirect(url); yield return T("Done"); }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var part = workflowContext.Content.As<WXMsgPart>(); var content = part.Content; var op = activityContext.GetState<string>("operator"); var value = activityContext.GetState<string>("textValue"); switch (op) { case "Equals": if (content == value) { yield return T("条件满足"); yield break; } break; case "NotEquals": if (content != value) { yield return T("条件满足"); yield break; } break; case "Contains": if (content.Contains(value)) { yield return T("条件满足"); yield break; } break; case "NotContains": if (!content.Contains(value)) { yield return T("条件满足"); yield break; } break; case "Starts": if (content.StartsWith(value)) { yield return T("条件满足"); yield break; } break; case "NotStarts": if (!content.StartsWith(value)) { yield return T("条件满足"); yield break; } break; case "Ends": if (content.EndsWith(value)) { yield return T("条件满足"); yield break; } break; case "NotEnds": if (!content.EndsWith(value)) { yield return T("条件满足"); yield break; } break; } yield return T("条件不满足"); }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { double lat1 = 0, lng1 = 0, distance = 0, distance1 = 0; bool flag = true; var part = workflowContext.Content.As<WXMsgPart>(); try { lat1 = activityContext.GetState<double>("lat1"); lng1 = activityContext.GetState<double>("lng1"); distance = activityContext.GetState<double>("distance"); distance1 = _winXinService.GetDistance(lat1, lng1, part.Location_X, part.Location_Y); } catch { flag = false; } if (lat1 + lat1 + distance == 0 || !flag) { yield return T("缺省"); yield break; } if (distance1 <= distance) { yield return T("在范围内"); yield break; } else { yield return T("在范围外"); yield break; } }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var tokens = new Dictionary<string, object> { { "Content", workflowContext.Content }, { SignalActivity.SignalEventName, activityContext.GetState<string>(SignalActivity.SignalEventName) } }; _workflowManager.TriggerEvent(SignalActivity.SignalEventName, workflowContext.Content, () => tokens); yield return T("Done"); }
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) { var part = workflowContext.Content.As<WXMsgPart>(); if (part.MsgType != "event") return false; var type = activityContext.GetState<string>("EventType"); if (type != part.Event) return false; var eventKey = activityContext.GetState<string>("EventKey"); if (!string.IsNullOrWhiteSpace(eventKey) && eventKey != part.EventKey) return false; return true; }
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) { return activityContext.GetState<string>(SignalEventName) == workflowContext.Tokens[SignalEventName].ToString(); }
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) { var url = activityContext.GetState<string>("Url"); return !string.IsNullOrWhiteSpace(url); }