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)
        {
            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);

            CustomAttributes["InitialRequest"] = parameter + "|0";
            CustomAttributes["NextRequest"]    = parameter + "|1";
            CustomAttributes["Content"]        = JsonConvert.SerializeObject(groupMembers);

            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.ListViewBlock",
                Attributes = CustomAttributes
            });
        }
Пример #3
0
        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
            });
        }
Пример #4
0
        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
            });
        }
Пример #5
0
        public override MobileBlock GetMobile(string parameter)
        {
            AvalancheUtilities.SetActionItems(GetAttributeValue("ActionItem"), CustomAttributes, CurrentPerson);

            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
            });
        }
Пример #6
0
        public override MobileBlock GetMobile(string parameter)
        {
            AvalancheUtilities.SetActionItems(GetAttributeValue("ActionItem"), CustomAttributes, CurrentPerson);

            CustomAttributes.Add("Source", AvalancheUtilities.ProcessLava(GetAttributeValue("Image"),
                                                                          CurrentPerson,
                                                                          parameter,
                                                                          GetAttributeValue("EnabledLavaCommands")
                                                                          ));
            CustomAttributes.Add("Aspect", GetAttributeValue("Aspect"));

            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.ImageBlock",
                Attributes = CustomAttributes
            });
        }
Пример #7
0
        public override MobileBlock GetMobile(string parameter)
        {
            AvalancheUtilities.SetActionItems(GetAttributeValue("ActionItem"),
                                              CustomAttributes,
                                              CurrentPerson, AvalancheUtilities.GetMergeFields(CurrentPerson),
                                              GetAttributeValue("EnabledLavaCommands"),
                                              parameter);

            CustomAttributes["Text"] = AvalancheUtilities.ProcessLava(GetAttributeValue("Text"),
                                                                      CurrentPerson,
                                                                      parameter,
                                                                      GetAttributeValue("EnabledLavaCommands"));

            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.IconBlock",
                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 paramater)
        {
            AvalancheUtilities.SetActionItems(GetAttributeValue("ActionItem"), CustomAttributes, CurrentPerson);
            var valueGuid = GetAttributeValue("Component");
            var value     = DefinedValueCache.Read(valueGuid);

            if (value != null)
            {
                CustomAttributes["Component"] = value.GetAttributeValue("ComponentType");
            }

            CustomAttributes["Content"]        = GetContent();
            CustomAttributes["InitialRequest"] = "Refresh";

            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.ListViewBlock",
                Attributes = CustomAttributes
            });
        }
Пример #10
0
        public override bool Execute(RockContext rockContext, WorkflowAction action, object entity, out List <string> errorMessages)
        {
            errorMessages = new List <string>();

            var actionItemValue = GetAttributeValue(action, "ActionType");

            var actionDictionary = new Dictionary <string, string>();

            AvalancheUtilities.SetActionItems(actionItemValue, actionDictionary, action.Activity?.AssignedPersonAlias?.Person, GetMergeFields(action));


            var  processOpt      = GetAttributeValue(action, "ProcessingOptions");
            bool canSendRedirect = actionDictionary.ContainsKey("ActionType") && actionDictionary["ActionType"] != "0" && HttpContext.Current != null;

            if (canSendRedirect)
            {
                HttpContext.Current.Response.AddHeader("ActionType", actionDictionary["ActionType"]);

                if (actionDictionary.ContainsKey("Resource"))
                {
                    HttpContext.Current.Response.AddHeader("Resource", actionDictionary["Resource"]);
                }

                if (actionDictionary.ContainsKey("Parameter"))
                {
                    HttpContext.Current.Response.AddHeader("Parameter", actionDictionary["Parameter"]);
                }
            }

            if (processOpt == "1")
            {
                // 1) if HttpContext.Current is null, this workflow action might be running as a job (there is no browser session associated), so Redirect couldn't have been sent to a browser
                // 2) if there was no url specified, the redirect wouldn't have executed either
                return(canSendRedirect);
            }
            else
            {
                return(processOpt != "2");
            }
        }
Пример #11
0
        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
            });
        }
Пример #12
0
        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
            });
        }
Пример #13
0
        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
            });
        }