コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {

                if (Request.QueryString["q"] != null)
                {
                    List<string> inputKeyWords = parseString(Request.QueryString["q"].ToString());
                    List<string> inputKeyWordsURI = new List<string>();
                    List<string> microHtmlPic = new List<string>();
                    List<string> microHtmlLabel = new List<string>();
                    string HTML;
                    keywordSearchServiceInterfaceClient keyWordsClient = new keywordSearchServiceInterfaceClient();

                    foreach (string keyword in inputKeyWords)
                    {
                        inputKeyWordsURI.Add(keyWordsClient.geturi_bestMatch(keyword));
                    }

                    ProfileConstructorInterfaceClient profileClient = new ProfileConstructorInterfaceClient();
                    List<MicroProfile> profiles = new List<MicroProfile>();
                    foreach (string keyword in inputKeyWordsURI)
                    {
                        profiles.Add((MicroProfile)profileClient.ConstructProfile(keyword, MergedServicechoiceProfile.micro, 1));
                    }

                    List<string> htmlTable = new List<string>();//<tr><td><div class="imgcontainer"><img src="testimg/220px-WikiBex.jpg" /></div></td></tr><tr><td class="title">hany</td></tr>
                    HTML = "<table class=\"relateTable\"><tr>";
                    foreach (MicroProfile microProfile in profiles)
                    {
                        HTML += "<td><div class=\"imgcontainer\"><a href=\"answer.aspx?uri=" + microProfile.URI + "\"><img src=\"" + microProfile.Picture + "\" /></a></div></td>";
                    }
                    HTML += "</tr><tr>";
                    foreach (MicroProfile microProfile in profiles)
                    {
                        HTML += "<td class=\"title\"><a href=\"answer.aspx?uri=" + microProfile.URI + "\">" + microProfile.Label + "</a></td>";
                    }
                    HTML += "</tr></table>";
                    HTML += "<script>var mainNodes = \"" + string.Join(",", inputKeyWordsURI.ToArray()) + "\"; </script>";
                    headerTable.InnerHtml = HTML;
                }
                //if nothing is sent in q parameter
                else
                {
                    //headerTable.InnerHtml = "<h2>There were no parameters to relate between</h2>";
                    answerbox.InnerHtml = "<h2>There were no parameters to relate between.....</h2>";

                }
            }
            catch (Exception c)
            {
                Util.log("RELATION ERROR" + c.Message);
                Response.Redirect("error.aspx");

            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //if there's no query, return the original page (this case should never happen)
            try
            {
                if (Request.QueryString["q"] == null)
                {
                    answerbox.InnerHtml = "<h3> No parameters to compare between... </h3>";
                    return;
                }
                else
                {

                    //parsing the parameters
                    List<string> parsedStringsList = parseString(Request.QueryString["q"].ToString());

                    //the outputURIs
                    List<string> outputURIs = new List<string>();

                    //using the keyword search to get the URIs
                    keywordSearchServiceInterfaceClient kwClient = new keywordSearchServiceInterfaceClient();
                    foreach (string item in parsedStringsList)
                    {
                        outputURIs.Add(kwClient.geturi_bestMatch(item));

                    }

                    //comparing between the translated uris
                    List<ResourceInformation> comparisonOutput = new List<ResourceInformation>();
                    ComparisonServiceInterfaceClient comparisonClient = new ComparisonServiceInterfaceClient();
                    comparisonOutput = comparisonClient.Compare(outputURIs.ToArray()).ToList();

                    // comparisonOutput = preprocessingComparisonObjects(comparisonOutput);

                    //getting the micro profiles
                    ProfileConstructorInterfaceClient constructProfile = new ProfileConstructorInterfaceClient();
                    List<MicroProfile> MicroProfilesList = new List<MicroProfile>();

                    foreach (string item in outputURIs)
                    {
                        MicroProfilesList.Add((MicroProfile)constructProfile.ConstructProfile(item, MergedServicechoiceProfile.micro, 10));

                    }

                    //output to the divs
                    //First the microProfile
                    answerbox.InnerHtml = "";
                    answerbox.InnerHtml +=
                        "<div class=\"comparisonbox tableheader\">" +
                        "<div class=\"predicate\">" +
                            "<p></p>" +
                        "</div>" +
                        "<div class=\"window\">" +
                            "<div class=\"datarow\">";

                    //this was added to handle the maps if available

                    foreach (MicroProfile item in MicroProfilesList)
                    {
                        answerbox.InnerHtml += "<div class=\"datacell\">" +
                                    "<a href=\"answer.aspx?uri=" + item.URI + " \"><img src=\"" + item.Picture + "\" />  </a>" +
                                    "<div class=\"title\"> <a href=\"answer.aspx?uri=" + item.URI + "\">" + item.Label + "</a></div>" +
                            //"<div class=\"Abstract\">" + item.Abstract + "</div>" +
                                "</div>";

                    }

                    answerbox.InnerHtml += "</div>" +
                        "</div>" +
                        "<div class=\"clearfix\">" +
                        "</div>" +
                    "</div>";

                    //right till now
                    //will crash if no comparison........

                    //now for the data for each entity
                    int numberOfPredicates = comparisonOutput[0].FinalComparisonObject.ToList().Count;
                    int numberOfObjects = comparisonOutput.Count;
                    //Second the table values

                    ////////////////THE MAPS PART///////////
                    if (canViewMap(comparisonOutput))
                    {
                        answerbox.InnerHtml += "<div class=\"comparisonbox expandableContent\">" +
                        "<div class=\"predicate\">" +
                            //this returns the predicate of all the tables
                        "Map" +
                        "</div>";

                        answerbox.InnerHtml += "<div class=\"window\">" +
                            "<div class=\"datarow\">";
                        List<string> mapstrings = viewMap(comparisonOutput);
                        foreach (string item in mapstrings)
                        {
                            answerbox.InnerHtml += "<div class=\"datacell\">";
                            answerbox.InnerHtml += item;
                            answerbox.InnerHtml += "</div>";

                        }
                        answerbox.InnerHtml += "</div>" +
                            "</div>" +
                            "</div>";
                    }
                    ////////////////////////////////////////////////////////

                    //comparisonOutput = removeUnwantedPredicates(comparisonOutput.ToList()).ToList();

                    for (int i = 0; i < numberOfPredicates; i++)
                    {
                        //check if the predicate is of the ones that should be excluded
                        if (isExcludedURI(comparisonOutput[0].FinalComparisonObject[i].Key.Key))
                            continue;

                        answerbox.InnerHtml += "<div class=\"comparisonbox expandableContent\">" +
                        "<div class=\"predicate\">" +
                            //this returns the predicate of all the tables
                        comparisonOutput[0].FinalComparisonObject[i].Key.Value +
                        "</div>";

                        answerbox.InnerHtml += "<div class=\"window\">" +
                            "<div class=\"datarow\">";

                        for (int j = 0; j < numberOfObjects; j++)
                        {
                            answerbox.InnerHtml += "<div class=\"datacell\">";
                            //should be in a href key and value
                            for (int k = 0; k < comparisonOutput[j].FinalComparisonObject[i].Value.ToList().Count; k++)
                            {
                                //we check if it's a uri or not
                                string uri = comparisonOutput[j].FinalComparisonObject[i].Value[k].Key;
                                string value = HttpUtility.HtmlDecode(comparisonOutput[j].FinalComparisonObject[i].Value[k].Value);
                                if (Uri.IsWellFormedUriString(uri, UriKind.Absolute))
                                {
                                    if (Uri.IsWellFormedUriString(value, UriKind.Absolute))
                                    {
                                        answerbox.InnerHtml += "<span><a href=\"" + uri + "\">" + value + "</a><br/></span>";
                                    }
                                    else
                                    {
                                        answerbox.InnerHtml += "<span><a href=\"answer.aspx?uri=" + uri + "\">" + value + "</a><br/></span>";
                                    }

                                }

                                else
                                {
                                    answerbox.InnerHtml += "<span>" + value + "<br/></span>";
                                }

                            }
                            answerbox.InnerHtml += "</div>";
                        }
                        answerbox.InnerHtml += "</div>" +
                            "</div>" +
                            "</div>";

                    }

                    answerbox.InnerHtml += "</div>";

                }
            }
            catch (Exception c)
            {

                //logging should go here
                Util.log("Comparison>> Message: " + c.Message + " Data: " + c.Data);
                Response.Redirect("error.aspx", false);

            }
        }