Esempio n. 1
0
        static void Main(string[] args)
        {
            //先设置当前工作目录为进程目录
            Console.WriteLine("原工作目录:"+Directory.GetCurrentDirectory());
            Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName));
            Console.WriteLine("现在工作目录:" + Directory.GetCurrentDirectory());

            //从后台维护数据表中设置错误码静态数据
            //ErrorcodeService.GetInstance().setErrorStaticData();

            string validdog = ConfigurationSettings.AppSettings["validdog"];//是否验证狗
            //启动解析线程
            TcpDataProcesser dataProcess = new TcpDataProcesser();
            Thread m_thread = new Thread(new ThreadStart(dataProcess.Processing));
            m_thread.Start();

            //启动持久化线程
            PersistentProcesser persistProcess = new PersistentProcesser();
            Thread m_thread3 = new Thread(new ThreadStart(persistProcess.Processing));
            m_thread3.Start();

            //设置最后成功处理时间到memcached,以便检测监控程序能判断是否正常运行
            MemcachedClientSatat.getInstance().Set("monitor_analyze_run_lasttime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            LogUtil.info("服务启动成功!");

            //循环检测狗
            while (1==1)
            {
                //循环狗检测程序,这个就要求必须将狗一直插入才能正常运行软件
                if (validdog == null || validdog.Equals("true"))
                {
                    LogUtil.info("开始检测加密狗");
                    string result = monitordog();
                    if (!string.IsNullOrEmpty(result))
                    {
                        LogUtil.info(result);

                        //kill thread
                        if (dataProcess!=null)
                            dataProcess.runmark = false;

                        if (m_thread!=null)
                            if (m_thread.IsAlive)
                                m_thread.Abort();

                        if (persistProcess != null)
                            persistProcess.runmark = false;

                        if (m_thread3 != null)
                            if (m_thread3.IsAlive)
                                m_thread3.Abort();

                        LogUtil.info("软件已经停止服务!");
                    }
                }
                Thread.Sleep(60*1000);//线程休息1分钟
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            //SystemCode.HexNumberToDenary("FC27", false, 16, 's');
            //启动解析线程
            TcpDataProcesser dataProcess = new TcpDataProcesser();
            Thread           m_thread    = new Thread(new ThreadStart(dataProcess.Processing));

            m_thread.Start();

            //启动清除过期数据线程
            //FlushProcesser flushProcess = new FlushProcesser();
            //Thread m_thread2 = new Thread(new ThreadStart(flushProcess.Processing));
            //m_thread2.Start();

            //启动持久化线程
            PersistentProcesser persistProcess = new PersistentProcesser();
            Thread m_thread3 = new Thread(new ThreadStart(persistProcess.Processing));

            m_thread3.Start();



            //DataProcess.DataProcessingEmail();

            LogUtil.info("数据解析服务启动成功!");
            string strLine;

            do
            {
                strLine = Console.ReadLine();
            } while (strLine != null && strLine != "exit");

            LogUtil.info("正在退出数据解析服务...");
            LogUtil.info("持久化剩余缓存数据...");
            //持久化尚未持久化的缓存数据后退出
            persistProcess.peristentData();
            LogUtil.info("剩余数据持久化完成...");

            //kill thread
            if (m_thread.IsAlive)
            {
                m_thread.Abort();
            }
            if (m_thread3.IsAlive)
            {
                m_thread3.Abort();
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            //SystemCode.HexNumberToDenary("FC27", false, 16, 's');
            //启动解析线程
            TcpDataProcesser dataProcess = new TcpDataProcesser();
            Thread m_thread = new Thread(new ThreadStart(dataProcess.Processing));
            m_thread.Start();

            //启动清除过期数据线程
            //FlushProcesser flushProcess = new FlushProcesser();
            //Thread m_thread2 = new Thread(new ThreadStart(flushProcess.Processing));
            //m_thread2.Start();

            //启动持久化线程
            PersistentProcesser persistProcess = new PersistentProcesser();
            Thread m_thread3 = new Thread(new ThreadStart(persistProcess.Processing));
            m_thread3.Start();

            //DataProcess.DataProcessingEmail();

            LogUtil.info("数据解析服务启动成功!");
            string strLine;
            do
            {
                strLine = Console.ReadLine();
            } while (strLine != null && strLine != "exit");

            LogUtil.info("正在退出数据解析服务...");
            LogUtil.info("持久化剩余缓存数据...");
            //持久化尚未持久化的缓存数据后退出
            persistProcess.peristentData();
            LogUtil.info("剩余数据持久化完成...");

            //kill thread
            if (m_thread.IsAlive)
                m_thread.Abort();
            if (m_thread3.IsAlive)
                m_thread3.Abort();
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            //先设置当前工作目录为进程目录
            Console.WriteLine("原工作目录:" + Directory.GetCurrentDirectory());
            Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName));
            Console.WriteLine("现在工作目录:" + Directory.GetCurrentDirectory());

            //从后台维护数据表中设置错误码静态数据
            //ErrorcodeService.GetInstance().setErrorStaticData();

            string validdog = ConfigurationSettings.AppSettings["validdog"];//是否验证狗
            //启动解析线程
            TcpDataProcesser dataProcess = new TcpDataProcesser();
            Thread           m_thread    = new Thread(new ThreadStart(dataProcess.Processing));

            m_thread.Start();


            //启动持久化线程
            PersistentProcesser persistProcess = new PersistentProcesser();
            Thread m_thread3 = new Thread(new ThreadStart(persistProcess.Processing));

            m_thread3.Start();

            //设置最后成功处理时间到memcached,以便检测监控程序能判断是否正常运行
            MemcachedClientSatat.getInstance().Set("monitor_analyze_run_lasttime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            LogUtil.info("服务启动成功!");

            //循环检测狗
            while (1 == 1)
            {
                //循环狗检测程序,这个就要求必须将狗一直插入才能正常运行软件
                if (validdog == null || validdog.Equals("true"))
                {
                    LogUtil.info("开始检测加密狗");
                    string result = monitordog();
                    if (!string.IsNullOrEmpty(result))
                    {
                        LogUtil.info(result);

                        //kill thread
                        if (dataProcess != null)
                        {
                            dataProcess.runmark = false;
                        }

                        if (m_thread != null)
                        {
                            if (m_thread.IsAlive)
                            {
                                m_thread.Abort();
                            }
                        }

                        if (persistProcess != null)
                        {
                            persistProcess.runmark = false;
                        }

                        if (m_thread3 != null)
                        {
                            if (m_thread3.IsAlive)
                            {
                                m_thread3.Abort();
                            }
                        }

                        LogUtil.info("软件已经停止服务!");
                    }
                }
                Thread.Sleep(60 * 1000);//线程休息1分钟
            }
        }