private void btnOpenUserAccount_Click(object sender, EventArgs e)
        {
            btnOpenUserAccount.Enabled = false;
            WCFManager.lableMsg        = this.labMessage;
            WCFManager.btnOpen         = this.btnOpenUserAccount;
            // labMessage.Text = "开户开始稍后.......";
            WCFManager.ShowMesg("开户开始稍后......");

            int amount = 100;

            int.TryParse(txtOpenAmount.Text.Trim(), out amount);
            decimal capital = 100000000000;

            decimal.TryParse(txtCapital.Text.Trim(), out capital);
            if (amount > 100)
            {
                //MessageBox.Show("批量开户不能大于100");
                labMessage.Text            = "批量开户不能大于100";
                btnOpenUserAccount.Enabled = true;
                return;
            }
            if (amount == 0)
            {
                amount = 100;
            }
            //开始初始化
            if (WCFManager.StartIni(capital, amount, chkIsIniHoldAccount.Checked))
            {
                WCFManager.ShowMesg("开户成功结束......");
            }
            else
            {
                WCFManager.ShowMesg("开户失败......");
            }

            // Thread.CurrentThread.Join(100000);
            //if (string.IsNullOrEmpty(message))
            //{
            //    message = "开户成功";
            //}
            // MessageBox.Show(message);
            //  btnOpenUserAccount.Enabled = true;
        }
        /// <summary>
        /// 开始批量开户并处理初始化资金
        /// </summary>
        /// <param name="capital">初始化资金</param>
        /// <param name="amount">批开户数</param>
        /// <returns></returns>
        public static bool StartIni(decimal capital, int amount, bool isInitHold)
        {
            time = DateTime.Now;
            string message = "";
            //WCFManager.GetAllCM_Commodity();
            //WCFManager.GetAllHKCommodity();
            List <UM_UserInfo> list = new List <UM_UserInfo>();

            using (TransactionManageClient client = GetManageClient())
            {
                lableMsg.Text = "正在调用管理中心开始开户请稍后.......";

                #region 管理中心开户
                InitFund inifund = new InitFund();
                inifund.HK  = capital;
                inifund.RMB = capital;
                inifund.US  = capital;
                //list = client.BatchAddTransaction(out message, amount, inifund, "FrontManager", "fzjQ37ynndk=");
                //只开后台交易员用户(因验证前台管理员身份)
                list = client.BatchAddTransaction(out message, amount, inifund, "FrontManager", "fzjQ37ynndk=");
                if (!string.IsNullOrEmpty(message))
                {
                    lableMsg.Text = message; //"调用管理中心开始开户完成.......";
                }
                else
                {
                    lableMsg.Text = "调用管理中心开始开户完成.......";
                }
            }
            #endregion
            string        userIDsStr = "";
            StringBuilder userIDs    = new StringBuilder("");
            #region  更新柜台资金可用资金
            lableMsg.Text = "开始调用柜台数据库初始化可用资金.......";
            foreach (var item in list)
            {
                userIDs.Append(" ,  '" + item.UserID.ToString() + "'");
                WCFManager.InsertCapitalAccountInfo(capital, item.UserID.ToString());
            }

            lableMsg.Text = "柜台初始化可用资金完成.......";
            #endregion
            #region 更新所有用户添加类型和初始密码为888888
            userIDsStr    = userIDs.ToString();
            lableMsg.Text = "更新管理中心添加交易员类型更为后台交易员和把密码初始化为888888并更新柜台交易员密码.......";
            if (!string.IsNullOrEmpty(userIDsStr))
            {
                userIDsStr = userIDsStr.Substring(userIDsStr.IndexOf(',') + 1);
                WCFManager.UpdateAddType(userIDsStr);
            }

            lableMsg.Text = "完成密码更新.......";

            #endregion

            #region  初始化持仓表
            //if (isInitHold)
            //{
            //    lableMsg.Text = "正在调用柜台初始化持仓量(线程开始开启分发).......";
            //    foreach (var item in list)
            //    {
            //        Thread th = new Thread(delegate() { WCFManager.InsertHoldAccount(item.UserID.ToString()); });
            //        th.Start();
            //        WCFManager.AddThread();
            //        th.Join(100);

            //        //WCFManager.InsertHoldAccount(item.UserID.ToString());
            //    }
            //    lableMsg.Text = "正在调用柜台初始化持仓量(线程开启完)各线程正在执行初始中请稍后.......";
            //}
            #endregion
            return(true);
        }
 private void Form1_Load(object sender, EventArgs e)
 {
     WCFManager.testcurrcy();
 }