private void DoDownloadUMPData(RequestMessage request) { ReturnMessage retMessage = new ReturnMessage(); retMessage.SessionID = SessionID; retMessage.Result = true; retMessage.Code = 0; retMessage.Command = request.Command; try { var listArgs = request.ListData; if (listArgs == null || listArgs.Count < 1) { retMessage.Result = false; retMessage.Code = Defines.RET_PARAM_INVALID; retMessage.Message = string.Format("Param count invalid"); SendMessage(retMessage); LogError(retMessage); return; } string strToken = listArgs[0]; if (ListLoggingServers == null || InstallInfo == null) { return; } var loggingServer = ListLoggingServers.FirstOrDefault(l => l.Token == strToken); if (loggingServer == null) { retMessage.Result = false; retMessage.Code = Defines.RET_PARAM_INVALID; retMessage.Message = string.Format("Token invalid.\t{0}", strToken); SendMessage(retMessage); LogError(retMessage); return; } mToken = strToken; mLoggingServer = loggingServer; string strInstallTime = DateTime.Parse(InstallInfo.InstallTime).ToString("yyyyMMddHHmmss"); string strFile = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), string.Format("UMP\\UMPUpdater\\Temp\\UMPData_{0}.zip", strInstallTime)); if (!File.Exists(strFile)) { retMessage.Result = false; retMessage.Code = Defines.RET_FILE_NOT_EXIST; retMessage.Message = string.Format("UMPData.zip not exist.\t{0}", strFile); SendMessage(retMessage); LogError(retMessage); return; } FileInfo fileInfo = new FileInfo(strFile); long totalsize = fileInfo.Length; string fileName = fileInfo.Name; retMessage.ListData.Add(totalsize.ToString()); retMessage.ListData.Add(fileName); SendMessage(retMessage); LogInfo(retMessage.Command, string.Format("Get UMPData.zip info end.\t{0}\t{1}", totalsize, fileName)); ThreadPool.QueueUserWorkItem(a => DoTransferUMPData()); } catch (Exception ex) { retMessage.Result = false; retMessage.Code = Defines.RET_FAIL; retMessage.Message = ex.Message; SendMessage(retMessage); LogError(retMessage); } }
private string GenerateToken(LoggingServerInfo info) { string strCode = string.Format("{0}{1}", mToken, info.HostAddress); return(ServerHashEncryption.EncryptString(strCode, EncryptionMode.SHA256V00Hex)); }