Example #1
0
        protected void ProcessUpload(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
        {
            System.IO.Stream      stream;
            Edit.Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();
            stream = AsyncFileUpload1.PostedFile.InputStream;


            byte[] imageBytes = new byte[AsyncFileUpload1.PostedFile.InputStream.Length + 1];
            AsyncFileUpload1.PostedFile.InputStream.Read(imageBytes, 0, imageBytes.Length);
            Framework.Utilities.Namespace xmlnamespace = new Profiles.Framework.Utilities.Namespace();
            XmlNamespaceManager           namespaces   = xmlnamespace.LoadNamespaces(BaseData);

            if (BaseData.SelectSingleNode("rdf:RDF/rdf:Description[1]/rdf:type[@rdf:resource='http://xmlns.com/foaf/0.1/Person']", namespaces) != null)
            {
                data.SaveImage(this.SubjectID, imageBytes, this.PropertyListXML);
            }
            if (BaseData.SelectSingleNode("rdf:RDF/rdf:Description[1]/rdf:type[@rdf:resource='http://xmlns.com/foaf/0.1/Group']", namespaces) != null)
            {
                data.SaveGroupImage(this.SubjectID, imageBytes, this.PropertyListXML);
            }

            base.GetSubjectProfile();
            this.PropertyListXML = propdata.GetPropertyList(this.BaseData, base.PresentationXML, this.PredicateURI, false, true, false);
            this.DrawProfilesModule();

            InitLinks();
            pnlUpload.Visible = false;
            upnlEditSection.Update();
        }
Example #2
0
        private void UpdateSecuritySetting(string securitygroup)
        {
            // maybe be able to make this more general purpose
            Edit.Utilities.DataIO secdata = new Profiles.Edit.Utilities.DataIO();

            if (!"0".Equals(securitygroup))
            {
                Edit.Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();
                if (this.PredicateURI.Equals("http://profiles.catalyst.harvard.edu/ontology/prns#hasGroupSettings"))
                {
                    data.UpdateGroupSecurity(this.Subject, Convert.ToInt32(securitygroup));
                }
                else if (this.PredicateURI.Equals("http://profiles.catalyst.harvard.edu/ontology/prns#emailEncrypted"))
                {
                    if (Convert.ToInt32(securitygroup) >= -10 && Convert.ToInt32(securitygroup) < 0)
                    {
                        data.UpdateSecuritySetting(this.Subject, data.GetStoreNode("http://vivoweb.org/ontology/core#email"), -20);
                    }
                    else
                    {
                        data.UpdateSecuritySetting(this.Subject, data.GetStoreNode("http://vivoweb.org/ontology/core#email"), Convert.ToInt32(securitygroup));
                    }
                }

                data.UpdateSecuritySetting(this.Subject, data.GetStoreNode(this.PredicateURI), Convert.ToInt32(securitygroup));

                divHidden.Visible = false;
            }
            Framework.Utilities.Cache.AlterDependency(this.Subject.ToString());
        }
Example #3
0
        public CustomEditAuthorInAuthorship(XmlDocument pagedata, List <ModuleParams> moduleparams, XmlNamespaceManager pagenamespaces)
            : base(pagedata, moduleparams, pagenamespaces)
        {
            SessionManagement sm = new SessionManagement();

            Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();
            propdata = new Profiles.Profile.Utilities.DataIO();

            this._subject      = Convert.ToInt64(Request.QueryString["subject"]);
            this._predicateuri = Request.QueryString["predicateuri"].Replace("!", "#");
            this._personId     = data.GetPersonID(_subject);

            Session["NodeID"]    = this._subject;
            Session["SessionID"] = sm.Session().SessionID;

            this.PropertyListXML = propdata.GetPropertyList(pagedata, base.PresentationXML, this._predicateuri, false, true, false);

            securityOptions.Subject        = this._subject;
            securityOptions.PredicateURI   = this._predicateuri;
            securityOptions.PrivacyCode    = Convert.ToInt32(this.PropertyListXML.SelectSingleNode("PropertyList/PropertyGroup/Property/@ViewSecurityGroup").Value);
            securityOptions.SecurityGroups = new XmlDocument();
            securityOptions.SecurityGroups.LoadXml(base.PresentationXML.DocumentElement.LastChild.OuterXml);


            securityOptions.BubbleClick += SecurityDisplayed;
        }
Example #4
0
        public CustomEditMainImage(XmlDocument pagedata, List <ModuleParams> moduleparams, XmlNamespaceManager pagenamespaces)
            : base(pagedata, moduleparams, pagenamespaces)
        {
            Edit.Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();
            SessionManagement     sm   = new SessionManagement();

            this.XMLData = pagedata;

            propdata = new Profiles.Profile.Utilities.DataIO();

            if (Request.QueryString["subject"] != null)
            {
                this.SubjectID = Convert.ToInt64(Request.QueryString["subject"]);
            }
            else if (base.GetRawQueryStringItem("subject") != null)
            {
                this.SubjectID = Convert.ToInt64(base.GetRawQueryStringItem("subject"));
            }
            else
            {
                Response.Redirect("~/search");
            }

            this.PredicateURI    = Request.QueryString["predicateuri"].Replace("!", "#");
            this.PropertyListXML = propdata.GetPropertyList(this.BaseData, base.PresentationXML, PredicateURI, false, true, false);
            litBackLink.Text     = "<a href='" + Root.Domain + "/edit/" + this.SubjectID.ToString() + "'>Edit Menu</a> &gt; <b>" + PropertyListXML.SelectSingleNode("PropertyList/PropertyGroup/Property/@Label").Value + "</b>";

            securityOptions.Subject        = this.SubjectID;
            securityOptions.PredicateURI   = PredicateURI;
            securityOptions.PrivacyCode    = Convert.ToInt32(this.PropertyListXML.SelectSingleNode("PropertyList/PropertyGroup/Property/@ViewSecurityGroup").Value);
            securityOptions.SecurityGroups = new XmlDataDocument();
            securityOptions.SecurityGroups.LoadXml(base.PresentationXML.DocumentElement.LastChild.OuterXml);

            securityOptions.BubbleClick += SecurityDisplayed;
        }
Example #5
0
        //Inserts comma seperated string of PubMed Ids into the db
        private void InsertPubMedIds(string value)
        {
            string uri = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?retmax=1000&db=pubmed&retmode=xml&id=" + value;

            System.Xml.XmlDocument myXml = new System.Xml.XmlDocument();
            myXml.LoadXml(this.HttpPost(uri, "Catalyst", "text/plain"));
            XmlNodeList nodes = myXml.SelectNodes("PubmedArticleSet/PubmedArticle");

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

            foreach (XmlNode node in nodes)
            {
                string pmid = node.SelectSingleNode("MedlineCitation/PMID").InnerText;

                if (!data.CheckPublicationExists(pmid))
                {
                    // Insert or update the publication
                    data.AddPublication(pmid, node.OuterXml);
                }

                // Assign the user to the publication
                data.AddPublication(_personId, _subject, Convert.ToInt32(pmid), this.PropertyListXML);
            }

            data.UpdateEntityOnePerson(_personId);
            this.KillCache();
            this.Counter = 0;
            Session["phAddPub.Visible"]           = null;
            Session["pnlAddPubMed.Visible"]       = null;
            Session["pnlAddCustomPubMed.Visible"] = null;
            Session["pnlDeletePubMed.Visible"]    = null;
            upnlEditSection.Update();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string keys = Request.QueryString["keys"];
            Profiles.Edit.Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();
            string suggestions = data.getAutoCompleteSuggestions(keys);

            litTest.Text = suggestions;
            return;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string keys = Request.QueryString["keys"];

            Profiles.Edit.Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();
            string suggestions = data.getAutoCompleteSuggestions(keys);

            litTest.Text = suggestions;
            return;
        }
        protected void gridEntities_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            Edit.Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();

            Int64 _object = Convert.ToInt64(data.GetStoreNode(gridEntities.DataKeys[e.RowIndex].Values[0].ToString()));

            data.DeleteTriple(this.SubjectID, this.PredicateID, _object);
            this.LoadEntityGrid(true);

            upnlEditSection.Update();
        }
        protected void ibDown_Click(object sender, EventArgs e)
        {
            Edit.Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();
            gridEntities.EditIndex = -1;
            GridViewRow row     = ((ImageButton)sender).Parent.Parent as GridViewRow;
            Int64       _object = Convert.ToInt64(data.GetStoreNode(gridEntities.DataKeys[row.RowIndex].Values[0].ToString()));

            data.MoveTripleUp(this.SubjectID, this.PredicateID, _object);

            this.LoadEntityGrid(true);
            upnlEditSection.Update();
        }
 private void UpdateSecuritySetting(string securitygroup)
 {
     Edit.Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();
     if (this.PredicateURI.Equals("http://profiles.catalyst.harvard.edu/ontology/prns#hasGroupSettings"))
     {
         data.UpdateGroupSecurity(this.Subject, Convert.ToInt32(securitygroup));
     }
     else
     {
         data.UpdateSecuritySetting(this.Subject, data.GetStoreNode(this.PredicateURI), Convert.ToInt32(securitygroup));
     }
 }
Example #11
0
        protected void deleteOne_Onclick(object sender, EventArgs e)
        {
            ImageButton lb = (ImageButton)sender;

            string key = lb.CommandArgument;

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

            data.DeleteOnePublication(this._personId, Convert.ToInt64(Session["NodeID"]), key, this.PropertyListXML);
            this.Counter = 0;
            grdEditPublications.DataBind();
            upnlEditSection.Update();
        }
Example #12
0
        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));
        }
Example #13
0
        public EditPersonalGadget(XmlDocument pagedata, List <ModuleParams> moduleparams, XmlNamespaceManager pagenamespaces)
            : base(pagedata, moduleparams, pagenamespaces)
        {
            SessionManagement sm = new SessionManagement();

            base.BaseData = pagedata;

            data = new Profiles.ORNG.Utilities.DataIO();
            Profiles.Edit.Utilities.DataIO    editdata = new Profiles.Edit.Utilities.DataIO();
            Profiles.Profile.Utilities.DataIO propdata = new Profiles.Profile.Utilities.DataIO();

            if (Request.QueryString["subject"] != null)
            {
                this.SubjectID = Convert.ToInt64(Request.QueryString["subject"]);
            }
            else if (base.GetRawQueryStringItem("subject") != null)
            {
                this.SubjectID = Convert.ToInt64(base.GetRawQueryStringItem("subject"));
            }
            else
            {
                Response.Redirect("~/search");
            }

            this.PredicateURI    = Request.QueryString["predicateuri"].Replace("!", "#");
            this.PropertyListXML = propdata.GetPropertyList(this.BaseData, base.PresentationXML, this.PredicateURI, false, true, false);
            litBackLink.Text     = "<a href='" + Root.Domain + "/edit/" + this.SubjectID.ToString() + "'>Edit Menu</a> &gt; <b>" + PropertyListXML.SelectSingleNode("PropertyList/PropertyGroup/Property/@Label").Value + "</b>";


            //create a new network triple request.
            base.RDFTriple = new RDFTriple(this.SubjectID, editdata.GetStoreNode(this.PredicateURI));

            base.RDFTriple.Expand      = true;
            base.RDFTriple.ShowDetails = true;
            base.GetDataByURI();//This will reset the data to a Network.

            // Profiles OpenSocial Extension by UCSF
            uri    = this.BaseData.SelectSingleNode("rdf:RDF/rdf:Description/@rdf:about", base.Namespaces).Value;
            uri    = uri.Substring(0, uri.IndexOf(Convert.ToString(this.SubjectID)) + Convert.ToString(this.SubjectID).Length);
            appId  = Convert.ToInt32(base.GetModuleParamString("AppId"));
            om     = OpenSocialManager.GetOpenSocialManager(uri, Page, true);
            gadget = om.AddGadget(appId, base.GetModuleParamString("View"), base.GetModuleParamString("OptParams"));

            securityOptions.Subject        = this.SubjectID;
            securityOptions.PredicateURI   = this.PredicateURI;
            securityOptions.PrivacyCode    = Convert.ToInt32(this.PropertyListXML.SelectSingleNode("PropertyList/PropertyGroup/Property/@ViewSecurityGroup").Value);
            securityOptions.SecurityGroups = new XmlDataDocument();
            securityOptions.SecurityGroups.LoadXml(base.PresentationXML.DocumentElement.LastChild.OuterXml);

            hasGadget = Convert.ToInt32(this.PropertyListXML.SelectSingleNode("PropertyList/PropertyGroup/Property/@NumberOfConnections").Value) > 0;
        }
        private void SaveEntityByURI(string uri)
        {
            Int64 objectid = 0;

            Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();
            objectid = data.GetStoreNode(uri.Trim());

            Session["pnlAddBySearch.Visible"] = null;
            Session["pnlAddByURI.Visible"]    = null;

            data.AddExistingEntity(SubjectID, PredicateID, objectid);

            this.LoadEntityGrid(true);
        }
Example #15
0
        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));
        }
        private void AddNewEntity()
        {
            Utilities.DataIO data           = new Profiles.Edit.Utilities.DataIO();
            string           newentity      = txtNewEntity.Text.Trim();
            string           entityclassuri = ddlAddNewPropertyList.SelectedValue.Trim();

            Session["pnlAddBySearch.Visible"] = null;
            Session["pnlAddByURI.Visible"]    = null;
            Int64 entityid = 0;

            entityid = data.AddNewEntity(newentity, entityclassuri);

            data.AddExistingEntity(this.SubjectID, this.PredicateID, entityid);

            this.LoadEntityGrid(true);
        }
        private void UpdateVisibility()
        {
            Edit.Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();
            int securitygroup          = Convert.ToInt32(this.PropertyListXML.SelectSingleNode("PropertyList/PropertyGroup/Property/@ViewSecurityGroup").Value);

            data.UpdateSecuritySetting(this.SubjectID, data.GetStoreNode(this.PredicateURI), securitygroup);

            if (securitygroup >= -10 && securitygroup < 0)
            {
                data.UpdateSecuritySetting(this.SubjectID, data.GetStoreNode("http://vivoweb.org/ontology/core#email"), -20);
            }
            else
            {
                data.UpdateSecuritySetting(this.SubjectID, data.GetStoreNode("http://vivoweb.org/ontology/core#email"), securitygroup);
            }
        }
Example #18
0
        protected void btnDeleteAll_OnClick(object sender, EventArgs e)
        {
            // PRG: Double-check we're using the correct username variable here
            //myParameters.Add("@username", (string)Session["ProfileUsername"]));
            Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();
            data.DeletePublications(_personId, _subject, true, true);
            this.Counter               = 0;
            phAddPub.Visible           = true;
            phAddPubMed.Visible        = true;
            phAddCustom.Visible        = true;
            phSecuritySettings.Visible = true;
            pnlDeletePubMed.Visible    = false;
            btnImgDeletePub.ImageUrl   = Root.Domain + "/Framework/images/icon_squareArrow.gif";

            grdEditPublications.DataBind();
            upnlEditSection.Update();
        }
        public EditPersonalGadget(XmlDocument pagedata, List<ModuleParams> moduleparams, XmlNamespaceManager pagenamespaces)
            : base(pagedata, moduleparams, pagenamespaces)
        {
            SessionManagement sm = new SessionManagement();
            base.BaseData = pagedata;

            data = new Profiles.ORNG.Utilities.DataIO();
            Profiles.Edit.Utilities.DataIO editdata = new Profiles.Edit.Utilities.DataIO();
            Profiles.Profile.Utilities.DataIO propdata = new Profiles.Profile.Utilities.DataIO();

            if (Request.QueryString["subject"] != null)
                this.SubjectID = Convert.ToInt64(Request.QueryString["subject"]);
            else if (base.GetRawQueryStringItem("subject") != null)
                this.SubjectID = Convert.ToInt64(base.GetRawQueryStringItem("subject"));
            else
                Response.Redirect("~/search");

            this.PredicateURI = Request.QueryString["predicateuri"].Replace("!", "#");
            this.PropertyListXML = propdata.GetPropertyList(this.BaseData, base.PresentationXML, this.PredicateURI, false, true, false);
            litBackLink.Text = "<a href='" + Root.Domain + "/edit/" + this.SubjectID.ToString() + "'>Edit Menu</a> &gt; <b>" + PropertyListXML.SelectSingleNode("PropertyList/PropertyGroup/Property/@Label").Value + "</b>";

            //create a new network triple request.
            base.RDFTriple = new RDFTriple(this.SubjectID, editdata.GetStoreNode(this.PredicateURI));

            base.RDFTriple.Expand = true;
            base.RDFTriple.ShowDetails = true;
            base.GetDataByURI();//This will reset the data to a Network.

            // Profiles OpenSocial Extension by UCSF
            uri = this.BaseData.SelectSingleNode("rdf:RDF/rdf:Description/@rdf:about", base.Namespaces).Value;
            uri = uri.Substring(0, uri.IndexOf(Convert.ToString(this.SubjectID)) + Convert.ToString(this.SubjectID).Length);
            appId = Convert.ToInt32(base.GetModuleParamString("AppId"));
            om = OpenSocialManager.GetOpenSocialManager(uri, Page, true);
            if (om.IsEnabled())
            {
                gadget = om.AddOntologyGadget(appId, base.GetModuleParamString("View"), base.GetModuleParamString("OptParams"));
            }

            securityOptions.Subject = this.SubjectID;
            securityOptions.PredicateURI = this.PredicateURI;
            securityOptions.PrivacyCode = Convert.ToInt32(this.PropertyListXML.SelectSingleNode("PropertyList/PropertyGroup/Property/@ViewSecurityGroup").Value);
            securityOptions.SecurityGroups = new XmlDataDocument();
            securityOptions.SecurityGroups.LoadXml(base.PresentationXML.DocumentElement.LastChild.OuterXml);

            hasGadget = Convert.ToInt32(this.PropertyListXML.SelectSingleNode("PropertyList/PropertyGroup/Property/@NumberOfConnections").Value) > 0;
        }
Example #20
0
        protected void btnDeleteCustomOnly_OnClick(object sender, EventArgs e)
        {
            Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();
            data.DeletePublications(_personId, _subject, false, true);
            this.KillCache();
            this.Counter               = 0;
            phAddPub.Visible           = true;
            phAddPubMed.Visible        = true;
            phAddCustom.Visible        = true;
            pnlDeletePubMed.Visible    = false;
            phSecuritySettings.Visible = true;
            btnImgDeletePub.ImageUrl   = Root.Domain + "/Framework/images/icon_squareArrow.gif";

            grdEditPublications.DataBind();


            upnlEditSection.Update();
        }
Example #21
0
        protected void btnNewORCID_Click(object sender, EventArgs e)
        {
            try
            {
                long subjectID       = Convert.ToInt32(Request.QueryString["subject"]);
                int  profilePersonID = new Profiles.Edit.Utilities.DataIO().GetPersonID(subjectID);
                Utilities.ProfilesRNSDLL.BLL.ORCID.Person personBLL = new Utilities.ProfilesRNSDLL.BLL.ORCID.Person();
                Utilities.ProfilesRNSDLL.BO.ORCID.Person  bo        = personBLL.GetByPersonID(profilePersonID);
                if (chkUploadInfoNow.Checked)
                {
                    bo = UploadInfoToORCID1.GetPersonWithPageData(bo);
                }

                GetPageControlValues(bo);

                if (Profiles.ORCID.Utilities.config.RequireAcknowledgement)
                {
                    bo.AgreementAcknowledged = true;
                }
                if (new Profiles.ORCID.Utilities.ProfilesRNSDLL.BLL.ORCID.Person().CreateNewORCID(bo, LoggedInInternalUsername, Profiles.ORCID.Utilities.ProfilesRNSDLL.BO.ORCID.REFPersonStatusType.REFPersonStatusTypes.User_Push_Failed))
                {
                    Edit.Utilities.DataIO data = new Edit.Utilities.DataIO();
                    data.AddLiteral(subjectID, data.GetStoreNode("http://vivoweb.org/ontology/core#orcidId"), data.GetStoreNode(bo.ORCID), this.PropertyListXML);

                    bool isProxy = Profiles.ORCID.Utilities.DataIO.getNodeIdFromInternalUserName(LoggedInInternalUsername) != subjectID;
                    Response.Redirect("~/ORCID/CreationConfirmation.aspx?UserORCID=" + bo.ORCID + "&Proxy=" + isProxy, false);
                    return;
                }
                else
                {
                    this.lblErrorsCreate.Text = bo.Error + bo.AllErrors + "<br /><br />";
                    GetErrorsAndMessages(bo);
                }
            }
            catch (Exception ex)
            {
                lblErrorsCreate.Text = ex.Message;
                LogException(ex);
            }
        }
        protected void btnNewORCID_Click(object sender, EventArgs e)
        {
            try
            {
                long subjectID = Convert.ToInt32(Request.QueryString["subject"]);
                int profilePersonID = new Profiles.Edit.Utilities.DataIO().GetPersonID(subjectID);
                Utilities.ProfilesRNSDLL.BLL.ORCID.Person personBLL = new Utilities.ProfilesRNSDLL.BLL.ORCID.Person();
                Utilities.ProfilesRNSDLL.BO.ORCID.Person bo = personBLL.GetByPersonID(profilePersonID);
                if (chkUploadInfoNow.Checked)
                {
                    bo = UploadInfoToORCID1.GetPersonWithPageData(bo);
                }

                GetPageControlValues(bo);

                if (Profiles.ORCID.Utilities.config.RequireAcknowledgement)
                {
                    bo.AgreementAcknowledged = true;
                }
                if (new Profiles.ORCID.Utilities.ProfilesRNSDLL.BLL.ORCID.Person().CreateNewORCID(bo, LoggedInInternalUsername, Profiles.ORCID.Utilities.ProfilesRNSDLL.BO.ORCID.REFPersonStatusType.REFPersonStatusTypes.User_Push_Failed))
                {
                    Edit.Utilities.DataIO data = new Edit.Utilities.DataIO();
                    data.AddLiteral(subjectID, data.GetStoreNode("http://vivoweb.org/ontology/core#orcidId"), data.GetStoreNode(bo.ORCID), this.PropertyListXML);

                    bool isProxy = Profiles.ORCID.Utilities.DataIO.getNodeIdFromInternalUserName(LoggedInInternalUsername) != subjectID;
                    Response.Redirect("~/ORCID/CreationConfirmation.aspx?UserORCID=" + bo.ORCID + "&Proxy="+isProxy, false);
                    return;
                }
                else
                {
                    this.lblErrorsCreate.Text = bo.Error + bo.AllErrors + "<br /><br />";
                    GetErrorsAndMessages(bo);
                }
            }
            catch (Exception ex)
            {
                lblErrorsCreate.Text = ex.Message;
                LogException(ex);
            }
        }
 private void UpdateSecuritySetting(string securitygroup)
 {
     // maybe be able to make this more general purpose
     if (this.PredicateURI.StartsWith(Profiles.ORNG.Utilities.OpenSocialManager.ORNG_ONTOLOGY_PREFIX))
     {
         Profiles.ORNG.Utilities.DataIO data = new Profiles.ORNG.Utilities.DataIO();
         if ("0".Equals(securitygroup))
         {
             data.RemovePersonalGadget(this.Subject, this.PredicateURI);
         }
         else
         {
             data.AddPersonalGadget(this.Subject, this.PredicateURI);
         }
     }
     else if (!"0".Equals(securitygroup))
     {
         Edit.Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();
         data.UpdateSecuritySetting(this.Subject, data.GetStoreNode(this.PredicateURI), Convert.ToInt32(securitygroup));
     }
     //Framework.Utilities.Cache.AlterDependency(this.Subject.ToString());
 }
Example #24
0
        protected void grdEditPublications_SelectedIndexChanged(object sender, EventArgs e)
        {
            pnlAddPubById.Visible       = false;
            pnlAddPubMed.Visible        = false;
            pnlAddPubMedResults.Visible = false;
            pnlAddCustomPubMed.Visible  = true;


            IDataReader reader = null;

            try
            {
                Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();

                HiddenField hdn = (HiddenField)grdEditPublications.Rows[grdEditPublications.SelectedIndex].FindControl("hdnMPID");

                reader = data.GetCustomPub(hdn.Value);

                if (reader.Read())
                {
                    drpPublicationType.SelectedValue = reader["hmspubcategory"].ToString();

                    txtPubMedAdditionalInfo.Text = reader["additionalinfo"].ToString();
                    txtPubMedAuthors.Text        = reader["authors"].ToString();
                    if (reader["hmspubcategory"].ToString() == "Thesis")
                    {
                        txtPubMedNewsCity.Text = reader["placeofpub"].ToString();
                    }
                    else
                    {
                        txtPubMedPublisherCity.Text = reader["placeofpub"].ToString();
                    }
                    txtPubMedNewsColumn.Text        = reader["newspapercol"].ToString();
                    txtPubMedConferenceDate.Text    = reader["confdts"].ToString();
                    txtPubMedConferenceEdition.Text = reader["confeditors"].ToString();
                    txtPubMedConferenceName.Text    = reader["confnm"].ToString();
                    txtPubMedPublisherContract.Text = reader["contractnum"].ToString();

                    if (reader["publicationdt"].ToString().Length > 0)
                    {
                        DateTime dt = (DateTime.Parse(reader["publicationdt"].ToString()));
                        txtPubMedPublicationDate.Text = dt.ToShortDateString();
                    }
                    txtPubMedEdition.Text            = reader["edition"].ToString();
                    txtPubMedPublicationIssue.Text   = reader["issuepub"].ToString();
                    txtPubMedConferenceLocation.Text = reader["confloc"].ToString();
                    txtPubMedPublisherName.Text      = reader["publisher"].ToString();
                    txtPubMedOptionalWebsite.Text    = reader["url"].ToString();
                    txtPubMedPublicationPages.Text   = reader["paginationpub"].ToString();
                    txtPubMedPublisherReport.Text    = reader["reptnumber"].ToString();
                    txtPubMedNewsSection.Text        = reader["newspapersect"].ToString();
                    txtPubMedTitle.Text             = reader["pubtitle"].ToString();
                    txtPubMedTitle2.Text            = reader["articletitle"].ToString();
                    txtPubMedNewsUniversity.Text    = reader["dissunivnm"].ToString();
                    txtPubMedPublicationVolume.Text = reader["volnum"].ToString();
                    txtPubMedAbstract.Text          = reader["abstract"].ToString();

                    ShowCustomEdit(reader["hmspubcategory"].ToString());


                    upnlEditSection.Update();
                }
            }
            catch (Exception ex)
            {
                string err = ex.Message;
            }
            finally
            {
                if (reader != null)
                {
                    if (!reader.IsClosed)
                    {
                        reader.Close();
                    }
                }
            }
        }
Example #25
0
        private Utilities.ProfilesRNSDLL.BO.ORCID.Person GetPersonWithDBData(int subject)
        {
            int profilePersonID = new Profiles.Edit.Utilities.DataIO().GetPersonID(subject);

            return(new Utilities.ProfilesRNSDLL.BLL.ORCID.Person().GetPersonWithDBData(profilePersonID, sm.Session().SessionID));
        }
 private Profiles.ORCID.Utilities.ProfilesRNSDLL.BO.ORCID.Person GetPersonWithDBData(int subject)
 {
     int profilePersonID = new Profiles.Edit.Utilities.DataIO().GetPersonID(subject);
     return new Profiles.ORCID.Utilities.ProfilesRNSDLL.BLL.ORCID.Person().GetPersonWithDBData(profilePersonID, sm.Session().SessionID);
 }
        public void DrawProfilesModule()
        {
            Framework.Utilities.DataIO data = new Profiles.Framework.Utilities.DataIO();

            if (Request.Form["hdnSelectedURI"] != string.Empty && Request.Form["hdnSelectedURI"] != null)
            {
                Edit.Utilities.DataIO editdata = new Profiles.Edit.Utilities.DataIO();

                string newentity = string.Empty;

                newentity = Request.Form["hdnSelectedURI"].Trim();

                Int64 _object = Convert.ToInt64(editdata.GetStoreNode(newentity));

                editdata.AddExistingEntity(this.SubjectID, this.PredicateID, _object);
                Session["pnlAddBySearch.Visible"] = null;
                this.LoadEntityGrid(true);
            }
            else
            {
                LoadEntityGrid(false);
            }

            XmlDocument            list         = data.GetPropertyRangeList(this.PredicateURI);
            List <GenericListItem> propertylist = new List <GenericListItem>();
            string space = string.Empty;


            foreach (XmlNode property in list.SelectNodes("PropertyRangeList/PropertyRange"))
            {
                for (int i = 0; i < Convert.ToInt16(property.SelectSingleNode("@Depth").Value); i++)
                {
                    space += Server.HtmlDecode("&nbsp;&nbsp;&nbsp;");
                }
                propertylist.Add(new GenericListItem(space + property.SelectSingleNode("@Label").Value, property.SelectSingleNode("@ClassURI").Value));
                space = string.Empty;
            }

            PropertyList = propertylist;

            if (ddlPropertyList.SelectedValue == string.Empty)
            {
                ddlPropertyList.DataSource     = propertylist;
                ddlPropertyList.DataTextField  = "Text";
                ddlPropertyList.DataValueField = "Value";
                ddlPropertyList.DataBind();
                ddlPropertyList.Items.Insert(0, new ListItem("--- Select ---", ""));
                ddlPropertyList.SelectedValue   = "";
                ddlPropertyList.EnableViewState = true;
            }

            if (ddlAddNewPropertyList.SelectedValue == string.Empty)
            {
                ddlAddNewPropertyList.DataSource     = propertylist;
                ddlAddNewPropertyList.DataTextField  = "Text";
                ddlAddNewPropertyList.DataValueField = "Value";
                ddlAddNewPropertyList.DataBind();
                ddlAddNewPropertyList.Items.Insert(0, new ListItem("--- Select ---", ""));
                ddlAddNewPropertyList.SelectedValue   = "";
                ddlAddNewPropertyList.EnableViewState = true;
            }
        }
        protected void cmdSaveByURI_onclick(object sender, ImageClickEventArgs e)
        {
            Edit.Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();

            if (txtURI.Text.ToLower().Trim() != string.Empty)
            {
                string uri      = string.Empty;
                bool   validuri = false;
                bool   urifound = false;
                XmlNamespaceManager nmsmanager = null;

                pnlAddByURI.Visible = false;



                //you need to get back the actual URI that is discovered during the post.
                //The post might be to an HTML document where I have to look for an alt link to RDF data.
                //Plus the URI we get back from this method needs to be used to create a triple in our Database so dont lose it.
                XmlDocument rtndata = data.GetURIRelLink(txtURI.Text.Trim(), ref uri);

                if (rtndata.InnerXml != string.Empty)
                {
                    urifound = true;
                }

                if (urifound)
                {
                    Framework.Utilities.Namespace namespaces = new Namespace();
                    nmsmanager = namespaces.LoadNamespaces(rtndata);

                    if (rtndata.SelectSingleNode("rdf:RDF/rdf:Description/rdf:type[@rdf:resource='" + PropertyList[0].Value + "']", nmsmanager) != null)
                    {
                        validuri = true;
                    }
                }

                if (uri.Trim() != string.Empty)
                {
                    litAddByURIConfirmLabel.Text = rtndata.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/rdfs:label", nmsmanager).InnerText;
                    hdnURI.Value = uri;
                }
                else
                {
                    litAddByURIConfirmLabel.Text = txtURI.Text.Trim();
                    hdnURI.Value = txtURI.Text.Trim();
                }

                if (validuri)
                {
                    litAddByURIConfirmType.Text = PropertyList[0].Text;
                }
                else if (!urifound)
                {
                    litAddByURIConfirmType.Text = "The item could not be found. Do you still want to add this URL?";
                }
                else if (!validuri)
                {
                    litAddByURIConfirmType.Text = "The item type is invalid. Do you want to add this item anyway?";
                }


                pnlAddByURIConfirm.Visible     = true;
                pnlAddBySearch.Visible         = false;
                pnlAddNew.Visible              = false;
                pnlAddByURI.Visible            = false;
                phAddBySearch.Visible          = false;
                phAddNew.Visible               = false;
                phAddByURL.Visible             = true;
                imgAddArror.ImageUrl           = "~/Framework/Images/icon_squareDownArrow.gif";
                Session["pnlAddByURI.Visible"] = true;
            }
        }
Example #29
0
        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");
                }
            }
        }
Example #30
0
        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);
        }
        private Profiles.ORCID.Utilities.ProfilesRNSDLL.BO.ORCID.Person GetPersonWithDBData()
        {
            int profilePersonID = new Profiles.Edit.Utilities.DataIO().GetPersonID(base.RDFTriple.Subject);

            return(new Profiles.ORCID.Utilities.ProfilesRNSDLL.BLL.ORCID.Person().GetPersonWithDBData(profilePersonID, sm.Session().SessionID));
        }
Example #32
0
        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");
                }
            }
        }
 private Utilities.ProfilesRNSDLL.BO.ORCID.Person GetPersonWithDBData()
 {
     int profilePersonID = new Profiles.Edit.Utilities.DataIO().GetPersonID(base.RDFTriple.Subject);
     return new Utilities.ProfilesRNSDLL.BLL.ORCID.Person().GetPersonWithDBData(profilePersonID, sm.Session().SessionID);
 }
Example #34
0
        protected void btnPubMedSaveCustom_OnClick(object sender, EventArgs e)
        {
            string click = "btnPubMedSaveCustom_OnClick";


            Hashtable myParameters = new Hashtable();

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

            myParameters.Add("@HMS_PUB_CATEGORY", drpPublicationType.SelectedValue);
            myParameters.Add("@ADDITIONAL_INFO", txtPubMedAdditionalInfo.Text);
            myParameters.Add("@ABSTRACT", txtPubMedAbstract.Text);
            myParameters.Add("@AUTHORS", txtPubMedAuthors.Text);
            if (drpPublicationType.SelectedValue == "Thesis")
            {
                myParameters.Add("@PLACE_OF_PUB", txtPubMedNewsCity.Text);
            }
            else
            {
                myParameters.Add("@PLACE_OF_PUB", txtPubMedPublisherCity.Text);
            }
            myParameters.Add("@NEWSPAPER_COL", txtPubMedNewsColumn.Text);
            myParameters.Add("@CONF_DTS", txtPubMedConferenceDate.Text);
            myParameters.Add("@CONF_EDITORS", txtPubMedConferenceEdition.Text);
            myParameters.Add("@CONF_NM", txtPubMedConferenceName.Text);
            myParameters.Add("@CONTRACT_NUM", txtPubMedPublisherContract.Text);

            DateTime temp;
            bool     yessubmit = false;

            if (DateTime.TryParse(txtPubMedPublicationDate.Text, out temp))
            {
                yessubmit = true;
            }

            myParameters.Add("@PUBLICATION_DT", txtPubMedPublicationDate.Text);

            myParameters.Add("@EDITION", txtPubMedEdition.Text);
            myParameters.Add("@ISSUE_PUB", txtPubMedPublicationIssue.Text);
            myParameters.Add("@CONF_LOC", txtPubMedConferenceLocation.Text);
            myParameters.Add("@PUBLISHER", txtPubMedPublisherName.Text);
            myParameters.Add("@URL", txtPubMedOptionalWebsite.Text);
            myParameters.Add("@PAGINATION_PUB", txtPubMedPublicationPages.Text);
            myParameters.Add("@REPT_NUMBER", txtPubMedPublisherReport.Text);
            myParameters.Add("@NEWSPAPER_SECT", txtPubMedNewsSection.Text);
            myParameters.Add("@PUB_TITLE", txtPubMedTitle.Text);
            myParameters.Add("@ARTICLE_TITLE", txtPubMedTitle2.Text);
            myParameters.Add("@DISS_UNIV_NM", txtPubMedNewsUniversity.Text);
            myParameters.Add("@VOL_NUM", txtPubMedPublicationVolume.Text);



            if (grdEditPublications.SelectedIndex > -1)
            {
                //myParameters.Add("@username", Profile.UserId);
                myParameters.Add("@updated_by", _personId);
                HiddenField hdn = (HiddenField)grdEditPublications.Rows[grdEditPublications.SelectedIndex].FindControl("hdnMPID");
                myParameters.Add("@mpid", hdn.Value);

                data.EditCustomPublication(myParameters, _subject, this.PropertyListXML);
                grdEditPublications.SelectedIndex = -1;
            }
            else
            {
                myParameters.Add("@PersonID", _personId);
                myParameters.Add("@created_by", _personId);
                data.AddCustomPublication(myParameters, _personId, _subject, this.PropertyListXML);
            }



            this.Counter = 0;
            grdEditPublications.DataBind();
            ClearPubMedCustom();
            ShowCustomEdit(drpPublicationType.SelectedValue);

            this.KillCache();
            LinkButton lb = (LinkButton)sender;

            if (lb.ID == "btnPubMedSaveCustom")
            {
                phAddPub.Visible           = true;
                phAddPubMed.Visible        = true;
                phDeletePub.Visible        = true;
                phSecuritySettings.Visible = true;
                phMain.Visible             = false;
                pnlAddCustomPubMed.Visible = false;
                btnImgAddCustom.ImageUrl   = Root.Domain + "/Framework/images/icon_squareArrow.gif";
            }
            Session["pnlAddCustomPubMed.Visible"] = null;

            upnlEditSection.Update();
        }
        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");
                }

            }
        }
Example #36
0
        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);
        }