Example #1
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
            });
        }
        public override MobileBlock GetMobile(string parameter)
        {
            CustomAttributes.Add("Source", AvalancheUtilities.ProcessLava(GetAttributeValue("Source"),
                                                                          CurrentPerson,
                                                                          parameter,
                                                                          GetAttributeValue("EnabledLavaCommands")
                                                                          ));

            CustomAttributes.Add("Artist", AvalancheUtilities.ProcessLava(GetAttributeValue("Artist"),
                                                                          CurrentPerson,
                                                                          parameter,
                                                                          GetAttributeValue("EnabledLavaCommands")
                                                                          ));

            CustomAttributes.Add("Title", AvalancheUtilities.ProcessLava(GetAttributeValue("Title"),
                                                                         CurrentPerson,
                                                                         parameter,
                                                                         GetAttributeValue("EnabledLavaCommands")
                                                                         ));

            CustomAttributes.Add("AutoPlay", GetAttributeValue("AutoPlay"));
            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.AudioPlayerBlock",
                Attributes = CustomAttributes
            });
        }
        public override MobileBlock GetMobile(string parameter)
        {
            var pageList = new List <string>();
            var pages    = GetAttributeValue("PagesToPreload").ToKeyValuePairList();

            foreach (var item in pages)
            {
                var page = "/api/avalanche/page/" +
                           item.Key + "/" +
                           AvalancheUtilities.ProcessLava(( string )item.Value,
                                                          CurrentPerson,
                                                          parameter,
                                                          GetAttributeValue("EnabledLavaCommands")
                                                          );
                pageList.Add(page);
            }

            CustomAttributes.Add("Resources", string.Join("|", pageList));

            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.Preload",
                Attributes = CustomAttributes
            });
        }
 private string GetContent(string parameter = "")
 {
     return(AvalancheUtilities.ProcessLava(GetAttributeValue("Lava"),
                                           CurrentPerson,
                                           parameter,
                                           GetAttributeValue("EnabledLavaCommands")));
 }
 /// <summary>
 /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
 /// </summarysni>
 /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
 protected override void OnLoad(EventArgs e)
 {
     imgImage.ImageUrl = AvalancheUtilities.ProcessLava(GetAttributeValue("Image"),
                                                        CurrentPerson,
                                                        "",
                                                        GetAttributeValue("EnabledLavaCommands"));
     lLava.Text = GetAttributeValue("Image");
 }
 /// <summary>
 /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
 /// </summary>
 /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
 protected override void OnLoad(EventArgs e)
 {
     lLava.Text         = GetAttributeValue("Lava");
     lLavaRendered.Text = AvalancheUtilities.ProcessLava(GetAttributeValue("Lava"),
                                                         CurrentPerson,
                                                         enabledLavaCommands: GetAttributeValue("EnabledLavaCommands"))
                          .ConvertMarkdownToHtml();
 }
Example #7
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
            });
        }
Example #8
0
        public override MobileBlock GetMobile(string parameter)
        {
            CustomAttributes["Text"] = AvalancheUtilities.ProcessLava(GetAttributeValue("Text"),
                                                                      CurrentPerson,
                                                                      parameter,
                                                                      GetAttributeValue("EnabledLavaCommands"));

            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.LabelBlock",
                Attributes = CustomAttributes
            });
        }
        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
            });
        }
        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
            });
        }
Example #11
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
            });
        }
Example #12
0
        public override MobileBlockResponse HandleRequest(string request, Dictionary <string, string> Body)
        {
            var groups = GetGroups();
            Dictionary <string, object> mergeObjects = new Dictionary <string, object>
            {
                { "Groups", groups }
            };
            var content = AvalancheUtilities.ProcessLava(GetAttributeValue("Lava"),
                                                         CurrentPerson,
                                                         request,
                                                         GetAttributeValue("EnabledLavaCommands"),
                                                         mergeObjects);

            content = content.Replace("\\", "\\\\");
            var response = "{\"Content\": " + content + "}";

            return(new MobileBlockResponse()
            {
                Request = request,
                Response = response,
                TTL = PageCache.OutputCacheDuration
            });
        }
Example #13
0
        private string GenerateCode(string resource)
        {
            if (resource == null || resource.Length != 10)
            {
                return("Please enter a 10 digit phone number.");
            }

            RockContext        rockContext        = new RockContext();
            PhoneNumberService phoneNumberService = new PhoneNumberService(rockContext);
            var numberOwners = phoneNumberService.Queryable()
                               .Where(pn => pn.Number == resource)
                               .Select(pn => pn.Person)
                               .DistinctBy(p => p.Id)
                               .ToList();

            if (numberOwners.Count == 0)
            {
                return("0|We are sorry, we could not find your phone number in our records.");
            }

            if (numberOwners.Count > 1)
            {
                return("2|We are sorry, we dected more than one person with your number in our records.");
            }

            var person = numberOwners.FirstOrDefault();

            UserLoginService userLoginService = new UserLoginService(rockContext);
            var userLogin = userLoginService.Queryable()
                            .Where(u => u.UserName == ("__PHONENUMBER__+1" + resource))
                            .FirstOrDefault();

            if (userLogin == null)
            {
                var entityTypeId = EntityTypeCache.Read("Avalanche.Security.Authentication.PhoneNumber").Id;

                userLogin = new UserLogin()
                {
                    UserName     = "******" + resource,
                    EntityTypeId = entityTypeId,
                };
                userLoginService.Add(userLogin);
            }

            userLogin.PersonId = person.Id;
            userLogin.LastPasswordChangedDateTime = Rock.RockDateTime.Now;
            userLogin.FailedPasswordAttemptWindowStartDateTime = Rock.RockDateTime.Now;
            userLogin.FailedPasswordAttemptCount = 0;
            userLogin.IsConfirmed = true;
            userLogin.Password    = new Random().Next(100000, 999999).ToString();

            rockContext.SaveChanges();

            var workflowName = string.Format("{0} ({1})", person.FullName, resource);
            var atts         = new Dictionary <string, string>
            {
                { "PhoneNumber", resource },
                { "Password", userLogin.Password }
            };

            var recipients = new List <RecipientData>();

            recipients.Add(new RecipientData(resource));

            var smsMessage = new RockSMSMessage();

            smsMessage.SetRecipients(recipients);

            // Get the From value
            Guid?fromGuid = GetAttributeValue("From").AsGuidOrNull();

            if (fromGuid.HasValue)
            {
                var fromValue = DefinedValueCache.Read(fromGuid.Value, rockContext);
                if (fromValue != null)
                {
                    smsMessage.FromNumber = DefinedValueCache.Read(fromValue.Id);
                }
            }

            var mergeObjects = new Dictionary <string, object> {
                { "password", userLogin.Password }
            };
            var message = AvalancheUtilities.ProcessLava(GetAttributeValue("Message"), CurrentPerson, mergeObjects: mergeObjects);

            smsMessage.Message = message;
            smsMessage.Send();

            return("1|Success!");
        }