Exemplo n.º 1
0
    private ICollection CreateVariableDataSource(SqlResult result)
    {
        try
        {
            DataTable dataTable = new DataTable();
            DataRow   dataRow;

            dataTable.Columns.Add(new DataColumn("VariableName", typeof(String)));
            dataTable.Columns.Add(new DataColumn("VariableValue", typeof(String)));

            result.SetFieldType(new SqlDataType[] {
                SqlDataType.String,
                SqlDataType.String
            });

            object[] record;
            while ((record = result.ReadRecord()) != null)
            {
                dataRow    = dataTable.NewRow();
                dataRow[0] = record[0] as string;
                dataRow[1] = record[1] as string;

                dataTable.Rows.Add(dataRow);
            }
            ViewState["Variables"] = dataTable;
            return(new DataView(dataTable));
        }
        catch (Exception)
        {
            return(null);
        }
    }
Exemplo n.º 2
0
    private ICollection CreateDataSource(SqlResult result, int serverId)
    {
        try
        {
            DataTable dataTable = new DataTable();
            DataRow   dataRow;
            dataTable.Columns.Add(new DataColumn("Name", typeof(String)));
            dataTable.Columns.Add(new DataColumn("Type", typeof(String)));
            dataTable.Columns.Add(new DataColumn("Leader", typeof(String)));
            dataTable.Columns.Add(new DataColumn("NodeGUID", typeof(String)));
            dataTable.Columns.Add(new DataColumn("ChildCount", typeof(Int32)));
            dataTable.Columns.Add(new DataColumn("ServerId", typeof(Int32)));
            dataTable.Columns.Add(new DataColumn("RoleNameEncoded", typeof(String)));

            result.SetFieldType(new SqlDataType[] {
                SqlDataType.String,
                SqlDataType.String,
                SqlDataType.Int32,
                SqlDataType.String,
                SqlDataType.Int32
            });

            object[] record;
            while ((record = result.ReadRecord()) != null)
            {
                dataRow = dataTable.NewRow();

                dataRow[0] = record[0] as string;
                string typeText = string.Empty;
                switch ((int)record[2])
                {
                case 2:
                    typeText = StringDef.Clan;
                    break;

                case 3:
                    typeText = StringDef.Seigneur;
                    break;

                case 4:
                    typeText = StringDef.Nation;
                    break;
                }
                dataRow[1] = typeText;
                dataRow[2] = record[1] as string;
                dataRow[3] = record[3] as string;
                dataRow[4] = (int)record[4];
                dataRow[5] = serverId;
                dataRow[6] = Server.UrlEncode(record[1] as string);

                dataTable.Rows.Add(dataRow);
            }
            return(new DataView(dataTable));
        }
        catch (Exception)
        {
            return(null);
        }
    }
Exemplo n.º 3
0
    IList <NpcStatisticInfo> QueryNpc(GameServer server, DateTime startTime, DateTime endTime, int logEvent, int offset)
    {
        string baseCmdString = string.Format("SELECT LogKey1, SUM(LogKey6) AS SubSum FROM {0} WHERE {1}='{2}' AND {3}>='{4}' AND {3}<'{5}' GROUP BY LogKey1",
                                             "{0}", FS2TableString.LogFieldLogEvent, logEvent, FS2TableString.LogFieldLogTime,
                                             _start.ToString("yyyy-MM-dd HH:mm:ss"), _end.ToString("yyyy-MM-dd HH:mm:ss"));
        string addTableCmdString;

        WebUtil.AddTableNameToCmd(CurrentUser.Id, server, baseCmdString, _start, _end, out addTableCmdString);

        if (addTableCmdString.Length == 0)
        {
            return(null);
        }

        string cmdText = string.Format("SELECT LogKey1, SUM(SubSum) AS ByKillCount FROM ({0}) AS A GROUP BY LogKey1 ORDER BY ByKillCount DESC LIMIT {1},{2};",
                                       addTableCmdString, offset, EntryPerPage);
        SqlResult queryResult = WebUtil.QueryGameServerDb(CurrentUser.Id, server, new SqlCommand(cmdText));

        if (queryResult != null && queryResult.Success)
        {
            queryResult.SetFieldType(new SqlDataType[] {
                SqlDataType.String,
                SqlDataType.Int32
            });

            IList <NpcStatisticInfo> infos = new List <NpcStatisticInfo>();
            object[] record = queryResult.ReadRecord();
            while (record != null)
            {
                NpcStatisticInfo info = new NpcStatisticInfo();
                info.TemaplteId = (string)record[0];
                info.Count      = (int)record[1];
                infos.Add(info);

                record = queryResult.ReadRecord();
            }

            ViewState[WebConfig.SessionQueryLogOffset] = offset;

            ButtonPreviousPage.Enabled = (offset > 0);
            ButtonFirstPage.Enabled    = (offset > 0);
            ButtonNextPage.Enabled     = (infos.Count >= EntryPerPage);

            return(infos);
        }
        else
        {
            if (queryResult == null)
            {
                LabelOpMsg.Text = StringDef.QueryTimeOut;
            }
            else
            {
                LabelOpMsg.Text = StringDef.OperationFail;
            }
            return(null);
        }
    }
Exemplo n.º 4
0
    private void itemquery()
    {
        string     queryString;
        ArrayList  paramList = new ArrayList();
        GameServer server    = AdminServer.TheInstance.GameServerManager.GetGameServer(int.Parse(this.DropDownListGameCenter.SelectedValue));

        //获得RoleId
        queryString = "select cAccountName, cRoleId from trolebaseinfo where cRoleName = '" + this.TextBoxcRoleName.Text + "'";

        SqlCommand rolecmd    = new SqlCommand(queryString, paramList.ToArray());
        SqlResult  roleResult = WebUtil.QueryGameServerDb(CurrentUser.Id, server, rolecmd);

        object[] roleRecord = null;
        if (roleResult != null && roleResult.Success)
        {
            roleResult.SetFieldType(
                new SqlDataType[] {
                SqlDataType.String,        //物品所属帐号名
                SqlDataType.String,        //cRoleId
            });

            if ((roleRecord = roleResult.ReadRecord()) != null)
            {
                string accountName = (string)roleRecord[0];
                string roleID      = (string)roleRecord[1];
                if (roleID != null)
                {
                    BindData(roleID, server.Id, TextBoxcRoleName.Text);
                }
            }
            else
            {
                LabelSuccess.Visible    = false;
                LabelOpMsg.Text         = "不存在该角色";
                LabelOpMsg.Visible      = true;
                ItemPanelResult.Visible = false;
                return;
            }
        }
        else
        {
            if (roleResult == null)
            {
                LabelSuccess.Visible    = false;
                LabelOpMsg.Text         = StringDef.NoConnectionAlert;
                LabelOpMsg.Visible      = true;
                ItemPanelResult.Visible = false;
            }
            else
            {
                LabelSuccess.Visible    = false;
                LabelOpMsg.Text         = StringDef.OperationFail;
                LabelOpMsg.Visible      = true;
                ItemPanelResult.Visible = false;
            }
        }
    }
Exemplo n.º 5
0
    protected FS2RoleDataInfo Query(GameServer server, int roleId)
    {
        FS2RoleDataInfo roleInfo  = null;
        ArrayList       paramList = new ArrayList();

        paramList.Add(roleId);
        string selectedFiled = string.Format("{0},{1},{2},{3},{4}",
                                             FS2TableString.RolesfirstFieldMoney, FS2TableString.RolesfirstFieldMoneyInBox,
                                             FS2TableString.RolesfirstFieldItemList, FS2TableString.RolesfirstFieldRoleName,
                                             FS2TableString.RolesfirstFieldId);
        string sqlCmdText = string.Format("SELECT {0} FROM {1} WHERE {2}='?';", selectedFiled,
                                          FS2TableString.RolesfirstTableName, FS2TableString.RolesfirstFieldId);
        SqlCommand cmd = new SqlCommand(sqlCmdText, paramList.ToArray());

        if (!server.IsConnected)
        {
            LabelOpMsg.Visible = true;
            LabelOpMsg.Text    = StringDef.NoConnectionAlert;
            return(null);
        }
        SqlResult result = WebUtil.QueryGameServerDb(CurrentUser.Id, server, cmd);

        if (result != null && result.Success)
        {
            result.SetFieldType(new SqlDataType[] {
                SqlDataType.UInt32,
                SqlDataType.UInt32,
                SqlDataType.Blob,
                SqlDataType.String,
                SqlDataType.Int32
            });
            object[] record;
            byte[]   itemData;

            roleInfo = new FS2RoleDataInfo();
            while ((record = result.ReadRecord()) != null)
            {
                if (record != null)
                {
                    roleInfo.Money      = (uint)record[0];
                    roleInfo.MoneyInBox = (uint)record[1];
                    itemData            = (byte[])record[2];
                    if (itemData != null)
                    {
                        roleInfo.ItemList = FS2ItemDataInfo.Parse(itemData);
                        //if (info != null) ItemList.Add(info);
                    }
                    roleInfo.RoleName = record[3] as string;
                    roleInfo.RoleId   = (int)record[4];
                }
            }
            //RenderView(roleInfo);
        }
        return(roleInfo);
    }
Exemplo n.º 6
0
    private Hashtable GetRoleGuid(ArrayList guidList)
    {
        GameServer server = ServerDropDownList.SelectedGameServer;

        if (server == null)
        {
            return(null);
        }
        if (guidList != null && guidList.Count != 0)
        {
            string        sqlCmdText  = "SELECT {0},{1},{2} FROM {3} WHERE {4}";
            StringBuilder guidBuilder = new StringBuilder();
            foreach (string guid in guidList)
            {
                guidBuilder.AppendFormat("{0}='{1}' OR ", FS2TableString.RolesfirstFieldGUID, guid);
            }
            SqlCommand sqlCmd = new SqlCommand(string.Format(sqlCmdText, FS2TableString.RolesfirstFieldId,
                                                             FS2TableString.RolesfirstFieldRoleName, FS2TableString.RolesfirstFieldGUID, FS2TableString.RolesfirstTableName, guidBuilder.ToString(0, guidBuilder.Length - 3)), null);
            if (!server.IsConnected)
            {
                LabelOpMsg.Visible = true;
                LabelOpMsg.Text    = StringDef.NoConnectionAlert;
                return(null);
            }
            SqlResult sqlResult = WebUtil.QueryGameServerDb(CurrentUser.Id, server, sqlCmd);
            if (sqlResult != null && sqlResult.Success)
            {
                Hashtable guidHashTable = new Hashtable();
                sqlResult.SetFieldType(new SqlDataType[] {
                    SqlDataType.Int32,
                    SqlDataType.String,
                    SqlDataType.String
                });

                object[]  record    = null;
                ArrayList roleInfos = new ArrayList();
                while ((record = sqlResult.ReadRecord()) != null)
                {
                    FS2RoleDataInfo role = new FS2RoleDataInfo();
                    role.RoleId   = (int)record[0];
                    role.RoleName = record[1] as string;
                    role.RoleGuid = record[2] as string;
                    if (role.RoleGuid != null && role.RoleGuid.Length != 0)
                    {
                        guidHashTable[role.RoleGuid] = role;
                    }
                }
                return(guidHashTable);
            }
        }
        return(null);
    }
Exemplo n.º 7
0
    private ICollection CreateProcessListDataSource(SqlResult result)
    {
        try
        {
            DataTable dataTable = new DataTable();
            DataRow   dataRow;

            dataTable.Columns.Add(new DataColumn("User", typeof(String)));
            dataTable.Columns.Add(new DataColumn("Host", typeof(String)));
            dataTable.Columns.Add(new DataColumn("Database", typeof(String)));
            dataTable.Columns.Add(new DataColumn("Command", typeof(String)));
            dataTable.Columns.Add(new DataColumn("Time", typeof(String)));
            dataTable.Columns.Add(new DataColumn("State", typeof(String)));
            dataTable.Columns.Add(new DataColumn("Info", typeof(String)));

            result.SetFieldType(new SqlDataType[] {
                SqlDataType.Int32,
                SqlDataType.String,
                SqlDataType.String,
                SqlDataType.String,
                SqlDataType.String,
                SqlDataType.String,
                SqlDataType.String,
                SqlDataType.String
            });
            object[] record;
            while ((record = result.ReadRecord()) != null)
            {
                dataRow    = dataTable.NewRow();
                dataRow[0] = record[1] as string;
                dataRow[1] = record[2] as string;
                dataRow[2] = record[3] as string;
                dataRow[3] = record[4] as string;
                dataRow[4] = record[5] as string;
                dataRow[5] = record[6] as string;
                dataRow[6] = record[7] as string;

                dataTable.Rows.Add(dataRow);
            }
            ViewState["ProcessList"] = dataTable;
            return(new DataView(dataTable));
        }
        catch (Exception)
        {
            return(null);
        }
    }
Exemplo n.º 8
0
    protected FS2RoleDataInfo Query(GameServer server, int roleId)
    {
        FS2RoleDataInfo roleInfo  = null;
        ArrayList       paramList = new ArrayList();

        paramList.Add(roleId);
        string selectedFiled = string.Format("{0},{1}",
                                             FS2TableString.RolesfirstFieldSkillList, FS2TableString.RolesfirstFieldRoleName);
        string sqlCmdText = string.Format("SELECT {0} FROM {1} WHERE {2}='?';", selectedFiled,
                                          FS2TableString.RolesfirstTableName, FS2TableString.RolesfirstFieldId);
        SqlCommand cmd = new SqlCommand(sqlCmdText, paramList.ToArray());

        if (!server.IsConnected)
        {
            LabelOpMsg.Text = StringDef.NoConnectionAlert;
            return(null);
        }
        SqlResult result = WebUtil.QueryGameServerDb(CurrentUser.Id, server, cmd);

        if (result != null && result.Success)
        {
            result.SetFieldType(new SqlDataType[] {
                SqlDataType.Blob,
                SqlDataType.String
            });
            object[] record;

            byte[] skillData;

            roleInfo = new FS2RoleDataInfo();
            while ((record = result.ReadRecord()) != null)
            {
                if (record != null)
                {
                    skillData = (byte[])record[0];
                    if (skillData != null)
                    {
                        roleInfo.SkillList = FS2SkillDataInfo.Parse(skillData);
                    }
                    roleInfo.RoleName = record[1] as string;
                }
            }
        }
        return(roleInfo);
    }
Exemplo n.º 9
0
    /// <summary>
    /// 判断数据库里面存不存在给定的表
    /// </summary>
    /// <param name="server">游戏服务器</param>
    /// <param name="cmd">SQL命令</param>
    /// <param name="tableName">表名</param>
    /// <param name="databaseName">数据库名</param>
    /// <returns></returns>
    public static bool IsTableExist(int userId, GameServer server, string tableName, string databaseName)
    {
        SqlCommand cmd    = new SqlCommand(string.Format(ShowTablesString, databaseName), string.Empty);
        SqlResult  result = QueryGameServerDb(userId, server, cmd);

        if (result.ResultState == SqlResult.State.Done && result.Success)
        {
            result.SetFieldType(new SqlDataType[] {
                SqlDataType.String
            });
            object[] record;
            while ((record = result.ReadRecord()) != null)
            {
                string tempName = record[0] as string;
                if (string.Equals(tableName, tempName))
                {
                    return(true);
                }
            }
        }
        return(false);
    }
Exemplo n.º 10
0
    /// <summary>
    /// 通过角色名查找角色的GUID
    /// </summary>
    /// <param name="server">游戏服务器</param>
    /// <param name="roleName">角色名</param>
    /// <returns>角色的GUID,或者null(没有找到)</returns>
    public static string FindRoleGuidByName(int userId, GameServer server, string roleName)
    {
        if (roleName != null && roleName.Length > 0)
        {
            string cmdText = string.Format("SELECT {0} FROM {1} WHERE {2}='?'",
                                           FS2TableString.RolesfirstFieldGUID,
                                           FS2TableString.RolesfirstTableName,
                                           FS2TableString.RolesfirstFieldRoleName);

            SqlResult findRoleGuidResult = QueryGameServerDb(userId, server, new SqlCommand(cmdText, roleName));
            if (findRoleGuidResult != null && findRoleGuidResult.Success)
            {
                findRoleGuidResult.SetFieldType(new SqlDataType[] { SqlDataType.String });
                object[] record = findRoleGuidResult.ReadRecord();
                if (record != null)
                {
                    return(record[0] as string);
                }
            }
        }

        return(null);
    }
Exemplo n.º 11
0
    /// <summary>
    /// 能过帐号名得到角色名(暂时还没有全服查找)
    /// </summary>
    /// <param name="userId">FSEye用户ID</param>
    /// <param name="server">服务器</param>
    /// <param name="account">帐号</param>
    /// <param name="selectOnline">是否在线</param>
    /// <returns></returns>
    public static IList GetRoleNameByAccount(int userId, GameServer server, string account, bool selectOnline)
    {
        if (server == null || !server.IsConnected)
        {
            return(null);
        }
        ArrayList     roleList = new ArrayList();
        StringBuilder cmdText  = new StringBuilder();

        cmdText.AppendFormat("SELECT {0},{1} FROM {2} WHERE {3}='?'",
                             FS2TableString.RolesfirstFieldId,
                             FS2TableString.RolesfirstFieldRoleName,
                             FS2TableString.RolesfirstTableName,
                             FS2TableString.RolesfirstFieldAccountName);
        if (selectOnline)
        {
            cmdText.AppendFormat(" AND {0}='1'", FS2TableString.RolesfirstFieldOnline);
        }

        SqlCommand cmd    = new SqlCommand(cmdText.ToString(), account);
        SqlResult  result = WebUtil.QueryGameServerDb(userId, server, cmd);

        if (result != null && result.Success)
        {
            result.SetFieldType(new SqlDataType[] {
                SqlDataType.Int32,
                SqlDataType.String
            });
            object[] record = null;
            while ((record = result.ReadRecord()) != null)
            {
                roleList.Add(record[1] as string);
            }
        }
        return(roleList);
    }
Exemplo n.º 12
0
    /// <summary>
    /// 得到日志表名
    /// </summary>
    /// <param name="userId"></param>
    /// <param name="server"></param>
    /// <returns></returns>
    public static ArrayList GetLogTables(int userId, GameServer server)
    {
        SqlCommand cmd     = new SqlCommand(string.Format(ShowTablesString, FS2TableString.FS2DatabaseName), string.Empty);
        SqlResult  result  = QueryGameServerDb(userId, server, cmd);
        ArrayList  results = new ArrayList();

        if (result.ResultState == SqlResult.State.Done && result.Success)
        {
            result.SetFieldType(new SqlDataType[] {
                SqlDataType.String
            });
            object[] record;
            while ((record = result.ReadRecord()) != null)
            {
                string tableName = record[0] as string;
                if (tableName.Contains(FS2TableString.LogTableNamePrefix))
                {
                    results.Add(tableName);
                }
            }
            return(results);
        }
        return(null);
    }
    void Query()
    {
        try
        {
            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();

            string RoleSexQueryText = "SELECT RoleType, RoleSex,TongGUID,SkillSeries FROM rolesfirst {0}";

            int startLevel = int.Parse(TextBoxStartLevel.Text);
            if (startLevel > 1)
            {
                searchCondition.Append(string.Format(" AND {0}>={1}", FS2TableString.RolesfirstFieldRoleLevel, startLevel));
            }

            int endLevel = int.Parse(TextBoxEndLevel.Text);
            if (endLevel < FS2GameDataManager.MaxLevel)
            {
                searchCondition.Append(string.Format(" AND {0}<={1}", FS2TableString.RolesfirstFieldRoleLevel, endLevel));
            }

            DateTime activeDate = DateCalendar.SelectedDate;
            if (DropDownListActivePlayer.SelectedIndex != 0 && activeDate == DateTime.MinValue)
            {
                LabelOpMsg.Text = string.Format(StringDef.MsgInputParamNotCorrect, StringDef.Date);
                return;
            }
            switch (DropDownListActivePlayer.SelectedIndex)
            {
            case 1:
                //活跃玩家
                searchCondition.AppendFormat(" AND {0}>='{1}' ", FS2TableString.RolesfirstFieldLastPlayingDate, activeDate.AddDays(-WebConfig.ActivePlayerDaySpan));
                break;

            case 2:
                //不活跃玩家
                searchCondition.AppendFormat(" AND {0}<'{1}' ", FS2TableString.RolesfirstFieldLastPlayingDate, activeDate.AddDays(-WebConfig.ActivePlayerDaySpan));
                break;
            }

            if (searchCondition.Length > 0)
            {
                searchCondition.Remove(0, 4);
                searchCondition.Insert(0, " WHERE");
            }

            SqlCommand cmd    = new SqlCommand(string.Format(RoleSexQueryText, searchCondition.Length == 0 ? string.Empty : searchCondition.ToString()), string.Empty);
            SqlResult  result = WebUtil.QueryGameServerDb(CurrentUser.Id, server, cmd);
            if (result != null && result.Success)
            {
                result.SetFieldType(
                    new SqlDataType[] {
                    SqlDataType.SByte,
                    SqlDataType.SByte,
                    SqlDataType.String,
                    SqlDataType.Int32
                });

                object[]         record    = null;
                RoleSexTotalInfo totalInfo = new RoleSexTotalInfo();
                ArrayList        infos     = new ArrayList();
                while ((record = result.ReadRecord()) != null)
                {
                    //RoleType, RoleSex,TongGUID,SkillSeries
                    FS2RoleDataInfo info = new FS2RoleDataInfo();
                    info.SkillSeries = (int)record[3];
                    switch ((SByte)record[0])
                    {
                    case (SByte)0:
                        if (info.SkillSeries == 0)
                        {
                            info.RoleType = FS2RoleType.Xuanfeng;
                        }
                        else if (info.SkillSeries == 1)
                        {
                            info.RoleType = FS2RoleType.Xingtian;
                        }
                        else
                        {
                            info.RoleType = FS2RoleType.Jiashi;
                        }
                        break;

                    case (SByte)1:
                        if (info.SkillSeries == 0)
                        {
                            info.RoleType = FS2RoleType.Zhenren;
                        }
                        else if (info.SkillSeries == 1)
                        {
                            info.RoleType = FS2RoleType.Tianshi;
                        }
                        else
                        {
                            info.RoleType = FS2RoleType.Daoshi;
                        }
                        break;

                    case (SByte)2:
                        if (info.SkillSeries == 0)
                        {
                            info.RoleType = FS2RoleType.Shoushi;
                        }
                        else if (info.SkillSeries == 1)
                        {
                            info.RoleType = FS2RoleType.Yishi;
                        }
                        else
                        {
                            info.RoleType = FS2RoleType.Yiren;
                        }
                        break;
                    }

                    info.RoleSex  = (FS2RoleSex)((SByte)record[1]);
                    info.TongName = record[2] as string;

                    switch (DropDownListSocialRelation.SelectedIndex)
                    {
                    case 0:
                        infos.Add(info);
                        break;

                    case 1:
                        if (info.TongName != null && info.TongName != string.Empty)
                        {
                            infos.Add(info);
                        }
                        break;

                    case 2:
                        if (info.TongName == null || info.TongName == string.Empty)
                        {
                            infos.Add(info);
                        }
                        break;
                        //case 3:
                        //    if (IsInZhuhou(info)) infos.Add(info);
                        //    break;
                        //case 4:
                        //    if (IsInNation(info)) infos.Add(info);
                        //    break;
                    }
                }

                if (infos.Count != 0)
                {
                    PanelResult.Visible = true;
                    _statInfo           = (FS2RoleDataInfo[])infos.ToArray(typeof(FS2RoleDataInfo));
                    CreateSearchRoleSexList((FS2RoleDataInfo[])infos.ToArray(typeof(FS2RoleDataInfo)));
                    LabelResult.Text = string.Format(StringDef.LabelStatisticResult, server.Group.Name, server.Name,
                                                     string.Format(StringDef.LabelRoleLevel, startLevel, endLevel),
                                                     StringDef.ProfessionalSex);
                }
                else
                {
                    PanelResult.Visible = false;
                    LabelOpMsg.Text     = StringDef.NoMatchingRecord;
                }
            }
        }
        catch (Exception ex)
        {
            LabelOpMsg.Text     = ex.Message;
            PanelResult.Visible = false;
        }
    }
Exemplo n.º 14
0
    private void QueryAndDisplay(bool firstTimeQuery)
    {
        string     roleGUID   = roleGUIDTextBox.Text;
        GameServer gameCenter = AdminServer.TheInstance.GameServerManager.GetGameServer(int.Parse(serverGroupDropDownList.SelectedValue));
        ArrayList  paramList  = new ArrayList();

        string queryString1 = " select logtime as time, '升级' as event, CONCAT('升到<', CAST(field2 as char(8)),'>级') as remark"
                              + " from log_3_1"
                              + " where field1='?'";


        string queryString2 = " select logtime as time, '加入门派' as event, CONCAT('加入<', (select field2 from faction where log_3_2.field3=faction.field1 and faction.field3=0), '>,当时为<', CAST(field2 as char(8)), '>级')   as remark"
                              + " from log_3_2"
                              + " where field1='?'";


        string queryString3 = " select logtime as time, '出师' as event, CONCAT('出师自<', (select field2 from faction where log_3_3.field3=faction.field1 and faction.field3=0), '>,路线<', (select field2 from faction where log_3_3.field3=faction.field1 and log_3_3.field4=faction.field3), '>,当时为<', CAST(field2 as char(8)), '>级')   as remark"
                              + " from log_3_3"
                              + " where field1='?'";

        string queryString4 = " select logtime as time, '加入家族' as event, CONCAT('加入<', (select field2 from kin where log_3_4.field3=kin.field1), '>,当时为<', CAST(field2 as char(8)), '>级')   as remark"
                              + " from log_3_4"
                              + " where field1='?'";

        string queryString5 = " select logtime as time, '退出家族' as event, CONCAT('退出<', (select field2 from kin where log_3_5.field3=kin.field1), '>,当时为<', CAST(field2 as char(8)), '>级')   as remark"
                              + " from log_3_5"
                              + " where field1='?'";

        string queryString6 = " select logtime as time, '完成任务' as event, CONCAT('主任务:', CAST(field4 as char), ' 子任务:', CAST(field5 as char)) as remark"
                              + " from log_3_6"
                              + " where field1='?'";

        string queryString7 = " select logtime as time,"
                              + " (case field2"
                              + " when 0 then '下线'"
                              + " when 1 then '登录'"
                              + " when 2 then '开始离线托管'"
                              + " when 3 then '离线托管超时'"
                              + " when 4 then '离线托管踢号'"
                              + " else '未知事件'"
                              + " end) as event,"
                              + " field3 as remark"
                              + " from log_3_7"
                              + " where field1='?'";


        //+ " union"
        //+ " select logtime as time, '选择路线' as event, CONCAT('选择路线<', (select field2 from faction where log_3_8.field3=faction.field1 and log_3_8.field4=faction.field3), '>,当时为<', CAST(field2 as char(8)), '>级')   as remark"
        //+ " from log_3_8"
        //+ " where field1='?'"
        //+ " and logtime between '?' and '?'"

        ArrayList queryStringsArrayList = new ArrayList();

        //根据eventTypeCheckBoxList的勾选情况来确定哪几个queryString被加入到最终的SQL语句中
        if (eventTypeCheckBoxList.SelectedIndex == -1)
        {
            LabelSuccess.Visible          = false;
            LabelOpMsg.Text               = "未选择事件类型 - 至少要选中一种事件";
            LabelOpMsg.Visible            = true;
            resultDataGrid.Visible        = false;
            resultPagingInfoPanel.Visible = false;
            return;
        }

        if (eventTypeCheckBoxList.Items.FindByValue("log_3_1").Selected == true)
        {
            queryStringsArrayList.Add(queryString1);
        }

        if (eventTypeCheckBoxList.Items.FindByValue("log_3_2,log_3_3,log_3_8").Selected == true)
        {
            queryStringsArrayList.Add(queryString2);
            queryStringsArrayList.Add(queryString3);
        }

        if (eventTypeCheckBoxList.Items.FindByValue("log_3_4,log_3_5").Selected == true)
        {
            queryStringsArrayList.Add(queryString4);
            queryStringsArrayList.Add(queryString5);
        }

        if (eventTypeCheckBoxList.Items.FindByValue("log_3_6").Selected == true)
        {
            queryStringsArrayList.Add(queryString6);
        }

        if (eventTypeCheckBoxList.Items.FindByValue("log_3_7").Selected == true)
        {
            queryStringsArrayList.Add(queryString7);
        }


        //若两个时间的TextBox不是都为空
        //注意,TextBox为空时,SelectedDate属性的值为DateTime.MinValue
        if (!((RecentLoginTime_start.SelectedDate == DateTime.MinValue) && (RecentLoginTime_end.SelectedDate == DateTime.MinValue)))
        {
            DateTime time1;
            DateTime time2;

            if (RecentLoginTime_start.SelectedDate == DateTime.MinValue)
            {
                time1 = DateTime.Now;
            }
            else
            {
                time1 = RecentLoginTime_start.SelectedDate;
            }
            if (RecentLoginTime_end.SelectedDate == DateTime.MinValue)
            {
                time2 = DateTime.Now;
            }
            else
            {
                time2 = RecentLoginTime_end.SelectedDate;
            }

            for (int i = 0; i < queryStringsArrayList.Count; i++)
            {
                queryStringsArrayList[i] += " and logtime between '?' and '?'";

                paramList.Add(roleGUID);

                if (time1 <= time2)
                {
                    paramList.Add(time1.ToString("yyyy-MM-dd HH:mm:ss"));
                    paramList.Add(time2.ToString("yyyy-MM-dd HH:mm:ss"));
                }
                else
                {
                    paramList.Add(time2.ToString("yyyy-MM-dd HH:mm:ss"));
                    paramList.Add(time1.ToString("yyyy-MM-dd HH:mm:ss"));
                }
            }
        }
        else
        {
            for (int i = 0; i < queryStringsArrayList.Count; i++)
            {
                paramList.Add(roleGUID);
            }
        }

        string queryString = String.Join(" union all ", (string[])queryStringsArrayList.ToArray(typeof(String)));

        queryString += " order by Time DESC ";

        queryString = queryString.Insert(7, " SQL_CALC_FOUND_ROWS ");

        int currentPage    = (int)ViewState["currentPage"];
        int resultsPerPage = (int)ViewState["resultsPerPage"];
        int offset         = resultsPerPage * currentPage;

        queryString += " limit " + offset.ToString() + "," + resultsPerPage.ToString();
        currentPage++;
        ViewState["currentPage"] = currentPage;

        SqlCommand sqlcmd      = new SqlCommand(queryString, paramList.ToArray());
        SqlResult  queryResult = WebUtil.QueryGameServerDb(CurrentUser.Id, gameCenter, sqlcmd);

        if (queryResult != null && queryResult.Success)
        {
            object[] record = null;

            DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("time", typeof(DateTime)));
            dt.Columns.Add(new DataColumn("event", typeof(String)));
            dt.Columns.Add(new DataColumn("remark", typeof(String)));
            DataRow dr;

            queryResult.SetFieldType
            (
                new SqlDataType[]
            {
                SqlDataType.DateTime,
                SqlDataType.String,
                SqlDataType.String,
            }
            );

            while ((record = queryResult.ReadRecord()) != null)
            {
                dr    = dt.NewRow();
                dr[0] = (DateTime)record[0];
                dr[1] = (String)record[1];
                dr[2] = (String)record[2];
                dt.Rows.Add(dr);
            }

            DataView dv = new DataView(dt);

            if (dt.Rows.Count == 0)
            {
                LabelSuccess.Visible          = false;
                LabelOpMsg.Text               = "没有满足条件的记录";
                LabelOpMsg.Visible            = true;
                resultDataGrid.Visible        = false;
                resultPagingInfoPanel.Visible = false;
                return;
            }

            resultDataGrid.DataSource = dv;
            resultDataGrid.DataBind();
            resultDataGrid.Visible = true;

            LabelOpMsg.Visible   = false;
            LabelSuccess.Text    = "查询成功完成";
            LabelSuccess.Visible = true;

            //只有在首次查询时,也就是点击查询按钮时才去查结果的总数,otherwise,总数已经在ViewState["totalResults"]中了
            if (firstTimeQuery == true)
            {
                SqlCommand sqlcmdRowCount      = new SqlCommand("select found_rows()", paramList.ToArray());
                SqlResult  queryResultRowCount = WebUtil.QueryGameServerDb(CurrentUser.Id, gameCenter, sqlcmdRowCount);

                queryResultRowCount.SetFieldType(new SqlDataType[] { SqlDataType.String });

                object[] rowCountResult = queryResultRowCount.ReadRecord();

                ViewState["totalResults"] = rowCountResult[0];
            }

            int rowCount = int.Parse((string)ViewState["totalResults"]);
            resultInfoLabel.Text = "共有" + rowCount.ToString() + "条记录,每页" + resultsPerPage.ToString() + "条记录,当前页数:" + currentPage.ToString();

            //当前页数大于1时才允许点击“第一页”按钮和“上一页”按钮
            if (currentPage >= 2)
            {
                ButtonFirstPage.Enabled    = true;
                ButtonPreviousPage.Enabled = true;
            }
            else
            {
                ButtonFirstPage.Enabled    = false;
                ButtonPreviousPage.Enabled = false;
            }

            //当下一页还能有记录的时候才允许点击“下一页”按钮
            if ((resultsPerPage * currentPage) < rowCount)
            {
                ButtonNextPage.Enabled = true;
            }
            else
            {
                ButtonNextPage.Enabled = false;
            }

            resultPagingInfoPanel.Visible = true;
        }
        else
        {
            if (queryResult == null)
            {
                LabelSuccess.Visible          = false;
                LabelOpMsg.Text               = StringDef.NoConnectionAlert;
                LabelOpMsg.Visible            = true;
                resultDataGrid.Visible        = false;
                resultPagingInfoPanel.Visible = false;
            }
            else
            {
                LabelSuccess.Visible          = false;
                LabelOpMsg.Text               = StringDef.OperationFail;
                LabelOpMsg.Visible            = true;
                resultDataGrid.Visible        = false;
                resultPagingInfoPanel.Visible = false;
            }
        }
    }
Exemplo n.º 15
0
    protected void Query(int offset)
    {
        try
        {
            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();

            string seller = TextBoxSeller.Text.Trim();
            if (seller.Length != 0)
            {
                if (CheckBoxSeller.Checked)
                {
                    searchCondition.Append(string.Format(" AND {0}='?'", FS2TableString.AuctionFieldSellerName));
                }
                else
                {
                    searchCondition.Append(string.Format(" AND {0} LIKE '%?%'", FS2TableString.AuctionFieldSellerName));
                }
                paramList.Add(seller);
            }

            string buyer = TextBoxBuyer.Text.Trim();
            if (buyer.Length != 0)
            {
                if (CheckBoxBuyer.Checked)
                {
                    searchCondition.AppendFormat(" AND {0}='?'", FS2TableString.AuctionFieldBuyerName);
                }
                else
                {
                    searchCondition.AppendFormat(" AND {0} LIKE '%?%'", FS2TableString.AuctionFieldBuyerName);
                }
                paramList.Add(buyer);
            }

            string itemName = TextBoxItemName.Text.Trim();
            if (itemName.Length != 0)
            {
                if (CheckBoxItemName.Checked)
                {
                    searchCondition.AppendFormat(" AND {0}='?'", FS2TableString.AuctionFieldGoodsName);
                }
                else
                {
                    searchCondition.AppendFormat(" AND {0} LIKE '%?%'", FS2TableString.AuctionFieldGoodsName);
                }
                paramList.Add(itemName);
            }

            //if (StartDate.Selected)
            //{
            //    searchCondition.AppendFormat(" AND {0}>='{1}'", FS2TableString.LogFieldLogTime, StartDate.SelectedDate);
            //}
            //if (EndDate.Selected)
            //{
            //    searchCondition.AppendFormat(" AND {0}<'{1}'", FS2TableString.LogFieldLogTime, EndDate.SelectedDate.AddDays(1));
            //}

            if (searchCondition.Length > 0)
            {
                searchCondition.Remove(0, 4);
                searchCondition.Insert(0, " WHERE");
            }

            string orderByType = string.Empty;
            switch (ListBoxOrderByType.SelectedIndex)
            {
            case 0:
                orderByType = "ASC";
                break;

            case 1:
                orderByType = "DESC";
                break;
            }
            string orderByStatement = string.Empty;
            switch (ListBoxOrderBy.SelectedIndex)
            {
            case 0:
                orderByStatement = string.Format(" ORDER BY {0} {1}", FS2TableString.AuctionFieldCurrentPrice, orderByType);
                break;

            case 1:
                orderByStatement = string.Format(" ORDER BY {0} {1}", FS2TableString.AuctionFieldPassPrice, orderByType);
                break;
            }

            int    limitCount     = _recordPerPage;
            string limitStatement = string.Format(" LIMIT {0},{1}", offset, limitCount);

            string cmdText      = "SELECT {0} FROM {1} {2} {3} {4}";
            string cmdFieldText = string.Format("{0},{1},{2},{3},{4},{5},{6},{7}",
                                                FS2TableString.AuctionFieldSellerName,
                                                FS2TableString.AuctionFieldGoodsName,
                                                FS2TableString.AuctionFieldBuyerName,
                                                FS2TableString.AuctionFieldStartTime,
                                                FS2TableString.AuctionFieldFinishTime,
                                                FS2TableString.AuctionFieldCurrentPrice,
                                                FS2TableString.AuctionFieldPassPrice,
                                                FS2TableString.AuctionFieldItemData);

            SqlCommand cmd    = new SqlCommand(string.Format(cmdText, cmdFieldText, FS2TableString.AuctionTableName, searchCondition.ToString(), orderByStatement, limitStatement), paramList.ToArray());
            SqlResult  result = WebUtil.QueryGameServerDb(CurrentUser.Id, server, cmd);
            if (result != null && result.Success)
            {
                result.SetFieldType(new SqlDataType[] {
                    SqlDataType.String,
                    SqlDataType.String,
                    SqlDataType.String,
                    SqlDataType.DateTime,
                    SqlDataType.DateTime,
                    SqlDataType.UInt32,
                    SqlDataType.UInt32,
                    SqlDataType.Blob
                });

                object[]  record = null;
                ArrayList infos  = new ArrayList();

                while ((record = result.ReadRecord()) != null)
                {
                    AuctionRoomItem info = new AuctionRoomItem();
                    info.SellerName   = record[0] as string;
                    info.GoodsName    = record[1] as string;
                    info.BuyerName    = record[2] as string;
                    info.StartTime    = (DateTime)record[3];
                    info.FinishTime   = (DateTime)record[4];
                    info.CurrentPrice = (uint)record[5];
                    info.PassPrice    = (uint)record[6];
                    info.ItemData     = FS2ItemDataInfo.ParseItem((byte[])record[7]);

                    infos.Add(info);
                }

                ViewState[WebConfig.SessionQueryLogOffset] = offset;

                ButtonPreviousPage.Enabled = (offset > 0);
                ButtonFirstPage.Enabled    = (offset > 0);
                ButtonNextPage.Enabled     = (infos.Count >= limitCount);

                ViewState[WebConfig.ParamServerId] = server.Id;
                if (infos.Count != 0)
                {
                    DataGridAuctionItem.DataSource = CreateDataSource(infos);
                    DataGridAuctionItem.DataBind();
                    PanelResult.Visible = true;
                }
                else
                {
                    LabelOpMsg.Text     = StringDef.NoMatchingRecord;
                    PanelResult.Visible = false;
                }
            }
            else
            {
                if (result == null)
                {
                    LabelOpMsg.Text = StringDef.QueryTimeOut;
                }
                else
                {
                    LabelOpMsg.Text = StringDef.OperationFail;
                }
                PanelResult.Visible = false;
            }
        }
        catch (Exception ex)
        {
            LabelOpMsg.Text     = ex.Message;
            PanelResult.Visible = false;
        }
    }
Exemplo n.º 16
0
    void Query(int offset)
    {
        try
        {
            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();

            //string tong = TextBoxTong.Text;
            //if (tong.Length > 0)
            //{
            //    if (CheckBoxTong.Checked)
            //    {
            //        searchCondition.Append(string.Format(" AND {0}='?'", FS2TableString.RolesfirstFieldTongGUID));
            //    }
            //    else
            //    {
            //        searchCondition.Append(string.Format(" AND {0} LIKE '%?%'", FS2TableString.RolesfirstFieldTongGUID));
            //    }
            //    paramList.Add(tong);
            //}

            searchCondition.Append(string.Format("{0} = {1}", " WHERE " + FS2TableString.RolesfirstFieldOnline, "1"));

            int sex = ListBoxSex.SelectedIndex - 1;
            if (sex >= 0)
            {
                searchCondition.Append(string.Format(" AND {0}={1}", FS2TableString.RolesfirstFieldRoleSex, sex));
            }

            StringBuilder roleTypeBuilder = new StringBuilder();
            foreach (ListItem item in CheckBoxListRoleType.Items)
            {
                if (item.Selected)
                {
                    string[] conValue = item.Value.Split(',');
                    roleTypeBuilder.AppendFormat("({0}='{1}' AND {2}='{3}') OR ", FS2TableString.RolesfirstFieldRoleType, conValue[0], FS2TableString.RolesfirstFieldSkillSeries, conValue[1]);
                }
            }
            if (roleTypeBuilder.Length != 0)
            {
                searchCondition.AppendFormat(" AND ({0}) ", roleTypeBuilder.ToString(0, roleTypeBuilder.Length - 3));
            }
            else
            {
                LabelOpMsg.Text = string.Format(StringDef.MsgCannotBeNone, StringDef.RoleClass);
                return;
            }

            //int roleClass = ListBoxRoleClass.SelectedIndex - 1;
            //if (roleClass >= 0)
            //{
            //    string[] conValue = ListBoxRoleClass.SelectedValue.Split(',');
            //    searchCondition.Append(string.Format(" AND {0}='{1}' AND {2}='{3}'", FS2TableString.RolesfirstFieldRoleType, conValue[0], FS2TableString.RolesfirstFieldSkillSeries, conValue[1]));
            //}

            int startLevel = int.Parse(TextBoxStartLevel.Text);
            if (startLevel > 1)
            {
                searchCondition.Append(string.Format(" AND {0}>={1}", FS2TableString.RolesfirstFieldRoleLevel, startLevel));
            }

            int endLevel = int.Parse(TextBoxEndLevel.Text);
            if (endLevel < FS2GameDataManager.MaxLevel)
            {
                searchCondition.Append(string.Format(" AND {0}<={1}", FS2TableString.RolesfirstFieldRoleLevel, endLevel));
            }

            string orderByType = string.Empty;
            switch (ListBoxOrderByType.SelectedIndex)
            {
            case 0:
                orderByType = "ASC";
                break;

            case 1:
                orderByType = "DESC";
                break;
            }

            string orderByStatement = string.Empty;
            switch (ListBoxOrderBy.SelectedIndex)
            {
            case 0:
                orderByStatement = string.Format(" ORDER BY {0} {1}", FS2TableString.RolesfirstFieldId, orderByType);
                break;

            case 1:
                orderByStatement = string.Format(" ORDER BY {0} {1}", FS2TableString.RolesfirstFieldRoleLevel, orderByType);
                break;

            case 2:
                orderByStatement = string.Format(" ORDER BY {0} {1}", FS2TableString.RolesfirstFieldRoleName, orderByType);
                break;
            }

            int    limitCount     = _recordPerPage;
            string limitStatement = string.Format(" LIMIT {0},{1}", offset, limitCount + 1);

            SqlCommand cmd    = new SqlCommand("SELECT Id,AccountName,RoleName,RoleSex,RoleType,RoleLevel,SkillSeries FROM rolesfirst" + searchCondition.ToString() + orderByStatement + limitStatement, paramList.ToArray());
            SqlResult  result = WebUtil.QueryGameServerDb(CurrentUser.Id, server, cmd);
            if (result != null && result.Success)
            {
                Session[WebConfig.SessionQueryLogOffset] = offset;

                result.SetFieldType(
                    new SqlDataType[] {
                    SqlDataType.Int32,
                    SqlDataType.String,
                    SqlDataType.String,
                    SqlDataType.SByte,
                    SqlDataType.SByte,
                    SqlDataType.SByte,
                    SqlDataType.Int32
                });

                ArrayList roles  = new ArrayList();
                object[]  record = null;
                while ((record = result.ReadRecord()) != null)
                {
                    FS2RoleDataInfo info = new FS2RoleDataInfo();
                    info.RoleId      = (int)record[0];
                    info.AccountName = (string)record[1];
                    info.RoleName    = (string)record[2];
                    info.RoleSex     = (FS2RoleSex)((SByte)record[3]);

                    info.SkillSeries = (int)record[6];
                    switch ((SByte)record[4])
                    {
                    case (SByte)0:
                        if (info.SkillSeries == 0)
                        {
                            info.RoleType = FS2RoleType.Xuanfeng;
                        }
                        else if (info.SkillSeries == 1)
                        {
                            info.RoleType = FS2RoleType.Xingtian;
                        }
                        else
                        {
                            info.RoleType = FS2RoleType.Jiashi;
                        }
                        break;

                    case (SByte)1:
                        if (info.SkillSeries == 0)
                        {
                            info.RoleType = FS2RoleType.Zhenren;
                        }
                        else if (info.SkillSeries == 1)
                        {
                            info.RoleType = FS2RoleType.Tianshi;
                        }
                        else
                        {
                            info.RoleType = FS2RoleType.Daoshi;
                        }
                        break;

                    case (SByte)2:
                        if (info.SkillSeries == 0)
                        {
                            info.RoleType = FS2RoleType.Shoushi;
                        }
                        else if (info.SkillSeries == 1)
                        {
                            info.RoleType = FS2RoleType.Yishi;
                        }
                        else
                        {
                            info.RoleType = FS2RoleType.Yiren;
                        }
                        break;
                    }

                    info.RoleLevel = (SByte)record[5];

                    roles.Add(info);
                }

                ButtonPreviousPage.Enabled = (offset > 0);
                ButtonFirstPage.Enabled    = (offset > 0);
                ButtonNextPage.Enabled     = (roles.Count > limitCount);

                bool success = CreateSearchRoleResultList(server.Id, (FS2RoleDataInfo[])roles.ToArray(typeof(FS2RoleDataInfo)));
                PanelResult.Visible = success;

                if (!success)
                {
                    LabelOpMsg.Text = StringDef.NoMatchingRecord;
                    return;
                }
            }
            else
            {
                if (result == null)
                {
                    LabelOpMsg.Text = StringDef.QueryTimeOut;
                }
                else
                {
                    LabelOpMsg.Text = StringDef.OperationFail;
                }
            }
        }
        catch (Exception ex)
        {
            LabelOpMsg.Text     = ex.Message;
            PanelResult.Visible = false;
        }
    }
Exemplo n.º 17
0
    private void QueryAndDisplay(bool firstTimeQuery)
    {
        //根据eventTypeCheckBoxList的勾选情况来确定哪几个queryString被加入到最终的SQL语句中
        if (eventTypeCheckBoxList.SelectedIndex == -1)
        {
            LabelSuccess.Visible          = false;
            LabelOpMsg.Text               = "未选择事件类型 - 至少要选中一种事件";
            LabelOpMsg.Visible            = true;
            resultDataGrid.Visible        = false;
            resultPagingInfoPanel.Visible = false;
            return;
        }

        string     itemGUID   = TextBoxInputItemGuid.Text;
        GameServer gameCenter = AdminServer.TheInstance.GameServerManager.GetGameServer(int.Parse(serverGroupDropDownList.SelectedValue));
        ArrayList  paramList  = new ArrayList();

        string queryString1 = " select logtime as Time,"
                              + " (case Field3"
                              + " when 1 then '生成:系统产生'"
                              + " when 2 then '生成:合成'"
                              + " when 3 then '生成:NPC商店购买'"
                              + " when 4 then '生成:奇珍阁购买'"
                              + " when 5 then '生成:NPC掉落'"
                              + " when 6 then '生成:手工拆分'"
                              + " when 7 then '生成:贩卖拆分'"
                              + " when 8 then '生成:脚本(任务)'"
                              + " else '未知事件'"
                              + " end) as eventname,"
                              + " Field30 as GoodsName, Field2 as userGUID, (select cRoleName from trolebaseinfo where trolebaseinfo.cRoleId = log_4_1.Field2 limit 1) as userName, Field31 as ItemDetails"
                              + " from log_4_1"
                              + " where Field1 = '?'";

        string queryString2 = " select logtime as Time,"
                              + " (case Field3"
                              + " when 1 then '销毁:系统销毁'"
                              + " when 2 then '销毁:系统回收(如丢弃在地上等)'"
                              + " when 3 then '销毁:有效期至'"
                              + " when 4 then '销毁:使用消耗'"
                              + " when 5 then '销毁:商品叠加'"
                              + " when 6 then '销毁:卖给NPC'"
                              + " when 7 then '销毁:脚本删除(任务)'"
                              + " when 8 then '销毁:装备磨损'"
                              + " else '未知事件'"
                              + " end) as eventname,"
                              + " (select Field30 from log_4_1 where log_4_1.field1 = log_4_2.field1 limit 1) as GoodsName,"
                              + " Field2 as userGUID,"
                              + " (select cRoleName from trolebaseinfo where trolebaseinfo.cRoleId = log_4_2.Field2 limit 1) as userName,"
                              + " (select Field31 from log_4_1 where log_4_1.field1 = log_4_2.field1 limit 1) as ItemDetails"
                              + " from log_4_2"
                              + " where Field1 = '?'";

        string queryString3 = " select logtime as Time,"
                              + " (case Field3"
                              + " when 1 then CONCAT('丢弃:丢弃在地上',' 地点:',(select mapName from map where mapid = Field4 limit 1  ),'  坐标: ','X:',CAST(Field5 as char(12)),' Y:',CAST(Field6 as char(12)))"
                              + " when 2 then CONCAT('邮寄',' 地点:',(select mapName from map where mapid = Field4 limit 1  ),'  坐标: ','X:',CAST(Field5 as char(12)),' Y:',CAST(Field6 as char(12)))"
                              + " else '未知事件'"
                              + " end) as eventname,"
                              + " (select Field30 from log_4_1 where log_4_1.field1 = log_4_3.field1 limit 1) as GoodsName,"
                              + " Field2 as userGUID,"
                              + " (select cRoleName from trolebaseinfo where trolebaseinfo.cRoleId = log_4_3.Field2 limit 1) as userName,"
                              + " (select Field31 from log_4_1 where log_4_1.field1 = log_4_3.field1 limit 1) as ItemDetails"
                              + " from log_4_3"
                              + " where Field1 = '?'";

        string queryString4 = " select logtime as Time,"
                              + " (case Field3"
                              + " when 1 then CONCAT('捡起',' 地点:',(select mapName from map where mapid = Field4 limit 1  ),'  坐标: ','X:',CAST(Field5 as char(12)),' Y:',CAST(Field6 as char(12)))"
                              + " when 2 then CONCAT('获取自邮件附件',' 地点:',(select mapName from map where mapid = Field4 limit 1  ),'  坐标: ','X:',CAST(Field5 as char(12)),' Y:',CAST(Field6 as char(12)))"
                              + " else '未知事件'"
                              + " end) as eventname,"
                              + " (select Field30 from log_4_1 where log_4_1.field1 = log_4_4.field1 limit 1) as GoodsName,"
                              + " Field2 as userGUID,"
                              + " (select cRoleName from trolebaseinfo where trolebaseinfo.cRoleId = log_4_4.Field2 limit 1) as userName,"
                              + " (select Field31 from log_4_1 where log_4_1.field1 = log_4_4.field1 limit 1) as ItemDetails"
                              + " from log_4_4"
                              + " where Field1 = '?'";

        string queryString5 = " select logtime as Time,"
                              + " (case Field4"
                              + " when 1 then CONCAT('所有者变更:玩家交易',' 买家<',(select cRoleName from trolebaseinfo where cRoleId =Field2 limit 1),'>坐标:',(select mapName from map where mapid = Field5 limit 1),' X:',CAST(Field6 as char(12)),' Y:',CAST(Field7 as char(12)),' 卖家<',(select cRoleName from trolebaseinfo where cRoleId =Field3 limit 1),'>坐标:',(select mapName from map where mapid = Field8 limit 1),' X:',CAST(Field9 as char(12)),' Y:',CAST(Field10 as char(12)))"
                              + " when 2 then CONCAT('所有者变更:收购',' 买家<',(select cRoleName from trolebaseinfo where cRoleId =Field2 limit 1),'>坐标:',(select mapName from map where mapid = Field5 limit 1),' X:',CAST(Field6 as char(12)),' Y:',CAST(Field7 as char(12)),' 卖家<',(select cRoleName from trolebaseinfo where cRoleId =Field3 limit 1),'>坐标:',(select mapName from map where mapid = Field8 limit 1),' X:',CAST(Field9 as char(12)),' Y:',CAST(Field10 as char(12)))"
                              + " when 3 then CONCAT('所有者变更:贩卖',' 买家<',(select cRoleName from trolebaseinfo where cRoleId =Field2 limit 1),'>坐标:',(select mapName from map where mapid = Field5 limit 1),' X:',CAST(Field6 as char(12)),' Y:',CAST(Field7 as char(12)),' 卖家<',(select cRoleName from trolebaseinfo where cRoleId =Field3 limit 1),'>坐标:',(select mapName from map where mapid = Field8 limit 1),' X:',CAST(Field9 as char(12)),' Y:',CAST(Field10 as char(12)))"
                              + " else '未知事件'"
                              + " end) as eventname,"
                              + " (select Field30 from log_4_1 where log_4_1.field1 = log_4_5.field1 limit 1) as GoodsName,"
                              + " Field2 as userGUID,"
                              + " (select cRoleName from trolebaseinfo where trolebaseinfo.cRoleId = log_4_5.Field2 limit 1) as userName,"
                              + " (select Field31 from log_4_1 where log_4_1.field1 = log_4_5.field1 limit 1) as ItemDetails"
                              + " from log_4_5"
                              + " where Field1 = '?'";

        string queryString6 = " select logtime as Time,"
                              + " (case field3"
                              + " when 1 then (case field15"
                              + " when 0 then '属性改变:玄晶剥离'"
                              + " else CONCAT('属性改变:强化装备至 +', field15)"
                              + " end)"
                              + " else '未知事件'"
                              + " end) as eventname,"
                              + " Field30 as GoodsName, Field2 as userGUID, (select cRoleName from trolebaseinfo where trolebaseinfo.cRoleId = log_4_6.Field2 limit 1) as userName, Field31 as ItemDetails"
                              + " from log_4_6"
                              + " where field1 = '?'";

        ArrayList queryStringsArrayList = new ArrayList();

        if (eventTypeCheckBoxList.Items.FindByValue("log_4_1").Selected == true)
        {
            queryStringsArrayList.Add(queryString1);
        }

        if (eventTypeCheckBoxList.Items.FindByValue("log_4_2").Selected == true)
        {
            queryStringsArrayList.Add(queryString2);
        }

        if (eventTypeCheckBoxList.Items.FindByValue("log_4_3").Selected == true)
        {
            queryStringsArrayList.Add(queryString3);
        }

        if (eventTypeCheckBoxList.Items.FindByValue("log_4_4").Selected == true)
        {
            queryStringsArrayList.Add(queryString4);
        }

        if (eventTypeCheckBoxList.Items.FindByValue("log_4_5").Selected == true)
        {
            queryStringsArrayList.Add(queryString5);
        }

        if (eventTypeCheckBoxList.Items.FindByValue("log_4_6").Selected == true)
        {
            queryStringsArrayList.Add(queryString6);
        }


        //若两个时间的TextBox不是都为空
        //注意,TextBox为空时,SelectedDate属性的值为DateTime.MinValue
        if (!((RecentLoginTime_start.SelectedDate == DateTime.MinValue) && (RecentLoginTime_end.SelectedDate == DateTime.MinValue)))
        {
            DateTime time1;
            DateTime time2;

            if (RecentLoginTime_start.SelectedDate == DateTime.MinValue)
            {
                time1 = DateTime.Now;
            }
            else
            {
                time1 = RecentLoginTime_start.SelectedDate;
            }
            if (RecentLoginTime_end.SelectedDate == DateTime.MinValue)
            {
                time2 = DateTime.Now;
            }
            else
            {
                time2 = RecentLoginTime_end.SelectedDate;
            }

            for (int i = 0; i < queryStringsArrayList.Count; i++)
            {
                queryStringsArrayList[i] += " and logtime between '?' and '?'";

                paramList.Add(itemGUID);

                if (time1 <= time2)
                {
                    paramList.Add(time1.ToString("yyyy-MM-dd HH:mm:ss"));
                    paramList.Add(time2.ToString("yyyy-MM-dd HH:mm:ss"));
                }
                else
                {
                    paramList.Add(time2.ToString("yyyy-MM-dd HH:mm:ss"));
                    paramList.Add(time1.ToString("yyyy-MM-dd HH:mm:ss"));
                }
            }
        }
        else
        {
            for (int i = 0; i < queryStringsArrayList.Count; i++)
            {
                paramList.Add(itemGUID);
            }
        }

        string queryString = String.Join(" union all ", (string[])queryStringsArrayList.ToArray(typeof(String)));

        queryString += " order by Time DESC ";

        queryString = queryString.Insert(7, " SQL_CALC_FOUND_ROWS ");

        int currentPage    = (int)ViewState["currentPage"];
        int resultsPerPage = (int)ViewState["resultsPerPage"];
        int offset         = resultsPerPage * currentPage;

        queryString += " limit " + offset.ToString() + "," + resultsPerPage.ToString();
        currentPage++;
        ViewState["currentPage"] = currentPage;

        SqlCommand sqlcmd      = new SqlCommand(queryString, paramList.ToArray());
        SqlResult  queryResult = WebUtil.QueryGameServerDb(CurrentUser.Id, gameCenter, sqlcmd);

        if (queryResult != null && queryResult.Success)
        {
            object[] record = null;

            DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("time", typeof(DateTime)));
            dt.Columns.Add(new DataColumn("event", typeof(String)));
            dt.Columns.Add(new DataColumn("itemName", typeof(String)));
            dt.Columns.Add(new DataColumn("ownerID", typeof(String)));
            dt.Columns.Add(new DataColumn("ownerRoleName", typeof(String)));
            dt.Columns.Add(new DataColumn("itemDetails", typeof(String)));
            dt.Columns.Add(new DataColumn("gameCenterID", typeof(String)));

            DataRow dr;

            queryResult.SetFieldType
            (
                new SqlDataType[]
            {
                SqlDataType.DateTime,
                SqlDataType.String,
                SqlDataType.String,
                SqlDataType.String,
                SqlDataType.String,
                SqlDataType.String,
            }
            );

            while ((record = queryResult.ReadRecord()) != null)
            {
                dr    = dt.NewRow();
                dr[0] = (DateTime)record[0];
                dr[1] = (String)record[1];
                dr[2] = (String)record[2];
                dr[3] = (String)record[3];
                dr[4] = (String)record[4];
                dr[5] = (String)record[5];
                dr[6] = serverGroupDropDownList.SelectedValue;
                dt.Rows.Add(dr);
            }

            DataView dv = new DataView(dt);

            if (dt.Rows.Count == 0)
            {
                LabelSuccess.Visible          = false;
                LabelOpMsg.Text               = "没有满足条件的记录";
                LabelOpMsg.Visible            = true;
                resultDataGrid.Visible        = false;
                resultPagingInfoPanel.Visible = false;

                return;
            }

            resultDataGrid.DataSource = dv;
            resultDataGrid.DataBind();
            resultDataGrid.Visible = true;

            LabelOpMsg.Visible   = false;
            LabelSuccess.Text    = "查询成功完成";
            LabelSuccess.Visible = true;

            //只有在首次查询时,也就是点击查询按钮时才去查结果的总数,otherwise,总数已经在ViewState["totalResults"]中了
            if (firstTimeQuery == true)
            {
                SqlCommand sqlcmdRowCount      = new SqlCommand("select found_rows()", paramList.ToArray());
                SqlResult  queryResultRowCount = WebUtil.QueryGameServerDb(CurrentUser.Id, gameCenter, sqlcmdRowCount);

                queryResultRowCount.SetFieldType(new SqlDataType[] { SqlDataType.String });

                object[] rowCountResult = queryResultRowCount.ReadRecord();

                ViewState["totalResults"] = rowCountResult[0];
            }

            int rowCount = int.Parse((string)ViewState["totalResults"]);
            resultInfoLabel.Text = "共有" + rowCount.ToString() + "条记录,每页" + resultsPerPage.ToString() + "条记录,当前页数:" + currentPage.ToString();

            //当前页数大于1时才允许点击“第一页”按钮和“上一页”按钮
            if (currentPage >= 2)
            {
                ButtonFirstPage.Enabled    = true;
                ButtonPreviousPage.Enabled = true;
            }
            else
            {
                ButtonFirstPage.Enabled    = false;
                ButtonPreviousPage.Enabled = false;
            }

            //当下一页还能有记录的时候才允许点击“下一页”按钮
            if ((resultsPerPage * currentPage) < rowCount)
            {
                ButtonNextPage.Enabled = true;
            }
            else
            {
                ButtonNextPage.Enabled = false;
            }

            resultPagingInfoPanel.Visible = true;
        }
        else
        {
            if (queryResult == null)
            {
                LabelSuccess.Visible          = false;
                LabelOpMsg.Text               = StringDef.NoConnectionAlert;
                LabelOpMsg.Visible            = true;
                resultDataGrid.Visible        = false;
                resultPagingInfoPanel.Visible = false;
            }
            else
            {
                LabelSuccess.Visible          = false;
                LabelOpMsg.Text               = StringDef.OperationFail;
                LabelOpMsg.Visible            = true;
                resultDataGrid.Visible        = false;
                resultPagingInfoPanel.Visible = false;
            }
        }
    }
Exemplo n.º 18
0
    void QueryRole(int serverId, string NodeGUID)
    {
        try
        {
            GameServer server = TheAdminServer.GameServerManager.GetGameServer(serverId);
            if (server == null)
            {
                LabelOpMsg.Text = string.Format(StringDef.MsgCannotBeNone, StringDef.GameServer);
                return;
            }
            if (!server.IsConnected)
            {
                LabelOpMsg.Text = StringDef.NoConnectionAlert;
                return;
            }

            ArrayList paramList = new ArrayList();
            string    cmdText   = "SELECT Id,AccountName,RoleName,RoleSex,RoleType,RoleLevel,SkillSeries,NoChatIn,NoLoginIn,Online FROM rolesfirst WHERE {0}='?' ORDER BY RoleName";
            paramList.Add(NodeGUID);

            SqlCommand cmd    = new SqlCommand(string.Format(cmdText, FS2TableString.RolesfirstFieldTongGUID), paramList.ToArray());
            SqlResult  result = WebUtil.QueryGameServerDb(CurrentUser.Id, server, cmd);

            if (result != null && result.Success)
            {
                result.SetFieldType(
                    new SqlDataType[] {
                    SqlDataType.Int32,
                    SqlDataType.String,
                    SqlDataType.String,
                    SqlDataType.SByte,
                    SqlDataType.SByte,
                    SqlDataType.SByte,
                    SqlDataType.Int32,
                    SqlDataType.Int32,
                    SqlDataType.Int32,
                    SqlDataType.Int32
                });

                ArrayList roles  = new ArrayList();
                object[]  record = null;
                while ((record = result.ReadRecord()) != null)
                {
                    FS2RoleDataInfo info = new FS2RoleDataInfo();
                    info.RoleId      = (int)record[0];
                    info.AccountName = (string)record[1];
                    info.RoleName    = (string)record[2];
                    info.RoleSex     = (FS2RoleSex)(SByte)record[3];
                    info.SkillSeries = (int)record[6];
                    switch ((SByte)record[4])
                    {
                    case (SByte)0:
                        if (info.SkillSeries == 0)
                        {
                            info.RoleType = FS2RoleType.Xuanfeng;
                        }
                        else if (info.SkillSeries == 1)
                        {
                            info.RoleType = FS2RoleType.Xingtian;
                        }
                        else
                        {
                            info.RoleType = FS2RoleType.Jiashi;
                        }
                        break;

                    case (SByte)1:
                        if (info.SkillSeries == 0)
                        {
                            info.RoleType = FS2RoleType.Zhenren;
                        }
                        else if (info.SkillSeries == 1)
                        {
                            info.RoleType = FS2RoleType.Tianshi;
                        }
                        else
                        {
                            info.RoleType = FS2RoleType.Daoshi;
                        }
                        break;

                    case (SByte)2:
                        if (info.SkillSeries == 0)
                        {
                            info.RoleType = FS2RoleType.Shoushi;
                        }
                        else if (info.SkillSeries == 1)
                        {
                            info.RoleType = FS2RoleType.Yishi;
                        }
                        else
                        {
                            info.RoleType = FS2RoleType.Yiren;
                        }
                        break;
                    }
                    info.RoleLevel = (SByte)record[5];
                    info.NoChatIn  = (int)record[7];
                    info.NoLoginIn = (int)record[8];
                    info.Online    = (int)record[9];

                    roles.Add(info);
                }

                DataGridRole.DataSource = CreateDataSource(roles, server.Id);
                DataGridRole.DataBind();

                if (roles == null || roles.Count != 0)
                {
                    LabelOpMsg.Text = StringDef.NoMatchingRecord;
                }
            }
            else
            {
                LabelOpMsg.Text = StringDef.Query + StringDef.Failure;
            }
        }
        catch (Exception ex)
        {
            LabelOpMsg.Text = ex.Message;
        }
    }
Exemplo n.º 19
0
    void Query(int offset)
    {
        try
        {
            PanelResult.Visible = false;

            GameServer server = AdminServer.TheInstance.GameServerManager.GetGameServer(int.Parse(serverGroupDropDownList.SelectedValue));
            if (server == null)
            {
                LabelOpMsg.Text = string.Format(StringDef.MsgCannotBeNone, StringDef.GameServer);
                return;
            }
            //读权限
            if (!WebUtil.CheckPrivilege(server.SecurityObject, OpType.READ, Session))
            {
                LabelOpMsg.Text = StringDef.NotEnoughPrivilege;
                return;
            }
            if (!server.IsConnected)
            {
                LabelOpMsg.Text = StringDef.NoConnectionAlert;
                return;
            }
            ArrayList     paramList       = new ArrayList();
            StringBuilder searchCondition = new StringBuilder();

            string cRoleName    = TextBoxcRoleName.Text;
            string cAccountName = TextBoxcAccountName.Text;
            WebUtil.ValidateValueString(cRoleName);
            WebUtil.ValidateValueString(cAccountName);
            //角色名
            if (cRoleName.Length > 0)
            {
                if (CheckBoxcRoleName.Checked)
                {
                    searchCondition.AppendFormat(" AND {0}='?'", JX2TableString.cRoleName);
                }
                else
                {
                    searchCondition.AppendFormat(" AND {0} LIKE '%?%'", JX2TableString.cRoleName);
                }
                paramList.Add(cRoleName);
            }
            //帐号名
            if (cAccountName.Length > 0)
            {
                if (CheckBoxcAccountName.Checked)
                {
                    searchCondition.Append(string.Format(" AND {0}='?'", JX2TableString.cAccountName));
                }
                else
                {
                    searchCondition.Append(string.Format(" AND {0} LIKE '%?%'", JX2TableString.cAccountName));
                }
                paramList.Add(cAccountName);
            }


            //性别
            int sex = ListBoxSex.SelectedIndex - 1;
            if (sex >= 0)
            {
                searchCondition.Append(string.Format(" AND {0}={1}", JX2TableString.iSex, sex));
            }
            //总在线时间
            string gametime_start_str = TextBoxdwGameTime_start.Text;
            string gametime_end_str   = TextBoxdwGameTime_end.Text;
            if (gametime_start_str != "" && gametime_end_str != "")
            {
                int GameTime_start = Convert.ToInt32(TextBoxdwGameTime_start.Text);
                int GameTime_end   = Convert.ToInt32(TextBoxdwGameTime_end.Text);

                if (GameTime_start > GameTime_end)
                {
                    LabelOpMsg.Text = StringDef.EndTimesmallerThanStartTime;
                    return;
                }
                else
                {
                    GameTime_start = GameTime_start * 3600;
                    GameTime_end   = GameTime_end * 3600;
                    searchCondition.AppendFormat(" AND {0}>='{1}' AND {0}<='{2}'", JX2TableString.iGameTime,
                                                 GameTime_start, GameTime_end);
                }
            }



            //金钱
            string Money_start_str = TextBoxMoney_start.Text;
            string Money_end_str   = TextBoxMoney_end.Text;
            if (Money_start_str != "" && Money_end_str != "")
            {
                int Money_start = Convert.ToInt32(TextBoxMoney_start.Text);
                int Money_end   = Convert.ToInt32(TextBoxMoney_end.Text);
                if (Money_start > Money_end)
                {
                    LabelOpMsg.Text = StringDef.EndTimesmallerThanStartTime;
                    return;
                }
                else
                {
                    searchCondition.AppendFormat(" AND {0}>='{1}' AND {0}<='{2}'", JX2TableString.iMoney,
                                                 Money_start, Money_end);
                }
            }



            //创建时间
            DateTime createtime_start = CreateTime_start.SelectedDate;
            DateTime createtime_end   = CreateTime_end.SelectedDate;
            if (createtime_start != DateTime.MinValue && createtime_end == DateTime.MinValue)
            {
                searchCondition.AppendFormat(" AND {0}>='{1}'", JX2TableString.dCreateTime,
                                             createtime_start.ToString("yyyy-MM-dd HH:mm:ss"));
            }
            else if (createtime_start == DateTime.MinValue && createtime_end != DateTime.MinValue)
            {
                searchCondition.AppendFormat(" AND {0}<='{1}'", JX2TableString.dCreateTime,
                                             createtime_end.ToString("yyyy-MM-dd HH:mm:ss"));
            }
            else if (createtime_start != DateTime.MinValue && createtime_end != DateTime.MinValue)
            {
                if (createtime_start > createtime_end)
                {
                    LabelOpMsg.Text = StringDef.ParameterInputError;
                    return;
                }
                else
                {
                    searchCondition.AppendFormat(" AND {0}>='{1}' AND {0}<='{2}'", JX2TableString.dCreateTime,
                                                 createtime_start.ToString("yyyy-MM-dd HH:mm:ss"), createtime_end.ToString("yyyy-MM-dd HH:mm:ss"));
                }
            }


            //最后一次登陆时间
            DateTime lastlogintime_start = LastLoginTime_start.SelectedDate;
            DateTime lastlogintime_end   = LastLoginTime_end.SelectedDate;
            if (lastlogintime_start != DateTime.MinValue && lastlogintime_end == DateTime.MinValue)
            {
                searchCondition.AppendFormat(" AND {0}>='{1}'", JX2TableString.dLastLoginTime,
                                             lastlogintime_start.ToString("yyyy-MM-dd HH:mm:ss"));
            }
            else if (lastlogintime_start == DateTime.MinValue && lastlogintime_end != DateTime.MinValue)
            {
                searchCondition.AppendFormat(" AND {0}<='{1}'", JX2TableString.dLastLoginTime,
                                             lastlogintime_end.ToString("yyyy-MM-dd HH:mm:ss"));
            }
            if (lastlogintime_start != DateTime.MinValue && lastlogintime_end != DateTime.MinValue)
            {
                if (lastlogintime_start > lastlogintime_end)
                {
                    LabelOpMsg.Text = StringDef.EndTimesmallerThanStartTime;
                    return;
                }
                else
                {
                    searchCondition.AppendFormat(" AND {0}>='{1}' AND {0}<='{2}'", JX2TableString.dLastLoginTime,
                                                 lastlogintime_start.ToString("yyyy-MM-dd HH:mm:ss"), lastlogintime_end.ToString("yyyy-MM-dd HH:mm:ss"));
                }
            }

            //角色
            StringBuilder roleTypeBuilder = new StringBuilder();
            foreach (ListItem item in CheckBoxListRoleType.Items)
            {
                if (item.Selected)
                {
                    string[] conValue = item.Value.Split(',');
                    roleTypeBuilder.AppendFormat("({0}='{1}' AND {2}='{3}') OR ", JX2TableString.iFaction, conValue[0], JX2TableString.iFactionRoute, conValue[1]);    //门派,与门派路线
                }
            }
            if (roleTypeBuilder.Length != 0)
            {
                searchCondition.AppendFormat(" AND ({0}) ", roleTypeBuilder.ToString(0, roleTypeBuilder.Length - 3));
            }
            else
            {
                LabelOpMsg.Text    = string.Format(StringDef.MsgCannotBeNone, StringDef.RoleClass);
                LabelOpMsg.Visible = true;
                return;
            }

            //等级排序
            int startLevel = int.Parse(ListBoxStartLevel.SelectedValue);
            if (startLevel > 1)
            {
                searchCondition.Append(string.Format(" AND {0}>={1}", JX2TableString.iLevel, startLevel));
            }

            int endLevel = int.Parse(ListBoxEndLevel.SelectedValue);
            if (endLevel < FS2GameDataManager.MaxLevel)
            {
                searchCondition.Append(string.Format(" AND {0}<={1}", JX2TableString.iLevel, endLevel));
            }

            if (searchCondition.Length > 0)
            {
                searchCondition.Remove(0, 4);
                searchCondition.Insert(0, " WHERE");
            }

            //排序
            string orderByType = string.Empty;
            switch (ListBoxOrderByType.SelectedIndex)
            {
            case 0:
                orderByType = "ASC";
                break;

            case 1:
                orderByType = "DESC";
                break;
            }

            string orderByStatement = string.Empty;
            switch (ListBoxOrderBy.SelectedIndex)
            {
            case 0:
                orderByStatement = string.Format(" ORDER BY {0} {1}", JX2TableString.iLevel, orderByType);
                break;

            case 1:
                orderByStatement = string.Format(" ORDER BY {0} {1}", JX2TableString.iFaction, orderByType);
                break;
            }

            int    limitCount     = _recordPerPage;
            string limitStatement = string.Format(" LIMIT {0},{1}", offset, limitCount + 1);

            SqlCommand cmd = new SqlCommand("SELECT cAccountName,cRoleName,iSex,iLevel,iGameTime,iFaction,iFactionRoute,iMoney, dCreateTime,dLastLoginTime,cRoleID FROM trolebaseinfo" + searchCondition.ToString() + orderByStatement + limitStatement, paramList.ToArray());

            SqlResult result = WebUtil.QueryGameServerDb(CurrentUser.Id, server, cmd);

            if (result != null && result.Success)
            {
                ViewState[WebConfig.SessionQueryLogOffset] = offset;

                result.SetFieldType(
                    new SqlDataType[] {
                    SqlDataType.String,
                    SqlDataType.String,
                    SqlDataType.SByte,
                    SqlDataType.Int32,    //等级
                    SqlDataType.Int32,    //在线时间
                    SqlDataType.Int32,
                    SqlDataType.Int32,
                    SqlDataType.Int64,
                    SqlDataType.DateTime,
                    SqlDataType.DateTime,
                    SqlDataType.String
                });
                //做结果列表了
                ArrayList roles  = new ArrayList();
                object[]  record = null;
                //Encoding utf8 = Encoding.UTF8;
                //Encoding gb2312 = Encoding.GetEncoding("GB2312");
                while ((record = result.ReadRecord()) != null)
                {
                    JX2RoleDataInfo info = new JX2RoleDataInfo();
                    info.cAccountName = (string)record[0];
                    //string strRoleName = (string)record[1];
                    //info.cRoleName = utf8.GetString(gb2312.GetBytes(strRoleName));
                    info.cRoleName = (string)record[1];
                    info.iSex      = (JX2RoleSex)(SByte)record[2];
                    info.iLevel    = (int)record[3];
                    //在线时间
                    info.iGameTime = (int)record[4];
                    //这个是门派字段
                    info.iFaction = (int)record[5];
                    //这个是门派路线字段
                    info.iFactionRoute = (int)record[6];
                    //这个是职业字段
                    info.RoleType = (JxRoleType)(info.iFaction * 100 + info.iFactionRoute);//RoleType等于iFaction乘100与iFactionRoute相加,为了与JxRoleType批配
                    info.iMoney   = (Int64)record[7];
                    if (record[8] != null)
                    {
                        info.dCreateTime = (DateTime)record[8];
                    }
                    //游戏新建角色,没登陆显示的上次登陆时间为1970-1-1 10:00:00,处理:上次登陆时间小与创建时间的,上次登陆时间置为创建时间
                    if (record[9] != null && (DateTime)record[9] > (DateTime)record[8])
                    {
                        info.dLastLoginTime = (DateTime)record[9];
                    }
                    else
                    {
                        info.dLastLoginTime = (DateTime)record[8];
                    }
                    info.cRoleID = (String)record[10];
                    roles.Add(info);
                }


                ButtonPreviousPage.Enabled = (offset > 0);
                ButtonFirstPage.Enabled    = (offset > 0);
                ButtonNextPage.Enabled     = (roles.Count > limitCount);
                DataGridResult.DataSource  = CreateDataSource(roles);
                DataGridResult.DataBind();

                if (roles != null && roles.Count != 0)
                {
                    PanelResult.Visible = true;
                }
                else
                {
                    PanelResult.Visible = false;
                }

                if (!PanelResult.Visible)
                {
                    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;
        }
    }
Exemplo n.º 20
0
    void ExpByPlayTime(System.Drawing.Graphics g, ZedGraph.MasterPane masterPane)
    {
        try
        {
            GameServer server = ServerDropDownList.SelectedGameServer;
            if (server == null)
            {
                LabelOpMsg.Text = string.Format(StringDef.MsgCannotBeNone, StringDef.GameServer);
                return;
            }
            //加入权限检查
            if (!WebUtil.CheckPrivilege(server.SecurityObject, OpType.READ, Session))
            {
                Response.Redirect(WebConfig.PageNotEnoughPrivilege, true);
            }
            if (!server.IsConnected)
            {
                LabelOpMsg.Text = StringDef.NoConnectionAlert;
                return;
            }

            List <int> playTimeList   = new List <int>();
            List <int> reachLevelList = new List <int>();

            string baseCmdString = string.Format("SELECT LogKey2, LogKey6,LogTime FROM {0} WHERE {1}='{2}' AND {3}='{4}'",
                                                 "{0}",
                                                 FS2TableString.LogFieldLogEvent,
                                                 LogEvent.PlayerUpgrade,
                                                 FS2TableString.LogFieldLogKey1,
                                                 _roleGuid);

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

            string     cmdString = string.Format("SELECT LogKey2,LogKey6 FROM ({0}) AS A ORDER BY LogTime ASC", addTableCmdString);
            SqlCommand cmd       = new SqlCommand(cmdString);
            SqlResult  result    = WebUtil.QueryGameServerDb(CurrentUser.Id, server, cmd);
            if (result != null && result.Success)
            {
                result.SetFieldType(new SqlDataType[] {
                    SqlDataType.String,
                    SqlDataType.Int32
                });
                object[] record = null;
                while ((record = result.ReadRecord()) != null)
                {
                    reachLevelList.Add(int.Parse((string)record[0]));
                    playTimeList.Add((Int32)record[1]);
                }
            }
            else
            {
                if (result == null)
                {
                    LabelOpMsg.Text = StringDef.QueryTimeOut;
                }
                else
                {
                    LabelOpMsg.Text = StringDef.OperationFail;
                }
            }

            int      count           = playTimeList.Count;
            double[] playTimeArray   = new double[count + 1];
            double[] reachLevelArray = new double[count + 1];
            playTimeArray[0]   = 0;
            reachLevelArray[0] = 1;
            for (int i = 0; i < count; i++)
            {
                playTimeArray[i + 1]   = playTimeList[i] / 60;
                reachLevelArray[i + 1] = reachLevelList[i];
            }

            GraphPane graphPane = masterPane[0];

            graphPane.Fill = new Fill(WebConfig.GraphPaneBgColor);

            graphPane.Legend.Fill.IsVisible          = false;
            graphPane.Legend.Border.IsVisible        = false;
            graphPane.Legend.FontSpec.Fill.IsVisible = false;

            graphPane.XAxis.Title.Text          = string.Format("{0} [{1}]", StringDef.PlayedTime, StringDef.Minute);
            graphPane.XAxis.MajorGrid.Color     = WebConfig.GraphXAxisGridColor;
            graphPane.XAxis.MinorTic.Size       = 0;
            graphPane.XAxis.Scale.FontSpec.Size = 12;

            graphPane.YAxis.Title.Text          = StringDef.Level;
            graphPane.YAxis.MajorGrid.IsVisible = true;
            graphPane.YAxis.MajorGrid.DashOff   = 0;
            graphPane.YAxis.MajorGrid.Color     = Color.Gray;
            graphPane.YAxis.MinorGrid.IsVisible = true;
            graphPane.YAxis.MinorGrid.Color     = Color.LightGray;
            graphPane.YAxis.MinorGrid.DashOff   = 0;
            graphPane.Title.Text = string.Format("[{0}] {1}", _roleName, StringDef.LevelCurve);

            graphPane.AddCurve(StringDef.Level, playTimeArray, reachLevelArray, Color.Red, SymbolType.None);
        }
        catch (Exception ex)
        {
            LabelOpMsg.Visible = true;
            LabelOpMsg.Text    = ex.Message;
            ZedGraphWebExpStatistic.Visible = false;
        }
    }
Exemplo n.º 21
0
    void Query(int offset)
    {
        try
        {
            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();

            StringBuilder roleTypeBuilder = new StringBuilder();
            foreach (ListItem item in CheckBoxListRoleType.Items)
            {
                if (item.Selected)
                {
                    string[] conValue = item.Value.Split(',');
                    roleTypeBuilder.AppendFormat("({0}='{1}' AND {2}='{3}') OR ", FS2TableString.RolesfirstFieldRoleType, conValue[0], FS2TableString.RolesfirstFieldSkillSeries, conValue[1]);
                }
            }
            if (roleTypeBuilder.Length != 0)
            {
                searchCondition.AppendFormat(" AND ({0}) ", roleTypeBuilder.ToString(0, roleTypeBuilder.Length - 3));
            }
            else
            {
                LabelOpMsg.Text = string.Format(StringDef.MsgCannotBeNone, StringDef.RoleClass);
                return;
            }

            int startLevel = int.Parse(TextBoxStartLevel.Text);
            if (startLevel > 1)
            {
                searchCondition.Append(string.Format(" AND {0}>={1}", FS2TableString.RolesfirstFieldRoleLevel, startLevel));
            }

            int endLevel = int.Parse(TextBoxEndLevel.Text);
            if (endLevel < FS2GameDataManager.MaxLevel)
            {
                searchCondition.Append(string.Format(" AND {0}<={1}", FS2TableString.RolesfirstFieldRoleLevel, endLevel));
            }

            DateTime activeDate = CalendarDate.SelectedDate;
            if (activeDate == DateTime.MinValue)
            {
                LabelOpMsg.Text = string.Format(StringDef.MsgInputParamNotCorrect, StringDef.Date);
                return;
            }
            switch (StatisticType.SelectedIndex)
            {
            case -1:
                LabelOpMsg.Text = string.Format(StringDef.MsgCannotBeNone, StringDef.Statistic + StringDef.Type);
                return;

            case 0:
                //活跃玩家
                searchCondition.AppendFormat(" AND {0}>='{1}' ", FS2TableString.RolesfirstFieldLastPlayingDate, activeDate.AddDays(-WebConfig.ActivePlayerDaySpan));
                break;

            case 1:
                //不活跃玩家
                searchCondition.AppendFormat(" AND {0}<'{1}' ", FS2TableString.RolesfirstFieldLastPlayingDate, activeDate.AddDays(-WebConfig.ActivePlayerDaySpan));
                break;

            case 2:
                //流失玩家
                searchCondition.AppendFormat(" AND {0}>='{1}' AND {0}<'{2}' ", FS2TableString.RolesfirstFieldLastPlayingDate, activeDate.AddDays(-WebConfig.ActivePlayerDaySpan).AddDays(-WebConfig.ActivePlayerDayValue), activeDate.AddDays(-WebConfig.ActivePlayerDaySpan));
                break;
            }

            if (searchCondition.Length > 0)
            {
                searchCondition.Remove(0, 4);
                searchCondition.Insert(0, " WHERE");
            }

            string orderByType = string.Empty;
            switch (ListBoxOrderByType.SelectedIndex)
            {
            case 0:
                orderByType = "ASC";
                break;

            case 1:
                orderByType = "DESC";
                break;
            }

            string orderByStatement = string.Empty;
            switch (ListBoxOrderBy.SelectedIndex)
            {
            case 0:
                orderByStatement = string.Format(" ORDER BY {0} {1}", FS2TableString.RolesfirstFieldRoleName, orderByType);
                break;

            case 1:
                orderByStatement = string.Format(" ORDER BY {0} {1}", FS2TableString.RolesfirstFieldRoleLevel, orderByType);
                break;
            }

            int    limitCount     = _recordPerPage;
            string limitStatement = string.Format(" LIMIT {0},{1}", offset, limitCount);

            string cmdText      = "SELECT {0} FROM {1} {2} {3} {4}";
            string cmdFieldText = "Id,AccountName,RoleName,RoleSex,RoleType,RoleLevel,SkillSeries";

            SqlCommand cmd = new SqlCommand(string.Format(cmdText, cmdFieldText, FS2TableString.RolesfirstTableName,
                                                          searchCondition.ToString(), orderByStatement, limitStatement));
            SqlResult result = WebUtil.QueryGameServerDb(CurrentUser.Id, server, cmd);
            if (result != null && result.Success)
            {
                Session[WebConfig.SessionQueryLogOffset] = offset;

                result.SetFieldType(
                    new SqlDataType[] {
                    SqlDataType.Int32,
                    SqlDataType.String,
                    SqlDataType.String,
                    SqlDataType.SByte,
                    SqlDataType.SByte,
                    SqlDataType.SByte,
                    SqlDataType.Int32
                });

                ArrayList roleList = new ArrayList();
                object[]  record   = null;
                while ((record = result.ReadRecord()) != null)
                {
                    FS2RoleDataInfo role = new FS2RoleDataInfo();
                    role.RoleId      = (int)record[0];
                    role.AccountName = record[1] as string;
                    role.RoleName    = record[2] as string;
                    role.RoleLevel   = (SByte)record[5];
                    role.SkillSeries = (int)record[6];
                    switch ((SByte)record[4])
                    {
                    case (SByte)0:
                        if (role.SkillSeries == 0)
                        {
                            role.RoleType = FS2RoleType.Xuanfeng;
                        }
                        else if (role.SkillSeries == 1)
                        {
                            role.RoleType = FS2RoleType.Xingtian;
                        }
                        else
                        {
                            role.RoleType = FS2RoleType.Jiashi;
                        }
                        break;

                    case (SByte)1:
                        if (role.SkillSeries == 0)
                        {
                            role.RoleType = FS2RoleType.Zhenren;
                        }
                        else if (role.SkillSeries == 1)
                        {
                            role.RoleType = FS2RoleType.Tianshi;
                        }
                        else
                        {
                            role.RoleType = FS2RoleType.Daoshi;
                        }
                        break;

                    case (SByte)2:
                        if (role.SkillSeries == 0)
                        {
                            role.RoleType = FS2RoleType.Shoushi;
                        }
                        else if (role.SkillSeries == 1)
                        {
                            role.RoleType = FS2RoleType.Yishi;
                        }
                        else
                        {
                            role.RoleType = FS2RoleType.Yiren;
                        }
                        break;
                    }

                    roleList.Add(role);
                }

                ButtonPreviousPage.Enabled = (offset > 0);
                ButtonFirstPage.Enabled    = (offset > 0);
                ButtonNextPage.Enabled     = (roleList.Count >= limitCount);

                bool success = CreateSearchRoleResultList(server.Id, (FS2RoleDataInfo[])roleList.ToArray(typeof(FS2RoleDataInfo)));
                PanelResult.Visible = success;

                if (!success)
                {
                    LabelOpMsg.Text = StringDef.NoMatchingRecord;
                }
                else
                {
                    LabelResult.Text = string.Format(StringDef.LabelStatisticResult, server.Group.Name, server.Name,
                                                     string.Format(StringDef.LabelRoleLevel, startLevel, endLevel),
                                                     StatisticType.SelectedItem.Text);
                }
            }
            else
            {
                if (result == null)
                {
                    LabelOpMsg.Text = StringDef.QueryTimeOut;
                }
                else
                {
                    LabelOpMsg.Text = StringDef.OperationFail;
                }
            }
        }
        catch (Exception ex)
        {
            LabelOpMsg.Text     = ex.Message;
            PanelResult.Visible = false;
        }
    }
Exemplo n.º 22
0
    private void Query(int offset)
    {
        try
        {
            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 cmdTextBuilder = new StringBuilder();
            cmdTextBuilder.AppendFormat("SELECT {1},{2},{3},{4},{5} FROM {6} ",
                                        FS2TableString.ItemBankFieldPlayerName, FS2TableString.ItemBankFieldGenre, FS2TableString.ItemBankFieldDetail,
                                        FS2TableString.ItemBankFieldParticular, FS2TableString.ItemBankFieldLevel, FS2TableString.ItemBankFieldItemCount,
                                        FS2TableString.ItemBankTableName);

            StringBuilder conditionStr = new StringBuilder();

            string itemId = TextBoxItemId.Text.Trim();
            if (itemId.Length != 0)
            {
                string[] ids = itemId.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                if (ids.Length != 4)
                {
                    LabelOpMsg.Text = StringDef.ParameterInputError;
                    return;
                }

                conditionStr.AppendFormat("AND {0}='{1}' AND {2}='{3}' AND {4}='{5}' AND {6}={7} ",
                                          FS2TableString.ItemBankFieldGenre, ids[0], FS2TableString.ItemBankFieldDetail, ids[1],
                                          FS2TableString.ItemBankFieldParticular, ids[2], FS2TableString.ItemBankFieldLevel, ids[3]);
            }

            string roleName = TextBoxRoleName.Text.Trim();
            if (roleName != null && roleName.Length != 0)
            {
                conditionStr.AppendFormat("AND {0}='?' ", FS2TableString.ItemBankFieldPlayerName);
                paramList.Add(roleName);
            }

            if (conditionStr.Length != 0)
            {
                conditionStr.Remove(0, 3);
                conditionStr.Insert(0, "WHERE");
                cmdTextBuilder.Append(conditionStr.ToString());
            }

            cmdTextBuilder.AppendFormat("GROUP BY CONCAT({0},{1},{2},{3})", FS2TableString.ItemBankFieldGenre,
                                        FS2TableString.ItemBankFieldDetail, FS2TableString.ItemBankFieldParticular, FS2TableString.ItemBankFieldLevel);

            int limitCount = _recordPerPage;
            cmdTextBuilder.AppendFormat(" LIMIT {0},{1}", offset, limitCount);

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

                object[]  record    = null;
                ArrayList statInfos = new ArrayList();
                while ((record = result.ReadRecord()) != null)
                {
                    ItemBankStatInfo info = new ItemBankStatInfo();

                    info.ItemTemplateId = string.Concat((int)record[0], ',', (int)record[1], ',', (int)record[2], ',', (int)record[3]);
                    info.Count          = (UInt32)record[4];

                    statInfos.Add(info);
                }

                ViewState[WebConfig.SessionQueryLogOffset] = offset;

                ButtonPreviousPage.Enabled = (offset > 0);
                ButtonFirstPage.Enabled    = (offset > 0);
                ButtonNextPage.Enabled     = (statInfos.Count >= limitCount);

                if (statInfos.Count != 0)
                {
                    PanelResult.Visible = true;
                    if (TextBoxRoleName.Text.Trim().Length != 0)
                    {
                        LabelResult.Text = string.Format(StringDef.LabelStatisticResult, server.Group.Name,
                                                         server.Name, roleName, StringDef.Item);
                    }
                    else
                    {
                        LabelResult.Text = string.Format(StringDef.LabelStatisticResult, server.Group.Name,
                                                         server.Name, string.Empty, StringDef.Item);
                    }

                    DataGridStatInfo.DataSource = CreateDataSource(statInfos);
                    DataGridStatInfo.DataBind();
                }
                else
                {
                    PanelResult.Visible = false;
                }
            }
            else
            {
                LabelOpMsg.Text     = StringDef.OperationFail;
                PanelResult.Visible = false;
            }
        }
        catch (Exception ex)
        {
            LabelOpMsg.Text     = ex.Message;
            PanelResult.Visible = false;
        }
    }
Exemplo n.º 23
0
    void Query()
    {
        try
        {
            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.AppendFormat("WHERE {0}={1}", FS2TableString.LogFieldLogEvent, LogEvent.ExchangeItem);

            string itemName = TextBoxInputItemName.Text.Trim();
            if (itemName.Length != 0)
            {
                searchCondition.AppendFormat(" AND {0} LIKE '?'", FS2TableString.LogFieldLogData);
                if (CheckBoxItemName.Checked)
                {
                    paramList.Add(string.Format("%“{0}”%", itemName));
                }
                else
                {
                    paramList.Add(string.Format("%“%{0}%”%", itemName));
                }
            }

            string giverName = TextBoxInputGiver.Text.Trim();
            if (giverName.Length != 0)
            {
                if (CheckBoxGiver.Checked)
                {
                    searchCondition.AppendFormat(" AND {0} IN ({1})", FS2TableString.LogFieldLogKey1,
                                                 string.Format("SELECT {0} FROM {1} WHERE {2}='?'", FS2TableString.RolesfirstFieldGUID,
                                                               FS2TableString.RolesfirstTableName, FS2TableString.RolesfirstFieldRoleName));
                }
                else
                {
                    searchCondition.AppendFormat(" AND {0} IN ({1})", FS2TableString.LogFieldLogKey1,
                                                 string.Format("SELECT {0} FROM {1} WHERE {2} LIKE '%?%'", FS2TableString.RolesfirstFieldGUID,
                                                               FS2TableString.RolesfirstTableName, FS2TableString.RolesfirstFieldRoleName));
                }
                paramList.Add(giverName);
            }

            string receiverName = TextBoxInputReceiver.Text.Trim();
            if (receiverName.Length != 0)
            {
                if (CheckBoxReceiver.Checked)
                {
                    searchCondition.AppendFormat(" AND {0} IN ({1})", FS2TableString.LogFieldLogKey3,
                                                 string.Format("SELECT {0} FROM {1} WHERE {2} = '?'", FS2TableString.RolesfirstFieldGUID,
                                                               FS2TableString.RolesfirstTableName, FS2TableString.RolesfirstFieldRoleName));
                }
                else
                {
                    searchCondition.AppendFormat(" AND {0} IN ({1})", FS2TableString.LogFieldLogKey3,
                                                 string.Format("SELECT {0} FROM {1} WHERE {2} LIKE '%?%'", FS2TableString.RolesfirstFieldGUID,
                                                               FS2TableString.RolesfirstTableName, FS2TableString.RolesfirstFieldRoleName));
                }
                paramList.Add(receiverName);
            }

            _start = StartDate.SelectedDate;
            if (_start == DateTime.MinValue)
            {
                LabelOpMsg.Text = StringDef.ParameterInputError;
                return;
            }
            _end = EndDate.SelectedDate;
            if (_end == DateTime.MinValue)
            {
                LabelOpMsg.Text = StringDef.ParameterInputError;
                return;
            }
            searchCondition.Append(string.Format(" 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 LogKey1,LogKey3,LogData,LogTime FROM {0} {1}",
                                                 "{0}", searchCondition.ToString());
            string addTableCmdString;
            WebUtil.AddTableNameToCmd(CurrentUser.Id, server, baseCmdString, paramList, _start, _end, out addTableCmdString, out paramList);
            if (addTableCmdString.Length == 0)
            {
                //
                return;
            }

            string     cmdString = "SELECT LogKey1,LogKey3,LogData,LogTime FROM ({0}) AS A ORDER BY LogTime";
            SqlCommand cmd       = new SqlCommand(string.Format(cmdString, addTableCmdString), paramList.ToArray());
            SqlResult  result    = WebUtil.QueryGameServerDb(CurrentUser.Id, server, cmd);
            if (result != null && result.Success)
            {
                result.SetFieldType(new SqlDataType[] {
                    SqlDataType.String,
                    SqlDataType.String,
                    SqlDataType.Blob,
                    SqlDataType.DateTime
                });

                object[]  record       = null;
                ArrayList infos        = new ArrayList();
                ArrayList roleGuidList = new ArrayList();

                while ((record = result.ReadRecord()) != null)
                {
                    ExchangeRecord info = new ExchangeRecord();

                    info.giverGuid = record[0] as string;
                    if (info.giverGuid != null && !roleGuidList.Contains(info.giverGuid))
                    {
                        roleGuidList.Add(info.giverGuid);
                    }
                    info.receiverGuid = record[1] as string;
                    if (info.receiverGuid != null && !roleGuidList.Contains(info.receiverGuid))
                    {
                        roleGuidList.Add(info.receiverGuid);
                    }
                    info.time = (DateTime)record[3];

                    string blobData = Encoding.Default.GetString((byte[])record[2]);
                    blobData = blobData.Replace("“", "\"");
                    blobData = blobData.Replace("”", "\"");
                    string[] blobDataSplit = blobData.Split('\"');
                    info.itemName = blobDataSplit[3];

                    infos.Add(info);
                }

                if (infos.Count == 0)
                {
                    //没有查询到信息
                    LabelOpMsg.Text     = StringDef.NoMatchingRecord;
                    PanelResult.Visible = false;
                }
                else
                {
                    PanelResult.Visible       = true;
                    DataGridResult.DataSource = CreateDataSource(infos, GetRoleGuid(roleGuidList));
                    DataGridResult.DataBind();
                }
            }
            else
            {
                if (result == null)
                {
                    LabelOpMsg.Text = StringDef.QueryTimeOut;
                }
                else
                {
                    LabelOpMsg.Text = StringDef.OperationFail;
                }
                PanelResult.Visible = false;
            }
        }
        catch (Exception ex)
        {
            PanelResult.Visible = false;
            LabelOpMsg.Text     = ex.Message;
        }
    }
Exemplo n.º 24
0
    void ExpByDate(System.Drawing.Graphics g, ZedGraph.MasterPane masterPane)
    {
        try
        {
            GameServer server = ServerDropDownList.SelectedGameServer;

            if (server == null)
            {
                LabelOpMsg.Text = string.Format(StringDef.MsgCannotBeNone, StringDef.GameServer);
                return;
            }
            //加入权限检查
            if (!WebUtil.CheckPrivilege(server.SecurityObject, OpType.READ, Session))
            {
                Response.Redirect(WebConfig.PageNotEnoughPrivilege, true);
            }
            if (!server.IsConnected)
            {
                LabelOpMsg.Text = StringDef.NoConnectionAlert;
                return;
            }

            List <DateTime> dateList = new List <DateTime>();
            List <int>      expList  = new List <int>();

            string baseCmdString = string.Format("SELECT DATE({0}) AS LogDate, SUM({1}) AS ExpSum FROM {2} WHERE {3}='{4}' AND {5}='{6}' GROUP BY LogDate",
                                                 FS2TableString.LogFieldLogTime,
                                                 FS2TableString.LogFieldLogKey6,
                                                 "{0}",
                                                 FS2TableString.LogFieldLogEvent,
                                                 LogEvent.GetExperience,
                                                 FS2TableString.LogFieldLogKey1,
                                                 _roleGuid);
            string addTableCmdString;
            WebUtil.AddTableNameToCmd(CurrentUser.Id, server, baseCmdString, _start, _end, out addTableCmdString);
            if (addTableCmdString.Length == 0)
            {
                return;
            }

            SqlCommand cmd    = new SqlCommand(string.Format("SELECT LogDate,ExpSum FROM ({0}) AS A ORDER BY LogDate ASC", addTableCmdString));
            SqlResult  result = WebUtil.QueryGameServerDb(CurrentUser.Id, server, cmd);
            if (result != null && result.Success)
            {
                result.SetFieldType(new SqlDataType[] { SqlDataType.DateTime, SqlDataType.Int32 });
                object[] record = null;
                while ((record = result.ReadRecord()) != null)
                {
                    dateList.Add((DateTime)record[0]);
                    expList.Add((Int32)record[1]);
                }
            }
            else
            {
                if (result == null)
                {
                    LabelOpMsg.Text = StringDef.QueryTimeOut;
                }
                else
                {
                    LabelOpMsg.Text = StringDef.OperationFail;
                }
            }

            TimeSpan actualTime = DateTime.Now.Subtract(_start > _createTime ? _start : _createTime);
            int      days       = actualTime.Days + 1;
            double[] dateArray  = new double[days];
            double[] expArray   = new double[days];
            for (int date = 0; date < days; date++)
            {
                DateTime dateTime = _createTime.AddDays(date);
                dateArray[date] = new XDate(dateTime.Year, dateTime.Month, dateTime.Day);

                double expAddToday = 0;
                for (int j = 0; j < dateList.Count; j++)
                {
                    DateTime date2 = dateList[j];
                    if (date2.Date == dateTime.Date)
                    {
                        expAddToday += expList[j];
                    }
                }

                expArray[date] = expAddToday;
                if (date > 0)
                {
                    expArray[date] += expArray[date - 1];
                }
            }

            GraphPane graphPane = masterPane[0];


            graphPane.Fill = new Fill(WebConfig.GraphPaneBgColor);

            graphPane.Legend.Fill.IsVisible          = false;
            graphPane.Legend.Border.IsVisible        = false;
            graphPane.Legend.FontSpec.Fill.IsVisible = false;

            graphPane.XAxis.Title.Text          = StringDef.Date;
            graphPane.XAxis.MajorGrid.Color     = WebConfig.GraphXAxisGridColor;
            graphPane.XAxis.Type                = AxisType.DateAsOrdinal;
            graphPane.XAxis.MinorTic.Size       = 0;
            graphPane.XAxis.Scale.MajorStep     = 1;
            graphPane.XAxis.Scale.FontSpec.Size = 12;
            graphPane.XAxis.Scale.MajorUnit     = DateUnit.Day;
            graphPane.XAxis.Scale.Format        = "MM-dd";

            graphPane.YAxis.MajorGrid.IsVisible = true;
            graphPane.YAxis.MajorGrid.DashOff   = 0;
            graphPane.YAxis.MajorGrid.Color     = Color.Gray;
            graphPane.YAxis.MinorGrid.IsVisible = true;
            graphPane.YAxis.MinorGrid.Color     = Color.LightGray;
            graphPane.YAxis.MinorGrid.DashOff   = 0;

            graphPane.Title.Text       = string.Format("[{0}] {1}", _roleName, StringDef.ExperienceCurve);
            graphPane.YAxis.Title.Text = StringDef.Exp;

            graphPane.AddCurve(StringDef.Exp, dateArray, expArray, Color.Red, SymbolType.None);
        }
        catch (Exception ex)
        {
            LabelOpMsg.Visible = true;
            LabelOpMsg.Text    = ex.Message;
            ZedGraphWebExpStatistic.Visible = false;
        }
    }
Exemplo n.º 25
0
    AnalyseResult AnalyseData(GameServer server, int logEventId, string additionalFilter)
    {
        double[] statisticValues = null;
        double[] statisticTimes  = null;
        double[] statisticCounts = null;

        bool bQuitFlag = false;

        StringBuilder whereStatement = new StringBuilder();

        whereStatement.AppendFormat(" WHERE {0}={1} ", FS2TableString.LogFieldLogEvent, logEventId);

        if (_roleGuid != null)
        {
            whereStatement.AppendFormat(" AND {0}='{1}'", FS2TableString.LogFieldLogKey1, _roleGuid);
        }

        whereStatement.AppendFormat(" AND {0} >= '{1}' AND {0} <= '{2}'",
                                    FS2TableString.LogFieldLogTime,
                                    _startDate,
                                    _endDate);

        if (additionalFilter != null && additionalFilter.Length > 0)
        {
            whereStatement.AppendFormat(" AND {0} ", additionalFilter);
        }

        string baseCmdString = string.Empty;

        switch (_viewType)
        {
        case ViewType.ByMonth:
            baseCmdString = string.Format("SELECT DATE_FORMAT(LogTime,'%Y-%m'),SUM(LogKey6),COUNT(*) FROM {0} {1} GROUP BY LogEvent",
                                          "{0}",
                                          whereStatement.ToString());

            int monthCount = 12 * (_endDate.Year - _startDate.Year) + (_endDate.Month - _startDate.Month) + 1;
            statisticValues = new double[monthCount];
            statisticTimes  = new double[monthCount];
            statisticCounts = new double[monthCount];

            for (int index = 0; index != statisticValues.Length; ++index)
            {
                DateTime tempDate = _startDate.AddMonths(index);
                statisticTimes[index] = new XDate(tempDate.Year, tempDate.Month, 1);
            }

            break;

        case ViewType.ByDay:
            baseCmdString = string.Format("SELECT DATE(LogTime), SUM(LogKey6), COUNT(*) FROM {0} {1} GROUP BY DATE(LogTime)",
                                          "{0}",
                                          whereStatement.ToString());

            TimeSpan span     = _endDate.Subtract(_startDate);
            int      dayCount = span.Days + 1;
            statisticValues = new double[dayCount];
            statisticTimes  = new double[dayCount];
            statisticCounts = new double[dayCount];
            for (int index = 0; index != statisticTimes.Length; ++index)
            {
                DateTime tempDate = _startDate.Date.AddDays(index);
                statisticTimes[index] = new XDate(tempDate);
            }
            break;

        case ViewType.ByHour:
            bQuitFlag = true;
            break;

        default:
            bQuitFlag = true;
            break;
        }

        if (bQuitFlag)
        {
            return(null);
        }

        string addTableCmdString;

        WebUtil.AddTableNameToCmd(CurrentUser.Id, server, baseCmdString, _startDate, _endDate, out addTableCmdString);
        if (addTableCmdString.Length == 0)
        {
            return(null);
        }

        SqlResult sqlResult = WebUtil.QueryGameServerDb(CurrentUser.Id, server, new SqlCommand(addTableCmdString));

        if (sqlResult != null && sqlResult.Success)
        {
            sqlResult.SetFieldType(new SqlDataType[] {
                SqlDataType.DateTime,
                SqlDataType.Int64,
                SqlDataType.Int32
            });

            object[] record = sqlResult.ReadRecord();

            switch (_viewType)
            {
            case ViewType.ByMonth:
                while (record != null)
                {
                    DateTime date  = (DateTime)record[0];
                    long     sum   = (long)record[1];
                    int      count = (int)record[2];

                    int monthIndex = 12 * (date.Year - _startDate.Year) + (date.Month - _startDate.Month);
                    statisticTimes[monthIndex]  = new XDate(date);
                    statisticValues[monthIndex] = sum;
                    statisticCounts[monthIndex] = count;

                    record = sqlResult.ReadRecord();
                }
                break;

            case ViewType.ByDay:
                while (record != null)
                {
                    DateTime date  = (DateTime)record[0];
                    long     sum   = (long)record[1];
                    int      count = (int)record[2];

                    TimeSpan indexSpan = date.Subtract(_startDate.Date);
                    statisticTimes[indexSpan.Days]  = new XDate(date);
                    statisticValues[indexSpan.Days] = sum;
                    statisticCounts[indexSpan.Days] = count;

                    record = sqlResult.ReadRecord();
                }
                break;
            }
        }
        else
        {
            return(null);
        }

        AnalyseResult result = new AnalyseResult();

        result.Values = statisticValues;
        result.Times  = statisticTimes;
        result.Counts = statisticCounts;

        return(result);
    }
Exemplo n.º 26
0
    protected void ButtonStatistic_Click(object sender, EventArgs e)
    {
        try
        {
            GameServer server = ServerDropDownList.SelectedGameServer;
            if (server == null)
            {
                LabelOpMsg.Text = string.Format(StringDef.MsgCannotBeNone, StringDef.GameServer);
                return;
            }

            if (!WebUtil.CheckPrivilege(server.SecurityObject, OpType.READ, Session))
            {
                Response.Redirect(WebConfig.PageNotEnoughPrivilege, true);
            }

            if (!server.IsConnected)
            {
                LabelOpMsg.Text = StringDef.NoConnectionAlert;
                return;
            }

            _roleName = TextBoxRoleName.Text.Trim();
            if (_roleName == null || _roleName.Length == 0)
            {
                LabelOpMsg.Text = string.Format(StringDef.MsgCannotBeNone, StringDef.RoleName);
                return;
            }

            //判断起始时间是否理
            _start = StartDate.SelectedDate;
            if (_start == DateTime.MinValue)
            {
                LabelOpMsg.Text = StringDef.ParameterInputError + StringDef.Colon + StringDef.Start;
                return;
            }
            _end = EndDate.SelectedDate;
            if (_end == DateTime.MinValue)
            {
                LabelOpMsg.Text = StringDef.ParameterInputError + StringDef.Colon + StringDef.EndTime;
                return;
            }
            if (_start >= _end)
            {
                LabelOpMsg.Text = StringDef.EndTimeError;
                return;
            }

            _createTime = DateTime.MinValue;

            string cmdText = string.Format("SELECT {0},{1} FROM {2} WHERE {3}='?'",
                                           FS2TableString.RolesfirstFieldGUID,
                                           FS2TableString.RolesfirstFieldCreateDate,
                                           FS2TableString.RolesfirstTableName,
                                           FS2TableString.RolesfirstFieldRoleName);

            SqlResult findRoleGuidResult = WebUtil.QueryGameServerDb(CurrentUser.Id, server, new SqlCommand(cmdText, _roleName));
            if (findRoleGuidResult != null && findRoleGuidResult.Success)
            {
                findRoleGuidResult.SetFieldType(new SqlDataType[] { SqlDataType.String, SqlDataType.DateTime });
                object[] record = findRoleGuidResult.ReadRecord();
                if (record != null)
                {
                    _roleGuid   = record[0] as string;
                    _createTime = (DateTime)record[1];
                }
            }

            if (_roleGuid == null)
            {
                LabelOpMsg.Text = string.Format(StringDef.RoleWithNameNotExist, _roleName);
                return;
            }

            ZedGraphWebExpStatistic.Visible = true;
        }
        catch (Exception ex)
        {
            LabelOpMsg.Text = ex.Message;
        }
    }
Exemplo n.º 27
0
    private void FileNode(int serverId, string nodeGuid)
    {
        GameServer server = TheAdminServer.GameServerManager.GetGameServer(serverId);

        if (server == null)
        {
            LabelOpMsg.Text = string.Format(StringDef.MsgCannotBeNone, StringDef.GameServer);
            return;
        }
        if (!server.IsConnected)
        {
            LabelOpMsg.Text = StringDef.NoConnectionAlert;
            return;
        }

        ArrayList paramList = new ArrayList();
        string    cmdText   = "SELECT NodeName,LeaderName,LayerId,NodeGUID,ChildCount FROM socialrelation WHERE {0}='?'";

        paramList.Add(nodeGuid);

        SqlCommand cmd    = new SqlCommand(string.Format(cmdText, FS2TableString.SocialrelationFieldNodeGUID), paramList.ToArray());
        SqlResult  result = WebUtil.QueryGameServerDb(CurrentUser.Id, server, cmd);

        if (result != null && result.Success)
        {
            result.SetFieldType(new SqlDataType[] {
                SqlDataType.String,
                SqlDataType.String,
                SqlDataType.Int32,
                SqlDataType.String,
                SqlDataType.Int32
            });

            object[]           record;
            SocialRelationInfo socialRelationInfo = null;
            while ((record = result.ReadRecord()) != null)
            {
                socialRelationInfo = new SocialRelationInfo();

                socialRelationInfo.NodeName   = record[0] as string;
                socialRelationInfo.LeaderName = record[1] as string;
                socialRelationInfo.LayerId    = (int)record[2];
                socialRelationInfo.NodeGUID   = record[3] as string;
                socialRelationInfo.ChildCount = (int)record[4];
            }
            if (socialRelationInfo != null)
            {
                switch (socialRelationInfo.LayerId)
                {
                case 2:
                    //氏族显示成员(Role)
                    LabelTitle.Text = string.Format("{0}[{1}] {2}:{3}", StringDef.Clan, socialRelationInfo.NodeName, StringDef.MemberCount, socialRelationInfo.ChildCount);
                    QueryRole(serverId, nodeGuid);
                    break;

                case 3:
                case 4:
                    //诸侯和国家
                    LabelTitle.Text = string.Format("{0}[{1}] {2}:{3}", socialRelationInfo.LayerId == 3 ? StringDef.Seigneur : StringDef.Nation, socialRelationInfo.NodeName, StringDef.MemberCount, socialRelationInfo.ChildCount);
                    QueryNode(serverId, nodeGuid);
                    break;
                }
            }
        }
    }
Exemplo n.º 28
0
    private FS2RoleDataInfo SetRoleData(GameServer server, object arg)
    {
        if (server != null)
        {
            SqlCommand cmd = null;
            if (arg.GetType() == typeof(int))
            {
                cmd = new SqlCommand(
                    string.Format("SELECT {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21},{24},{25} FROM {22} WHERE {23}='?'",
                                  FS2TableString.RolesfirstFieldId,
                                  FS2TableString.RolesfirstFieldTongGUID,
                                  FS2TableString.RolesfirstFieldAccountName,
                                  FS2TableString.RolesfirstFieldRoleName,
                                  FS2TableString.RolesfirstFieldRoleSex,
                                  FS2TableString.RolesfirstFieldRoleType,
                                  FS2TableString.RolesfirstFieldRoleLevel,
                                  FS2TableString.RolesfirstFieldMoney,
                                  FS2TableString.RolesfirstFieldMoneyInBox,
                                  FS2TableString.RolesfirstFieldPlayedTime,
                                  FS2TableString.RolesfirstFieldCreateDate,
                                  FS2TableString.RolesfirstFieldLastPlayingDate,
                                  FS2TableString.RolesfirstFieldLastPlayingIP,
                                  FS2TableString.RolesfirstFieldNoChatIn,
                                  FS2TableString.RolesfirstFieldNoLoginIn,
                                  FS2TableString.RolesfirstFieldUseRevivePosition,
                                  FS2TableString.RolesfirstFieldReviveID,
                                  FS2TableString.RolesfirstFieldReviveX,
                                  FS2TableString.RolesfirstFieldReviveY,
                                  FS2TableString.RolesfirstFieldEnterMapID,
                                  FS2TableString.RolesfirstFieldGUID,
                                  FS2TableString.RolesfirstFieldOnline,
                                  FS2TableString.RolesfirstTableName,
                                  FS2TableString.RolesfirstFieldId,
                                  FS2TableString.RolesfirstFieldSkillSeries,
                                  FS2TableString.RolesfirstFieldSpyLevel),
                    arg
                    );
            }
            else if (arg.GetType() == typeof(string))
            {
                cmd = new SqlCommand(
                    string.Format("SELECT {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21},{24},{25} FROM {22} WHERE {23}='?'",
                                  FS2TableString.RolesfirstFieldId,
                                  FS2TableString.RolesfirstFieldTongGUID,
                                  FS2TableString.RolesfirstFieldAccountName,
                                  FS2TableString.RolesfirstFieldRoleName,
                                  FS2TableString.RolesfirstFieldRoleSex,
                                  FS2TableString.RolesfirstFieldRoleType,
                                  FS2TableString.RolesfirstFieldRoleLevel,
                                  FS2TableString.RolesfirstFieldMoney,
                                  FS2TableString.RolesfirstFieldMoneyInBox,
                                  FS2TableString.RolesfirstFieldPlayedTime,
                                  FS2TableString.RolesfirstFieldCreateDate,
                                  FS2TableString.RolesfirstFieldLastPlayingDate,
                                  FS2TableString.RolesfirstFieldLastPlayingIP,
                                  FS2TableString.RolesfirstFieldNoChatIn,
                                  FS2TableString.RolesfirstFieldNoLoginIn,
                                  FS2TableString.RolesfirstFieldUseRevivePosition,
                                  FS2TableString.RolesfirstFieldReviveID,
                                  FS2TableString.RolesfirstFieldReviveX,
                                  FS2TableString.RolesfirstFieldReviveY,
                                  FS2TableString.RolesfirstFieldEnterMapID,
                                  FS2TableString.RolesfirstFieldGUID,
                                  FS2TableString.RolesfirstFieldOnline,
                                  FS2TableString.RolesfirstTableName,
                                  FS2TableString.RolesfirstFieldRoleName,
                                  FS2TableString.RolesfirstFieldSkillSeries,
                                  FS2TableString.RolesfirstFieldSpyLevel),
                    arg
                    );
            }

            if (!server.IsConnected)
            {
                LabelOpMsg.Text = StringDef.NoConnectionAlert;
                return(null);
            }
            SqlResult result = WebUtil.QueryGameServerDb(CurrentUser.Id, server, cmd);
            if (result != null)
            {
                if (result.Success)
                {
                    result.SetFieldType(
                        new SqlDataType[] {
                        SqlDataType.Int32,
                        SqlDataType.String,
                        SqlDataType.String,
                        SqlDataType.String,
                        SqlDataType.SByte,
                        SqlDataType.SByte,
                        SqlDataType.SByte,
                        SqlDataType.UInt32,
                        SqlDataType.UInt32,
                        SqlDataType.UInt32,
                        SqlDataType.DateTime,
                        SqlDataType.DateTime,
                        SqlDataType.Int64,
                        SqlDataType.Int32,
                        SqlDataType.Int32,
                        SqlDataType.Byte,
                        SqlDataType.Int32,
                        SqlDataType.Int32,
                        SqlDataType.Int32,
                        SqlDataType.Int32,
                        SqlDataType.String,
                        SqlDataType.Int32,
                        SqlDataType.Int32,
                        SqlDataType.Int32
                    });

                    object[] record = result.ReadRecord();
                    if (record != null)
                    {
                        FS2RoleDataInfo role = new FS2RoleDataInfo();
                        role.RoleId      = (int)record[0];
                        role.TongName    = (string)record[1];
                        role.AccountName = (string)record[2];
                        role.RoleName    = (string)record[3];
                        role.RoleSex     = (FS2RoleSex)(int.Parse(record[4].ToString()));
                        role.SkillSeries = (int)record[22];
                        switch ((SByte)record[5])
                        {
                        case (SByte)0:
                            if (role.SkillSeries == 0)
                            {
                                role.RoleType = FS2RoleType.Xuanfeng;
                            }
                            else if (role.SkillSeries == 1)
                            {
                                role.RoleType = FS2RoleType.Xingtian;
                            }
                            else
                            {
                                role.RoleType = FS2RoleType.Jiashi;
                            }
                            break;

                        case (SByte)1:
                            if (role.SkillSeries == 0)
                            {
                                role.RoleType = FS2RoleType.Zhenren;
                            }
                            else if (role.SkillSeries == 1)
                            {
                                role.RoleType = FS2RoleType.Tianshi;
                            }
                            else
                            {
                                role.RoleType = FS2RoleType.Daoshi;
                            }
                            break;

                        case (SByte)2:
                            if (role.SkillSeries == 0)
                            {
                                role.RoleType = FS2RoleType.Shoushi;
                            }
                            else if (role.SkillSeries == 1)
                            {
                                role.RoleType = FS2RoleType.Yishi;
                            }
                            else
                            {
                                role.RoleType = FS2RoleType.Yiren;
                            }
                            break;
                        }
                        role.RoleLevel         = int.Parse(record[6].ToString());
                        role.Money             = (uint)record[7];
                        role.MoneyInBox        = (uint)record[8];
                        role.PlayedTime        = (uint)record[9];
                        role.CreateDate        = (DateTime)record[10];
                        role.LastPlayingDate   = (DateTime)record[11];
                        role.LastPlayingIP     = new System.Net.IPAddress((Int64)record[12]);
                        role.NoChatIn          = (int)record[13];
                        role.NoLoginIn         = (int)record[14];
                        role.UseRevivePosition = (byte)record[15];
                        role.ReviveID          = (int)record[16];
                        role.ReviveX           = (int)record[17];
                        role.ReviveY           = (int)record[18];
                        role.EnterMapId        = (int)record[19];
                        role.RoleGuid          = (string)record[20];
                        role.Online            = (int)record[21];
                        role.SpyLevel          = (int)record[23];

                        //查询氏族名称
                        if (role.TongName != null && role.TongName.Length != 0)
                        {
                            SqlCommand tongNameCmd = new SqlCommand(string.Format("SELECT {0} FROM {1} WHERE {2}='?'",
                                                                                  FS2TableString.SocialrelationFieldNodeName, FS2TableString.SocialrelationTableName,
                                                                                  FS2TableString.SocialrelationFieldNodeGUID), role.TongName);
                            SqlResult tongNameResult = WebUtil.QueryGameServerDb(CurrentUser.Id, server, tongNameCmd);
                            if (tongNameResult != null && tongNameResult.Success)
                            {
                                tongNameResult.SetFieldType(new SqlDataType[] {
                                    SqlDataType.String
                                });
                                object[] tongNameRecord = tongNameResult.ReadRecord();
                                if (tongNameRecord != null && tongNameRecord.Length > 0)
                                {
                                    ViewState[WebConfig.ParamNodeGUID] = role.TongName;
                                    role.TongName = tongNameRecord[0] as string;
                                    //ViewState[WebConfig.ParamNodeGUID] 在role.TongName被改变后不变?!
                                }
                            }
                        }

                        return(role);
                    }
                }
            }
        }

        return(null);
    }
Exemplo n.º 29
0
    void Query(int offset)
    {
        GameServer server = ServerDropDownList.SelectedGameServer;

        if (server == null)
        {
            LabelOpMsg.Text = string.Format(StringDef.MsgCannotBeNone, StringDef.GameServer);
            return;
        }
        if (!server.IsConnected)
        {
            LabelOpMsg.Text = StringDef.NoConnectionAlert;
            return;
        }

        string roleName = TextBoxRole.Text.Trim();

        if (roleName == null || roleName.Length == 0)
        {
            LabelOpMsg.Text = string.Format(StringDef.MsgCannotBeNone, StringDef.RoleName);
            return;
        }

        string roleGuid = WebUtil.FindRoleGuidByName(CurrentUser.Id, server, roleName);

        if (roleGuid == null || roleGuid.Length == 0)
        {
            LabelOpMsg.Text = string.Format(StringDef.MsgNotExist, StringDef.RoleName);
            return;
        }

        StringBuilder whereStatement = new StringBuilder();

        whereStatement.AppendFormat(" WHERE PlayerGuid='{0}'", roleGuid);

        foreach (ListItem item in CheckBoxListPlayerAction.Items)
        {
            if (!item.Selected)
            {
                whereStatement.AppendFormat(" AND ActionId<>{0}", item.Value);
            }
        }

        if (ScriptCalendarStartTime.Selected)
        {
            DateTime startTime = ScriptCalendarStartTime.SelectedDate;
            whereStatement.AppendFormat(" AND RecordTime>='{0}'", startTime);
        }

        if (ScriptCalendarEndTime.Selected)
        {
            DateTime endTime = ScriptCalendarEndTime.SelectedDate;
            whereStatement.AppendFormat(" AND RecordTime<='{0}'", endTime);
        }

        StringBuilder orderByStatement = new StringBuilder();

        if (ListBoxOrderBy.SelectedIndex == 0)
        {
            orderByStatement.Append(" ORDER BY RecordTime");
        }
        else
        {
            orderByStatement.Append(" ORDER BY PlayerAction");
        }
        if (ListBoxOrderByType.SelectedIndex == 0)
        {
            orderByStatement.Append(" ASC");
        }
        else
        {
            orderByStatement.Append(" DESC");
        }

        SqlCommand cmd = new SqlCommand("SELECT Id,RecordTime,PlayerAction,ActionDesc FROM playeraction" + whereStatement.ToString() + orderByStatement.ToString());

        if (!server.IsConnected)
        {
            LabelOpMsg.Text = StringDef.NoConnectionAlert;
            return;
        }
        SqlResult result = WebUtil.QueryGameServerDb(CurrentUser.Id, server, cmd);

        ArrayList c2sNetMsgInfoList = new ArrayList();

        if (result != null && result.Success)
        {
            result.SetFieldType(new SqlDataType[] { SqlDataType.Int32, SqlDataType.DateTime, SqlDataType.Int32, SqlDataType.String });
            object[] record = null;
            while ((record = result.ReadRecord()) != null)
            {
                PlayerActionInfo info = new PlayerActionInfo();
                info.Id         = (int)record[0];
                info.RecordTime = (DateTime)record[1];
                info.Action     = (int)record[2];
                info.Desc       = record[3] as string;
                c2sNetMsgInfoList.Add(info);
            }

            if (c2sNetMsgInfoList.Count == 0)
            {
                LabelOpMsg.Text = StringDef.NoMatchingRecord;
                return;
            }
            else
            {
                CreateTableC2SNetMsg(c2sNetMsgInfoList);
                PanelResult.Visible = true;
            }
        }
        else
        {
            if (result == null)
            {
                LabelOpMsg.Text = StringDef.QueryTimeOut;
            }
            else
            {
                LabelOpMsg.Text = StringDef.OperationFail;
            }
        }
    }
Exemplo n.º 30
0
    void Query(int offset)
    {
        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     tempParamList   = new ArrayList();
            ArrayList     paramList       = new ArrayList();
            StringBuilder searchCondition = new StringBuilder();

            searchCondition.Append(string.Format("WHERE LogEvent='{0}'", LogEvent.NpcDropStatistic));

            string npcId = TextBoxNpcId.Text.Trim();
            if (npcId.Length == 0)
            {
                LabelOpMsg.Text = string.Format(StringDef.MsgCannotBeNone, StringDef.NpcID);
                return;
            }
            searchCondition.Append(string.Format(" AND {0}='{1}' ", FS2TableString.LogFieldLogKey1, npcId));

            _start = StartDate.SelectedDate;
            if (_start == DateTime.MinValue)
            {
                LabelOpMsg.Text = StringDef.ParameterInputError;
                return;
            }
            _end = EndDate.SelectedDate;
            if (_end == DateTime.MinValue)
            {
                LabelOpMsg.Text = StringDef.ParameterInputError;
                return;
            }
            searchCondition.Append(string.Format(" 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 LogKey2,SUM(LogKey6) AS SubSum FROM {0} {1} GROUP BY LogKey2",
                                                 "{0}", searchCondition.ToString());
            string addTableCmdString;
            WebUtil.AddTableNameToCmd(CurrentUser.Id, server, baseCmdString, tempParamList, _start, _end, out addTableCmdString, out paramList);

            if (addTableCmdString.Length == 0)
            {
                return;
            }

            int    limitCount     = _recordPerPage;
            string limitStatement = string.Format(" LIMIT {0},{1}", offset, limitCount);

            string cmdString = "SELECT LogKey2,SUM(SubSum) AS Total FROM ({0}) AS A GROUP BY LogKey2 ORDER BY Total DESC {1}";

            SqlCommand cmd    = new SqlCommand(string.Format(cmdString, addTableCmdString, limitStatement), paramList.ToArray());
            SqlResult  result = WebUtil.QueryGameServerDb(CurrentUser.Id, server, cmd);
            if (result != null && result.Success)
            {
                result.SetFieldType(new SqlDataType[] {
                    SqlDataType.String,
                    SqlDataType.UInt32
                });
                object[]  record = null;
                ArrayList infos  = new ArrayList();
                while ((record = result.ReadRecord()) != null)
                {
                    NpcDropItem info = new NpcDropItem();
                    info.itemTemplateId = record[0] as string;
                    info.num            = (UInt32)record[1];
                    infos.Add(info);
                }

                //²éѯ×ÜÊý
                uint   total = 0;
                string baseCmdTotalString = string.Format("SELECT SUM(LogKey6) AS SubSum FROM {0} {1}",
                                                          "{0}", searchCondition.ToString());
                string addTableCmdTotalString;
                WebUtil.AddTableNameToCmd(CurrentUser.Id, server, baseCmdTotalString, _start, _end, out addTableCmdTotalString);

                if (addTableCmdTotalString.Length != 0)
                {
                    string     cmdTotalString = "SELECT SUM(SubSum) FROM ({0}) AS A";
                    SqlCommand sqlTotal       = new SqlCommand(string.Format(cmdTotalString, addTableCmdTotalString), paramList.ToArray());
                    SqlResult  sqlTotalResult = WebUtil.QueryGameServerDb(CurrentUser.Id, server, sqlTotal);

                    if (sqlTotalResult != null && sqlTotalResult.Success)
                    {
                        sqlTotalResult.SetFieldType(new SqlDataType[] {
                            SqlDataType.UInt32
                        });
                        record = sqlTotalResult.ReadRecord();
                        if (record != null && record[0] != null)
                        {
                            total = (uint)record[0];
                        }
                    }
                }

                ViewState[WebConfig.SessionQueryLogOffset] = offset;

                ButtonPreviousPage.Enabled = (offset > 0);
                ButtonFirstPage.Enabled    = (offset > 0);
                ButtonNextPage.Enabled     = (infos.Count >= limitCount);

                if (infos.Count != 0)
                {
                    PanelResult.Visible = true;
                    CreateSearchResultList((NpcDropItem[])infos.ToArray(typeof(NpcDropItem)), total);
                    LabelResult.Text = string.Format(StringDef.LabelStatisticResult, server.Group.Name,
                                                     server.Name, string.Empty, StringDef.NpcDropItem);
                }
                else
                {
                    PanelResult.Visible = false;
                    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;
        }
    }