示例#1
0
        public void CreateUploadMessages(BO.ORCID.Person person, string loggedInInternalUsername)
        {
            // Before opening the transaction get the 'read limited' token if it exists.
            // if it does not exist or is expired we will create a message to update it.
            BO.ORCID.PersonToken personToken = new BLL.ORCID.PersonToken().GetByPersonIDAndPermissionID(person.PersonID, (int)BO.ORCID.REFPermission.REFPermissions.orcid_profile_read_limited);

            using (System.Data.Common.DbTransaction trans = base.GetEditTransaction())
            {
                try
                {
                    new ProfilesRNSDLL.BLL.ORCID.Person().Edit(person, trans);
                    if (!personToken.Exists || personToken.IsExpired)
                    {
                        CreateMessageToReadLimited(person, trans);
                    }
                    if (person.PushBiographyToORCID || (person.HasURLsToPush))
                    {
                        CreateBioUpdateMessage(person, trans, loggedInInternalUsername);
                    }
                    WorksUpdate(person, trans);
                    AffiliationsUpdate(person, trans);
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw ErrorLog.LogError(ex, loggedInInternalUsername, "An error occurred while generating the messages to send to ORCID.");
                }
            }
        }
        public void CreateUploadMessages(BO.ORCID.Person person, string loggedInInternalUsername)
        {
            // Before opening the transaction get the 'read limited' token if it exists.
            // if it does not exist or is expired we will create a message to update it.
            BO.ORCID.PersonToken personToken = new BLL.ORCID.PersonToken().GetByPersonIDAndPermissionID(person.PersonID, (int)BO.ORCID.REFPermission.REFPermissions.orcid_profile_read_limited);

            using (System.Data.Common.DbTransaction trans = base.GetEditTransaction())
            {
                try
                {
                    new ProfilesRNSDLL.BLL.ORCID.Person().Edit(person, trans);
                    if (!personToken.Exists || personToken.IsExpired)
                    {
                        CreateMessageToReadLimited(person, trans);
                    }
                    if (person.PushBiographyToORCID || (person.HasURLsToPush))
                    {
                        CreateBioUpdateMessage(person, trans, loggedInInternalUsername);
                    }
                    WorksUpdate(person, trans);
                    AffiliationsUpdate(person, trans);
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw ErrorLog.LogError(ex, loggedInInternalUsername, "An error occurred while generating the messages to send to ORCID.");
                }
            }
        }
 public ProfilesRNSDLL.BO.ORCID.PersonToken Get(BO.ORCID.Person person, BO.ORCID.REFPermission refPermission)
 {
     ProfilesRNSDLL.BO.ORCID.PersonToken personToken = new BLL.ORCID.PersonToken().GetByPersonIDAndPermissionID(person.PersonID, refPermission.PermissionID);
     if (personToken.Exists && !personToken.IsExpired)
     {
         return personToken;
     }
     else
     {
         BO.ORCID.PersonToken bo = new BO.ORCID.PersonToken();
         bo.PersonID = person.PersonID;
         bo.PermissionID = refPermission.PermissionID;
         return bo;
     }
 }
示例#4
0
 public ProfilesRNSDLL.BO.ORCID.PersonToken Get(BO.ORCID.Person person, BO.ORCID.REFPermission refPermission)
 {
     ProfilesRNSDLL.BO.ORCID.PersonToken personToken = new BLL.ORCID.PersonToken().GetByPersonIDAndPermissionID(person.PersonID, refPermission.PermissionID);
     if (personToken.Exists && !personToken.IsExpired)
     {
         return(personToken);
     }
     else
     {
         BO.ORCID.PersonToken bo = new BO.ORCID.PersonToken();
         bo.PersonID     = person.PersonID;
         bo.PermissionID = refPermission.PermissionID;
         return(bo);
     }
 }
示例#5
0
        public System.Xml.XmlDocument GetORCIDRecordLimited(BO.ORCID.Person orcidPerson, string loggedInInternalUsername)
        {
            BO.ORCID.REFPermission refPermission = new BLL.ORCID.REFPermission().Get((int)BO.ORCID.REFPermission.REFPermissions.orcid_profile_read_limited);

            // Make sure we have either created the ORCID or the user has provided the ORCID.
            if (orcidPerson.ORCIDIsNull)
            {
                throw new ProfilesRNSDLL.DevelopmentBase.BO.ExceptionSafeToDisplay("Cannot return the ORCID record, the ORCID identifier has not been recorded.");
            }

            // Make sure the users has granted the permission to read the profile.
            BO.ORCID.PersonToken personToken = new BLL.ORCID.PersonToken().GetByPersonIDAndPermissionID(orcidPerson.PersonID, (int)BO.ORCID.REFPermission.REFPermissions.orcid_profile_read_limited);
            if (personToken.Exists && !personToken.IsExpired)
            {
                try
                {
                    string ORCIDCreateProfileURL = ProfilesRNSDLL.BO.ORCID.Config.ORCID_API_URL_WITH_VERSION + "/" + orcidPerson.ORCID + "/" + refPermission.MethodAndRequest;

                    var httpWebRequest = WebRequest.Create(ORCIDCreateProfileURL);
                    httpWebRequest.ContentType = "application/vdn.orcid+xml";
                    httpWebRequest.Method      = System.Net.WebRequestMethods.Http.Get;

                    httpWebRequest.Headers.Add("Authorization", " Bearer " + personToken.AccessToken);

                    using (WebResponse response = httpWebRequest.GetResponse())
                    {
                        using (var reader = new StreamReader(response.GetResponseStream()))
                        {
                            string result = reader.ReadToEnd();
                            System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
                            xml.LoadXml(result);
                            return(xml);
                        }
                    }
                    // curl -H 'Content-Type: application/vdn.orcid+xml' -H 'Authorization: Bearer f6d49570-c048-45a9-951f-a81ebb1fa543' -X GET 'http://api.sandbox-1.orcid.org/v1.0.23/0000-0003-1495-7122/orcid-profile' -L -i
                }
                catch (Exception ex)
                {
                    throw BLL.ORCID.ErrorLog.LogError(ex, loggedInInternalUsername, "An error occurred while connecting to ORCID.  Unable to retrieve token information to save.");
                }
            }
            else
            {
                throw new ProfilesRNSDLL.DevelopmentBase.BO.ExceptionSafeToDisplay("Cannot return the ORCID record, permission has not been granted to read the record.");
            }
        }
 public bool CheckForValidToken(BO.ORCID.Person person, BO.ORCID.REFPermission refPermission)
 {
     ProfilesRNSDLL.BO.ORCID.PersonToken personToken = new BLL.ORCID.PersonToken().GetByPersonIDAndPermissionID(person.PersonID, refPermission.PermissionID);
     return personToken.Exists && !personToken.IsExpired;
 }
示例#7
0
 public bool CheckForValidToken(BO.ORCID.Person person, BO.ORCID.REFPermission refPermission)
 {
     ProfilesRNSDLL.BO.ORCID.PersonToken personToken = new BLL.ORCID.PersonToken().GetByPersonIDAndPermissionID(person.PersonID, refPermission.PermissionID);
     return(personToken.Exists && !personToken.IsExpired);
 }
        public System.Xml.XmlDocument GetORCIDRecordLimited(BO.ORCID.Person orcidPerson, string loggedInInternalUsername)
        {
            BO.ORCID.REFPermission refPermission = new BLL.ORCID.REFPermission().Get((int)BO.ORCID.REFPermission.REFPermissions.orcid_profile_read_limited);

            // Make sure we have either created the ORCID or the user has provided the ORCID.
            if (orcidPerson.ORCIDIsNull)
            {
                throw new ProfilesRNSDLL.DevelopmentBase.BO.ExceptionSafeToDisplay("Cannot return the ORCID record, the ORCID identifier has not been recorded.");
            }

            // Make sure the users has granted the permission to read the profile.
            BO.ORCID.PersonToken personToken = new BLL.ORCID.PersonToken().GetByPersonIDAndPermissionID(orcidPerson.PersonID, (int)BO.ORCID.REFPermission.REFPermissions.orcid_profile_read_limited);
            if (personToken.Exists && !personToken.IsExpired)
            {
                try
                {
                    string ORCIDCreateProfileURL = ProfilesRNSDLL.BO.ORCID.Config.ORCID_API_URL_WITH_VERSION + "/" + orcidPerson.ORCID + "/" + refPermission.MethodAndRequest;

                    var httpWebRequest = WebRequest.Create(ORCIDCreateProfileURL);
                    httpWebRequest.ContentType = "application/vdn.orcid+xml";
                    httpWebRequest.Method = System.Net.WebRequestMethods.Http.Get;

                    httpWebRequest.Headers.Add("Authorization", " Bearer " + personToken.AccessToken);

                    using (WebResponse response = httpWebRequest.GetResponse())
                    {
                        using (var reader = new StreamReader(response.GetResponseStream()))
                        {
                            string result = reader.ReadToEnd();
                            System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
                            xml.LoadXml(result);
                            return xml;
                        }
                    }
                    // curl -H 'Content-Type: application/vdn.orcid+xml' -H 'Authorization: Bearer f6d49570-c048-45a9-951f-a81ebb1fa543' -X GET 'http://api.sandbox-1.orcid.org/v1.0.23/0000-0003-1495-7122/orcid-profile' -L -i
                }
                catch (Exception ex)
                {
                    throw BLL.ORCID.ErrorLog.LogError(ex, loggedInInternalUsername, "An error occurred while connecting to ORCID.  Unable to retrieve token information to save.");
                }
            }
            else
            {
                throw new ProfilesRNSDLL.DevelopmentBase.BO.ExceptionSafeToDisplay("Cannot return the ORCID record, permission has not been granted to read the record.");
            }
        }