public static void Add(int sortMainId, string employeeId, string contactType) { ContactObject co = new ContactObject(); co.SortMainId = sortMainId; co.ContactType = contactType; if (co.SetNames(employeeId)) { co.Save(); } }
public bool DeleteContact(ContactObject contact) { try { Config.Conn.Execute("DELETE FROM dat_Contact WHERE ContactId = @ContactId", contact); } catch (Exception ex) { ErrorLogObject.LogError("ContactObject::IsValid", ex); return(false); } return(true); }
public ContactObject SaveContact(ContactObject contact) { if (contact.ContactId > 0) // Update { string sql = @" UPDATE dat_Contact SET SortMainId = @SortMainId, FirstName = @FirstName, MiddleName = @MiddleName, LastName = @LastName, ContactType = @ContactType, Phone = @Phone, EmployeeId = @EmployeeId, WorkOrg = @WorkOrg WHERE ContactId = @ContactId"; Config.Conn.Execute(sql, contact); } else { string sql = @" INSERT INTO dat_Contact ( SortMainId, FirstName, MiddleName, LastName, ContactType, Phone, EmployeeId, WorkOrg ) VALUES ( @SortMainId, @FirstName, @MiddleName, @LastName, @ContactType, @Phone, @EmployeeId, @WorkOrg ) SELECT CAST(SCOPE_IDENTITY() AS INT)"; contact.ContactId = Config.Conn.Query <int>(sql, contact).Single(); } return(contact); }
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); }