Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            GetQueryParams();

            //Set display props according to lang
            if (PageAssemblyContext.Current.PageAssemblyInstruction.Language == "es")
            {
                lblResultsFor.Text = "resultados de:";
            }
            else
            {
                lblResultsFor.Text = "results found for:";
            }

            SetupCommon();
            SetupCanonicalUrl(this.DictionaryRouter.GetBaseURL());

            LoadData();

            //set up pager stuff
            string pageHtml = string.Empty;

            if (NumResults > 0 && PageAssemblyContext.Current.DisplayVersion != DisplayVersions.Print)
            {
                Dictionary <string, string> queryParams = GetPageQueryParams();

                NciUrl pagerUrl = new NciUrl();
                pagerUrl.SetUrl(PageAssemblyContext.Current.requestedUrl.ToString());

                DrugPager objPager = new DrugPager(pagerUrl, queryParams, CurrentPageIndex, PageSize, 2, NumResults);
                pageHtml = objPager.RenderPager();
            }

            litPager.Text = pageHtml;
        }
Beispiel #2
0
 // Parameter r (Redirect Flag)
 private void ParseRedirectFlag(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "r"))
     {
         searchParams.RedirectFlag = true;
     }
 }
Beispiel #3
0
        /// <summary>
        /// Use this event handler to perform operations like update
        /// the page meta tags , web analytics, etc
        /// </summary>
        /// <param name="e">Not used</param>
        protected override void OnPreRenderComplete(EventArgs e)
        {
            // Ideally we would load the trailing Stylesheests and JavaScript in OnInitComplete
            // or similar.  The problem is, we can't guarantee that all the other code will get
            // it right.  So we set up the trailing stuff here instead.
            InsertFooterStyleSheetsJavascriptsReferences();

            base.OnPreRenderComplete(e);
            SetTitle();
            InsertCanonicalURL();
            InsertPageMetaData();
            InsertPageLinkRels();
            InsertBodyTagAttributes();
            InsertHTMLTagAttributes();

            //Set the form action so it does not post back to the page template path.
            if (this.Form != null)
            {
                NciUrl formAction = this.PageAssemblyInstruction.GetUrl("PostBackURL");

                if (formAction == null || string.IsNullOrEmpty(formAction.ToString()))
                {
                    //Log Error
                }
                else
                {
                    this.Form.Action = formAction.ToString();
                }
            }
        }
Beispiel #4
0
 //Parameter t (Main Cancer Type)
 private static void SerializeCancerType(NciUrl url, CTSSearchParams searchParams)
 {
     if (searchParams.IsFieldSet(FormFields.MainType))
     {
         url.QueryParameters.Add("t", string.Join("|", searchParams.MainType.Codes));
     }
 }
Beispiel #5
0
 //Parameter fin (Findings)
 private void ParseFindings(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "fin"))
     {
         searchParams.Findings = GetTermFieldFromParam(url.QueryParameters["fin"], FormFields.Findings, searchParams);
     }
 }
Beispiel #6
0
 // Parameter r (Redirect Flag)
 private static void SerializeRedirectFlag(NciUrl url, CTSSearchParams searchParams)
 {
     if (searchParams.RedirectFlag == true)
     {
         url.QueryParameters.Add("r", "1");
     }
 }
        /// <summary>
        /// Gets the View URL for an ID
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string GetDetailedViewUrl(string id)
        {
            NciUrl url = new NciUrl();

            url.SetUrl(string.Format(this.BaseConfig.DetailedViewPagePrettyUrlFormatter, id));
            return(url.ToString());
        }
Beispiel #8
0
 // Parameter in (Investigator)
 private static void SerializeInvestigator(NciUrl url, CTSSearchParams searchParams)
 {
     if (searchParams.IsFieldSet(FormFields.Investigator))
     {
         url.QueryParameters.Add("in", HttpUtility.UrlEncode(searchParams.Investigator));
     }
 }
Beispiel #9
0
 // Parameter lo (Lead Org)
 private static void SerializeLeadOrg(NciUrl url, CTSSearchParams searchParams)
 {
     if (searchParams.IsFieldSet(FormFields.LeadOrg))
     {
         url.QueryParameters.Add("lo", HttpUtility.UrlEncode(searchParams.LeadOrg));
     }
 }
Beispiel #10
0
 //Parameter d (Drugs)
 private static void SerializeDrugs(NciUrl url, CTSSearchParams searchParms)
 {
     if (searchParms.IsFieldSet(FormFields.Drugs))
     {
         url.QueryParameters.Add("d", SerializeMultiTermFields(searchParms.Drugs));
     }
 }
Beispiel #11
0
 //Parameter i (Other treatments / interventions)
 private static void SerializeOtherTreatments(NciUrl url, CTSSearchParams searchParms)
 {
     if (searchParms.IsFieldSet(FormFields.OtherTreatments))
     {
         url.QueryParameters.Add("i", SerializeMultiTermFields(searchParms.OtherTreatments));
     }
 }
Beispiel #12
0
 // Parameter va (Search VA Only)
 private static void SerializeIsVAOnly(NciUrl url, CTSSearchParams searchParams)
 {
     if (searchParams.IsFieldSet(FormFields.IsVAOnly))
     {
         url.QueryParameters.Add("va", searchParams.IsVAOnly ? "1" : "0");
     }
 }
Beispiel #13
0
        // Parameter loc (Location, and AtNIH if loc=nih)
        private static void SerializeLocation(NciUrl url, CTSSearchParams searchParams)
        {
            url.QueryParameters.Add("loc", searchParams.Location.ToString("d"));

            if (url.QueryParameters.ContainsKey("loc"))
            {
                switch (searchParams.Location)
                {
                //None needs not to be set
                //AtNIH is all that is needed for NIH
                case LocationType.Zip:
                {
                    SerializeZipCode(url, searchParams);
                    break;
                }

                case LocationType.CountryCityState:
                {
                    SerializeCountryCityState(url, searchParams);
                    break;
                }

                case LocationType.Hospital:
                {
                    SerializeHospital(url, searchParams);
                    break;
                }
                }
            }
        }
Beispiel #14
0
 // Parameter hv (Healthy Volunteers)
 private static void SerializeHealthyVolunteers(NciUrl url, CTSSearchParams searchParams)
 {
     if (searchParams.IsFieldSet(FormFields.HealthyVolunteers))
     {
         url.QueryParameters.Add("hv", searchParams.HealthyVolunteer.ToString("d")); //Output the decimal value of the enum as a string.
     }
 }
Beispiel #15
0
 //Parameter q (Keyword/Phrase)
 private static void SerializeKeyword(NciUrl url, CTSSearchParams searchParams)
 {
     if (searchParams.IsFieldSet(FormFields.Phrase))
     {
         url.QueryParameters.Add("q", HttpUtility.UrlEncode(searchParams.Phrase));
     }
 }
Beispiel #16
0
 // Parameter a (Age)
 private static void SerializeAge(NciUrl url, CTSSearchParams searchParams)
 {
     if (searchParams.IsFieldSet(FormFields.Age))
     {
         url.QueryParameters.Add("a", searchParams.Age.ToString());
     }
 }
Beispiel #17
0
 // Parameter va (VA Only Search)
 private void ParseIsVAOnly(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "va"))
     {
         int va = url.CTSParamAsInt("va", -1);
         if (va == -1)
         {
             LogParseError(FormFields.IsVAOnly, "Please enter a valid VA facility search parameter.", searchParams);
         }
         else if (va > 1)
         {
             LogParseError(FormFields.IsVAOnly, "Please enter a valid VA facility search parameter.", searchParams);
         }
         else
         {
             if (va == 0)
             {
                 searchParams.IsVAOnly = false;
             }
             else
             {
                 searchParams.IsVAOnly = true;
             }
         }
     }
 }
Beispiel #18
0
 //Parameter stg (Stages)
 private void ParseStages(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "stg"))
     {
         searchParams.Stages = GetTermFieldFromParam(url.QueryParameters["stg"], FormFields.Stages, searchParams);
     }
 }
Beispiel #19
0
        /// <summary>
        /// Gets a query parameter as an int or uses a default
        /// </summary>
        /// <param name="param"></param>
        /// <param name="def"></param>
        /// <param name="isInvalid">An output variable indicating if the value was set, but was NOT a valid int</param>
        /// <returns></returns>
        public static int CTSParamAsInt(this NciUrl url, string param, int def)
        {
            string paramval = url.QueryParameters[param];
            bool   isInvalid;

            return(ParamAsInt(paramval, def, out isInvalid));
        }
            public string GetPagerUrl(NciUrl basePageUrl, string first, string page)
            {
                NciUrl pagerUrl = basePageUrl;

                if(!pagerUrl.QueryParameters.ContainsKey("first"))
                {
                    pagerUrl.QueryParameters.Add("first", first);
                }
                else
                {
                    pagerUrl.QueryParameters.Remove("first");
                    pagerUrl.QueryParameters.Add("first", first);
                }

                if (!pagerUrl.QueryParameters.ContainsKey("page"))
                {
                    pagerUrl.QueryParameters.Add("page", page);
                }
                else
                {
                    pagerUrl.QueryParameters.Remove("page");
                    pagerUrl.QueryParameters.Add("page", page);
                }

                return pagerUrl.ToString();
            }
Beispiel #21
0
        /// <summary>
        /// Method called to redirect old search URLs to the new search URL
        /// </summary>
        protected void RedirectToResultsList(string searchString, string contains, string first, string page)
        {
            NciUrl redirectURL = new NciUrl();

            redirectURL.SetUrl(GetSearchUrl());

            redirectURL.QueryParameters.Add("q", searchString);

            if (contains.Equals("true"))
            {
                redirectURL.QueryParameters.Add("contains", contains);
            }

            if (!string.IsNullOrEmpty(first))
            {
                redirectURL.QueryParameters.Add("first", first);
            }

            if (!string.IsNullOrEmpty(page))
            {
                redirectURL.QueryParameters.Add("page", page);
            }

            // Add redirect query parameter for analytics
            redirectURL.QueryParameters.Add("redirect", "true");

            NCI.Web.CDE.Application.PermanentRedirector.DoPermanentRedirect(Response, redirectURL.ToString(), "Dictionary Friendly Name Redirect");
        }
Beispiel #22
0
        /// <summary>
        /// This sets up the Original Pretty URL, the current full URL and the app path
        /// </summary>
        private void SetupUrls()
        {
            //We want to use the PURL for this item.
            //NOTE: THIS
            NciUrl purl = this.PageInstruction.GetUrl(PageAssemblyInstructionUrls.PrettyUrl);

            if (purl == null || string.IsNullOrWhiteSpace(purl.ToString()))
            {
                throw new Exception("DynamicTrialListingPageDiseaseControl requires current PageAssemblyInstruction to provide its PrettyURL through GetURL.  PrettyURL is null or empty.");
            }

            //It is expected that this is pure and only the pretty URL of this page.
            //This means that any elements on the same page as this app should NOT overwrite the
            //PrettyURL URL Filter.
            this.PrettyUrl = purl.ToString();

            //Now, that we have the PrettyURL, let's figure out what the app paths are...
            NciUrl currURL = new NciUrl();

            currURL.SetUrl(HttpContext.Current.Request.RawUrl);
            currURL.SetUrl(currURL.UriStem);

            //Make sure this URL starts with the pretty url
            if (currURL.UriStem.ToLower().IndexOf(this.PrettyUrl.ToLower()) != 0)
            {
                throw new Exception(String.Format("JSApplicationProxy: Cannot Determine App Path for Page, {0}, with PrettyURL {1}.", currURL.UriStem, PrettyUrl));
            }

            this.CurrentUrl = currURL;
        }
Beispiel #23
0
 //Parameter i (Other treatments / interventions)
 private void ParseOtherTreatments(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "i"))
     {
         searchParams.OtherTreatments = GetTermFieldFromParam(url.QueryParameters["i"], FormFields.OtherTreatments, searchParams);
     }
 }
Beispiel #24
0
        /// <summary>
        /// Parses the URL for all of the parameters for an intervention dynamic listing page
        /// </summary>
        protected override void ParseURL()
        {
            if (this.CurrAppPath == "/")
            {
                throw new HttpException(400, "Invalid Parameters");
            }

            List <string> rawParams = new List <string>();

            if (this.IsNoTrials)
            {
                NciUrl ParsedReqUrlParams = new NciUrl(true, true, true);  //We need this to be lowercase and collapse duplicate params. (Or not use an NCI URL)
                ParsedReqUrlParams.SetUrl(this.Request.Url.Query);


                if (ParsedReqUrlParams.QueryParameters.Count == 0)
                {
                    throw new HttpException(400, "Invalid Parameters");
                }

                rawParams = GetRawParametersFromQueryString(ParsedReqUrlParams);
                SetDoNotIndex();
                Response.StatusCode             = 404;
                Response.TrySkipIisCustomErrors = true;
            }
            else
            {
                rawParams = this.CurrAppPath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries).ToList <string>();
            }

            SetUpRawParametersForListingPage(rawParams);
            SetUpCanonicalUrl();
        }
Beispiel #25
0
 //Parameter d (Drugs)
 private void ParseDrugs(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "d"))
     {
         searchParams.Drugs = GetTermFieldFromParam(url.QueryParameters["d"], FormFields.Drugs, searchParams);
     }
 }
Beispiel #26
0
 //Parameter tt (Trial Type)
 private void ParseTrialTypes(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "tt"))
     {
         searchParams.TrialTypes = GetLabelledFieldFromParam(url.QueryParameters["tt"], FormFields.TrialTypes, searchParams);
     }
 }
Beispiel #27
0
        //Parameter hos (Hospital)
        private void ParseHospital(NciUrl url, CTSSearchParams searchParams)
        {
            HospitalLocationSearchParams locParams = new HospitalLocationSearchParams();
            bool hasInvalidParam = false;

            if (IsInUrl(url, "hos"))
            {
                string hospital = url.CTSParamAsStr("hos");
                if (!string.IsNullOrWhiteSpace(hospital))
                {
                    locParams.Hospital = hospital;
                }
                else
                {
                    hasInvalidParam = true;
                    LogParseError(FormFields.Hospital, "Please enter a valid hospital/institution parameter.", searchParams);
                }
            }
            else
            {
                hasInvalidParam = true;
                LogParseError(FormFields.Hospital, "Please enter a valid hospital/institution parameter.", searchParams);
            }

            if (!hasInvalidParam)
            {
                searchParams.LocationParams = locParams;
            }
            else
            {
                searchParams.LocationParams = new HospitalLocationSearchParams();
            }
        }
Beispiel #28
0
        // Parameter z (Zip Code) && zp (Zip Proximity)
        private void ParseZipCode(NciUrl url, CTSSearchParams searchParams)
        {
            ZipCodeLocationSearchParams locParams = new ZipCodeLocationSearchParams();

            searchParams.LocationParams = locParams;

            if (IsInUrl(url, "z"))
            {
                string zipCode = url.CTSParamAsStr("z");

                if (string.IsNullOrWhiteSpace(zipCode) || (zipCode.Length < 5))
                {
                    LogParseError(FormFields.ZipCode, "Please enter a valid zip code value.", searchParams);
                }

                string pattern = @"^[0-9]{5}$";
                if (Regex.IsMatch(zipCode, pattern))
                {
                    GeoLocation geolocation = this._zipLookupSvc.GetZipCodeGeoEntry(zipCode);
                    if (geolocation != null)
                    {
                        locParams.ZipCode     = zipCode;
                        locParams.GeoLocation = geolocation;

                        if (IsInUrl(url, "zp"))
                        {
                            int zipRadius = url.CTSParamAsInt("zp", -1);
                            if (zipRadius < 1 || zipRadius > 12451)
                            {
                                LogParseError(FormFields.ZipRadius, "Please enter a valid zip radius value.", searchParams);
                                searchParams.LocationParams = new ZipCodeLocationSearchParams();
                            }
                            else
                            {
                                locParams.ZipRadius         = zipRadius;
                                searchParams.LocationParams = locParams;
                            }
                        }
                        else
                        {
                            searchParams.LocationParams = locParams;
                        }
                    }
                    else
                    {
                        LogParseError(FormFields.ZipCode, "Please enter a valid zip code value.", searchParams);
                    }
                }
                else
                {
                    LogParseError(FormFields.ZipCode, "Please enter a valid zip code value.", searchParams);
                }
            }
            else
            {
                //Handle when zipcode has not been specified, but location type is zip code
                LogParseError(FormFields.ZipCode, "Please enter a valid zip code value.", searchParams);
            }
        }
Beispiel #29
0
        /// <summary>
        /// Serialize the parameters to a URL
        /// </summary>
        /// <param name="searchParams">The search parameters to serialize</param>
        /// <returns>A URL with query params.</returns>
        public static NciUrl ConvertParamsToUrl(CTSSearchParams searchParams)
        {
            NciUrl url = new NciUrl();

            _paramSerializers(url, searchParams);

            return(url);
        }
Beispiel #30
0
        /// <summary>
        /// Gets an instance of a CTSSearchParams object based on params in URL.
        /// </summary>
        /// <param name="url">The URL to parse</param>
        /// <returns></returns>
        public CTSSearchParams Create(string url)
        {
            NciUrl reqUrl = new NciUrl(true, true, true);

            reqUrl.SetUrl(url);

            return(Create(reqUrl));
        }