コード例 #1
0
        private PdfPCell MultipleLineFieldToCell(PdfPCell cell, Boolean forCompile, dtoSubmissionValueField item, String emptyItem, String maxCharInfo)
        {
            Chunk chunk = new Chunk((forCompile ? "" : ((item.Value == null || String.IsNullOrEmpty(item.Value.Text)) ? emptyItem : item.Value.Text)), GetFont(ItemType.Paragraph));

            if (forCompile)
            {
                PdfPTable tInput = GetTable(1, 1);
                PdfPCell  cInput = new PdfPCell();
                if (item.Field.MaxLength > 4000)
                {
                    cInput.Rowspan = 15;
                }
                else if (item.Field.MaxLength > 2000)
                {
                    cInput.Rowspan = 10;
                }
                else
                {
                    cInput.Rowspan = 5;
                }
                tInput.AddCell(cInput);
                cell.AddElement(tInput);
            }
            else
            {
                cell.AddElement(chunk);
            }
            if (item.Field.MaxLength > 0)
            {
                cell.AddElement(GetParagraph(String.Format(maxCharInfo, item.Field.MaxLength), GetFont(ItemType.Caption)));
            }
            return(cell);
        }
コード例 #2
0
        private Cell DisclaimerLineFieldToCell(Cell cell, Boolean forCompile, dtoSubmissionValueField item, String emptyItem, Dictionary <SubmissionTranslations, string> translations)
        {
            switch (item.Field.DisclaimerType)
            {
            case DisclaimerType.None:
                cell.Add(GetParagraph(emptyItem, GetFont(ItemType.Paragraph), Element.ALIGN_RIGHT));
                break;

            case DisclaimerType.Standard:
                if (forCompile)
                {
                    cell.Add(GetParagraph("( )  " + translations[SubmissionTranslations.DisclaimerAccept] + "    ( )  " + translations[SubmissionTranslations.DisclaimerReject], GetFont(ItemType.Paragraph), Element.ALIGN_RIGHT));
                }
                else
                {
                    cell.Add(GetParagraph((item.Value != null && item.Value.Text == "True" ? translations[SubmissionTranslations.DisclaimerAccept] : translations[SubmissionTranslations.DisclaimerReject]), GetFont(ItemType.Paragraph), Element.ALIGN_RIGHT));
                }
                break;

            case DisclaimerType.CustomDisplayOnly:
                cell.Add(GetParagraph(emptyItem, GetFont(ItemType.Paragraph), Element.ALIGN_RIGHT));
                break;

            default:
                MultipleChoiceFieldToCell(cell, forCompile, item, emptyItem, translations);
                break;
            }
            return(cell);
        }
コード例 #3
0
        private PdfPCell FileInputFieldToCell(PdfPCell cell, Boolean forCompile, dtoSubmissionValueField item, String emptyItem, Dictionary <SubmissionTranslations, string> translations)
        {
            //Chunk chunkUnselect = (item.Field.Type == FieldType.CheckboxList) ? whitesquare : whitebullet;
            //Chunk chunkSelect = (item.Field.Type == FieldType.CheckboxList) ? new iTextSharp.text.Chunk("\u25A0", FontFactory.GetFont(FontFactory.ZAPFDINGBATS, 12, Font.NORMAL, Color.BLACK)) : new iTextSharp.text.Chunk("\u25CB", FontFactory.GetFont(FontFactory.ZAPFDINGBATS, 12, Font.NORMAL, Color.BLACK));
            String unselect = "[   ]  ";

            if (forCompile)
            {
                cell.AddElement(GetParagraph(unselect, GetFont(ItemType.Paragraph)));
            }
            else
            {
                cell.AddElement(GetParagraph((item.Value == null || item.Value.IdLink == 0) ? translations[SubmissionTranslations.FileNotSubmitted] : translations[SubmissionTranslations.FileSubmitted], GetFont(ItemType.Paragraph)));
            }
            return(cell);
        }
コード例 #4
0
        private PdfPCell AddGenericFieldToTable(PdfPCell cell, Boolean forCompile, dtoSubmissionValueField item, String emptyItem, String maxCharInfo)
        {
            Chunk chunk = new Chunk((forCompile ? "" : (item.Value == null || String.IsNullOrEmpty(item.Value.Text) ? emptyItem : item.Value.Text)), GetFont(ItemType.Paragraph));

            cell.AddElement(chunk);
            if (forCompile && item.Field.MaxLength > 200)
            {
                Chunk ch = new Chunk("\r\n", GetFont(ItemType.Paragraph));
                cell.AddElement(ch);
            }

            if (item.Field.MaxLength > 0)
            {
                cell.AddElement(GetParagraph(String.Format(maxCharInfo, item.Field.MaxLength), GetFont(ItemType.Caption)));
            }
            return(cell);
        }
コード例 #5
0
        /// <summary>
        /// Dato l'elemento associato alla compilazione utente (stringa), verifica se è superata la soglia massima prevista
        /// </summary>
        /// <param name="item">Contenuto elemento sottomissione utente (tabella)</param>
        /// <returns>TRUE se la soglia è stata superata</returns>
        public static bool IsOverRange(dtoSubmissionValueField item)
        {
            if (item == null ||
                item.Field == null ||
                item.Field.Type != FieldType.TableReport ||
                item.Field.TableFieldSetting == null ||
                item.Field.TableFieldSetting.MaxTotal == 0
                )
            {
                return(false);
            }

            if (item.Value == null || String.IsNullOrEmpty(item.Value.Text))
            {
                return(false); //è vuoto, cioè 0 = sono sotto
            }
            return(IsOverRange(item.Value.Text, item.Field.TableFieldSetting.MaxTotal));
        }
コード例 #6
0
 public void InitView(dtoSubmissionValueField field, Boolean disabled, Boolean isPublic)
 {
     if (UserContext.isAnonymous && !isPublic)
     {
         View.DisplaySessionTimeout();
     }
     else
     {
         View.Disabled = disabled;
         if (field == null)
         {
             View.DisplayEmptyField();
         }
         else
         {
             View.SetupView(field, isPublic);
         }
     }
 }
コード例 #7
0
        /// <summary>
        /// "Decora" l'html di una tabella con classi e parametri opzionali per la visualizzazione
        /// </summary>
        /// <param name="item">Valore inserito dall'utente</param>
        /// <param name="forcompile">True se è per la compilazione</param>
        /// <returns>Una stringa con l'html completo della tabella</returns>
        public static string TableDecorateHtml(dtoSubmissionValueField item, bool forcompile)
        {
            String tablestr = (item != null && item.Value != null) ? item.Value.Text : "";

            //TableSetting.Cols.Split("|").ToList()
            if (String.IsNullOrEmpty(tablestr))
            {
                tablestr = "<table></table>";
            }

            if (item.Field.Type == FieldType.TableSimple)
            {
                tablestr = TableSimpleDecorateHtml(tablestr, item, forcompile);
            }
            else if (item.Field.Type == FieldType.TableReport)
            {
                tablestr = TableReportDecorateHtml(tablestr, item, forcompile);
            }

            return(tablestr);
        }
コード例 #8
0
        /// <summary>
        /// "Decora" l'html di una tabella semplice con classi e parametri opzionali per la visualizzazione
        /// </summary>
        /// <param name="contentTable">Tabella semplice - compilazione utente</param>
        /// <param name="item">elemento sottomesso dall'utente</param>
        /// <param name="forcompile">True se è epr la compilazione</param>
        /// <returns></returns>
        public static string TableSimpleDecorateHtml(string contentTable, dtoSubmissionValueField item, bool forcompile)
        {
            forcompile = forcompile || String.IsNullOrEmpty(contentTable);

            String CompileString = "&nbsp;";



            if (item.Field.TableFieldSetting != null && !String.IsNullOrEmpty(item.Field.TableFieldSetting.Cols))
            {
                String Header = "";

                foreach (String th in item.Field.TableFieldSetting.Cols.Split('|').ToList())
                {
                    Header        = string.Format("{0}<td border=\"1\"><b>{1}</b></td>", Header, th);
                    CompileString = string.Format("{0}<td border=\"1\">&nbsp; </td>", CompileString);
                }

                CompileString = String.IsNullOrEmpty(CompileString) ? "<td>&nbsp;</td>" : CompileString;

                Header = String.IsNullOrEmpty(Header)
                    ? ""
                    : string.Format("<tr>{0}</tr>", Header);

                contentTable = contentTable.Replace(
                    "<table>",
                    String.Format("<table border=\"1\" cellpadding=\"4\" cellspacing=\"0\">{0}", Header));
            }

            if (forcompile)
            {
                contentTable = contentTable.Replace("</table>", String.Format("<tr>{0}</tr></table>", CompileString));
                //tablestr = tablestr.Replace("</table>", String.Format("<tr>{0}</tr></table>", CompileString));
                //tablestr = tablestr.Replace("</table>", String.Format("<tr>{0}</tr></table>", CompileString));
            }
            contentTable = contentTable.Replace("></td>", ">&nbsp; </td>");

            return(contentTable.Replace(Environment.NewLine, "<br />"));
        }
コード例 #9
0
        /// <summary>
        /// "Decora" l'html di una tabella Economica con classi e parametri opzionali per la visualizzazione
        /// </summary>
        /// <param name="contentTable">Tabella sorgente</param>
        /// <param name="item">Elemento sottomissione</param>
        /// <param name="forcompile">True se è per la compilazione</param>
        /// <returns>Stringa html con la tabella</returns>
        public static string TableReportDecorateHtml(string contentTable, dtoSubmissionValueField item, bool forcompile)
        {
            try
            {
                String sourceTable = item.Value.Text;
                String outTable    = "";

                String CompileString = "&nbsp;";

                String Header = "";


                int colCount = 0;

                if (item.Field.TableFieldSetting != null)
                {
                    if (!String.IsNullOrEmpty(item.Field.TableFieldSetting.Cols))
                    {
                        foreach (String th in item.Field.TableFieldSetting.Cols.Split('|').ToList())
                        {
                            Header        = string.Format("{0}<td border=\"1\"><b>{1}</b></td>", Header, th);
                            CompileString = string.Format("{0}<td border=\"1\">&nbsp; </td>", CompileString);
                            colCount++;
                        }
                    }
                    else
                    {
                        Header        = string.Format("{0}<td border=\"1\"><b>{1}</b></td>", Header, "");
                        CompileString = string.Format("{0}<td border=\"1\">&nbsp; </td>", CompileString);
                        colCount++;
                    }

                    Header        = string.Format("{0}<td border=\"1\"><b>{1}</b></td>", Header, "Quantità");
                    CompileString = string.Format("{0}<td border=\"1\">&nbsp; </td>", CompileString);

                    Header        = string.Format("{0}<td border=\"1\"><b>{1}</b></td>", Header, "Costo unitario");
                    CompileString = string.Format("{0}<td border=\"1\">&nbsp; </td>", CompileString);

                    Header        = string.Format("{0}<td border=\"1\"><b>{1}</b></td>", Header, "Totale");
                    CompileString = string.Format("{0}<td border=\"1\">&nbsp; </td>", CompileString);

                    if (!String.IsNullOrEmpty(Header))
                    {
                        Header = string.Format("<tr>{0}</tr>", Header);
                    }

                    colCount += 3;
                }

                //if (forcompile)
                //{
                //    sourceTable = sourceTable.Replace("</table>", String.Format("<tr>{0}</tr></table>", CompileString));
                //    //tablestr = tablestr.Replace("</table>", String.Format("<tr>{0}</tr></table>", CompileString));
                //    //tablestr = tablestr.Replace("</table>", String.Format("<tr>{0}</tr></table>", CompileString));
                //}


                //Aggiungo Header
                //outTable = sourceTable.Replace("<table>", String.Format("<table border=\"1\" cellpadding=\"4\" cellspacing=\"0\"><tr>{0}</tr>", Header));

                Double total = 0;
                string rows  = "";

                if (!(String.IsNullOrEmpty(sourceTable)))
                {
                    string contentXml = String.Format("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>{0}{1}",
                                                      System.Environment.NewLine, sourceTable)
                    ;
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(contentXml);

                    string rowformat = "{0}<tr>{1}</tr>";


                    foreach (XmlNode trXml in doc.GetElementsByTagName("tr"))
                    {
                        string prow            = "";
                        int    currentColCount = 0;

                        foreach (XmlNode tdXml in trXml.ChildNodes)
                        {
                            string ptd = "";


                            string cssclass = "";


                            if (tdXml.Attributes != null && tdXml.Attributes.Count > 0)
                            {
                                try
                                {
                                    cssclass = tdXml.Attributes["class"].Value;
                                }
                                catch (Exception ex)
                                {
                                }
                            }

                            //(tdXml.Attributes != null && tdXml.Attributes.("class") != null) ?   : "";

                            if (!String.IsNullOrEmpty(cssclass))
                            {
                                Double val = 0;
                                Double.TryParse(tdXml.InnerText.ToString(), out val);

                                string euro = (cssclass == "total" || cssclass == "unitycost") ? "&euro;" : ""; //€-


                                ptd = string.Format("<td border=\"1\" class=\"{0}\">{1} {2}</td>", cssclass, val, euro);

                                if (cssclass == "total")
                                {
                                    total += val;
                                }
                            }
                            else
                            {
                                ptd = string.Format("<td border=\"1\">{0}</td>", tdXml.InnerText);
                            }


                            colCount = (currentColCount > colCount) ? currentColCount : colCount;   //Fix se header vuoto

                            prow = String.Format("{0}{1}", prow, ptd);
                        }

                        rows = string.Format(rowformat, rows, prow);
                    }

                    //colCount = doc.GetElementsByTagName("tr").Item(0).ChildNodes.Count;
                }

                String totalRow = String.Format("<tr><td colspan=\"{0}\">&nbsp;</td><td>{1}</td><td>{2} &euro;</td></tr>",
                                                (colCount - 2), "Totale", total);



                if (forcompile || String.IsNullOrEmpty(sourceTable))
                {
                    outTable = string.Format("<table  border=\"1\" cellspacing=\"0\">{0}{1}<tr>{2}</tr>{3}</table>",
                                             Header,
                                             rows,
                                             CompileString,
                                             totalRow);
                }
                else
                {
                    outTable = string.Format("<table border=\"1\" cellspacing=\"0\">{0}{1}{2}</table>",
                                             Header,
                                             rows,
                                             totalRow);
                }

                outTable = outTable.Replace("></td>", ">&nbsp; </td>").Replace("<td>", "<td border=\"1\">");

                return(outTable.Replace(Environment.NewLine, "<br />"));; //tablestr;
            }
            catch (Exception ex)
            {
            }
            return(contentTable);
        }
コード例 #10
0
 public void InitView(long idCall, long idSubmission, lm.Comol.Core.FileRepository.Domain.RepositoryIdentifier identifier, dtoSubmissionValueField field, Boolean disabled, Boolean isPublic)
 {
     if (UserContext.isAnonymous && !isPublic)
     {
         View.DisplaySessionTimeout();
     }
     else
     {
         View.Disabled        = disabled;
         View.IdCall          = idCall;
         View.IdSubmission    = idSubmission;
         View.IdCallCommunity = identifier.IdCommunity;
         if (field == null)
         {
             View.Mandatory = false;
             View.DisplayEmptyField();
         }
         else
         {
             View.Mandatory      = (field.Field == null) ? false : field.Field.Mandatory;
             View.DisclaimerType = (field.Field == null) ? DisclaimerType.None : field.Field.DisclaimerType;
             View.Options        = (field.Field == null) ? new List <dtoFieldOption>() : field.Field.Options;
             View.SetupView(field, UserContext.CurrentUserID, identifier, isPublic);
         }
     }
 }
コード例 #11
0
        private PdfPCell MultipleChoiceFieldToCell(PdfPCell cell, Boolean forCompile, dtoSubmissionValueField item, String emptyItem, Dictionary <SubmissionTranslations, string> translations)
        {
            //Chunk chunkUnselect = (item.Field.Type == FieldType.CheckboxList) ? whitesquare : whitebullet;
            //Chunk chunkSelect = (item.Field.Type == FieldType.CheckboxList) ? new iTextSharp.text.Chunk("\u25A0", FontFactory.GetFont(FontFactory.ZAPFDINGBATS, 12, Font.NORMAL, Color.BLACK)) : new iTextSharp.text.Chunk("\u25CB", FontFactory.GetFont(FontFactory.ZAPFDINGBATS, 12, Font.NORMAL, Color.BLACK));
            String unselect      = (item.Field.Type == FieldType.CheckboxList) ? "[   ]  " : "(   )  ";
            String freeTextSpace = (item.Field.Type == FieldType.CheckboxList) ? "       " : "       ";

            String        optOpen    = (item.Field.Type == FieldType.CheckboxList) ? "[" : "(";
            String        optClose   = (item.Field.Type == FieldType.CheckboxList) ? "]  " : ")  ";
            Chunk         chOpen     = new Chunk(optOpen, GetFont(ItemType.Paragraph));
            Chunk         chSelected = new Chunk("X", GetFont(ItemType.SelectedItem));
            Chunk         chClose    = new Chunk(optClose, GetFont(ItemType.Paragraph));
            List <String> mValue     = (item.Value == null || String.IsNullOrEmpty(item.Value.Text)) ? new List <String>() : item.Value.Text.Split('|').ToList();

            Paragraph par = GetParagraph("", GetFont(ItemType.Paragraph), 0);

            par.IndentationLeft = 10;

            foreach (dtoFieldOption opt in item.Field.Options.Where(o => o.Deleted == BaseStatusDeleted.None).ToList())
            {
                if (forCompile)
                {
                    par.Add(new Chunk(unselect + opt.Name, GetFont(ItemType.Paragraph)));
                    if (opt.IsFreeValue)
                    {
                        par.Add(new Chunk("  ______________________________________________________________________", GetFont(ItemType.Paragraph)));
                    }
                    par.Add(Chunk.NEWLINE);
                }
                else
                {
                    if (mValue.Contains(opt.Id.ToString()))
                    {
                        par.Add(chOpen);
                        par.Add(chSelected);
                        par.Add(chClose);
                        par.Add(new Chunk(opt.Name, GetFont(ItemType.SelectedItem)));
                        if (opt.IsFreeValue)
                        {
                            if (!String.IsNullOrEmpty(item.Value.FreeText))
                            {
                                par.Add(Chunk.NEWLINE);
                                par.Add(new Chunk(freeTextSpace + item.Value.FreeText, GetFont(ItemType.Paragraph)));
                            }
                            else
                            {
                                par.Add(new Chunk("  ______________________________________________________________________", GetFont(ItemType.Paragraph)));
                            }
                        }
                        par.Add(Chunk.NEWLINE);
                    }
                    else
                    {
                        par.Add(new Chunk(unselect + opt.Name, GetFont(ItemType.Paragraph)));
                        if (opt.IsFreeValue)
                        {
                            par.Add(new Chunk("  ______________________________________________________________________", GetFont(ItemType.Paragraph)));
                        }
                        par.Add(Chunk.NEWLINE);
                    }
                }
            }
            cell.AddElement(par);
            if (item.Field.Type == FieldType.CheckboxList)
            {
                if (item.Field.MaxOption > 0 && item.Field.MinOption == 0)
                {
                    cell.AddElement(GetParagraph(String.Format(translations[SubmissionTranslations.MaxOption], item.Field.MaxOption), GetFont(ItemType.Caption)));
                }
                else if (item.Field.MaxOption == 0 && item.Field.MinOption > 0)
                {
                    cell.AddElement(GetParagraph(String.Format(translations[SubmissionTranslations.MinOption], item.Field.MinOption), GetFont(ItemType.Caption)));
                }
                else if (item.Field.MinOption > 0 && item.Field.MaxOption > 0)
                {
                    cell.AddElement(GetParagraph(String.Format(translations[SubmissionTranslations.MinOptionMaxOption], item.Field.MinOption, item.Field.MaxOption), GetFont(ItemType.Caption)));
                }
            }
            return(cell);
        }