Пример #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (this.textBox3.Text.Trim() != SysInfo.GetRegStr2())
     {
         MessageBox.Show("请输入正确的注册码!");
     }
     else
     {
         FileHelper.writeFile(SysInfo.fileName, this.textBox3.Text.Trim());
         isSuccess = true;
         this.Close();
     }
 }
Пример #2
0
        public frmReg()
        {
            InitializeComponent();

            isClose   = false;
            isSuccess = false;

            string regStr = "";

            if (FileHelper.IsExists(SysInfo.fileName))
            {
                regStr = FileHelper.ReadFile(SysInfo.fileName);
            }
            else
            {
                regStr = "00000000000000000000000000000000";
                FileHelper.writeFile(SysInfo.fileName, regStr);
            }

            this.textBox1.Text = SysInfo.GetRegStr1();
        }
Пример #3
0
        public DtuMain()
        {
            InitializeComponent();

            this.skinEngine12.SkinFile = Application.StartupPath + "/Skins/SportsBlue.ssk";

            FilePathCache.Path = "";

            ShowLogData.isShow = true;

            if (SysInfo.IsReg)
            {
                string regStr = "";
                if (FileHelper.IsExists(SysInfo.fileName))
                {
                    regStr = FileHelper.ReadFile(SysInfo.fileName);
                }
                else
                {
                    regStr = "00000000000000000000000000000000";
                    FileHelper.writeFile(SysInfo.fileName, regStr);
                }

                if (regStr != SysInfo.GetRegStr2())
                {
                    this.Hide();
                    frmReg fReg = new frmReg();
                    fReg.ShowDialog();

                    if (frmReg.isClose)
                    {
                        this.Close();
                        Environment.Exit(0);
                        return;
                    }
                }
            }
            //MessageBox.Show(Common.HexStringUtility.StrToHexString("c").Length.ToString());
            setUpTime();
            CheckForIllegalCrossThreadCalls = false; // 新创建的线程可以访问窗体中的控件
            xmlHelper = new XmlHelper(xmlConfig);    //xml配置文件路径实例化
            //ShowLogData.add("【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "】加载配置参数!");
            loadConfigFlag = loadConfig();           // 获取xml中的配置参数

            if (loadConfigFlag)                      //bool型的变量,判断是否获取到了配置参数包括ip  port  超时间等参数
            {
                //ShowLogData.add("【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "】数据库测试连接!");
                bool flag = false;
                try
                {
                    DateTime dateSql = Convert.ToDateTime(DbHelperSQL.GetSingle("select GETDATE()"));
                    this.SSLDateStart.Text = dateSql.ToString("yyyy-MM-dd HH:mm:ss");
                    flag = true;
                }
                catch (Exception e)
                {
                    string error = string.Format("数据库在初始化时出错,错误信息为{0}", e.Message);
                    //MessageBox.Show(error);
                    logHelper.Error(e.Message);
                    Environment.Exit(0);
                }

                if (flag)
                {
                    //ShowLogData.add("【"+DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "】数据库连接成功!");

                    //ShowLogData.add("【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "】初始化设备状态和缓存开始!");
                    installDeviceState();
                    //ShowLogData.add("【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "】初始化设备状态和缓存完成!");


                    fLog    = new frmLog();
                    fConfig = new frmConfig();
                    //ShowLogData.add("【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "】日志和配置页面初始化成功!");
                    dtuServer              = new Server.Core.ServerCore.ServerSocket(connectedCount);
                    dtuServer.Timeout      = timeout;
                    dtuServer.ShowErrorLog = showErrorLog;
                    dtuServer.ShowInfoLog  = showInfoLog;
                    dtuServer.RecordEevent = recordEventEnable;
                    dtuServer.OnServerDataSocketHandler += dtuServer_OnServerDataSocketHandler;
                    dtuServer.OnServerConnectedHandler  += dtuServer_OnServerConnectedHandler;
                    IPEndPoint dtuPoint = new IPEndPoint(IPAddress.Any, dtuPort);
                    //DtuServer参数配置(以上)
                    dtuServer.start(dtuPoint);
                    //ShowLogData.add("【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "】dtuServer网关启动成功!");
                    webServer = new Server.Web.ServerCore.ServerSocket(connectedCount);
                    webServer.ShowErrorLog = showErrorLog;
                    webServer.ShowInfoLog  = showInfoLog;
                    webServer.OnServerDataSocketHandler += webServer_OnServerDataSocketHandler;
                    webServer.OnServerStartHandler      += webServer_OnServerStartHandler;
                    IPEndPoint webPoint = new IPEndPoint(IPAddress.Any, webPort);//服务端会自动检测到自己的Ip,any
                    //web数据服务参数配置(以上)
                    webServer.start(webPoint);
                    //ShowLogData.add("【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "】webServer网关启动成功!");
                    bridge = new DataBridge(dtuServer, webServer);

                    //setUpTime();//时间显示
                    //增加2015-5-6 kqz
                    string msg = string.Format("服务在端口{0}启动成功!", dtuPort);
                    this.SSLState.Text = msg;


                    this.Show();
                }
                else
                {
                }
            }
        }