public Guid SaveQuoteSheetToDMS(QuoteSheet quoteSheet, byte[] reportBytes, Submission submission, bool isDeclinature) { var fileId = Guid.Empty.ToString(); // TODO: Exception handling using (var dmsService = new DMSService()) { fileId = dmsService.FNUploadDocument(quoteSheet.Title + ".pdf", quoteSheet.Title, reportBytes, quoteSheet.DocumentClass, quoteSheet.ObjectStore); dmsService.FNUpdateDocumentProperties(fileId, quoteSheet.ObjectStore, quoteSheet.ObjectStore, this.SetFileNetProperties(quoteSheet, submission, isDeclinature)); } return(new Guid(fileId)); }
// TODO: Don't we need know which quote is generating the quotesheet? private FileNetProperty[] SetFileNetProperties(QuoteSheet quoteSheet, Submission submission, bool isDeclinature) { var quotes = submission.Options.Select(s => s) .SelectMany(o => o.OptionVersions) .SelectMany(ov => ov.Quotes) .Where(q => q.IsSubscribeMaster) .ToList(); var mainQuote = quotes.FirstOrDefault(); // TODO: For the moment, we will use the first quote we come across var subscribeReferences = quotes.Select(q => q.SubscribeReference) .Aggregate(string.Empty, (current, sr) => current + (sr + ";")); var currentDateTime = DateTime.Now; var businessPlanList = string.Empty; using (var subscribeService = new PolicyDataService.PolicyServiceClient()) { businessPlanList = quotes.Select(q => q.SubscribeReference) .Select(subscribeService.GetPolicyBPC) .Aggregate(businessPlanList, (current, pd) => current + (pd.BPC + " - " + pd.Description + ";")); } var properties = new List <FileNetProperty> { /* Base Document Properties * * Mandatory; * - DocumentTitle (String) * * Optional; * - Description (String) */ //new FileNetProperty { Key = "DocumentTitle", Value = "Quote sheet" }, new FileNetProperty { Key = "DocumentTitle", Value = isDeclinature ? Settings.Default["DeclinatureDocTitle"].ToString() : Settings.Default["QuoteDocTitle"].ToString() }, // new FileNetProperty {Key = "Description", Value = "Quote sheet description"}, /* Underwriting Document Properties * * Mandatory; * - uwPolicyID (ListOfString): List of Subscribe references delimited by semi-colon. * - uwBusinessPlan (ListOfString): List of business plans delimited by semi-colon. * - uwDocType (String): Document type. * - uwInsuredName (String): Insured name. * - uwCOB (String): Class of business code. * - uwUnderwriter (String): Underwriter pseudonym. * - uwBrokerPSU (String): Broker pseudonym. * - uwInceptionDate (Date): Inception date. * - uwAccountingYear (Integer): Accounting year. * - uwStatus (String): Status, which is always "QUOTE" at this stage. * - uwEntryStatus (String): Entry status, which is either "PARTIAL" or "NTU" at this stage. * * Optional; * - PolicyIDSP (String): List of Subscribe references delimited by semi-colon. * - BusinessPlanSP (String): List of business plans delimited by semi-colon. * - uwWrittenDate (Date): Written date. * - AccountingYearFloat (Float): Accounting year. * * Note 1: * FileNet has two fields for each Policy ID and Business Plan. One field is a String data-type * and the other (the primary field) is a ListOfString. For consistency, both of the values should be * the same with the exception that the ListOfString will be parsed by the web service into an array * by a specified delimiter (this was a quick-fix on the web service). * * In order to pass back a ListOfString value to the FileNet web service, a delimited string should * be passed with the delimiter specified in the Delimiter property of the FileNetProperty class. * * Note 2: * The values for the document type must exist in the FileNet document type choice list or it will * throw back an error. * * Note 3: * FileNet has two fields for accounting year. One field is a Float data-type and the other is an * Integer. For consistency, both of the values should be the same. */ new FileNetProperty { Key = "uwPolicyID", Value = subscribeReferences, Delimiter = ";" }, new FileNetProperty { Key = "PolicyIDSP", Value = subscribeReferences }, new FileNetProperty { Key = "uwBusinessPlan", Value = businessPlanList, Delimiter = ";" }, new FileNetProperty { Key = "BusinessPlanSP", Value = businessPlanList }, new FileNetProperty { Key = "uwDocType", Value = isDeclinature ? Settings.Default["DeclinatureDocType"].ToString() : "Quote" }, //new FileNetProperty { Key = "uwInsuredName", Value = submission.InsuredName },//TODO: S2Q new FileNetProperty { Key = "uwCOB", Value = mainQuote.COBId }, //new FileNetProperty { Key = "uwUnderwriter", Value = submission.UnderwriterContactCode },//TODO: S2Q //new FileNetProperty { Key = "uwBrokerPSU", Value = submission.BrokerPseudonym },//TODO: S2Q new FileNetProperty { Key = "uwAccountingYear", Value = mainQuote.AccountYear }, new FileNetProperty { Key = "uwStatus", Value = "QUOTE" }, new FileNetProperty { Key = "uwEntryStatus", Value = mainQuote.EntryStatus }, /* Other Custom Document Properties * * Mandatory; * - uwInputDeviceID (String): The system that uploaded the document ("Console"). The other entry * points are Kofax, Worflow (via Web Services) and SharePoint (via ICC). This is to help * administrators understand the origins of the document. * - uwIndexPerson (String): Login name of the user that uploaded the document. * - uwLoadToDMSDateAndTime (Date): Upload date. * - uwOpsInfo (String): Delimited string of workflow status flags, which is always * "Aggs=0;FacRI=0;Group=0;BPQARequired=0;PTradeFile=0;S2000=0;PreBind=0;PostBind=0;ReSign=0;t&cChange=0;UrgentCase=0;ForeignLanguage=0" * at this stage. * * Optional; * - uwIndexDateTime (Date): Upload date. * - strLoadToDMSDateAndTime (String): Upload date-time string in the format of "dd/MM/yyyy HH:mm". * - WSTriggerStatus (String): Workflow initiation status flag used by FileNet, which is always * "INVALID" at this stage. */ new FileNetProperty { Key = "uwInputDeviceID", Value = "Console" }, new FileNetProperty { Key = "uwIndexPerson", Value = quoteSheet.IssuedBy.DomainLogon }, // TODO: Is this the current user? new FileNetProperty { Key = "uwIndexDateTime", Value = currentDateTime }, new FileNetProperty { Key = "uwLoadToDMSDateAndTime", Value = currentDateTime }, new FileNetProperty { Key = "strLoadToDMSDateAndTime", Value = currentDateTime.ToString("dd/MM/yyyy HH:mm") }, new FileNetProperty { Key = "WSTriggerStatus", Value = "INVALID" }, new FileNetProperty { Key = "uwOpsInfo", Value = "Aggs=0;FacRI=0;Group=0;BPQARequired=0;PTradeFile=0;S2000=0;PreBind=0;PostBind=0;ReSign=0;t&cChange=0;UrgentCase=0;ForeignLanguage=0" } }; if (mainQuote.InceptionDate != null) { properties.Add(new FileNetProperty { Key = "uwInceptionDate", Value = mainQuote.InceptionDate.GetValueOrDefault() }); } return(properties.ToArray()); }
public string CreateQuoteSheet(CreateQuoteSheetDto dto, out Submission submission) { // TODO: use the correct quote sheet... var quoteSheetTemplateId = dto.QuoteSheetTemplateId; dto.QuoteSheetTemplateUrl = this.ConsoleRepository.Query <QuoteTemplate>() .FirstOrDefault(qt => qt.Id == dto.QuoteSheetTemplateId).RdlPath; dto.QuoteSheetTemplateName = this.ConsoleRepository.Query <QuoteTemplate>() .FirstOrDefault(qt => qt.Id == dto.QuoteSheetTemplateId).Name; submission = this.SubmissionModule.GetSubmissionById(dto.SubmissionId); //todo this is done to clear previous context. has to be fixed once softdelet is fixed. using (IConsoleRepository consoleRepository = new ConsoleRepository()) { if (submission == null) { throw new KeyNotFoundException(string.Format(this.NotFoundMessage, dto.SubmissionId)); } consoleRepository.Attach(submission); var currentUser = consoleRepository.Query <User>() .FirstOrDefault(u => u.DomainLogon == this.HttpContext.CurrentUser.Identity.Name); if (currentUser == null) { throw new ApplicationException("Current user could not be found"); } var versions = (from version in submission.Options.SelectMany(o => o.OptionVersions) from option in dto.OptionList where version.OptionId == option.OptionId from versionNumber in option.OptionVersionNumberList where version.VersionNumber == versionNumber select version).ToList(); var isDeclinature = false; var submSt = submission.Options.Select(s => s) .SelectMany(o => o.OptionVersions) .SelectMany(ov => ov.Quotes) .Where(q => q.IsSubscribeMaster).Select(s => s.SubmissionStatus).Distinct().ToList(); if ((submSt.Count == 1) && (submSt.FirstOrDefault().Equals(Settings.Default["DeclinatureSubmissionStatus"].ToString()))) { isDeclinature = true; } var quotesheet = new QuoteSheet {//Todo: S2Q Title = string.Format(this.QuoteSheetTitle, submission.Title, versions.SelectMany(ov => ov.Quotes).First().InsuredName, DateTime.Now), IssuedBy = currentUser, IssuedById = currentUser.Id, IssuedDate = DateTime.Now, ObjectStore = Settings.Default["DMSObjectStore"].ToString(), DocumentClass = Settings.Default["DMSDocumentClass"].ToString(), DocumentType = isDeclinature ? Settings.Default["DeclinatureDocType"].ToString() : Settings.Default["QuoteDocType"].ToString() }; var content = this.QuoteSheetData.CreateQuoteSheetPdf(dto, isDeclinature); quotesheet.Guid = this.QuoteSheetData.SaveQuoteSheetToDMS(quotesheet, content, submission, isDeclinature); quotesheet.OptionVersions = versions; if (!isDeclinature) { foreach (var quote in versions.SelectMany(ov => ov.Quotes)) { if (!quote.SubmissionStatus.Equals(Settings.Default["DeclinatureSubmissionStatus"].ToString())) { quote.OptionVersion.IsLocked = true; quote.SubmissionStatus = "QUOTED"; } } } consoleRepository.Add(quotesheet); consoleRepository.SaveChanges(); return(string.Format(this.QuoteSheetUrl, ConfigurationManager.AppSettings["UWDmsFileDownloadURL"], quotesheet.Guid)); } }