Beispiel #1
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;
        }
    }
Beispiel #2
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;
        }
    }