示例#1
0
    void Query()
    {
        try
        {
            int serverId = ServerDropDownList.SelectedServerId;
            GameServer server = ServerDropDownList.SelectedGameServer;
            if (server == null)
            {
                LabelOpMsg.Text = string.Format(StringDef.MsgCannotBeNone, StringDef.GameServer);
                return;
            }
            if (!server.IsConnected)
            {
                LabelOpMsg.Text = StringDef.NoConnectionAlert;
                return;
            }            

            ArrayList paramList = new ArrayList();
            StringBuilder searchCondition = new StringBuilder();

            searchCondition.Append(string.Format(" WHERE {0} = '{1}' ", FS2TableString.LogFieldLogEvent, LogEvent.TaiSuiStatistic));

            string roleName = TextBoxRoleName.Text.Trim();
            WebUtil.ValidateValueString(roleName);
            if (roleName.Length > 0)
            {
                string subTable = "(SELECT GUID FROM rolesfirst WHERE RoleName='?')";
                searchCondition.Append(string.Format(" AND {0} IN {1} ", FS2TableString.LogFieldLogKey1,subTable));
                paramList.Add(roleName);
            }

            string type = string.Empty;
            switch (RadioButtonListType.SelectedValue)
            {
                case "Day":
                    type = "DATE(LogTime)";
                    break;
                case "Month":
                    type = "DATE_FORMAT(LogTime,'%Y-%m')";
                    break;
            }

            _start = StartDate.SelectedDate;
            if (_start == DateTime.MinValue)
            {
                LabelOpMsg.Text = StringDef.ParameterInputError;
                return;
            }
            _end = EndDate.SelectedDate;
            if (_end == DateTime.MinValue)
            {
                LabelOpMsg.Text = StringDef.ParameterInputError;
                return;
            }
            if (_start >= _end)
            {
                LabelOpMsg.Text = StringDef.EndTimeError;
                return;
            }

            searchCondition.AppendFormat(" AND {0}>='{1}' AND {0}<'{2}'", FS2TableString.LogFieldLogTime,
                _start.ToString("yyyy-MM-dd HH:mm:ss"), _end.ToString("yyyy-MM-dd HH:mm:ss"));

            string baseCmdString = string.Format("SELECT {0},SUM(LogKey6) FROM {1} {2} GROUP BY {0}",
                type, "{0}", searchCondition.ToString());

            string cmdString;
            WebUtil.AddTableNameToCmd(CurrentUser.Id, server, baseCmdString, paramList, _start, _end, out cmdString, out paramList);
            if (cmdString.Length == 0)
            {
                //
                return;
            }

            SqlCommand cmd = new SqlCommand(cmdString, paramList.ToArray());
            SqlResult result = WebUtil.QueryGameServerDb(CurrentUser.Id, server, cmd);
            if (result != null && result.Success)
            {
                result.SetFieldType(new SqlDataType[]{
                                    SqlDataType.DateTime,
                                    SqlDataType.Int32
                                    });

                object[] record = null;
                ArrayList infos = new ArrayList();
                int total = 0;
                while ((record = result.ReadRecord()) != null)
                {
                    TaiSuiUseInfo info = new TaiSuiUseInfo();
                    info.date = (DateTime)record[0];
                    info.num = (int)record[1];

                    total += info.num;
                    infos.Add(info);
                }

                if (infos.Count != 0)
                {
                    ZedGraphWebStatistic.Visible = true;
                    PanelResult.Visible = true;
                    _statInfo = (TaiSuiUseInfo[])infos.ToArray(typeof(TaiSuiUseInfo));
                    _totalCount = total;

                    //CreateTableHead();
                    //CreateSearchResultList((TaiSuiUseInfo[])infos.ToArray(typeof(TaiSuiUseInfo)), total);
                    LabelResult.Text = string.Format(StringDef.LabelStatisticResult, server.Group.Name, server.Name,
                        roleName.Length == 0 ? string.Empty : string.Format("[{0}]{1}", roleName, StringDef.Use), StringDef.TaiSui);
                }
                else
                {
                    LabelOpMsg.Text = StringDef.NoMatchingRecord;
                }
            }
            else
            {
                if (result == null)
                    LabelOpMsg.Text = StringDef.QueryTimeOut;
                else
                    LabelOpMsg.Text = StringDef.OperationFail;
            }

        }
        catch (Exception ex)
        {
            LabelOpMsg.Text = ex.Message;
            PanelResult.Visible = false;
        }
    }
示例#2
0
    void Query()
    {
        try
        {
            int        serverId = ServerDropDownList.SelectedServerId;
            GameServer server   = ServerDropDownList.SelectedGameServer;
            if (server == null)
            {
                LabelOpMsg.Text = string.Format(StringDef.MsgCannotBeNone, StringDef.GameServer);
                return;
            }
            if (!server.IsConnected)
            {
                LabelOpMsg.Text = StringDef.NoConnectionAlert;
                return;
            }

            ArrayList     paramList       = new ArrayList();
            StringBuilder searchCondition = new StringBuilder();

            searchCondition.Append(string.Format(" WHERE {0} = '{1}' ", FS2TableString.LogFieldLogEvent, LogEvent.TaiSuiStatistic));

            string roleName = TextBoxRoleName.Text.Trim();
            WebUtil.ValidateValueString(roleName);
            if (roleName.Length > 0)
            {
                string subTable = "(SELECT GUID FROM rolesfirst WHERE RoleName='?')";
                searchCondition.Append(string.Format(" AND {0} IN {1} ", FS2TableString.LogFieldLogKey1, subTable));
                paramList.Add(roleName);
            }

            string type = string.Empty;
            switch (RadioButtonListType.SelectedValue)
            {
            case "Day":
                type = "DATE(LogTime)";
                break;

            case "Month":
                type = "DATE_FORMAT(LogTime,'%Y-%m')";
                break;
            }

            _start = StartDate.SelectedDate;
            if (_start == DateTime.MinValue)
            {
                LabelOpMsg.Text = StringDef.ParameterInputError;
                return;
            }
            _end = EndDate.SelectedDate;
            if (_end == DateTime.MinValue)
            {
                LabelOpMsg.Text = StringDef.ParameterInputError;
                return;
            }
            if (_start >= _end)
            {
                LabelOpMsg.Text = StringDef.EndTimeError;
                return;
            }

            searchCondition.AppendFormat(" AND {0}>='{1}' AND {0}<'{2}'", FS2TableString.LogFieldLogTime,
                                         _start.ToString("yyyy-MM-dd HH:mm:ss"), _end.ToString("yyyy-MM-dd HH:mm:ss"));

            string baseCmdString = string.Format("SELECT {0},SUM(LogKey6) FROM {1} {2} GROUP BY {0}",
                                                 type, "{0}", searchCondition.ToString());

            string cmdString;
            WebUtil.AddTableNameToCmd(CurrentUser.Id, server, baseCmdString, paramList, _start, _end, out cmdString, out paramList);
            if (cmdString.Length == 0)
            {
                //
                return;
            }

            SqlCommand cmd    = new SqlCommand(cmdString, paramList.ToArray());
            SqlResult  result = WebUtil.QueryGameServerDb(CurrentUser.Id, server, cmd);
            if (result != null && result.Success)
            {
                result.SetFieldType(new SqlDataType[] {
                    SqlDataType.DateTime,
                    SqlDataType.Int32
                });

                object[]  record = null;
                ArrayList infos  = new ArrayList();
                int       total  = 0;
                while ((record = result.ReadRecord()) != null)
                {
                    TaiSuiUseInfo info = new TaiSuiUseInfo();
                    info.date = (DateTime)record[0];
                    info.num  = (int)record[1];

                    total += info.num;
                    infos.Add(info);
                }

                if (infos.Count != 0)
                {
                    ZedGraphWebStatistic.Visible = true;
                    PanelResult.Visible          = true;
                    _statInfo   = (TaiSuiUseInfo[])infos.ToArray(typeof(TaiSuiUseInfo));
                    _totalCount = total;

                    //CreateTableHead();
                    //CreateSearchResultList((TaiSuiUseInfo[])infos.ToArray(typeof(TaiSuiUseInfo)), total);
                    LabelResult.Text = string.Format(StringDef.LabelStatisticResult, server.Group.Name, server.Name,
                                                     roleName.Length == 0 ? string.Empty : string.Format("[{0}]{1}", roleName, StringDef.Use), StringDef.TaiSui);
                }
                else
                {
                    LabelOpMsg.Text = StringDef.NoMatchingRecord;
                }
            }
            else
            {
                if (result == null)
                {
                    LabelOpMsg.Text = StringDef.QueryTimeOut;
                }
                else
                {
                    LabelOpMsg.Text = StringDef.OperationFail;
                }
            }
        }
        catch (Exception ex)
        {
            LabelOpMsg.Text     = ex.Message;
            PanelResult.Visible = false;
        }
    }