Esempio n. 1
0
        /// <summary>
        /// Adds the pages to update package.
        /// </summary>
        /// <param name="package">The package.</param>
        /// <param name="applicationRoot">The application root.</param>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="pages">The pages.</param>
        /// <param name="depth">The depth.</param>
        private static void AddPagesToUpdatePackage(UpdatePackage package, string applicationRoot, RockContext rockContext, IEnumerable <PageCache> pages, int depth = 0)
        {
            foreach (var page in pages)
            {
                var additionalPageSettings = page.AdditionalSettings.FromJsonOrNull <AdditionalPageSettings>() ?? new AdditionalPageSettings();

                var mobilePage = new MobilePage
                {
                    LayoutGuid         = page.Layout.Guid,
                    DisplayInNav       = page.DisplayInNavWhen == DisplayInNavWhen.WhenAllowed,
                    Title              = page.PageTitle,
                    PageGuid           = page.Guid,
                    Order              = page.Order,
                    ParentPageGuid     = page.ParentPage?.Guid,
                    IconUrl            = page.IconBinaryFileId.HasValue ? $"{ applicationRoot }GetImage.ashx?Id={ page.IconBinaryFileId.Value }" : null,
                    LavaEventHandler   = additionalPageSettings.LavaEventHandler,
                    DepthLevel         = depth,
                    AuthorizationRules = string.Join(",", GetOrderedExplicitAuthorizationRules(page))
                };

                package.Pages.Add(mobilePage);

                var childPages = page.GetPages(rockContext);
                if (childPages.Any())
                {
                    AddPagesToUpdatePackage(package, applicationRoot, rockContext, childPages, depth + 1);
                }
            }
        }
        protected String GetDefaultLabel(int labelID)
        {
            if ((labelID < 0) || (labelID >= LabelIDs.Length))
            {
                throw new ArgumentException(System.Web.Mobile.SR.GetString(
                                                System.Web.Mobile.SR.ControlAdapter_InvalidDefaultLabel));
            }

            MobilePage page = Page;

            if (page != null)
            {
                ControlAdapter pageAdapter = (ControlAdapter)page.Adapter;
                if (pageAdapter._defaultLabels == null)
                {
                    pageAdapter._defaultLabels = new String[LabelIDs.Length];
                }

                String labelValue = pageAdapter._defaultLabels[labelID];
                if (labelValue == null)
                {
                    labelValue = System.Web.Mobile.SR.GetString(LabelIDs[labelID]);
                    pageAdapter._defaultLabels[labelID] = labelValue;
                }

                return(labelValue);
            }
            else
            {
                return(System.Web.Mobile.SR.GetString(LabelIDs[labelID]));
            }
        }
 /// <include file='doc\UpWmlMobileTextWriter.uex' path='docs/doc[@for="UpWmlMobileTextWriter.UpWmlMobileTextWriter"]/*' />
 public UpWmlMobileTextWriter(TextWriter writer, MobileCapabilities device, MobilePage page)
     : base(writer, device, page)
 {
     _screenWidth           = device.ScreenCharactersWidth;
     _screenHeight          = device.ScreenCharactersHeight;
     _canRenderMixedSelects = device.CanRenderMixedSelects;
 }
Esempio n. 4
0
        public void TEST_4()
        {
            driver.Navigate().GoToUrl(this.mainPageUrl);
            MainPage mainPage = new MainPage(driver);

            mainPage.setRuLanguage();
            string expectedTitle = "Hotline - сравнить цены в интернет-магазинах Украины";

            Assert.AreEqual(expectedTitle, mainPage.getTitle(), "Title differs");

            MobilePage mobilePage  = mainPage.selectMobile();
            string     mobileTitle = "Мобильные телефоны, электроника, аксессуары | Hotline";

            Assert.AreEqual(mobileTitle, mobilePage.getTitle(), "Title differs");

            PowerBankPage powerBankPage  = mobilePage.selectPowerBank();
            string        powerBankTitle = "Портативные зарядные устройства и повербанки (powerbank) | Hotline";

            Assert.AreEqual(powerBankTitle, powerBankPage.getTitle(), "Title differs");

            int filterMax = 1000;

            powerBankPage.setPriceFilter(filterMax).confirmPriceFilter();
            powerBankPage.confirmVolumeFilter();
        }
Esempio n. 5
0
        public MobilePage GetPage(int id, string parameter = "")
        {
            var person = GetPerson();

            if (!HttpContext.Current.Items.Contains("CurrentPerson"))
            {
                HttpContext.Current.Items.Add("CurrentPerson", person);
            }

            var pageCache = PageCache.Read(id);

            if (!pageCache.IsAuthorized(Authorization.VIEW, person))
            {
                return(new MobilePage());
            }

            SavePageViewInteraction(pageCache, person);

            string theme      = pageCache.Layout.Site.Theme;
            string layout     = pageCache.Layout.FileName;
            string layoutPath = PageCache.FormatPath(theme, layout);

            Rock.Web.UI.RockPage cmsPage = (Rock.Web.UI.RockPage)BuildManager.CreateInstanceFromVirtualPath(layoutPath, typeof(Rock.Web.UI.RockPage));

            MobilePage mobilePage = new MobilePage();

            mobilePage.Layout    = AvalancheUtilities.GetLayout(pageCache.Layout.Name);
            mobilePage.Title     = pageCache.PageTitle;
            mobilePage.ShowTitle = pageCache.PageDisplayTitle;
            foreach (var attribute in pageCache.AttributeValues)
            {
                mobilePage.Attributes.Add(attribute.Key, attribute.Value.ValueFormatted);
            }
            foreach (var block in pageCache.Blocks)
            {
                if (block.IsAuthorized(Authorization.VIEW, person))
                {
                    var blockCache = BlockCache.Read(block.Id);
                    try
                    {
                        var control = ( RockBlock )cmsPage.TemplateControl.LoadControl(blockCache.BlockType.Path);
                        if (control is RockBlock && control is IMobileResource)
                        {
                            control.SetBlock(pageCache, blockCache);
                            var mobileResource = control as IMobileResource;
                            var mobileBlock    = mobileResource.GetMobile(parameter);
                            mobileBlock.BlockId = blockCache.Id;
                            mobileBlock.Zone    = blockCache.Zone;
                            mobilePage.Blocks.Add(mobileBlock);
                        }
                    }
                    catch (Exception e)
                    {
                        ExceptionLogService.LogException(e, HttpContext.Current);
                    }
                }
            }
            HttpContext.Current.Response.Headers.Set("TTL", pageCache.OutputCacheDuration.ToString());
            return(mobilePage);
        }
Esempio n. 6
0
        internal static void RedirectToUrl(HttpContext context, String url, bool endResponse)
        {
            //do not add __redir=1 if it already exists
            int i = url.IndexOf(QueryStringAssignment);

            if (i == -1)
            {
                i = url.IndexOf('?');
                if (i >= 0)
                {
                    url = url.Insert(i + 1, _redirectQueryStringInline);
                }
                else
                {
                    url = String.Concat(url, _redirectQueryString);
                }
            }
            AllowRedirection(context);
            MobilePage page = context.Handler as MobilePage;

            if ((page != null) && (!page.Device.SupportsRedirectWithCookie))
            {
                String formsAuthCookieName = Security.FormsAuthentication.FormsCookieName;
                if (formsAuthCookieName != String.Empty)
                {
                    context.Response.Cookies.Remove(formsAuthCookieName);
                }
            }
            context.Response.Redirect(url, endResponse);
        }
Esempio n. 7
0
        public async Task <ActionResult <MobilePage> > PostMobilePage(MobilePage mobilePage)
        {
            _context.Pages.Add(mobilePage);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMobilePage", new { id = mobilePage.MobilePageId }, mobilePage));
        }
Esempio n. 8
0
        public async Task <IActionResult> PutMobilePage(Guid id, MobilePage mobilePage)
        {
            if (id != mobilePage.Guid)
            {
                return(BadRequest());
            }

            _context.Entry(mobilePage).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MobilePageExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 9
0
        public static void SignOut()
        {
            MobilePage page = HttpContext.Current.Handler as MobilePage;

            if (page != null)
            {
                page.Adapter.PersistCookielessData = false;
                if (!page.Device.SupportsEmptyStringInCookieValue)
                {
                    // Desktop signout with empty cookie value is not handled properly by the device.
                    InternalSignOut();
                    return;
                }
            }
            FormsAuthentication.SignOut();
        }
Esempio n. 10
0
        public MenuPage(MobilePage page)
        {
            InitializeComponent();

            var layoutManager = new Utilities.LayoutManager(page.Layout);
            var layout        = layoutManager.Content;

            //Modify the page with attributes
            AttributeHelper.ApplyTranslation(this, page.Attributes);

            //Put blocks into the layout
            foreach (var block in page.Blocks)
            {
                var blockType = Type.GetType(block.BlockType);
                if (blockType != null)
                {
                    IRenderable mobileBlock = ( IRenderable )Activator.CreateInstance(blockType);
                    mobileBlock.Attributes = block.Attributes;

                    //Setup postback handler if required
                    if (mobileBlock is IHasBlockMessenger)
                    {
                        var hasPostbackBlock = mobileBlock as IHasBlockMessenger;
                        hasPostbackBlock.MessageHandler = new BlockMessenger(block.BlockId);
                    }

                    var zone = layoutManager.GetElement(block.Zone);

                    if (zone != null)
                    {
                        try
                        {
                            var renderedBlock = mobileBlock.Render();
                            AttributeHelper.ApplyTranslation(renderedBlock, mobileBlock.Attributes);
                            zone.Children.Add(renderedBlock);
                        }
                        catch (Exception e)
                        {
                            //
                        }
                    }
                }
            }
            MainStackLayout.Children.Add(layout);
            Menu = layout;
        }
Esempio n. 11
0
        public void ExecuteCommand()
        {
            if (Command != null)
            {
                Me = (LogoutCommand)Command;
            }
            try
            {
                //clear login settings
                Common.RemoveSettings(Me.SettingsToRemove);

                //app start screen
                App  app = Configuration.GetInstance().App;
                Page p   = MobilePage.GetPage(app.DefaultScreen).GetPage();

                Page.Navigation.PushModalAsync(p);
            }
            catch (Exception ex)
            {
                IPage.DisplayErrorAlert(ex.Message);
            }
        }
        public void ExecuteCommand()
        {
            if (Command != null)
            {
                Me = (NavigateToScreenCommand)Command;
            }

            //log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            try
            {
                Page p = MobilePage.GetPage(Me.NavigateScreen).GetPage();

                Page.Navigation.PushAsync(p);

                //if (Command != null)
                //{
                //    Me = (NavigateToUrlCommand)Command;
                //}

                //if (String.IsNullOrEmpty(Me.NavigateUrl))
                //{
                //    throw new ApplicationException("NavigateUrl is invalid");
                //}
                //string url = Common.CreateUrlWithQueryStringContext(Me.NavigateUrl, Me.Context);
                //url = String.Format(url, Page.Request.QueryString[Me.EntityID]);

                //log.DebugFormat("RedirectUrl:{0}", url);
                //Page.Response.Redirect(url,false);
                //HttpContext.Current.ApplicationInstance.CompleteRequest();
            }
            catch (Exception ex)
            {
                //Page.DisplayErrorAlert(ex);

                //log.Error(ex);
            }
        }
        private void AddTitleBar(ContentView layout, MobilePage page)
        {
            nav = ( StackLayout )layoutManager.GetElement("NavBar");
            if (nav != null)
            {
                nav.IsVisible = true;
                if (page.Attributes.ContainsKey("AccentColor") && !string.IsNullOrEmpty(page.Attributes["AccentColor"]))
                {
                    nav.BackgroundColor = (Color) new ColorTypeConverter().ConvertFromInvariantString(page.Attributes["AccentColor"]);
                }

                StackLayout stackLayout = new StackLayout
                {
                    HeightRequest   = 44,
                    Orientation     = StackOrientation.Horizontal,
                    VerticalOptions = LayoutOptions.Center
                };

                nav.Children.Add(stackLayout);

                if (App.Navigation.Navigation.NavigationStack.Count > 1)
                {
                    IconLabel icon = new IconLabel
                    {
                        Text = "fa fa-chevron-left",
                        HorizontalOptions = LayoutOptions.Start,
                        VerticalOptions   = LayoutOptions.Center,
                        FontSize          = 30,
                        Margin            = new Thickness(10, 7, 0, 0),
                        TextColor         = Color.Black
                    };

                    TapGestureRecognizer tgr = new TapGestureRecognizer()
                    {
                        NumberOfTapsRequired = 1
                    };
                    tgr.Tapped += (s, ee) =>
                    {
                        AvalancheNavigation.RemovePage();
                    };
                    nav.GestureRecognizers.Add(tgr);

                    stackLayout.Children.Add(icon);
                }

                Label label = new Label
                {
                    Text = page.Title,
                    HorizontalTextAlignment = TextAlignment.Center,
                    HorizontalOptions       = LayoutOptions.CenterAndExpand,
                    VerticalOptions         = LayoutOptions.Center,
                    FontSize  = 20,
                    Margin    = new Thickness(0, 6, 0, 0),
                    TextColor = Color.Black
                };
                stackLayout.Children.Add(label);

                BoxView boxview = new BoxView
                {
                    HeightRequest     = 0.5,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    BackgroundColor   = Color.Black
                };
                nav.Children.Add(boxview);
            }
        }
        protected async void SaveEditForm()
        {
            DataCommandService dataCommandDB = DataCommandService.GetInstance();

            bool   SuccessIndicator = false;
            string retVal           = null;

            if (true)//Page.IsValid)
            {
                try
                {
                    object r = null;
                    List <ScreenDataCommandParameter> parameters = null;
                    switch (PageMode)
                    {
                    case FormViewMode.View:
                        CodeTorch.Core.Common.LogInfo("\r\n\r\nIn Insert Mode");

                        if (String.IsNullOrEmpty(Me.InsertCommand))
                        {
                            throw new Exception("InsertCommand is invalid");
                        }
                        CodeTorch.Core.Common.LogDebug(String.Format("InsertCommand:{0}", Me.InsertCommand));

                        parameters = Common.GetPopulatedCommandParameters(Me.InsertCommand, IPage);

                        DataCommand command = DataCommand.GetDataCommand(Me.InsertCommand);

                        switch (command.ReturnType)
                        {
                        case DataCommandReturnType.DataTable:
                            r = await dataCommandDB.GetDataForDataCommand(Me.InsertCommand, parameters);

                            break;

                        case DataCommandReturnType.Integer:
                            r = await dataCommandDB.ExecuteDataCommand(Me.InsertCommand, parameters);

                            break;

                        case DataCommandReturnType.Xml:
                            throw new NotImplementedException();
                            break;

                        case DataCommandReturnType.None:
                            break;
                        }


                        if (r != null)
                        {
                            if (!String.IsNullOrEmpty(Me.AfterInsertSettings))
                            {
                                if (r is DataTable)
                                {
                                    DataTable dt = r as DataTable;
                                    if (dt.Rows.Count > 0)
                                    {
                                        DataRow row = dt.Rows[0];
                                        Common.DataRowToSettings(row, Me.AfterInsertSettings);
                                    }
                                }
                            }
                            //if r is datatable - see if any of the values need to be stored in settings
                            //retVal = r.ToString();
                            //CodeTorch.Core.Common.LogDebug(String.Format("Output Parameter:{0}", retVal));
                        }

                        CodeTorch.Core.Common.LogDebug(String.Format("RedirectAfterInsert:{0}", Me.RedirectAfterInsert));
                        if (Me.RedirectAfterInsert)
                        {
                            if (!String.IsNullOrEmpty(Me.AfterInsertRedirectScreen))
                            {
                                Page p = MobilePage.GetPage(Me.AfterInsertRedirectScreen).GetPage();

                                Page.Navigation.PushAsync(p);
                            }
                            else
                            {
                                //TODO: do what -tell about config error
                            }

                            //string url = GetRedirectUrl(retVal);
                            //log.DebugFormat("RedirectUrl:{0}", url);
                            //Page.Response.Redirect(url,false);
                            //HttpContext.Current.ApplicationInstance.CompleteRequest();
                        }
                        else
                        {
                            Page.DisplayAlert("Alert", Me.AfterInsertConfirmationMessage, "OK");

                            //Page.DisplaySuccessAlert(String.Format(Me.AfterInsertConfirmationMessage, retVal));

                            //RefreshSections();
                        }
                        break;
                        //case FormViewMode.Edit:
                        //    log.Info("In Edit Mode");
                        //    if (String.IsNullOrEmpty(Me.UpdateCommand))
                        //    {
                        //        throw new ApplicationException("UpdateCommand is invalid");
                        //    }
                        //    log.DebugFormat("UpdateCommand:{0}", Me.UpdateCommand);

                        //    parameters = pageDB.GetPopulatedCommandParameters(Me.UpdateCommand, Page);
                        //    dataCommandDB.ExecuteDataCommand(Me.UpdateCommand, parameters);

                        //    log.DebugFormat("RedirectAfterUpdate:{0}", Me.RedirectAfterUpdate);
                        //    if (Me.RedirectAfterUpdate)
                        //    {
                        //        string url = GetRedirectUrl(Page.Request.QueryString[Me.EntityID]);
                        //        log.DebugFormat("RedirectUrl:{0}", url);
                        //        Page.Response.Redirect(url, false);
                        //        HttpContext.Current.ApplicationInstance.CompleteRequest();
                        //    }
                        //    else
                        //    {
                        //        Page.DisplaySuccessAlert(String.Format(Me.AfterUpdateConfirmationMessage, retVal));

                        //        RefreshSections();
                        //    }
                        //    break;
                    }
                    SuccessIndicator = true;
                }
                catch (Exception ex)
                {
                    SuccessIndicator = false;

                    IPage.DisplayErrorAlert(ex.Message);



                    //log.Error(ex);
                }
            }

            //return SuccessIndicator;
        }
        public async void ExecuteCommand()
        {
            if (Command != null)
            {
                Me = (ValidateUserCommand)Command;
            }
            try
            {
                DataTable          dt            = null;
                DataCommandService dataCommandDB = DataCommandService.GetInstance();
                bool IsAuthenticated             = false;

                //call data command

                //if we get datatable and row=1 store

                List <ScreenDataCommandParameter> parameters = null;
                parameters = Common.GetPopulatedCommandParameters(Me.LoginCommand, IPage);

                DataCommand command = DataCommand.GetDataCommand(Me.LoginCommand);

                switch (command.ReturnType)
                {
                case DataCommandReturnType.DataTable:
                    dt = await dataCommandDB.GetDataForDataCommand(Me.LoginCommand, parameters);

                    break;

                case DataCommandReturnType.Integer:
                    throw new NotImplementedException();
                    break;

                case DataCommandReturnType.Xml:
                    throw new NotImplementedException();
                    break;

                case DataCommandReturnType.None:
                    throw new NotImplementedException();
                    break;
                }

                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        DataRow row = dt.Rows[0];
                        Common.DataRowToSettings(row, Me.AfterLoginSettings);
                        IsAuthenticated = true;
                        if (!String.IsNullOrEmpty(Me.AfterLoginRedirectScreen))
                        {
                            Page p = MobilePage.GetPage(Me.AfterLoginRedirectScreen).GetPage();

                            Page.Navigation.PushAsync(p);
                        }
                    }
                }

                if (!IsAuthenticated)
                {
                    IPage.DisplayErrorAlert("You have entered an invalid username/password combination. Please try again.");
                }
            }
            catch (Exception ex)
            {
                IPage.DisplayErrorAlert(ex.Message);
            }
        }