Ejemplo n.º 1
0
 public ProcessLogObject SaveProcessLog(ProcessLogObject processLog)
 {
     if (processLog.ProcessLogId > 0) // Update
     {
         string sql = @"
             UPDATE  dat_ProcessLog
             SET     SortMainId = @SortMainId,
                     Result = @Result,
                     ResultDesc = @ResultDesc
             WHERE   ProcessLogId = @ProcessLogId";
         Config.Conn.Execute(sql, processLog);
     }
     else
     {
         string sql = @"
             INSERT INTO dat_ProcessLog (
                 SortMainId,
                 Result,
                 ResultDesc
             )
             VALUES (
                 @SortMainId,
                 @Result,
                 @ResultDesc
             )
             SELECT CAST(SCOPE_IDENTITY() AS INT)";
         processLog.ProcessLogId = Config.Conn.Query <int>(sql, processLog).Single();
     }
     return(processLog);
 }
Ejemplo n.º 2
0
        public static void Add(int?sortMainId, string log, string desc)
        {
            var o = new ProcessLogObject();

            o.SortMainId = sortMainId;
            o.Result     = log;
            o.ResultDesc = desc;
            o.Save();
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
 public static void Add(string log, string desc)
 {
     ProcessLogObject.Add(null, log, desc);
 }
Ejemplo n.º 5
0
 public static void Add(int?sortMainId, string log)
 {
     ProcessLogObject.Add(sortMainId, log, String.Empty);
 }
Ejemplo n.º 6
0
 public static void Add(string log)
 {
     ProcessLogObject.Add(null, log, String.Empty);
 }