예제 #1
0
        private void LoadUnlineUser()
        {
            TraceLog.ReleaseWrite("正在加载玩家数据...");
            List <string> userList = new List <string>();

            try
            {
                int              loadUnlineDay = ConfigUtils.GetSetting("LoadUnlineDay", "1").ToInt();
                int              maxCount      = ConfigUtils.GetSetting("MaxLoadCount", "100").ToInt();
                string           sql           = string.Format("SELECT top {0} [UserID] FROM GameUser where LoginDate>@LoginDate order by LoginDate desc", maxCount);
                IDataParameter[] para          = new SqlParameter[] {
                    SqlParamHelper.MakeInParam("@LoginDate", SqlDbType.DateTime, 0, DateTime.Now.Date.AddDays(-loadUnlineDay))
                };
                var dbProvider = DbConnectionProvider.CreateDbProvider(DbConfig.Data);
                using (IDataReader reader = dbProvider.ExecuteReader(CommandType.Text, sql, para))
                {
                    while (reader.Read())
                    {
                        userList.Add(reader["UserID"].ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("LoadUnlineUser:{0}", ex);
            }
            var cacheSet = new GameDataCacheSet <GameUser>();

            foreach (string userId in userList)
            {
                cacheSet.FindKey(userId);
            }
            TraceLog.ReleaseWrite("正在加载玩家结束");
        }
예제 #2
0
파일: Passport.cs 프로젝트: dongliang/Scut
 private bool SetStat(string aPid, PassMark aMark)
 {
     try
     {
         string sUpSql = "update SnsPassportLog set mark=@aNewMark,";
         if (aMark == PassMark.IsPushToNewUser)
         {
             sUpSql += " regpushtime=getdate()";
         }
         else if (aMark == PassMark.IsReg)
         {
             sUpSql += " regtime=getdate()";
         }
         sUpSql += " where passportid=@aPid";
         SqlParameter[] paramsUpdate = new SqlParameter[2];
         string         sTmp         = aPid.Substring(PreAccount.Length);
         paramsUpdate[0] = SqlParamHelper.MakeInParam("@anewMark", SqlDbType.Int, 0, Convert.ToInt32(aMark));
         paramsUpdate[1] = SqlParamHelper.MakeInParam("@aPid", SqlDbType.VarChar, 0, sTmp);
         SqlHelper.ExecuteNonQuery(config.connectionString, CommandType.Text, sUpSql, paramsUpdate);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
예제 #3
0
 public void AppendPageParam(List<SqlParameter> parameters, int pageIndex, int pageSize)
 {
     int statIndex = (pageIndex - 1) * pageSize;
     int endIndex = pageIndex * pageSize;
     parameters.Add(SqlParamHelper.MakeInParam("@statIndex", SqlDbType.Int, 0, statIndex));
     parameters.Add(SqlParamHelper.MakeInParam("@endIndex", SqlDbType.Int, 0, endIndex));
 }
예제 #4
0
    public void InitData(SqlDataReader aReader)
    {
        _GroupId       = Convert.ToInt32(aReader["groupid"]);
        _GroupLv       = Convert.ToInt32(aReader["grouplv"]);
        _GroupName     = Convert.ToString(aReader["groupname"]);
        _IsSuperMaster = Convert.ToBoolean(aReader["IsSuperMaster"]);
        _GroupStat     = Convert.ToBoolean(aReader["GroupStat"]);
        _GameList      = Convert.ToString(aReader["GameList"]);
        string con     = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
        string sGetSql = "select * from GameOA.dbo.oa_GroupPurview where GroupId=@aGetGroupid";

        SqlParameter[] paramsGet = new SqlParameter[1];
        paramsGet[0] = SqlParamHelper.MakeInParam("@aGetGroupId", SqlDbType.Int, 0, _GroupId);
        using (SqlDataReader oReader = SqlHelper.ExecuteReader(con, CommandType.Text, sGetSql, paramsGet))
        {
            if (oReader == null)
            {
                throw new Exception();
            }
            if (oReader.HasRows)
            {
                while (oReader.Read())
                {
                    _ListPageId.Add(Convert.ToInt32(oReader["pageid"]));
                }
            }
        }
    }
예제 #5
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <returns></returns>
        public int ChangePass(string userId)
        {
            try
            {
                //md5加密
                string password = CryptoHelper.DES_Decrypt(_PassportPwd, GameEnvironment.ProductDesEnKey);
                password = PasswordEncryptMd5(password);
                string         sInsertSql   = string.Empty;
                SqlParameter[] paramsUpdate = new SqlParameter[5];
                string         condition    = " where 1=1";
                if (userId.ToUpper().StartsWith("Z"))
                {
                    condition += " and PassportID=@UserId";
                }
                else
                {
                    condition += " and UserID=@UserId";
                }
                sInsertSql = "update SnsUserInfo set passportpwd=@aPassportPwd,RegType=@RegType,DeviceID=@DeviceID,PwdType=@PwdType" + condition;

                paramsUpdate[0] = SqlParamHelper.MakeInParam("@UserId", SqlDbType.VarChar, 0, userId);
                paramsUpdate[1] = SqlParamHelper.MakeInParam("@aPassportPwd", SqlDbType.VarChar, 0, password);
                paramsUpdate[2] = SqlParamHelper.MakeInParam("@RegType", SqlDbType.Int, 0, (int)RegType.Normal);
                paramsUpdate[3] = SqlParamHelper.MakeInParam("@DeviceID", SqlDbType.VarChar, 0, string.Empty);
                paramsUpdate[4] = SqlParamHelper.MakeInParam("@PwdType", SqlDbType.Int, 0, (int)PwdType.MD5);//MD5

                return(SqlHelper.ExecuteNonQuery(config.connectionString, CommandType.Text, sInsertSql, paramsUpdate));
            }
            catch (Exception ex)
            {
                _Logger.SaveLog(ex);
                return(0);
            }
        }
예제 #6
0
        /// <summary>
        /// 是否有绑定DeviceID
        /// </summary>
        /// <returns></returns>
        public static SnsCenterUser GetUserByDeviceID(string deviceID)
        {
            if (deviceID.Length == 0 || deviceID.StartsWith("00:00:00:00:00:"))
            {
                deviceID = Guid.NewGuid().ToString();
            }
            string sGetSql = "select top 1 PassportId, PassportPwd,PwdType, RegType from SnsUserInfo where DeviceID=@DeviceID";
            List <SqlParameter> listTmp = new List <SqlParameter>();

            listTmp.Add(SqlParamHelper.MakeInParam("@DeviceID", SqlDbType.VarChar, 0, deviceID));
            SqlParameter[] paramsGet = listTmp.ToArray();
            using (SqlDataReader aReader = SqlHelper.ExecuteReader(config.connectionString, CommandType.Text, sGetSql, paramsGet))
            {
                if (aReader.Read())
                {
                    PwdType pwdType  = (PwdType)Enum.ToObject(typeof(PwdType), Convert.ToInt32(aReader["PwdType"]));
                    string  password = Convert.ToString(aReader["PassportPwd"]);
                    if (pwdType == PwdType.MD5)
                    {
                        password = CryptoHelper.DES_Encrypt(password, GameEnvironment.ProductDesEnKey);
                    }

                    SnsCenterUser user = new SnsCenterUser(Convert.ToString(aReader["PassportId"]), password, deviceID);
                    user.RegType = (RegType)Enum.ToObject(typeof(RegType), Convert.ToInt32(aReader["RegType"]));
                    return(user);
                }
            }
            return(null);
        }
예제 #7
0
        internal bool ReloadServer(int gameID)
        {
            try
            {
                lock (thisLock)
                {
                    var serverDict = (Dictionary <int, ServerList>)getCache();
                    if (serverDict.ContainsKey(gameID))
                    {
                        serverDict.Remove(gameID);
                    }

                    string         sql       = "SELECT [ID],[GameID],[ServerName],[BaseUrl],[ActiveNum],[Weight],isEnable,[TargetServer],EnableDate,IntranetAddress FROM ServerInfo where GameID=@GameID ORDER BY GameID asc,ID asc";
                    SqlParameter[] paramList = new[]
                    {
                        SqlParamHelper.MakeInParam("@GameID", SqlDbType.Int, 0, gameID)
                    };
                    using (SqlDataReader reader = SqlHelper.ExecuteReader(config.connectionString, CommandType.Text, sql, paramList))
                    {
                        LoadServer(reader, serverDict);
                        addCache(serverDict);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                SaveLog(ex);
                return(false);
            }
        }
        /// <summary>
        /// 添加配置
        /// </summary>
        /// <param name="dir"></param>
        /// <returns></returns>
        public int AddConfig(Direct_Config dir)
        {
            string sql = @"  
                    declare @mynum int;
                    select @mynum=count(1)  from  Direct_Config where name=@urlname and RealUrl=@realurl and softid=@softid
                    if(@mynum=0)
                    begin
                     INSERT INTO Direct_Config(SoftID, UrlName, RealUrl, PID)
                     values(@softid,@urlname,@realurl,@pid)  select  @@IDENTITY;
                    end
                    else
                    select 0";

            SqlParameter[] paras =
            {
                SqlParamHelper.MakeInParam("@softid",  SqlDbType.Int,       4, dir.SoftID),
                SqlParamHelper.MakeInParam("@urlname", SqlDbType.VarChar, 100, dir.UrlName),
                SqlParamHelper.MakeInParam("@realurl", SqlDbType.VarChar, 200, dir.RealUrl),
                SqlParamHelper.MakeInParam("@pid",     SqlDbType.Int,       4, dir.PID),
            };
            int result = 0;

            using (IDataReader dr = SqlHelper.ExecuteReader(StatConn, CommandType.Text, sql, paras))
            {
                if (dr.Read())
                {
                    result = Convert.ToInt32(dr[0]);
                }
            }
            return(result);
        }
예제 #9
0
        /// <summary>
        /// 添加新的关键字
        /// </summary>
        /// <param name="aKeyWord"></param>
        /// <param name="aStat"></param>
        /// <returns></returns>
        public bool AddNewKeyWord(string aKeyWord, int aStat)
        {
            string con     = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
            string sGetSql = "select * from SnsCenter.dbo.ForbidWordKey where keyword=@aKeyWord";

            SqlParameter[] paramsGet = new SqlParameter[2];
            paramsGet[0] = SqlParamHelper.MakeInParam("@aKeyWord", SqlDbType.VarChar, 0, aKeyWord);
            using (SqlDataReader aReader = SqlHelper.ExecuteReader(con, CommandType.Text, sGetSql, paramsGet))
            {
                if (aReader == null)
                {
                    return(false);
                }

                if (aReader.HasRows)
                {
                    return(false);
                }
            }

            string sInsertSql = "insert into SnsCenter.dbo.forbidWordKey(keyWord, Stat)values(@aKeyWord, @aStat)";

            paramsGet[1] = SqlParamHelper.MakeInParam("@aStat", SqlDbType.Int, 0, aStat);
            if (SqlHelper.ExecuteNonQuery(con, CommandType.Text, sInsertSql, paramsGet) == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #10
0
        public static void SetLoginType(ref RegType regType, ref PwdType pwdType, string passportId)
        {
            string sGetSql = "select top 1 RegType,DeviceID,PwdType from SnsUserInfo where PassportId=@aPassportId";
            List <SqlParameter> listTmp = new List <SqlParameter>();

            listTmp.Add(SqlParamHelper.MakeInParam("@aPassportId", SqlDbType.VarChar, 0, passportId));
            SqlParameter[] paramsGet = listTmp.ToArray();
            using (SqlDataReader aReader = SqlHelper.ExecuteReader(config.connectionString, CommandType.Text, sGetSql, paramsGet))
            {
                if (aReader.Read())
                {
                    string  deviceID = Convert.ToString(aReader["DeviceID"]);
                    RegType rt       = (RegType)Enum.ToObject(typeof(RegType), Convert.ToInt32(aReader["RegType"]));
                    pwdType = (PwdType)Enum.ToObject(typeof(PwdType), Convert.ToInt32(aReader["PwdType"]));
                    if (rt == RegType.Other && regType != RegType.Other)
                    {
                        //渠道登陆的用户允许更换包登陆
                        regType = string.IsNullOrEmpty(deviceID) ? RegType.Normal : rt;
                    }
                    else
                    {
                        regType = rt;
                    }
                }
            }
        }
        /// <summary>
        /// 获取Moborobo的MAC列表
        /// </summary>
        /// <param name="statDate"></param>
        /// <returns></returns>
        public string GetMoboroboMacs(DateTime statDate)
        {
            string cmdText =
                "select Platform,MAC,NewUserCount from PCDailyMac with(nolock) where SoftID=@SoftID and StatDate=@StatDate order by MAC,Platform";

            SqlParameter[] parameters = new SqlParameter[]
            {
                SqlParamHelper.MakeInParam("@SoftID", SqlDbType.Int, 4, 58),
                SqlParamHelper.MakeInParam("@StatDate", SqlDbType.Int, 4, statDate.ToString("yyyyMMdd"))
            };
            StringBuilder moboroboMacsJson = new StringBuilder("{\"success\":true,\"data\":[");

            using (
                SqlDataReader reader = SqlHelper.ExecuteReader(ComputingDB_Sjqd_ConnString, CommandType.Text, cmdText,
                                                               parameters))
            {
                while (reader.Read())
                {
                    MobileOption platform     = (MobileOption)Convert.ToInt32(reader["Platform"]);
                    string       mac          = reader["MAC"].ToString();
                    int          newUserCount = Convert.ToInt32(reader["NewUserCount"]);
                    moboroboMacsJson.AppendFormat("{{\"MAC\":\"{0}\",\"Platform\":\"{1}\",\"NewUserCount\":{2}}},", mac,
                                                  platform, newUserCount);
                }
            }
            return(moboroboMacsJson.ToString().TrimEnd(',') + "]}");
        }
        /// <summary>
        /// 获取MAC地址关联的新增设备数
        /// </summary>
        /// <param name="softId"></param>
        /// <param name="mac"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        public Dictionary <MobileOption, int> GetNewUserCountsByMac(int softId, string mac, DateTime startDate,
                                                                    DateTime endDate)
        {
            string cmdText =
                "select Platform,NewUserCount from PCDailyMac with(nolock) where SoftID=@SoftID and MAC=@MAC and StatDate between @StartDate and @EndDate";

            SqlParameter[] parameters = new SqlParameter[]
            {
                SqlParamHelper.MakeInParam("@SoftID", SqlDbType.Int, 4, softId),
                SqlParamHelper.MakeInParam("@MAC", SqlDbType.VarChar, 50, mac),
                SqlParamHelper.MakeInParam("@StartDate", SqlDbType.Int, 4, startDate.ToString("yyyyMMdd")),
                SqlParamHelper.MakeInParam("@EndDate", SqlDbType.Int, 4, endDate.ToString("yyyyMMdd"))
            };
            Dictionary <MobileOption, int> newUserCountsByMac = new Dictionary <MobileOption, int>();

            using (
                SqlDataReader reader = SqlHelper.ExecuteReader(ComputingDB_Sjqd_ConnString, CommandType.Text, cmdText,
                                                               parameters))
            {
                while (reader.Read())
                {
                    MobileOption platform     = (MobileOption)Convert.ToInt32(reader["Platform"]);
                    int          newUserCount = Convert.ToInt32(reader["NewUserCount"]);
                    if (newUserCountsByMac.ContainsKey(platform))
                    {
                        newUserCountsByMac[platform] = newUserCountsByMac[platform] + newUserCount;
                    }
                    else
                    {
                        newUserCountsByMac.Add(platform, newUserCount);
                    }
                }
            }
            return(newUserCountsByMac);
        }
예제 #13
0
    public bool GetFormula()
    {
        bool   bHasFormula = false;
        string con         = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
        string sGetSql     = "select * from ConfigFormula where formulaid=@aformulaid";

        SqlParameter[] paramsGet = new SqlParameter[1];
        paramsGet[0] = SqlParamHelper.MakeInParam("@aformulaid", SqlDbType.Int, 0, _formulaId);
        using (SqlDataReader aReader = SqlHelper.ExecuteReader(con, CommandType.Text, sGetSql, paramsGet))
        {
            if (aReader == null)
            {
                throw new Exception();
            }
            if (aReader.HasRows)
            {
                bHasFormula = true;
                aReader.Read();
                this.InitData(aReader);
            }
        }

        if (bHasFormula)
        {
        }

        return(bHasFormula);
    }
예제 #14
0
        internal int ChangeUserInfo(string pid, SnsUser snsuser)
        {
            try
            {
                string sInsertSql = string.Empty;
                List <SqlParameter> paramsUpdate = new List <SqlParameter>();
                paramsUpdate.Add(SqlParamHelper.MakeInParam("@PassportId", SqlDbType.VarChar, 0, pid));

                sInsertSql = "update SnsUserInfo set PassportId=@PassportId";
                if (!string.IsNullOrEmpty(snsuser.Mobile))
                {
                    sInsertSql += ", Mobile=@Mobile";
                    paramsUpdate.Add(SqlParamHelper.MakeInParam("@Mobile", SqlDbType.VarChar, 0, snsuser.Mobile));
                }
                if (!string.IsNullOrEmpty(snsuser.Mail))
                {
                    sInsertSql += ", Mail=@Mail";
                    paramsUpdate.Add(SqlParamHelper.MakeInParam("@Mail", SqlDbType.VarChar, 0, snsuser.Mail));
                }
                if (!string.IsNullOrEmpty(snsuser.RealName))
                {
                    sInsertSql += ", RealName=@RealName";
                    paramsUpdate.Add(SqlParamHelper.MakeInParam("@RealName", SqlDbType.VarChar, 0, snsuser.RealName));
                }
                if (!string.IsNullOrEmpty(snsuser.IDCards))
                {
                    sInsertSql += ", IDCards=@IDCards";
                    paramsUpdate.Add(SqlParamHelper.MakeInParam("@IDCards", SqlDbType.VarChar, 0, snsuser.IDCards));
                }
                if (!string.IsNullOrEmpty(snsuser.ActiveCode))
                {
                    sInsertSql += ", ActiveCode=@ActiveCode";
                    paramsUpdate.Add(SqlParamHelper.MakeInParam("@ActiveCode", SqlDbType.VarChar, 0, snsuser.ActiveCode));
                }
                if (snsuser.SendActiveDate > DateTime.MinValue)
                {
                    sInsertSql += ", SendActiveDate=@SendActiveDate";
                    paramsUpdate.Add(SqlParamHelper.MakeInParam("@SendActiveDate", SqlDbType.DateTime, 0, snsuser.SendActiveDate));
                }
                if (snsuser.ActiveDate > DateTime.MinValue)
                {
                    sInsertSql += ", ActiveDate=@ActiveDate";
                    paramsUpdate.Add(SqlParamHelper.MakeInParam("@ActiveDate", SqlDbType.DateTime, 0, snsuser.ActiveDate));
                }
                if (!string.IsNullOrEmpty(snsuser.WeixinCode))
                {
                    sInsertSql += ", WeixinCode=@WeixinCode";
                    paramsUpdate.Add(SqlParamHelper.MakeInParam("@WeixinCode", SqlDbType.VarChar, 0, snsuser.WeixinCode));
                }
                sInsertSql += " where PassportId=@PassportId";

                return(SqlHelper.ExecuteNonQuery(config.connectionString, CommandType.Text, sInsertSql, paramsUpdate.ToArray()));
            }
            catch (Exception ex)
            {
                _Logger.SaveLog(ex);
                return(0);
            }
        }
예제 #15
0
        public int InsertSnsUser(string[] paramNames, string[] paramValues)
        {
            SnsPassport oSnsPassportLog = new SnsPassport();

            if (!oSnsPassportLog.VerifyRegPassportId(_PassportId))
            {
                return(0);
            }
            //md5加密
            string password = CryptoHelper.DES_Decrypt(_PassportPwd, GameEnvironment.ProductDesEnKey);

            password = PasswordEncryptMd5(password);
            string sInsertSql = string.Empty;

            string extColumns = string.Join(",", paramNames);

            extColumns = extColumns.TrimEnd().Length > 0 ? "," + extColumns : string.Empty;
            string paramColumns = string.Join(",@", paramNames);

            paramColumns = paramColumns.TrimEnd().Length > 0 ? ",@" + paramColumns : string.Empty;

            List <SqlParameter> paramsInsert = new List <SqlParameter>();

            sInsertSql  = string.Format("insert into SnsUserInfo(passportid, passportpwd, DeviceID, RegType, RegTime,RetailID,RetailUser,PwdType{0})", extColumns);
            sInsertSql += string.Format("values(@aPassportId, @aPassportPwd, @DeviceID, @RegType, @RegTime, @RetailID, @RetailUser,@PwdType{0}) select @@IDENTITY", paramColumns);
            paramsInsert.Add(SqlParamHelper.MakeInParam("@aPassportId", SqlDbType.VarChar, 0, _PassportId));
            paramsInsert.Add(SqlParamHelper.MakeInParam("@aPassportPwd", SqlDbType.VarChar, 0, password));
            paramsInsert.Add(SqlParamHelper.MakeInParam("@deviceID", SqlDbType.VarChar, 0, _deviceID));
            paramsInsert.Add(SqlParamHelper.MakeInParam("@RegType", SqlDbType.Int, 0, (int)RegType));
            paramsInsert.Add(SqlParamHelper.MakeInParam("@RegTime", SqlDbType.DateTime, 0, DateTime.Now));
            paramsInsert.Add(SqlParamHelper.MakeInParam("@RetailID", SqlDbType.VarChar, 0, RetailID));
            paramsInsert.Add(SqlParamHelper.MakeInParam("@RetailUser", SqlDbType.VarChar, 0, RetailUser));
            paramsInsert.Add(SqlParamHelper.MakeInParam("@PwdType", SqlDbType.Int, 0, (int)PwdType.MD5));
            for (int i = 0; i < paramNames.Length; i++)
            {
                paramsInsert.Add(SqlParamHelper.MakeInParam("@" + paramNames[i], SqlDbType.VarChar, 0, paramValues[i]));
            }
            try
            {
                if (!oSnsPassportLog.SetPassportReg(_PassportId))
                {
                    throw new Exception("SetPassportReg Error");
                }
                using (SqlDataReader aReader = SqlHelper.ExecuteReader(config.connectionString, CommandType.Text, sInsertSql, paramsInsert.ToArray()))
                {
                    if (aReader.Read())
                    {
                        _userid = Convert.ToInt32(aReader[0]);
                    }
                }
                return(_userid);
            }
            catch (Exception ex)
            {
                _Logger.SaveLog(ex);
                return(0);
            }
        }
예제 #16
0
파일: BaseLogin.cs 프로젝트: dongliang/Scut
    /// <summary>
    /// 检测用户输入的登录用户名与密码是否一直
    /// </summary>
    /// <param name="aUserName"></param>
    /// <param name="aPwd"></param>
    /// <param name="isExpire">过期</param>
    /// <returns></returns>
    protected bool CheckUserLogin(string aUserName, string aPwd, out bool isExpire)
    {
        isExpire = false;
        string aTmpPwdMd5 = this.DoMd5(aPwd);

        try
        {
            string         con         = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
            string         sSqlExist   = "select * from GameOA.dbo.OA_User where UserName=@aUserName";
            SqlParameter[] paramsLogin = new SqlParameter[1];
            paramsLogin[0] = SqlParamHelper.MakeInParam("@aUserName", SqlDbType.VarChar, 0, aUserName);
            using (SqlDataReader loginReader = SqlHelper.ExecuteReader(con, CommandType.Text, sSqlExist, paramsLogin))
            {
                if (loginReader == null)
                {
                    return(false);
                }
                else
                {
                    if (loginReader.HasRows && loginReader.Read())
                    {
                        DateTime expireDate = ConvertHelper.ToDateTime(loginReader["pwdmodifydate"]);
                        if (expireDate.AddDays(oa_changepwd_day) < DateTime.Now)//30天过期
                        {
                            isExpire = true;
                        }
                        if (Convert.ToString(loginReader["UserPassword"]) == aTmpPwdMd5)
                        {
                            BaseCookie oBaseSession = new BaseCookie();
                            oBaseSession.SaveCookie(loginReader, 4 * 60);

                            string         sql        = @"INSERT INTO [GameOA].[dbo].[LoginLog]([LoginIP],[LoginID],[LoginTime])VALUES(@LoginIP,@LoginID,getdate())";
                            string         LoginIP    = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
                            SqlParameter[] paramsList = new SqlParameter[] {
                                SqlParamHelper.MakeInParam("@LoginIP", SqlDbType.VarChar, 0, LoginIP),
                                SqlParamHelper.MakeInParam("@LoginID", SqlDbType.VarChar, 20, aUserName)
                            };
                            SqlHelper.ExecuteNonQuery(con, CommandType.Text, sql, paramsList);

                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
        }
        catch
        {
            return(false);
        }
    }
예제 #17
0
    public static string AddLogToDB(HttpRequest aRequest, int aUserId, string aUserIp)
    {
        try
        {
            string sLogValue = "\r\n";

            sLogValue += "userid=" + aUserId.ToString() + "\r\n";
            //-------------------------------------------
            string aRequestType = aRequest.RequestType.ToLower();
            sLogValue += aRequestType + "\r\n";
            //----------------------------------------
            string sHostUrl = aRequest.Url.Host;
            sLogValue += sHostUrl + "\r\n";
            //-----------------------------------
            string aRawUrl = aRequest.Path;
            sLogValue += aRawUrl + "\r\n";
            //-----------------------------------
            string aReqValue = "";
            if (aRequestType == "get")
            {
                aReqValue = aRequest.QueryString.ToString();
            }
            else
            {
                string[] aFormKeys = aRequest.Form.AllKeys;
                for (int i = 0; i < aFormKeys.Length; i++)
                {
                    aReqValue += aFormKeys[i].ToString() + "=" + aRequest.Form[i].ToString();
                    if (i < aFormKeys.Length - 1)
                    {
                        aReqValue += "&";
                    }
                }
            }
            sLogValue += aReqValue + "\r\n";
            //-------------------
            string sInsertSql = "insert into GameOA.dbo.OA_VisitPageLog(userid, LogUrlHost, LogPath, LogRequestType, LogClientRequest, LogUserIp, LogTime)";
            sInsertSql += "values(@aUserId, @aLogUrlHost, @aLogPath, @aLogRequestType, @aLogClientRequest, @aLogUserId, getdate())";
            string         con          = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
            SqlParameter[] paramsInsert = new SqlParameter[6];
            paramsInsert[0] = SqlParamHelper.MakeInParam("@aUserId", SqlDbType.Int, 0, aUserId);
            paramsInsert[1] = SqlParamHelper.MakeInParam("@aLogUrlHost", SqlDbType.VarChar, 0, sHostUrl);
            paramsInsert[2] = SqlParamHelper.MakeInParam("@aLogPath", SqlDbType.VarChar, 0, aRawUrl);
            paramsInsert[3] = SqlParamHelper.MakeInParam("@aLogRequestType", SqlDbType.VarChar, 0, aRequestType);
            paramsInsert[4] = SqlParamHelper.MakeInParam("@aLogClientRequest", SqlDbType.VarChar, 0, aReqValue);
            paramsInsert[5] = SqlParamHelper.MakeInParam("@aLogUserId", SqlDbType.VarChar, 0, aUserIp);
            SqlHelper.ExecuteNonQuery(con, CommandType.Text, sInsertSql, paramsInsert);
            //   paramsInsert[6] = conndb.MakeInParam("@aLogUrlHost", SqlDbType.VarChar, 0, sHostUrl);

            return(sLogValue);
        }
        catch (Exception ex)
        {
            return(ex.Message + ex.StackTrace);
        }
        //------------------
    }
예제 #18
0
        /// <summary>
        /// 获取平台版本数据列表
        /// </summary>
        /// <param name="platform"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="Count"></param>
        /// <returns></returns>
        public static List <SjzsVersions> GetSoftVersionsList(int platform, int pageIndex, int pageSize, out int Count)
        {
            string cmdText = @"WITH T AS (
                                SELECT ROW_NUMBER() OVER(ORDER BY version ASC) row_id,ID,[platform],version,E_version FROM Sjzs__Versions {0}
                                )
                                SELECT * FROM (SELECT row_id,ID,[platform],version,E_version FROM T WHERE row_id BETWEEN @startIndex AND @endIndex
                                UNION ALL
                                SELECT -1,COUNT(0),'','','' FROM T)A ORDER BY row_id";

            if (platform > 0 && platform != 99)
            {
                cmdText = string.Format(cmdText, "WHERE [Platform]=@Platform");
            }
            else
            {
                cmdText = string.Format(cmdText, string.Empty);
            }
            SqlParameter[] param = new SqlParameter[]
            {
                SqlParamHelper.MakeInParam("@Platform", SqlDbType.Int, 4, platform),
                SqlParamHelper.MakeInParam("@startIndex", SqlDbType.Int, 4, (pageIndex - 1) * pageSize + 1),
                SqlParamHelper.MakeInParam("@endIndex", SqlDbType.Int, 4, pageIndex * pageSize)
            };

            Count = 0;
            List <SjzsVersions> list = new List <SjzsVersions>();

            using (IDataReader read = SqlHelper.ExecuteReader(_connectionString, CommandType.Text, cmdText, param))
            {
                while (read.Read())
                {
                    if (read["row_id"].ToInt32(0) == -1)
                    {
                        Count = read["id"].ToInt32(0);
                    }
                    else
                    {
                        list.Add(new SjzsVersions()
                        {
                            ID       = read["id"].ToInt32(0),
                            SoftId   = 0,
                            Platform = read["platform"].ToString().ToEnum <MobileOption>(MobileOption.All),
                            Version  =
                                read["version"] != null && read["version"] != DBNull.Value
                                        ? read["version"].ToString()
                                        : string.Empty,
                            E_Version =
                                read["e_version"] != null && read["e_version"] != DBNull.Value
                                        ? read["e_version"].ToString()
                                        : string.Empty
                        });
                    }
                }
            }

            return(list);
        }
예제 #19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="uID"></param>
        /// <returns></returns>
        public List <FeedbackInfo> GetFeedBackList(int uID)
        {
            string sql = string.Format("SELECT [GMID],[UId],[GameID],[ServerID],[GMType],[content],[SubmittedTime],[RContent],[ReplyTime],[ReplyID],Pid,NickName FROM GMFeedBack where UId=@UId order by SubmittedTime desc");

            SqlParameter[] parameters = new[] {
                SqlParamHelper.MakeInParam("@UId", SqlDbType.Int, 0, uID),
            };
            return(GetFeedBackList(sql, parameters));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        private DateTime GetKeyTime_TimeStr(string key)
        {
            string sql = "select [value] from EtlStates with(nolock) where [key]=@key";

            SqlParameter[] parameters = new SqlParameter[]
            {
                SqlParamHelper.MakeInParam("@key", SqlDbType.VarChar, 100, key)
            };
            return(Convert.ToDateTime(SqlHelper.ExecuteScalar(StatConn, CommandType.Text, sql, parameters)));
        }
예제 #21
0
        /// <summary>
        /// 修改平台版本
        /// </summary>
        /// <param name="softVer"></param>
        /// <returns></returns>
        public static int UpdateSoftVersions(SjzsVersions softVer)
        {
            string cmdText = "UPDATE Sjzs__Versions SET E_Version = @E_Version WHERE ID = @ID";

            SqlParameter[] param = new SqlParameter[]
            {
                SqlParamHelper.MakeInParam("@E_Version", SqlDbType.VarChar, 100, softVer.E_Version),
                SqlParamHelper.MakeInParam("@ID", SqlDbType.Int, 4, softVer.ID)
            };
            return(SqlHelper.ExecuteNonQuery(_connectionString, CommandType.Text, cmdText, param));
        }
        public int DeleteConfig(Direct_Config dir)
        {
            string sql = @"delete from Direct_Config
                           where ID=@id;";

            SqlParameter[] paras =
            {
                SqlParamHelper.MakeInParam("@id", SqlDbType.Int, 4, dir.ID),
            };
            return(SqlHelper.ExecuteNonQuery(StatConn, CommandType.Text, sql, paras));
        }
예제 #23
0
        /// <summary>
        /// 更新固件版本
        /// </summary>
        /// <param name="gjb"></param>
        /// <returns></returns>
        public static int Update(FwVersions gjb)
        {
            string cmdText = @"UPDATE Sjzs__fwVersions SET E_FwVersion = @E_FwVersion WHERE ID=@id";

            SqlParameter[] param = new SqlParameter[]
            {
                SqlParamHelper.MakeInParam("@id", SqlDbType.Int, 4, gjb.ID),
                SqlParamHelper.MakeInParam("@E_FwVersion", SqlDbType.VarChar, 100, gjb.E_FwVersion)
            };
            return(SqlHelper.ExecuteNonQuery(_connectionString, CommandType.Text, cmdText, param));
        }
예제 #24
0
        /// <summary>
        /// 通过微信号
        /// </summary>
        /// <param name="openId"></param>
        /// <returns></returns>
        internal SnsUser GetUserByWeixin(string openId)
        {
            SnsUser             snsUser = new SnsUser();
            string              sGetSql = "select top 1 [UserId],[PassportID],[PassportPwd],[DeviceID],[RegType],[RegTime],[RetailID],[RetailUser],[Mobile],[Mail],[PwdType],[RealName],[IDCards],[ActiveCode],[SendActiveDate],[ActiveDate],WeixinCode from SnsUserInfo where WeixinCode=@WeixinCode";
            List <SqlParameter> listTmp = new List <SqlParameter>();

            listTmp.Add(SqlParamHelper.MakeInParam("@WeixinCode", SqlDbType.VarChar, 0, openId));
            SqlParameter[] paramsGet = listTmp.ToArray();
            SetUserInfo(sGetSql, paramsGet, snsUser);
            return(snsUser);
        }
예제 #25
0
        /// <summary>
        /// 修改设备型号
        /// </summary>
        /// <param name="sbx"></param>
        /// <returns></returns>
        public static int UpdateSBXH(Jixings sbx)
        {
            string cmdText = "UPDATE Sjzs__Jixing SET E_jixing = @E_jixing WHERE ID = @ID";

            SqlParameter[] param = new SqlParameter[]
            {
                SqlParamHelper.MakeInParam("@E_jixing", SqlDbType.VarChar, 100, sbx.E_Sbxh),
                SqlParamHelper.MakeInParam("@ID", SqlDbType.Int, 4, sbx.ID)
            };
            return(SqlHelper.ExecuteNonQuery(_connectionString, CommandType.Text, cmdText, param));
        }
예제 #26
0
 public void AddParameter(string field, SqlDbType sqlDbType, int size, object value)
 {
     if (fieldList.ContainsKey(field))
     {
         fieldList[field] = SqlParamHelper.MakeInParam(PreParamChar + field, sqlDbType, size, value);
     }
     else
     {
         fieldList.Add(field, SqlParamHelper.MakeInParam(PreParamChar + field, sqlDbType, size, value));
     }
 }
예제 #27
0
        private void DoQuery()
        {
            List <SqlParameter> paramValues = new List <SqlParameter>();
            string    condition             = "Where 1=1";
            JsonTable jsonTable             = new JsonTable();

            if (GetParam("NickName").Length > 0)
            {
                condition += " and NickName like @NickName";
                paramValues.Add(SqlParamHelper.MakeInParam("@NickName", SqlDbType.VarChar, 0, "%" + GetParam("NickName") + "%"));
            }
            if (GetParam("Pid").Length > 0)
            {
                condition += " and Pid=@Pid";
                paramValues.Add(SqlParamHelper.MakeInParam("@Pid", SqlDbType.VarChar, 0, GetParam("Pid")));
            }
            if (GetParam("UserStatus").Length > 0)
            {
                condition += " and UserStatus=@UserStatus";
                paramValues.Add(SqlParamHelper.MakeInParam("@UserStatus", SqlDbType.VarChar, 0, GetParam("UserStatus")));
            }
            if (GetParam("MsgState").Length > 0)
            {
                condition += " and MsgState=@MsgState";
                paramValues.Add(SqlParamHelper.MakeInParam("@MsgState", SqlDbType.VarChar, 0, GetParam("MsgState")));
            }
            if (GetParam("fromDate").Length > 0)
            {
                condition += " and CreateDate>=@fromDate";
                paramValues.Add(SqlParamHelper.MakeInParam("@fromDate", SqlDbType.VarChar, 0, GetParam("fromDate")));
            }
            if (GetParam("toDate").Length > 0)
            {
                condition += " and CreateDate<=@toDate";
                paramValues.Add(SqlParamHelper.MakeInParam("@toDate", SqlDbType.VarChar, 0, GetParam("toDate")));
            }
            if (IsChannel)
            {
                condition += " and RetailID=@ChannelID";
                paramValues.Add(SqlParamHelper.MakeInParam("@ChannelID", SqlDbType.VarChar, 0, EmpRetailId));
            }

            var service = new DdzDataService(GameID, ServerID);

            AppendPageParam(paramValues, PageIndex, PageSize);
            var getter = service.Get <UserGetter>(condition, PageIndex, PageSize, paramValues);

            jsonTable.rows  = getter.GetData();
            jsonTable.total = getter.RecordCount;

            _context.Response.Write(jsonTable.ToJson());
        }
예제 #28
0
 public void AddParam(string paramName, SqlDbType sqlType, int size, object value)
 {
     if (parameter.Exists(p => p.ParameterName == paramName))
     {
         SqlParameter sqlParam = parameter.Find(p => p.ParameterName == paramName);
         sqlParam.SqlDbType = sqlType;
         sqlParam.Value     = value;
         sqlParam.Size      = size;
     }
     else
     {
         parameter.Add(SqlParamHelper.MakeInParam(paramName, sqlType, size, value));
     }
 }
        /// <summary>
        /// 更新跳转配置
        /// </summary>
        /// <returns></returns>
        public int UpdateConfig(Direct_Config dir)
        {
            string sql = string.Format(@"update dbo.Direct_Config
                                        set SoftID=@softid, UrlName=@urlname,RealUrl=@realurl,PID=@pid
                                        where ID=@id");

            SqlParameter[] paras =
            {
                SqlParamHelper.MakeInParam("@softid",  SqlDbType.Int,       4, dir.SoftID),
                SqlParamHelper.MakeInParam("@urlname", SqlDbType.VarChar, 100, dir.UrlName),
                SqlParamHelper.MakeInParam("@realurl", SqlDbType.VarChar, 200, dir.RealUrl),
                SqlParamHelper.MakeInParam("@pid",     SqlDbType.Int,       4, dir.PID),
            };
            return(SqlHelper.ExecuteNonQuery(StatConn, CommandType.Text, sql, paras));
        }
예제 #30
0
        /// <summary>
        /// 格式化where中IN从语句的表达式
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="values"></param>
        public virtual string FormatExpressionByIn(string fieldName, params object[] values)
        {
            if (values.Length == 0)
            {
                throw new ArgumentException("values len:0");
            }
            var paramNames = new string[values.Length];

            for (int i = 0; i < paramNames.Length; i++)
            {
                var paramName = SqlParamHelper.FormatParamName(fieldName + (i + 1));
                paramNames[i] = paramName;
                AddParam(SqlParamHelper.MakeInParam(paramName, values[i]));
            }
            return(string.Format("{0} IN ({1})", SqlParamHelper.FormatName(fieldName), string.Join(",", paramNames)));
        }