public XmlDocument GetRDFData(RDFTriple request)
        {
            string xmlstr = string.Empty;
            XmlDocument xmlrtn = new XmlDocument();
            if (Framework.Utilities.Cache.Fetch(request.Key + "data") == null || request.Edit)
            {

                if (request.Type != string.Empty)
                {

                    string connstr = ConfigurationManager.ConnectionStrings["ProfilesDB"].ConnectionString;

                    SqlConnection dbconnection = new SqlConnection(connstr);
                    SqlCommand dbcommand = new SqlCommand();

                    try
                    {
                        Framework.Utilities.DebugLogging.Log("{CLOUD} DATA BASE start GetRDFData(RDFTriple request) :" + request.Key + "data", request);

                        dbconnection.Open();
                        dbcommand.CommandType = CommandType.StoredProcedure;

                        dbcommand.CommandTimeout = base.GetCommandTimeout();

                        dbcommand.CommandText = "[RDF.].[GetDataRDF]";
                        dbcommand.Parameters.Add(new SqlParameter("@subject", request.Subject));
                        dbcommand.Parameters.Add(new SqlParameter("@predicate", request.Predicate));
                        dbcommand.Parameters.Add(new SqlParameter("@object", request.Object));
                        dbcommand.Parameters.Add(new SqlParameter("@returnXMLasStr", true));

                        if (request.Offset != null && request.Offset != string.Empty)
                            dbcommand.Parameters.Add(new SqlParameter("@offset", request.Offset));

                        if (request.Limit != null && request.Limit != string.Empty)
                            dbcommand.Parameters.Add(new SqlParameter("@limit", request.Limit));

                        dbcommand.Parameters.Add(new SqlParameter("@showDetails", request.ShowDetails));
                        dbcommand.Parameters.Add(new SqlParameter("@expand", request.Expand));

                        dbcommand.Parameters.Add(new SqlParameter("@SessionID", request.Session.SessionID));

                        if (request.ExpandRDFList != string.Empty)
                            dbcommand.Parameters.Add(new SqlParameter("@ExpandRDFListXML", request.ExpandRDFList));

                        dbcommand.Connection = dbconnection;
                        Framework.Utilities.DebugLogging.Log("{CLOUD} DATA BASE preread GetRDFData(RDFTriple request) :" + request.Key + "data", request);

                        using (var dbreader = dbcommand.ExecuteReader(CommandBehavior.CloseConnection))
                        {
                            while (dbreader.Read())
                            {
                                xmlstr += dbreader[0].ToString();
                            }
                            dbreader.Close();
                        }

                        xmlrtn.LoadXml(xmlstr);
                        Framework.Utilities.DebugLogging.Log("{CLOUD} DATA BASE end GetRDFData(RDFTriple request) :" + request.Key + "data", request);

                        Framework.Utilities.Cache.Set(request.Key + "data", xmlrtn);
                        xmlstr = string.Empty;

                    }
                    catch (Exception e)
                    {
                        Framework.Utilities.DebugLogging.Log(e.Message + e.StackTrace);
                        throw new Exception(e.Message);
                    }
                    finally
                    {
                        // UCSF. Trying to close connection instead of clearing it.
                        //SqlConnection.ClearPool(dbconnection);
                        if (dbconnection.State != ConnectionState.Closed)
                            dbconnection.Close();
                    }
                }
                else if (request.URI != string.Empty)
                {
                    Framework.Utilities.DebugLogging.Log("{CLOUD} HTTP POST start GetRDFData(RDFTriple request) :" + request.Key + "data", request);
                    HTTPIO httpio = new HTTPIO();
                    xmlrtn = httpio.QueryHTTPIO(request);
                    Framework.Utilities.DebugLogging.Log("{CLOUD} HTTP POST end GetRDFData(RDFTriple request) :" + request.Key + "data", request);
                    Framework.Utilities.Cache.Set(request.Key + "data", xmlrtn);
                }
            }

            else
            {
                Framework.Utilities.DebugLogging.Log("{CLOUD} CACHE start GetRDFData(RDFTriple request) :" + request.Key + "data", request);
                xmlrtn = Framework.Utilities.Cache.Fetch(request.Key + "data");
                Framework.Utilities.DebugLogging.Log("{CLOUD} CACHE end GetRDFData(RDFTriple request) :" + request.Key + "data", request);
            }

            return xmlrtn;
        }
Пример #2
0
        public XmlDocument GetRDFData(RDFTriple request)
        {
            string xmlstr = string.Empty;
            XmlDocument xmlrtn = new XmlDocument();
            bool UsedCache = true;
            DateTime timer = DateTime.Now;

            Framework.Utilities.DebugLogging.Log("GetRDFData START: KEY=" + request.Key + "|data TIME=" + timer.ToLongTimeString());

            try
            {
                xmlrtn = Framework.Utilities.Cache.Fetch(request.Key + "|data");

                if (xmlrtn == null || request.Edit)
                {
                    xmlrtn = new XmlDocument();

                    UsedCache = false;

                    if (request.Type != string.Empty)
                    {

                        string connstr = ConfigurationManager.ConnectionStrings["ProfilesDB"].ConnectionString;

                        SqlConnection dbconnection = new SqlConnection(connstr);
                        SqlCommand dbcommand = new SqlCommand();

                        dbconnection.Open();
                        dbcommand.CommandType = CommandType.StoredProcedure;

                        dbcommand.CommandTimeout = base.GetCommandTimeout();

                        dbcommand.CommandText = "[RDF.].[GetDataRDF]";
                        dbcommand.Parameters.Add(new SqlParameter("@subject", request.Subject));
                        dbcommand.Parameters.Add(new SqlParameter("@predicate", request.Predicate));
                        dbcommand.Parameters.Add(new SqlParameter("@object", request.Object));
                        dbcommand.Parameters.Add(new SqlParameter("@returnXMLasStr", true));

                        if (request.Offset != null && request.Offset != string.Empty)
                            dbcommand.Parameters.Add(new SqlParameter("@offset", request.Offset));

                        if (request.Limit != null && request.Limit != string.Empty)
                            dbcommand.Parameters.Add(new SqlParameter("@limit", request.Limit));

                        dbcommand.Parameters.Add(new SqlParameter("@showDetails", request.ShowDetails));
                        dbcommand.Parameters.Add(new SqlParameter("@expand", request.Expand));

                        dbcommand.Parameters.Add(new SqlParameter("@SessionID", request.Session.SessionID));

                        if (request.ExpandRDFList != string.Empty)
                            dbcommand.Parameters.Add(new SqlParameter("@ExpandRDFListXML", request.ExpandRDFList));

                        Framework.Utilities.DebugLogging.Log("GetRDFData EXPANDRDF: KEY=" + request.ExpandRDFList);

                        dbcommand.Connection = dbconnection;

                        using (var dbreader = dbcommand.ExecuteReader(CommandBehavior.CloseConnection))
                        {
                            while (dbreader.Read())
                            {
                                xmlstr += dbreader[0].ToString();
                            }
                            dbreader.Close();

                            SqlConnection.ClearPool(dbconnection);
                        }

                        xmlrtn.LoadXml(xmlstr);

                        //Framework.Utilities.Cache.Set(request.Key + "|data", xmlrtn);
                        Framework.Utilities.Cache.Set(request.Key + "|data", xmlrtn, request.Subject, request.Session.SessionID);
                        xmlstr = string.Empty;

                    }
                    else if (request.URI != string.Empty)
                    {
                        HTTPIO httpio = new HTTPIO();
                        xmlrtn = httpio.QueryHTTPIO(request);
                        Framework.Utilities.Cache.Set(request.Key + "|data", xmlrtn);
                    }
                }

            }
            catch (Exception e)
            {
                Framework.Utilities.DebugLogging.Log(e.Message + e.StackTrace);
                throw new Exception(e.Message);
            }

            Framework.Utilities.DebugLogging.Log("GetRDFData END  : KEY=" + request.Key + "|data USEDCACHE=" + UsedCache.ToString() + " TIME=" + timer.ToLongTimeString() + " DURATION=" + (DateTime.Now - timer).TotalMilliseconds);

            return xmlrtn;
        }
Пример #3
0
        public XmlDocument GetRDFData(RDFTriple request)
        {
            string      xmlstr    = string.Empty;
            XmlDocument xmlrtn    = new XmlDocument();
            bool        UsedCache = true;
            DateTime    timer     = DateTime.Now;

            Framework.Utilities.DebugLogging.Log("GetRDFData START: KEY=" + request.Key + "|data TIME=" + timer.ToLongTimeString());

            try
            {
                xmlrtn = Framework.Utilities.Cache.Fetch(request.Key + "|data");

                if (xmlrtn == null || request.Edit)
                {
                    xmlrtn = new XmlDocument();

                    UsedCache = false;

                    if (request.Type != string.Empty)
                    {
                        string connstr = ConfigurationManager.ConnectionStrings["ProfilesDB"].ConnectionString;

                        SqlConnection dbconnection = new SqlConnection(connstr);
                        SqlCommand    dbcommand    = new SqlCommand();

                        dbconnection.Open();
                        dbcommand.CommandType = CommandType.StoredProcedure;

                        dbcommand.CommandTimeout = base.GetCommandTimeout();

                        dbcommand.CommandText = "[RDF.].[GetDataRDF]";
                        dbcommand.Parameters.Add(new SqlParameter("@subject", request.Subject));
                        dbcommand.Parameters.Add(new SqlParameter("@predicate", request.Predicate));
                        dbcommand.Parameters.Add(new SqlParameter("@object", request.Object));
                        dbcommand.Parameters.Add(new SqlParameter("@returnXMLasStr", true));


                        if (request.Offset != null && request.Offset != string.Empty)
                        {
                            dbcommand.Parameters.Add(new SqlParameter("@offset", request.Offset));
                        }

                        if (request.Limit != null && request.Limit != string.Empty)
                        {
                            dbcommand.Parameters.Add(new SqlParameter("@limit", request.Limit));
                        }

                        dbcommand.Parameters.Add(new SqlParameter("@showDetails", request.ShowDetails));
                        dbcommand.Parameters.Add(new SqlParameter("@expand", request.Expand));

                        dbcommand.Parameters.Add(new SqlParameter("@SessionID", request.Session.SessionID));

                        if (request.ExpandRDFList != string.Empty)
                        {
                            dbcommand.Parameters.Add(new SqlParameter("@ExpandRDFListXML", request.ExpandRDFList));
                        }

                        Framework.Utilities.DebugLogging.Log("GetRDFData EXPANDRDF: KEY=" + request.ExpandRDFList);

                        dbcommand.Connection = dbconnection;

                        using (var dbreader = dbcommand.ExecuteReader(CommandBehavior.CloseConnection))
                        {
                            while (dbreader.Read())
                            {
                                xmlstr += dbreader[0].ToString();
                            }
                            dbreader.Close();

                            SqlConnection.ClearPool(dbconnection);
                        }



                        xmlrtn.LoadXml(xmlstr);

                        //Framework.Utilities.Cache.Set(request.Key + "|data", xmlrtn);
                        Framework.Utilities.Cache.Set(request.Key + "|data", xmlrtn, request.Subject, request.Session.SessionID);
                        xmlstr = string.Empty;
                    }
                    else if (request.URI != string.Empty)
                    {
                        HTTPIO httpio = new HTTPIO();
                        xmlrtn = httpio.QueryHTTPIO(request);
                        Framework.Utilities.Cache.Set(request.Key + "|data", xmlrtn);
                    }
                }
            }
            catch (Exception e)
            {
                Framework.Utilities.DebugLogging.Log(e.Message + e.StackTrace);
                throw new Exception(e.Message);
            }

            Framework.Utilities.DebugLogging.Log("GetRDFData END  : KEY=" + request.Key + "|data USEDCACHE=" + UsedCache.ToString() + " TIME=" + timer.ToLongTimeString() + " DURATION=" + (DateTime.Now - timer).TotalMilliseconds);

            return(xmlrtn);
        }