Ejemplo n.º 1
0
 protected override bool InitCache()
 {
     try
     {
         string con     = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
         string sGetSql = "select [userid],[username],[userpassword],[useremail],[userinfo],[usergroupid],[userCName] from GameOa.dbo.oa_user ";
         using (SqlDataReader aReader = SqlHelper.ExecuteReader(con, CommandType.Text, sGetSql))
         {
             if (aReader == null)
             {
                 throw new Exception();
             }
             List <BaseEmployee> listBaseEmp = new List <BaseEmployee>();
             if (aReader.HasRows)
             {
                 while (aReader.Read())
                 {
                     BaseEmployee oTmpEmployee = new BaseEmployee(Convert.ToInt32(aReader["userid"]));
                     oTmpEmployee.InitData(aReader);
                     listBaseEmp.Add(oTmpEmployee);
                 }
             }
             this.addCache(listBaseEmp);
             return(true);
         }
     }
     catch (Exception ex)
     {
         this.SaveLog(ex);
         return(false);
     }
 }
Ejemplo n.º 2
0
 protected override bool InitCache()
 {
     try
     {
         string con     = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
         string sGetSql = "select * from GameOA.dbo.oa_PermitIp where PermitStat=1";
         using (SqlDataReader aReader = SqlHelper.ExecuteReader(con, CommandType.Text, sGetSql))
         {
             if (aReader == null)
             {
                 throw new Exception();
             }
             List <string> permitIps = new List <string>();
             if (aReader.HasRows)
             {
                 while (aReader.Read())
                 {
                     permitIps.Add(aReader["PermitIp"].ToString());
                 }
             }
             this.addCache(permitIps);
             return(true);
         }
     }
     catch (Exception ex)
     {
         this.SaveLog(ex);
         return(false);
     }
 }
Ejemplo n.º 3
0
 protected override bool InitCache()
 {
     try
     {
         string con     = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
         string sGetSql = "select * from GameOA.dbo.oa_usergroup";
         using (SqlDataReader rReader = SqlHelper.ExecuteReader(con, CommandType.Text, sGetSql))
         {
             if (rReader == null)
             {
                 throw new Exception();
             }
             List <BaseEmployeeGroup> tmpList = new List <BaseEmployeeGroup>();
             if (rReader.HasRows)
             {
                 while (rReader.Read())
                 {
                     BaseEmployeeGroup oTmp = new BaseEmployeeGroup();
                     oTmp.InitData(rReader);
                     tmpList.Add(oTmp);
                 }
             }
             this.addCache(tmpList);
             return(true);
         }
     }
     catch (Exception ex)
     {
         this.SaveLog(ex);
         return(false);
     }
 }
Ejemplo n.º 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"]));
                }
            }
        }
    }
Ejemplo n.º 5
0
        public void RunError()
        {
            MessageConfig    config    = ConfigContext.GetInstance().SysMessageConfig;
            string           pcName    = Dns.GetHostName();
            HashSet <string> queuqHash = new HashSet <string>();

            new Thread(() =>
            {
                while (true)
                {
                    var messageList = MessageQueue.GetPrivateQueuesByMachine(pcName);
                    foreach (var messageQueue in messageList)
                    {
                        if (messageQueue.QueueName.ToLower().IndexOf("errorlogcmdsql") != -1)
                        {
                            if (!queuqHash.Contains(messageQueue.QueueName))
                            {
                                queuqHash.Add(messageQueue.QueueName);

                                MessageConfig tempConfig        = new MessageConfig();
                                tempConfig.IsErrorQueue         = true;
                                tempConfig.ManagerName          = config.ManagerName;
                                tempConfig.ManagerThreadNumber  = config.ManagerThreadNumber;
                                tempConfig.ManagerThreadTimeOut = config.ManagerThreadTimeOut;
                                tempConfig.ManagerMessagePath   = messageQueue.Path;
                                tempConfig.ManagerErrorPath     = config.ManagerErrorPath;
                                new Thread(new MSMQDistribution().Receive).Start(tempConfig);
                            }
                        }
                    }
                    Thread.Sleep(60000);
                }
            }).Start();
        }
Ejemplo n.º 6
0
 protected override bool InitCache()
 {
     try
     {
         string con  = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
         string sSql = "select * from GameOA.dbo.OA_Config order by Id";
         using (SqlDataReader reader = SqlHelper.ExecuteReader(con, CommandType.Text, sSql))
         {
             if (reader == null)
             {
                 throw new Exception();
             }
             if (reader.HasRows)
             {
                 Dictionary <string, string> dict = new Dictionary <string, string>();
                 while (reader.Read())
                 {
                     dict.Add(reader["Name"].ToString(), reader["Value"].ToString());
                 }
                 this.addCache(dict);
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         this.SaveLog(ex);
         return(false);
     }
 }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
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);
    }
Ejemplo n.º 9
0
        /// <summary>
        /// 监控系统整体性能
        /// </summary>
        public void MonitorAll()
        {
            PC.CategoryName = "Processor";        //指定获取计算机进程信息  如果传Processor参数代表查询计算机CPU
            PC.CounterName  = "% Processor Time"; //占有率
            PC.InstanceName = "_Total";
            float cpuValue = PC.NextValue();

            Thread.Sleep(TimeSpan.FromSeconds(1));
            cpuValue = PC.NextValue();
            PostDataToServer(Math.Round(cpuValue, 2).ToString(), saveDir, "");

            if (ConfigContext.GetInstance().MaxCPU < cpuValue)
            {
                if (ContinuousManage.GetInstance().GetIsWaring(CpuMonitorKey + _serverIP + PC.CounterName))
                {
                    string title   = _serverIP + "机器CPU过高";
                    string content = string.Format("IP:{2} CPU:{0},高于警戒值:{1}", cpuValue.ToString(), ConfigContext.GetInstance().MaxCPU.ToString(), _serverIP);

                    //Modify post trace
                    string planName  = string.Format("{0},CPU高于警戒值", _serverIP);
                    string planValue = string.Format("{0}/{1}", Math.Round(cpuValue, 2), ConfigContext.GetInstance().MaxCPU);
                    OaSimplePlanHelper.PostDataToServer(planName, planValue);
                    LogHelper.WriteException("CPU监视[" + _serverIP + "]>>", new Exception(content));
                    Mail139Helper.SendMail(title, content, ConfigContext.GetInstance().SendTo139Mail, true);
                }
            }
            else
            {
                ContinuousManage.GetInstance().Reset(CpuMonitorKey + _serverIP + PC.CounterName);
            }
        }
Ejemplo n.º 10
0
 private static void SendToMail(string content)
 {
     if (errorTimes > ContinuousTimes)
     {
         try
         {
             lock (thisLock)
             {
                 errorTimes = 0;
             }
             Mail139Helper.SendMail("游戏登录监视", content, ConfigContext.GetInstance().SendTo139Mail, true);
         }
         catch (Exception ex)
         {
             Logger.SaveLog("Log in to check mail error", ex);
         }
     }
     else
     {
         lock (thisLock)
         {
             errorTimes++;
         }
     }
 }
Ejemplo n.º 11
0
    /// <summary>
    /// 导入数据到数据库
    /// </summary>
    /// <param name="table">导入的数据表</param>
    /// <param name="tableName">数据库表名</param>
    public ImportState ImportSql(DataTable table, string tableName)
    {
        if (!TableExist(tableName)) //表名是否存在
        {
            return(ImportState.TableNameError);
        }

        if (table == null)
        {
            return(ImportState.ExcelFormatError);
        }
        ArrayList tableField = GetTableField(tableName);   //表格的列名称

        StringBuilder columnName = new StringBuilder();

        for (int i = 0; i < table.Columns.Count; i++)
        {
            columnName.Append(table.Columns[i].ColumnName + ",");
            string currentColumn = table.Columns[i].ToString().ToUpper(); //当前列名
            for (int j = 0; j < tableField.Count; j++)
            {
                if (tableField[j].ToString().ToUpper() == table.Columns[i].ToString().ToUpper())
                {
                    break;   //跳出本层和上一层循环,continue是跳出本层循环,如果用continue,会继续执行j++   Excel里的字段必须在Sql中都有
                }
                if ((tableField[j].ToString().ToUpper() != table.Columns[i].ToString().ToUpper()) && j == tableField.Count - 1)
                {
                    return(ImportState.FieldMatchError);
                }
            }
        }
        columnName.Remove(columnName.Length - 1, 1);    //移除最后一个逗号
        StringBuilder value = null;
        string        con   = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;

        try
        {
            string strSql = string.Empty;
            for (int h = 0; h < table.Rows.Count; h++)
            {
                value = new StringBuilder();
                for (int k = 0; k < table.Columns.Count; k++)     //根据列名得到值
                {
                    value.Append("'" + table.Rows[h][k].ToString() + "',");
                }
                value.Remove(value.Length - 1, 1);        //移除最后一个逗号

                strSql = "insert into " + tableName + "(" + columnName.ToString() + ") values(" + value + ")";
                SqlHelper.ExecuteNonQuery(con, CommandType.Text, strSql);
            }
            //sqlTran.Commit();
            return(ImportState.Success);
        }
        catch (Exception ex)
        {
            ErrorInfo = ex.Message;
            //sqlTran.Rollback();
            return(ImportState.DataTypeError);
        }
    }
Ejemplo n.º 12
0
    protected override bool InitCache()
    {
        try
        {
            string con = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
            string sGetSql = "select [PageID],[PageTitle],[PageUrl],[DisplayLeft],[PageDesc],[FatherPid],[LastModifyTime],[menuID] from GameOA.dbo.oa_purviewpage";
                using (SqlDataReader oReader = SqlHelper.ExecuteReader(con, CommandType.Text, sGetSql))
                {
                    if (oReader == null)
                    {
                        throw new Exception();
                    }
                    List<BasePurviewPage> tmpList = new List<BasePurviewPage>();
                    if (oReader.HasRows)
                    {
                        while (oReader.Read())
                        {
                            BasePurviewPage oTmp = new BasePurviewPage();
                            oTmp.InitData(oReader);
                            tmpList.Add(oTmp);
                        }
                    }
                    this.addCache(tmpList);
                    return true;
                }

        }
        catch (Exception ex)
        {
            this.SaveLog(ex);
            return false;
        }
    }
Ejemplo n.º 13
0
    /// <summary>
    /// 获取最大Id
    /// </summary>
    /// <returns></returns>
    public int GetMaxId()
    {
        string con     = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
        string sGetSql = "select max(groupid) from GameOA.dbo.oa_UserGroup ";
        object tobj    = SqlHelper.ExecuteScalar(con, CommandType.Text, sGetSql);

        return(Convert.ToInt32(tobj) + 1);
    }
Ejemplo n.º 14
0
    /// <summary>
    /// 获取最大栏目序号
    /// </summary>
    /// <returns></returns>
    public int GetMaxDisplayIndex()
    {
        string con     = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
        string sGetSql = "Select max(DisplayIndex) from GameOA.dbo.oa_leftmenu ";
        object tobj    = SqlHelper.ExecuteScalar(con, CommandType.Text, sGetSql);

        return(Convert.ToInt32(tobj) + 1);
    }
Ejemplo n.º 15
0
    /// <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);
        }
    }
Ejemplo n.º 16
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);
        }
        //------------------
    }
Ejemplo n.º 17
0
    protected override bool InitCache()
    {
        try
        {
            string con     = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
            string sGetSql = "select [menuid],[menuname],[menuDesc],[fatherid],[DisplayIndex] from GameOA.dbo.oa_leftmenu where fatherid = -1 order by DisplayIndex";
            using (SqlDataReader oReader = SqlHelper.ExecuteReader(con, CommandType.Text, sGetSql))
            {
                if (oReader == null)
                {
                    throw new Exception();
                }
                List <BaseLeftMenu> tmpList = new List <BaseLeftMenu>();
                if (oReader.HasRows)
                {
                    while (oReader.Read())
                    {
                        BaseLeftMenu oTmp = new BaseLeftMenu();
                        oTmp.InitData(oReader);
                        oTmp.GetPurviewPages();


                        sGetSql = "select [menuid],[menuname],[menuDesc],[fatherid],[DisplayIndex] from GameOA.dbo.oa_leftmenu where fatherid =" + oTmp.MenuId;

                        using (SqlDataReader childReader = SqlHelper.ExecuteReader(con, CommandType.Text, sGetSql))
                        {
                            if (childReader == null)
                            {
                                throw new Exception();
                            }
                            if (childReader.HasRows)
                            {
                                while (childReader.Read())
                                {
                                    BaseLeftMenu childMenu = new BaseLeftMenu();
                                    childMenu.InitData(childReader);
                                    childMenu.GetPurviewPages();
                                    tmpList.Add(childMenu);
                                    oTmp.ChildPages.Add(childMenu);
                                }
                            }
                        }


                        tmpList.Add(oTmp);
                    }
                }
                this.addCache(tmpList);
                return(true);
            }
        }
        catch (Exception ex)
        {
            this.SaveLog(ex);
            return(false);
        }
    }
Ejemplo n.º 18
0
        public void SearchSimplePlanInfo()
        {
            try
            {
                string pcName      = Dns.GetHostName();
                var    messageList = MessageQueue.GetPrivateQueuesByMachine(pcName);
                foreach (var queue in messageList)
                {
                    int queueCount = -1;
                    try
                    {
                        queueCount = queue.GetAllMessages().Length;
                    }
                    catch (Exception ex)
                    {
                    }
                    OaSimplePlanHelper.PostDataToServer(PlanType.msmq, queue.QueueName, queueCount);

                    if ((queueCount > MaxErrorQueue && queue.QueueName.ToLower().IndexOf("errorlogcmdsql") != -1) ||
                        (queueCount > ConfigContext.GetInstance().CitQueueMaxCount))
                    {
                        if (ContinuousManage.GetInstance().GetIsWaring(SimplePlanInfoKey + _serverIP + queue.QueueName))
                        {
                            string title   = _serverIP + "服务器消息队列异常";
                            string content = string.Format("队列服务器:{0}<br />队列名称:{1}<br />队列总数:{2}<br />",
                                                           _serverIP,
                                                           queue.QueueName,
                                                           queueCount
                                                           );
                            int maxQueueCount = ConfigContext.GetInstance().CitQueueMaxCount;
                            if (queue.QueueName.ToLower().IndexOf("errorlogcmdsql") != -1)
                            {
                                maxQueueCount = MaxErrorQueue;
                            }
                            //Modify post trace
                            string planName  = string.Format("{0},消息队列{1}高于警戒值", _serverIP, queue.QueueName);
                            string planValue = string.Format("{0}/{1}", queueCount, maxQueueCount);
                            OaSimplePlanHelper.PostDataToServer(planName, planValue);
                            LogHelper.WriteException("服务器消息队列监视[" + _serverIP + "]>>", new Exception(content));

                            Mail139Helper.SendMail(title, content, ConfigContext.GetInstance().SendTo139Mail, true);
                        }
                    }
                    else
                    {
                        ContinuousManage.GetInstance().Reset(SimplePlanInfoKey + _serverIP + queue.QueueName);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteException("MSMQ information error", ex);
            }
        }
Ejemplo n.º 19
0
 protected DataSet GetLevelDS()
 {
     try
     {
         string con    = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
         string strSql = "SELECT LevelRangeID,LevelName FROM  SnsCenter.dbo.ConfigLevelRange";
         return(SqlHelper.ExecuteDataset(con, CommandType.Text, strSql));
     }
     catch
     {
         return(null);
     }
 }
Ejemplo n.º 20
0
    public void DoDelete(string aNewPhoneNum)
    {
        string con        = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
        string sUpdateSql = "update mobilegame.dbo.userbasicinfo set mobilephone=@aNewPhone where mobilephone=@amobilephone";

        SqlParameter[] paramsupdate = new SqlParameter[2];
        paramsupdate[0] = SqlParamHelper.MakeInParam("@aNewPhone", SqlDbType.VarChar, 0, aNewPhoneNum);
        paramsupdate[1] = SqlParamHelper.MakeInParam("@amobilephone", SqlDbType.VarChar, 0, this._deleteMobilePhone);
        if (SqlHelper.ExecuteNonQuery(con, CommandType.Text, sUpdateSql, paramsupdate) == 1)
        {
            this._sErrorMsg = "帐号删除成功";
        }
        else
        {
            this._sErrorMsg = "帐号删除失败";
        }
    }
Ejemplo n.º 21
0
    private bool CheckPhone(string aCheckPhone, bool isNew)
    {
        string con     = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
        string sGetSql = "select * from mobilegame.dbo.userbasicinfo where mobilephone=@amobilephone";

        SqlParameter[] paramsGet = new SqlParameter[1];
        paramsGet[0] = SqlParamHelper.MakeInParam("@amobilephone", SqlDbType.VarChar, 0, aCheckPhone);
        using (SqlDataReader aReader = SqlHelper.ExecuteReader(con, CommandType.Text, sGetSql, paramsGet))
        {
            if (aReader == null)
            {
                this._sErrorMsg = "查询号码" + aCheckPhone + "是否已注册出现异常";
                return(false);
            }
            else
            {
                if (isNew)
                {
                    if (aReader.HasRows)
                    {
                        this._sErrorMsg = "号码:" + aCheckPhone + "已注册";
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    if (aReader.HasRows)
                    {
                        //aReader.Read();
                        //_UserId = Convert.ToInt32(aReader["userid"]);
                        return(true);
                    }
                    else
                    {
                        this._sErrorMsg = "所要删除手机号码" + aCheckPhone + "未注册";
                        return(false);
                    }
                }
            }
        }
    }
Ejemplo n.º 22
0
 /// <summary>
 /// 执行消息队列SQL语句
 /// </summary>
 /// <param name="messageQueue">消息队列对象</param>
 public bool DoSqlExecute(SqlMessageQueue messageQueue, int reDoingCount)
 {
     if (messageQueue == null || messageQueue.paramters == null)
     {
         return(false);
     }
     try
     {
         SqlParameter[] paramsAction = new SqlParameter[messageQueue.paramters.Length];
         for (int i = 0; i < messageQueue.paramters.Length; i++)
         {
             if (messageQueue.paramters[i] == null)
             {
                 continue;
             }
             SqlDbType dbtype = (SqlDbType)Enum.Parse(typeof(SqlDbType), messageQueue.paramters[i].iDBTypeValue.ToString(), true);
             paramsAction[i] = SqlParamHelper.MakeInParam(messageQueue.paramters[i].paramName, dbtype, messageQueue.paramters[i].isize, messageQueue.paramters[i].ivalue);
         }
         int result = 0;
         if (string.IsNullOrEmpty(messageQueue.ConnectionString))
         {
             result = SqlHelper.ExecuteNonQuery(ConfigContext.GetInstance().ConnctionString, messageQueue.commandType, messageQueue.commandText, paramsAction);
         }
         else
         {
             result = SqlHelper.ExecuteNonQuery(messageQueue.ConnectionString, messageQueue.commandType, messageQueue.commandText, paramsAction);
         }
         if (result > 1)
         {
             LogHelper.WriteDebug(string.Format("Message queue [{0} times] perform impact {1} line Sql:{2}", reDoingCount, result, messageQueue.commandText + ":parameter:" + messageQueue.commandType + GetMessagQueueParamterString(messageQueue)));
         }
         return(true);
     }
     catch (SqlException sqlex)
     {
         LogHelper.WriteException(string.Format("Message queue [{0} times] to execute SQL statements SQLEX:{1};{2}", reDoingCount, sqlex.Message, messageQueue.commandText + ":parameter:" + messageQueue.commandType + GetMessagQueueParamterString(messageQueue)), sqlex);
     }
     catch (Exception ex)
     {
         LogHelper.WriteException(string.Format("Message queue [{0} times] SQL statement error:{1};{2}", reDoingCount, ex.Message, messageQueue.commandText + ":parameter:" + messageQueue.commandType + GetMessagQueueParamterString(messageQueue)), ex);
     }
     return(false);
 }
Ejemplo n.º 23
0
    protected DataSet GetDetailDS(int gameId, bool activeLoss, string levelRangeID, string beginTime, string endTime)
    {
        try
        {
            string         con   = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
            SqlParameter[] param = new SqlParameter[5];
            param[0] = SqlParamHelper.MakeInParam("@GameId", SqlDbType.Int, 4, gameId);
            param[1] = SqlParamHelper.MakeInParam("@ActiveLoss", SqlDbType.Bit, 1, activeLoss);
            param[2] = SqlParamHelper.MakeInParam("@LevelRangeID", SqlDbType.VarChar, 5, levelRangeID);
            param[3] = SqlParamHelper.MakeInParam("@BeginTime", SqlDbType.VarChar, 50, beginTime);
            param[4] = SqlParamHelper.MakeInParam("@EndTime", SqlDbType.VarChar, 50, endTime);

            return(SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, StoredProcedure, param));
        }
        catch
        {
            return(null);
        }
    }
Ejemplo n.º 24
0
        private void ReDoSqlExecute(MSMQContext context, SqlMessageQueue messageQueue, int runTimes)
        {
            try
            {
                for (int i = 0; i < ConfigContext.GetInstance().ReDoExecuteCount; i++)
                {
                    runTimes++;
                    if (DoSqlExecute(messageQueue, runTimes))
                    {
                        LogHelper.WriteDebug(string.Format("Message queue [{0} times] re-execute Sql: {1} successfully!", runTimes, messageQueue.commandText));
                        return;
                    }
                }

                WriteErrorMSMQ(context.MsgConfig, messageQueue);
            }
            catch (Exception ex)
            {
                LogHelper.WriteException(string.Format("Queue reexecute {0} error:", context.MsgConfig.ManagerMessagePath), ex);
            }
        }
Ejemplo n.º 25
0
    public ArrayList GetTableField(string tableName)  //得到数据库某一个表中的所有字段
    {
        ArrayList al    = new ArrayList();
        string    con   = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
        string    table = tableName.Substring(0, tableName.LastIndexOf('.') + 1);

        tableName = tableName.Substring(tableName.LastIndexOf('.') + 1);
        string sql = "SELECT b.name FROM " + table + "sysobjects a INNER JOIN " + table + "syscolumns b ON a.id = b.id WHERE (a.name = '" + tableName + "')";

        using (SqlDataReader reader = SqlHelper.ExecuteReader(con, CommandType.Text, sql))
        {
            if (reader != null && reader.HasRows)
            {
                while (reader.Read())
                {
                    al.Add(reader.GetString(0));
                }
            }
        }

        return(al); //返回的是表中的字段
    }
Ejemplo n.º 26
0
    /// <summary>
    /// 查看数据库里是否有此表名
    /// </summary>
    /// <param name="tableName"></param>
    public bool TableExist(string tableName)
    {
        string con   = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
        string table = tableName.Substring(0, tableName.LastIndexOf('.') + 1);

        tableName = tableName.Substring(tableName.LastIndexOf('.') + 1).ToUpper();
        string sql = "select name from " + table + "sysobjects where type='u'";

        using (SqlDataReader reader = SqlHelper.ExecuteReader(con, CommandType.Text, sql))
        {
            if (reader != null && reader.HasRows)
            {
                while (reader.Read())
                {
                    if (reader.GetString(0).ToUpper() == tableName)
                    {
                        return(true);
                    }
                }
            }
        }
        return(false);
    }
Ejemplo n.º 27
0
 protected override bool InitCache()
 {
     try
     {
         string con  = ConfigContext.GetInstance().DataBaseSettingProvider.SimpleManagerConnstring;
         string sSql = "select * from SnsCenter.dbo.ConfigGameProject order by gameid";
         using (SqlDataReader reader = SqlHelper.ExecuteReader(con, CommandType.Text, sSql))
         {
             if (reader == null)
             {
                 throw new Exception();
             }
             if (reader.HasRows)
             {
                 List <BaseGameProject> tmplist = new List <BaseGameProject>();
                 while (reader.Read())
                 {
                     BaseGameProject oTmpBaseAsp = new BaseGameProject();
                     oTmpBaseAsp.InitData(reader);
                     tmplist.Add(oTmpBaseAsp);
                 }
                 this.addCache(tmplist);
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         this.SaveLog(ex);
         return(false);
     }
 }
Ejemplo n.º 28
0
        /// <summary>
        /// 检查服务器磁盘空间容量
        /// </summary>
        public void CheckDriveInfo()
        {
            try
            {
                DriveInfo[]   alldrive   = DriveInfo.GetDrives();
                List <string> listWaring = new List <string>();
                foreach (DriveInfo d in alldrive)
                {
                    if (d.DriveType == DriveType.Fixed)
                    {
                        DriveWaring checkItem = null;
                        foreach (DriveWaring driveItem in ConfigContext.GetInstance().DriveWaringSet)
                        {
                            if (d.Name.IndexOf(driveItem.DriveName) != -1)
                            {
                                checkItem = driveItem;
                                break;
                            }
                        }

                        int curFreeSpace = Convert.ToInt32(d.TotalFreeSpace / 1048576); //计算剩余多少M
                        int waringSize   = 10000;
                        if (checkItem != null)
                        {
                            waringSize = checkItem.WaringSize;
                        }

                        PostDataToServer(_serverIP, d.Name, curFreeSpace);

                        string waringKey = DriveInfoKey + _serverIP + d.Name;
                        if (curFreeSpace < waringSize)
                        {
                            if (ContinuousManage.GetInstance().GetIsWaring(waringKey))
                            {
                                string content = string.Format("磁盘:{0},剩余空间:{1}MB,低于警戒值:{2}MB<br />", d.Name,
                                                               curFreeSpace, waringSize);
                                listWaring.Add(content);

                                //Modify post trace
                                string planName  = string.Format("{0},磁盘:{1}低于警戒值", _serverIP, d.Name);
                                string planValue = string.Format("{0}/{1}MB", curFreeSpace, waringSize);
                                OaSimplePlanHelper.PostDataToServer(planName, planValue);
                            }
                        }
                        else
                        {
                            ContinuousManage.GetInstance().Reset(waringKey);
                        }
                    }
                }
                if (listWaring.Count > 0)
                {
                    if (ContinuousManage.GetInstance().GetIsWaring(DriveInfoKey + _serverIP))
                    {
                        string title   = _serverIP + "磁盘空间不足";
                        string content = string.Format("共{0}个磁盘空间不足<br />", listWaring.Count);
                        foreach (string item in listWaring)
                        {
                            content += item;
                        }

                        LogHelper.WriteException("Disk monitoring [" + _serverIP + "]>>", new Exception(content));
                        Mail139Helper.SendMail(title, content, ConfigContext.GetInstance().SendTo139Mail, true);
                    }
                }
                else
                {
                    ContinuousManage.GetInstance().Reset(DriveInfoKey + _serverIP);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteException("Check server disk space remaining capacity error", ex);
            }
        }