public static void SerachJobInServer(string taskCode, byte[] output) { //JobsSearcher.Logger.Info("Enter"); StateObject stateObj = null; try { stateObj = new StateObject(); TCPSocket.Connect(stateObj); stateObj.ClientStream.AuthenticateAsClient(m_domainName); byte[] headerBytes = BuildHeaders(taskCode, output.Length); TcpUtil.WriteHeaderData(stateObj.ClientStream, headerBytes); TcpUtil.WriteData(stateObj.ClientStream, output); bool keepAlive = true; while (keepAlive) { string outputMsg = TcpUtil.ReadDataJob(stateObj.ClientStream, out keepAlive); if (!string.IsNullOrEmpty(outputMsg)) { string[] headersAndMsg = SplitConditionAndMessage(outputMsg); if (headersAndMsg[0].StartsWith("AuditTypeId")) { AuditProcessor.ProcessAudit(headersAndMsg); TcpUtil.WriteData(stateObj.ClientStream, Encoding.ASCII.GetBytes("received")); } else { DataTable dt = AnalyzerManager.ProxydbObj.GetTableFromDB(headersAndMsg[0], "PacketDetails"); if (dt != null && dt.Rows.Count > 0) { string tempOut = JsonConvert.SerializeObject(dt); TcpUtil.WriteData(stateObj.ClientStream, Encoding.ASCII.GetBytes(tempOut)); } else { TcpUtil.WriteData(stateObj.ClientStream, Encoding.ASCII.GetBytes(string.Empty)); } } } } } catch (Exception ex) { //JobsSearcher.Logger.Error(ex); } finally { stateObj.Close(); } AuditProcessor.ExistingAudit(); //JobsSearcher.Logger.Info("Exit"); }
public static void SerachJobInServer(object obj) { ThreadPoolCommonClass common = (ThreadPoolCommonClass)obj; StateObject stateObj = null; try { stateObj = new StateObject(); TCPSocket.Connect(stateObj); stateObj.ClientStream.AuthenticateAsClient(m_domainName); byte[] headerBytes = BuildHeaders(common.TaskCode, common.Output.Length, UpdateClient.Keys.ElementAt(common.ThreadIndx)); TcpUtil.WriteHeaderData(stateObj.ClientStream, headerBytes); TcpUtil.WriteData(stateObj.ClientStream, common.Output); bool keepAlive = true; while (keepAlive) { string outputMsg = TcpUtil.ReadDataJob(stateObj.ClientStream, out keepAlive); if (!string.IsNullOrEmpty(outputMsg)) { string[] headersAndMsg = SplitConditionAndMessage(outputMsg); if (headersAndMsg[0] == "WinAudit") { AuditProcessor.ProcessAudit(headersAndMsg); TcpUtil.WriteData(stateObj.ClientStream, Encoding.ASCII.GetBytes("received")); } else { DataTable dt = AnalyzerManager.ProxydbObj.GetTableFromDB(headersAndMsg[0], "PacketDetails"); if (dt != null && dt.Rows.Count > 0) { string tempOut = JsonConvert.SerializeObject(dt); TcpUtil.WriteData(stateObj.ClientStream, Encoding.ASCII.GetBytes(tempOut)); } else { TcpUtil.WriteData(stateObj.ClientStream, Encoding.ASCII.GetBytes(string.Empty)); } } } } } catch (Exception) { } finally { stateObj.Close(); } }