public bool ReadDataReal(string RealData, Database db, KQTextFormatInfo textFormat, int MacSN, string Version, ref int RecordCount, ref int LogID, ProcessRealData prog) { bool ret = false; RecordCount = 0; LogID = 0; try { ret = DeviceObject.objKS.AttLogDataReal(RealData, Version, ref RecordCount, ref LogID); for (int j = 0; j < RecordCount; j++) { if (DeviceObject.objKS.AttLogDataValue(j, ref attLog)) { WriteTextFile(attLog, MacSN); if (textFormat.Allow) { WriteTextFormat(db, textFormat, attLog, MacSN); } SaveDB(db, attLog, MacSN); if (attLog.IsCount == 0) { RecordCount = RecordCount - 1; } if (prog != null) { prog(attLog, MacSN); } } } } catch (Exception E) { Pub.ShowErrorMsg(E); } return(ret); }
private bool ReadData(Database db, KQTextFormatInfo textFormat, int MacSN, ref int RecordCount, ref int RecordIndex, bool AutoRetry, ProcessReadData prog, ProcessRealData progReal) { RecordCount = 0; RecordIndex = 0; bool ret = false; TRecordCount recCount = new TRecordCount(); if (!DeviceObject.objKS.AttLogCount(IsNew, ref recCount)) { return(false); } RecordCount = recCount.Count; if (RecordCount == 0) { return(true); } DialogResult result; for (int i = 1; i <= recCount.Sector; i++) { RetryReadData: if (IsStop) { DeviceObject.objKS.Close(); break; } Application.DoEvents(); ret = DeviceObject.objKS.AttLogData(SystemInfo.DataFilePath, IsNew, i, ref logCount); if (!ret) { if (AutoRetry) { goto RetryReadData; } result = Pub.MessageBoxQuestion(cap + "\r\n\r\n" + DeviceObject.objKS.ErrMsg + "\r\n\r\n" + msgContinue, MessageBoxButtons.AbortRetryIgnore); if (result == DialogResult.Abort) { break; } else if (result == DialogResult.Ignore) { continue; } else { goto RetryReadData; } } for (int j = 0; j < logCount; j++) { if (RecordIndex >= recCount.Count) { break; } if (DeviceObject.objKS.AttLogDataValue(j, ref attLog)) { WriteTextFile(attLog, MacSN); if (textFormat.Allow) { WriteTextFormat(db, textFormat, attLog, MacSN); } SaveDB(db, attLog, MacSN); if (attLog.IsCount != 0) { RecordIndex = RecordIndex + 1; } if (RecordIndex > recCount.Count) { RecordIndex = recCount.Count; } if (prog != null) { prog(recCount.Count, RecordIndex); } if (progReal != null) { progReal(attLog, MacSN); } } } } if (ret && IsNew && recCount.Count > 0 && !IsStop) { RetryFlag: ret = DeviceObject.objKS.AttLogFlag(recCount.Count); if (!ret) { if (AutoRetry) { goto RetryFlag; } if (!Pub.MessageBoxShowQuestion(cap + "\r\n\r\n" + DeviceObject.objKS.ErrMsg + "\r\n\r\n" + msgContinue)) { goto RetryFlag; } } } return(ret); }
public bool ReadData(Database db, KQTextFormatInfo textFormat, int MacSN, ref int RecordCount, ref int RecordIndex, bool AutoRetry, ProcessRealData prog) { return(ReadData(db, textFormat, MacSN, ref RecordCount, ref RecordIndex, AutoRetry, null, prog)); }