/// <summary> /// Capability to render a duty overview /// to PDF and HTML /// </summary> internal override void RenderBodyInternal(HtmlTemplateEngine sink) { /* render the object header (which can be org or pers) */ RenderObjectHeader(sink); /* render one section per category (same for all kinds of "host objects") */ var section = HtmlTemplateEngine.LoadTemplate("hardcopy_dutyoverview-2categorysection.ent", m); var categories = Data.Tables[ReportDatatableIdentifiers.REPORT_DATATABLE_HARDCOPY_DUTYOVW_CATEGORIES]; foreach (DataRow dr in categories.Rows) { /* set the section caption */ section.Set("category", dr["Category"].ToString()); var description = dr["Description"].ToString(); if (String.IsNullOrWhiteSpace(description)) { section.Set("description_commentstart", Html.cstHTMLCommentStart); section.Set("description_commentend", Html.cstHTMLCommentEnd); } else { section.Set("description", description); } /* populate the section's dutycall table */ var duties = Data.Tables[ReportDatatableIdentifiers.REPORT_DATATABLE_HARDCOPY_DUTYOVW_DUTIES]; var list = new DutRows(); foreach (DataRow dut in duties.Rows) { /* does this belong in this section? */ bool matches_cat = false; if (dut["CatID"].Equals(DBNull.Value) && dr["CatID"].Equals(DBNull.Value)) { matches_cat = true; } else if (dut["CatID"].Equals(DBNull.Value) == false && dr["CatID"].Equals(DBNull.Value) == false && Convert.ToInt32(dut["CatID"]) == Convert.ToInt32(dr["CatID"])) { matches_cat = true; } /* yep. */ if (matches_cat) { var item = new DutRow(dut, m); list.Add(item, LCID); } } section.Set("dutyitems", list.ToString(LCID)); /* this category section including its table is done, then */ sink.SubmitPart(section.AsStringBuilder); } }
protected internal override void RenderObjectHeader(HtmlTemplateEngine sink) { /* get data */ var dt = Data.Tables[ReportDatatableIdentifiers.REPORT_DATATABLE_HARDCOPY_DUTYOVW_ORG].Rows[0]; /* load the template */ var s = HtmlTemplateEngine.LoadTemplate("hardcopy_dutyoverview-1orgunit.ent", m); /* populate it fully */ s.Set("orgunit", dt["fOrgCap"].ToString()); s.Set("parentorgunit", dt["fParentOrgCap"].ToString()); s.Set("metaorg", dt["fMetaOrgCap"].ToString()); s.Set("iscentral", dt["fIsCentral"].ToString()); s.Set("costcenters", dt["fCostcenters"].ToString()); s.Set("orgdescription", dt["fDescription"].ToString()); /* commit */ sink.SubmitPart(s.AsStringBuilder); }
protected internal override void RenderObjectHeader(HtmlTemplateEngine sink) { /* get data */ var dt = Data.Tables[ReportDatatableIdentifiers.REPORT_DATATABLE_HARDCOPY_DUTYOVW_PER].Rows[0]; /* load the template */ var s = HtmlTemplateEngine.LoadTemplate("hardcopy_dutyoverview-1employee.ent", m); /* populate it fully */ s.Set("employeename", dt["fEmployeeName"].ToString()); s.Set("employeestatus", dt["fEmployeeStatus"].ToString()); s.Set("persnr", dt["PersNr"].ToString()); s.Set("employeefunction", dt["fEmployeeFunction"].ToString()); s.Set("orgcap", dt["fOrgCap"].ToString()); s.Set("shift", dt["Shift"].ToString()); /* commit */ sink.SubmitPart(s.AsStringBuilder); }
/// <summary> /// Capability to render the body of a safety incident report placard to /// PDF and HTML /// </summary> internal override void RenderBodyInternal(HtmlTemplateEngine sink) { /* get data */ var dt = Data.Tables[ReportDatatableIdentifiers.REPORT_DATATABLE_HARDCOPY_SAFETYALERT].Rows[0]; /* load the incident report body template */ var s = HtmlTemplateEngine.LoadTemplate("hardcopy_safetyalert.ent", m); /* populate it fully */ s.Set("nrcomposite", dt["NrComposite"].ToString()); s.Set("partnerinvolved", dt["fPartnerInvolved"].ToString()); s.Set("cat_abbrev", dt["CatAbbrev"].ToString()); s.Set("cat_caption", dt["CatCaption"].ToString()); if (Convert.ToInt32(dt["CompanyInfoVisible"]) == 1) { s.Set("companyinfo_visible", "blendin"); s.Set("ccompany", dt["Companyname"].ToString()); s.Set("cbusiness", dt["CompanyBusiness"].ToString()); s.Set("cplant", dt["CompanyPlant"].ToString()); } else { s.Set("companyinfo_visible", "blendout"); } if (Convert.ToInt32(dt["CompanyLogoVisible"]) == 1) { s.Set("companylogo_visible", "blendin"); s.Set("companylogo", String.Format("exe.aspx?proc=pgbinaryget&namedresource={0}&nonce={1}", dt["LogoResourcename"].ToString(), Guid.NewGuid().ToString())); } else { s.Set("companylogo_visible", "blendout"); s.Set("companylogo", "images/spacer.gif"); } s.Set("date", dt["fDate"].ToString()); s.Set("time", dt["fTime"].ToString()); s.Set("orgcap", dt["OrgCap"].ToString()); s.Set("workplace", dt["Workplace"].ToString()); s.Set("originatorname", dt["OriginatorName"].ToString()); s.Set("crea_when", dt["fcrea_when"].ToString()); s.Set("natureofinjury", dt["NatureOfInjury"].ToString()); s.Set("placarduntil", dt["fPlacardUntil"].ToString()); s.Set("courseofevents", dt["fCourseOfEvents"].ToString()); s.Set("causes", dt["fCauses"].ToString()); s.Set("measures", dt["fMeasures"].ToString()); if (String.IsNullOrWhiteSpace(dt["fMeasures"].ToString())) { /* [dlatikay 20120207] we do not show the measure memo label if we have no content */ s.Set("measuresvisiblecommentstart", Html.cstHTMLCommentStart); s.Set("measuresvisiblecommentend", Html.cstHTMLCommentEnd); } /* pictures */ if (Convert.ToInt32(dt["ShowImageRow1"]) == 1 && (!(dt["Image1"].Equals(DBNull.Value)))) { s.Set("show_image_row1", "blendin"); s.Set("image1", MediaURL(Convert.ToInt32(dt["Image1"]))); } else { s.Set("show_image_row1", "blendout"); s.Set("image1", "images/spacer.gif"); } if (Convert.ToInt32(dt["ShowImageRow2"]) == 1 && (!(dt["Image1"].Equals(DBNull.Value))) && (!(dt["Image2"].Equals(DBNull.Value)))) { s.Set("show_image_row2", "blendin"); s.Set("image2", MediaURL(Convert.ToInt32(dt["Image1"]))); /* sic 1>2 */ s.Set("image3", MediaURL(Convert.ToInt32(dt["Image2"]))); /* sic 2>3 */ } else { s.Set("show_image_row2", "blendout"); s.Set("image2", "images/spacer.gif"); s.Set("image3", "images/spacer.gif"); } /* [dlatikay 20120215] do we want to include a QR code? */ s.Set("qrcode_commentstart", Html.cstHTMLCommentStart); s.Set("qrcode_commentend", Html.cstHTMLCommentEnd); if (this.PresentationOptions.HasFlag(ReportPresentationOptions.ShowQRCode)) { string qr_code_url; if (CreateQRCodeForSubject(out qr_code_url)) { /* reference the picture using the binid we received from our host app */ s.Set("qrcode_url", qr_code_url); s.Set("qrcode_commentstart", String.Empty); s.Set("qrcode_commentend", String.Empty); } } /* commit */ sink.SubmitPart(s.AsStringBuilder); }
/// <summary> /// Capability to render the body of a training participants list /// to PDF and HTML /// </summary> internal override void RenderBodyInternal(HtmlTemplateEngine sink) { /* get data */ var dt = Data.Tables[ReportDatatableIdentifiers.REPORT_DATATABLE_HARDCOPY_EMPLOYEE].Rows[0]; /* load the report body template */ var s = HtmlTemplateEngine.LoadTemplate("hardcopy_proofoftraining-1employee.ent", m); /* populate it fully */ s.Set("persnr", dt["PersNr"].ToString()); s.Set("employeename", dt["fEmployeeName"].ToString()); s.Set("employeeaddress", dt["fEmployeeAddress"].ToString()); s.Set("employeeplaceofbirth", dt["PlaceOfBirth"].ToString()); s.Set("orgcap", dt["OrgCap"].ToString()); s.Set("participations", dt["fParticipations"].ToString()); /* commit */ sink.SubmitPart(s.AsStringBuilder); /* cache the training subjects part */ int audienceid; var subjects = new Dictionary <int, List <SubjectRow> >(); var subs = Data.Tables[ReportDatatableIdentifiers.REPORT_DATATABLE_HARDCOPY_EMPLOYEE_TRAININGSUBJECTS]; foreach (DataRow sub in subs.Rows) { audienceid = Convert.ToInt32(sub["AudienceID"]); var subject_row = new SubjectRow(sub); if (subjects.ContainsKey(audienceid)) { subjects[audienceid].Add(subject_row); } else { subjects.Add(audienceid, new List <SubjectRow>() { subject_row }); } } /* populate the training participations part */ clsTemplate p = HtmlTemplateEngine.LoadTemplate("hardcopy_proofoftraining-2participations.ent", m); var partis = Data.Tables[ReportDatatableIdentifiers.REPORT_DATATABLE_HARDCOPY_EMPLOYEE_TRAININGHISTORY]; foreach (DataRow part in partis.Rows) { /* we re-use the same template */ p.ClearDynamic(); /* populate one instance */ p.Set("motivation", part["fMotivation"]); p.Set("nrcomposite", part["NrComposite"]); p.Set("orgcap", part["OrgCap"]); p.Set("workplace", part["Workplace"]); p.Set("trainer", part["fTrainerName"]); p.Set("responsible", part["fResponsibleName"]); p.Set("duration", part["fDuration"]); p.Set("remarks", part["ParticipationRemark"]); var room = part["fResource"].ToString(); var partner = part["TrainerPartnername"].ToString(); if (String.IsNullOrWhiteSpace(room) && String.IsNullOrWhiteSpace(partner)) { p.Set("roomorpartner_commentstart", Html.cstHTMLCommentStart); p.Set("roomorpartner_commentend", Html.cstHTMLCommentEnd); } else { p.Set("room", room); p.Set("partner", partner); } p.Set("date", part["fDate"]); p.Set("datetime", part["fDatetime"]); p.Set("tra_cap", part["fCaption"]); p.Set("topic", part["TopicCaption"]); var topic_description = part["TopicDescription"].ToString(); if (String.IsNullOrWhiteSpace(topic_description)) { p.Set("topicdescription_commentstart", Html.cstHTMLCommentStart); p.Set("topicdescription_commentend", Html.cstHTMLCommentEnd); } else { p.Set("description", topic_description); } /* get the subjects which apply, and append */ audienceid = Convert.ToInt32(part["AudienceID"]); var anysubjects = false; if (subjects.ContainsKey(audienceid)) { var ssubj = String.Empty; foreach (var subj in subjects[audienceid]) { ssubj = ssubj.ConcatWith(Environment.NewLine, subj.Text); } if (!String.IsNullOrWhiteSpace(ssubj)) { p.Set("subjects", ssubj); anysubjects = true; } } if (!anysubjects) { p.Set("anysubjects_commentstart", Html.cstHTMLCommentStart); p.Set("anysubjects_commentend", Html.cstHTMLCommentEnd); } /* send one instance */ sink.SubmitPart(p.AsStringBuilder); } }
/// <summary> /// Capability to render the body of a safety incident report placard to /// PDF and HTML /// </summary> internal override void RenderBodyInternal(HtmlTemplateEngine sink) { /* get data */ var dt = Data.Tables[ReportDatatableIdentifiers.REPORT_DATATABLE_HARDCOPY_INCIDENTVERBOSE].Rows[0]; /* load the incident report body template */ clsTemplate s = HtmlTemplateEngine.LoadTemplate("hardcopy_incident-1basicdata.ent", m); /* populate it fully */ s.Set("nrcomposite", dt["NrComposite"].ToString()); s.Set("partnerinvolved", dt["fPartnerInvolved"].ToString()); s.Set("cat_abbrev", dt["CatAbbrev"].ToString()); s.Set("cat_caption", dt["CatCaption"].ToString()); s.Set("eventdatetime", dt["fTime"].ToString()); s.Set("orgcap", dt["OrgCap"].ToString()); s.Set("workplace", dt["Workplace"].ToString()); s.Set("originatorname", dt["OriginatorName"].ToString()); s.Set("crea_when", dt["fcrea_when"].ToString()); s.Set("lm_when", dt["flm_when_who"].ToString()); s.Set("natureofinjury", dt["NatureOfInjury"].ToString()); s.Set("typeofcontact", dt["TypeOfContact"].ToString()); s.Set("bodypart", dt["BodyPart"].ToString()); s.Set("bodypartdetails", dt["BodypartDetails"].ToString()); s.Set("hygieneagency", dt["HygieneAgency"].ToString()); s.Set("generalagency", dt["Medium"].ToString()); s.Set("activity", dt["ActivityCaption"].ToString()); s.Set("risk", dt["fRisk"].ToString()); s.Set("courseofevents", dt["fCourseOfEvents"].ToString()); s.Set("causes", dt["fCauses"].ToString()); /* persons involved */ var invo = Data.Tables[ReportDatatableIdentifiers.REPORT_DATATABLE_HARDCOPY_SHARED_PERS]; var spers = new StringBuilder(); foreach (DataRow dr in invo.Rows) { var sheading = dr["Heading"].ToString(); var sname = dr["Name"].ToString(); if (String.IsNullOrWhiteSpace(sheading)) { spers.AppendFormat(", {0}", sname); } else { spers.AppendFormat("{0}<strong>{1}</strong> {2}", spers.Length > 0 ? "<br />" : String.Empty, sheading, sname); } } s.Set("personsinvolved", spers.ToString()); /* pictures */ var pics = Data.Tables[ReportDatatableIdentifiers.REPORT_DATATABLE_HARDCOPY_SHARED_PICS]; if (pics.Rows.Count > 0) { var spics = new StringBuilder(); foreach (DataRow dr in pics.Rows) { spics.AppendFormat("<img alt=\"\" src=\"{0}\" onload=\"JavaScript:sizepic(this);\" />{1}", MediaURL(Convert.ToInt32(dr["BinID"])), Environment.NewLine ); } s.Set("pics", spics.ToString()); } else { s.Set("anypics_commentstart", Html.cstHTMLCommentStart); s.Set("anypics_commentend", Html.cstHTMLCommentEnd); } /* root cause analysis */ var fins = Data.Tables[ReportDatatableIdentifiers.REPORT_DATATABLE_HARDCOPY_INCIDENT_FIN]; var finpic_binids = new List <int>(); var any_rcas = false; var any_findings = false; var rcarows = new RcaRows(); foreach (DataRow dr in fins.Rows) { /* enum and format the root cause findings; * gather infos about the other findings and their pics at the same time */ var linktype = (proxyfindinglinktypes)Convert.ToInt32(dr["LinkType"]); if (linktype == proxyfindinglinktypes.pflt_ProxyRootcause) { any_rcas = true; /* parse this one root cause item now */ rcarows.Add(new RcaRow(dr, m), LCID); } else { any_findings = true; if (!dr["BinID"].Equals(DBNull.Value)) /* we use this loop to gather the finding pics already */ { var binid = Convert.ToInt32(dr["BinID"]); if (binid > 0 && (!finpic_binids.Contains(binid))) { finpic_binids.Add(binid); } } } } if (any_rcas) { s.Set("rcaitems", rcarows.ToString(LCID)); } else { s.Set("anyrcaitems_commentstart", Html.cstHTMLCommentStart); s.Set("anyrcaitems_commentend", Html.cstHTMLCommentEnd); } /* commit first section */ sink.SubmitPart(s.AsStringBuilder); /* findings */ clsTemplate f = HtmlTemplateEngine.LoadTemplate("hardcopy_incident-2findings.ent", m); var sfindings = String.Empty; var fin_cap = any_rcas ? m(3258) : m(233); /* Other findings / Findings */ if (finpic_binids.Count > 0) { var spics = new StringBuilder(); foreach (var binid in finpic_binids) { spics.AppendFormat("<img alt=\"\" src=\"{0}\" onload=\"JavaScript:sizepic(this);\" />{1}", MediaURL(binid), Environment.NewLine ); } f.Set("pics", spics.ToString()); } else { f.Set("anypics_commentstart", Html.cstHTMLCommentStart); f.Set("anypics_commentend", Html.cstHTMLCommentEnd); } /* commit finding section */ if (any_findings) { /* enum and format the findings */ var category_summary = String.Empty; var categories_mentioned = new List <string>(); var finrows = new FinRows(); foreach (DataRow dr in fins.Rows) { /* parse this one finding now */ var linktype = (proxyfindinglinktypes)Convert.ToInt32(dr["LinkType"]); if (linktype != proxyfindinglinktypes.pflt_ProxyRootcause) /* [dlatikay 20120209] here, we take only the "residual", "true" findings - the root cause proxy findings go in the RCA section up, and are not mentioned here a second time */ { finrows.Add(new FinRow(dr, m), LCID); } } /* take care of the category summary */ foreach (var finrow in finrows.Values) { if (!String.IsNullOrWhiteSpace(finrow.sCatAbbrev)) { if (!categories_mentioned.Contains(finrow.sCatAbbrev)) { category_summary = String.Format("{0}{1}{2}... {3}", category_summary, String.IsNullOrWhiteSpace(category_summary) ? String.Empty : ", ", finrow.sCatAbbrev, finrow.sCatCap); categories_mentioned.Add(finrow.sCatAbbrev); } } } f.Set("fin_cap", fin_cap); f.Set("findingitems", finrows.ToString(LCID)); f.Set("category_summary", category_summary); sink.SubmitPart(f.AsStringBuilder); } /* measures */ var meas = Data.Tables[ReportDatatableIdentifiers.REPORT_DATATABLE_HARDCOPY_INCIDENT_MEA]; clsTemplate tm = HtmlTemplateEngine.LoadTemplate("hardcopy_incident-3measures.ent", m); var smeasures = String.Empty; var hasmeasuretext = !dt["fMeasures"].Equals(DBNull.Value); if (hasmeasuretext) { smeasures = dt["fMeasures"].ToString(); } if (String.IsNullOrWhiteSpace(smeasures)) { hasmeasuretext = false; } var any_measures = meas.Rows.Count > 0 || hasmeasuretext; if (any_measures) { /* enum and compose the actual measure items */ var mearows = new MeaRows(); foreach (DataRow dr in meas.Rows) { /* parse this one measure now */ mearows.Add(new MeaRow(dr, m), LCID); } smeasures = mearows.ToString(LCID); /* display the text from the report? */ if (hasmeasuretext) { tm.Set("measures", dt["fMeasures"].ToString()); } else { tm.Set("measuretext_commentstart", Html.cstHTMLCommentStart); tm.Set("measuretext_commentend", Html.cstHTMLCommentEnd); } /* display the 1:n list? */ if (String.IsNullOrWhiteSpace(smeasures)) { tm.Set("anymeasures_commentstart", Html.cstHTMLCommentStart); tm.Set("anymeasures_commentend", Html.cstHTMLCommentEnd); } else { tm.Set("measureitems", smeasures); } sink.SubmitPart(tm.AsStringBuilder); } }
public override void RenderHtml(StringBuilder s) { /* load the amcharts embedder */ var chart_template = HtmlTemplateEngine.LoadTemplate("am_embed.html", my); var settings_template = HtmlTemplateEngine.LoadTemplate("am_settings.xml", my); var graph_partial = HtmlTemplateEngine.LoadTemplate("am_graph.partial", my); var data_template = HtmlTemplateEngine.LoadTemplate("am_data.xml", my); /* 1. composition of settings */ settings_template.Set("title", sherm.core.Html.CDATAEncode(Title)); settings_template.Set("columntype", Stacked ? "stacked" : "clustered"); settings_template.Set("animation_grow_time", Animated ? "3" : "0"); /* added [dlatikay 20111205] */ var graphs = new StringBuilder(); foreach (var graph in Graphs) { graph_partial.Set("ordinal", graph.Ordinal.ToString()); graph_partial.Set("type", GetTypeDesignator(graph.GraphType)); /* [dlatikay 20110620] added overriding type: can mix line and bar (eg. Pareto) */ graph_partial.Set("title", System.Web.HttpUtility.HtmlEncode(graph.Title)); graph_partial.Set("color", ColorTranslator.ToHtml(graph.Color)); graphs.AppendLine(graph_partial.ToString()); } /* assign the graphs */ settings_template.Set("graphs", graphs.ToString()); /* 2. composition of values - in consts because considered "too small for partials" */ const string seriesvalue = "<value xid=\"{0}\">{1}</value>"; const string graphitem = "<graph gid=\"{0}\">{1}</graph>"; const string valueitem = "<value xid=\"{0}\">{1}</value>\r\n"; /* 2a. composition of series descriptors */ var seriesvalues = new StringBuilder(); foreach (var series in Series) { seriesvalues.AppendLine(String.Format(seriesvalue, series.Ordinal.ToString(), HttpUtility.HtmlEncode(series.Seriesname))); } data_template.Set("series", seriesvalues.ToString()); /* 2b. the graphs */ var graphitems = new StringBuilder(); foreach (var graph in Graphs) { var graphsvalues = new StringBuilder(); foreach (var value in graph.Values) { graphsvalues.AppendFormat(valueitem, value.Key.ToString(), value.Value.ToXml); } /* next graph */ graphitems.AppendFormat(graphitem, graph.Ordinal.ToString(), graphsvalues); } data_template.Set("graphsvalues", graphitems.ToString()); /* replacements */ chart_template.Set("type", GetTypeDesignator()); chart_template.Set("chart_div_id", Guid.NewGuid().ToString()); chart_template.Set("settings", String.Join("\"+\"", settings_template.ToString().Replace("\"", "\\\"").Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))); chart_template.Set("data", String.Join("\"+\"", data_template.ToString().Replace("\"", "\\\"").Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))); /* [dlatikay 20110610] -!!- consider to abandon embedding this as JS script string in case they get too long - * upload to binstorage and reference from there */ /* deliver */ s.AppendLine(chart_template.ToString()); }