/// <summary>
        /// 清算柜台分页查询
        /// </summary>
        /// <param name="counterQueryEntity">清算柜台实体</param>
        /// <param name="pageNo">当前页</param>
        /// <param name="pageSize">当前要显示的记录数</param>
        /// <param name="rowCount">总行数</param>
        /// <returns></returns>
        public DataSet GetPagingCounter(CT_Counter counterQueryEntity, int pageNo, int pageSize,
                                        out int rowCount)
        {
            string SQL_SELECT_Counter =
                @" select CouterID,name,IP,XiaDanServicePort,MaxValues,State,XiaDanServiceName,QueryServiceName,AccountServiceName,AccountServicePort,QueryServicePort,SendServiceName,SendPort  FROM CT_Counter where 1=1 ";

            if (counterQueryEntity.name != null && !string.IsNullOrEmpty(counterQueryEntity.name))
            {
                SQL_SELECT_Counter += "AND name LIKE  '%' + @name + '%' ";
            }
            if (counterQueryEntity.IP != null && !string.IsNullOrEmpty(counterQueryEntity.IP))
            {
                SQL_SELECT_Counter += "AND IP=@IP ";
            }

            Database  database  = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = database.GetSqlStringCommand(SQL_SELECT_Counter);


            if (counterQueryEntity.name != null && !string.IsNullOrEmpty(counterQueryEntity.name))
            {
                database.AddInParameter(dbCommand, "name", DbType.String, counterQueryEntity.name);
            }
            if (counterQueryEntity.IP != null && !string.IsNullOrEmpty(counterQueryEntity.IP))
            {
                database.AddInParameter(dbCommand, "IP", DbType.String, counterQueryEntity.IP);
            }

            return(CommPager.QueryPager(database, dbCommand, SQL_SELECT_Counter, pageNo, pageSize, out rowCount,
                                        "UM_Counter"));
        }
예제 #2
0
 private void GetEntity()
 {
     try
     {
         if (m_counter == null)
         {
             m_counter = new CT_Counter();
         }
         m_counter.IP = txt_IP.Text;
         //m_counter.MaxValues = int.Parse(txt_MaxValues.Text);
         m_counter.name = txt_CounterName.Text;
         m_counter.XiaDanServicePort  = int.Parse(txt_Port.Text);
         m_counter.XiaDanServiceName  = txt_XiaDanServiceName.Text;
         m_counter.AccountServiceName = txt_AccountServiceName.Text;
         m_counter.QueryServiceName   = txt_QueryServiceName.Text;
         m_counter.State = (int)Types.StateEnum.ConnDefeat;
         //新加代码 09.04.08
         m_counter.SendServiceName    = txtSendServiceName.Text;
         m_counter.AccountServicePort = int.Parse(txtAccountServicePort.Text);
         m_counter.QueryServicePort   = int.Parse(txtQueryServicePort.Text);
         m_counter.SendPort           = int.Parse(txtSendPort.Text);
     }
     catch (Exception ex)
     {
         string errCode   = "GL-3034";
         string errMsg    = "获取实体失败!";
         var    exception = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(exception.ToString(), exception.InnerException);
     }
 }
        /// <summary>
        /// 修改柜台信息
        /// </summary>
        /// <param name="handle">当前行</param>
        private void CounterUpdate(int handle)
        {
            try
            {
                if (handle < 0)
                {
                    return;
                }
                CounterEdit counterEdit = new CounterEdit();
                counterEdit.EditType = 2;
                DataRow dw       = ViewCounter.GetDataRow(handle);
                int     CouterID = int.Parse(dw["CouterID"].ToString());

                CT_Counter Counter = CounterBLL.GetModel(CouterID);
                counterEdit.Counter = Counter;
                if (counterEdit.ShowDialog(this) == DialogResult.OK)
                {
                    InitCounterList();
                    this.ViewCounter.FocusedRowHandle = handle;
                }
            }
            catch (Exception ex)
            {
                ShowMessageBox.ShowInformation("修改柜台信息失败!");
                string      errCode   = "GL-3005";
                string      errMsg    = "修改柜台信息失败!";
                VTException exception = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(exception.ToString(), exception.InnerException);
            }
        }
        /// <summary>
        /// 管理员查询根据交易员查询交易员各资金账户相关信息
        /// </summary>
        /// <param name="adminId">管理员ID</param>
        /// <param name="adminPassword">管理员密码</param>
        /// <param name="traderId">交易员ID</param>
        /// <param name="CouterID">柜台ID</param>
        /// <param name="strErrorMessage"></param>
        /// <returns></returns>
        public DataTable AdminFindTraderCapitalAccountInfoByID(string adminId, string adminPassword, string traderId, int CouterID, out string strErrorMessage)
        {
            //调用柜台管理员查询根据交易员查询交易员各资金账户相关信息方法
            // string s;
            try
            {
                CT_Counter T = StaticDalClass.CounterDAL.GetModel(CouterID);
                List <TradersAccountCapitalInfo> tradersAccountCList =
                    ServiceIn.AccountManageServiceProxy.GetInstance().AdminFindTraderCapitalAccountInfoByID(T, adminId,
                                                                                                            adminPassword,
                                                                                                            traderId,
                                                                                                            out
                                                                                                            strErrorMessage);

                if (tradersAccountCList.Count > 0)
                {
                    //return tradersAccountCList;
                    return(ToDataTable(tradersAccountCList));
                }
                else
                {
                    strErrorMessage = "GL-0233:调用柜台开户方法AdminFindTraderCapitalAccountInfoByID失败!";// +s; //写调试信息
                    LogHelper.WriteDebug(strErrorMessage);
                }
            }
            catch (VTException ex)
            {
                strErrorMessage = ex.ToString();
                LogHelper.WriteError(ex.ToString(), ex.InnerException);
                return(null);
            }
            return(null);
        }
        /// <summary>
        /// 自由转帐(同币种)
        /// </summary>
        /// <param name="freeTransfer"> 自由转账实体</param>
        /// <param name="currencyType">当前币种类型</param>
        /// <param name="couterID">柜台ID</param>
        /// <param name="outMessage">输出信息</param>
        /// <returns></returns>
        public bool TwoAccountsFreeTransferFunds(FreeTransferEntity freeTransfer, TypesCurrencyType currencyType, int couterID,
                                                 out string outMessage)
        {
            try
            {
                CT_Counter T       = StaticDalClass.CounterDAL.GetModel(couterID);
                bool       _Result =
                    ServiceIn.AccountManageServiceProxy.GetInstance().TwoAccountsFreeTransferFunds(T, freeTransfer,
                                                                                                   currencyType, out outMessage);


                if (_Result == false)
                {
                    if (!string.IsNullOrEmpty(outMessage))
                    {
                        //outMessage = "GL-:调用柜台自由转帐(同币种)方法TwoAccountsFreeTransferFunds失败!";// +s; //写调试信息
                        LogHelper.WriteDebug(outMessage);
                    }
                    return(false);
                }
                return(true);
            }
            catch (VTException ex)
            {
                outMessage = "GL-0234:调用柜台自由转帐(同币种)方法TwoAccountsFreeTransferFunds失败!";
                LogHelper.WriteError(ex.ToString() + outMessage, ex.InnerException);
                //写错误信息
                return(false);
            }
        }
예제 #6
0
        /// <summary>
        /// 对管理员用户名和密码进行验证,并个性化设置操作
        /// </summary>
        /// <param name="pec">个性化资金实体类</param>
        /// <param name="LoginName">管理员用户名</param>
        /// <param name="PassWord">密码</param>
        /// <param name="message">返回的信息</param>
        /// <returns>格式化资金是否成功</returns>
        public bool PersonalizationCapital(PersonalizationCapital pec, string LoginName, string PassWord, out string message)
        {
            //验证管理员用户名和密码是否通过验证
            bool lastly = true;
            Out_TransactionManage outTran = new Out_TransactionManage();
            bool login = outTran.AdminLoginConfirmation(LoginName, PassWord, out message);

            if (login == true)
            {
                #region 对获取的数据通过柜台进行分组,并根据分组后柜台调用柜台服务接口
                Dictionary <string, CapitalPersonalization> list = outTran.CounterGrouping(pec);
                //循环list中键值,并分别通过键值获取柜台信息和通过键值获取个性化资金信息再调用柜台的个性化资金接口
                foreach (string key in list.Keys)
                {
                    string     CID       = key;
                    int        CounterID = int.Parse(CID);
                    CT_Counter T         = StaticDalClass.CounterDAL.GetModel((int)CounterID);;
                    //调用柜台的个性化资金接口
                    bool state = AccountManageServiceProxy.GetInstance().PersonalizationCapital(T, list[key], out message);
                    if (state == false)
                    {
                        lastly = false;
                    }
                }
                return(lastly);

                #endregion 对获取的数据通过柜台进行分组,并根据分组后柜台调用柜台服务接口
            }
            return(false);
        }
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public CT_Counter ReaderBind(IDataReader dataReader)
        {
            var    model = new CT_Counter();
            object ojb;

            ojb = dataReader["CouterID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CouterID = (int)ojb;
            }
            model.name = dataReader["name"].ToString();
            model.IP   = dataReader["IP"].ToString();
            ojb        = dataReader["XiaDanServicePort"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.XiaDanServicePort = (int)ojb;
            }
            ojb = dataReader["MaxValues"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.MaxValues = (int)ojb;
            }
            ojb = dataReader["State"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.State = (int)ojb;
            }
            model.AccountServiceName = dataReader["AccountServiceName"].ToString();
            model.QueryServiceName   = dataReader["QueryServiceName"].ToString();
            model.XiaDanServiceName  = dataReader["XiaDanServiceName"].ToString();
            ojb = dataReader["AccountServicePort"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AccountServicePort = (int)ojb;
            }
            ojb = dataReader["QueryServicePort"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.QueryServicePort = (int)ojb;
            }
            model.SendServiceName = dataReader["SendServiceName"].ToString();

            ojb = dataReader["SendPort"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.SendPort = (int)ojb;
            }
            return(model);
        }
        /// <summary>
        /// 解冻帐号
        /// </summary>
        /// <param name="DealerAccount">帐号表</param>
        /// <param name="ThawReason">解冻原因</param>
        /// <param name="mess"></param>
        /// <returns></returns>
        public bool ThawAccount(UM_DealerAccount DealerAccount, UM_ThawReason ThawReason, out string mess)
        {
            mess = string.Empty;
            CT_Counter T = GetCounterByUserID((int)DealerAccount.UserID);
            List <FindAccountEntity> l = new List <FindAccountEntity>();

            if (T == null)
            {
                mess = "GL-0227:交易员对应的柜台不存在!"; //写调试信息
                LogHelper.WriteDebug(mess);
                return(false);
            }
            try
            {
                FindAccountEntity FindAccountEntity = new FindAccountEntity();
                FindAccountEntity.AccountType = (int)DealerAccount.AccountTypeID;
                FindAccountEntity.UserID      = DealerAccount.UserID.ToString();
                l.Add(FindAccountEntity);
                if (!ServiceIn.AccountManageServiceProxy.GetInstance().ThawAccount(T, l, out mess))
                {
                    mess = "GL-0228:调用柜台解冻帐号方法ThawAccount()失败!" + mess; //写调试信息
                    LogHelper.WriteDebug(mess);
                    return(false);
                }
            }
            catch (VTException Ex)
            {
                mess = Ex.ToString();
                //写错误日志
                return(false);
            }
            try
            {
                StaticDalClass.DealerAccountDAL.Update(DealerAccount);
                StaticDalClass.ThawReasonDAL.Add(ThawReason);
            }
            catch (Exception ex)
            {
                ServiceIn.AccountManageServiceProxy.GetInstance().FreezeAccount(T, l, out mess);
                string      errCode = "GL-0229";
                string      errMsg  = "冻结帐号方法FreezeAccount()异常!" + ex.Message;
                VTException vte     = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(vte.ToString(), vte.InnerException);
                mess = vte.ToString();
                return(false);
            }
            return(true);
        }
 /// <summary>
 /// 根据用户ID得到柜台实体
 /// </summary>
 /// <param name="UserID">用户ID</param>
 /// <returns></returns>
 private CT_Counter GetCounterByUserID(int UserID)
 {
     try
     {
         UM_UserInfo USER = StaticDalClass.UserInfoDAL.GetModel(UserID);
         CT_Counter  CT   = StaticDalClass.CounterDAL.GetModel((int)USER.CouterID);
         return(CT);
     }
     catch (Exception ex)
     {
         string      errCode = "GL-0217";
         string      errMsg  = "根据用户ID得到柜台实体GetCounterByUserID()方法异常!";
         VTException vte     = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(vte.ToString(), vte.InnerException);
         return(null);
     }
 }
 /// <summary>
 /// 个性化资金
 /// </summary>
 /// <param name="CT">柜台信息</param>
 /// <param name="cap">个性化资金实体类</param>
 /// <param name="mess">返回的错误信息</param>
 /// <returns>是否个性化成功</returns>
 public bool PersonalizationCapital(CT_Counter CT, CapitalPersonalization cap, out string mess)
 {
     try
     {
         using (AccountAndCapitalManagementClient client = GetClient(CT))
         {
             //string mess;
             return(client.AdminPersonalizationCapital(out mess, cap));
         }
     }
     catch (Exception ex)
     {
         string      errCode = "GL-8114";
         string      errMsg  = "调用清算柜台提供的AdminPersonalizationCapital()方法异常," + ex.Message;
         VTException vte     = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(vte.ToString(), vte.InnerException);
         throw vte;
     }
 }
 /// <summary>
 /// 批量销户
 /// </summary>
 /// <param name="CT">柜台表</param>
 /// <param name="Userids">用户ID</param>
 /// <param name="mess">输出信息</param>
 /// <returns></returns>
 public bool DeleteVolumeTraderAccount(CT_Counter CT, List <string> Userids, out string mess)
 {
     try
     {
         using (AccountAndCapitalManagementClient client = GetClient(CT))
         {
             //string mess;
             return(client.DeleteVolumeTraderAccount(out mess, Userids));
         }
     }
     catch (Exception ex)
     {
         string      errCode = "GL-8104";
         string      errMsg  = "调用清算柜台提供的DeleteVolumeTraderAccount()方法异常," + ex.Message;
         VTException vte     = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(vte.ToString(), vte.InnerException);
         throw vte;
     }
 }
 /// <summary>
 /// 设置查询实体对象
 /// </summary>
 private bool SetQueryCounter()
 {
     try
     {
         if (QueryCounter == null)
         {
             QueryCounter = new CT_Counter();
         }
         if (this.txt_Name.Text != string.Empty)
         {
             QueryCounter.name = this.txt_Name.Text;
         }
         else
         {
             QueryCounter.name = null;
         }
         if (this.txt_IP.Text == string.Empty)
         {
             QueryCounter.IP = null;
         }
         else
         {
             if (CommonClass.InputTest.IPTest(this.txt_IP.Text))
             {
                 QueryCounter.IP = this.txt_IP.Text;
             }
             else
             {
                 ShowMessageBox.ShowInformation("请输入正确的IP地址!");
                 return(false);
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         string      errCode   = "GL-3003";
         string      errMsg    = "设置查询实体对象失败!";
         VTException exception = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(exception.ToString(), exception.InnerException);
         return(false);
     }
 }
 /// <summary>
 /// 解冻帐户
 /// </summary>
 /// <param name="CT">柜台表</param>
 /// <param name="l_AccountEntity">帐户实体</param>
 /// <param name="mess">输出信息</param>
 /// <returns></returns>
 public bool ThawAccount(CT_Counter CT, List <FindAccountEntity> l_AccountEntity, out string mess)
 {
     try
     {
         using (AccountAndCapitalManagementClient client = GetClient(CT))
         {
             //string mess;
             return(client.ThawAccount(out mess, l_AccountEntity));
         }
     }
     catch (Exception ex)
     {
         string      errCode = "GL-8106";
         string      errMsg  = "调用清算柜台提供的ThawAccount()方法异常," + ex.Message;
         VTException vte     = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(vte.ToString(), vte.InnerException);
         throw vte;
     }
 }
 /// <summary>
 /// 自由转帐(同币种)
 /// </summary>
 /// <param name="CT">柜台表</param>
 /// <param name="freeTransfer"> 自由转账实体</param>
 /// <param name="currencyType">当前币种类型</param>
 /// <param name="outMessage">输出信息</param>
 /// <returns></returns>
 public bool TwoAccountsFreeTransferFunds(CT_Counter CT, FreeTransferEntity freeTransfer, TypesCurrencyType currencyType,
                                          out string outMessage)
 {
     try
     {
         using (AccountAndCapitalManagementClient client = GetClient(CT))
         {
             //string mess;
             return(client.TwoAccountsFreeTransferFunds(out outMessage, freeTransfer, currencyType));
         }
     }
     catch (Exception ex)
     {
         string      errCode = "GL-8112";
         string      errMsg  = "调用清算柜台提供的TwoAccountsFreeTransferFunds()方法异常," + ex.Message;
         VTException vte     = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(vte.ToString(), vte.InnerException);
         throw vte;
     }
 }
 /// <summary>
 /// 获取当前所有持仓中要提供当日结算价清算的代码
 /// </summary>
 /// <param name="T">柜台信息</param>
 /// <param name="errMsg">输出信息</param>
 /// <returns></returns>
 public List <QH_TodaySettlementPriceInfo> GetReckoningHoldCodeList(CT_Counter T, out string errMsg)
 {
     try
     {
         LogHelper.WriteDebug("=====获取当前所有持仓中要提供当日结算价清算的代码,柜台:" + T.CouterID);
         using (AccountAndCapitalManagementClient client = GetClient(T))
         {
             return(client.GetAllReckoningHoldCode(out errMsg));
         }
     }
     catch (Exception ex)
     {
         string errCode = "GL-8116";
         errMsg = "调用清算柜台提供的GetAllReckoningHoldCode()方法异常," + ex.Message;
         VTException vte = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(vte.ToString(), vte.InnerException);
         //throw vte;
     }
     return(null);
 }
 /// <summary>
 /// 查看指定的时间柜台是否完成清算
 /// </summary>
 /// <param name="T">柜台信息</param>
 /// <param name="doneDate">指定日期时间</param>
 /// <returns></returns>
 public bool IsReckoningDone(CT_Counter T, DateTime doneDate)
 {
     try
     {
         LogHelper.WriteDebug("=====查看指定的时间柜台是否完成清算,柜台:" + T.CouterID);
         using (AccountAndCapitalManagementClient client = GetClient(T))
         {
             return(client.IsReckoningDone(doneDate));
         }
     }
     catch (Exception ex)
     {
         string      errCode = "GL-8116";
         string      errMsg  = "调用清算柜台提供的IsReckoningDone()方法异常," + ex.Message;
         VTException vte     = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(vte.ToString(), vte.InnerException);
         //throw vte;
         return(false);
     }
 }
        /// <summary>
        /// 根据柜台实体获取清算柜台资金账户管理服务
        /// </summary>
        /// <param name="CT">柜台实体</param>
        /// <returns>返回清算柜台资金账户管理服务连接</returns>
        private AccountAndCapitalManagementClient GetClient(CT_Counter CT)
        {
            AccountAndCapitalManagementClient client;

            try
            {
                EndpointAddress tcpAddress =
                    new EndpointAddress(string.Format("net.tcp://{0}:{1}/{2}", CT.IP, CT.AccountServicePort, CT.AccountServiceName));
                client = new AccountAndCapitalManagementClient(endpiontConfigurationName, tcpAddress);
            }
            catch (Exception ex)
            {
                string      errCode = "GL-8110";
                string      errMsg  = "无法获取清算柜台提供的服务[IAccountAndCapitalManagement],IP为:" + CT.IP;
                VTException vte     = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(vte.ToString(), vte.InnerException);
                throw vte;
            }
            return(client);
        }
 /// <summary>
 /// 修改密码
 /// </summary>
 /// <param name="CT">柜台表</param>
 /// <param name="UserID">用户ID</param>
 /// <param name="PassWord">密码</param>
 /// <param name="mess">输出信息</param>
 /// <returns></returns>
 public bool UpdateUserPassword(CT_Counter CT, int UserID, string PassWord, out string mess)
 {
     try
     {
         using (AccountAndCapitalManagementClient client = GetClient(CT))
         {
             // string mess;
             UM_UserInfo user        = StaticDalClass.UserInfoDAL.GetModel(UserID);
             string      oldPassword = user.Password;
             return(client.UpdateUserPassword(out mess, UserID.ToString(), oldPassword, PassWord));
         }
     }
     catch (Exception ex)
     {
         string      errCode = "GL-8107";
         string      errMsg  = "调用清算柜台提供的UpdateUserPassword()方法异常," + ex.Message;
         VTException vte     = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(vte.ToString(), vte.InnerException);
         throw vte;
     }
 }
 /// <summary>
 /// 手动提交清算
 /// </summary>
 /// <param name="T">柜台信息</param>
 /// <param name="listInfo">结算价列表</param>
 /// <param name="errorMsg">异常信息</param>
 /// <returns></returns>
 public bool DoManualReckoning(CT_Counter T, List <QH_TodaySettlementPriceInfo> listInfo, out string errorMsg)
 {
     errorMsg = string.Empty;
     try
     {
         LogHelper.WriteDebug("=====调用清算柜台提供的FaultRecoveryReckoning()方法进行手动提交清算,柜台:" + T.CouterID);
         using (AccountAndCapitalManagementClient client = GetClient(T))
         {
             return(client.FaultRecoveryReckoning(out errorMsg, listInfo));
         }
     }
     catch (Exception ex)
     {
         string      errCode = "GL-8115";
         string      errMsg  = "调用清算柜台提供的FaultRecoveryReckoning()方法异常," + ex.Message;
         VTException vte     = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(vte.ToString(), vte.InnerException);
         //throw vte;
     }
     return(false);
 }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CT_Counter GetModel(int CouterID)
        {
            var strSql = new StringBuilder();

            strSql.Append(
                "select CouterID,name,IP,XiaDanServicePort,MaxValues,State,XiaDanServiceName,AccountServiceName,QueryServiceName,AccountServicePort,QueryServicePort,SendServiceName,SendPort from CT_Counter ");
            strSql.Append(" where CouterID=@CouterID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "CouterID", DbType.Int32, CouterID);
            CT_Counter model = null;

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(CT_Counter model)
        {
            var strSql = new StringBuilder();

            strSql.Append("insert into CT_Counter(");
            strSql.Append(
                "name,IP,XiaDanServicePort,MaxValues,State,XiaDanServiceName,QueryServiceName,AccountServiceName,AccountServicePort,QueryServicePort,SendServiceName,SendPort)");

            strSql.Append(" values (");
            strSql.Append(
                "@name,@IP,@XiaDanServicePort,@MaxValues,@State,@XiaDanServiceName,@QueryServiceName,@AccountServiceName,@AccountServicePort,@QueryServicePort,@SendServiceName,@SendPort)");
            strSql.Append(";select @@IDENTITY");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "name", DbType.String, model.name);
            db.AddInParameter(dbCommand, "IP", DbType.String, model.IP);
            db.AddInParameter(dbCommand, "XiaDanServicePort", DbType.Int32, model.XiaDanServicePort);
            db.AddInParameter(dbCommand, "MaxValues", DbType.Int32, model.MaxValues);
            db.AddInParameter(dbCommand, "State", DbType.Byte, model.State);
            db.AddInParameter(dbCommand, "XiaDanServiceName", DbType.String, model.XiaDanServiceName);
            db.AddInParameter(dbCommand, "QueryServiceName", DbType.String, model.QueryServiceName);
            db.AddInParameter(dbCommand, "AccountServiceName", DbType.String, model.AccountServiceName);
            db.AddInParameter(dbCommand, "AccountServicePort", DbType.Int32, model.AccountServicePort);
            db.AddInParameter(dbCommand, "QueryServicePort", DbType.Int32, model.QueryServicePort);
            db.AddInParameter(dbCommand, "SendServiceName", DbType.String, model.SendServiceName);
            db.AddInParameter(dbCommand, "SendPort", DbType.Int32, model.SendPort);

            int    result;
            object obj = db.ExecuteScalar(dbCommand);

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(CT_Counter model)
        {
            var strSql = new StringBuilder();

            strSql.Append("update CT_Counter set ");
            strSql.Append("name=@name,");
            strSql.Append("IP=@IP,");
            strSql.Append("XiaDanServicePort=@XiaDanServicePort,");
            strSql.Append("MaxValues=@MaxValues,");
            strSql.Append("State=@State,");
            strSql.Append("XiaDanServiceName=@XiaDanServiceName,");
            strSql.Append("QueryServiceName=@QueryServiceName,");
            strSql.Append("AccountServiceName=@AccountServiceName,");
            strSql.Append("AccountServicePort=@AccountServicePort,");
            strSql.Append("QueryServicePort=@QueryServicePort,");
            strSql.Append("SendServiceName=@SendServiceName,");
            strSql.Append("SendPort=@SendPort ");
            strSql.Append(" where CouterID=@CouterID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "CouterID", DbType.Int32, model.CouterID);
            db.AddInParameter(dbCommand, "name", DbType.String, model.name);
            db.AddInParameter(dbCommand, "IP", DbType.String, model.IP);
            db.AddInParameter(dbCommand, "XiaDanServicePort", DbType.Int32, model.XiaDanServicePort);
            db.AddInParameter(dbCommand, "MaxValues", DbType.Int32, model.MaxValues);
            db.AddInParameter(dbCommand, "State", DbType.Byte, model.State);
            db.AddInParameter(dbCommand, "XiaDanServiceName", DbType.String, model.XiaDanServiceName);
            db.AddInParameter(dbCommand, "AccountServiceName", DbType.String, model.AccountServiceName);
            db.AddInParameter(dbCommand, "QueryServiceName", DbType.String, model.QueryServiceName);
            db.AddInParameter(dbCommand, "AccountServicePort", DbType.Int32, model.AccountServicePort);
            db.AddInParameter(dbCommand, "QueryServicePort", DbType.Int32, model.QueryServicePort);
            db.AddInParameter(dbCommand, "SendServiceName", DbType.String, model.SendServiceName);
            db.AddInParameter(dbCommand, "SendPort", DbType.Int32, model.SendPort);
            db.ExecuteNonQuery(dbCommand);
        }
        /// <summary>
        /// 删除交易员根据ID
        /// </summary>
        /// <param name="UserID">用户ID</param>
        /// <param name="mess"></param>
        /// <returns></returns>
        public bool DelTransaction(int UserID, out string mess)
        {
            //更新本地状态  只要状态更新成功,如果本次删除失败会通过定时服务再次去删除
            //try
            //{
            //    StaticDalClass.UserInfoDAL.UpdateDelState(UserID, null, null);
            //}
            //catch (Exception Ex)
            //{
            //    string errCode = "GL-0211";
            //    string errMsg = "交易员更新为删除状态失败";
            //    VTException vte = new VTException(errCode, errMsg, Ex);
            //    mess = vte.ToString();
            //    return false;
            //}
            //调用柜台销户方法
            try
            {
                CT_Counter T = GetCounterByUserID(UserID);
                if (T == null)
                {
                    mess = "GL-0212:交易员获取相应柜台失败"; //写调试信息
                    LogHelper.WriteDebug(mess);
                    return(false);
                }
                if (!AccountManageServiceProxy.GetInstance().DeleteSingleTraderAccount(T, UserID.ToString(), out mess))
                {
                    mess = "GL-0213:调用柜台柜台销户方法DeleteSingleTraderAccount失败!" + mess; //写调试信息
                    LogHelper.WriteDebug(mess);
                    return(false);
                }
            }
            catch (VTException Ex)
            {
                mess = Ex.ToString();
                //写错误日志
                return(false);
            }
            try
            {
                Database     db   = DatabaseFactory.CreateDatabase();
                DbConnection Conn = db.CreateConnection();
                if (Conn.State != ConnectionState.Open)
                {
                    Conn.Open();
                }
                DbTransaction Tran = Conn.BeginTransaction();
                try
                {
                    StaticDalClass.ThawReasonDAL.DeleteByUserID(UserID, Tran, db);

                    StaticDalClass.FreezeReasonDAL.DeleteByUserID(UserID, Tran, db);

                    StaticDalClass.OriginationFundDAL.DeleteByUserID(UserID, Tran, db);

                    StaticDalClass.DealerAccountDAL.DeleteByUserID(UserID, Tran, db);

                    StaticDalClass.DealerTradeBreedClassDAL.DeleteByUserID(UserID, Tran, db);

                    StaticDalClass.UserInfoDAL.Delete(UserID, Tran, db);
                    Tran.Commit();
                    mess = "GL-0214:交易员删除成功!";
                    return(true);
                }
                catch (Exception ex)
                {
                    Tran.Rollback();
                    string      errCode = "GL-0215";
                    string      errMsg  = "删除交易员方法失败!";
                    VTException vte     = new VTException(errCode, errMsg, ex);
                    LogHelper.WriteError(vte.ToString(), vte.InnerException);
                    mess = vte.ToString();
                    return(false);
                }
                finally
                {
                    if (Conn.State == ConnectionState.Open)
                    {
                        Conn.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                string      errCode = "GL-0216";
                string      errMsg  = "连接数据库失败!";
                VTException vte     = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(vte.ToString(), vte.InnerException);
                mess = vte.ToString();
                return(false);
            }
        }
        /// <summary>
        /// 管理员查询根据交易员查询交易员各银行资金账户相关信息
        /// </summary>
        /// <param name="adminId">管理员ID(可传空值:因柜台没验证)</param>
        /// <param name="adminPassword">管理员密码(可传空值:因柜台没验证)</param>
        /// <param name="traderID">交易员ID</param>
        /// <param name="strErrorMessage">输出信息</param>
        /// <returns>返回交易员的资金明细</returns>
        public UM_FundAddInfo AdminFindTraderBankCapitalAccountInfoByID(string adminId, string adminPassword, string traderID, out string strErrorMessage)
        {
            //调用柜台管理员查询根据交易员查询交易员各资金账户相关信息方法
            List <TradersAccountCapitalInfo> tradersAccountCList = new List <TradersAccountCapitalInfo>();
            UM_FundAddInfo uM_FundAddInfo = new UM_FundAddInfo();//追加资金明细实体

            try
            {
                int         couterID;
                UM_UserInfo uM_UserInfo = new UM_UserInfo();
                uM_UserInfo = GetUMUserInfoModel(Convert.ToInt32(traderID));
                if (uM_UserInfo == null)
                {
                    strErrorMessage = "用户ID不存在!";
                    LogHelper.WriteDebug(strErrorMessage);
                    return(null);
                }
                couterID = Convert.ToInt32(uM_UserInfo.CouterID);
                if (string.IsNullOrEmpty(couterID.ToString()))
                {
                    strErrorMessage = "交易员ID(用户ID)的柜台不存在!";
                    LogHelper.WriteDebug(strErrorMessage);
                    return(null);
                }
                CT_Counter T = StaticDalClass.CounterDAL.GetModel(couterID);
                tradersAccountCList =
                    ServiceIn.AccountManageServiceProxy.GetInstance().AdminFindTraderCapitalAccountInfoByID(T, adminId,
                                                                                                            adminPassword,
                                                                                                            traderID,
                                                                                                            out
                                                                                                            strErrorMessage);

                if (tradersAccountCList.Count == 0)
                {
                    strErrorMessage = "GL-0052:调用柜台开户方法AdminFindTraderCapitalAccountInfoByID失败!";// +s; //写调试信息
                    LogHelper.WriteDebug(strErrorMessage);
                    return(null);
                }
                //返回银行账户里的可用资金
                foreach (TradersAccountCapitalInfo traderACInfo in tradersAccountCList)
                {
                    if (traderACInfo.AccountType == (int)GTA.VTS.Common.CommonObject.Types.AccountType.BankAccount)
                    {
                        switch (traderACInfo.CurrencyType)
                        {
                        case (int)GTA.VTS.Common.CommonObject.Types.CurrencyType.RMB:
                            uM_FundAddInfo.RMBNumber = traderACInfo.AvailableCapital;
                            break;

                        case (int)GTA.VTS.Common.CommonObject.Types.CurrencyType.HK:
                            uM_FundAddInfo.HKNumber = traderACInfo.AvailableCapital;
                            break;

                        case (int)GTA.VTS.Common.CommonObject.Types.CurrencyType.US:
                            uM_FundAddInfo.USNumber = traderACInfo.AvailableCapital;
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
            catch (VTException ex)
            {
                strErrorMessage = ex.ToString();
                LogHelper.WriteError(ex.ToString(), ex.InnerException);
                return(null);
            }
            return(uM_FundAddInfo);
        }
        /// <summary>
        /// 修改交易员
        /// </summary>
        /// <param name="dtAdd">新增加的权限表</param>
        /// <param name="dtDel">要删除的权限表</param>
        /// <param name="UserInfo">用户信息</param>
        /// <param name="UpdatePwd">需要更新的密码</param>
        /// <param name="mess"></param>
        /// <returns></returns>
        public bool UpdateTransaction(DataTable dtAdd, DataTable dtDel, UM_UserInfo UserInfo, bool UpdatePwd,
                                      out string mess)
        {
            //调用柜台服务
            if (UpdatePwd)
            {
                try
                {
                    CT_Counter T = StaticDalClass.CounterDAL.GetModel((int)UserInfo.CouterID);
                    if (T == null)
                    {
                        mess = "GL-0207:交易员获取相应柜台失败"; //写调试信息
                        LogHelper.WriteDebug(mess);

                        return(false);
                    }
                    if (!ServiceIn.AccountManageServiceProxy.GetInstance().UpdateUserPassword(T, UserInfo.UserID,
                                                                                              UserInfo.Password, out mess))
                    {
                        mess = "GL-0208:调用柜台修改交易员方法UpdateUserPassword()失败!" + mess; //写调试信息
                        LogHelper.WriteDebug(mess);

                        return(false);
                    }
                }
                catch (VTException Ex)
                {
                    LogHelper.WriteError(Ex.ToString(), Ex.InnerException);
                    mess = Ex.ToString();
                    //写错误日志
                    return(false);
                }
            }

            Database     db   = DatabaseFactory.CreateDatabase();
            DbConnection Conn = db.CreateConnection();

            if (Conn.State != ConnectionState.Open)
            {
                Conn.Open();
            }
            DbTransaction Tran = Conn.BeginTransaction();

            try
            {
                StaticDalClass.UserInfoDAL.Update(UserInfo, Tran, db);

                for (int i = 0; i < dtAdd.Rows.Count; i++)
                {
                    UM_DealerTradeBreedClass DealerTradeBreedClass = new UM_DealerTradeBreedClass();
                    DealerTradeBreedClass.UserID       = UserInfo.UserID;
                    DealerTradeBreedClass.BreedClassID = int.Parse(dtAdd.Rows[i]["BreedClassID"].ToString());
                    StaticDalClass.DealerTradeBreedClassDAL.Add(DealerTradeBreedClass, Tran, db);
                }
                for (int i = 0; i < dtDel.Rows.Count; i++)
                {
                    StaticDalClass.DealerTradeBreedClassDAL.Delete(
                        int.Parse(dtDel.Rows[i]["DealerTradeBreedClassID"].ToString()), Tran, db);
                }
                Tran.Commit();
                mess = "GL-0209:修改成功!";
                return(true);
            }
            catch (Exception Ex)
            {
                Tran.Rollback();
                string      errCode = "GL-0210";
                string      errMsg  = "修改交易员失败!";
                VTException vte     = new VTException(errCode, errMsg, Ex);
                LogHelper.WriteError(vte.ToString(), vte.InnerException);
                mess = vte.ToString();
                return(false);
            }
            finally
            {
                if (Conn.State == ConnectionState.Open)
                {
                    Conn.Close();
                }
            }
        }
 /// <summary>
 /// 管理员查询根据交易员查询交易员各资金账户相关信息
 /// </summary>
 /// <param name="CT">柜台表</param>
 /// <param name="adminId">管理员ID</param>
 /// <param name="adminPassword">管理员密码</param>
 /// <param name="traderId">交易员ID</param>
 /// <param name="strErrorMessage">查询相关异常信息</param>
 /// <returns></returns>
 public List <TradersAccountCapitalInfo> AdminFindTraderCapitalAccountInfoByID(CT_Counter CT, string adminId, string adminPassword, string traderId, out string strErrorMessage)
 {
     try
     {
         using (AccountAndCapitalManagementClient client = GetClient(CT))
         {
             //string mess;
             return(client.AdminFindTraderCapitalAccountInfo(out strErrorMessage, adminId, adminPassword, traderId));
         }
     }
     catch (Exception ex)
     {
         string      errCode = "GL-8111";
         string      errMsg  = "调用清算柜台提供的AdminFindTraderCapitalAccountInfoByID()方法异常," + ex.Message;
         VTException vte     = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(vte.ToString(), vte.InnerException);
         throw vte;
     }
 }
        /// <summary>
        /// 追加资金
        /// </summary>
        /// <param name="model">追加资金实体</param>
        /// <param name="mess"></param>
        /// <returns></returns>
        public bool AddFund(ManagementCenter.Model.UM_FundAddInfo model, out string mess)
        {
            mess = string.Empty;
            UM_UserInfo user = StaticDalClass.UserInfoDAL.GetModel((int)model.UserID);

            if (user == null || user.RoleID != (int)ManagementCenter.Model.CommonClass.Types.RoleTypeEnum.Transaction)
            {
                mess = "GL-0219:交易员编号不存在!"; //写调试信息
                LogHelper.WriteDebug(mess);
                return(false);
            }

            CT_Counter T = GetCounterByUserID((int)model.UserID);

            if (T == null)
            {
                mess = "GL-0220:交易员对应的柜台不存在!"; //写调试信息
                LogHelper.WriteDebug(mess);
                return(false);
            }
            UM_DealerAccount DealerAccount = StaticDalClass.DealerAccountDAL.GetModelByUserIDAndType((int)model.UserID,
                                                                                                     (int)
                                                                                                     GTA.VTS.Common.CommonObject.Types.
                                                                                                     AccountAttributionType
                                                                                                     .
                                                                                                     BankAccount);

            if (DealerAccount == null)
            {
                mess = "GL-0221:交易员对应的银行帐号不存在!"; //写调试信息
                LogHelper.WriteDebug(mess);
                return(false);
            }
            try
            {
                AddCapitalEntity AddCapitalEntity = new AddCapitalEntity();
                AddCapitalEntity.AddHKAmount        = (decimal)model.HKNumber;
                AddCapitalEntity.AddRMBAmount       = (decimal)model.RMBNumber;
                AddCapitalEntity.AddUSAmount        = (decimal)model.USNumber;
                AddCapitalEntity.TraderID           = model.UserID.ToString();
                AddCapitalEntity.BankCapitalAccount = DealerAccount.DealerAccoutID;
                if (!ServiceIn.AccountManageServiceProxy.GetInstance().AddCapital(T, AddCapitalEntity, out mess))
                {
                    mess = "GL-0222:调用柜台追加资金方法AddCapital()失败!" + mess; //写调试信
                    LogHelper.WriteDebug(mess);
                    return(false);
                }
            }
            catch (VTException Ex)
            {
                mess = Ex.ToString();
                //写错误日志
                return(false);
            }
            try
            {
                if (model.HKNumber == decimal.MaxValue)
                {
                    model.HKNumber = null;
                }
                if (model.RMBNumber == decimal.MaxValue)
                {
                    model.RMBNumber = null;
                }
                if (model.USNumber == decimal.MaxValue)
                {
                    model.USNumber = null;
                }
                StaticDalClass.FundAddInfoDAL.Add(model);
            }
            catch (Exception ex)
            {
                string      errCode = "GL-0223";
                string      errMsg  = "追加资金失败!";
                VTException vte     = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(vte.ToString(), vte.InnerException);
                mess = vte.ToString();
                return(false);
            }
            return(true);
        }
        /// <summary>
        /// 添加交易员
        /// </summary>
        /// <param name="dt">权限列表</param>
        /// <param name="UserInfo">交易员实体</param>
        /// <param name="initfund">初始资金实体</param>
        /// <param name="mess"></param>
        /// <returns></returns>
        public bool AddTransaction(DataTable dt, UM_UserInfo UserInfo, InitFund initfund, out string mess)
        {
            try
            {
                List <AccountEntity> l_AccountEntity = new List <AccountEntity>();

                string BackAccount = string.Empty;
                int    UserID;

                Database     db   = DatabaseFactory.CreateDatabase();
                DbConnection Conn = db.CreateConnection();
                if (Conn.State != ConnectionState.Open)
                {
                    Conn.Open();
                }
                DbTransaction Tran = Conn.BeginTransaction();

                try
                {
                    //添加用户基本信息表
                    UserID = StaticDalClass.UserInfoDAL.Add(UserInfo, Tran, db);
                    if (UserID < 1)
                    {
                        mess = "GL-0200:添加用户基本信息失败"; //写调试信息
                        LogHelper.WriteDebug(mess);
                        return(false);
                    }
                    //添加用户交易品种权限表
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        UM_DealerTradeBreedClass DealerTradeBreedClass = new UM_DealerTradeBreedClass();
                        DealerTradeBreedClass.UserID       = UserID;
                        DealerTradeBreedClass.BreedClassID = int.Parse(dt.Rows[i]["BreedClassID"].ToString());
                        StaticDalClass.DealerTradeBreedClassDAL.Add(DealerTradeBreedClass, Tran, db);
                    }
                    //分配帐号列表
                    List <UM_AccountType> AccountType = StaticDalClass.AccountTypeDAL.GetListArray(string.Empty);
                    if (AccountType == null || AccountType.Count == 0)
                    {
                        mess = "GL-0201:获取帐号类型列表失败"; //写调试信息
                        LogHelper.WriteDebug(mess);
                        return(false);
                    }
                    //传加密后的密码给柜台开户
                    string DesPassWord = UtilityClass.DesEncrypt(UserInfo.Password, string.Empty);

                    foreach (UM_AccountType type in AccountType)
                    {
                        UM_DealerAccount DealerAccount = new UM_DealerAccount();
                        DealerAccount.AccountTypeID  = type.AccountTypeID;
                        DealerAccount.DealerAccoutID = ProductionAccount.FormationAccount((int)UserInfo.CouterID,
                                                                                          UserID,
                                                                                          (int)
                                                                                          DealerAccount.AccountTypeID);
                        DealerAccount.IsDo = true;
                        DealerAccount.AccountAttributionType = type.AccountAttributionType;
                        DealerAccount.UserID = UserID;
                        StaticDalClass.DealerAccountDAL.Add(DealerAccount, Tran, db);

                        //添加到调用柜台接口的参数类表
                        {
                            AccountEntity Element = new AccountEntity();
                            Element.Account             = DealerAccount.DealerAccoutID;
                            Element.AccountAAttribution = (int)DealerAccount.AccountAttributionType;
                            Element.AccountType         = (int)DealerAccount.AccountTypeID;
                            Element.CurrencyHK          = initfund.HK;
                            Element.CurrencyRMB         = initfund.RMB;
                            Element.CurrencyUS          = initfund.US;
                            Element.RoleNumber          = (int)GTA.VTS.Common.CommonObject.Types.UserId.Trader;
                            Element.TraderID            = UserID.ToString();
                            Element.TraderPassWord      = DesPassWord;
                            l_AccountEntity.Add(Element);
                        }
                        if (type.AccountAttributionType ==
                            (int)GTA.VTS.Common.CommonObject.Types.AccountAttributionType.BankAccount)
                        {
                            BackAccount = DealerAccount.DealerAccoutID;
                        }
                    }
                    //保存初始资金
                    if (!SaveFund(initfund, Tran, db, BackAccount))
                    {
                        mess = "GL-0202:初始化资金失败!"; //写调试信息
                        LogHelper.WriteDebug(mess);
                        return(false);
                    }
                    Tran.Commit();
                }
                catch (Exception ex)
                {
                    Tran.Rollback();
                    string      errCode = "GL-0203";
                    string      errMsg  = "添加交易员失败!";
                    VTException vte     = new VTException(errCode, errMsg, ex);
                    LogHelper.WriteError(vte.ToString(), vte.InnerException);
                    mess = vte.ToString();
                    return(false);
                }
                finally
                {
                    if (Conn.State == ConnectionState.Open)
                    {
                        Conn.Close();
                    }
                }

                //调用柜台开户方法
                string s;
                try
                {
                    CT_Counter T = StaticDalClass.CounterDAL.GetModel((int)UserInfo.CouterID);

                    if (
                        !ServiceIn.AccountManageServiceProxy.GetInstance().SingleTraderOpenAccount(T, l_AccountEntity, out s))
                    {
                        mess = "GL-0204:调用柜台开户方法SingleTraderOpenAccount失败!" + s; //写调试信息
                        LogHelper.WriteDebug(mess);

                        DelTransaction(UserID, out s);
                        return(false);
                    }
                }
                catch (VTException ex)
                {
                    mess = ex.ToString();
                    LogHelper.WriteError(ex.ToString(), ex.InnerException);
                    DelTransaction(UserID, out s);
                    //写错误信息
                    return(false);
                }
                mess = "GL-0232:开户成功!";
                return(true);
            }
            catch (Exception Ex)
            {
                string      errCode = "GL-0205";
                string      errMsg  = "数据库连接失败!";
                VTException vte     = new VTException(errCode, errMsg, Ex);
                LogHelper.WriteError(vte.ToString(), vte.InnerException);
                mess = vte.ToString();
                return(false);
            }
        }