示例#1
0
        private string FormatPrintResults(IEnumerable <ClinicalTrial> results, DateTime searchDate, CTSSearchParams searchTerms)
        {
            string searchUrl = _config.BasicSearchPagePrettyUrl;

            if (searchTerms.ResultsLinkFlag == ResultsLinkType.Advanced)
            {
                searchUrl = _config.AdvSearchPagePrettyUrl;
            }

            PrintVelocityHelpers helpers = new PrintVelocityHelpers(_config);

            // Bind results to velocity template
            LiteralControl ltl = new LiteralControl(VelocityTemplate.MergeTemplateWithResultsByFilepath(
                                                        _config.PrintPageTemplatePath,
                                                        new
            {
                Control     = new { SearchFormUrl = searchUrl },
                Results     = results,
                SearchDate  = searchDate.ToString("M/d/yyyy"),
                Parameters  = searchTerms,
                PrintHelper = helpers,
                TrialTools  = new TrialVelocityTools()
            }
                                                        ));

            return(ltl.Text);
        }
示例#2
0
        //protected override void OnLoad(EventArgs e)
        //{
        //    base.OnLoad(e);
        //    processData();
        //}

        #endregion

        #region Private Methods
        private void processData()
        {
            try
            {
                if (this.BlogSearchList != null)
                {
                    // Validate();


                    string siteName = SiteName;



                    // Call the  datamanger to perform the search
                    ICollection <SeriesPrevNextResult> searchResults =
                        BlogSearchDataManager.Execute(this.BlogSearchList.Filter, this.BlogSearchList.ContentID,
                                                      this.BlogSearchList.Language, Settings.IsLive, siteName);

                    BlogSearchResult blogSearch = new BlogSearchResult();
                    blogSearch.Results = searchResults;

                    blogSearch.SiteName = siteName;


                    LiteralControl ltl = new LiteralControl(VelocityTemplate.MergeTemplateWithResults(this.BlogSearchList.ResultsTemplate, blogSearch));
                    Controls.Add(ltl);
                }
            }
            catch (Exception ex)
            {
                log.Error("this.SearchListSnippet:processData", ex);
            }
        }
示例#3
0
 public HealthCheckModule(IHealthCheckHandler healthCheckHandler, List <string> templateAssemblies, string templateName)
     : base("/healthcheck")
 {
     RegisterRoutes();
     template                = new VelocityTemplate(templateAssemblies);
     this.templateName       = templateName;
     this.healthCheckHandler = healthCheckHandler;
 }
        protected sealed override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            ///////////////////////////
            // Parse the page specific parameters
            if (ParsedReqUrlParams.IsInUrl("pn"))
            {
                this._pageNum = ParsedReqUrlParams.CTSParamAsInt(PAGENUM_PARAM, 1);
            }

            if (ParsedReqUrlParams.IsInUrl("ni"))
            {
                //_itemsPerPage can come from the config.  This is setup on init
                this._itemsPerPage = ParsedReqUrlParams.CTSParamAsInt(ITEMSPP_PARAM, _itemsPerPage);
            }

            //Get the Query object
            JObject query = SetupQueryForListing();

            //fetch results
            var results = _basicCTSManager.GetClinicalTrials(
                query,
                this._pageNum,
                this._itemsPerPage
                );

            //CODE ADDED BY CHRISTIAN RIKONG ON 12/07/2017 at 03:07 PM - THE GOAL IS THAT WHEN THERE ARE NO TRIALS RESULTS, WE
            //REDIRECT TO THE NOTRIALS PAGE

            if (results == null || (results.TotalResults == 0))
            {
                this.OnEmptyResults();
            }

            this.TotalSearchResults = results.TotalResults;

            //Load VM File and show search results
            LiteralControl ltl = new LiteralControl(VelocityTemplate.MergeTemplateWithResultsByFilepath(
                                                        this.BaseConfig.ResultsPageTemplatePath,
                                                        new
            {
                Results    = results,
                Control    = this,
                TrialTools = new TrialVelocityTools()
            }
                                                        ));

            Controls.Add(ltl);

            //DO WE NOT SETUP URLS?

            // Setup web analytics
            this.SetAnalytics();
        }
示例#5
0
        public HealthCheckModule() : base("/healthcheck")
        {
            RegisterRoutes();

            template = new VelocityTemplate(new List <string>(new[] {
                typeof(IHealthCheck).Assembly.GetName().Name
            }));

            templateName = @"Common.HealthCheck.Template.Views.Index.htm";

            healthCheckHandler = IoCContainer.Instance.HealthCheckHandler;
        }
示例#6
0
        /// <summary>
        /// Overrides the OnPreRender event and forces derrived classes to handle events here.
        /// </summary>
        /// <param name="e"></param>
        protected override sealed void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            string templatePath = this.GetTemplatePath();
            object templateData = this.GetDataForTemplate();

            LiteralControl ltl = new LiteralControl(VelocityTemplate.MergeTemplateWithResultsByFilepath(
                                                        templatePath,
                                                        templateData
                                                        )
                                                    );

            Controls.Add(ltl);

            SetAnalytics();
        }
        public void FromFile()
        {
            var destPath = _res.CopyToBaseDirectory();

            AssertTemplate(VelocityTemplate.FromFile(destPath));
        }
 public void FromResource()
 {
     AssertTemplate(VelocityTemplate.FromResource(_res));
 }
        public void FromString()
        {
            var tplText = _res.ReadAllText(Encoding.UTF8);

            AssertTemplate(VelocityTemplate.FromString(tplText));
        }
示例#10
0
        private void processData()
        {
            try
            {
                if (this.SearchList != null)
                {
                    // Validate();

                    int actualMaxResult = this.SearchList.MaxResults;

                    DateTime startDate = StartDate, endDate = EndDate;
                    string   keyWord  = KeyWords;
                    string   siteName = SiteName;
                    if (this.SearchList.SearchType == "keyword")
                    {
                        startDate = DateTime.MinValue;
                        endDate   = DateTime.MaxValue;
                    }
                    else if (this.SearchList.SearchType == "date")
                    {
                        keyWord = string.Empty;
                    }

                    int year = 0;
                    Dictionary <string, string> filters = GetUrlFilters();
                    if (startDate == DateTime.MinValue && endDate == DateTime.MaxValue && filters.ContainsKey("year"))
                    {
                        try
                        {
                            year = Int32.Parse(filters["year"]);
                            if (filters.ContainsKey("month"))
                            {
                                try
                                {
                                    int month   = Int32.Parse(filters["month"]);
                                    int lastDay = DateTime.DaysInMonth(year, month);
                                    startDate = new DateTime(year, month, 1);
                                    endDate   = new DateTime(year, month, lastDay);
                                }
                                catch
                                {
                                    NCI.Web.CDE.Application.ErrorPageDisplayer.RaisePageByCode("BaseSearchSnippet", 404, "Invalid month parameter in dynamic list filter");
                                }
                            }
                            else
                            {
                                startDate = new DateTime(year, 1, 1);
                                endDate   = new DateTime(year, 12, 31);
                            }
                        }
                        catch
                        {
                            NCI.Web.CDE.Application.ErrorPageDisplayer.RaisePageByCode("BaseSearchSnippet", 404, "Invalid year parameter in dynamic list filter");
                        }
                    }

                    if (startDate == DateTime.MinValue && endDate == DateTime.MaxValue && filters.ContainsKey("month") && !filters.ContainsKey("year"))
                    {
                        NCI.Web.CDE.Application.ErrorPageDisplayer.RaisePageByCode("BaseSearchSnippet", 404, "Invalid parameter in dynamic list filter: cannot have month without year");
                    }

                    List <TaxonomyFilter> filtersForSql = new List <TaxonomyFilter>(this.SearchList.SearchFilters.TaxonomyFilters.Where(filter => filter.Taxons.Count() > 0));
                    foreach (KeyValuePair <string, string> entry in filters)
                    {
                        if (entry.Key != "year" && entry.Key != "month")
                        {
                            bool contains = filtersForSql.Any(filter => filter.TaxonomyName == entry.Key);
                            if (!contains)
                            {
                                TaxonomyFilter newFilter = new TaxonomyFilter();
                                newFilter.TaxonomyName = entry.Key;
                                List <int>   taxonIDs  = entry.Value.Split(',').Select(Int32.Parse).ToList();
                                List <Taxon> newTaxons = new List <Taxon>();
                                foreach (int ID in taxonIDs)
                                {
                                    Taxon newTaxon = new Taxon();
                                    newTaxon.ID = ID;
                                    newTaxons.Add(newTaxon);
                                }
                                newFilter.Taxons = newTaxons.ToArray <Taxon>();
                                filtersForSql.Add(newFilter);
                            }
                        }
                    }


                    // Call the  datamanger to perform the search
                    ICollection <SearchResult> searchResults =
                        SearchDataManager.Execute(CurrentPage,
                                                  startDate,
                                                  endDate,
                                                  keyWord,
                                                  ReturnTaxonomySqlParam(filtersForSql),
                                                  this.SearchList.RecordsPerPage,
                                                  this.SearchList.MaxResults,
                                                  this.SearchList.SearchFilter,
                                                  this.SearchList.ExcludeSearchFilter,
                                                  this.SearchList.ResultsSortOrder,
                                                  this.SearchList.Language,
                                                  Settings.IsLive,
                                                  out actualMaxResult, siteName);

                    DynamicSearch dynamicSearch = new DynamicSearch();
                    dynamicSearch.Results         = searchResults;
                    dynamicSearch.StartDate       = String.Format("{0:MM/dd/yyyy}", startDate);
                    dynamicSearch.EndDate         = String.Format("{0:MM/dd/yyyy}", endDate);
                    dynamicSearch.KeyWord         = keyWord;
                    dynamicSearch.SiteName        = siteName;
                    dynamicSearch.DisqusShortname = this.SearchList.DisqusShortname;
                    dynamicSearch.SearchTitle     = this.SearchList.SearchTitle;

                    // check if the site is in production
                    bool isProd = PageAssemblyContext.Current.IsProd;
                    // append a shortname prefix based on the production state
                    dynamicSearch.DisqusShortname = dynamicSearch.DisqusShortname + (isProd ? "-prod" : "-dev");

                    this.PageInstruction.AddUrlFilter("Print", (name, url) =>
                    {
                        if (url.QueryParameters.ContainsKey("keyword") == false)
                        {
                            url.QueryParameters.Add("keyword", keyWord);
                        }
                        if (!((dynamicSearch.StartDate == "01/01/0001") || (dynamicSearch.EndDate == "12/31/9999")))
                        {
                            url.QueryParameters.Add("startmonth", startDate.Month.ToString());
                            url.QueryParameters.Add("startyear", startDate.Year.ToString());
                            url.QueryParameters.Add("endmonth", endDate.Month.ToString());
                            url.QueryParameters.Add("endyear", endDate.Year.ToString());
                        }
                    });

                    if (actualMaxResult > 0)
                    {
                        if (CurrentPage > 1)
                        {
                            dynamicSearch.StartCount = (this.SearchList.RecordsPerPage * (CurrentPage - 1)) + 1;
                        }
                        else
                        {
                            dynamicSearch.StartCount = 1;
                        }

                        if (CurrentPage == 1)
                        {
                            dynamicSearch.EndCount = this.SearchList.RecordsPerPage;
                            if (searchResults.Count < this.SearchList.RecordsPerPage)
                            {
                                dynamicSearch.EndCount = actualMaxResult;
                            }
                        }
                        else
                        {
                            dynamicSearch.EndCount = dynamicSearch.StartCount + this.SearchList.RecordsPerPage - 1;
                            if (searchResults.Count < this.SearchList.RecordsPerPage)
                            {
                                dynamicSearch.EndCount = actualMaxResult;
                            }
                        }
                    }

                    int recCount = 0;
                    foreach (SearchResult sr in searchResults)
                    {
                        sr.RecNumber = dynamicSearch.StartCount + recCount++;
                    }

                    int validCount = this.SearchList.MaxResults;

                    if (actualMaxResult < this.SearchList.MaxResults || this.SearchList.MaxResults == 0)
                    {
                        validCount = actualMaxResult;
                    }
                    else
                    {
                        validCount = this.SearchList.MaxResults;
                    }

                    dynamicSearch.ResultCount = validCount;
                    LiteralControl ltl = new LiteralControl(VelocityTemplate.MergeTemplateWithResultsByFilepath(this.SearchList.ResultsTemplate, dynamicSearch));
                    Controls.Add(ltl);

                    if (this.SearchList.ResultsTemplate.Contains("Blog"))
                    {
                        SetupBlogPager(this.SearchList.RecordsPerPage, validCount, filters);
                    }
                    else
                    {
                        SetupPager(this.SearchList.RecordsPerPage, validCount, filters);
                    }
                }
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (Exception ex)
            {
                log.Error("this.SearchListSnippet:processData", ex);
            }
        }