Example #1
0
 // 获得css文件的路径(或者http:// 地址)。将根据是否具有“统计页”来自动处理
 // parameters:
 //      strDefaultCssFileName   “css”模板缺省情况下,将采用的虚拟目录中的css文件名,纯文件名
 string GetAutoCssUrl(PrintOption option,
     string strDefaultCssFileName)
 {
     string strCssFilePath = option.GetTemplatePageFilePath("css");  // 大小写不敏感
     if (String.IsNullOrEmpty(strCssFilePath) == false)
         return strCssFilePath;
     else
     {
         return PathUtil.MergePath(this.MainForm.DataDir, strDefaultCssFileName);    // 缺省的
     }
 }
Example #2
0
        int BuildPageTop(PrintOption option,
    Hashtable macro_table,
    string strFileName,
    bool bOutputTable)
        {
            string strCssUrl = GetAutoCssUrl(option, "itemhandover.css");
            string strLink = "<link href='" + strCssUrl + "' type='text/css' rel='stylesheet' />";

            StreamUtil.WriteText(strFileName,
                "<html><head>" + strLink + "</head><body>");


            // 页眉
            string strPageHeaderText = option.PageHeader;

            if (String.IsNullOrEmpty(strPageHeaderText) == false)
            {
                strPageHeaderText = StringUtil.MacroString(macro_table,
                    strPageHeaderText);

                StreamUtil.WriteText(strFileName,
                    "<div class='pageheader'>" + strPageHeaderText + "</div>");
            }

            // 表格标题
            string strTableTitleText = option.TableTitle;

            if (String.IsNullOrEmpty(strTableTitleText) == false)
            {

                strTableTitleText = StringUtil.MacroString(macro_table,
                    strTableTitleText);

                StreamUtil.WriteText(strFileName,
                    "<div class='tabletitle'>" + strTableTitleText + "</div>");
            }

            if (bOutputTable == true)
            {

                // 表格开始
                StreamUtil.WriteText(strFileName,
                    "<table class='table'>");   //   border='1'

                // 栏目标题
                StreamUtil.WriteText(strFileName,
                    "<tr class='column'>");

                for (int i = 0; i < option.Columns.Count; i++)
                {
                    Column column = option.Columns[i];

                    string strCaption = column.Caption;

                    // 如果没有caption定义,就挪用name定义
                    if (String.IsNullOrEmpty(strCaption) == true)
                        strCaption = column.Name;

                    string strClass = StringUtil.GetLeft(column.Name);

                    StreamUtil.WriteText(strFileName,
                        "<td class='" + strClass + "'>" + strCaption + "</td>");
                }

                StreamUtil.WriteText(strFileName,
                    "</tr>");
            }

            return 0;
        }
Example #3
0
        int BuildPageBottom(PrintOption option,
    Hashtable macro_table,
    string strFileName,
    bool bOutputTable)
        {


            if (bOutputTable == true)
            {
                // 表格结束
                StreamUtil.WriteText(strFileName,
                    "</table>");
            }

            // 页脚
            string strPageFooterText = option.PageFooter;

            if (String.IsNullOrEmpty(strPageFooterText) == false)
            {
                /*
                StreamUtil.WriteText(strFileName,
                    "<hr class='pagefooter' />");
                 * */


                strPageFooterText = StringUtil.MacroString(macro_table,
                    strPageFooterText);

                StreamUtil.WriteText(strFileName,
        "<div class='pagefooter'>" + strPageFooterText + "</div>");
            }


            StreamUtil.WriteText(strFileName, "</body></html>");

            return 0;
        }
Example #4
0
        // 是否包含种价格列?
        static bool bHasBiblioPriceColumn(PrintOption option)
        {
            for (int i = 0; i < option.Columns.Count; i++)
            {
                Column column = option.Columns[i];

                string strText = StringUtil.GetLeft(column.Name);


                if (strText == "biblioPrice"
                    || strText == "种价格")
                    return true;
            }

            return false;
        }
Example #5
0
        int BuildHtmlTableLine(PrintOption option,
            List<ListViewItem> items,
            string strFileName,
            int nPage,
            int nLine)
        {
            // 栏目内容
            string strLineContent = "";
            int nRet = 0;

            bool bBiblioSumLine = false;    // 是否为种的最后一行(汇总行)

            int nIndex = nPage * option.LinesPerPage + nLine;

            if (nIndex >= items.Count)
                goto END1;

            ListViewItem item = items[nIndex];

            string strMARC = "";
            string strOutMarcSyntax = "";

            if (this.MarcFilter != null
                || option.HasEvalue() == true)
            {
                string strError = "";

                // TODO: 有错误要明显报出来,否则容易在打印出来后才发现,就晚了

                // 获得MARC格式书目记录
                string strBiblioRecPath = ListViewUtil.GetItemText(item, COLUMN_BIBLIORECPATH);

                // TODO: 可以 cache,提高速度
                nRet = GetMarc(strBiblioRecPath,
                    out strMARC,
                    out strOutMarcSyntax,
                    out strError);
                if (nRet == -1)
                {
                    strLineContent = strError;
                    goto END1;
                }

                if (this.MarcFilter != null)
                {
                    this.ColumnTable.Clear();   // 清除上一记录处理时残余的内容
                    this.MarcFilter.Host.UiItem = item; // 当前正在处理的 ListViewItem

                    // 触发filter中的Record相关动作
                    nRet = this.MarcFilter.DoRecord(
                        null,
                        strMARC,
                        strOutMarcSyntax,
                        nIndex,
                        out strError);
                    if (nRet == -1)
                    {
                        strLineContent = strError;
                        goto END1;
                    }
                }
            }

            for (int i = 0; i < option.Columns.Count; i++)
            {
                Column column = option.Columns[i];

                /*
                int nIndex = nPage * option.LinesPerPage + nLine;

                if (nIndex >= items.Count)
                    break;

                ListViewItem item = items[nIndex];
                 * */

                string strContent = "";

                if (string.IsNullOrEmpty(column.Evalue) == false)
                {
                    Jurassic.ScriptEngine engine = new Jurassic.ScriptEngine();
                    engine.EnableExposedClrTypes = true;
                    engine.SetGlobalValue("syntax", strOutMarcSyntax);
                    engine.SetGlobalValue("biblio", new MarcRecord(strMARC));
                    strContent = engine.Evaluate(column.Evalue).ToString();

                }
                else
                {

                    strContent = GetColumnContent(item,
                        column.Name);

                    if (strContent == "!!!#")
                        strContent = ((nPage * option.LinesPerPage) + nLine + 1).ToString();

                    if (strContent == "!!!biblioPrice")
                    {
                        // 看看自己是不是处在切换边沿
                        string strCurLineBiblioRecPath = GetColumnContent(item, "biblioRecpath");

                        string strNextLineBiblioRecPath = "";

                        if (nIndex < items.Count - 1)
                        {
                            ListViewItem next_item = items[nIndex + 1];
                            strNextLineBiblioRecPath = GetColumnContent(next_item, "biblioRecpath");
                        }

                        if (strCurLineBiblioRecPath != strNextLineBiblioRecPath)
                        {
                            // 处在切换边沿

                            // 汇总前面的册价格
                            strContent = ComputeBiblioPrice(items, nIndex).ToString();
                            bBiblioSumLine = true;
                        }
                        else
                        {
                            // 其他普通行
                            strContent = "&nbsp;";
                        }
                    }

                }

                // 截断字符串
                if (column.MaxChars != -1)
                {
                    if (strContent.Length > column.MaxChars)
                    {
                        strContent = strContent.Substring(0, column.MaxChars);
                        strContent += "...";
                    }
                }

                if (String.IsNullOrEmpty(strContent) == true)
                    strContent = "&nbsp;";

                string strClass = StringUtil.GetLeft(column.Name);
                if (strClass.Length > 0 && strClass[0] == '@')
                {
                    strClass = "ext_" + strClass.Substring(1);
                }

                strLineContent +=
                    IndentString(4) + "<td class='" + strClass + "'>" + strContent + "</td>\r\n";
            }

        END1:

            string strOdd = "";
            if (((nLine + 1) % 2) != 0) // 用每页内的行号来计算奇数
                strOdd = " odd";

            string strBiblioSum = "";
            if (bBiblioSumLine == true)
                strBiblioSum = " biblio_sum";

            // 2009/10/10 changed
            StreamUtil.WriteText(strFileName,
                IndentString(3) + "<tr class='content" + strBiblioSum + strOdd + "'><!-- 内容行"
                + (bBiblioSumLine == true ? "(书目汇总)" : "")
                + (nIndex + 1).ToString() + " -->\r\n");

            StreamUtil.WriteText(strFileName,
                strLineContent);

            StreamUtil.WriteText(strFileName,
                IndentString(3) + "</tr>\r\n");

            return 0;
        }
Example #6
0
        int BuildTextTableLine(PrintOption option,
            List<ListViewItem> items,
            int nIndex,
            StreamWriter sw,
            // ref ExcelDocument doc,
            IXLWorksheet sheet,
            bool bCutText)
        {
            string strError = "";
            int nRet = 0;

            if (nIndex >= items.Count)
            {
                strError = "error: nIndex(" + nIndex.ToString() + ") >= items.Count(" + items.Count.ToString() + ")";
                goto ERROR1;
            }

            ListViewItem item = items[nIndex];
            string strMARC = "";
            string strOutMarcSyntax = "";

            if (this.MarcFilter != null
                || option.HasEvalue() == true)
            {

                // TODO: 有错误要明显报出来,否则容易在打印出来后才发现,就晚了

                // 获得MARC格式书目记录
                string strBiblioRecPath = ListViewUtil.GetItemText(item, COLUMN_BIBLIORECPATH);
                nRet = GetMarc(strBiblioRecPath,
                    out strMARC,
                    out strOutMarcSyntax,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;

                if (this.MarcFilter != null)
                {
                    this.ColumnTable.Clear();   // 清除上一记录处理时残余的内容
                    this.MarcFilter.Host.UiItem = item; // 当前正在处理的 ListViewItem

                    // 触发filter中的Record相关动作
                    nRet = this.MarcFilter.DoRecord(
                        null,
                        strMARC,
                        strOutMarcSyntax,
                        nIndex,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;
                }
            }

            // 栏目内容
            string strLineContent = "";

            // bool bBiblioSumLine = false;    // 是否为种的最后一行(汇总行)
            List<CellData> cells = new List<CellData>();
            int nColIndex = 0;

            for (int i = 0; i < option.Columns.Count; i++)
            {
                Column column = option.Columns[i];
                bool bNumber = false;

                // int nIndex = nPage * option.LinesPerPage + nLine;

                /*
                if (nIndex >= items.Count)
                    break;

                ListViewItem item = items[nIndex];
                 * */
                string strContent = "";
                if (string.IsNullOrEmpty(column.Evalue) == false)
                {
                    Jurassic.ScriptEngine engine = new Jurassic.ScriptEngine();
                    engine.EnableExposedClrTypes = true;
                    engine.SetGlobalValue("syntax", strOutMarcSyntax);
                    engine.SetGlobalValue("biblio", new MarcRecord(strMARC));
                    strContent = engine.Evaluate(column.Evalue).ToString();

                }
                else
                {
                    strContent = GetColumnContent(item,
                        column.Name);

                    if (strContent == "!!!#")
                    {
                        // strContent = ((nPage * option.LinesPerPage) + nLine + 1).ToString();
                        strContent = (nIndex + 1).ToString();
                        bNumber = true;
                    }

                    if (strContent == "!!!biblioPrice")
                    {
                        // 看看自己是不是处在切换边沿
                        string strCurLineBiblioRecPath = GetColumnContent(item, "biblioRecpath");

                        string strNextLineBiblioRecPath = "";

                        if (nIndex < items.Count - 1)
                        {
                            ListViewItem next_item = items[nIndex + 1];
                            strNextLineBiblioRecPath = GetColumnContent(next_item, "biblioRecpath");
                        }

                        if (strCurLineBiblioRecPath != strNextLineBiblioRecPath)
                        {
                            // 处在切换边沿

                            // 汇总前面的册价格
                            strContent = ComputeBiblioPrice(items, nIndex).ToString();
                            // bBiblioSumLine = true;
                        }
                        else
                        {
                            // 其他普通行
                            strContent = "";    //  "&nbsp;";
                        }

                    }
                }

                if (bCutText == true)
                {
                    // 截断字符串
                    if (column.MaxChars != -1)
                    {
                        if (strContent.Length > column.MaxChars)
                        {
                            strContent = strContent.Substring(0, column.MaxChars);
                            strContent += "...";
                        }
                    }
                }

                if (String.IsNullOrEmpty(strContent) == true)
                    strContent = "";    //  "&nbsp;";

                // string strClass = Global.GetLeft(column.Name);

                if (i != 0)
                    strLineContent += "\t";

                strLineContent += strContent;

                if (sheet != null)
                {
#if NO
                    CellData cell = new CellData(nColIndex++, strContent,
            !bNumber,
            5);
                    cells.Add(cell);
#endif
                    IXLCell cell = sheet.Cell(nIndex + _nTopIndex + 1, nColIndex + 1);
                    if (bNumber == true)
                        cell.Value = strContent;
                    else
                        cell.SetValue(strContent);
                    cell.Style.Alignment.WrapText = true;
                    cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;

                    nColIndex++;
                }
            }

            /*
            if (bBiblioSumLine == false)
            {
                StreamUtil.WriteText(strFileName,
        "<tr class='content'>");
            }
            else
            {
                StreamUtil.WriteText(strFileName,
        "<tr class='content_biblio_sum'>");
            }*/
            if (sw != null)
                sw.WriteLine(strLineContent);

#if NO
            if (doc != null)
                doc.WriteExcelLine(nIndex + _nTopIndex,
                    cells,
                    WriteExcelLineStyle.AutoString);  // WriteExcelLineStyle.None
#endif

            return 0;
        ERROR1:
            if (sw != null)
                sw.WriteLine(strError);
        if (sheet != null)
        {
#if NO
            List<CellData> temp_cells = new List<CellData>();
            temp_cells.Add(new CellData(0, strError));
            doc.WriteExcelLine(nIndex + _nTopIndex, temp_cells);
#endif
            IXLCell cell = sheet.Cell(nIndex + _nTopIndex + 1, 1);
            cell.Value = strError;

        }
            return -1;
        }
Example #7
0
        int BuildHtmlPageTop(PrintOption option,
            Hashtable macro_table,
            string strFileName,
            bool bOutputTable)
        {
            /*
            string strLibraryServerUrl = this.MainForm.AppInfo.GetString(
    "config",
    "circulation_server_url",
    "");
            int pos = strLibraryServerUrl.LastIndexOf("/");
            if (pos != -1)
                strLibraryServerUrl = strLibraryServerUrl.Substring(0, pos);
             * */

            // 2009/10/10 changed
            string strCssUrl = GetAutoCssUrl(option, "accountbook.css");

            string strLink = IndentString(2) + "<link href='" + strCssUrl + "' type='text/css' rel='stylesheet' />\r\n";

            StreamUtil.WriteText(strFileName,
                "<html>\r\n"
                + IndentString(1) + "<head>\r\n" + strLink
                + IndentString(1) + "</head>\r\n"
                + IndentString(1) + "<body>\r\n");

           
            // 页眉
            string strPageHeaderText = option.PageHeader;

            if (String.IsNullOrEmpty(strPageHeaderText) == false)
            {
                strPageHeaderText = StringUtil.MacroString(macro_table,
                    strPageHeaderText);

                StreamUtil.WriteText(strFileName,
                    IndentString(2) + "<div class='pageheader'>" + strPageHeaderText + "</div><!-- 页眉 -->\r\n");

                /*
                StreamUtil.WriteText(strFileName,
                    "<hr class='pageheader' />");
                 * */
            }

            // 表格标题
            string strTableTitleText = option.TableTitle;

            if (String.IsNullOrEmpty(strTableTitleText) == false)
            {

                strTableTitleText = StringUtil.MacroString(macro_table,
                    strTableTitleText);

                StreamUtil.WriteText(strFileName,
                    IndentString(2) + "<div class='tabletitle'>" + strTableTitleText + "</div><!-- 表格标题 -->\r\n");
            }

            if (bOutputTable == true)
            {

                // 表格开始
                StreamUtil.WriteText(strFileName,
                    IndentString(2) + "<table class='table'><!-- 内容表格开始 -->\r\n");   //   border='1'

                // 栏目标题
                StreamUtil.WriteText(strFileName,
                    IndentString(3) + "<tr class='column'><!-- 栏目标题行开始 -->\r\n");

                for (int i = 0; i < option.Columns.Count; i++)
                {
                    Column column = option.Columns[i];

                    string strCaption = column.Caption;

                    // 如果没有caption定义,就挪用name定义
                    if (String.IsNullOrEmpty(strCaption) == true)
                        strCaption = column.Name;

                    string strClass = StringUtil.GetLeft(column.Name);
                    if (strClass.Length > 0 && strClass[0] == '@')
                    {
                        strClass = "ext_" + strClass.Substring(1);
                    }

                    StreamUtil.WriteText(strFileName,
                        IndentString(4) + "<td class='" + strClass + "'>" + strCaption + "</td>\r\n");
                }

                StreamUtil.WriteText(strFileName,
                    IndentString(3) + "</tr><!-- 栏目标题行结束 -->\r\n");

            }

            return 0;
        }
Example #8
0
        // 构造表格标题和标题行
        int WriteTableBegin(
            XmlTextWriter writer,
            PrintOption option,
            Hashtable macro_table)
        {

            // 表格标题
            string strTableTitleText = option.TableTitle;

            if (String.IsNullOrEmpty(strTableTitleText) == false)
            {

                strTableTitleText = StringUtil.MacroString(macro_table,
                    strTableTitleText);

                WriteParagraph(writer, strTableTitleText);
            }

            // <w:tbl>
            writer.WriteStartElement("w", "tbl", m_strWordMlNsUri);

            WriteTableProperty(writer);

            // <w:tr>
            writer.WriteStartElement("w", "tr", m_strWordMlNsUri);

            for (int i = 0; i < option.Columns.Count; i++)
            {
                Column column = option.Columns[i];

                string strCaption = column.Caption;

                // 如果没有caption定义,就挪用name定义
                if (String.IsNullOrEmpty(strCaption) == true)
                    strCaption = column.Name;

                // string strClass = Global.GetLeft(column.Name);

                // <w:tc>
                writer.WriteStartElement("w", "tc", m_strWordMlNsUri);

                WriteParagraph(writer, strCaption);

                // <w:tc>
                writer.WriteEndElement();
            }

            // <w:tr>
            writer.WriteEndElement();

            return 0;
        }
Example #9
0
        // 构造表格标题和标题行
        int BuildTextPageTop(PrintOption option,
            Hashtable macro_table,
            StreamWriter sw,
            // ref ExcelDocument doc
            IXLWorksheet sheet
            )
        {
            // 表格标题
            string strTableTitleText = option.TableTitle;

            if (String.IsNullOrEmpty(strTableTitleText) == false)
            {

                strTableTitleText = StringUtil.MacroString(macro_table,
                    strTableTitleText);

                if (sw != null)
                {
                    sw.WriteLine(strTableTitleText);
                    sw.WriteLine("");
                }

                if (sheet != null)
                {
#if NO
                    doc.WriteExcelTitle(0,
    option.Columns.Count,  // nTitleCols,
    strTableTitleText,
    6);
#endif
                    var header = sheet.Range(1, 1,
                        1, option.Columns.Count).Merge();
                    header.Value = strTableTitleText;
                    header.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
                    // header.Style.Font.FontName = "微软雅黑";
                    header.Style.Font.Bold = true;
                    header.Style.Font.FontSize = 16;
                }
            }

            string strColumnTitleLine = "";

            List<int> widths = new List<int>();

            for (int i = 0; i < option.Columns.Count; i++)
            {
                Column column = option.Columns[i];

                widths.Add(column.WidthChars);

                string strCaption = column.Caption;

                // 如果没有caption定义,就挪用name定义
                if (String.IsNullOrEmpty(strCaption) == true)
                    strCaption = column.Name;

                // string strClass = Global.GetLeft(column.Name);

                if (i != 0)
                    strColumnTitleLine += "\t";

                strColumnTitleLine += strCaption;

                if (sheet != null)
                {
#if NO
                                    doc.WriteExcelCell(
            2,
            i,
            strCaption,
            true);
#endif
                    var cell = sheet.Cell(2+1, i+1);
                    cell.Value = strCaption;
                    // cell.Style.Font.FontName = "微软雅黑";
                    cell.Style.Font.Bold = true;

                    if (column.WidthChars != -1)
                        sheet.Column(i + 1).Width = column.WidthChars;
                }
            }

            if (sw != null)
                sw.WriteLine(strColumnTitleLine);

#if NO
            if (doc != null)
                SetColumnWidth(doc, widths);
#endif


            return 0;
        }
Example #10
0
        int BuildPageTop(PrintOption option,
            Hashtable macro_table,
            string strFileName,
            bool bOutputTable)
        {
            /*
            string strLibraryServerUrl = this.MainForm.AppInfo.GetString(
    "config",
    "circulation_server_url",
    "");
            int pos = strLibraryServerUrl.LastIndexOf("/");
            if (pos != -1)
                strLibraryServerUrl = strLibraryServerUrl.Substring(0, pos);
             * */

            // string strCssUrl = this.MainForm.LibraryServerDir + "/itemhandover.css";
            // 2009/10/10 changed
            string strCssUrl = GetAutoCssUrl(option, "itemhandover.css");

            /*
            // 2009/10/9
            string strCssFilePath = option.GetTemplatePageFilePath("css");  // 大小写不敏感
            if (String.IsNullOrEmpty(strCssFilePath) == false)
                strCssUrl = strCssFilePath;
            else
                strCssUrl = this.MainForm.LibraryServerDir + "/itemhandover.css";    // 缺省的
             * */

            string strLink = "<link href='" + strCssUrl + "' type='text/css' rel='stylesheet' />";

            StreamUtil.WriteText(strFileName,
                "<html><head>" + strLink + "</head><body>");


            // 页眉
            string strPageHeaderText = option.PageHeader;

            if (String.IsNullOrEmpty(strPageHeaderText) == false)
            {
                strPageHeaderText = StringUtil.MacroString(macro_table,
                    strPageHeaderText);

                StreamUtil.WriteText(strFileName,
                    "<div class='pageheader'>" + strPageHeaderText + "</div>");

                /*
                StreamUtil.WriteText(strFileName,
                    "<hr class='pageheader' />");
                 * */
            }

            // 表格标题
            string strTableTitleText = option.TableTitle;

            if (String.IsNullOrEmpty(strTableTitleText) == false)
            {

                strTableTitleText = StringUtil.MacroString(macro_table,
                    strTableTitleText);

                StreamUtil.WriteText(strFileName,
                    "<div class='tabletitle'>" + strTableTitleText + "</div>");
            }

            if (bOutputTable == true)
            {
                // 表格开始
                StreamUtil.WriteText(strFileName,
                    "<table class='table'>");   //   border='1'

                // 栏目标题
                StreamUtil.WriteText(strFileName,
                    "<tr class='column'>");

                for (int i = 0; i < option.Columns.Count; i++)
                {
                    Column column = option.Columns[i];

                    string strCaption = column.Caption;

                    // 如果没有caption定义,就挪用name定义
                    if (String.IsNullOrEmpty(strCaption) == true)
                        strCaption = column.Name;

                    string strClass = StringUtil.GetLeft(column.Name);

                    StreamUtil.WriteText(strFileName,
                        "<td class='" + strClass + "'>" + strCaption + "</td>");
                }

                StreamUtil.WriteText(strFileName,
                    "</tr>");

            }

            return 0;
        }
Example #11
0
        int BuildWordXmlTableLine(PrintOption option,
            List<ListViewItem> items,
            int nIndex,
            XmlTextWriter writer,
            bool bCutText)
        {
            string strError = "";
            int nRet = 0;

            if (nIndex >= items.Count)
            {
                strError = "error: nIndex(" + nIndex.ToString() + ") >= items.Count(" + items.Count.ToString() + ")";
                goto ERROR1;
            }

            ListViewItem item = items[nIndex];
            string strMARC = "";
            string strOutMarcSyntax = "";

            if (this.MarcFilter != null
                || option.HasEvalue() == true)
            {

                // TODO: 有错误要明显报出来,否则容易在打印出来后才发现,就晚了

                // 获得MARC格式书目记录
                string strBiblioRecPath = ListViewUtil.GetItemText(item, COLUMN_BIBLIORECPATH);
                nRet = GetMarc(strBiblioRecPath,
                    out strMARC,
                    out strOutMarcSyntax,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;

                if (this.MarcFilter != null)
                {
                    this.ColumnTable.Clear();   // 清除上一记录处理时残余的内容
                    this.MarcFilter.Host.UiItem = item; // 当前正在处理的 ListViewItem

                    // 触发filter中的Record相关动作
                    nRet = this.MarcFilter.DoRecord(
                        null,
                        strMARC,
                        strOutMarcSyntax,
                        nIndex,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;
                }
            }

            // <w:tr>
            writer.WriteStartElement("w", "tr", m_strWordMlNsUri);

            for (int i = 0; i < option.Columns.Count; i++)
            {
                Column column = option.Columns[i];

                // int nIndex = nPage * option.LinesPerPage + nLine;

                /*
                if (nIndex >= items.Count)
                    break;

                ListViewItem item = items[nIndex];
                 * */

                string strContent = "";
                if (string.IsNullOrEmpty(column.Evalue) == false)
                {
                    Jurassic.ScriptEngine engine = new Jurassic.ScriptEngine();
                    engine.EnableExposedClrTypes = true;
                    engine.SetGlobalValue("syntax", strOutMarcSyntax);
                    engine.SetGlobalValue("biblio", new MarcRecord(strMARC));
                    strContent = engine.Evaluate(column.Evalue).ToString();
                }
                else
                {
                    strContent = GetColumnContent(item,
                        column.Name);

                    if (strContent == "!!!#")
                    {
                        // strContent = ((nPage * option.LinesPerPage) + nLine + 1).ToString();
                        strContent = (nIndex + 1).ToString();
                    }

                    if (strContent == "!!!biblioPrice")
                    {
                        // 看看自己是不是处在切换边沿
                        string strCurLineBiblioRecPath = GetColumnContent(item, "biblioRecpath");

                        string strNextLineBiblioRecPath = "";

                        if (nIndex < items.Count - 1)
                        {
                            ListViewItem next_item = items[nIndex + 1];
                            strNextLineBiblioRecPath = GetColumnContent(next_item, "biblioRecpath");
                        }

                        if (strCurLineBiblioRecPath != strNextLineBiblioRecPath)
                        {
                            // 处在切换边沿

                            // 汇总前面的册价格
                            strContent = ComputeBiblioPrice(items, nIndex).ToString();
                            // bBiblioSumLine = true;
                        }
                        else
                        {
                            // 其他普通行
                            strContent = "";    //  "&nbsp;";
                        }
                    }
                }

                if (bCutText == true)
                {
                    // 截断字符串
                    if (column.MaxChars != -1)
                    {
                        if (strContent.Length > column.MaxChars)
                        {
                            strContent = strContent.Substring(0, column.MaxChars);
                            strContent += "...";
                        }
                    }
                }

                if (String.IsNullOrEmpty(strContent) == true)
                    strContent = "";    //  "&nbsp;";

                // string strClass = Global.GetLeft(column.Name);

                // <w:tc>
                writer.WriteStartElement("w", "tc", m_strWordMlNsUri);

                WriteParagraph(writer, strContent);

                // <w:tc>
                writer.WriteEndElement();
            }

            /*
            if (bBiblioSumLine == false)
            {
                StreamUtil.WriteText(strFileName,
        "<tr class='content'>");
            }
            else
            {
                StreamUtil.WriteText(strFileName,
        "<tr class='content_biblio_sum'>");
            }*/

            // <w:tr>
            writer.WriteEndElement();
            // sw.WriteLine(strLineContent);
            return 0;
        ERROR1:
            // <w:tr>
            writer.WriteStartElement("w", "tr", m_strWordMlNsUri);

            // <w:tc>
            writer.WriteStartElement("w", "tc", m_strWordMlNsUri);

            WriteParagraph(writer, strError);

            // <w:tc>
            writer.WriteEndElement();

            // <w:tr>
            writer.WriteEndElement();

            return -1;
        }
Example #12
0
        int BuildTableLine(PrintOption option,
            List<ListViewItem> items,
            string strFileName,
            int nPage,
            int nLine)
        {
            // 栏目内容
            string strLineContent = "";

            bool bBiblioSumLine = false;    // 是否为种的最后一行(汇总行)

            for (int i = 0; i < option.Columns.Count; i++)
            {
                Column column = option.Columns[i];

                int nIndex = nPage * option.LinesPerPage + nLine;

                if (nIndex >= items.Count)
                    break;

                ListViewItem item = items[nIndex];

                string strContent = GetColumnContent(item,
                    column.Name);

                if (strContent == "!!!#")
                    strContent = ((nPage * option.LinesPerPage) + nLine + 1).ToString();

                if (strContent == "!!!biblioPrice")
                {
                    // 看看自己是不是处在切换边沿
                    string strCurLineBiblioRecPath = GetColumnContent(item, "biblioRecpath");

                    string strNextLineBiblioRecPath = "";

                    if (nIndex < items.Count - 1)
                    {
                        ListViewItem next_item = items[nIndex + 1];
                        strNextLineBiblioRecPath = GetColumnContent(next_item, "biblioRecpath");
                    }

                    if (strCurLineBiblioRecPath != strNextLineBiblioRecPath)
                    {
                        // 处在切换边沿

                        // 汇总前面的册价格
                        strContent = ComputeBiblioPrice(items, nIndex).ToString();
                        bBiblioSumLine = true;
                    }
                    else
                    {
                        // 其他普通行
                        strContent = "&nbsp;";
                    }


                }

                // 截断字符串
                if (column.MaxChars != -1)
                {
                    if (strContent.Length > column.MaxChars)
                    {
                        strContent = strContent.Substring(0, column.MaxChars);
                        strContent += "...";
                    }
                }

                if (String.IsNullOrEmpty(strContent) == true)
                    strContent = "&nbsp;";

                string strClass = StringUtil.GetLeft(column.Name);

                strLineContent +=
                    "<td class='" + strClass + "'>" + strContent + "</td>";
            }

            if (bBiblioSumLine == false)
            {
                StreamUtil.WriteText(strFileName,
        "<tr class='content'>");
            }
            else
            {
                StreamUtil.WriteText(strFileName,
        "<tr class='content_biblio_sum'>");
            }

            StreamUtil.WriteText(strFileName,
    strLineContent);

            StreamUtil.WriteText(strFileName,
                "</tr>");

            return 0;
        }
Example #13
0
        // 构造下属成员的详情表格
        // return:
        //      实际到达的成员册数
        int BuildMembersTable(
            // string strFilename,
            PrintOption option,
            Hashtable macro_table,
            ListViewItem parent_item,
            out string strResult,
            out string strError)
        {
            strError = "";
            strResult = "";


            OriginItemData data = (OriginItemData)parent_item.Tag;
            Debug.Assert(data != null, "");

            if (String.IsNullOrEmpty(data.Xml) == true)
            {
                strError = "data.Xml为空";
                return -1;
            }

            // 将item record xml装入DOM,然后select出每个<item>元素
            XmlDocument dom = new XmlDocument();
            try
            {
                dom.LoadXml(data.Xml);
            }
            catch (Exception ex)
            {
                string strRecPath = ListViewUtil.GetItemText(parent_item, COLUMN_RECPATH);
                strError = "路径为 '" + strRecPath + "' 的册记录XML装入DOM时出错: " + ex.Message;
                return -1;
            }

            XmlNodeList nodes = dom.DocumentElement.SelectNodes("binding/item");
            if (nodes.Count == 0)
                return 0;

            int nArriveCount = 0;   // 到达(并参与了装订的)的册数
            int nMissingCount = 0;  // 缺期的册数
            int nIssueCount = nodes.Count;   // 理论上应含多少册

            // 表格开始
            strResult +=
                "<div class='members_table_title'>所含单册</div>";


            // 表格开始
            strResult +=
                "<table class='members'>";

            // 栏目标题
            strResult +=
                "<tr class='column'>";

            for (int i = 0; i < option.Columns.Count; i++)
            {
                Column column = option.Columns[i];

                string strCaption = column.Caption;

                // 如果没有caption定义,就挪用name定义
                if (String.IsNullOrEmpty(strCaption) == true)
                    strCaption = column.Name;

                string strClass = StringUtil.GetLeft(column.Name);

            strResult +=
                    "<td class='" + strClass + "'>" + strCaption + "</td>";
            }

            strResult += "</tr>";

            List<string> missing_volumes = new List<string>();
            for (int i = 0; i < nodes.Count; i++)
            {
                XmlNode node = nodes[i];

                Hashtable value_table = new Hashtable();

                bool bMissing = false;
                // 获得布尔型的属性参数值
                // return:
                //      -1  出错。但是nValue中已经有了nDefaultValue值,可以不加警告而直接使用
                //      0   正常获得明确定义的参数值
                //      1   参数没有定义,因此代替以缺省参数值返回
                DomUtil.GetBooleanParam(node,
                    "missing",
                    false,
                    out bMissing,
                    out strError);
                /*
                if (bMissing == true)
                    continue;
                 * */

                if (bMissing == true)
                    nMissingCount++;
                else
                    nArriveCount++;

                string strRefID = DomUtil.GetAttr(node, "refID");
                string strVolumeString = DomUtil.GetAttr(node, "volume");
                string strPublishTime = DomUtil.GetAttr(node, "publishTime");
                string strBarcode = DomUtil.GetAttr(node, "barcode");
                string strRegisterNo = DomUtil.GetAttr(node, "registerNo");

                if (bMissing == true)
                {
                    // 年
                    string strYear = IssueUtil.GetYearPart(strPublishTime);
                    missing_volumes.Add("y." + strYear + "," + strVolumeString);
                }

                value_table["%missing%"] = bMissing == true ? "缺" : "";
                value_table["%refID%"] = strRefID;
                value_table["%volume%"] = strVolumeString;
                value_table["%publishTime%"] = BindingControl.GetDisplayPublishTime(strPublishTime);
                if (String.IsNullOrEmpty(strBarcode) == false)
                    value_table["%barcode%"] = strBarcode;
                if (String.IsNullOrEmpty(strRegisterNo) == false)
                    value_table["%registerNo%"] = strRegisterNo;

                if (bMissing == true)
                    strResult += "<tr class='content missing'>";
                else
                    strResult += "<tr class='content'>";

                for (int j = 0; j < option.Columns.Count; j++)
                {
                    Column column = option.Columns[j];

                    List<Hashtable> value_tables = new List<Hashtable>();
                    value_tables.Add(value_table);
                    value_tables.Add(macro_table);
                    value_tables.Add(this.ColumnTable);

                    string strContent = GetColumnContent(value_tables,
                        strRefID,
                        StringUtil.GetLeft(column.Name));

                    string strClass = StringUtil.GetLeft(column.Name);
            strResult +=
                        "<td class='" + strClass + "'>" + strContent + "</td>";

                }

                strResult += "</tr>";
            }


            // 表格结束
            strResult +=
                "</table>";

            macro_table["%arrivecount%"] = nArriveCount.ToString();
            macro_table["%missingcount%"] = nMissingCount.ToString();
            macro_table["%issuecount%"] = nIssueCount.ToString();
            macro_table["%missingvolume%"] = BuildVolumeRangeString(missing_volumes);

            return nArriveCount;
        }
Example #14
0
        int BuildPageBottom(PrintOption option,
            Hashtable macro_table,
            string strFileName)
        {

            // 页脚
            string strPageFooterText = option.PageFooter;

            if (String.IsNullOrEmpty(strPageFooterText) == false)
            {
                strPageFooterText = StringUtil.MacroString(macro_table,
                    strPageFooterText);

                StreamUtil.WriteText(strFileName,
        "<div class='pagefooter'>" + strPageFooterText + "</div>");
            }

            StreamUtil.WriteText(strFileName, "</body></html>");

            return 0;
        }
Example #15
0
        int BuildPageTop(PrintOption option,
    Hashtable macro_table,
    string strFileName)
        {
            string strCssUrl = GetAutoCssUrl(option, "printbinding.css");
            string strLink = "<link href='" + strCssUrl + "' type='text/css' rel='stylesheet' />";

            StreamUtil.WriteText(strFileName,
                "<!DOCTYPE html PUBLIC \" -//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
                + "<html><head>" + strLink + "</head><body>");

            // 页眉
            string strPageHeaderText = option.PageHeader;

            if (String.IsNullOrEmpty(strPageHeaderText) == false)
            {
                strPageHeaderText = StringUtil.MacroString(macro_table,
                    strPageHeaderText);

                StreamUtil.WriteText(strFileName,
                    "<div class='pageheader'>" + strPageHeaderText + "</div>");
            }

            /*
            // 书商名称
            StreamUtil.WriteText(strFileName,
    "<div class='seller'>" + GetPureSellerName(seller.Seller) + "</div>");
             * */

            return 0;
        }
Example #16
0
        int BuildTableLine(PrintOption option,
    List<ListViewItem> items,
    string strFileName,
    int nPage,
    int nLine)
        {
            int nIndex = nPage * option.LinesPerPage + nLine;

            if (nIndex >= items.Count)
                return 0;

            ListViewItem item = items[nIndex];

            string strAmerceOperator = "";
            string strSumContent = "";
            int nItemCount = 0;
            if (item == null)
            {
                // 汇总前面的价格
                strSumContent = ComputeSameAmerceOperatorSumPrice(items, nIndex, out strAmerceOperator, out nItemCount).ToString();
            }

            // 栏目内容
            string strLineContent = "";

            for (int i = 0; i < option.Columns.Count; i++)
            {
                Column column = option.Columns[i];

                string strContent = "";

                // 表示需要打印小计行
                if (item == null)
                {
                    string strColumnName = StringUtil.GetLeft(column.Name);
                    if (strColumnName == "price"
                        || strColumnName == "金额")
                    {
                        strContent = strAmerceOperator + " 共 " + nItemCount.ToString() + "项 小计:" + strSumContent;
                    }
                    else if (strColumnName == "amerceOperator"
                        || strColumnName == "收费者")
                    {
                        strContent = strAmerceOperator;
                    }
                }
                else
                {
                    strContent = GetColumnContent(item,
                        column.Name);
                }

                if (strContent == "!!!#")
                    strContent = ((nPage * option.LinesPerPage) + nLine + 1).ToString();

                // 截断字符串
                if (column.MaxChars != -1)
                {
                    if (strContent.Length > column.MaxChars)
                    {
                        strContent = strContent.Substring(0, column.MaxChars);
                        strContent += "...";
                    }
                }

                if (String.IsNullOrEmpty(strContent) == true)
                    strContent = "&nbsp;";

                string strClass = StringUtil.GetLeft(column.Name);

                strLineContent +=
                    "<td class='" + strClass + "'>" + strContent + "</td>";
            }

            if (item != null)
            {
                StreamUtil.WriteText(strFileName,
                    "<tr class='content'>");
            }
            else
            {
                StreamUtil.WriteText(strFileName,
                    "<tr class='content_amerceoperator_sum'>");
            }

            StreamUtil.WriteText(strFileName,
                strLineContent);

            StreamUtil.WriteText(strFileName,
                "</tr>");

            return 0;
        }