public string Build(Statute model) { StringBuilder builder = new StringBuilder(); int indent = 0; builder.AppendLine(String.Format(RTF_HEADER, FontName).Replace("[", "{").Replace("]", "}")); foreach (var para in Paragraphs) { builder.AppendLine(String.Format(HEADER_FORMAT, RtfEscape(BuildText(model, para.Header), out indent), indent, FontSizeHeader)); foreach (var line in para.Body) { builder.AppendLine(String.Format(CLAUSE_FORMAT, RtfEscape(line, out indent), indent, FontSize)); } } for (int i = 0; i < model.GeneralInformation.FounderCount; i++) { string name = model.GeneralInformation.FounderNames[i]; builder.AppendLine(String.Format(SIGNING_LINE, RtfEscape(name, out indent))); } builder.AppendLine("}"); return(builder.ToString()); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "delete", Route = "DeleteStatute/{Id}")] HttpRequest req, int Id, [Table("Statutes", Connection = "RipaStorage")] CloudTable statutes, ILogger log) { try { if (!RIPAAuthorization.ValidateAdministratorRole(req, log).ConfigureAwait(false).GetAwaiter().GetResult()) { return(new UnauthorizedResult()); } } catch (Exception ex) { log.LogError(ex.Message); return(new UnauthorizedResult()); } try { Statute statute = new Statute { PartitionKey = "CA", RowKey = Id.ToString(), OffenseCode = Id, ETag = "*" }; TableOperation deleteOperation = TableOperation.Delete(statute); TableResult result = await statutes.ExecuteAsync(deleteOperation); return(new OkObjectResult(result)); } catch { return(new BadRequestObjectResult("Statute Offense Code not found")); } }
public static Statute GetStatute(DataRow row) { Statute statute = new Statute { ETag = "*", PartitionKey = "CA", OffenseValidationCD = Convert.ToInt32(row.ItemArray[0]), RowKey = row.ItemArray[1].ToString(), OffenseCode = Convert.ToInt32(row.ItemArray[1]), OffenseTxnTypeCD = Convert.ToInt32(row.ItemArray[2].ToString()), OffenseStatute = row.ItemArray[3].ToString(), OffenseTypeOfStatuteCD = row.ItemArray[4].ToString(), StatuteLiteral = row.ItemArray[5].ToString(), OffenseDefaultTypeOfCharge = row.ItemArray[6].ToString(), OffenseTypeOfCharge = row.ItemArray[7].ToString(), OffenseLiteralIdentifierCD = row.ItemArray[8].ToString() }; statute.OffenseDegree = String.IsNullOrEmpty(row.ItemArray[9].ToString()) ? null : statute.OffenseDegree = Convert.ToInt32(row.ItemArray[9].ToString()); statute.BCSHierarchyCD = String.IsNullOrEmpty(row.ItemArray[10].ToString()) ? null : statute.BCSHierarchyCD = Convert.ToInt32(row.ItemArray[10].ToString()); string offenseEnacted = row.ItemArray[11].ToString(); if (!string.IsNullOrEmpty(offenseEnacted)) { if (offenseEnacted.Length == 8) { statute.OffenseEnacted = DateTime.ParseExact(offenseEnacted, "yyyyMMdd", CultureInfo.InvariantCulture); } else { statute.OffenseEnacted = DateTime.Parse(offenseEnacted); } } string offenseRepealed = row.ItemArray[12].ToString(); if (!string.IsNullOrEmpty(offenseRepealed)) { if (offenseEnacted.Length == 8) { statute.OffenseRepealed = DateTime.ParseExact(offenseRepealed, "yyyyMMdd", CultureInfo.InvariantCulture); } else { statute.OffenseRepealed = DateTime.Parse(offenseRepealed); } } statute.ALPSCognizantCD = row.ItemArray[13].ToString(); return(statute); }
public IActionResult Statute(Statute model, string handler) { var doc = new TextGeneration.Document { FontName = "Verdana", FontSize = 16 }; for (int i = 1; i <= 12; i++) { var paragraphInfo = Program.ReadJson <TextGeneration.Data.Paragraph>(Program.GetParagraphResourceFileName(i)); doc.Paragraphs.Add(paragraphInfo.BuildDocumentParagraph(model)); } byte[] result; string docText = doc.Build(model); result = System.Text.Encoding.ASCII.GetBytes(docText); return(File(result, "application/rtf", "satzung.rtf", true)); }
/// <remarks> /// All models need to have "model" in their variable name /// </remarks> public IActionResult Index(Statute model, string handler, GeneralInformation generalModel) { if (generalModel != null) { model.GeneralInformation = generalModel; } if (handler == "findPurpose") { model.PurposeInformation.FindPurpose(); } else if (handler == "finalSubmit") { var doc = new TextGeneration.Document { FontName = "Verdana", FontSize = 22, FontSizeHeader = 24 }; foreach (string paragraphFileName in Program.GetParagraphResources()) { var paragraphInfo = Program.ReadJson <TextGeneration.Data.Paragraph>(paragraphFileName); doc.Paragraphs.Add(paragraphInfo.BuildDocumentParagraph(model)); } byte[] result; result = System.Text.Encoding.ASCII.GetBytes(doc.Build(model)); return(File(result, "application/rtf", $"Satzung - {model.GeneralInformation.ClubName}.rtf", true)); } return(View(model)); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "Put", Route = "PutStatute/{Id}")] Statute statute, HttpRequest req, int Id, [Table("Statutes", Connection = "RipaStorage")] CloudTable statutes, ILogger log) { try { if (!RIPAAuthorization.ValidateAdministratorRole(req, log).ConfigureAwait(false).GetAwaiter().GetResult()) { return(new UnauthorizedResult()); } } catch (Exception ex) { log.LogError(ex.Message); return(new UnauthorizedResult()); } try { if (statute.OffenseCode == 0) { throw new Exception("Offense Code Must be type Integer and is required"); } statute.PartitionKey = "CA"; statute.RowKey = Id.ToString(); statute.OffenseCode = Id; statute.ETag = "*"; TableOperation createOperation = TableOperation.InsertOrReplace(statute); TableResult result = await statutes.ExecuteAsync(createOperation); return(new OkObjectResult(result)); } catch { return(new BadRequestObjectResult("Statute failed on insert or replace")); } }
private Charge CreateNewCharge(JustWareApiClient api, XElement chargeXml) { var chargeValues = GetChildValues(chargeXml); Charge charge = new Charge(); charge.Operation = OperationType.Insert; string query = String.Format("Code = \"{0}\"", chargeValues["Code"]); Statute statute = api.FindStatutes(query, null).FirstOrDefault(); if (statute != null) { charge.StatuteID = statute.ID; } else { MessageBox.Show("Statue with code " + chargeValues["Code"] + " not found"); return(null); } charge.ChargeNumber = short.Parse(chargeValues["ChargeNumber"]); charge.Date = DateTime.Parse(chargeValues["Occurred"]); charge.Notes = chargeValues["OfficerNotes"]; return(charge); }