Exemplo n.º 1
0
        public string DrawMyTable()
        {
            StringBuilder sb         = new StringBuilder();
            StringBuilder jsAddSites = new StringBuilder();

            sb.Append(DrawListTableStart(6, 18, "Institution|Matches", "|", "|", "450|150", "l|c"));
            Int64 OddRow = 0;

            DIRECT.Utilities.DataIO oDataIO = new Profiles.DIRECT.Utilities.DataIO();
            SqlDataReader           dr      = oDataIO.DirectResultset();

            while (dr.Read())
            {
                OddRow = 1 - OddRow;
                sb.Append(DrawListTableRow("doLocalPersonSearch('" + DirectServiceURL() + "'," + dr["SiteID"] + ");", "doSiteHoverOver(" + dr["SiteID"].ToString() + ");", "doSiteHoverOut(" + dr["SiteID"].ToString() + ");", OddRow,
                                           dr["SiteName"].ToString() + "|" + "<div id='SITE_STATUS_" + dr["SiteID"].ToString() + "'><div class='siteresult' style='height:16px;'></div></div>",
                                           "|",
                                           "450|150",
                                           "l|c"));
                jsAddSites.AppendLine("var t = {}; t.SiteID = " + dr["SiteID"] + "; t.ResultPopType = ''; t.ResultDetailsURL = ''; t.FSID = ''; fsObject.push(t);");
            }
            dr.Close();
            try { dr.Dispose(); }
            catch (Exception ex) { }
            sb.Append(DrawListTableEnd());

            sb.Append("<script>");
            sb.Append(jsAddSites.ToString());
            sb.Append("</script>");

            return(sb.ToString());
        }
Exemplo n.º 2
0
        protected void DrawUIOnLoad()
        {
            oDataIO = new DIRECT.Utilities.DataIO();

            Profiles.DIRECT.Utilities.DataIO searchDataIO;
            Profiles.Search.Utilities.DataIO profileDataIO;

            string      DirectServiceURL   = Root.Domain + "/DIRECT/Modules/DirectSearch/directservice.aspx";// Request.Url.AbsoluteUri.Replace("&", "&amp;");
            string      ProfilesURL        = Root.Domain;
            string      PopulationTypeText = oDataIO.GetDirectConfig().PopulationType;
            int         QueryTimeout       = oDataIO.GetDirectConfig().Timeout;
            XmlDocument query = new XmlDocument();
            XmlDocument result;

            Framework.Utilities.Namespace rdfnamespaces = new Namespace();
            XmlNamespaceManager           namespaces    = null;



            string sql = string.Empty;
            string ResultDetailsURL = string.Empty;
            string strResult        = "";

            SqlDataReader dr;

            if (Request["Request"] == null)
            {
                return;
            }

            string task = Request["Request"].ToLower();

            switch (task)
            {
            case "getsites":
                string ResultStr = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + "<site-list>";


                dr = oDataIO.GetSitesOrderBySortOrder();
                while (dr.Read())
                {
                    Int64  SiteID   = Convert.ToInt64(dr["SiteID"]);
                    string SiteName = dr["SiteName"].ToString();
                    string QueryURL = dr["QueryURL"].ToString();
                    if (SiteName == null)
                    {
                        SiteName = "";
                    }
                    if (QueryURL == null)
                    {
                        QueryURL = "";
                    }
                    ResultStr = ResultStr + "<site-description><site-id>" + SiteID + "</site-id><name>" + cx(SiteName) + "</name><aggregate-query>" + cx(QueryURL) + "</aggregate-query></site-description>";
                }

                if (!dr.IsClosed)
                {
                    dr.Close();
                }

                ResultStr           += "</site-list>";
                Response.ContentType = "text/xml";
                Response.AddHeader("Content-Type", "text/xml;charset=UTF-8");
                //Response.ContentEncoding.CodePage = 65001;
                Response.Charset = "UTF-8";

                Response.Write(ResultStr);


                break;

            case "incomingcount":

                string q = Request["SearchPhrase"].Trim();
                // Enter log record
                sql = "insert into [Direct.].LogIncoming(Details,ReceivedDate,RequestIP,QueryString) " +
                      " values (0,GetDate()," + cs(Request.ServerVariables["REMOTE_ADDR"]) + "," + cs(q) + ")";

                oDataIO.ExecuteSQLDataCommand(sql);

                // Execute query
                string x = "<SearchOptions>" +
                           "<MatchOptions>" +
                           "<SearchString ExactMatch=\"false\">" + cx(q) + "</SearchString> " +
                           "<SearchFiltersList /> " +
                           "<ClassURI>http://xmlns.com/foaf/0.1/Person</ClassURI> " +
                           "</MatchOptions>" +
                           "<OutputOptions>" +
                           "<Offset>0</Offset>" +
                           "<Limit>1</Limit> " +
                           "<SortByList>" +
                           "</SortByList>" +
                           "</OutputOptions>" +
                           "</SearchOptions>";
                query.LoadXml(x);

                profileDataIO = new Profiles.Search.Utilities.DataIO();
                result        = profileDataIO.Search(query, false);
                namespaces    = rdfnamespaces.LoadNamespaces(result);

                string ResultCount = result.SelectSingleNode("rdf:RDF/rdf:Description/prns:numberOfConnections", namespaces).InnerText;

                // Form result message
                ResultStr  = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
                ResultStr += "<aggregation-result>";
                ResultStr += "<count>" + ResultCount + "</count>";
                ResultStr += "<population-type>" + PopulationTypeText + "</population-type>";
                ResultStr += "<preview-URL>" + DirectServiceURL + "?Request=IncomingPreview&amp;SearchPhrase=" + cx(q) + "</preview-URL>";
                ResultStr += "<search-results-URL>" + DirectServiceURL + "?Request=IncomingDetails&amp;SearchPhrase=" + cx(q) + "</search-results-URL>";
                ResultStr += "</aggregation-result>";

                // Send result
                Response.ContentType = "text/xml";
                Response.AddHeader("Content-Type", "text/xml;charset=UTF-8");
                //Response.ContentEncoding.CodePage = 65001;
                Response.Charset = "UTF-8";
                Response.Write(ResultStr);
                break;

            case "incomingdetails":

                q = Request["SearchPhrase"].Trim();

                // Enter log record
                sql  = "insert into [Direct.].LogIncoming(Details,ReceivedDate,RequestIP,QueryString) ";
                sql += " values (1,GetDate()," + cs(Request.ServerVariables["REMOTE_ADDR"]) + "," +
                       cs(q) + ")";

                oDataIO.ExecuteSQLDataCommand(sql);

                // Execute query

                query.LoadXml("<SearchOptions>" +
                              "<MatchOptions>" +
                              "<SearchString ExactMatch=\"false\">" + cx(q) + "</SearchString> " +
                              "<SearchFiltersList /> " +
                              "<ClassURI>http://xmlns.com/foaf/0.1/Person</ClassURI> " +
                              "</MatchOptions>" +
                              "<OutputOptions>" +
                              "<Offset>0</Offset>" +
                              "<Limit>1</Limit> " +
                              "<SortByList>" +
                              "</SortByList>" +
                              "</OutputOptions>" +
                              "</SearchOptions>");


                profileDataIO = new Profiles.Search.Utilities.DataIO();
                result        = profileDataIO.Search(query, false);

                strResult = result.InnerXml;

                // Parse results
                XmlDocument objDoc = new XmlDocument();
                objDoc = new XmlDocument();
                objDoc.LoadXml(strResult);


                namespaces = rdfnamespaces.LoadNamespaces(result);

                ResultCount = result.SelectSingleNode("rdf:RDF/rdf:Description/prns:numberOfConnections", namespaces).InnerText;

                if (ProfilesURL.Substring(ProfilesURL.Length - 1) != "/")
                {
                    ProfilesURL += "/";
                }
                Response.Redirect(ProfilesURL + "search/default.aspx?searchtype=people&classuri=http://xmlns.com/foaf/0.1/Person&searchfor=" + q + "&exactPhrase=false");



                break;

            case "incomingpreview":

                q = Request["SearchPhrase"].Trim();

                Utilities.DataIO data = new Profiles.DIRECT.Utilities.DataIO();

                string searchphrase = Request["SearchPhrase"].Trim();
                Response.Write(data.Search(searchphrase));

                break;

            case "outgoingcount":

                if (Request["blank"] == "y")
                {
                    Response.Write("<html><body></body></html>");
                    Response.End();
                }

                string SearchPhrase = Request["SearchPhrase"];


                Response.Write("<script>parent.dsLoading=1;</script>" + Environment.NewLine);


                dr = oDataIO.GetSitesOrderBySiteID();

                SiteIDs = new int[1000];
                URLs    = new string[1000];
                FSIDs   = new string[1000];

                Site site;
                ListOfSites = new List <Site>();
                Int64 sites = 0;

                List <AsyncProcessing> ListOfThreads = new List <AsyncProcessing>();
                AsyncProcessing        async;
                while (dr.Read())
                {
                    SiteIDs[sites] = Convert.ToInt32(dr["SiteID"].ToString());
                    URLs[sites]    = dr["QueryURL"] + SearchPhrase;
                    FSIDs[sites]   = dr["FSID"].ToString();
                    site           = new Site(URLs[sites], SiteIDs[sites], FSIDs[sites], SearchPhrase, HttpContext.Current);
                    ListOfSites.Add(site);
                    async = new AsyncProcessing();
                    async.BeginProcessRequest(site);
                    ListOfThreads.Add(async);
                    sites++;
                }

                if (!dr.IsClosed)
                {
                    dr.Close();
                }


                //eat up the CPU for x number of seconds :) so all the requests can come back.  This is set in the web.config file
                DateTime end = DateTime.Now.AddSeconds(QueryTimeout);
                while (DateTime.Now < end)
                {
                }

                //close out anything that did not complete in 5 seconds
                for (int loop = 0; loop < ListOfThreads.Count; loop++)
                {
                    if (!ListOfThreads[loop].Site.IsDone)
                    {
                        sql = "update [Direct.].LogOutgoing set ResponseTime = datediff(ms,SentDate,GetDate()), "
                              + " ResponseState = " + 1
                              + " where FSID = " + cs(ListOfThreads[loop].Site.FSID);

                        oDataIO.ExecuteSQLDataCommand(sql);
                        Response.Write("<script>parent.siteResult(" + ListOfThreads[loop].Site.SiteID + ",1,0,'','','','');</script>");
                        ListOfThreads.Remove(ListOfThreads[loop]);
                    }
                }

                try
                {
                    Response.Flush();
                }
                catch { }

                break;

            case "outgoingdetails":

                string FSID   = Request["fsid"].Trim();
                string SiteId = string.Empty;
                if (FSID != "")
                {
                    dr = oDataIO.GetFsID(cs(FSID));

                    if (dr.Read())
                    {
                        SiteId           = dr["SiteID"].ToString();
                        ResultDetailsURL = dr["ResultDetailsURL"].ToString().Replace("\n\t", "");
                    }

                    if (!dr.IsClosed)
                    {
                        dr.Close();
                    }
                }
                if ((FSID != "") && (SiteId != "") && (ResultDetailsURL != ""))
                {
                    // Enter log record
                    oDataIO.ExecuteSQLDataCommand("insert into [Direct.].LogOutgoing(FSID,SiteID,Details,SentDate) "
                                                  + " values ('" + FSID + "'," + SiteId + ",1,GetDate())");

                    Response.Redirect(ResultDetailsURL);
                }
                else
                {
                    Response.Redirect(ProfilesURL);
                }
                break;
            }

            Response.End();
        }
        public string DrawMyTable()
        {
            StringBuilder sb = new StringBuilder();
            StringBuilder jsAddSites = new StringBuilder();
            sb.Append(DrawListTableStart(6, 18, "Institution|Matches", "|", "|", "450|150", "l|c"));
            Int64 OddRow = 0;

            DIRECT.Utilities.DataIO oDataIO = new Profiles.DIRECT.Utilities.DataIO();
            SqlDataReader dr = oDataIO.DirectResultset();

            while (dr.Read())
            {
                OddRow = 1 - OddRow;
                sb.Append(DrawListTableRow("doLocalPersonSearch('" + DirectServiceURL() + "'," + dr["SiteID"] + ");", "doSiteHoverOver(" + dr["SiteID"].ToString() + ");", "doSiteHoverOut(" + dr["SiteID"].ToString() + ");", OddRow,
                    dr["SiteName"].ToString() + "|" + "<div id='SITE_STATUS_" + dr["SiteID"].ToString() + "'><div class='siteresult' ></div></div>",
                    "|",
                    "450|150",
                    "l|c"));
                jsAddSites.AppendLine("var t = {}; t.SiteID = " + dr["SiteID"] + "; t.ResultPopType = ''; t.ResultDetailsURL = ''; t.FSID = ''; fsObject.push(t);");
            }
            dr.Close();
            try { dr.Dispose(); }
            catch (Exception ex) { }
            sb.Append(DrawListTableEnd());

            sb.Append("<script>");
            sb.Append(jsAddSites.ToString());
            sb.Append("</script>");

            return sb.ToString();
        }
        protected void DrawUIOnLoad()
        {
            oDataIO = new DIRECT.Utilities.DataIO();

            Profiles.DIRECT.Utilities.DataIO searchDataIO;

            string DirectServiceURL = Root.Domain + "/DIRECT/Modules/DirectSearch/directservice.aspx";// Request.Url.AbsoluteUri.Replace("&", "&amp;");
            string ProfilesURL = Root.Domain;
            string PopulationTypeText = oDataIO.GetDirectConfig().PopulationType;
            int QueryTimeout = oDataIO.GetDirectConfig().Timeout;
            XmlDocument query = new XmlDocument();
            XmlDocument result;

            Framework.Utilities.Namespace rdfnamespaces = new Namespace();
            XmlNamespaceManager namespaces = null;

            string sql = string.Empty;
            string ResultDetailsURL = string.Empty;
            string strResult = "";

            SqlDataReader dr;

            if (Request["Request"] == null) { return; }

            string task = Request["Request"].ToLower();
            switch (task)
            {
                case "getsites":
                    string ResultStr = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + "<site-list>";

                    dr = oDataIO.GetSitesOrderBySortOrder();
                    while (dr.Read())
                    {
                        Int64 SiteID = Convert.ToInt64(dr["SiteID"]);
                        string SiteName = dr["SiteName"].ToString();
                        string QueryURL = dr["QueryURL"].ToString();
                        if (SiteName == null) SiteName = "";
                        if (QueryURL == null) QueryURL = "";
                        ResultStr = ResultStr + "<site-description><site-id>" + SiteID + "</site-id><name>" + cx(SiteName) + "</name><aggregate-query>" + cx(QueryURL) + "</aggregate-query></site-description>";
                    }

                    if (!dr.IsClosed)
                        dr.Close();

                    ResultStr += "</site-list>";
                    Response.ContentType = "text/xml";
                    Response.AddHeader("Content-Type", "text/xml;charset=UTF-8");
                    //Response.ContentEncoding.CodePage = 65001;
                    Response.Charset = "UTF-8";

                    Response.Write(ResultStr);

                    break;
                case "incomingcount":

                    string q = Request["SearchPhrase"].Trim();
                    // Enter log record
                    sql = "insert into [Direct.].LogIncoming(Details,ReceivedDate,RequestIP,QueryString) " +
                         " values (0,GetDate()," + cs(Request.ServerVariables["REMOTE_ADDR"]) + "," + cs(q) + ")";

                    oDataIO.ExecuteSQLDataCommand(sql);

                    // Execute query
                    string x = "<SearchOptions>" +
                              "<MatchOptions>" +
                              "<SearchString ExactMatch=\"false\">" + cx(q) + "</SearchString> " +
                              "<SearchFiltersList /> " +
                              "<ClassURI>http://xmlns.com/foaf/0.1/Person</ClassURI> " +
                              "</MatchOptions>" +
                              "<OutputOptions>" +
                              "<Offset>0</Offset>" +
                              "<Limit>1</Limit> " +
                              "<SortByList>" +
                              "</SortByList>" +
                              "</OutputOptions>" +
                              "</SearchOptions>";
                    query.LoadXml(x);

                    searchDataIO = new Profiles.DIRECT.Utilities.DataIO();
                    result = searchDataIO.Search(query);
                    namespaces = rdfnamespaces.LoadNamespaces(result);

                    string ResultCount = result.SelectSingleNode("rdf:RDF/rdf:Description/prns:numberOfConnections", namespaces).InnerText;

                    // Form result message
                    ResultStr = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
                    ResultStr += "<aggregation-result>";
                    ResultStr += "<count>" + ResultCount + "</count>";
                    ResultStr += "<population-type>" + PopulationTypeText + "</population-type>";
                    ResultStr += "<preview-URL>" + DirectServiceURL + "?Request=IncomingPreview&amp;SearchPhrase=" + cx(q) + "</preview-URL>";
                    ResultStr += "<search-results-URL>" + DirectServiceURL + "?Request=IncomingDetails&amp;SearchPhrase=" + cx(q) + "</search-results-URL>";
                    ResultStr += "</aggregation-result>";

                    // Send result
                    Response.ContentType = "text/xml";
                    Response.AddHeader("Content-Type", "text/xml;charset=UTF-8");
                    //Response.ContentEncoding.CodePage = 65001;
                    Response.Charset = "UTF-8";
                    Response.Write(ResultStr);
                    break;

                case "incomingdetails":

                    q = Request["SearchPhrase"].Trim();

                    // Enter log record
                    sql = "insert into [Direct.].LogIncoming(Details,ReceivedDate,RequestIP,QueryString) ";
                    sql += " values (1,GetDate()," + cs(Request.ServerVariables["REMOTE_ADDR"]) + "," +
                            cs(q) + ")";

                    oDataIO.ExecuteSQLDataCommand(sql);

                    // Execute query

                    query.LoadXml("<SearchOptions>" +
                           "<MatchOptions>" +
                           "<SearchString ExactMatch=\"false\">" + cx(q) + "</SearchString> " +
                           "<SearchFiltersList /> " +
                           "<ClassURI>http://xmlns.com/foaf/0.1/Person</ClassURI> " +
                           "</MatchOptions>" +
                           "<OutputOptions>" +
                           "<Offset>0</Offset>" +
                           "<Limit>1</Limit> " +
                           "<SortByList>" +
                           "</SortByList>" +
                           "</OutputOptions>" +
                           "</SearchOptions>");

                    searchDataIO = new Profiles.DIRECT.Utilities.DataIO();
                    result = searchDataIO.Search(query);

                    strResult = result.InnerXml;

                    // Parse results
                    XmlDocument objDoc = new XmlDocument();
                    objDoc = new XmlDocument();
                    objDoc.LoadXml(strResult);

                    namespaces = rdfnamespaces.LoadNamespaces(result);

                    ResultCount = result.SelectSingleNode("rdf:RDF/rdf:Description/prns:numberOfConnections", namespaces).InnerText;

                    if (ProfilesURL.Substring(ProfilesURL.Length - 1) != "/") { ProfilesURL += "/"; }
                    Response.Redirect(ProfilesURL + "search/default.aspx?searchtype=people&classuri=http://xmlns.com/foaf/0.1/Person&searchfor=" + q);

                    break;
                case "incomingpreview":

                    q = Request["SearchPhrase"].Trim();

                    Utilities.DataIO data = new Profiles.DIRECT.Utilities.DataIO();

                    string searchphrase = Request["SearchPhrase"].Trim();
                    Response.Write(data.Search(searchphrase));

                    break;

                case "outgoingcount":

                    if (Request["blank"] == "y")
                    {
                        Response.Write("<html><body></body></html>");
                        Response.End();
                    }

                    string SearchPhrase = Request["SearchPhrase"];

                    Response.Write("<script>parent.dsLoading=1;</script>" + Environment.NewLine);

                    dr = oDataIO.GetSitesOrderBySiteID();

                    SiteIDs = new int[1000];
                    URLs = new string[1000];
                    FSIDs = new string[1000];

                    Site site;
                    ListOfSites = new List<Site>();
                    Int64 sites = 0;

                    List<AsyncProcessing> ListOfThreads = new List<AsyncProcessing>();
                    AsyncProcessing async;
                    while (dr.Read())
                    {
                        SiteIDs[sites] = Convert.ToInt32(dr["SiteID"].ToString());
                        URLs[sites] = dr["QueryURL"] + SearchPhrase;
                        FSIDs[sites] = dr["FSID"].ToString();
                        site = new Site(URLs[sites], SiteIDs[sites], FSIDs[sites], SearchPhrase, HttpContext.Current);
                        ListOfSites.Add(site);
                        async = new AsyncProcessing();
                        async.BeginProcessRequest(site);
                        ListOfThreads.Add(async);
                        sites++;
                    }

                    if (!dr.IsClosed)
                        dr.Close();

                    //eat up the CPU for x number of seconds :) so all the requests can come back.  This is set in the web.config file
                    DateTime end = DateTime.Now.AddSeconds(QueryTimeout);
                    while (DateTime.Now < end)
                    { }

                    //close out anything that did not complete in 5 seconds
                    for (int loop = 0; loop < ListOfThreads.Count; loop++)
                    {

                        if (!ListOfThreads[loop].Site.IsDone)
                        {
                            sql = "update [Direct.].LogOutgoing set ResponseTime = datediff(ms,SentDate,GetDate()), "
                                    + " ResponseState = " + 1
                                    + " where FSID = " + cs(ListOfThreads[loop].Site.FSID);

                            oDataIO.ExecuteSQLDataCommand(sql);
                            Response.Write("<script>parent.siteResult(" + ListOfThreads[loop].Site.SiteID + ",1,0,'','','','');</script>");
                            ListOfThreads.Remove(ListOfThreads[loop]);
                        }
                    }

                    try
                    {
                        Response.Flush();
                    }
                    catch { }

                    break;
                case "outgoingdetails":

                    string FSID = Request["fsid"].Trim();
                    string SiteId = string.Empty;
                    if (FSID != "")
                    {
                        dr = oDataIO.GetFsID(cs(FSID));

                        if (dr.Read())
                        {
                            SiteId = dr["SiteID"].ToString();
                            ResultDetailsURL = dr["ResultDetailsURL"].ToString().Replace("\n\t", "");
                        }

                        if (!dr.IsClosed)
                            dr.Close();
                    }
                    if ((FSID != "") && (SiteId != "") && (ResultDetailsURL != ""))
                    {
                        // Enter log record
                        oDataIO.ExecuteSQLDataCommand("insert into [Direct.].LogOutgoing(FSID,SiteID,Details,SentDate) "
                            + " values ('" + FSID + "'," + SiteId + ",1,GetDate())");

                        Response.Redirect(ResultDetailsURL);

                    }
                    else
                        Response.Redirect(ProfilesURL);
                    break;
            }

            Response.End();
        }