示例#1
0
        public static void Add(int?authorId, int sortMainId, string employeeId, string name, AffiliationEnum affiliationType, string affiliation, string orcidId, bool isPrimary, int?countryId, int?stateId)
        {
            AuthorObject ao = new AuthorObject();

            if (authorId.HasValue)
            {
                ao = AuthorObject.GetAuthor(authorId.Value);
            }
            ao.SortMainId      = sortMainId;
            ao.Affiliation     = affiliation;
            ao.OrcidId         = orcidId;
            ao.EmployeeId      = employeeId;
            ao.AffiliationEnum = affiliationType;
            ao.SetName(name, affiliationType, employeeId);
            if (affiliationType != AffiliationEnum.INL)
            {
                ao.CountryId = countryId;
                if (countryId.HasValue && countryId.Value == Helper.UnitedStatesCountryId)
                {
                    ao.StateId = stateId;
                }
            }
            ao.Save();
            if (isPrimary)
            {
                ao.SetAsPrimary();
            }
        }
示例#2
0
        public int?Import()
        {
            int?sortId = null;

            var sort = new SortMainObject();

            sort.StatusEnum   = StatusEnum.Imported;
            sort.SharePointId = LrsId;
            sort.Title        = $"{StiNumber}-Revision-{Revision}";
            sort.StiNumber    = StiNumber;
            sort.Revision     = Revision;

            sort.PublishTitle        = Title;
            sort.Abstract            = Abstract;
            sort.JournalName         = JournalName;
            sort.ConferenceName      = ConferenceName;
            sort.ConferenceSponsor   = ConferenceSponsor;
            sort.ConferenceLocation  = ConferenceLocation;
            sort.ConferenceBeginDate = ConferenceBeginDate;
            sort.ConferenceEndDate   = ConferenceEndDate;

            sort.OwnerName       = OwnerName ?? EmployeeCache.GetName(OwnerEmployeeId);
            sort.OwnerEmployeeId = OwnerEmployeeId;
            sort.CreateDate      = CreateDate;
            sort.ModifiedDate    = ModifiedDate;
            sort.ApprovedDate    = ApprovedDate;
            sort.RelatedSti      = RelatedSti;
            if (sort.ApprovedDate.HasValue && sort.ApprovedDate.Value > new DateTime(2000, 1, 1))
            {
                sort.DueDate = sort.ApprovedDate.Value.AddMonths(1);
            }

            sort.ReviewStatus         = ReviewStatus;
            sort.ReviewProgress       = ReviewProgress;
            sort.AccessLimitationEnum = AccessLimitationEnum.Unlimited; //Default to Unlimited
            sort.Country   = "US";
            sort.Language  = "English";
            sort.IsFromLrs = true;
            if (!string.IsNullOrWhiteSpace(sort.OwnerEmployeeId) || !string.IsNullOrWhiteSpace(sort.OwnerName))
            {
                sort.Save();
                sortId = sort.SortMainId;
                ProcessLogObject.Add(sort.SortMainId, "Added Entry");
                if (Contacts != null)
                {
                    foreach (var contact in Contacts)
                    {
                        var cont = new ContactObject();
                        cont.SortMainId      = sort.SortMainId.Value;
                        cont.FirstName       = contact.FirstName ?? EmployeeCache.GetEmployee(contact.EmployeeId)?.FirstName;
                        cont.MiddleName      = contact.MiddleName ?? EmployeeCache.GetEmployee(contact.EmployeeId)?.MiddleName;
                        cont.LastName        = contact.LastName ?? EmployeeCache.GetEmployee(contact.EmployeeId)?.LastName;
                        cont.ContactTypeEnum = ContactTypeEnum.POC;
                        cont.Phone           = contact.Phone ?? EmployeeCache.GetEmployee(contact.EmployeeId)?.PhoneNumber;
                        cont.EmployeeId      = contact.EmployeeId;
                        cont.WorkOrg         = contact.WorkOrg;
                        //cont.OrcidId = contact.OrcidId;
                        cont.Save();
                        ProcessLogObject.Add(sort.SortMainId, "Added Contact");
                    }
                }

                if (Authors != null)
                {
                    foreach (var author in Authors)
                    {
                        var auth = new AuthorObject();
                        auth.SharePointId = author.AuthorId;
                        auth.SortMainId   = sort.SortMainId.Value;
                        auth.FirstName    = author.FirstName;
                        auth.MiddleName   = author.MiddleName;
                        auth.LastName     = author.LastName;
                        auth.Affiliation  = author.Affiliation;
                        switch (author.AffiliationType)
                        {
                        case "INL":
                            auth.AffiliationEnum = AffiliationEnum.INL;
                            auth.Affiliation     = "Idaho National Laboratory";
                            break;

                        case "University":
                            auth.AffiliationEnum = AffiliationEnum.University;
                            break;

                        default:
                            auth.AffiliationEnum = AffiliationEnum.Other;
                            break;
                        }

                        auth.Email      = author.Email;
                        auth.OrcidId    = author.OrcidId;
                        auth.IsPrimary  = author.IsPrimary;
                        auth.EmployeeId = author.EmployeeId;
                        auth.WorkOrg    = author.WorkOrg;
                        auth.CountryId  = MemoryCache.GetCountryByCode(author.CountryCode)?.CountryId;
                        auth.StateId    = MemoryCache.GetStateByShortName(author.StateCode)?.StateId;
                        auth.Save();
                        ProcessLogObject.Add(sort.SortMainId, "Added Author");
                    }
                }

                if (Fundings != null)
                {
                    foreach (var funding in Fundings)
                    {
                        var fund = new FundingObject();
                        fund.SortMainId              = sort.SortMainId.Value;
                        fund.Year                    = funding.Year;
                        fund.FundingTypeId           = funding.FundingTypeId;
                        fund.Org                     = funding.Org;
                        fund.ContractNumber          = funding.ContractNumber;
                        fund.Percent                 = funding.Percent;
                        fund.DoeFundingCategoryId    = funding.DoeFundingCategoryId;
                        fund.GrantNumber             = funding.GrantNumber;
                        fund.TrackingNumber          = funding.TrackingNumber;
                        fund.SppCategoryId           = funding.SppCategoryId;
                        fund.SppApproved             = funding.SppApproved;
                        fund.FederalAgencyId         = funding.FederalAgencyId;
                        fund.ApproveNoReason         = funding.ApproveNoReason;
                        fund.OtherDescription        = funding.OtherDescription;
                        fund.CountryId               = funding.CountryId;
                        fund.AdditionalInfo          = funding.AdditionalInfo;
                        fund.ProjectArea             = funding.ProjectArea;
                        fund.ProjectNumber           = funding.ProjectNumber;
                        fund.PrincipalInvEmployeeId  = funding.PrincipalInvEmployeeId;
                        fund.MilestoneTrackingNumber = funding.MilestoneTrackingNumber;

                        try
                        {
                            fund.Save();
                            ProcessLogObject.Add(sort.SortMainId, "Added Funding Type");
                        }
                        catch (Exception ex)
                        {
                            ErrorLogObject.LogError("Console:ImportFromSharepoint:FundingSave", ex);
                        }
                    }
                }

                if (Subjects != null)
                {
                    foreach (var subject in Subjects)
                    {
                        SortMetaDataObject.AddNew(MetaDataTypeEnum.SubjectCategories, sort.SortMainId.Value, subject);
                        ProcessLogObject.Add(sort.SortMainId, "Added subject Metadata");
                    }
                }

                if (Keywords != null)
                {
                    foreach (var keyword in Keywords)
                    {
                        SortMetaDataObject.AddNew(MetaDataTypeEnum.Keywords, sort.SortMainId.Value, keyword);
                        ProcessLogObject.Add(sort.SortMainId, "Added Keyword Metadata");
                    }
                }

                if (CoreCapabilities != null)
                {
                    foreach (var core in CoreCapabilities)
                    {
                        SortMetaDataObject.AddNew(MetaDataTypeEnum.CoreCapabilities, sort.SortMainId.Value, core);
                        ProcessLogObject.Add(sort.SortMainId, "Added Core Capability Metadata");
                    }
                }

                if (Reviewers != null)
                {
                    foreach (var reviewer in Reviewers)
                    {
                        try
                        {
                            ReviewObject review = new ReviewObject();
                            review.SortMainId = sort.SortMainId.Value;
                            switch (reviewer.ReviewerType)
                            {
                            case "Manager":
                                review.ReviewerTypeEnum = ReviewerTypeEnum.Manager;
                                break;

                            case "Classification":
                                review.ReviewerTypeEnum = ReviewerTypeEnum.Classification;
                                break;

                            case "ExportControl":
                                review.ReviewerTypeEnum = ReviewerTypeEnum.ExportControl;
                                break;

                            case "TechDeployment":
                                review.ReviewerTypeEnum = ReviewerTypeEnum.TechDeployment;
                                break;

                            case "PeerTechnical":
                                review.ReviewerTypeEnum = ReviewerTypeEnum.PeerTechnical;
                                break;
                            }

                            review.Reviewer             = reviewer.ReviewerName ?? EmployeeCache.GetName(reviewer.ReviewerEmployeeId) ?? "Unknown";
                            reviewer.ReviewerEmployeeId = reviewer.ReviewerEmployeeId;
                            review.ReviewDate           = reviewer.ReviewDate;
                            review.Approval             = reviewer.Status;
                            review.Save();
                        }
                        catch (Exception ex)
                        {
                            ErrorLogObject.LogError("Console:ProcessReviewers", ex);
                        }
                    }
                }

                Email.SendEmail(sort, EmailTypeEnum.Initial, true);
                ProcessLogObject.Add(sort.SortMainId, "Email Sent");
                ProcessLogObject.Add(sort.SortMainId, "Success");
            }

            return(sortId);
        }