dp2
dp2 copied to clipboard
统计方案“借阅排行[分馆]”改写
因最新版 dp2circulation 中 OperLogStatisForm 的 Channel 成员被废止,统计方案“借阅排行[分馆]”需改写。
main.cs 内容如下:
// *** 借阅排行[分馆] ***
// 修改历史:
// 2013/12/25 创建
// 2013/12/26 增加未借出图书的表格
// 2022/1/10 用 GetChannel() 获得 channel
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.IO;
using System.Text;
using System.Xml;
using System.Diagnostics;
using System.Drawing; // Size
using dp2Circulation;
using DigitalPlatform;
using DigitalPlatform.Xml;
using DigitalPlatform.Text;
using DigitalPlatform.dp2.Statis;
using DigitalPlatform.CirculationClient;
public class MyStatis : OperLogStatis
{
TableCollection tables = new TableCollection();
#if NO
Table tableDepartment = new Table(1); // 按单位
Table tableReader = new Table(3); // 按读者(人)
// 列定义:条码 姓名 单位 册次
Table tableBook = new Table(2); // 按图书(种)
// 列定义:种记录路径 摘要 册次
Table tableClass = new Table(1); // 按图书(分类)
// 列定义:类目 册次
#endif
List<string> ClassNames = null; // 类名列表
int m_nDepartmentTableMaxLine = -1;
int m_nReaderTableMaxLine = 100;
int m_nBookTableMaxLine = 100;
int m_nNotBorrowBookTableMaxLine = -1;
bool m_bFixClassColumn = true; // 图书分类报表:恒定类目列
bool m_bBiblioClass = false; // 图书分类报表:是否从书目记录中获得分类号 (否则从册记录中的索取号中获得)
public override void OnBegin(object sender, StatisEventArgs e)
{
this.ClearConsoleForPureTextOutputing();
// 获得输入参数
HtmlInputDialog window = new HtmlInputDialog();
window.Text = "借阅排行 -- 指定输出特性";
window.Url = this.ProjectDir + "\\input.html";
window.Size = new Size(700, 500);
window.ShowDialog();
if (window.DialogResult != DialogResult.OK)
{
e.Continue = ContinueType.SkipAll;
return;
}
// MessageBox.Show(window.SubmitUrl);
string strError = "";
if (window.SubmitUrl == "action://ok/")
{
string strValue = window.SubmitResult["DepartmentTableMaxLine"];
try
{
this.m_nDepartmentTableMaxLine = Convert.ToInt32(strValue);
}
catch
{
strError = "参数DepartmentTableMaxLine '" + strValue + "' 格式错误";
goto ERROR1;
}
strValue = window.SubmitResult["ReaderTableMaxLine"];
try
{
this.m_nReaderTableMaxLine = Convert.ToInt32(strValue);
}
catch
{
strError = "参数ReaderTableMaxLine '" + strValue + "' 格式错误";
goto ERROR1;
}
strValue = window.SubmitResult["BookTableMaxLine"];
try
{
this.m_nBookTableMaxLine = Convert.ToInt32(strValue);
}
catch
{
strError = "参数BookTableMaxLine '" + strValue + "' 格式错误";
goto ERROR1;
}
strValue = window.SubmitResult["NotBorrowBookTableMaxLine"];
try
{
this.m_nNotBorrowBookTableMaxLine = Convert.ToInt32(strValue);
}
catch
{
strError = "参数 NotBorrowBookTableMaxLine '" + strValue + "' 格式错误";
goto ERROR1;
}
this.m_bFixClassColumn = (window.SubmitResult["FixClassColumn"] == "true");
this.m_bBiblioClass = (window.SubmitResult["BiblioClass"] == "true" || window.SubmitResult["BiblioClass"] == "on");
}
else
{
e.Continue = ContinueType.SkipAll;
return;
}
string strClassNameFilename = this.ProjectDir + "\\class.txt";
LoadClassNames(strClassNameFilename);
return;
ERROR1:
MessageBox.Show(this.OperLogStatisForm, strError);
}
public override void OnRecord(object sender, StatisEventArgs e)
{
string strError = "";
int nRet = 0;
XmlDocument dom = new XmlDocument();
try
{
dom.LoadXml(this.Xml);
}
catch (Exception ex)
{
strError = "Load Xml to DOM error: " + ex.Message;
goto ERROR1;
}
this.WriteTextToConsole(this.CurrentLogFileName + ":" + this.CurrentRecordIndex.ToString() + "\r\n");
string strOperation = DomUtil.GetElementText(dom.DocumentElement, "operation");
string strAction = DomUtil.GetElementText(dom.DocumentElement, "action");
if (strOperation != "borrow" && strOperation != "return")
return;
string strOperator = DomUtil.GetElementText(dom.DocumentElement, "operator");
string strAccessClass = ""; // 索书号中的分类号
string strBiblioRecPath = ""; // 书目记录路径
string strLocation = ""; // 册馆藏地点
XmlNode nodeItem = null;
string strItemXml = DomUtil.GetElementText(dom.DocumentElement,
"itemRecord", out nodeItem);
string strItemRecPath = "";
if (nodeItem != null)
strItemRecPath = DomUtil.GetAttr(nodeItem, "recPath");
if (String.IsNullOrEmpty(strItemXml) == false
&& nodeItem != null)
{
// this.WriteTextToConsole( strItemRecPath + "\r\n");
// 从册记录中提取<parent>
XmlDocument itemdom = new XmlDocument();
itemdom.LoadXml(strItemXml);
string strParentID = DomUtil.GetElementText(itemdom.DocumentElement,
"parent");
strBiblioRecPath = BuildBiblioRecPath(strItemRecPath, strParentID);
strLocation = DomUtil.GetElementText(itemdom.DocumentElement,
"location");
strLocation = StringUtil.GetPureLocation(strLocation);
if (this.m_bBiblioClass == true)
{
if (strBiblioRecPath != null)
{
string strResultValue = "";
nRet = this.OperLogStatisForm.GetBiblioPart(strBiblioRecPath,
null, // strInputXml
"@class",
out strResultValue,
out strError);
if (nRet == -1)
{
// strResultValue = "?";
if (string.IsNullOrEmpty(strError) == true)
strError = strResultValue;
goto ERROR1;
}
// this.WriteTextToConsole("class:" + strResultValue + "\r\n");
if (String.IsNullOrEmpty(strResultValue) == true)
strResultValue = "?";
strAccessClass = GetClassName(strResultValue);
}
}
else
{
// 从册记录的索取号中获得分类号部分
string strAccessNo = DomUtil.GetElementText(itemdom.DocumentElement,
"accessNo");
strAccessNo = StringUtil.BuildLocationClassEntry(strAccessNo);
// 丢掉'/'后面的部分
nRet = strAccessNo.IndexOf("/");
if (nRet != -1)
strAccessNo = strAccessNo.Substring(0, nRet);
strAccessClass = GetClassName(strAccessNo);
}
}
if (strBiblioRecPath == null)
{
this.WriteTextToConsole(this.CurrentLogFileName + ":" + this.CurrentRecordIndex.ToString() + "没有书目记录路径\r\n");
strBiblioRecPath = "?";
}
XmlNode nodeReader = null;
string strReaderXml = DomUtil.GetElementText(dom.DocumentElement,
"readerRecord", out nodeReader);
string strReaderRecPath = DomUtil.GetAttr(nodeReader, "recPath");
string strReaderDbName = Global.GetDbName(strReaderRecPath);
string strReaderBarcode = "?";
string strReaderName = "?";
string strDepartment = "?";
if (String.IsNullOrEmpty(strReaderXml) == false
&& nodeReader != null)
{
// string strReaderRecPath = DomUtil.GetAttr(nodeReader, "recPath");
// 从读者记录中提取各种信息
XmlDocument readerdom = new XmlDocument();
readerdom.LoadXml(strReaderXml);
strReaderBarcode = DomUtil.GetElementText(readerdom.DocumentElement,
"barcode");
strReaderName = DomUtil.GetElementText(readerdom.DocumentElement,
"name");
strDepartment = DomUtil.GetElementText(readerdom.DocumentElement,
"department");
}
if (strOperation == "borrow" && strAction != "renew")
{
// 借阅量
// 按部门
this.tables.IncValue("department_" + strReaderDbName, strDepartment, 0, 1, 1);
// 按读者
this.tables.IncValue("reader_" + strReaderDbName, strReaderBarcode, 2, 1, 1);
// 按图书种
this.tables.IncValue("book_" + strLocation, strBiblioRecPath, 1, 1, 1);
// 按图书分类
this.tables.IncValue("class_" + strLocation, strAccessClass, 0, 1, 1);
// 因为类目可能互相重叠,所以Report那里计算的合计是不准确的,必须在统计过程中累加
this.tables.IncValue("class_" + strLocation, "合计", 0, 1, 1);
// 按照馆藏地点、每种,累计被借阅次数
this.tables.IncValue("item_" + strLocation, strItemRecPath, 0, 1, 1);
/*
// 需要将类号变换为列号
// 借阅册 列号0
table.IncValue(strAccessClass, 0, 1, 1);
*/
}
if (strOperation == "borrow" && strAction == "renew")
{
// 续借册 列号2
}
if (strOperation == "return" && strAction == "return")
{
// 还书册 列号4
}
return;
ERROR1:
DialogResult result = MessageBox.Show(this.OperLogStatisForm,
strError + "\r\n\r\n是否继续处理?",
"统计",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1);
if (result == DialogResult.No)
e.Continue = ContinueType.SkipAll;
}
public override void OnEnd(object sender, StatisEventArgs e)
{
int nRet = 0;
string strError = "";
var channel = this.OperLogStatisForm.GetChannel();
try
{
string strDeleteComment = "";
// *** 按部门
List<string> names = this.tables.GetNames("department_");
names.Sort();
foreach (string strName in names)
{
this.OperLogStatisForm.Progress.SetMessage("正在处理表格 " + strName + " ...");
string strReaderDbName = strName.Substring("department_".Length);
Table tableDepartment = this.tables.GetTable(strName);
tableDepartment.Sort("0:d");
// 删除多余的行
strDeleteComment = "内容共 " + tableDepartment.Count.ToString() + " 行";
if (this.m_nDepartmentTableMaxLine != -1
&& tableDepartment.Count > this.m_nDepartmentTableMaxLine)
{
tableDepartment.RemoveLines(this.m_nDepartmentTableMaxLine);
strDeleteComment += "; 只保留了前 " + this.m_nDepartmentTableMaxLine.ToString() + "行";
}
Report report = Report.BuildReport(tableDepartment,
"部门||department,借书(册)||borrowitem",
" ",
true);
if (report != null)
{
string strHead = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head>"
+ "<meta http-equiv='Content-Type' content=\"text/html; charset=utf-8\">"
+ "<title></title>"
+ "<link rel='stylesheet' href='" + this.ProjectDir + "/style_department.css' type='text/css'>"
+ "</head><body>"
+ "<div class='tabletitle'>借阅排行 按部门 <br/>" + strReaderDbName + "<br/>[" + this.GetTimeRangeString() + "]</div>"
+ "<div class='titlecomment'>" + strDeleteComment + "</div>";
string strTail = "</body></html>";
string strHtml = strHead + report.HtmlTable(tableDepartment) + strTail;
// this.WriteTextToConsole("</pre>" + strHtml);
// 写入输出文件
string strOutputFileName = this.NewOutputFileName();
this.WriteToOutputFile(strOutputFileName,
strHtml,
Encoding.UTF8);
}
}
// *** 按读者
names = this.tables.GetNames("reader_");
names.Sort();
foreach (string strName in names)
{
this.OperLogStatisForm.Progress.SetMessage("正在处理表格 " + strName + " ...");
string strReaderDbName = strName.Substring("reader_".Length);
Table tableReader = this.tables.GetTable(strName);
tableReader.Sort("2:d");
// 删除多余的行
strDeleteComment = "内容共 " + tableReader.Count.ToString() + " 行";
if (this.m_nReaderTableMaxLine != -1
&& tableReader.Count > this.m_nReaderTableMaxLine)
{
tableReader.RemoveLines(this.m_nReaderTableMaxLine);
strDeleteComment += "; 只保留了前 " + this.m_nReaderTableMaxLine.ToString() + "行";
}
// 加入姓名和单位列
this.WriteTextToConsole("正在加入读者姓名和单位列\r\n");
for (int i = 0; i < tableReader.Count; i++)
{
this.OperLogStatisForm.Progress.SetMessage("正在加入 " + (i + 1).ToString() + "/" + tableReader.Count.ToString() + " 个读者姓名和单位,可能需要较长时间 ...");
Line line = tableReader[i];
string strReaderBarcode = line.Entry;
if (String.IsNullOrEmpty(strReaderBarcode) == true
|| strReaderBarcode == "?")
continue;
string strReaderName = "";
string strDepartment = "";
string[] results = null;
string strRecPath = "";
byte[] baTimestamp = null;
nRet = this.OperLogStatisForm.GetReaderInfo(strReaderBarcode,
"xml:noborrowhistory",
out results,
out strRecPath,
out baTimestamp,
out strError);
if (nRet == -1)
{
strReaderName = "***error: " + strError;
goto DOADD;
}
else
{
if (results == null || results.Length == 0)
{
strReaderName = "not found";
goto DOADD;
}
}
// 从读者记录中提取各种信息
XmlDocument readerdom = new XmlDocument();
try
{
readerdom.LoadXml(results[0]);
}
catch (Exception ex)
{
strReaderName = "LOADDOM error: " + ex.Message;
goto DOADD;
}
strReaderName = DomUtil.GetElementText(readerdom.DocumentElement,
"name");
strDepartment = DomUtil.GetElementText(readerdom.DocumentElement,
"department");
/*
this.WriteTextToConsole("---strReaderName=["+strReaderName+"]\r\n");
this.WriteTextToConsole("---strDepartment=["+strDepartment+"]\r\n");
*/
DOADD:
line.SetValue(0, strReaderName);
line.SetValue(1, strDepartment);
}
Report report = Report.BuildReport(tableReader,
"读者证条码||readerbarcode,姓名||readername,单位||department,借书(册)||borrowitem",
" ",
true);
if (report != null)
{
report[1].Sum = false;
report[2].Sum = false;
string strHead = "<html><!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head>"
+ "<meta http-equiv='Content-Type' content=\"text/html; charset=utf-8\">"
+ "<title></title>"
+ "<link rel='stylesheet' href='" + this.ProjectDir + "/style_reader.css' type='text/css'>"
+ "</head><body>"
+ "<div class='tabletitle'>借阅排行 按读者 <br/>" + strReaderDbName + "<br/>[" + this.GetTimeRangeString() + "]</div>"
+ "<div class='titlecomment'>" + strDeleteComment + "</div>";
string strTail = "</body></html>";
string strHtml = strHead + report.HtmlTable(tableReader) + strTail;
// this.WriteTextToConsole("</pre>" + strHtml);
// 写入输出文件
string strOutputFileName = this.NewOutputFileName();
this.WriteToOutputFile(strOutputFileName,
strHtml,
Encoding.UTF8);
}
}
// *** 按图书(种)
names = this.tables.GetNames("book_");
names.Sort();
foreach (string strName in names)
{
this.OperLogStatisForm.Progress.SetMessage("正在处理表格 " + strName + " ...");
string strLocation = strName.Substring("book_".Length);
Table tableBook = this.tables.GetTable(strName);
tableBook.Sort("1:d");
// 删除多余的行
strDeleteComment = "内容共 " + tableBook.Count.ToString() + " 行";
if (this.m_nBookTableMaxLine != -1
&& tableBook.Count > this.m_nBookTableMaxLine)
{
// tableBook.RemoveLines(this.m_nBookTableMaxLine);
strDeleteComment += "; 只保留了前 " + this.m_nBookTableMaxLine.ToString() + "行";
}
if (this.m_nBookTableMaxLine == -1)
this.m_nBookTableMaxLine = tableBook.Count;
// 加入摘要列
this.WriteTextToConsole("正在加入书目摘要列\r\n");
List<string> biblio_recpaths = new List<string>();
for (int i = 0; i < Math.Min(this.m_nBookTableMaxLine, tableBook.Count); i++)
{
Line line = tableBook[i];
biblio_recpaths.Add(line.Entry);
}
BiblioLoader loader = new BiblioLoader();
loader.Channel = channel; // this.OperLogStatisForm.Channel;
loader.Stop = this.OperLogStatisForm.Progress;
loader.Format = "summary";
loader.GetBiblioInfoStyle = GetBiblioInfoStyle.None;
loader.RecPaths = biblio_recpaths;
{
int i = 0;
foreach (BiblioItem item in loader)
{
this.OperLogStatisForm.Progress.SetMessage("正在加入 " + (i + 1).ToString() + "/" + biblio_recpaths.Count.ToString() + " 个书目摘要,可能需要较长时间 ...");
tableBook.SetValue(item.RecPath, 0, item.Content);
i++;
}
}
#if NO
for (int i = 0; i < tableBook.Count; i++)
{
this.OperLogStatisForm.Progress.SetMessage("正在加入 " + (i + 1).ToString() + "/" + tableBook.Count.ToString() + " 个书目摘要,可能需要较长时间 ...");
Line line = tableBook[i];
string strBiblioRecPath = line.Entry;
if (strBiblioRecPath != "?")
{
// 获取书目记录的摘要
string strSummary = "";
string strOutBiblioRecPath = "";
nRet = this.OperLogStatisForm.GetBiblioSummary(
"@bibliorecpath:" + strBiblioRecPath,
"",
"",
out strOutBiblioRecPath,
out strSummary,
out strError);
if (nRet == -1)
strSummary = "***error: " + strError;
line.SetValue(0, strSummary);
}
}
#endif
Report report = Report.BuildReport(tableBook,
"图书种路径||bibliorecpath,书目摘要||summary,借书(册)||borrowitem",
" ",
true);
if (report != null)
{
report[1].Sum = false;
string strHead = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head>"
+ "<meta http-equiv='Content-Type' content=\"text/html; charset=utf-8\">"
+ "<title></title>"
+ "<link rel='stylesheet' href='" + this.ProjectDir + "/style_book.css' type='text/css'>"
+ "</head><body>"
+ "<div class='tabletitle'>借阅排行 按图书(种) <br/>" + strLocation + "<br/>[" + this.GetTimeRangeString() + "]</div>"
+ "<div class='titlecomment'>" + strDeleteComment + "</div>";
string strTail = "</body></html>";
string strHtml = strHead + report.HtmlTable(tableBook, this.m_nBookTableMaxLine) + strTail;
// this.WriteTextToConsole("</pre>" + strHtml);
// 写入输出文件
string strOutputFileName = this.NewOutputFileName();
this.WriteToOutputFile(strOutputFileName,
strHtml,
Encoding.UTF8);
}
}
// *** 按图书(分类)
names = this.tables.GetNames("class_");
names.Sort();
foreach (string strName in names)
{
this.OperLogStatisForm.Progress.SetMessage("正在处理表格 " + strName + " ...");
string strLocation = strName.Substring("class_".Length);
Table tableClass = this.tables.GetTable(strName);
tableClass.Sort("-1:a");
// 在table中确保加入预定义的class行
if (this.m_bFixClassColumn == true
&& this.ClassNames != null)
{
for (int j = 0; j < this.ClassNames.Count; j++)
{
string strClassName = this.ClassNames[j];
tableClass.EnsureLine(strClassName, 1);
}
tableClass.Sort("-1:a");
}
strDeleteComment = "";
Report report = Report.BuildReport(tableClass,
"类目||class,借书(册)||borrowitem",
" ",
false);
if (report != null)
{
string strHead = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head>"
+ "<meta http-equiv='Content-Type' content=\"text/html; charset=utf-8\">"
+ "<title></title>"
+ "<link rel='stylesheet' href='" + this.ProjectDir + "/style_bookclass.css' type='text/css'>"
+ "</head><body>"
+ "<div class='tabletitle'>借阅排行 按图书(分类) <br/>" + strLocation + "<br/>[" + this.GetTimeRangeString() + "]</div>"
+ "<div class='titlecomment'>" + strDeleteComment + "</div>";
string strTail = "</body></html>";
string strHtml = strHead + report.HtmlTable(tableClass) + strTail;
// this.WriteTextToConsole("</pre>" + strHtml);
// 写入输出文件
string strOutputFileName = this.NewOutputFileName();
this.WriteToOutputFile(strOutputFileName,
strHtml,
Encoding.UTF8);
}
}
// *** 没有被借阅过的种
if (m_nNotBorrowBookTableMaxLine != 0)
{
names = this.tables.GetNames("book_");
names.Sort();
foreach (string strName in names)
{
this.OperLogStatisForm.Progress.SetMessage("正在处理表格 " + strName + " ...");
string strLocation = strName.Substring("book_".Length);
Table tableBook = this.tables.GetTable(strName);
List<string> biblio_recpaths = new List<string>();
foreach (string key in tableBook.Keys)
{
biblio_recpaths.Add(key);
}
List<string> all_bibliorecpaths = null;
nRet = ItemSearchForm.SearchOneLocationItems(
this.OperLogStatisForm.MainForm,
channel, // this.OperLogStatisForm.Channel,
this.OperLogStatisForm.Progress,
strLocation,
"bibliorecpath",
out all_bibliorecpaths,
out strError);
if (nRet == -1)
goto ERROR1;
all_bibliorecpaths.Sort();
// StringUtil.RemoveDup(ref all_bibliorecpaths);
biblio_recpaths.Sort();
// StringUtil.RemoveDup(ref biblio_recpaths);
string strDebugInfo = "";
List<string> targetLeft = new List<string>();
List<string> targetMiddle = null;
List<string> targetRight = null;
nRet = StringUtil.LogicOper("SUB",
all_bibliorecpaths,
biblio_recpaths,
ref targetLeft,
ref targetMiddle,
ref targetRight,
false,
out strDebugInfo,
out strError);
if (nRet == -1)
goto ERROR1;
// 删除多余的行
strDeleteComment = "内容共 " + targetLeft.Count.ToString() + " 行 (被借阅过的共有 " + tableBook.Count.ToString() + " 种,此馆藏点全部图书 " + all_bibliorecpaths.Count.ToString()+ " 种)";
if (this.m_nNotBorrowBookTableMaxLine != -1
&& targetLeft.Count > this.m_nNotBorrowBookTableMaxLine)
{
targetLeft.RemoveRange(this.m_nNotBorrowBookTableMaxLine,
targetLeft.Count - this.m_nNotBorrowBookTableMaxLine);
strDeleteComment += "; 只保留了前 " + this.m_nNotBorrowBookTableMaxLine.ToString() + "行";
}
Table temp = new Table(1);
BiblioLoader loader = new BiblioLoader();
loader.Channel = channel; // this.OperLogStatisForm.Channel;
loader.Stop = this.OperLogStatisForm.Progress;
loader.Format = "summary";
loader.GetBiblioInfoStyle = GetBiblioInfoStyle.None;
loader.RecPaths = targetLeft;
int i = 0;
foreach (BiblioItem item in loader)
{
this.OperLogStatisForm.Progress.SetMessage("正在加入 " + (i + 1).ToString() + "/" + targetLeft.Count.ToString() + " 个书目摘要,可能需要较长时间 ...");
temp.SetValue(item.RecPath, 0, item.Content);
i++;
}
temp.Sort("-1:aP");
Report report = Report.BuildReport(temp,
"图书种路径||bibliorecpath,书目摘要||summary",
" ",
true);
if (report != null)
{
report[1].Sum = false;
string strHead = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head>"
+ "<meta http-equiv='Content-Type' content=\"text/html; charset=utf-8\">"
+ "<title></title>"
+ "<link rel='stylesheet' href='" + this.ProjectDir + "/style_book.css' type='text/css'>"
+ "</head><body>"
+ "<div class='tabletitle'>从没有被借阅过的图书 按图书(种) <br/>" + strLocation + "<br/>[" + this.GetTimeRangeString() + "]</div>"
+ "<div class='titlecomment'>" + strDeleteComment + "</div>";
string strTail = "</body></html>";
string strHtml = strHead + report.HtmlTable(temp) + strTail;
// this.WriteTextToConsole("</pre>" + strHtml);
// 写入输出文件
string strOutputFileName = this.NewOutputFileName();
this.WriteToOutputFile(strOutputFileName,
strHtml,
Encoding.UTF8);
}
}
}
}
finally
{
this.OperLogStatisForm.ReturnChannel(channel);
}
this.OperLogStatisForm.Progress.SetMessage("");
this.WriteTextToConsole("输出报表完成。\r\n");
return;
ERROR1:
MessageBox.Show(this.OperLogStatisForm, strError);
}
// 将分类号名称定义从文件读入内存
void LoadClassNames(string strClassNameFile)
{
if (File.Exists(strClassNameFile) == false)
return;
StreamReader sr = null;
try
{
sr = new StreamReader(strClassNameFile, Encoding.ASCII);
}
catch (Exception ex)
{
throw new Exception("打开文件 " + strClassNameFile + " 失败: " + ex.Message);
}
try
{
this.ClassNames = new List<string>();
for (; ; )
{
string strLine = sr.ReadLine();
if (strLine == null)
break;
if (String.IsNullOrEmpty(strLine) == true)
continue;
this.ClassNames.Add(strLine);
}
}
finally
{
sr.Close();
}
}
// 将分类号字符串对预定义的分类号表进行匹配
string GetClassName(string strClassString)
{
if (String.IsNullOrEmpty(strClassString) == true)
return "?";
// 如果没有分类号定义,直接返回分类号头部的1字符
if (this.ClassNames == null
|| this.ClassNames.Count == 0)
return strClassString.Substring(0, 1);
string strHead = "";
string strResult = "";
for (int i = 0; i < this.ClassNames.Count; i++)
{
string strClassName = this.ClassNames[i];
if (strClassString.Length < strClassName.Length)
continue;
if (strHead.Length != strClassName.Length)
strHead = strClassString.Substring(0, strClassName.Length);
if (strHead == strClassName)
{
// 命中了的,长度更长的才进入strResult
if (strResult.Length < strClassName.Length)
strResult = strClassName;
}
}
if (strResult == "")
return "?"; // 没有找到
return strResult;
}
// 根据册记录路径和父(种)记录ID构造出种记录路径
string BuildBiblioRecPath(string strItemRecPath, string strParentID)
{
string strItemDbName = Global.GetDbName(strItemRecPath);
// 根据实体库名获得对应的书目库名
string strBiblioDbName = this.OperLogStatisForm.MainForm.GetBiblioDbNameFromItemDbName(strItemDbName);
if (strBiblioDbName == null)
return null;
return strBiblioDbName + "/" + strParentID;
}
}