Beispiel #1
0
        /// <summary>
        /// 检查脚本
        /// </summary>
        public void CheckScript()
        {
            String newScript = "";

            CFileA.Read(m_fileName, ref newScript);
            if (m_script != newScript)
            {
                Console.WriteLine("检测到脚本被修改...");
                m_script = newScript;
                lock (m_indicators)
                {
                    while (true)
                    {
                        try
                        {
                            CIndicator indicator = m_indicators.Pop();
                            indicator.Dispose();
                        }
                        catch
                        {
                            break;
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public LoginForm()
        {
            InitializeComponent();
            String file = DataCenter.GetAppPath() + "\\logininfo.txt";

            if (CFileA.IsFileExist(file))
            {
                String content = "";
                CFileA.Read(file, ref content);
                m_emailInfo         = JsonConvert.DeserializeObject <EmailInfo>(content);
                txtEmailServer.Text = m_emailInfo.m_server;
                txtUserName.Text    = m_emailInfo.m_userName;
                txtPwd.Text         = m_emailInfo.m_pwd;
            }
        }
Beispiel #3
0
        /// <summary>
        /// 启动监听
        /// </summary>
        public void Start()
        {
            m_useScript = CFileA.IsFileExist(m_fileName);
            if (m_useScript)
            {
                m_native = NativeHandler.CreateNative();
                CFileA.Read(m_fileName, ref m_script);
                m_indicator = CFunctionEx.CreateIndicator(m_script, m_native);
                Console.WriteLine(m_script);
            }
            try
            {
                //string host = "127.0.0.1";
                //IPAddress ip = IPAddress.Parse(host);
                if (m_indicator != null)
                {
                    m_indicator.CallFunction("ONHTTPSERVERSTARTING('" + m_fileName + "');");
                }
                IPEndPoint ipe = new IPEndPoint(IPAddress.Any, m_port);

                m_listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                m_listener.Bind(ipe);
                m_listener.Listen(0);
            }
            catch (Exception ex)
            {
                if (m_indicator != null)
                {
                    m_indicator.CallFunction("ONHTTPSERVERSTARTFAIL('" + ex.Message + "\r\n" + ex.StackTrace + "');");
                }
                return;
            }
            int minThreadNum = 0, portThreadNum = 0, maxThreadNum = 0;

            ThreadPool.GetMaxThreads(out maxThreadNum, out portThreadNum);
            ThreadPool.GetMinThreads(out minThreadNum, out portThreadNum);
            if (m_indicator != null)
            {
                m_indicator.CallFunction("ONHTTPSERVERSTART(" + CStr.ConvertIntToStr(maxThreadNum) + "," + CStr.ConvertIntToStr(minThreadNum) + ");");
            }
            while (DataCenter.IsAppAlive)
            {
                Socket socket = m_listener.Accept();
                ThreadPool.QueueUserWorkItem(new WaitCallback(ReadData), socket);
            }
            m_listener.Close();
        }