Example #1
0
        /// <summary>
        /// 定时连接柜台服务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void InitializeTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            this.toolStripStatusLabel1.Text      = ResourceOperate.Instanse.GetResourceByKey("Reconnect") + "...";
            this.toolStripStatusLabel1.ForeColor = Color.Red;
            string errorMsg  = "";
            bool   isSuccess = wcfLogic.Initialize(ServerConfig.TraderID, "", out errorMsg);

            if (isSuccess)
            {
                this.toolStripStatusLabel1.Text      = ResourceOperate.Instanse.GetResourceByKey("Connected");
                this.toolStripStatusLabel1.ForeColor = Color.Green;
                InitializeTimer.Enabled = false;
                UpdateTimer.Enabled     = true;
            }
            else
            {
                this.toolStripStatusLabel1.Text      = ResourceOperate.Instanse.GetResourceByKey("Failed");
                this.toolStripStatusLabel1.ForeColor = Color.Red;
            }
        }
        /// <summary>
        /// 连接按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConnect_Click(object sender, EventArgs e)
        {
            if (wcfLogic.IsServiceOk)
            {
                return;
            }
            string errorMsg  = "";
            bool   isSuccess = wcfLogic.Initialize(ServerConfig.TraderID, "", out errorMsg);

            if (isSuccess)
            {
                //StartTimer();
                wcfLogic.ServiceOk = true;
            }
            else
            {
                string errMsg = ResourceOperate.Instanse.GetResourceByKey("StartWCF");
                MessageBox.Show(errMsg);
            }
        }