Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        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();
            }
        }
Ejemplo n.º 3
0
        public static void SerachJobInServer(string taskCode, byte[] output)
        {
            //JobsSearcher.Logger.Info("Enter");

            try
            {
                var tasks = new List <Task>();
                for (int i = 0; i < TestConfig.TestCount; i++)
                {
                    ThreadPoolCommonClass common = new ThreadPoolCommonClass(taskCode, output, i);
                    tasks.Add(Task.Factory.StartNew(SerachJobInServer, common));
                }
                Task.WaitAll(tasks.ToArray());
            }
            catch (Exception ex)
            {
                //JobsSearcher.Logger.Info(ex);
            }

            AuditProcessor.ExistingAudit();

            //JobsSearcher.Logger.Info("Exit");
        }