public SearchException(string message, Exception inner, SearchItemInfo searchItem) : base(message, inner) { m_SearchItem = searchItem; }
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(); switch (ListBoxWay.SelectedValue) { case "All": searchCondition.Append(string.Format("WHERE (LogEvent='{0}' OR LogEvent='{1}')", LogEvent.BuyStatistic, LogEvent.NpcDropStatistic)); break; case "Buy": searchCondition.Append(string.Format("WHERE LogEvent='{0}'", LogEvent.BuyStatistic)); break; case "Drop": searchCondition.Append(string.Format("WHERE LogEvent='{0}'", LogEvent.NpcDropStatistic)); break; } string itemId = TextBoxItemId.Text.Trim(); if (itemId == null || itemId.Length == 0) { LabelOpMsg.Text = string.Format(StringDef.MsgCannotBeNone, StringDef.ItemID); return; } searchCondition.Append(string.Format(" AND {0}='{1}' ", FS2TableString.LogFieldLogKey2, itemId)); _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, _end)); string baseCmdString = string.Format("SELECT LogKey1,LogKey2,LogEvent,SUM(LogKey6) AS SubSum FROM {0} {1} GROUP BY LogKey1", "{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 LogKey1,LogKey2,LogEvent,SUM(SubSum) AS Total FROM ({0}) AS A GROUP BY LogKey1 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.String, SqlDataType.Int32, SqlDataType.Int32 }); object[] record = null; ArrayList infos = new ArrayList(); while ((record = result.ReadRecord()) != null) { SearchItemInfo info = new SearchItemInfo(); info.sourceId = record[0] as string; info.id = record[1] as string; info.way = (int)record[2]; info.count = (int)record[3]; 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, tempParamList, _start, _end, out addTableCmdTotalString, out paramList); 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((SearchItemInfo[])infos.ToArray(typeof(SearchItemInfo)), total); LabelResult.Text = string.Format(StringDef.LabelStatisticResult, server.Group.Name, server.Name, StringDef.Item, StringDef.Drop); } 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; } }
/// <summary> /// Gets the search items for the module's articles. /// </summary> /// <returns>The collection of search items for the <see cref="Module"/>'s articles</returns> private IEnumerable <SearchItemInfo> GetSearchItemsImpl() { var articlesTable = Article.GetArticlesByModuleId(this.Module.ModuleID, true); foreach (DataRow row in articlesTable.Rows) { var searchedContent = new StringBuilder(8192); // article name string name = HtmlUtils.Clean(row["Name"].ToString().Trim(), false); if (Engage.Utility.HasValue(name)) { searchedContent.AppendFormat("{0}{1}", name, " "); } else { // do we bother with the rest? continue; } // article text string articleText = row["ArticleText"].ToString().Trim(); if (Engage.Utility.HasValue(articleText)) { searchedContent.AppendFormat("{0}{1}", articleText, " "); } // article description string description = row["Description"].ToString().Trim(); if (Engage.Utility.HasValue(description)) { searchedContent.AppendFormat("{0}{1}", description, " "); } // article metakeyword string keyword = row["MetaKeywords"].ToString().Trim(); if (Engage.Utility.HasValue(keyword)) { searchedContent.AppendFormat("{0}{1}", keyword, " "); } // article metadescription string metaDescription = row["MetaDescription"].ToString().Trim(); if (Engage.Utility.HasValue(metaDescription)) { searchedContent.AppendFormat("{0}{1}", metaDescription, " "); } // article metatitle string metaTitle = row["MetaTitle"].ToString().Trim(); if (Engage.Utility.HasValue(metaTitle)) { searchedContent.AppendFormat("{0}{1}", metaTitle, " "); } string itemId = row["ItemId"].ToString(); var item = new SearchItemInfo { Title = name, Description = HtmlUtils.Clean(description, false), Author = Convert.ToInt32(row["AuthorUserId"], CultureInfo.InvariantCulture), PubDate = Convert.ToDateTime(row["LastUpdated"], CultureInfo.InvariantCulture), ModuleId = this.Module.ModuleID, SearchKey = "Article-" + itemId, Content = HtmlUtils.StripWhiteSpace(HtmlUtils.Clean(searchedContent.ToString(), false), true), }; if (this.SetGuid) { item.GUID = "itemid=" + itemId; } if (ModuleBase.AllowVenexusSearchForPortal(this.Module.PortalID)) { string indexUrl = UrlGenerator.GetItemLinkUrl( Convert.ToInt32(itemId, CultureInfo.InvariantCulture), Utility.GetPortalSettings(this.Module.PortalID), this.Module.TabID, this.Module.ModuleID); // UpdateVenexusBraindump(IDbTransaction trans, string indexTitle, string indexContent, string indexWashedContent) DataProvider.Instance().UpdateVenexusBraindump( Convert.ToInt32(itemId, CultureInfo.InvariantCulture), name, articleText, HtmlUtils.Clean(articleText, false), this.Module.PortalID, indexUrl); } yield return(item); } }
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(); switch (ListBoxWay.SelectedValue) { case "All": searchCondition.Append(string.Format("WHERE (LogEvent='{0}' OR LogEvent='{1}')", LogEvent.BuyStatistic, LogEvent.NpcDropStatistic)); break; case "Buy": searchCondition.Append(string.Format("WHERE LogEvent='{0}'", LogEvent.BuyStatistic)); break; case "Drop": searchCondition.Append(string.Format("WHERE LogEvent='{0}'", LogEvent.NpcDropStatistic)); break; } string itemId = TextBoxItemId.Text.Trim(); if (itemId == null || itemId.Length == 0) { LabelOpMsg.Text = string.Format(StringDef.MsgCannotBeNone, StringDef.ItemID); return; } searchCondition.Append(string.Format(" AND {0}='{1}' ", FS2TableString.LogFieldLogKey2, itemId)); _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, _end)); string baseCmdString = string.Format("SELECT LogKey1,LogKey2,LogEvent,SUM(LogKey6) AS SubSum FROM {0} {1} GROUP BY LogKey1", "{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 LogKey1,LogKey2,LogEvent,SUM(SubSum) AS Total FROM ({0}) AS A GROUP BY LogKey1 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.String, SqlDataType.Int32, SqlDataType.Int32 }); object[] record = null; ArrayList infos = new ArrayList(); while ((record = result.ReadRecord()) != null) { SearchItemInfo info = new SearchItemInfo(); info.sourceId = record[0] as string; info.id = record[1] as string; info.way = (int)record[2]; info.count = (int)record[3]; 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, tempParamList, _start, _end, out addTableCmdTotalString, out paramList); 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((SearchItemInfo[])infos.ToArray(typeof(SearchItemInfo)), total); LabelResult.Text = string.Format(StringDef.LabelStatisticResult, server.Group.Name, server.Name, StringDef.Item, StringDef.Drop); } 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; } }
bool CreateSearchResultList(SearchItemInfo[] infos, uint totalNum) { if (infos != null) { foreach (SearchItemInfo info in infos) { TableRow row = new TableRow(); TableCell cell = new TableCell(); FS2ItemData item = FS2GameDataManager.TheInstance.GetItemData(info.id); if (item != null) { string colorStr = "Black"; switch (item.Quality) { case FS2ItemQuality.White: colorStr = "Black"; break; case FS2ItemQuality.Blue: colorStr = "#3165FF"; break; case FS2ItemQuality.Green: colorStr = "#00FB00"; break; case FS2ItemQuality.Yellow: colorStr = "Yellow"; break; case FS2ItemQuality.Orange: colorStr = "#F8952C"; break; } cell.Text = string.Format("<span onmouseover='{0}' style='color:{1}'>{2}</span>", string.Format("updateRoleItemInfo(\"{0}\")", item.TemplateId), colorStr, item.Name); } else cell.Text = info.id; row.Cells.Add(cell); cell = new TableCell(); switch (info.way) { case LogEvent.BuyStatistic: cell.Text = StringDef.NotAvailable; break; case LogEvent.NpcDropStatistic: FS2NpcData npc = FS2GameDataManager.TheInstance.GetNpcData(int.Parse(info.sourceId)); if (npc != null) cell.Text = string.Format("{0}[{1}]", npc.Name, npc.TemplateId); else cell.Text = StringDef.NotAvailable; break; } row.Cells.Add(cell); cell = new TableCell(); switch (info.way) { case LogEvent.BuyStatistic: cell.Text = StringDef.Buy; break; case LogEvent.NpcDropStatistic: cell.Text = StringDef.Drop; break; } row.Cells.Add(cell); cell = new TableCell(); cell.Text = info.count.ToString(); row.Cells.Add(cell); cell = new TableCell(); if (totalNum != 0) { cell.Text = Decimal.Round((decimal)info.count / totalNum * 100, 3).ToString() + "%"; } else { cell.Text = info.count.ToString(); } row.Cells.Add(cell); TableSearchItem.Rows.Add(row); } TableRow rowHead = new TableRow(); rowHead.Font.Bold = true; TableCell cellHead = new TableCell(); cellHead.ColumnSpan = 5; cellHead.Text = string.Format("{0} : {1}", StringDef.Total, totalNum); rowHead.Cells.Add(cellHead); TableSearchItem.Rows.Add(rowHead); return true; } return false; }
private static void SearchArticleIndex(DataTable dt, SearchItemInfoCollection items, ModuleInfo modInfo) { for (int i = 0; i < dt.Rows.Count; i++) { DataRow row = dt.Rows[i]; var searchedContent = new StringBuilder(8192); //article name string name = HtmlUtils.Clean(row["Name"].ToString().Trim(), false); if (Utility.HasValue(name)) { searchedContent.AppendFormat("{0}{1}", name, " "); } else { //do we bother with the rest? continue; } //article text string articleText = row["ArticleText"].ToString().Trim(); if (Utility.HasValue(articleText)) { searchedContent.AppendFormat("{0}{1}", articleText, " "); } //article description string description = row["Description"].ToString().Trim(); if (Utility.HasValue(description)) { searchedContent.AppendFormat("{0}{1}", description, " "); } //article metakeyword string keyword = row["MetaKeywords"].ToString().Trim(); if (Utility.HasValue(keyword)) { searchedContent.AppendFormat("{0}{1}", keyword, " "); } //article metadescription string metaDescription = row["MetaDescription"].ToString().Trim(); if (Utility.HasValue(metaDescription)) { searchedContent.AppendFormat("{0}{1}", metaDescription, " "); } //article metatitle string metaTitle = row["MetaTitle"].ToString().Trim(); if (Utility.HasValue(metaTitle)) { searchedContent.AppendFormat("{0}{1}", metaTitle, " "); } string itemId = row["ItemId"].ToString(); var item = new SearchItemInfo { Title = name, Description = HtmlUtils.Clean(description, false), Author = Convert.ToInt32(row["AuthorUserId"], CultureInfo.InvariantCulture), PubDate = Convert.ToDateTime(row["LastUpdated"], CultureInfo.InvariantCulture), ModuleId = modInfo.ModuleID, SearchKey = "Article-" + itemId, Content = HtmlUtils.StripWhiteSpace( HtmlUtils.Clean(searchedContent.ToString(), false), true), GUID = "itemid=" + itemId }; items.Add(item); //Check if the Portal is setup to enable venexus indexing if (ModuleBase.AllowVenexusSearchForPortal(modInfo.PortalID)) { string indexUrl = Utility.GetItemLinkUrl(Convert.ToInt32(itemId, CultureInfo.InvariantCulture), modInfo.PortalID, modInfo.TabID, modInfo.ModuleID); //UpdateVenexusBraindump(IDbTransaction trans, string indexTitle, string indexContent, string indexWashedContent) Data.DataProvider.Instance().UpdateVenexusBraindump(Convert.ToInt32(itemId, CultureInfo.InvariantCulture), name, articleText, HtmlUtils.Clean(articleText, false), modInfo.PortalID, indexUrl); } //} } }