public System.IO.Stream GetUserPhotoList150x300(Int64 NodeID) { Object result = null; Edit.Utilities.DataIO resize = new Profiles.Edit.Utilities.DataIO(); result = resize.ResizeImageFile(GetUserPhotoList(NodeID), 150, 300); if (result == null) { result = (byte[])System.Text.Encoding.ASCII.GetBytes("null"); } return(new System.IO.MemoryStream((byte[])result)); }
public System.IO.Stream GetUserPhotoList(Int64 NodeID, bool harvarddefault) { Object result = null; Edit.Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO(); //Use the editor method to resize the photo to 150. Edit.Utilities.DataIO resize = new Profiles.Edit.Utilities.DataIO(); try { string connstr = ConfigurationManager.ConnectionStrings["ProfilesDB"].ConnectionString; SqlConnection dbconnection = new SqlConnection(connstr); dbconnection.Open(); SqlCommand dbcommand; if (harvarddefault) { dbcommand = new SqlCommand("select photo from [Catalyst.].[Person.Photo] where personid = " + data.GetPersonID(NodeID).ToString()); dbcommand.CommandType = CommandType.Text; dbcommand.CommandTimeout = base.GetCommandTimeout(); } else { dbcommand = new SqlCommand("[Profile.Data].[Person.GetPhotos]"); dbcommand.CommandType = CommandType.StoredProcedure; dbcommand.CommandTimeout = base.GetCommandTimeout(); dbcommand.Parameters.Add(new SqlParameter("@NodeID", NodeID)); } dbcommand.Connection = dbconnection; result = resize.ResizeImageFile((byte[])dbcommand.ExecuteScalar(), 150); if (result == null) { result = (byte[])System.Text.Encoding.ASCII.GetBytes("null"); } dbconnection.Close(); } catch (Exception e) { throw new Exception(e.Message); } return(new System.IO.MemoryStream((byte[])result)); }
public void ProcessRequest(HttpContext context) { Utilities.DataIO data = new Profiles.Profile.Utilities.DataIO(); // Set up the response settings context.Response.ContentType = "image/jpeg"; context.Response.Cache.SetCacheability(HttpCacheability.Public); context.Response.BufferOutput = false; Int64 nodeid = -1; if (!string.IsNullOrEmpty(context.Request.QueryString["NodeID"])) { // get the id for the image nodeid = Convert.ToInt32(context.Request.QueryString["NodeID"]); } if (nodeid > 0) { bool thumbnail = false; int width = 150; int height = 300; if (context.Request.QueryString["Thumbnail"] != null) { thumbnail = true; } if (context.Request.QueryString["Width"] != null) { width = Convert.ToInt32(context.Request.QueryString["Width"]); height = 2 * width; } if (context.Request.QueryString["Height"] != null) { height = Convert.ToInt32(context.Request.QueryString["Height"]); } byte[] image = (byte[])Framework.Utilities.Cache.FetchObject(GetCacheKey(nodeid, width, height)); if (image == null) { // stuff below this and if statement is what makes it slow Framework.Utilities.RDFTriple request = new Profiles.Framework.Utilities.RDFTriple(nodeid); request.Expand = true; request.ShowDetails = true; request.ExpandRDFList = "<ExpandRDF Class=\"http://xmlns.com/foaf/0.1/Person\" Property=\"http://vivoweb.org/ontology/core#authorInAuthorship\" Limit=\"1\" />"; Framework.Utilities.Namespace xmlnamespace = new Profiles.Framework.Utilities.Namespace(); XmlDocument person; person = data.GetRDFData(request); XmlNamespaceManager namespaces = xmlnamespace.LoadNamespaces(person); byte[] rawimage = null; if (person.SelectSingleNode("rdf:RDF/rdf:Description[1]/prns:mainImage/@rdf:resource", namespaces) != null) { rawimage = data.GetUserPhotoList(nodeid); } else if (thumbnail) { rawimage = silhouetteImage; } if (rawimage != null) { Edit.Utilities.DataIO resize = new Profiles.Edit.Utilities.DataIO(); image = resize.ResizeImageFile(rawimage, width, height); // we are caching silhouettes many times, but that is OK Framework.Utilities.Cache.Set(GetCacheKey(nodeid, width, height), image, nodeid, request.Session.SessionID); } } if (image != null) { Stream stream = new System.IO.MemoryStream(image); // Set up the response settings context.Response.ContentType = "image/jpeg"; context.Response.Cache.SetExpires(DateTime.Now.AddDays(7)); context.Response.Cache.SetCacheability(HttpCacheability.Public); context.Response.Cache.SetValidUntilExpires(true); context.Response.BufferOutput = false; context.Response.AddHeader("Content-Length", stream.Length.ToString()); const int buffersize = 1024 * 16; byte[] buffer2 = new byte[buffersize]; int count = stream.Read(buffer2, 0, buffersize); while (count > 0) { context.Response.OutputStream.Write(buffer2, 0, count); count = stream.Read(buffer2, 0, buffersize); } } else { context.Response.Write("No Image Found"); } } }
public System.IO.Stream GetUserPhotoList(Int64 NodeID, bool harvarddefault) { Object result = null; Edit.Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO(); //Use the editor method to resize the photo to 150. Edit.Utilities.DataIO resize = new Profiles.Edit.Utilities.DataIO(); try { string connstr = ConfigurationManager.ConnectionStrings["ProfilesDB"].ConnectionString; SqlConnection dbconnection = new SqlConnection(connstr); dbconnection.Open(); SqlCommand dbcommand; if (harvarddefault) { dbcommand = new SqlCommand("select photo from [Catalyst.].[Person.Photo] where personid = " + data.GetPersonID(NodeID).ToString()); dbcommand.CommandType = CommandType.Text; dbcommand.CommandTimeout = base.GetCommandTimeout(); } else { dbcommand = new SqlCommand("[Profile.Data].[Person.GetPhotos]"); dbcommand.CommandType = CommandType.StoredProcedure; dbcommand.CommandTimeout = base.GetCommandTimeout(); dbcommand.Parameters.Add(new SqlParameter("@NodeID", NodeID)); } dbcommand.Connection = dbconnection; result = resize.ResizeImageFile((byte[])dbcommand.ExecuteScalar(), 150); if (result == null) { result = (byte[])System.Text.Encoding.ASCII.GetBytes("null"); } dbconnection.Close(); } catch (Exception e) { throw new Exception(e.Message); } return new System.IO.MemoryStream((byte[])result); }
public void ProcessRequest(HttpContext context) { Utilities.DataIO data = new Profiles.Profile.Utilities.DataIO(); // Set up the response settings context.Response.ContentType = "image/jpeg"; context.Response.Cache.SetCacheability(HttpCacheability.NoCache); context.Response.BufferOutput = false; Int64 nodeid = -1; if (!string.IsNullOrEmpty(context.Request.QueryString["NodeID"])) { // get the id for the image nodeid = Convert.ToInt32(context.Request.QueryString["NodeID"]); } if (nodeid > 0) { bool thumbnail = false; int width = 150; int height = 300; if (context.Request.QueryString["Thumbnail"] != null) { thumbnail = true; } if (context.Request.QueryString["Width"] != null) { width = Convert.ToInt32(context.Request.QueryString["Width"]); height = 2 * width; } if (context.Request.QueryString["Height"] != null) { height = Convert.ToInt32(context.Request.QueryString["Height"]); } byte[] image = (byte[])Framework.Utilities.Cache.FetchObject(GetCacheKey(nodeid, width, height)); if (image == null) { // stuff below this and if statement is what makes it slow Framework.Utilities.RDFTriple request = new Profiles.Framework.Utilities.RDFTriple(nodeid); byte[] rawimage = null; rawimage = data.GetUserPhotoList(nodeid, request.Session.SessionID); if (thumbnail && rawimage == null) { rawimage = silhouetteImage; } if (rawimage != null) { Edit.Utilities.DataIO resize = new Profiles.Edit.Utilities.DataIO(); image = resize.ResizeImageFile(rawimage, width, height); // we are caching silhouettes many times, but that is OK Framework.Utilities.Cache.Set(GetCacheKey(nodeid, width, height), image, nodeid, request.Session.SessionID); } } if (image != null) { Stream stream = new System.IO.MemoryStream(image); // Set up the response settings context.Response.ContentType = "image/jpeg"; context.Response.Cache.SetExpires(DateTime.Now.AddDays(7)); context.Response.Cache.SetCacheability(HttpCacheability.Public); context.Response.Cache.SetValidUntilExpires(true); context.Response.BufferOutput = false; context.Response.AddHeader("Content-Length", stream.Length.ToString()); const int buffersize = 1024 * 16; byte[] buffer2 = new byte[buffersize]; int count = stream.Read(buffer2, 0, buffersize); while (count > 0) { context.Response.OutputStream.Write(buffer2, 0, count); count = stream.Read(buffer2, 0, buffersize); } } else { context.Response.Write("No Image Found"); } } }
public System.IO.Stream GetUserPhotoList150x300(Int64 NodeID) { Object result = null; Edit.Utilities.DataIO resize = new Profiles.Edit.Utilities.DataIO(); result = resize.ResizeImageFile(GetUserPhotoList(NodeID), 150, 300); if (result == null) { result = (byte[])System.Text.Encoding.ASCII.GetBytes("null"); } return new System.IO.MemoryStream((byte[])result); }