// 对每个日志文件,每个日志记录进行循环 // return: // 0 普通返回 // 1 要全部中断 int DoTask1Loop(out string strError) { strError = ""; int nRet = 0; // long lRet = 0; List <string> LogFileNames = null; // TODO: 是否需要检查起止日期是否为空值?空值是警告还是就当作今天? string strStartDate = DateTimeUtil.DateTimeToString8(this.dateControl_start.Value); string strEndDate = DateTimeUtil.DateTimeToString8(this.dateControl_end.Value); string strWarning = ""; // 根据日期范围,发生日志文件名 // parameters: // strStartDate 起始日期。8字符 // strEndDate 结束日期。8字符 // return: // -1 错误 // 0 成功 nRet = MakeLogFileNames(strStartDate, strEndDate, true, out LogFileNames, out strWarning, out strError); if (nRet == -1) { return(-1); } if (String.IsNullOrEmpty(strWarning) == false) { MessageBox.Show(this, strWarning); } #if NO string strStyle = ""; if (this.MainForm.AutoCacheOperlogFile == true) { strStyle = "autocache"; } #endif ProgressEstimate estimate = new ProgressEstimate(); #if NO nRet = OperLogForm.ProcessFiles(this, stop, estimate, Channel, LogFileNames, this.MainForm.OperLogLevel, strStyle, this.MainForm.OperLogCacheDir, null, // param, procDoRecord, // DoRecord, out strError); if (nRet == -1) { return(-1); } #endif OperLogLoader loader = new OperLogLoader(); loader.Channel = this.Channel; loader.Stop = this.Stop; loader.owner = this; loader.estimate = estimate; loader.FileNames = LogFileNames; loader.nLevel = this.MainForm.OperLogLevel; loader.AutoCache = false; loader.CacheDir = ""; List <OperLogLine> lines = new List <OperLogLine>(); foreach (OperLogItem item in loader) { string strXml = item.Xml; if (string.IsNullOrEmpty(strXml) == true) { continue; } { XmlDocument dom = new XmlDocument(); try { dom.LoadXml(strXml); } catch (Exception ex) { strError = "Load Xml to DOM error: " + ex.Message; return(-1); } string strOperation = DomUtil.GetElementText(dom.DocumentElement, "operation"); if (strOperation != "borrow" && strOperation != "return") { continue; } string strAction = DomUtil.GetElementText(dom.DocumentElement, "action"); string strOperator = DomUtil.GetElementText(dom.DocumentElement, "operator"); #if NO XmlNode nodeItem = null; string strItemXml = DomUtil.GetElementText(dom.DocumentElement, "itemRecord", out nodeItem); string strItemRecPath = ""; if (nodeItem != null) { strItemRecPath = DomUtil.GetAttr(nodeItem, "recPath"); } // 册记录相关的书目记录路径,这个后面统一提取,就不用日志记录中的数据了 #endif XmlNode nodeReader = null; string strReaderXml = DomUtil.GetElementText(dom.DocumentElement, "readerRecord", out nodeReader); string strReaderRecPath = DomUtil.GetAttr(nodeReader, "recPath"); string strReaderDbName = Global.GetDbName(strReaderRecPath); // TODO: 根据读者库名获得馆代码 string strLibraryCode = ""; string strItemBarcode = DomUtil.GetElementText(dom.DocumentElement, "itemBarcode"); string strReaderBarcode = DomUtil.GetElementText(dom.DocumentElement, "readerBarcode"); string strOperTime = DomUtil.GetElementText(dom.DocumentElement, "operTime"); OperLogLine line = new OperLogLine(); line.ItemBarcode = strItemBarcode; // 馆藏地点需要另行获得 line.ReaderBarcode = strReaderBarcode; line.OperTime = strOperTime; line.LibraryCode = strLibraryCode; lines.Add(line); } if (lines.Count > 300) { // 写入数据库一次 lines.Clear(); } } if (lines.Count > 0) { // 写入数据库一次 } return(nRet); }
// 对每个日志文件,每个日志记录进行循环 // return: // 0 普通返回 // 1 要全部中断 int DoTask1Loop(out string strError) { strError = ""; int nRet = 0; // long lRet = 0; List<string> LogFileNames = null; // TODO: 是否需要检查起止日期是否为空值?空值是警告还是就当作今天? string strStartDate = DateTimeUtil.DateTimeToString8(this.dateControl_start.Value); string strEndDate = DateTimeUtil.DateTimeToString8(this.dateControl_end.Value); string strWarning = ""; // 根据日期范围,发生日志文件名 // parameters: // strStartDate 起始日期。8字符 // strEndDate 结束日期。8字符 // return: // -1 错误 // 0 成功 nRet = MakeLogFileNames(strStartDate, strEndDate, true, out LogFileNames, out strWarning, out strError); if (nRet == -1) return -1; if (String.IsNullOrEmpty(strWarning) == false) MessageBox.Show(this, strWarning); #if NO string strStyle = ""; if (this.MainForm.AutoCacheOperlogFile == true) strStyle = "autocache"; #endif ProgressEstimate estimate = new ProgressEstimate(); #if NO nRet = OperLogForm.ProcessFiles(this, stop, estimate, Channel, LogFileNames, this.MainForm.OperLogLevel, strStyle, this.MainForm.OperLogCacheDir, null, // param, procDoRecord, // DoRecord, out strError); if (nRet == -1) return -1; #endif OperLogLoader loader = new OperLogLoader(); loader.Channel = this.Channel; loader.Stop = this.Stop; loader.owner = this; loader.estimate = estimate; loader.FileNames = LogFileNames; loader.nLevel = this.MainForm.OperLogLevel; loader.AutoCache = false; loader.CacheDir = ""; List<OperLogLine> lines = new List<OperLogLine>(); foreach (OperLogItem item in loader) { string strXml = item.Xml; if (string.IsNullOrEmpty(strXml) == true) continue; { XmlDocument dom = new XmlDocument(); try { dom.LoadXml(strXml); } catch (Exception ex) { strError = "Load Xml to DOM error: " + ex.Message; return -1; } string strOperation = DomUtil.GetElementText(dom.DocumentElement, "operation"); if (strOperation != "borrow" && strOperation != "return") continue; string strAction = DomUtil.GetElementText(dom.DocumentElement, "action"); string strOperator = DomUtil.GetElementText(dom.DocumentElement, "operator"); #if NO XmlNode nodeItem = null; string strItemXml = DomUtil.GetElementText(dom.DocumentElement, "itemRecord", out nodeItem); string strItemRecPath = ""; if (nodeItem != null) strItemRecPath = DomUtil.GetAttr(nodeItem, "recPath"); // 册记录相关的书目记录路径,这个后面统一提取,就不用日志记录中的数据了 #endif XmlNode nodeReader = null; string strReaderXml = DomUtil.GetElementText(dom.DocumentElement, "readerRecord", out nodeReader); string strReaderRecPath = DomUtil.GetAttr(nodeReader, "recPath"); string strReaderDbName = Global.GetDbName(strReaderRecPath); // TODO: 根据读者库名获得馆代码 string strLibraryCode = ""; string strItemBarcode = DomUtil.GetElementText(dom.DocumentElement, "itemBarcode"); string strReaderBarcode = DomUtil.GetElementText(dom.DocumentElement, "readerBarcode"); string strOperTime = DomUtil.GetElementText(dom.DocumentElement, "operTime"); OperLogLine line = new OperLogLine(); line.ItemBarcode = strItemBarcode; // 馆藏地点需要另行获得 line.ReaderBarcode = strReaderBarcode; line.OperTime = strOperTime; line.LibraryCode = strLibraryCode; lines.Add(line); } if (lines.Count > 300) { // 写入数据库一次 lines.Clear(); } } if (lines.Count > 0) { // 写入数据库一次 } return nRet; }