public bool CreateNewORCID(BO.ORCID.Person person, string loggedInInternalUsername, ProfilesRNSDLL.BO.ORCID.REFPersonStatusType.REFPersonStatusTypes failedStatus)
        {
            // Make sure an institution email has been provided.
            // Ensure that the new ORCID information can be saved in the database as it doesn't violate any business rules, e.g. missing internal username.
            if (!BizRulesForCreation(person))
            {
                try
                {
                    person.HasError = false;
                    person.PersonStatusTypeID = (int)failedStatus;
                    Edit(person, false);
                }
                catch
                {

                }
                return false;
            }
            try
            {
                ProfilesRNSDLL.BLL.ORCID.PersonMessage personMessageBLL = new PersonMessage();
                ProfilesRNSDLL.BLL.ORCID.PersonOthername personOthernameBLL = new PersonOthername();
                ProfilesRNSDLL.BLL.ORCID.PersonAlternateEmail personAlternateEmailBLL = new PersonAlternateEmail();
                ProfilesRNSDLL.BLL.ORCID.PersonURL personURLBLL = new PersonURL();
                ProfilesRNSDLL.BLL.ORCID.PersonWork personWorkBLL = new PersonWork();
                ProfilesRNSDLL.BLL.ORCID.PersonAffiliation personAffiliationBLL = new PersonAffiliation();

                if (PostNewORCIDRequestToORCIDAPI(person, loggedInInternalUsername))
                {
                    // Save the person record (includes the narrative, aka biography, if one was provided).
                    person.PersonStatusTypeID = (int)ProfilesRNSDLL.BO.ORCID.REFPersonStatusType.REFPersonStatusTypes.ORCID_Created;
                    person.ORCIDRecorded = DateTime.Now;
                    if (!Save(person))
                    {
                        person.Error += "The ORCID was created but a problem (person save failed) occurred while saving the data in the BU database. ";
                        return false;
                    }
                    // Create a message to save what was sent to ORCID.
                    // Also mark the person with the person message ID
                    if (!personMessageBLL.CreatePersonMessage(person))
                    {
                        person.Error += "The ORCID was created but a problem (person message save failed) occurred while saving the data in the BU database. ";
                        return false;
                    }
                    BLL.ORCID.PersonMessage.SetPersonMessageID(person);
                    // Save the other names
                    if (!personOthernameBLL.AddIfAny(person))
                    {
                        person.Error += "The ORCID was created but a problem (saving of other names failed) occurred while saving the data in the BU database. ";
                        return false;
                    }
                    // Save the alternate email addresses
                    if (!personAlternateEmailBLL.AddIfAny(person))
                    {
                        person.Error += "The ORCID was created but a problem (saving of alternate emails failed) occurred while saving the data in the BU database. ";
                        return false;
                    }
                    // Save the urls
                    if (!personURLBLL.AddIfAny(person))
                    {
                        person.Error += "The ORCID was created but a problem (saving of urls failed) occurred while saving the data in the BU database. ";
                        return false;
                    }
                    // Save the works
                    if (!personWorkBLL.AddIfAny(person))
                    {
                        person.Error += "The ORCID was created but a problem (saving of works failed) occurred while saving the data in the BU database. ";
                        return false;
                    }
                    // Save the works
                    if (!personAffiliationBLL.AddIfAny(person))
                    {
                        person.Error += "The ORCID was created but a problem (saving of affiliations failed) occurred while saving the data in the BU database. ";
                        return false;
                    }
                    return true;
                }
                else
                {
                    person.HasError = false;
                    person.PersonStatusTypeID = (int)failedStatus;
                    try
                    {
                        Save(person, false);
                    }
                    catch (Exception ex)
                    {
                        throw BLL.ORCID.ErrorLog.LogError(ex, loggedInInternalUsername, "An error occurred while saving the fact that the batch push failed.");
                    }
                    return false;
                }
            }
            catch (Exception ex)
            {
                throw ErrorLog.LogError(ex, loggedInInternalUsername, "An error occurred while generating the messages to send to ORCID.");
            }
        }
Beispiel #2
0
        public bool CreateNewORCID(BO.ORCID.Person person, string loggedInInternalUsername, ProfilesRNSDLL.BO.ORCID.REFPersonStatusType.REFPersonStatusTypes failedStatus)
        {
            // Make sure an institution email has been provided.
            // Ensure that the new ORCID information can be saved in the database as it doesn't violate any business rules, e.g. missing internal username.
            if (!BizRulesForCreation(person))
            {
                try
                {
                    person.HasError           = false;
                    person.PersonStatusTypeID = (int)failedStatus;
                    Edit(person, false);
                }
                catch
                {
                }
                return(false);
            }
            try
            {
                ProfilesRNSDLL.BLL.ORCID.PersonMessage        personMessageBLL        = new PersonMessage();
                ProfilesRNSDLL.BLL.ORCID.PersonOthername      personOthernameBLL      = new PersonOthername();
                ProfilesRNSDLL.BLL.ORCID.PersonAlternateEmail personAlternateEmailBLL = new PersonAlternateEmail();
                ProfilesRNSDLL.BLL.ORCID.PersonURL            personURLBLL            = new PersonURL();
                ProfilesRNSDLL.BLL.ORCID.PersonWork           personWorkBLL           = new PersonWork();
                ProfilesRNSDLL.BLL.ORCID.PersonAffiliation    personAffiliationBLL    = new PersonAffiliation();

                if (PostNewORCIDRequestToORCIDAPI(person, loggedInInternalUsername))
                {
                    // Save the person record (includes the narrative, aka biography, if one was provided).
                    person.PersonStatusTypeID = (int)ProfilesRNSDLL.BO.ORCID.REFPersonStatusType.REFPersonStatusTypes.ORCID_Created;
                    person.ORCIDRecorded      = DateTime.Now;
                    if (!Save(person))
                    {
                        person.Error += "The ORCID was created but a problem (person save failed) occurred while saving the data in the BU database. ";
                        return(false);
                    }
                    // Create a message to save what was sent to ORCID.
                    // Also mark the person with the person message ID
                    if (!personMessageBLL.CreatePersonMessage(person))
                    {
                        person.Error += "The ORCID was created but a problem (person message save failed) occurred while saving the data in the BU database. ";
                        return(false);
                    }
                    BLL.ORCID.PersonMessage.SetPersonMessageID(person);
                    // Save the other names
                    if (!personOthernameBLL.AddIfAny(person))
                    {
                        person.Error += "The ORCID was created but a problem (saving of other names failed) occurred while saving the data in the BU database. ";
                        return(false);
                    }
                    // Save the alternate email addresses
                    if (!personAlternateEmailBLL.AddIfAny(person))
                    {
                        person.Error += "The ORCID was created but a problem (saving of alternate emails failed) occurred while saving the data in the BU database. ";
                        return(false);
                    }
                    // Save the urls
                    if (!personURLBLL.AddIfAny(person))
                    {
                        person.Error += "The ORCID was created but a problem (saving of urls failed) occurred while saving the data in the BU database. ";
                        return(false);
                    }
                    // Save the works
                    if (!personWorkBLL.AddIfAny(person))
                    {
                        person.Error += "The ORCID was created but a problem (saving of works failed) occurred while saving the data in the BU database. ";
                        return(false);
                    }
                    // Save the works
                    if (!personAffiliationBLL.AddIfAny(person))
                    {
                        person.Error += "The ORCID was created but a problem (saving of affiliations failed) occurred while saving the data in the BU database. ";
                        return(false);
                    }
                    return(true);
                }
                else
                {
                    person.HasError           = false;
                    person.PersonStatusTypeID = (int)failedStatus;
                    try
                    {
                        Save(person, false);
                    }
                    catch (Exception ex)
                    {
                        throw BLL.ORCID.ErrorLog.LogError(ex, loggedInInternalUsername, "An error occurred while saving the fact that the batch push failed.");
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ErrorLog.LogError(ex, loggedInInternalUsername, "An error occurred while generating the messages to send to ORCID.");
            }
        }