public override MobileBlock GetMobile(string parameter) { AvalancheUtilities.SetActionItems(GetAttributeValue("ActionItem"), CustomAttributes, CurrentPerson, AvalancheUtilities.GetMergeFields(CurrentPerson), GetAttributeValue("EnabledLavaCommands"), parameter); var valueGuid = GetAttributeValue("Component"); var value = DefinedValueCache.Read(valueGuid); if (value != null) { CustomAttributes["Component"] = value.GetAttributeValue("ComponentType"); } CustomAttributes["Content"] = GetContent(parameter); CustomAttributes["InitialRequest"] = parameter; return(new MobileBlock() { BlockType = "Avalanche.Blocks.ListViewBlock", Attributes = CustomAttributes }); }
public override MobileBlock GetMobile(string parameter) { AvalancheUtilities.SetActionItems(GetAttributeValue("ActionItem"), CustomAttributes, CurrentPerson, AvalancheUtilities.GetMergeFields(CurrentPerson), GetAttributeValue("EnabledLavaCommands"), parameter); if (!string.IsNullOrWhiteSpace(GetAttributeValue("Text"))) { CustomAttributes["Text"] = GetAttributeValue("Text"); } if (GetAttributeValue("AspectRatio").AsDouble() != 0) { CustomAttributes["AspectRatio"] = GetAttributeValue("AspectRatio"); } CustomAttributes.Add("Source", AvalancheUtilities.ProcessLava(GetAttributeValue("Image"), CurrentPerson, parameter, GetAttributeValue("EnabledLavaCommands") )); return(new MobileBlock() { BlockType = "Avalanche.Blocks.TextOverImage", Attributes = CustomAttributes }); }
public override MobileBlock GetMobile(string parameter) { var groups = GetGroups(); CustomAttributes["Content"] = AvalancheUtilities.ProcessLava( GetAttributeValue("NoGroupsMarkdown"), CurrentPerson, parameter, GetAttributeValue("EnabledLavaCommands")); if (!groups.Any()) { return(new MobileBlock() { BlockType = "Avalanche.Blocks.MarkdownDetail", Attributes = CustomAttributes }); } AvalancheUtilities.SetActionItems(GetAttributeValue("ActionItem"), CustomAttributes, CurrentPerson, AvalancheUtilities.GetMergeFields(CurrentPerson), GetAttributeValue("EnabledLavaCommands"), parameter); var valueGuid = GetAttributeValue("Component"); var value = DefinedValueCache.Get(valueGuid); if (value != null) { CustomAttributes["Component"] = value.GetAttributeValue("ComponentType"); } CustomAttributes["InitialRequest"] = parameter; //Request for pull to refresh Dictionary <string, object> mergeObjects = new Dictionary <string, object> { { "Groups", groups } }; var content = AvalancheUtilities.ProcessLava(GetAttributeValue("Lava"), CurrentPerson, parameter, GetAttributeValue("EnabledLavaCommands"), mergeObjects); content = content.Replace("\\", "\\\\"); CustomAttributes["Content"] = content; return(new MobileBlock() { BlockType = "Avalanche.Blocks.ListViewBlock", Attributes = CustomAttributes }); }
public override MobileBlock GetMobile(string parameter) { AvalancheUtilities.SetActionItems(GetAttributeValue("ActionItem"), CustomAttributes, CurrentPerson, AvalancheUtilities.GetMergeFields(CurrentPerson), GetAttributeValue("EnabledLavaCommands"), parameter); CustomAttributes.Add("Text", AvalancheUtilities.ProcessLava(GetAttributeValue("Text"), CurrentPerson, parameter)); CustomAttributes.Add("Icon", AvalancheUtilities.ProcessLava(GetAttributeValue("Icon"), CurrentPerson, parameter)); return(new MobileBlock() { BlockType = "Avalanche.Blocks.IconButton", Attributes = CustomAttributes }); }
public override MobileBlock GetMobile(string parameter) { _firstDayOfWeek = GetAttributeValue("StartofWeekDay").ConvertToEnum <DayOfWeek>(); var eventCalendar = new EventCalendarService(new RockContext()).Get(GetAttributeValue("EventCalendar").AsGuid()); if (eventCalendar != null) { _calendarId = eventCalendar.Id; _calendarName = eventCalendar.Name; } CampusPanelOpen = GetAttributeValue("CampusFilterDisplayMode") == "3"; CampusPanelClosed = GetAttributeValue("CampusFilterDisplayMode") == "4"; CategoryPanelOpen = !String.IsNullOrWhiteSpace(GetAttributeValue("FilterCategories")) && GetAttributeValue("CategoryFilterDisplayMode") == "3"; CategoryPanelClosed = !String.IsNullOrWhiteSpace(GetAttributeValue("FilterCategories")) && GetAttributeValue("CategoryFilterDisplayMode") == "4"; AvalancheUtilities.SetActionItems(GetAttributeValue("ActionItem"), CustomAttributes, CurrentPerson, AvalancheUtilities.GetMergeFields(CurrentPerson), GetAttributeValue("EnabledLavaCommands"), parameter); var valueGuid = GetAttributeValue("Component"); var value = DefinedValueCache.Read(valueGuid); if (value != null) { CustomAttributes["Component"] = value.GetAttributeValue("ComponentType"); } var data = BindData(); CustomAttributes["Content"] = data; CustomAttributes["InitialRequest"] = parameter; return(new MobileBlock() { BlockType = "Avalanche.Blocks.ListViewBlock", Attributes = CustomAttributes }); }
public override MobileBlock GetMobile(string parameter) { var valueGuid = GetAttributeValue("Component"); var value = DefinedValueCache.Read(valueGuid); if (value != null) { CustomAttributes["Component"] = value.GetAttributeValue("ComponentType"); } var groupMembers = GetGroupMembers(parameter, 0); if (groupMembers == null || !groupMembers.Any()) { return(new MobileBlock() { BlockType = "Avalanche.Blocks.Null", Attributes = CustomAttributes }); } AvalancheUtilities.SetActionItems(GetAttributeValue("ActionItem"), CustomAttributes, CurrentPerson, AvalancheUtilities.GetMergeFields(CurrentPerson), GetAttributeValue("EnabledLavaCommands"), parameter); CustomAttributes["InitialRequest"] = parameter + "|0"; CustomAttributes["NextRequest"] = parameter + "|1"; CustomAttributes["Content"] = JsonConvert.SerializeObject(groupMembers); return(new MobileBlock() { BlockType = "Avalanche.Blocks.ListViewBlock", Attributes = CustomAttributes }); }
public override MobileBlockResponse HandleRequest(string request, Dictionary <string, string> Body) { body = Body; RockContext rockContext = new RockContext(); PrayerRequestService prayerRequestService = new PrayerRequestService(rockContext); PrayerRequest prayerRequest = new PrayerRequest(); prayerRequest.EnteredDateTime = RockDateTime.Now; prayerRequest.FirstName = GetItem("firstName"); prayerRequest.LastName = GetItem("lastName"); prayerRequest.Text = GetItem("request"); prayerRequest.RequestedByPersonAliasId = CurrentPersonAliasId; if (!string.IsNullOrWhiteSpace(GetItem("campus"))) { prayerRequest.CampusId = GetItem("campus").AsInteger(); } bool isAutoApproved = GetAttributeValue("EnableAutoApprove").AsBoolean(); if (isAutoApproved) { prayerRequest.ApprovedByPersonAliasId = CurrentPersonAliasId; prayerRequest.ApprovedOnDateTime = RockDateTime.Now; var expireDays = GetAttributeValue("ExpireDays").AsDouble(); prayerRequest.ExpirationDate = RockDateTime.Now.AddDays(expireDays); } //Category if (GetItem("category").AsInteger() != 0) { prayerRequest.CategoryId = GetItem("category").AsInteger(); } else { Guid defaultCategoryGuid = GetAttributeValue("DefaultCategory").AsGuid(); var defaultCategory = CategoryCache.Read(defaultCategoryGuid); if (defaultCategory != null) { prayerRequest.CategoryId = defaultCategory.Id; } } if (GetItem("urgent").AsBoolean()) { prayerRequest.IsUrgent = true; } else { prayerRequest.IsUrgent = false; } if (GetItem("allowComments").AsBoolean()) { prayerRequest.AllowComments = true; } else { prayerRequest.AllowComments = false; } if (GetItem("allowPublication").AsBoolean()) { prayerRequest.IsPublic = true; } else { prayerRequest.IsPublic = false; } prayerRequestService.Add(prayerRequest); rockContext.SaveChanges(); Guid?workflowTypeGuid = GetAttributeValue("Workflow").AsGuidOrNull(); if (workflowTypeGuid.HasValue) { prayerRequest.LaunchWorkflow(workflowTypeGuid, prayerRequest.Name); } AvalancheUtilities.SetActionItems(GetAttributeValue("ActionItem"), CustomAttributes, CurrentPerson, AvalancheUtilities.GetMergeFields(CurrentPerson)); var response = new FormResponse { Success = true, Message = GetAttributeValue("SaveSuccessText") }; if (CustomAttributes.ContainsKey("ActionType") && CustomAttributes["ActionType"] != "0") { response.ActionType = CustomAttributes["ActionType"]; } if (CustomAttributes.ContainsKey("Resource")) { response.Resource = CustomAttributes["Resource"]; } if (CustomAttributes.ContainsKey("Parameter")) { response.Parameter = CustomAttributes["Parameter"]; } return(new MobileBlockResponse() { Request = request, Response = JsonConvert.SerializeObject(response), TTL = 0 }); }
public override MobileBlockResponse HandleRequest(string request, Dictionary <string, string> Body) { if (Body.ContainsKey("__WorkflowId__")) { int id = 0; int.TryParse(Body["__WorkflowId__"], out id); if (id > 0) { WorkflowId = id; } } if (Body.ContainsKey("__ActionTypeId__")) { int id = 0; int.TryParse(Body["__ActionTypeId__"], out id); if (id > 0) { ActionTypeId = id; } } HydrateObjects(); var response = new FormResponse(); SetFormValues(Body); if (!string.IsNullOrWhiteSpace(request) && _workflow != null && _actionType != null && _actionType.WorkflowForm != null && _activity != null && _action != null) { var mergeFields = AvalancheUtilities.GetMergeFields(this.CurrentPerson); mergeFields.Add("Action", _action); mergeFields.Add("Activity", _activity); mergeFields.Add("Workflow", _workflow); Guid activityTypeGuid = Guid.Empty; string responseText = "Your information has been submitted successfully."; foreach (var action in _actionType.WorkflowForm.Actions.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)) { var actionDetails = action.Split(new char[] { '^' }); if (actionDetails.Length > 0 && actionDetails[0] == request) { if (actionDetails.Length > 2) { activityTypeGuid = actionDetails[2].AsGuid(); } if (actionDetails.Length > 3 && !string.IsNullOrWhiteSpace(actionDetails[3])) { responseText = actionDetails[3].ResolveMergeFields(mergeFields); } break; } } _action.MarkComplete(); _action.FormAction = request; _action.AddLogEntry("Form Action Selected: " + _action.FormAction); if (_action.ActionTypeCache.IsActivityCompletedOnSuccess) { _action.Activity.MarkComplete(); } if (_actionType.WorkflowForm.ActionAttributeGuid.HasValue) { var attribute = AttributeCache.Read(_actionType.WorkflowForm.ActionAttributeGuid.Value); if (attribute != null) { IHasAttributes item = null; if (attribute.EntityTypeId == _workflow.TypeId) { item = _workflow; } else if (attribute.EntityTypeId == _activity.TypeId) { item = _activity; } if (item != null) { item.SetAttributeValue(attribute.Key, request); } } } if (!activityTypeGuid.IsEmpty()) { var activityType = _workflowType.ActivityTypes.Where(a => a.Guid.Equals(activityTypeGuid)).FirstOrDefault(); if (activityType != null) { WorkflowActivity.Activate(activityType, _workflow); } } List <string> errorMessages; if (_workflowService.Process(_workflow, out errorMessages)) { int?previousActionId = null; if (_action != null) { previousActionId = _action.Id; } ActionTypeId = null; _action = null; _actionType = null; _activity = null; if (HttpContext.Current.Response.Headers.GetValues("ActionType") != null && HttpContext.Current.Response.Headers.GetValues("ActionType").Any()) { response.Success = true; response.ActionType = HttpContext.Current.Response.Headers.GetValues("ActionType").FirstOrDefault(); if (HttpContext.Current.Response.Headers.GetValues("Resource") != null) { response.Resource = HttpContext.Current.Response.Headers.GetValues("Resource").FirstOrDefault(); } if (HttpContext.Current.Response.Headers.GetValues("Parameter") != null) { response.Parameter = HttpContext.Current.Response.Headers.GetValues("Parameter").FirstOrDefault(); } } else { if (HydrateObjects() && _action != null && _action.Id != previousActionId) { response.FormElementItems = BuildForm(true); response.Success = true; } else { response.Message = responseText; response.Success = true; } } } else { response.Message = "Workflow Processing Error(s): \n"; response.Message += errorMessages.AsDelimited("\n", null, false); } } return(new MobileBlockResponse() { Request = request, Response = JsonConvert.SerializeObject(response), TTL = 0 }); }
private List <FormElementItem> BuildForm(bool setValues) { var formElements = new List <FormElementItem>(); var mergeFields = AvalancheUtilities.GetMergeFields(CurrentPerson); mergeFields.Add("Action", _action); mergeFields.Add("Activity", _activity); mergeFields.Add("Workflow", _workflow); var form = _actionType.WorkflowForm; foreach (var formAttribute in form.FormAttributes.OrderBy(a => a.Order)) { if (formAttribute.IsVisible) { var attribute = AttributeCache.Read(formAttribute.AttributeId); string value = attribute.DefaultValue; if (_workflow != null && _workflow.AttributeValues.ContainsKey(attribute.Key) && _workflow.AttributeValues[attribute.Key] != null) { value = _workflow.AttributeValues[attribute.Key].Value; } // Now see if the key is in the activity attributes so we can get it's value else if (_activity != null && _activity.AttributeValues.ContainsKey(attribute.Key) && _activity.AttributeValues[attribute.Key] != null) { value = _activity.AttributeValues[attribute.Key].Value; } value = attribute.FieldType.Field.EncodeAttributeValue(attribute, value, formAttribute.IsReadOnly); if (!string.IsNullOrWhiteSpace(formAttribute.PreHtml)) { formElements.Add(new FormElementItem { Type = FormElementType.Label, Value = formAttribute.PreHtml.ResolveMergeFields(mergeFields) }); } if (formAttribute.IsReadOnly) { formElements.Add(new FormElementItem { Type = FormElementType.Label, Value = value, Label = formAttribute.HideLabel ? string.Empty : attribute.Name }); } else { var formElement = attribute.FieldType.Field.GetMobileElement(attribute); formElement.Key = attribute.Key; formElement.Label = formAttribute.HideLabel ? string.Empty : attribute.Name; formElement.Required = formAttribute.IsRequired; formElement.Value = value; formElements.Add(formElement); } if (!string.IsNullOrWhiteSpace(formAttribute.PostHtml)) { formElements.Add(new FormElementItem { Type = FormElementType.Label, Value = formAttribute.PostHtml.ResolveMergeFields(mergeFields) }); } } } foreach (var action in form.Actions.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)) { var details = action.Split(new char[] { '^' }); if (details.Length > 0) { formElements.Add(new FormElementItem { Type = FormElementType.Button, Value = details[0].EscapeQuotes(), Label = details[0].EscapeQuotes(), Key = details[0].EscapeQuotes() }); } } formElements.Add(new FormElementItem { Type = FormElementType.Hidden, Key = "__WorkflowId__", Value = _workflow.Id.ToString() }); formElements.Add(new FormElementItem { Type = FormElementType.Hidden, Key = "__ActionTypeId__", Value = _action.ActionTypeId.ToString() }); return(formElements); }
public override MobileBlock GetMobile(string parameter) { if (CurrentPerson == null) { return(new MobileBlock() { BlockType = "Avalanche.Blocks.Null", Attributes = CustomAttributes }); } AvalancheUtilities.SetActionItems(GetAttributeValue("ActionItem"), CustomAttributes, CurrentPerson, AvalancheUtilities.GetMergeFields(CurrentPerson), GetAttributeValue("EnabledLavaCommands"), parameter); var valueGuid = GetAttributeValue("Component"); var value = DefinedValueCache.Get(valueGuid); if (value != null) { CustomAttributes["Component"] = value.GetAttributeValue("ComponentType"); } CustomAttributes["InitialRequest"] = parameter; //Request for pull to refresh var family = new List <ListElement>(); family.Add( new ListElement { Image = GlobalAttributesCache.Value("InternalApplicationRoot") + CurrentPerson.PhotoUrl, Id = CurrentPersonAlias.Guid.ToString(), Title = CurrentPerson.FullName, Description = GetInfo(CurrentPerson, true) }); foreach (var member in CurrentPerson.GetFamilyMembers()) { family.Add(new ListElement { Image = GlobalAttributesCache.Value("InternalApplicationRoot") + member.Person.PhotoUrl, Id = member.Person.PrimaryAlias.Guid.ToString(), Title = member.Person.FullName, Description = GetInfo(member.Person, false) }); } family.Add(new ListElement { Id = "0", Title = "Add New Family Member" }); var additionalChanges = GetAttributeValue("AdditionalChangesLink"); var additionalChangesPage = PageCache.Get(additionalChanges); if (additionalChangesPage != null) { family.Add(new ListElement { ActionType = "1", Resource = additionalChangesPage.Id.ToString(), Title = "Request Additional Changes", Id = "1" }); } CustomAttributes["Content"] = JsonConvert.SerializeObject(family); return(new MobileBlock() { BlockType = "Avalanche.Blocks.ListViewBlock", Attributes = CustomAttributes }); }