예제 #1
0
        /// <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);
            }
        }
예제 #2
0
        /// <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);
            }
        }