private static DisclosureStatementViewModel DisclosureStatementFrom(DisclosureStatement source) { return(source == null ? new DisclosureStatementViewModel() : new DisclosureStatementViewModel { DeliveryType = source.DeliveryType, PageCount = source.PageCount, PostmarkDate = source.PostmarkDate, ReceivedDate = source.ReceivedDate.HasValue ? source.ReceivedDate.Value : DateTime.MinValue, Status = CPConvert.ToString(source.Status), StatusDate = source.StatusDate, SubmissionType = source.SubmissionType, IsSmallCampaign = source.SmallCampaign, Deferred = source.DeferredFiling, BackupDeliveryType = source.BackupDeliveryType, BackupPostmarkDate = source.BackupPostmarkDate, BackupReceivedDate = source.BackupReceivedDate, DataFormat = GetDataFormat(source) }); }
public IHttpActionResult GenerateDisclosureStatement(DisclosureStatement Param) { JSON returnJSON = new JSON(); Application app = new Application(); //object misValue = System.Reflection.Missing.Value; if (!File.Exists(ServerPathTempForms() + Param.FileName + ".docx")) { File.Copy(ServerPathFormsTemplate() + "Disclosure Statement.docx", ServerPathTempForms() + Param.FileName + ".docx"); Document doc = app.Documents.Open(ServerPathTempForms() + Param.FileName + ".docx"); Dictionary <string, string> bookmarks = new Dictionary <string, string> { //{ "NameOfBorrowerLessee", Param.LesseeBorrowerFirstName + " " + Param.LesseeBorrowerMiddleInitial + ". " + Param.LesseeBorrowerLastName + " " + Param.LesseeBorrowerSuffix }, { "BorrowerLessee", Param.BorrowerLessee }, { "Address", Param.Address }, { "MLANum", Param.MLA.ToString() }, { "LNANum", Param.LNA.ToString() }, { "STCLNum", Param.STCL.ToString() }, { "LSNum", Param.LS.ToString() }, { "PNNum", Param.PN.ToString() }, { "AmountToBeFinanced", Param.AmountToBeFinanced.ToString() }, }; FormToWord.ApplyDataToBookmark(bookmarks, doc); doc.Save(); //doc.SaveAs2(ServerPathTempForms() + Param.FileName + ".pdf", WdSaveFormat.wdFormatPDF); doc.Close(); app.Quit(); var response = ResponseMessage(Response(Param.FileName)); return(response); } else { return(Json(returnJSON)); } }
private static string GetDataFormat(DisclosureStatement statement) { if (statement == null) { return(null); } StringBuilder sb = new StringBuilder(); foreach (SubmissionFormat f in Enum.GetValues(typeof(SubmissionFormat))) { if (f == SubmissionFormat.None) { continue; } if (statement.SubmissionFormats.HasFlag(f)) { sb.AppendFormat(f.ToString <SubmissionFormat>()); sb.Append(", "); } } return(sb.ToString().Trim().Trim(',')); }
/// <summary> /// Generates an item in a list of certification submissions in a repeater control. /// </summary> /// <param name="container">A reference to the containing <see cref="RepeaterItem"/> control.</param> void BuildItemTemplate(Control container) { Table docSummary = new Table() { BorderWidth = 0, CellPadding = 0, CellSpacing = 0 }; Table format_Backup = new Table() { BorderWidth = 0, CellPadding = 0, CellSpacing = 0 }; Panel docPanel = new Panel() { CssClass = "docSummary" }; docPanel.Controls.Add(docSummary); container.Controls.Add(docPanel); Panel formatPanel = new Panel() { CssClass = "format-backup" }; formatPanel.Controls.Add(format_Backup); container.Controls.Add(formatPanel); // basic properties docSummary.DataBinding += (sender, e) => { DisclosureStatement item = (container as RepeaterItem).DataItem as DisclosureStatement; if (item == null) { return; } TableRow tr = new TableRow(); docSummary.Controls.Add(tr); tr.Controls.Add(new TableCell() { CssClass = "expander" }); tr.Controls.Add(new TableCell() { CssClass = "cp-ReceivedDate", Text = string.Format(Properties.Resources.DateFormat, item.ReceivedDate) }); tr.Controls.Add(new TableCell() { CssClass = "cp-SubmissionType", Text = _gridTemplate.GetSubmissionTypeText(item) }); tr.Controls.Add(new TableCell() { CssClass = "cp-Status", Text = CPConvert.ToString(item.Status) }); tr.Controls.Add(new TableCell() { CssClass = "cp-StatusAsOf", Text = string.Format(Properties.Resources.DateFormat, item.StatusDate) }); tr.Controls.Add(new TableCell() { CssClass = "cp-PageCount", Text = item.PageCount == 0 && item.SubmittedOnline ? "(n/a)" : item.PageCount.ToString() }); tr.Controls.Add(new TableCell() { CssClass = "cp-DeliveryType", Text = CPConvert.ToString(item.DeliveryType) }); tr.Controls.Add(new TableCell() { CssClass = "cp-SmallDeferred", Text = item.SmallCampaign ? "* Small Campaign" : item.DeferredFiling ? "* Deferred Filing" : null }); }; // additional properties format_Backup.DataBinding += (sender, e) => { // data format DisclosureStatement item = (container as RepeaterItem).DataItem as DisclosureStatement; if (item == null) { return; } StringBuilder sb = new StringBuilder(); bool multiFormat = false; sb.Append("<span class=\"label\">Submission Format:</span> "); foreach (SubmissionFormat f in Enum.GetValues(typeof(SubmissionFormat))) { if (f == SubmissionFormat.None) { continue; } if (item.SubmissionFormats.HasFlag(f)) { if (multiFormat) { sb.Append(", "); } sb.AppendFormat(f.ToString <SubmissionFormat>()); multiFormat = true; } } TableRow tr = new TableRow(); format_Backup.Controls.Add(tr); tr.Controls.Add(new TableCell() { CssClass = "cp-ReceivedDate" }); tr.Controls.Add(new TableCell() { CssClass = "cp-DataFormat", Text = sb.ToString(), ColumnSpan = 2 }); tr.Controls.Add(new TableCell() { CssClass = "cp-PostmarkDate", Text = item.PostmarkDate.HasValue ? "<span class=\"label\">Postmarked:</span> " + string.Format(Properties.Resources.DateFormat, item.PostmarkDate) : null }); // backup documentation if (item.BackupReceived) { tr = new TableRow() { CssClass = "cp-BackupDetails" }; format_Backup.Controls.Add(tr); tr.Controls.Add(new TableCell() { CssClass = "caption", Text = "Backup Documentation" }); tr.Controls.Add(new TableCell() { CssClass = "cp-ReceivedDate", Text = "<span class=\"label\"Received:</span> " + string.Format(Properties.Resources.DateFormat, item.BackupReceivedDate) }); tr.Controls.Add(new TableCell() { CssClass = "cp-DeliveryType", Text = "<span class=\"label\">Delivery Method:</span> " + CPConvert.ToString(item.BackupDeliveryType) }); tr.Controls.Add(new TableCell() { CssClass = "cp-PostmarkDate", Text = item.BackupPostmarkDate.HasValue ? "<span class=\"label\">Postmarked:</span> " + string.Format(Properties.Resources.DateFormat, item.BackupPostmarkDate) : null }); } }; }
/// <summary> /// Retrieves a generic collection of all filing disclosure statements on record for the specified candidate and election cycle. /// </summary> /// <param name="candidateID">The ID of the candidate whose filing disclosure statements are to be retrieved.</param> /// <param name="electionCycle">The election cycle in which to search.</param> /// <returns>A generic List collection of all filing disclosure statements on record for the specified candidate and election cycle.</returns> public DisclosureStatementHistories GetDisclosureStatements(string candidateID, string electionCycle) { using (DisclosureStatementTds ds = new DisclosureStatementTds()) { using (DisclosureStatementsTableAdapter ta = new DisclosureStatementsTableAdapter()) { ta.Fill(ds.DisclosureStatements, candidateID, electionCycle); } DisclosureStatementHistories dsh = new DisclosureStatementHistories(); var s = this.GetStatements(electionCycle); foreach (DisclosureStatementTds.DisclosureStatementsRow row in ds.DisclosureStatements.Rows) { char[] idArray = row.CommitteeID.Trim().ToCharArray(); if (idArray.Length == 0) { continue; } char id = idArray[0]; string committeeName = row.CommitteeName.Trim(); if (row.StatementNumber > byte.MaxValue) { continue; } byte statementNumber = Convert.ToByte(row.StatementNumber); if (object.Equals(s, null) || !s.ContainsKey(statementNumber)) { continue; } string key = DisclosureStatementHistories.ToKey(id, statementNumber); //if committee has not yet been encountered, add new name and statement number entries for it if (!dsh.CommitteeNames.ContainsKey(id)) { dsh.CommitteeNames.Add(id, committeeName); dsh.CommitteeStatements.Add(id, new Dictionary <byte, Statement>(Properties.Settings.Default.MaxStatementsPerCycle)); } //if statement has not yet been encountered, add new statement history var statements = dsh.CommitteeStatements[id]; if (!statements.ContainsKey(statementNumber)) { statements.Add(statementNumber, s[statementNumber]); dsh.Submissions[DisclosureStatementHistories.ToKey(id, statementNumber)] = new DisclosureStatementHistory(); } //fetch applicable dates and create a new DisclosureStatement object as appropriate DisclosureStatement dsDoc = new DisclosureStatement(s[statementNumber], row.Number, id, row.LastUpdated) { CommitteeName = committeeName, PageCount = row.PageCount, StatusReason = CPConvert.ToDocumentStatusReason(row.ReasonCode.Trim()), Status = CPConvert.ToDocumentStatus(row.StatusCode.Trim()), DeliveryType = CPConvert.ToDeliveryType(row.DeliveryCode.Trim()), SubmissionType = CPConvert.ToSubmissionType(row.SubmissionCode.Trim()), ReceivedDate = row.IsReceivedDateNull() ? null : row.ReceivedDate as DateTime?, StatusDate = row.IsStatusDateNull() ? null : row.StatusDate as DateTime?, PostmarkDate = row.IsPostmarkDateNull() ? null : row.PostmarkDate as DateTime?, IsAuditResponse = "Y".Equals(row.IsAuditResponse.Trim(), StringComparison.OrdinalIgnoreCase), ReceiptCompleteDate = row.IsReceiptCompleteDateNull() ? null : row.ReceiptCompleteDate as DateTime?, SmallCampaign = "Y".Equals(row.IsSmallCampaign.Trim(), StringComparison.OrdinalIgnoreCase), DeferredFiling = "Y".Equals(row.IsDeferredFiling.Trim(), StringComparison.OrdinalIgnoreCase) }; // submission formats if ("Y".Equals(row.IsCsmartWeb.Trim(), StringComparison.OrdinalIgnoreCase)) { dsDoc.SubmissionFormats |= SubmissionFormat.CsmartWeb; } else if ("Y".Equals(row.IsInternet.Trim(), StringComparison.OrdinalIgnoreCase)) { dsDoc.SubmissionFormats |= SubmissionFormat.IDS; } else { if ("Y".Equals(row.IsCD.Trim(), StringComparison.OrdinalIgnoreCase)) { dsDoc.SubmissionFormats |= SubmissionFormat.CD; } if ("Y".Equals(row.IsFloppy.Trim(), StringComparison.OrdinalIgnoreCase)) { dsDoc.SubmissionFormats |= SubmissionFormat.FloppyDisk; } if ("Y".Equals(row.IsPaper.Trim(), StringComparison.OrdinalIgnoreCase)) { dsDoc.SubmissionFormats |= dsDoc.DeliveryType == DeliveryType.Internet ? SubmissionFormat.ElectronicDocument : SubmissionFormat.Paper; } } // backup info if (!row.IsBackupReceivedDateNull()) { dsDoc.BackupDeliveryType = CPConvert.ToDeliveryType(row.BackupDeliveryType.Trim()); dsDoc.BackupReceivedDate = row.BackupReceivedDate; if (!row.IsBackupPostmarkDateNull()) { dsDoc.BackupPostmarkDate = row.BackupPostmarkDate; } } //add new DisclosureStatement object to appropriate statement history collection dsh.Submissions[DisclosureStatementHistories.ToKey(id, statementNumber)].Documents.Add(dsDoc); } return(dsh); } }