private bool TryMatchUrl(string[] urlParams, RequestContext requestContext, bool setUrlParametersResolved)
        {
            if (urlParams == null || urlParams.Length == 0)
            {
                return(false);
            }

            var    url = RouteHelper.GetUrlParameterString(urlParams);
            string redirectUrl;
            var    providerName = this.providerNameResolver != null?this.providerNameResolver() : null;

            var contentItemResolver = new ContentDataItemResolver();
            var item = contentItemResolver.GetItemByUrl(url, this.ItemType, providerName, out redirectUrl);

            if (item != null)
            {
                SystemManager.CurrentHttpContext.Items["detailItem"] = item;

                this.AddContentItemToRouteData(requestContext, redirectUrl, item, setUrlParametersResolved);

                return(true);
            }
            else if (urlParams.Length > 1)
            {
                this.TryMatchUrl(urlParams.Take(urlParams.Length - 1).ToArray(), requestContext, false);

                return(false);
            }

            return(false);
        }
        /// <summary>
        /// Gets ReturnURL set by administrator or taken from query string
        /// </summary>
        /// <returns>
        /// ReturnURL to redirect or empty string
        /// </returns>
        protected internal string GetReturnURL(HttpContextBase context)
        {
            var path        = context.Request.AppRelativeCurrentExecutionFilePath;
            var redirectUrl = RouteHelper.ResolveUrl(path, UrlResolveOptions.Absolute);

            if (!string.IsNullOrEmpty(context.Request.Url.Query))
            {
                // Remove err flag in redirect data
                redirectUrl = redirectUrl.Replace("&err=true", string.Empty).Replace("err=true", string.Empty);
            }

            if (this.LoginRedirectPageId.HasValue)
            {
                redirectUrl = this.GetPageUrl(this.LoginRedirectPageId);
            }
            else
            {
                // Get redirectUrl from query string parameter
                string redirectUrlFromQS;
                this.TryResolveUrlFromUrlReferrer(context, out redirectUrlFromQS);

                if (!string.IsNullOrWhiteSpace(redirectUrlFromQS))
                {
                    redirectUrl = redirectUrlFromQS;
                }
            }

            return(redirectUrl);
        }
        public void EventWidget_AllEvents_DisplayAll()
        {
            var methodName = MethodInfo.GetCurrentMethod().Name;

            try
            {
                this.BuildEvents(methodName);

                var eventController = new EventController();
                eventController.Model.DisplayMode   = ListDisplayMode.Paging;
                eventController.Model.SelectionMode = SelectionMode.AllItems;

                var mvcProxy = new MvcControllerProxy()
                {
                    Settings = new ControllerSettings(eventController), ControllerName = typeof(EventController).FullName
                };
                var containedEvents = new string[] { CurrentEventNameFormat, NextWeekEventNameFormat, NextMonthEventNameFormat, PreviousMonthEventNameFormat, PreviousWeekEventNameFormat }.Select(s => string.Format(CultureInfo.InvariantCulture, s, methodName));

                using (var generator = new PageContentGenerator())
                {
                    generator.CreatePageWithWidget(mvcProxy, null, methodName, methodName, methodName, 0);
                    var pageContent = WebRequestHelper.GetPageWebContent(RouteHelper.GetAbsoluteUrl("~/" + methodName + "0"));

                    foreach (var title in containedEvents)
                    {
                        Assert.Contains(pageContent, title, StringComparison.Ordinal);
                    }
                }
            }
            finally
            {
                ServerOperations.Events().DeleteAllEvents();
            }
        }
Example #4
0
        /// <summary>
        /// Renders appropriate list view depending on the <see cref="DetailTemplateName"/>
        /// </summary>
        /// <param name="item">The item which details will be displayed.</param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public ActionResult Details(Image item)
        {
            if (!this.MatchesParent(item))
            {
                RouteHelper.SetUrlParametersResolved(false);
            }

            this.InitializeMetadataDetailsViewBag(item);

            var itemIndex        = this.ParseToNullableInt32(this.GetQueryString("itemIndex"));
            var fullTemplateName = this.detailTemplateNamePrefix + this.DetailTemplateName;

            if (item != null)
            {
                this.ViewBag.Title = item.Title;
            }

            this.ViewBag.DetailsPageId  = this.DetailsPageId;
            this.ViewBag.OpenInSamePage = this.OpenInSamePage;
            this.ViewBag.ItemIndex      = itemIndex;
            this.ViewBag.UrlKeyPrefix   = this.Model.UrlKeyPrefix;

            var viewModel = this.Model.CreateDetailsViewModel(item, itemIndex);

            this.AddCacheDependencies(this.Model.GetKeysOfDependentObjects(viewModel));

            this.AddCanonicalUrlTag(item);

            return(this.View(fullTemplateName, viewModel));
        }
        private bool TryMapSuccessorsRouteData(string[] urlParams, RequestContext requestContext, DynamicModuleManager manager, Type parentType)
        {
            string redirectUrl;
            var    item = manager.Provider.GetItemFromUrl(parentType, RouteHelper.GetUrlParameterString(urlParams), true, out redirectUrl);

            if (item != null)
            {
                requestContext.RouteData.Values["action"]     = "Successors";
                requestContext.RouteData.Values["parentItem"] = item;

                if (this.Request["page"] != null)
                {
                    requestContext.RouteData.Values["page"] = int.Parse(this.Request["page"]);
                }

                return(true);
            }

            if (urlParams.Length > 1)
            {
                this.TryMapSuccessorsRouteData(urlParams.Take(urlParams.Length - 1).ToArray(), requestContext, manager, parentType);
            }

            return(false);
        }
Example #6
0
 public NotificationBannerModel(NotificationForBannerModel notification, bool showPadlock = false,
                                bool showLink = false)
 {
     NotificationId      = notification.NotificationId.ToString();
     SortByDate          = notification.NotificationDate ?? notification.CreationDate;
     TbService           = notification.TbService;
     TbServiceCode       = notification.TbServiceCode;
     TbServicePHECCode   = notification.TbServicePHECCode;
     LocationPHECCode    = notification.LocationPHECCode;
     CaseManager         = notification.CaseManager;
     CaseManagerIsActive = notification.CaseManagerIsActive;
     CaseManagerId       = notification.CaseManagerId;
     NhsNumber           = notification.NhsNumber;
     DateOfBirth         = notification.DateOfBirth;
     CountryOfBirth      = notification.CountryOfBirth;
     Postcode            = notification.Postcode;
     Name = notification.Name;
     Sex  = notification.Sex;
     NotificationStatus               = notification.NotificationStatus;
     NotificationStatusString         = notification.NotificationStatus.GetDisplayName();
     NotificationDate                 = notification.NotificationDate.ConvertToString();
     DrugResistance                   = notification.DrugResistance;
     TreatmentOutcome                 = CalculateOutcome(notification.TreatmentEvents, notification.IsPostMortemWithCorrectEvents);
     PreviousTbServiceCodes           = notification.PreviousTbServiceCodes;
     PreviousPhecCodes                = notification.PreviousPhecCodes;
     LinkedNotificationTbServiceCodes = notification.LinkedNotificationTbServiceCodes;
     LinkedNotificationPhecCodes      = notification.LinkedNotificationPhecCodes;
     Source       = NtbsSource;
     ShowLink     = showLink;
     ShowPadlock  = showPadlock;
     RedirectPath = RouteHelper.GetNotificationPath(notification.NotificationId, NotificationSubPaths.Overview);
 }
        private CommentsListWidgetSettings GetCommentsListWidgetSettings(string threadTitle, bool useReviews)
        {
            var isUserAuthenticatedUrl = RouteHelper.ResolveUrl("~/RestApi/session/is-authenticated", UrlResolveOptions.Rooted);
            var rootUrl = RouteHelper.ResolveUrl("~/RestApi/comments-api/", UrlResolveOptions.Rooted);
            var hasUserAlreadyReviewedUrl = RouteHelper.ResolveUrl("~/RestApi/reviews-api", UrlResolveOptions.Rooted);
            var createCommentUrl          = RouteHelper.ResolveUrl("~/RestApi/reviews-api", UrlResolveOptions.Rooted);

            return(new CommentsListWidgetSettings()
            {
                CommentsAllowSubscription = this.ThreadConfig.AllowSubscription && !this.ThreadIsClosed,
                CommentsAutoRefresh = this.CommentsAutoRefresh,
                CommentsInitiallySortedDescending = this.CommentsConfig.AreNewestOnTop,
                CommentsPerPage = this.CommentsConfig.EnablePaging ? this.CommentsConfig.CommentsPerPage : 500,
                CommentsRefreshInterval = this.CommentsRefreshInterval,
                CommentsTextMaxLength = this.CommentTextMaxLength,
                CommentsThread = this.Thread ?? this.GetCommentsThreadProxy(threadTitle),
                CommentsThreadKey = this.ThreadKey,
                CommentsThreadType = this.ThreadType,
                IsDesignMode = SystemManager.IsDesignMode,
                IsUserAuthenticatedUrl = isUserAuthenticatedUrl,
                RequiresApproval = this.ThreadConfig.RequiresApproval,
                RequiresAuthentication = this.ThreadConfig.RequiresAuthentication,
                RequiresCaptcha = this.CommentsConfig.UseSpamProtectionImage,
                AlwaysUseUtc = this.CommentsConfig.AlwaysUseUtc,
                RootUrl = rootUrl,
                UserAvatarImageUrl = this.UserAvatarImageUrl,
                UserDisplayName = this.UserDisplayName,
                //// Reviews
                UseReviews = useReviews,
                HasUserAlreadyReviewedUrl = hasUserAlreadyReviewedUrl,
                CreateCommentUrl = createCommentUrl
            });
        }
        /// <inheritdoc/>
        protected override void InitializeRouteParameters(MvcProxyBase proxyControl)
        {
            RouteHelper.SetUrlParametersResolved(false);

            var originalContext = proxyControl.Context.Request.RequestContext ?? proxyControl.Page.GetRequestContext();

            var paramsMapper = this.GetDefaultParamsMapper(proxyControl.Controller);

            if (paramsMapper != null)
            {
                var requestContext = proxyControl.RequestContext;
                var originalParams = MvcRequestContextBuilder.GetRouteParams(originalContext);
                var controllerName = SitefinityViewEngine.GetControllerName(proxyControl.Controller);
                requestContext.RouteData.Values[DynamicUrlParamActionInvoker.ControllerNameKey] = controllerName;

                paramsMapper.ResolveUrlParams(originalParams, requestContext);
                proxyControl.Controller.TempData.Add("IsInPureMode", proxyControl.IsInPureMode);

                if (!proxyControl.ContentTypeName.IsNullOrEmpty())
                {
                    proxyControl.Controller.RouteData.Values.Add("contentTypeName", proxyControl.ContentTypeName);
                }
            }
            else
            {
                base.InitializeRouteParameters(proxyControl);
            }
        }
Example #9
0
        private IList getList()
        {
            switch (searchable)
            {
            case Searchable.products:
                return(ProductsHolder.products);

            case Searchable.routes:
                return(RouteHelper.makeRoutesDisplayable(DeliveryHolder.routes));

            case Searchable.workers:
                return(WorkerHolder.workers);

            case Searchable.avaliableWorkers:
                return(WorkerHolder.avaliableWorkers);

            case Searchable.locations:
                return(DeliveryHolder.locations);

            case Searchable.vehicles:
                return(DeliveryHolder.vehicles);

            case Searchable.avaliableVehicles:
                return(DeliveryHolder.avaliableVehicles);

            case Searchable.partner:
                return(DeliveryHolder.partners);

            case Searchable.warehouse:
                return(WarehouseHolder.warehouses);

            default:
                return(default);
            }
        }
Example #10
0
        public void DrawRouteToPlace(Route route, Place place)
        {
            if (MyLocation == null)
            {
                return;
            }

            map.Clear();

            string snippet = route.legs[0].distance.text +
                             ", " + route.legs[0].duration.text;

            var marker = new MarkerOptions();

            marker.SetTitle(place.name);
            marker.SetSnippet(snippet);
            marker.SetPosition(new LatLng(place.geometry.location.lat, place.geometry.location.lng));
            map.AddMarker(marker);

            var polyline = new PolylineOptions();

            polyline.InvokeColor(ContextCompat.GetColor(Activity.ApplicationContext, Resource.Color.route_polyline));
            var points = RouteHelper.GetPointsFromRoute(route);

            foreach (var point in points)
            {
                polyline.Add(new LatLng(point.lat, point.lng));
            }

            map.AddPolyline(polyline);

            UpdateCameraPosition(new LatLng(MyLocation.lat, MyLocation.lng));
        }
Example #11
0
        private void SearchForm_Load(object sender, EventArgs e)
        {
            cmbWhere.Items.AddRange(Enum.GetValues(typeof(SearchOption)).Cast <Enum>().ToArray());
            tboxValue.Enabled = false;
            switch (searchable)
            {
            case Searchable.products:
                cmbSearchBy.Items.AddRange(typeof(Product).GetProperties().Select(ele => ele.Name).ToArray());
                dgv.DataSource = ProductsHolder.products;
                break;

            case Searchable.routes:
                cmbSearchBy.Items.AddRange(typeof(Route).GetProperties().Select(ele => ele.Name).ToArray());
                dgv.DataSource = RouteHelper.makeRoutesDisplayable(DeliveryHolder.routes);
                break;

            case Searchable.workers:
                cmbSearchBy.Items.AddRange(typeof(Worker).GetProperties().Select(ele => ele.Name).ToArray());
                dgv.DataSource = WorkerHolder.workers;
                break;

            case Searchable.avaliableWorkers:
                cmbSearchBy.Items.AddRange(typeof(Worker).GetProperties().Select(ele => ele.Name).ToArray());
                dgv.DataSource = WorkerHolder.avaliableWorkers;
                break;

            case Searchable.locations:
                cmbSearchBy.Items.AddRange(typeof(Location).GetProperties().Select(ele => ele.Name).ToArray());
                dgv.DataSource = DeliveryHolder.locations;
                break;

            case Searchable.vehicles:
                cmbSearchBy.Items.AddRange(typeof(Location).GetProperties().Select(ele => ele.Name).ToArray());
                dgv.DataSource = DeliveryHolder.vehicles;
                break;

            case Searchable.avaliableVehicles:
                cmbSearchBy.Items.AddRange(typeof(Location).GetProperties().Select(ele => ele.Name).ToArray());
                dgv.DataSource = DeliveryHolder.avaliableVehicles;
                break;

            case Searchable.partner:
                cmbSearchBy.Items.AddRange(typeof(Partner).GetProperties().Select(ele => ele.Name).ToArray());
                dgv.DataSource = DeliveryHolder.partners;
                break;

            case Searchable.warehouse:
                cmbSearchBy.Items.AddRange(typeof(Warehouse).GetProperties().Select(ele => ele.Name).ToArray());
                dgv.DataSource = WarehouseHolder.warehouses;
                break;

            case Searchable.avaliableDrivers:
                cmbSearchBy.Items.AddRange(typeof(Worker).GetProperties().Select(ele => ele.Name).ToArray());
                dgv.DataSource = WorkerHolder.avaliableWorkers.FindAll((worker) => worker.position == WorkerPosition.driver);
                break;

            default:
                break;
            }
        }
Example #12
0
        /// <inheritdoc />
        public virtual string GetLogoutPageUrl()
        {
            string logoutRedirectUrl = this.ExternalLogoutUrl;

            if (string.IsNullOrEmpty(logoutRedirectUrl))
            {
                if (this.LogoutPageId.HasValue)
                {
                    logoutRedirectUrl = HyperLinkHelpers.GetFullPageUrl(this.LogoutPageId.Value);
                }
                else
                {
                    logoutRedirectUrl = UrlPath.ResolveAbsoluteUrl(this.currentPageUrl, true);
                }
            }

            if (HttpContext.Current.Request.Url == null)
            {
                return(string.Empty);
            }

            string fullLogoutUrl = RouteHelper.ResolveUrl(ClaimsManager.GetLogoutUrl(logoutRedirectUrl), UrlResolveOptions.Rooted);

            // Workaround an issue when the application is hosted under an application path.
            if (SystemManager.CurrentHttpContext != null && SystemManager.CurrentHttpContext.Request.ApplicationPath != "/")
            {
                fullLogoutUrl = fullLogoutUrl.Replace("sts_signout=true&", "");
            }

            return(fullLogoutUrl);
        }
Example #13
0
        private Guid CreateTemplateWithWidgetAndBasePageOnIt(PageTemplateFramework framework, Controller widgetController, out Guid pageId, out string pageUrl)
        {
            var pageManager = PageManager.GetManager();

            // Create template
            var templateId = framework == PageTemplateFramework.Hybrid ?
                             ServerOperations.Templates().CreateHybridMVCPageTemplate(FrontendModuleFilterTests.TemplateTitle + Guid.NewGuid().ToString("N")) :
                             ServerOperations.Templates().CreatePureMVCPageTemplate(FrontendModuleFilterTests.TemplateTitle + Guid.NewGuid().ToString("N"));

            // Place widget on template
            var mvcProxy = new MvcControllerProxy();

            mvcProxy.ControllerName = widgetController.GetType().FullName;
            mvcProxy.Settings       = new ControllerSettings(widgetController);
            SampleUtilities.AddControlToTemplate(templateId, mvcProxy, "Body", "FrontendModuleFilterTestsWidgetCaption");

            // Create page with template
            var template = pageManager.GetTemplates().Where(t => t.Id == templateId).SingleOrDefault();

            pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, "TestPageName", "test-page-url");
            var page = pageManager.GetPageNode(pageId);

            pageUrl = RouteHelper.GetAbsoluteUrl(page.GetFullUrl());

            return(templateId);
        }
        /// <summary>
        /// Determines whether the specified path is whitelisted for executing server code.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns>Whether the specified path is whitelisted for execution server code.</returns>
        protected virtual bool IsWhitelisted(string path)
        {
            var resolvedRoot = RouteHelper.ResolveUrl("~/" + this.rootPath, UrlResolveOptions.Rooted | UrlResolveOptions.AppendTrailingSlash);

            return(path.StartsWith(resolvedRoot + "client-components/", StringComparison.OrdinalIgnoreCase) ||
                   path.StartsWith(resolvedRoot + "Mvc/Scripts/", StringComparison.OrdinalIgnoreCase));
        }
Example #15
0
        /// <inheritdoc />
        public bool HideListView(RequestContext context)
        {
            if (this.HideListViewOnChildDetailsView)
            {
                var contentType     = this.ContentType;
                var routeParams     = MvcRequestContextBuilder.GetRouteParams(context);
                var urlParamsString = RouteHelper.GetUrlParameterString(routeParams);
                if (urlParamsString != null)
                {
                    var manager = this.GetManager() as DynamicModuleManager;

                    var allTypes          = ModuleBuilderManager.GetModules().SelectMany(x => x.Types);
                    var dynamicModuleType = allTypes.FirstOrDefault(x => x.TypeNamespace == contentType.Namespace && x.TypeName == contentType.Name);
                    var dynamicModuleTypesForThisModule = allTypes.Where(x => x.ModuleId == dynamicModuleType.ModuleId).ToList();

                    var successorTypes = this.GetTypeSuccessors(dynamicModuleTypesForThisModule, dynamicModuleType).Select(c => c.GetFullTypeName()).ToList();
                    var item           = manager.Provider.GetItemsFromUrl(urlParamsString, successorTypes, true).FirstOrDefault();
                    if (item != null)
                    {
                        return(successorTypes.Contains(item.GetType().FullName));
                    }
                }
            }

            return(false);
        }
Example #16
0
        /// <inheritdoc />
        protected override bool TryMatchUrl(string[] urlParams, RequestContext requestContext, string urlKeyPrefix)
        {
            if (urlParams == null || !this.IsPaginationAllowed())
            {
                return(false);
            }

            var routeTemplate = this.routeTemplateResolver();

            var metaParams = routeTemplate
                             .Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

            var parameterMap = this.MapParams(this.actionMethod, metaParams, urlParams, this.urlParamNames);

            if (parameterMap == null)
            {
                return(false);
            }

            requestContext.RouteData.Values[UrlParamsMapperBase.ActionNameKey] = this.actionName;
            this.PopulateRouteData(requestContext.RouteData.Values, parameterMap);
            RouteHelper.SetUrlParametersResolved();

            return(true);
        }
Example #17
0
        protected virtual void AddContentItemToRouteData(RequestContext requestContext, string redirectUrl, IDataItem item, bool setUrlParametersResolved = true)
        {
            requestContext.RouteData.Values[UrlParamsMapperBase.ActionNameKey] = this.actionName;

            var parameters = this.ActionMethod.GetParameters();

            if (parameters.Length > 0 && parameters[0].ParameterType.IsAssignableFrom(this.ItemType))
            {
                requestContext.RouteData.Values[parameters[0].ParameterName] = item;
            }

            if (!redirectUrl.IsNullOrEmpty())
            {
                requestContext.RouteData.Values[Telerik.Sitefinity.Mvc.ControllerActionInvoker.ShouldProcessRequestKey] = redirectUrl;
            }

            if (redirectUrl.IsNullOrEmpty() == false && parameters.Length > 1 && parameters[1].ParameterType == typeof(string))
            {
                requestContext.RouteData.Values[parameters[1].ParameterName] = redirectUrl;
            }

            if (setUrlParametersResolved)
            {
                RouteHelper.SetUrlParametersResolved();
            }
        }
Example #18
0
 public TunAdapter()
 {
     InterfaceIndex   = RouteHelper.ConvertLuidToIndex(tun2socks.tun_luid());
     NetworkInterface = NetworkInterfaceUtils.Get((int)InterfaceIndex);
     Gateway          = IPAddress.Parse(Global.Settings.TUNTAP.Gateway);
     Global.Logger.Info($"WinTUN 适配器:{NetworkInterface.Name} {NetworkInterface.Id} {NetworkInterface.Description}, index: {InterfaceIndex}");
 }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var  routeItem = RouteHelper.GetCurrentConfigRouteItem();
            bool need      = routeItem == null ? false : routeItem.NeedLogin;

            if (need == false) // 不需要验证签名
            {
                return;
            }
            string   requestSign = filterContext.RequestContext.HttpContext.Request.Headers["IBB-Service-Sign"];
            string   timestamp   = filterContext.RequestContext.HttpContext.Request.Headers["IBB-Service-Timestamp"];
            string   salt        = filterContext.RequestContext.HttpContext.Request.Headers["IBB-Service-Salt"];
            DateTime time;

            if (string.IsNullOrWhiteSpace(timestamp) || DateTime.TryParse(timestamp, out time) == false)
            {
                throw new ApplicationException(string.Format("无效的timestamp;IBB-Service-Sign:{0};IBB-Service-Timestamp:{1};IBB-Service-Salt:{2}", requestSign, timestamp, salt));
            }
            if (time.AddMinutes(10) < DateTime.Now)
            {
                throw new ApplicationException(string.Format("此请求的签名已过期;IBB-Service-Sign:{0};IBB-Service-Timestamp:{1};IBB-Service-Salt:{2}", requestSign, timestamp, salt));
            }
            string privateKey = ConfigurationManager.AppSettings["ServicePrivateKey"];
            string sign       = MD5Crypto(timestamp + salt + privateKey);

            if (sign != requestSign)
            {
                throw new ApplicationException(string.Format("请求的签名错误;IBB-Service-Sign:{0};IBB-Service-Timestamp:{1};IBB-Service-Salt:{2}", requestSign, timestamp, salt));
            }
        }
Example #20
0
 // Access level is treated as a bool for either able to view or not. This differs from the standard PermissionLevel
 // implemented across the codebase due to there being no visual difference between full edit permissions
 // and readonly permissions on notification banner models
 public NotificationBannerModel(Notification notification, bool showPadlock = false, bool showLink = false)
 {
     NotificationId      = notification.NotificationId.ToString();
     SortByDate          = notification.NotificationDate ?? notification.CreationDate;
     TbService           = notification.HospitalDetails.TBServiceName;
     TbServiceCode       = notification.HospitalDetails.TBServiceCode;
     TbServicePHECCode   = notification.HospitalDetails.TBService?.PHECCode;
     LocationPHECCode    = notification.PatientDetails.PostcodeLookup?.LocalAuthority?.LocalAuthorityToPHEC?.PHECCode;
     CaseManager         = notification.HospitalDetails.CaseManagerName;
     CaseManagerIsActive = notification.HospitalDetails.CaseManager?.IsActive;
     CaseManagerId       = notification.HospitalDetails.CaseManagerId;
     NhsNumber           = notification.PatientDetails.FormattedNhsNumber;
     DateOfBirth         = notification.PatientDetails.FormattedDob;
     CountryOfBirth      = notification.PatientDetails.CountryName;
     Postcode            = notification.PatientDetails.FormattedNoAbodeOrPostcodeString;
     Name = notification.PatientDetails.FullName;
     Sex  = notification.PatientDetails.SexLabel;
     NotificationStatus          = notification.NotificationStatus;
     NotificationStatusString    = notification.NotificationStatus.GetDisplayName();
     NotificationDate            = notification.FormattedNotificationDate;
     DrugResistance              = notification.DrugResistanceProfile.DrugResistanceProfileString;
     TreatmentOutcome            = CalculateOutcome(notification.TreatmentEvents, notification.IsPostMortemAndHasCorrectEvents);
     PreviousTbServiceCodes      = notification.PreviousTbServices.Select(service => service.TbServiceCode);
     PreviousPhecCodes           = notification.PreviousTbServices.Select(service => service.PhecCode);
     LinkedNotificationPhecCodes =
         notification.Group?.Notifications.Select(no => no.HospitalDetails.TBService.PHECCode);
     LinkedNotificationTbServiceCodes =
         notification.Group?.Notifications.Select(no => no.HospitalDetails.TBServiceCode);
     Source       = NtbsSource;
     ShowLink     = showLink;
     ShowPadlock  = showPadlock;
     RedirectPath = RouteHelper.GetNotificationPath(notification.NotificationId, NotificationSubPaths.Overview);
 }
Example #21
0
        public void FoundationResourcePackage_AddNewLayoutFile_VerifyGeneratedTemplateAndCreatedPageContent()
        {
            int templatesCount = this.PageManager.GetTemplates().Count();

            try
            {
                string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageDestinationFilePath(Constants.PackageName, Constants.LayoutFileName);
                FeatherServerOperations.ResourcePackages().AddNewResource(Constants.LayoutFileResource, filePath);

                FeatherServerOperations.ResourcePackages().WaitForTemplatesCountToIncrease(templatesCount, 1);

                var template = this.PageManager.GetTemplates().Where(t => t.Title == Constants.TemplateTitle).FirstOrDefault();
                Assert.IsNotNull(template, "Template was not found");

                Guid pageId = FeatherServerOperations.Pages().CreatePageWithTemplate(template, Constants.PageTitle, Constants.PageUrl);

                var page    = this.PageManager.GetPageNode(pageId);
                var pageUrl = page.GetFullUrl();
                pageUrl = RouteHelper.GetAbsoluteUrl(pageUrl);

                string pageContent = WebRequestHelper.GetPageWebContent(pageUrl);
                Assert.IsTrue(pageContent.Contains(Constants.LayoutTemplateText), "Layout template text was not found in the page content");
            }
            finally
            {
                ServerOperations.Pages().DeletePage(Constants.PageTitle);
                ServerOperations.Templates().DeletePageTemplate(Constants.TemplateTitle);

                string filePath = FeatherServerOperations.ResourcePackages().GetResourcePackageDestinationFilePath(Constants.PackageName, Constants.LayoutFileName);
                File.Delete(filePath);
            }
        }
        public void EventWidget_AllEvents_FilterByCalendar()
        {
            var methodName = MethodInfo.GetCurrentMethod().Name;
            var calendarId = ServerOperations.Events().CreateCalendar(Guid.NewGuid(), "custom_calendar");

            ServerOperations.Events().CreateEvent(methodName + "_fromdefault", "some content", false, DateTime.Now, DateTime.Now.AddHours(2), ServerOperations.Events().GetDefaultCalendarId());
            ServerOperations.Events().CreateEvent(methodName + "_fromcustom", "some content", false, DateTime.Now, DateTime.Now.AddHours(2), calendarId);

            try
            {
                var mvcProxy = new MvcControllerProxy();
                mvcProxy.ControllerName = typeof(EventController).FullName;
                var eventController = new EventController();

                eventController.Model.NarrowSelectionMode = Telerik.Sitefinity.Frontend.Mvc.Models.SelectionMode.FilteredItems;
                eventController.Model.SerializedNarrowSelectionFilters = this.GetNarrowSelectionSerializedQueryData("Calendars", "Parent.Id.ToString()", "Parent.Id", calendarId, "System.String");

                mvcProxy.Settings = new ControllerSettings(eventController);

                using (var generator = new PageContentGenerator())
                {
                    generator.CreatePageWithWidget(mvcProxy, null, methodName, methodName, methodName, 0);
                    var pageContent = WebRequestHelper.GetPageWebContent(RouteHelper.GetAbsoluteUrl("~/" + methodName + "0"));

                    Assert.Contains(pageContent, methodName + "_fromcustom", System.StringComparison.Ordinal);
                    Assert.DoesNotContain(pageContent, methodName + "_fromdefault", System.StringComparison.Ordinal);
                }
            }
            finally
            {
                ServerOperations.Events().DeleteAllEvents();
                ServerOperations.Events().DeleteCalendar(calendarId);
            }
        }
        public void CheckRouteChainages()
        {
            var network           = GetSnakeNetwork(false, new Point(0, 0), new Point(100, 0), new Point(200, 100));
            var branch            = network.Branches[0];
            var networkLocation0  = new NetworkLocation(branch, 0);
            var networkLocation10 = new NetworkLocation(branch, 10);
            var networkLocation20 = new NetworkLocation(branch, 20);
            var networkLocation30 = new NetworkLocation(branch, 30);
            var networkLocation40 = new NetworkLocation(branch, 40);

            branch.BranchFeatures.Add(networkLocation0);
            branch.BranchFeatures.Add(networkLocation10);
            branch.BranchFeatures.Add(networkLocation20);
            branch.BranchFeatures.Add(networkLocation30);
            branch.BranchFeatures.Add(networkLocation40);

            var route  = RouteHelper.CreateRoute(new[] { new NetworkLocation(branch, 5), new NetworkLocation(branch, 35) });
            var route2 = RouteHelper.CreateRoute(new[] { new NetworkLocation(branch, 35), new NetworkLocation(branch, 5) });

            Assert.AreEqual(-1, RouteHelper.GetRouteChainage(route, networkLocation0));
            Assert.AreEqual(5, RouteHelper.GetRouteChainage(route, networkLocation10));
            Assert.AreEqual(15, RouteHelper.GetRouteChainage(route, networkLocation20));
            Assert.AreEqual(25, RouteHelper.GetRouteChainage(route, networkLocation30));
            Assert.AreEqual(-1, RouteHelper.GetRouteChainage(route, networkLocation40));

            Assert.AreEqual(-1, RouteHelper.GetRouteChainage(route2, networkLocation0));
            Assert.AreEqual(25, RouteHelper.GetRouteChainage(route2, networkLocation10));
            Assert.AreEqual(15, RouteHelper.GetRouteChainage(route2, networkLocation20));
            Assert.AreEqual(5, RouteHelper.GetRouteChainage(route2, networkLocation30));
            Assert.AreEqual(-1, RouteHelper.GetRouteChainage(route2, networkLocation40));
        }
Example #24
0
        /// <inheritdoc />
        protected override bool TryMatchUrl(string[] urlParams, RequestContext requestContext)
        {
            if (urlParams == null || urlParams.Length == 0)
            {
                return(false);
            }

            var    url = RouteHelper.GetUrlParameterString(urlParams);
            string redirectUrl;
            var    item = this.GetItemByUrl(url, out redirectUrl);

            if (item != null)
            {
                this.AddContentItemToRouteData(requestContext, redirectUrl, item);

                return(true);
            }
            else if (urlParams.Length > 1)
            {
                this.TryMatchUrl(urlParams.Take(urlParams.Length - 1).ToArray(), requestContext);

                return(false);
            }

            return(false);
        }
        public void GetLocationsForAnotherRoute()
        {
            var network = CreateThreeNodesNetwork();
            var branch  = (Branch)network.Branches[0];

            var source = new NetworkCoverage {
                Network = network
            };

            source[new NetworkLocation(branch, 10.0)] = 10.0;
            source[new NetworkLocation(branch, 50.0)] = 30.0;
            source[new NetworkLocation(branch, 60.0)] = 20.0;
            source[new NetworkLocation(branch, 80.0)] = 10.0;

            //90-->0-->80
            var route = RouteHelper.CreateRoute(new[] { new NetworkLocation(branch, 90.0)
                                                        , new NetworkLocation(branch, 0.0), new NetworkLocation(branch, 80) });
            var expectedLocations = new[]
            {
                new NetworkLocation(branch, 90.0)
                , new NetworkLocation(branch, 80.0)
                , new NetworkLocation(branch, 60.0)
                , new NetworkLocation(branch, 50.0)
                , new NetworkLocation(branch, 10.0)
                , new NetworkLocation(branch, 0)
                , new NetworkLocation(branch, 10.0)
                , new NetworkLocation(branch, 50.0)
                , new NetworkLocation(branch, 60.0)
                , new NetworkLocation(branch, 80.0)
            };

            var actualLocations = RouteHelper.GetLocationsInRoute(source, route);

            Assert.AreEqual(expectedLocations, actualLocations);
        }
Example #26
0
        /// <inheritdoc/>
        protected override void InitializeRouteParameters(MvcProxyBase proxyControl)
        {
            var originalContext = this.Context.Request.RequestContext ?? proxyControl.Page.GetRequestContext();

            this.SetControllerRouteParam(proxyControl);

            var controller = proxyControl.GetController();

            if (!FrontendManager.AttributeRouting.HasAttributeRouting(controller.RouteData))
            {
                var paramsMapper = this.GetDefaultParamsMapper(controller);
                if (paramsMapper != null)
                {
                    var originalParams = MvcRequestContextBuilder.GetRouteParams(originalContext);
                    var requestContext = proxyControl.RequestContext;

                    var modelProperty = controller.GetType().GetProperty("Model");
                    if (modelProperty != null)
                    {
                        var model = modelProperty.GetValue(controller, null);
                        var modelUrlKeyProperty  = model == null ? null : model.GetType().GetProperty("UrlKeyPrefix");
                        var modelUrlKeyPrefix    = modelUrlKeyProperty == null ? null : (string)modelUrlKeyProperty.GetValue(model, null);
                        var expectedUrlKeyPrefix = string.IsNullOrEmpty(modelUrlKeyPrefix) ? null : "!" + modelUrlKeyPrefix;
                        var currentUrlKeyPrefix  = originalParams == null ? null : originalParams.FirstOrDefault(p => p.StartsWith("!", StringComparison.OrdinalIgnoreCase));

                        if (expectedUrlKeyPrefix == currentUrlKeyPrefix)
                        {
                            paramsMapper.ResolveUrlParams(originalParams, requestContext, modelUrlKeyPrefix);
                        }
                        else
                        {
                            this.GetPrefixParamsMapper(controller).ResolveUrlParams(originalParams, requestContext);
                            RouteHelper.SetUrlParametersResolved();
                        }
                    }
                    else
                    {
                        paramsMapper.ResolveUrlParams(originalParams, requestContext);
                    }

                    if (!proxyControl.ContentTypeName.IsNullOrEmpty())
                    {
                        controller.RouteData.Values.Add("contentTypeName", proxyControl.ContentTypeName);
                    }
                }
                else
                {
                    proxyControl.RequestContext.RouteData.Values.Remove(FeatherActionInvoker.ControllerNameKey);
                    base.InitializeRouteParameters(proxyControl);
                }
            }
            else
            {
                if (this.ShouldProcessRequest(controller) && FrontendManager.AttributeRouting.UpdateRouteData(this.Context, controller.RouteData))
                {
                    //// Attribute routing was successful.
                    RouteHelper.SetUrlParametersResolved();
                }
            }
        }
        public void GetSegmentForNetworkLocationTest()
        {
            var network       = CreateThreeNodesNetwork(); // new Point(0, 0), new Point(100, 0), new Point(300, 0)
            var branch0T100   = (Branch)network.Branches[0];
            var branch100T300 = (Branch)network.Branches[1];

            var route = RouteHelper.CreateRoute(new[]
            {
                new NetworkLocation(branch0T100, 20.0),
                new NetworkLocation(branch0T100, 80.0),
                new NetworkLocation(branch100T300, 20.0)
            });

            Assert.AreEqual(3, route.Segments.Values.Count);
            INetworkSegment networkSegment;

            networkSegment = RouteHelper.GetSegmentForNetworkLocation(route, new NetworkLocation(branch0T100, 10));
            Assert.IsNull(networkSegment);
            networkSegment = RouteHelper.GetSegmentForNetworkLocation(route, new NetworkLocation(branch0T100, 50));
            Assert.AreEqual(networkSegment, route.Segments.Values[0]);
            networkSegment = RouteHelper.GetSegmentForNetworkLocation(route, new NetworkLocation(branch0T100, 90));
            Assert.AreEqual(networkSegment, route.Segments.Values[1]);
            networkSegment = RouteHelper.GetSegmentForNetworkLocation(route, new NetworkLocation(branch100T300, 10));
            Assert.AreEqual(networkSegment, route.Segments.Values[2]);
            networkSegment = RouteHelper.GetSegmentForNetworkLocation(route, new NetworkLocation(branch100T300, 30));
            Assert.IsNull(networkSegment);
        }
Example #28
0
        /// <summary>
        /// Tries to resolve parent filter mode.
        /// </summary>
        /// <param name="urlParams">The URL params.</param>
        /// <param name="requestContext">The request context.</param>
        /// <returns></returns>
        protected virtual bool TryResolveParentFilterMode(string[] urlParams, RequestContext requestContext, BlogsManager manager = null)
        {
            var blogsManager = manager ?? BlogsManager.GetManager(this.Model.ProviderName);

            string param = RouteHelper.GetUrlParameterString(urlParams);

            string redirectUrl;

            var item = blogsManager.GetItemFromUrl(typeof(Blog), param, out redirectUrl);

            if (item != null)
            {
                requestContext.RouteData.Values["action"]     = "Successors";
                requestContext.RouteData.Values["parentItem"] = item;

                if (this.Request["page"] != null)
                {
                    requestContext.RouteData.Values["page"] = int.Parse(this.Request["page"]);
                }

                return(true);
            }

            if (urlParams.Length > 1)
            {
                this.TryResolveParentFilterMode(urlParams.Take(urlParams.Length - 1).ToArray(), requestContext, manager);
            }

            return(false);
        }
        public void IsBranchFeatureInRoute()
        {
            var network           = GetSnakeNetwork(false, new Point(0, 0), new Point(100, 0), new Point(200, 100));
            var branch            = network.Branches[0];
            var networkLocation0  = new NetworkLocation(branch, 0);
            var networkLocation10 = new NetworkLocation(branch, 10);
            var networkLocation20 = new NetworkLocation(branch, 20);
            var networkLocation30 = new NetworkLocation(branch, 30);
            var networkLocation40 = new NetworkLocation(branch, 40);

            branch.BranchFeatures.Add(networkLocation0);
            branch.BranchFeatures.Add(networkLocation10);
            branch.BranchFeatures.Add(networkLocation20);
            branch.BranchFeatures.Add(networkLocation30);
            branch.BranchFeatures.Add(networkLocation40);

            var route = RouteHelper.CreateRoute(
                new[] { new NetworkLocation(branch, 5), new NetworkLocation(branch, 35) });

            Assert.IsFalse(RouteHelper.IsBranchFeatureInRoute(route, networkLocation0));
            Assert.IsTrue(RouteHelper.IsBranchFeatureInRoute(route, networkLocation10));
            Assert.IsTrue(RouteHelper.IsBranchFeatureInRoute(route, networkLocation20));
            Assert.IsTrue(RouteHelper.IsBranchFeatureInRoute(route, networkLocation30));
            Assert.IsFalse(RouteHelper.IsBranchFeatureInRoute(route, networkLocation40));
        }
        public ContentResult SelectedItemsContextMenu(string webQueryName, string implementationsKey, string prefix)
        {
            var lites = this.ParseLiteKeys <Entity>();

            if (lites.IsEmpty())
            {
                return(Content(""));
            }

            object          queryName       = Finder.ResolveQueryName(webQueryName);
            Implementations implementations = implementationsKey == "[All]" ? Implementations.ByAll :
                                              Implementations.By(implementationsKey.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(t => Navigator.ResolveType(t)).ToArray());

            var items = ContextualItemsHelper.GetContextualItemListForLites(new SelectedItemsMenuContext
            {
                Url = RouteHelper.New(),
                ControllerContext = this.ControllerContext,
                Lites             = lites,
                QueryName         = queryName,
                Implementations   = implementations,
                Prefix            = prefix,
            });

            if (items.IsNullOrEmpty())
            {
                return(Content(""));
            }

            var sb = new HtmlStringBuilder(items.Select(mi => mi.ToHtml()));

            sb.Add(new MvcHtmlString(@"<script>$(function(){ $('[data-toggle=""tooltip""]').tooltip({}); });</script>"));
            return(Content(sb.ToHtml().ToString()));
        }
Example #31
0
 public RedirectResult Redirect(RouteHelper helper, bool requireHttps = false)
 {
     return Redirect(helper.AsUrl().ToHtmlString());
 }