Example #1
0
        public void DeassignService(int agentInstanceId)
        {
            LookupStrategies.DeassignService(agentInstanceId);
            AggregationServices?.DeassignService(agentInstanceId);

            PriorEvalStrategies?.DeassignService(agentInstanceId);

            PreviousGetterStrategies?.DeassignService(agentInstanceId);
        }
Example #2
0
        public void Assign(
            int agentInstanceId,
            SubordTableLookupStrategy lookupStrategy,
            AggregationService aggregationService,
            PriorEvalStrategy priorEvalStrategy,
            PreviousGetterStrategy previousGetterStrategy)
        {
            LookupStrategies.AssignService(agentInstanceId, lookupStrategy);
            AggregationServices?.AssignService(agentInstanceId, aggregationService);

            PriorEvalStrategies?.AssignService(agentInstanceId, priorEvalStrategy);

            PreviousGetterStrategies?.AssignService(agentInstanceId, previousGetterStrategy);
        }
Example #3
0
        public void DeassignService(int agentInstanceId)
        {
            LookupStrategies.DeassignService(agentInstanceId);
            if (AggregationServices != null) {
                AggregationServices.DeassignService(agentInstanceId);
            }

            if (PriorEvalStrategies != null) {
                PriorEvalStrategies.DeassignService(agentInstanceId);
            }

            if (PreviousGetterStrategies != null) {
                PreviousGetterStrategies.DeassignService(agentInstanceId);
            }
        }
Example #4
0
        public static void ComputeData(Stopwatch sw)
        {
            sw.Restart();
            var sessFactFactory = new SessionFactoryFactory(false);
            var sessionFactory  = sessFactFactory.GetSessionFactory();
            var repository      = new Repository(sessionFactory);

            repository.Clear();

            AggregationServices services = new AggregationServices(repository);

            services.ReAggregateAllOperations();
            sw.Stop();
            Console.WriteLine("Profiles computed in: {0}", sw.ElapsedMilliseconds);
            sw.Restart();
            services.ComputeBalancesForAllAccounts();

            repository.Flush();
            sw.Stop();
            Console.WriteLine("Balances computed in: {0}", sw.ElapsedMilliseconds);
        }
Example #5
0
 /// <summary> Add a new aggregation to the system </summary>
 /// <param name="NewAggregation"> Information for the new aggregation </param>
 /// <returns> Message indicating success or any errors encountered </returns>
 public RestResponseMessage Add_New_Aggregation(New_Aggregation_Arguments NewAggregation)
 {
     return(AggregationServices.add_new_aggregation(NewAggregation));
 }
Example #6
0
 /// <summary> Gets the entire collection hierarchy (used for hierarchical tree displays) </summary>
 /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
 /// <returns> Fully built aggregation hierarchy </returns>
 public Aggregation_Hierarchy Get_Aggregation_Hierarchy(Custom_Tracer Tracer)
 {
     return(AggregationServices.get_aggregation_hierarchy(Tracer));
 }
Example #7
0
 /// <summary> Gets the all information, including the HTML, for an item aggregation child page </summary>
 /// <param name="AggregationCode"> Code for the aggregation </param>
 /// <param name="RequestedLanguage"> Requested language to retrieve </param>
 /// <param name="DefaultLanguage"> Default interface language, in case the requested language does not exist </param>
 /// <param name="ChildPageCode"> Code the requested child page </param>
 /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
 /// <returns> Fully built object, based on the aggregation configuration and reading the source HTML file </returns>
 public HTML_Based_Content Get_Aggregation_HTML_Child_Page(string AggregationCode, Web_Language_Enum RequestedLanguage, Web_Language_Enum DefaultLanguage, string ChildPageCode, Custom_Tracer Tracer)
 {
     return(AggregationServices.get_item_aggregation_html_child_page(AggregationCode, RequestedLanguage, DefaultLanguage, ChildPageCode, Tracer));
 }
Example #8
0
 /// <summary> Gets the language-specific item aggregation, by aggregation code and language code </summary>
 /// <param name="AggregationCode"> Code for the aggregation </param>
 /// <param name="RequestedLanguage"> Requested language to retrieve </param>
 /// <param name="DefaultLanguage"> Default interface language, in case the requested language does not exist </param>
 /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
 /// <returns> Built language-specific item aggregation object  </returns>
 public Item_Aggregation Get_Aggregation(string AggregationCode, Web_Language_Enum RequestedLanguage, Web_Language_Enum DefaultLanguage, Custom_Tracer Tracer)
 {
     return(AggregationServices.get_item_aggregation(AggregationCode, RequestedLanguage, DefaultLanguage, Tracer));
 }
Example #9
0
 /// <summary> Gets the complete (language agnostic) item aggregation, by aggregation code </summary>
 /// <param name="AggregationCode"> Code for the requested aggregation </param>
 /// <param name="UseCache"> Flag indicates if the cache should be used to check for a built copy or store the final product </param>
 /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
 /// <returns> Fully built language-agnostic aggregation, with all related configurations </returns>
 public Complete_Item_Aggregation Get_Complete_Aggregation(string AggregationCode, bool UseCache, Custom_Tracer Tracer)
 {
     return(AggregationServices.get_complete_aggregation(AggregationCode, UseCache, Tracer));
 }
        /// <summary> Get just the search statistics information for a search or browse </summary>
        /// <param name="Response"></param>
        /// <param name="UrlSegments"></param>
        /// <param name="QueryString"></param>
        /// <param name="Protocol"></param>
        /// <param name="IsDebug"></param>
        public void NewEndpoint_Results_JSON(HttpResponse Response, List <string> UrlSegments, NameValueCollection QueryString, Microservice_Endpoint_Protocol_Enum Protocol, bool IsDebug)
        {
            Custom_Tracer tracer = new Custom_Tracer();

            tracer.Add_Trace("NewEndpointServices.NewEndpoint_Results_JSON", "Parse request to determine search requested");

            // Get all the searh field necessary from the query string
            Results_Arguments args = new Results_Arguments(QueryString);

            // Additional results arguments
            // limit number of results
            int     artificial_result_limitation = -1;
            Boolean isNumeric = false;

            if (!String.IsNullOrEmpty(QueryString["limit_results"]))
            {
                isNumeric = Int32.TryParse(QueryString["limit_results"], out artificial_result_limitation);

                if (!isNumeric)
                {
                    artificial_result_limitation = -1;
                }
                else if (artificial_result_limitation < 1)
                {
                    artificial_result_limitation = -1;
                }
            }

            int pagenum = 1;

            if (!String.IsNullOrEmpty(QueryString["page"]))
            {
                isNumeric = Int32.TryParse(QueryString["page"], out pagenum);

                if (!isNumeric)
                {
                    pagenum = 1;
                }
                else if (pagenum < 1)
                {
                    pagenum = 1;
                }
                else if (pagenum > 1)
                {
                    artificial_result_limitation = -1;
                }
            }

            // limit title length, in words
            int artificial_title_length_limitation = -1;

            if (!String.IsNullOrEmpty(QueryString["title_length"]))
            {
                isNumeric = Int32.TryParse(QueryString["title_length"], out artificial_title_length_limitation);

                if (!isNumeric)
                {
                    artificial_title_length_limitation = -1;
                }
                else if (artificial_title_length_limitation < 1)
                {
                    artificial_title_length_limitation = -1;
                }
            }

            Boolean include_metadata = false;

            if (!String.IsNullOrEmpty(QueryString["metadata"]))
            {
                include_metadata = true;
            }

            // Was a collection indicated?
            if (UrlSegments.Count > 0)
            {
                args.Aggregation = UrlSegments[0];
            }

            // Get the aggregation object (we need to know which facets to use, etc.. )
            tracer.Add_Trace("NewEndpointServices.NewEndpoint_Results_JSON", "Get the '" + args.Aggregation + "' item aggregation (for facets, etc..)");
            Complete_Item_Aggregation aggr = AggregationServices.get_complete_aggregation(args.Aggregation, true, tracer);

            // If no aggregation was returned, that is an error
            if (aggr == null)
            {
                tracer.Add_Trace("NewEndpointServices.NewEndpoint_Results_JSON", "Returned aggregation was NULL... aggregation code may not be valid");

                if (IsDebug)
                {
                    Response.ContentType = "text/plain";
                    Response.Output.WriteLine("DEBUG MODE DETECTED");
                    Response.Output.WriteLine();
                    Response.Output.WriteLine(tracer.Text_Trace);
                    return;
                }

                Response.ContentType = "text/plain";
                Response.Output.WriteLine("Error occurred or aggregation '" + args.Aggregation + "' not valid");
                Response.StatusCode = 500;
                return;
            }

            // Perform the search
            tracer.Add_Trace("NewEndpointServices.NewEndpoint_Results_JSON", "Perform the search");
            Search_Results_Statistics   resultsStats;
            List <iSearch_Title_Result> resultsPage;
            ResultsEndpointErrorEnum    error = Get_Search_Results(args, aggr, false, tracer, out resultsStats, out resultsPage);


            // Was this in debug mode?
            // If this was debug mode, then just write the tracer
            if (IsDebug)
            {
                Response.ContentType = "text/plain";
                Response.Output.WriteLine("DEBUG MODE DETECTED");
                Response.Output.WriteLine();
                Response.Output.WriteLine(tracer.Text_Trace);
                return;
            }

            Response.Output.WriteLine("{\"stats\":{\"total_items\":\"" + resultsStats.Total_Items + "\",\"total_titles\":\"" + resultsStats.Total_Titles + "\"},");
            Response.Output.WriteLine(" \"results\":[");

            // Map to the results object title / item
            tracer.Add_Trace("ResultsServices.NewEndpoint_Results_JSON", "Map to the results object title / item");
            int items_counter = 0;
            int resultnum     = 0;

            if (resultsPage != null)
            {
                foreach (iSearch_Title_Result thisResult in resultsPage)
                {
                    // Every results should have an item
                    if (thisResult.Item_Count == 0)
                    {
                        continue;
                    }
                    else
                    {
                        resultnum++;
                    }

                    if (artificial_result_limitation != -1 && resultnum > artificial_result_limitation)
                    {
                        tracer.Add_Trace("NewEndpointServices.Get_Search_Results_Set", "Reached limit [" + artificial_result_limitation + "].");
                        break;
                    }
                    // Was this NOT the first item?
                    if (items_counter > 0)
                    {
                        Response.Output.WriteLine(",");
                    }

                    Response.Output.Write("        ");
                    items_counter++;

                    // add each descriptive field over
                    iSearch_Item_Result itemResult = thisResult.Get_Item(0);

                    string bibid     = thisResult.BibID;
                    string title     = thisResult.GroupTitle;
                    string vid       = itemResult.VID;
                    string thumbnail = itemResult.MainThumbnail;

                    title = Process_Title(title, artificial_title_length_limitation);

                    // {"bibid":"1212", "vid":"00001", "title":"sdsd", "subjects":["subj1", "subj2", "subj3"] },

                    Response.Output.Write("{ \"bibid\":\"" + bibid + "\", \"vid\":\"" + vid + "\", ");
                    Response.Output.Write("\"title\":\"" + HttpUtility.HtmlEncode(title) + "\",");
                    Response.Output.Write("\"url_item\":\"" + Engine_ApplicationCache_Gateway.Settings.Servers.Application_Server_URL + bibid + "/" + vid + "/\",");
                    Response.Output.Write("\"url_thumbnail\":\"" + Engine_ApplicationCache_Gateway.Settings.Servers.Image_URL +
                                          SobekFileSystem.AssociFilePath(bibid, vid).Replace("\\", "/") + thumbnail + "\"");

                    int field_index = 0;

                    if (resultsStats.Metadata_Labels.Count > 0 && include_metadata)
                    {
                        foreach (string metadataTerm in resultsStats.Metadata_Labels)
                        {
                            if (!String.IsNullOrWhiteSpace(thisResult.Metadata_Display_Values[field_index]))
                            {
                                // how to display this metadata field?
                                string metadataTermDisplay = metadataTerm.ToLower();

                                string termString = thisResult.Metadata_Display_Values[field_index];
                                Response.Output.Write(",\"" + metadataTermDisplay + "\":[");

                                int individual_term_counter = 0;

                                if (termString.IndexOf("|") > 0)
                                {
                                    string[] splitter = termString.Split("|".ToCharArray());

                                    foreach (string thisSplit in splitter)
                                    {
                                        if (!String.IsNullOrWhiteSpace(thisSplit))
                                        {
                                            if (individual_term_counter > 0)
                                            {
                                                Response.Output.Write(", \"" + HttpUtility.HtmlEncode(thisSplit.Trim()) + "\"");
                                            }
                                            else
                                            {
                                                Response.Output.Write("\"" + HttpUtility.HtmlEncode(thisSplit.Trim()) + "\"");
                                            }

                                            individual_term_counter++;
                                        }
                                    }
                                }
                                else
                                {
                                    Response.Output.Write("\"" + HttpUtility.HtmlEncode(termString.Trim()) + "\"");
                                }

                                Response.Output.Write("]");
                            }

                            field_index++;
                        }
                    }

                    Response.Output.Write("}");
                }
            }

            Response.Output.WriteLine();
            Response.Output.WriteLine("    ]");
            Response.Output.WriteLine("} ");

            // If an error occurred, return the error
            switch (error)
            {
            case ResultsEndpointErrorEnum.Database_Exception:
                Response.ContentType = "text/plain";
                Response.Output.WriteLine("Database exception");
                Response.StatusCode = 500;
                return;

            case ResultsEndpointErrorEnum.Database_Timeout_Exception:
                Response.ContentType = "text/plain";
                Response.Output.WriteLine("Database timeout");
                Response.StatusCode = 500;
                return;

            case ResultsEndpointErrorEnum.Solr_Exception:
                Response.ContentType = "text/plain";
                Response.Output.WriteLine("Solr exception");
                Response.StatusCode = 500;
                return;

            case ResultsEndpointErrorEnum.Unknown:
                Response.ContentType = "text/plain";
                Response.Output.WriteLine("Unknown error");
                Response.StatusCode = 500;
                return;
            }
        }
        /// <summary> Get just the search statistics information for a search or browse </summary>
        /// <param name="Response"></param>
        /// <param name="UrlSegments"></param>
        /// <param name="QueryString"></param>
        /// <param name="Protocol"></param>
        /// <param name="IsDebug"></param>
        public void NewEndpoint_Results_XML(HttpResponse Response, List <string> UrlSegments, NameValueCollection QueryString, Microservice_Endpoint_Protocol_Enum Protocol, bool IsDebug)
        {
            Custom_Tracer tracer = new Custom_Tracer();

            tracer.Add_Trace("NewEndpointServices.Get_Search_Results_Set", "Parse request to determine search requested");

            // Get all the searh field necessary from the query string
            Results_Arguments args = new Results_Arguments(QueryString);

            // Additional results arguments
            // limit number of results
            int     artificial_result_limitation = -1;
            Boolean isNumeric = false;

            if (!String.IsNullOrEmpty(QueryString["limit_results"]))
            {
                isNumeric = Int32.TryParse(QueryString["limit_results"], out artificial_result_limitation);

                if (!isNumeric)
                {
                    artificial_result_limitation = -1;
                }
                else if (artificial_result_limitation < 1)
                {
                    artificial_result_limitation = -1;
                }
            }

            int pagenum = 1;

            if (!String.IsNullOrEmpty(QueryString["page"]))
            {
                isNumeric = Int32.TryParse(QueryString["page"], out pagenum);

                if (!isNumeric)
                {
                    pagenum = 1;
                }
                else if (pagenum < 1)
                {
                    pagenum = 1;
                }
                else if (pagenum > 1)
                {
                    artificial_result_limitation = -1;
                }
            }

            // limit title length, in words
            //int artificial_title_length_limitation = -1;
            ///if (!String.IsNullOrEmpty(QueryString["title_length"]))
            //{
            //    isNumeric = Int32.TryParse(QueryString["title_length"], out artificial_title_length_limitation);
            //    if (!isNumeric)
            //    {
            //        artificial_title_length_limitation = -1;
            //    }
            ///    else if (artificial_title_length_limitation < 1)
            ///    {
            ///        artificial_title_length_limitation = -1;
            ///    }
            ///}

            Boolean include_metadata = false;

            //if (!String.IsNullOrEmpty(QueryString["metadata"]))
            //{
            include_metadata = true;
            //}

            // Was a collection indicated?
            if (UrlSegments.Count > 0)
            {
                args.Aggregation = UrlSegments[0];
            }

            // Get the aggregation object (we need to know which facets to use, etc.. )
            tracer.Add_Trace("NewEndpointServices.Get_Search_Results_Set", "Get the '" + args.Aggregation + "' item aggregation (for facets, etc..)");
            Complete_Item_Aggregation aggr = AggregationServices.get_complete_aggregation(args.Aggregation, true, tracer);

            // If no aggregation was returned, that is an error
            if (aggr == null)
            {
                tracer.Add_Trace("NewEndpointServices.Get_Search_Results_Set", "Returned aggregation was NULL... aggregation code may not be valid");

                if (IsDebug)
                {
                    Response.ContentType = "text/plain";
                    Response.Output.WriteLine("DEBUG MODE DETECTED");
                    Response.Output.WriteLine();
                    Response.Output.WriteLine(tracer.Text_Trace);
                    return;
                }

                Response.ContentType = "text/plain";
                Response.Output.WriteLine("Error occurred or aggregation '" + args.Aggregation + "' not valid");
                Response.StatusCode = 500;
                return;
            }

            // Perform the search
            tracer.Add_Trace("NewEndpointServices.Get_Search_Results_Set", "Perform the search");
            Search_Results_Statistics   resultsStats;
            List <iSearch_Title_Result> resultsPage;
            ResultsEndpointErrorEnum    error = Get_Search_Results(args, aggr, false, tracer, out resultsStats, out resultsPage);

            // Was this in debug mode?
            // If this was debug mode, then just write the tracer
            if (IsDebug)
            {
                tracer.Add_Trace("NewEndpointServices.Get_Search_Results_Set", "Debug mode detected");

                Response.ContentType = "text/plain";
                Response.Output.WriteLine("DEBUG MODE DETECTED");
                Response.Output.WriteLine();
                Response.Output.WriteLine(tracer.Text_Trace);
                return;
            }

            try
            {
                tracer.Add_Trace("NewEndpointServices.Get_Search_Results_Set", "Begin writing the XML result to the response");
                Response.Output.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>");

                int count_pages = (int)Math.Floor((double)resultsStats.Total_Items / 20);

                if (count_pages == 0)
                {
                    count_pages = 1;
                }

                if (pagenum > count_pages)
                {
                    pagenum = count_pages;
                }

                Response.Output.WriteLine("<results total_items=\"" + resultsStats.Total_Items + "\" total_titles=\"" + resultsStats.Total_Titles + "\" page_count=\"" + count_pages + "\" max_results_per_page=\"20\"");

                if (artificial_result_limitation != -1)
                {
                    Response.Output.WriteLine("limit_results=\"" + artificial_result_limitation + "\"");
                }

                ///if (artificial_title_length_limitation != -1)
                ///{
                ///    Response.Output.WriteLine("title_length=\"" + artificial_title_length_limitation + "\"");
                ///}

                Response.Output.WriteLine(">");

                // Map to the results object title / item
                tracer.Add_Trace("ResultsServices.Get_Search_Results_Set", "Map to the results object title / item");

                // resultnum
                int resultnum = 0;

                if (pagenum > 1)
                {
                    resultnum = ((pagenum - 1) * 20);
                }

                if (resultsPage != null)
                {
                    foreach (iSearch_Title_Result thisResult in resultsPage)
                    {
                        // Every results should have an item
                        if (thisResult.Item_Count == 0)
                        {
                            continue;
                        }
                        else
                        {
                            resultnum++;
                        }

                        if (artificial_result_limitation != -1 && resultnum > artificial_result_limitation)
                        {
                            tracer.Add_Trace("NewEndpointServices.Get_Search_Results_Set", "Reached limit [" + artificial_result_limitation + "].");
                            break;
                        }

                        // add each descriptive field over
                        iSearch_Item_Result itemResult = thisResult.Get_Item(0);

                        string bibid     = thisResult.BibID;
                        string title     = thisResult.GroupTitle;
                        string vid       = itemResult.VID;
                        string thumbnail = itemResult.MainThumbnail;

                        //title = Process_Title(title, artificial_title_length_limitation);

                        Response.Output.WriteLine("  <result resultnum=\"" + resultnum + "\" bibid=\"" + bibid + "\" vid=\"" + vid + "\">");
                        Response.Output.WriteLine("    <title>" + HttpUtility.HtmlEncode(title) + "</title>");
                        Response.Output.WriteLine("    <url_item>" + Engine_ApplicationCache_Gateway.Settings.Servers.Application_Server_URL + bibid + "/" + vid + "/</url_item>");

                        if (!String.IsNullOrEmpty(thumbnail))
                        {
                            try
                            {
                                Response.Output.WriteLine("    <url_thumbnail>" + Engine_ApplicationCache_Gateway.Settings.Servers.Image_URL +
                                                          SobekFileSystem.AssociFilePath(bibid, vid).Replace("\\", "/") + thumbnail.Trim() + "</url_thumbnail>");
                            }
                            catch (Exception ee)
                            {
                                Response.Output.WriteLine("ERROR WRITING THUMBNAIL");
                                Response.Output.WriteLine(ee.Message);
                                Response.Output.WriteLine(ee.StackTrace);
                            }
                        }

                        int field_index = 0;

                        if (resultsStats.Metadata_Labels.Count > 0 && include_metadata)
                        {
                            Response.Output.WriteLine("<metadata>");

                            foreach (string metadataTerm in resultsStats.Metadata_Labels)
                            {
                                if (!String.IsNullOrWhiteSpace(thisResult.Metadata_Display_Values[field_index]))
                                {
                                    // how to display this metadata field?
                                    string metadataTermDisplay = metadataTerm.ToLower();
                                    string termString          = thisResult.Metadata_Display_Values[field_index];

                                    if (termString.IndexOf("|") > 0)
                                    {
                                        string[] splitter = termString.Split("|".ToCharArray());

                                        foreach (string thisSplit in splitter)
                                        {
                                            if (!String.IsNullOrWhiteSpace(thisSplit))
                                            {
                                                Response.Output.WriteLine("    <" + metadataTermDisplay + ">" + HttpUtility.HtmlEncode(thisSplit.Trim()) + "</" + metadataTermDisplay + ">");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Response.Output.WriteLine("    <" + metadataTermDisplay + ">" + HttpUtility.HtmlEncode(termString.Trim()) + "</" + metadataTermDisplay + ">");
                                    }
                                }

                                field_index++;
                            }

                            Response.Output.WriteLine("</metadata>");
                        }

                        Response.Output.WriteLine("  </result>");
                    }
                }

                Response.Output.WriteLine("</results>");

                tracer.Add_Trace("NewEndpointServices.Get_Search_Results_Set", "Done writing the XML result to the response");
            }
            catch (Exception ee)
            {
                Response.Output.Write(ee.Message);
                Response.Output.Write(ee.StackTrace);
            }

            // If an error occurred, return the error
            switch (error)
            {
            case ResultsEndpointErrorEnum.Database_Exception:
                Response.ContentType = "text/plain";
                Response.Output.WriteLine("Database exception");
                Response.StatusCode = 500;
                return;

            case ResultsEndpointErrorEnum.Database_Timeout_Exception:
                Response.ContentType = "text/plain";
                Response.Output.WriteLine("Database timeout");
                Response.StatusCode = 500;
                return;

            case ResultsEndpointErrorEnum.Solr_Exception:
                Response.ContentType = "text/plain";
                Response.Output.WriteLine("Solr exception");
                Response.StatusCode = 500;
                return;

            case ResultsEndpointErrorEnum.Unknown:
                Response.ContentType = "text/plain";
                Response.Output.WriteLine("Unknown error");
                Response.StatusCode = 500;
                return;
            }
        }