public static int OnMsg(int nNodeID, string strRequestString, MainForm mainForm, ref string strRespone) { int nErrorCode = (int)ENUM_GetTaskLogResponseError.eGetTaskLogResponseError_UnknownFailed; // 检查请求合法性 if (!IsValidGetTaskLogMsg(strRequestString, RSAKeyContainer.GetInstance.GetJavaPublicKey())) { // 消息检查未通过 nErrorCode = (int)ENUM_GetTaskLogResponseError.eGetTaskLogResponseError_UnvalidMsg; LOGGER.WARN($"Server get task log request is not a invalid msg. \n Request = {strRequestString}"); } else { SGetTaskLogInfo info = ParseStructFromRequest(strRequestString, RSAKeyContainer.GetInstance.GetCSharpPrivateKey()); if (info.taskID <= 0) { // 消息不正常 nErrorCode = (int)ENUM_GetTaskLogResponseError.eGetTaskLogResponseError_UnvalidTaskId; LOGGER.WARN($"Server get task log request is not a invalid msg. \n Request = {strRequestString} \n TaskInfo = {info.ToLogString()}"); } else { // 消息解析成功,开始逻辑处理 { List <string> strTaskLogFile = FKLog.FKSQLiteLogMgr.GetInstance.GetTaskLogDBFileName(info.taskID); if (strTaskLogFile.Count <= 0) { // 找不到对应的日志文件编号 LOGGER.WARN($"Can't find task log date. TaskID = {info.taskID}"); nErrorCode = (int)ENUM_GetTaskLogResponseError.eGetTaskLogResponseError_CannotFindTaskDB; strRespone = ("{\"detail\":[],\"logCount\":0,\"nodeID\":") + nNodeID + (",\"taskID\":") + info.taskID + (",\"status\":") + nErrorCode + ("}"); return(nErrorCode); } bool bIsAllFileExist = true; string strLostFile = string.Empty; for (int i = 0; i < strTaskLogFile.Count; ++i) { if (!File.Exists(strTaskLogFile[i])) { strLostFile = strTaskLogFile[i]; bIsAllFileExist = false; break; } } if (!bIsAllFileExist) { // 对应的日志文件不存在 LOGGER.WARN($"Log file is not exist. TaskID = {info.taskID}, Lost file = {strLostFile}"); nErrorCode = (int)ENUM_GetTaskLogResponseError.eGetTaskLogResponseError_CannotFindLogDB; strRespone = ("{\"detail\":[],\"logCount\":0,\"nodeID\":") + nNodeID + (",\"taskID\":") + info.taskID + (",\"status\":") + nErrorCode + ("}"); return(nErrorCode); } string strDetails = LOGGER.GetLogByTaskID(info.taskID, strTaskLogFile[0]); int nDetailsNum = LOGGER.GetLogNumByTaskID(info.taskID, strTaskLogFile[0]); nErrorCode = (int)ENUM_GetTaskLogResponseError.eGetTaskLogResponseError_Successed; strRespone = ("{") + strDetails + (",\"logCount\":") + nDetailsNum + (",\"nodeID\":") + nNodeID + (",\"taskID\":") + info.taskID + (",\"status\":") + nErrorCode + ("}"); return(nErrorCode); } } } strRespone = ("{\"detail\":[],\"logCount\":0,\"nodeID\":") + nNodeID + (",\"taskID\":0,\"status\":") + nErrorCode + ("}"); return(nErrorCode); }