Ejemplo n.º 1
0
        /// <summary>
        /// 查询登陆成功后的返回信息
        /// </summary>
        /// <param name="loginfo">登陆返回信息</param>
        /// <param name="tradeAccount">用户账号</param>
        /// <param name="tradePwd">用户密码</param>
        public static void ListLoginfo(ref Loginfo loginfo, string tradeAccount, string tradePwd)
        {
            try
            {
                //tradePwd = EncryptHelper.DesEncrypt(tradePwd);

                string sql = "update Base_User set LoginID=@LoginID where Account=@tradeAccount and LoginPwd=@tradePwd and Status='1' and usertype=3";

                DbHelper.ExecuteSql(sql,
                     new System.Data.Common.DbParameter[]{
                       DbHelper.CreateDbParameter(DataBaseType.SqlServer,"@LoginID",DbParameterType.String,loginfo.LoginID,ParameterDirection.Input),
                       DbHelper.CreateDbParameter(DataBaseType.SqlServer,"@tradeAccount",DbParameterType.String,tradeAccount,ParameterDirection.Input),
                       DbHelper.CreateDbParameter(DataBaseType.SqlServer,"@tradePwd",DbParameterType.String,tradePwd,ParameterDirection.Input),
                   });

                loginfo.QuotesAddressIP = ip;
                loginfo.QuotesPort = Convert.ToInt32(port);

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 行情客户端用户登陆
 /// </summary>
 /// <param name="tradeAccount">登陆账号</param>
 /// <param name="tradePwd">登陆密码</param>
 /// <param name="mac">mac地址</param>
 /// <returns>Loginfo</returns>
 public Loginfo GetLoginEx(string tradeAccount, string tradePwd, string mac)
 {
     //实例化实体类
     Loginfo loginfo = new Loginfo();
     loginfo.LoginID = "-1";
     try
     {
         tradePwd = Des3.Des3EncodeCBC(tradePwd);
         //判断用户是否存在 函数1
         if (ComFunction.ListLogin(ref loginfo, tradeAccount, tradePwd, mac))
         {
             loginfo.LoginID = System.Guid.NewGuid().ToString().Replace("-", "");
             loginfo.QuotesAddressIP = ComFunction.ip;
             loginfo.QuotesPort = Convert.ToInt32(ComFunction.port);
         }
     }
     catch (Exception ex)
     {
         ComFunction.WriteErr(ex);
         loginfo.LoginID = "-1";
     }
     return loginfo;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 查询用户是否存在
        /// </summary>
        /// <param name="loginfo">登陆信息</param>
        /// <param name="tradeAccount">用户账账号</param>
        /// <param name="tradePwd">密码</param>
        /// <param name="mac">MAC地址</param>
        /// <returns>存在返回true 否则返回false</returns>
        public static bool ListLogin(ref Loginfo loginfo, string tradeAccount, string tradePwd, string mac)
        {
            System.Data.Common.DbDataReader dbreader = null;
            bool IsSuc = false;
            try
            {
                //tradePwd = EncryptHelper.DesEncrypt(tradePwd);

                loginfo.TdUser = new TradeUser();

                string sql = "select LinkAdress,opentime,email,LastLoginTime, userId,userName,Account,PhoneNum,CardNum,OrderPhone,sex,CardType, MinTrade,OrderUnit," +
                             "MaxTrade,PermitRcash,PermitCcash,PermitDhuo,PermitHshou,PermitRstore,PermitDelOrder,orgid from Base_User where status='1' and usertype=3 " +
                             "and Account=@tradeAccount and LoginPwd=@tradePwd";
                //select                                                      userId,userName,tradeAccount,PhoneNum,CardNum,OrderPhone,sex,CardType, MinTrade,OrderUnit,MaxTrade,PermitRcash,PermitCcash,PermitDhuo,PermitHshou,PermitRstore,PermitDelOrder,
                dbreader = DbHelper.ExecuteReader(sql,
                    new System.Data.Common.DbParameter[]{
                       DbHelper.CreateDbParameter(DataBaseType.SqlServer,"@tradeAccount",DbParameterType.String,tradeAccount,ParameterDirection.Input),
                       DbHelper.CreateDbParameter(DataBaseType.SqlServer,"@tradePwd",DbParameterType.String,tradePwd,ParameterDirection.Input)
                   });
                if (dbreader.Read())
                {
                    loginfo.TdUser.MinTrade = System.DBNull.Value != dbreader["MinTrade"] ? Convert.ToDouble(dbreader["MinTrade"]) : 1;
                    loginfo.TdUser.OrderUnit = System.DBNull.Value != dbreader["OrderUnit"] ? Convert.ToDouble(dbreader["OrderUnit"]) : 1;
                    loginfo.TdUser.MaxTrade = System.DBNull.Value != dbreader["MaxTrade"] ? Convert.ToDouble(dbreader["MaxTrade"]) : 10;
                    loginfo.TdUser.PermitRcash = System.DBNull.Value != dbreader["PermitRcash"] ? Convert.ToBoolean(dbreader["PermitRcash"]) : false;
                    loginfo.TdUser.PermitCcash = System.DBNull.Value != dbreader["PermitCcash"] ? Convert.ToBoolean(dbreader["PermitCcash"]) : false;
                    loginfo.TdUser.PermitDhuo = System.DBNull.Value != dbreader["PermitDhuo"] ? Convert.ToBoolean(dbreader["PermitDhuo"]) : false;
                    loginfo.TdUser.PermitHshou = System.DBNull.Value != dbreader["PermitHshou"] ? Convert.ToBoolean(dbreader["PermitHshou"]) : false;
                    loginfo.TdUser.PermitRstore = System.DBNull.Value != dbreader["PermitRstore"] ? Convert.ToBoolean(dbreader["PermitRstore"]) : false;
                    loginfo.TdUser.PermitDelOrder = System.DBNull.Value != dbreader["PermitDelOrder"] ? Convert.ToBoolean(dbreader["PermitDelOrder"]) : false;

                    loginfo.TdUser.UserID = System.DBNull.Value != dbreader["UserID"] ? dbreader["UserID"].ToString() : string.Empty;
                    loginfo.TdUser.Account = System.DBNull.Value != dbreader["Account"] ? dbreader["Account"].ToString() : string.Empty;
                    loginfo.TdUser.UserName = System.DBNull.Value != dbreader["UserName"] ? dbreader["UserName"].ToString() : string.Empty;
                    loginfo.TdUser.PhoneNum = System.DBNull.Value != dbreader["PhoneNum"] ? dbreader["PhoneNum"].ToString() : string.Empty;
                    loginfo.TdUser.CardNum = System.DBNull.Value != dbreader["CardNum"] ? dbreader["CardNum"].ToString() : string.Empty;
                    loginfo.TdUser.OrderPhone = System.DBNull.Value != dbreader["OrderPhone"] ? dbreader["OrderPhone"].ToString() : string.Empty;
                    loginfo.TdUser.Email = System.DBNull.Value != dbreader["Email"] ? dbreader["Email"].ToString() : string.Empty;
                    loginfo.TdUser.LinkAdress = System.DBNull.Value != dbreader["LinkAdress"] ? dbreader["LinkAdress"].ToString() : string.Empty;
                    if (System.DBNull.Value != dbreader["OpenTime"])
                    {
                        loginfo.TdUser.OpenTime = Convert.ToDateTime(dbreader["OpenTime"]);
                    }
                    else
                    {
                        loginfo.TdUser.OpenTime = null;
                    }
                    if (System.DBNull.Value != dbreader["LastLoginTime"])
                    {
                        loginfo.TdUser.LastLoginTime = Convert.ToDateTime(dbreader["LastLoginTime"]);
                    }
                    else
                    {
                        loginfo.TdUser.LastLoginTime = null;
                    }
                    loginfo.TdUser.Sex = System.DBNull.Value != dbreader["Sex"] ? dbreader["Sex"].ToString() : string.Empty;
                    loginfo.TdUser.CardType = System.DBNull.Value != dbreader["CardType"] ? dbreader["CardType"].ToString() : string.Empty;
                    loginfo.TdUser.OrgId = System.DBNull.Value != dbreader["OrgId"] ? dbreader["OrgId"].ToString() : string.Empty;

                    IsSuc = true;
                }
                //过滤MAC地址
                if (IsSuc)
                {
                    dbreader.Close();
                    dbreader = DbHelper.ExecuteReader(string.Format("select mac from Trade_mac where mac='{0}'", mac));
                    if (dbreader.Read())
                    {
                        IsSuc = false;
                    }
                }
                //过滤IP地址
                if (IsSuc)
                {
                    dbreader.Close();
                    dbreader = DbHelper.ExecuteReader("select startip,endip from Trade_ip");
                    UInt32 istartip = 0;
                    UInt32 iendip = 0;
                    UInt32 icleintip = GetUintIP(GetClientIp());
                    while (dbreader.Read())
                    {
                        istartip = GetUintIP(dbreader["startip"].ToString());
                        iendip = GetUintIP(dbreader["endip"].ToString());
                        if (icleintip >= istartip && icleintip <= iendip)
                        {
                            IsSuc = false;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                if (null != dbreader)
                {
                    dbreader.Close();
                    dbreader.Dispose();
                }
            }
            return IsSuc;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 用户登陆
        /// </summary>
        /// <param name="tradeAccount">登陆账号</param>
        /// <param name="tradePwd">登陆密码</param>
        /// <param name="mac">mac地址</param>
        /// <returns>Loginfo</returns>
        public Loginfo GetLogin(string tradeAccount, string tradePwd, string mac)
        {
            //实例化实体类
            Loginfo loginfo = new Loginfo();
            loginfo.LoginID = "-1";
            try
            {
                tradePwd = Des3.Des3EncodeCBC(tradePwd);
                //判断用户是否存在 函数1
                if (ComFunction.ListLogin(ref loginfo, tradeAccount, tradePwd, mac))
                {
                    loginfo.LoginID = System.Guid.NewGuid().ToString().Replace("-", "");

                    //如果存在 随机生存登陆标识 并更新到数据库 查询行情IP和PORT 返回实体类
                    ComFunction.ListLoginfo(ref loginfo, tradeAccount, tradePwd);
                }
            }
            catch (Exception ex)
            {
                ComFunction.WriteErr(ex);
                loginfo.LoginID = "-1";
            }
            return loginfo;
        }