Skip to content

Commit

Permalink
改进创建出纳历史库功能
Browse files Browse the repository at this point in the history
  • Loading branch information
DigitalPlatform committed Jan 12, 2016
1 parent 78a9ffb commit eeecda7
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 90 deletions.
1 change: 0 additions & 1 deletion DigitalPlatform.LibraryServer/LibraryApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,6 @@ public int LoadCfg(
goto ERROR1;
}


#if LOG_INFO
app.WriteErrorLog("INFO: ArriveMonitor");
#endif
Expand Down
208 changes: 127 additions & 81 deletions DigitalPlatform.LibraryServer/MongoDb/BuildMongoOperDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ static int ParseLogRecorverStart(string strStart,
return -1;
}


strFileName = strStart.Substring(nRet + 1).Trim();

// 如果文件名没有扩展名,自动加上
Expand Down Expand Up @@ -164,6 +163,22 @@ public override void Worker()
return;
}

// 开始处理时的日期
string strEndDate = DateTimeUtil.DateTimeToString8(DateTime.Now);

// 记忆当前最后一条操作日志记录的位置
// return:
// -1 出错
// 0 日志文件不存在,或者记录数为 0
// >0 记录数
long lRecCount = GetOperLogCount(strEndDate,
out strError);
if (lRecCount == -1)
{
this.AppendResultText("启动失败: " + strError + "\r\n");
return;
}

this.App.WriteErrorLog(this.Name + " 任务启动。");

if (bClearFirst == true)
Expand Down Expand Up @@ -216,8 +231,13 @@ public override void Worker()

if (bStart == true)
{
long lMax = -1;
if (strEndDate + ".log" == strFileName)
lMax = lRecCount;

nRet = DoOneLogFile(strFileName,
lStartIndex,
lMax,
out strError);
if (nRet == -1)
goto ERROR1;
Expand All @@ -226,123 +246,149 @@ public override void Worker()
}

this.AppendResultText("循环结束\r\n");

this.App.WriteErrorLog(this.Name + "恢复 任务结束。");
return;
ERROR1:
return;
}

// 获得一个日志文件中记录的总数
// parameters:
// strDate 日志文件的日期,8 字符
// return:
// -1 出错
// 0 日志文件不存在,或者记录数为 0
// >0 记录数
long GetOperLogCount(string strDate,
out string strError)
{
strError = "";

string strXml = "";
long lRecCount = 0;

string strStyle = "getcount";
long lAttachmentLength = 0;
long lRet = this.App.OperLog.GetOperLog(
"*",
strDate + ".log",
-1, // lIndex,
-1, // lHint,
strStyle,
"", // strFilter
out lRecCount,
out strXml,
out lAttachmentLength,
out strError);
if (lRet == 0)
{
lRecCount = 0;
return 0;
}
if (lRet != 1)
return -1;
Debug.Assert(lRecCount >= 0, "");
return lRecCount;
}

// 处理一个日志文件的恢复任务
// parameters:
// strFileName 纯文件名
// lStartIndex 开始的记录(从0开始计数)
// lMax 最多处理多少个记录。-1 表示全部处理
// return:
// -1 error
// 0 file not found
// 1 succeed
int DoOneLogFile(string strFileName,
long lStartIndex,
long lMax,
out string strError)
{
strError = "";

this.AppendResultText("做文件 " + strFileName + "\r\n");

Debug.Assert(this.App != null, "");
string strTempFileName = this.App.GetTempFileName("logrecover"); // Path.GetTempFileName();
try
long lIndex = 0;
long lHint = -1;
long lHintNext = -1;
for (lIndex = lStartIndex; ; lIndex++)
{
if (this.Stopped == true)
break;

long lIndex = 0;
long lHint = -1;
long lHintNext = -1;
if (lMax != -1 && lIndex >= lMax)
break;

for (lIndex = lStartIndex; ; lIndex++)
string strXml = "";

if (lIndex != 0)
lHint = lHintNext;

SetProgressText(strFileName + " 记录" + (lIndex + 1).ToString());

long lAttachmentLength = 0;
// 获得一个日志记录
// parameters:
// strFileName 纯文件名,不含路径部分
// lHint 记录位置暗示性参数。这是一个只有服务器才能明白含义的值,对于前端来说是不透明的。
// 目前的含义是记录起始位置。
// return:
// -1 error
// 0 file not found
// 1 succeed
// 2 超过范围
int nRet = this.App.OperLog.GetOperLog(
"*",
strFileName,
lIndex,
lHint,
"", // level-0
"", // strFilter
out lHintNext,
out strXml,
out lAttachmentLength, // attachment,
out strError);
if (nRet == -1)
return -1;
if (nRet == 0)
return 0;
if (nRet == 2)
{
if (this.Stopped == true)
break;
// 最后一条补充提示一下
if (((lIndex - 1) % 100) != 0)
this.AppendResultText("做日志记录 " + strFileName + " " + (lIndex).ToString() + "\r\n");
break;
}

string strXml = "";
// 处理一个日志记录

if (lIndex != 0)
lHint = lHintNext;
if ((lIndex % 100) == 0)
this.AppendResultText("做日志记录 " + strFileName + " " + (lIndex + 1).ToString() + "\r\n");

SetProgressText(strFileName + " 记录" + (lIndex + 1).ToString());
/*
// 测试时候在这里安排跳过
if (lIndex == 1 || lIndex == 2)
continue;
* */

using (Stream attachment = File.Create(strTempFileName))
{
// Debug.Assert(!(lIndex == 182 && strFileName == "20071225.log"), "");


long lAttachmentLength = 0;
// 获得一个日志记录
// parameters:
// strFileName 纯文件名,不含路径部分
// lHint 记录位置暗示性参数。这是一个只有服务器才能明白含义的值,对于前端来说是不透明的。
// 目前的含义是记录起始位置。
// return:
// -1 error
// 0 file not found
// 1 succeed
// 2 超过范围
int nRet = this.App.OperLog.GetOperLog(
"*",
strFileName,
lIndex,
lHint,
"", // level-0
"", // strFilter
out lHintNext,
out strXml,
// ref attachment,
attachment,
out strError);
if (nRet == -1)
return -1;
if (nRet == 0)
return 0;
if (nRet == 2)
{
// 最后一条补充提示一下
if (((lIndex - 1) % 100) != 0)
this.AppendResultText("做日志记录 " + strFileName + " " + (lIndex).ToString() + "\r\n");
break;
}

// 处理一个日志记录

if ((lIndex % 100) == 0)
this.AppendResultText("做日志记录 " + strFileName + " " + (lIndex + 1).ToString() + "\r\n");

/*
// 测试时候在这里安排跳过
if (lIndex == 1 || lIndex == 2)
continue;
* */

nRet = DoOperLogRecord(strXml,
attachment,
out strError);
if (nRet == -1)
{
this.AppendResultText("发生错误:" + strError + "\r\n");
return -1;
}
}
nRet = DoOperLogRecord(strXml,
// attachment,
out strError);
if (nRet == -1)
{
this.AppendResultText("发生错误:" + strError + "\r\n");
return -1;
}

return 0;
}
finally
{
File.Delete(strTempFileName);
}

return 0;
}

// 执行一个日志记录的动作
int DoOperLogRecord(string strXml,
Stream attachment,
// Stream attachment,
out string strError)
{
strError = "";
Expand Down
Binary file modified ZipUtil.exe
Binary file not shown.
3 changes: 0 additions & 3 deletions dp2Circulation/Reader/ReaderInfoForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@ public int LoadRecord(string strBarcode,
MessageBoxDefaultButton.Button2);
if (result != DialogResult.Yes)
return 0; // cancelled

}

this.m_nChannelInUse++;
Expand All @@ -525,7 +524,6 @@ public int LoadRecord(string strBarcode,
}
try
{

stop.OnStop += new StopEventHandler(this.DoStop);
stop.Initial("正在装载读者记录 ...");
stop.BeginLoop();
Expand Down Expand Up @@ -651,7 +649,6 @@ public int LoadRecord(string strBarcode,
if (nRet == -1)
goto ERROR1;


// 接着装入对象资源
{
nRet = this.binaryResControl1.LoadObject(
Expand Down
7 changes: 7 additions & 0 deletions dp2Circulation/Statis/ReportForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7909,6 +7909,11 @@ public int TraceReturn(
{
strError = "";

string strAction = DomUtil.GetElementText(domLog.DocumentElement,
"action");
if (strAction == "read")
return 0; // read 动作并不会改变任何册记录,所以这里返回了

//long lRet = 0;
int nRet = 0;

Expand All @@ -7920,6 +7925,8 @@ public int TraceReturn(
return -1;
}



// 读入册记录
string strConfirmItemRecPath = DomUtil.GetElementText(domLog.DocumentElement,
"confirmItemRecPath");
Expand Down
2 changes: 1 addition & 1 deletion dp2Circulation/dp2Circulation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<SuiteName>dp2 V2</SuiteName>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage>
<ApplicationRevision>15</ApplicationRevision>
<ApplicationRevision>16</ApplicationRevision>
<ApplicationVersion>2.10.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand Down
2 changes: 1 addition & 1 deletion dp2Installer/dp2Installer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<SuiteName>dp2 V2</SuiteName>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage>
<ApplicationRevision>76</ApplicationRevision>
<ApplicationRevision>77</ApplicationRevision>
<ApplicationVersion>1.1.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand Down
2 changes: 1 addition & 1 deletion dp2LibraryXE/dp2LibraryXE.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<SuiteName>dp2 V2</SuiteName>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage>
<ApplicationRevision>56</ApplicationRevision>
<ApplicationRevision>57</ApplicationRevision>
<ApplicationVersion>1.1.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand Down
4 changes: 3 additions & 1 deletion dp2LibraryXE/opac_app/Browse.aspx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,12 @@ public void Page_Error(object sender, EventArgs e)
// http://support.microsoft.com/kb/306355
Exception objErr = Server.GetLastError().GetBaseException();

if (objErr is ArgumentException)
if (objErr != null && objErr is ArgumentException)
{
Server.ClearError();
this.SetErrorInfo("请重新点击树节点");
}
#if NO
else
{
string err = "<b>Error Caught in Page_Error event</b><hr><br>" +
Expand All @@ -206,6 +207,7 @@ public void Page_Error(object sender, EventArgs e)
Response.Write(err.ToString());
Server.ClearError();
}
#endif
}

// 设置出错信息
Expand Down
4 changes: 3 additions & 1 deletion dp2OPAC/Browse.aspx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,12 @@ public void Page_Error(object sender, EventArgs e)
// http://support.microsoft.com/kb/306355
Exception objErr = Server.GetLastError().GetBaseException();

if (objErr is ArgumentException)
if (objErr != null && objErr is ArgumentException)
{
Server.ClearError();
this.SetErrorInfo("请重新点击树节点");
}
#if NO
else
{
string err = "<b>Error Caught in Page_Error event</b><hr><br>" +
Expand All @@ -206,6 +207,7 @@ public void Page_Error(object sender, EventArgs e)
Response.Write(err.ToString());
Server.ClearError();
}
#endif
}

// 设置出错信息
Expand Down

0 comments on commit eeecda7

Please sign in to comment.