public virtual StockNewCollection GetStockNewListBySource(int sourceId, StockNewColumns orderBy, string orderDirection, int page, int pageSize, out int totalRecords) { try { Database database = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = database.GetStoredProcCommand("spStockNewsGetListBySource"); database.AddInParameter(dbCommand, "@SourceId", DbType.Int32, sourceId); database.AddInParameter(dbCommand, "@OrderBy", DbType.AnsiString, orderBy.ToString()); database.AddInParameter(dbCommand, "@OrderDirection", DbType.AnsiString, orderDirection.ToString()); database.AddInParameter(dbCommand, "@Page", DbType.Int32, page); database.AddInParameter(dbCommand, "@PageSize", DbType.Int32, pageSize); database.AddOutParameter(dbCommand, "@TotalRecords", DbType.Int32, 4); StockNewCollection stockNewCollection = new StockNewCollection(); using (IDataReader reader = database.ExecuteReader(dbCommand)) { while (reader.Read()) { StockNew stockNew = CreateStockNewFromReader(reader); stockNewCollection.Add(stockNew); } reader.Close(); } totalRecords = (int)database.GetParameterValue(dbCommand, "@TotalRecords"); return stockNewCollection; } catch (Exception ex) { // log this exception log4net.Util.LogLog.Error(ex.Message, ex); // wrap it and rethrow throw new ApplicationException(SR.DataAccessGetStockNewListException, ex); } }
protected void LoadNewsList() { Int32 totalRows; stockNewCollection = StockNewService.GetStockNewList(linkId, StockNewColumns.NewsId, "DESC", this.topPaging.CurrentIndex, ApplicationHelper.PageSize, out totalRows); newsRepeater.DataSource = stockNewCollection; newsRepeater.DataBind(); this.topPaging.PageSize = this.bottomPaging.PageSize = ApplicationHelper.PageSize; this.topPaging.ItemCount = this.bottomPaging.ItemCount = totalRows; }
private void ApprovedNewStockList() { Int32 totalRows; string stockNewItemStringId; stockNewCollection = StockNewService.GetStockNewList(linkId, StockNewColumns.NewsId, "DESC", this.topPaging.CurrentIndex, ApplicationHelper.PageSize, out totalRows); foreach (StockNew stockNewItem in stockNewCollection) { stockNewItemStringId = Request.Form["selectedItem_" + Convert.ToString(stockNewItem.NewsId)]; if (stockNewItemStringId != null) { selectedItems = selectedItems + "," + stockNewItemStringId; } } selectedItems = selectedItems.Substring(1,(selectedItems.Length)-1); string selectedItemsGroupNews = Request.Form["selectedGroupNewsItem"]; int pos, symbolId; Int32 stockId; Int32 newGroupId; if (selectedItems == string.Empty || selectedItems == null) return; foreach (string selectedItemId in selectedItems.Split(',')) { stockId = Convert.ToInt32(selectedItemId); newGroupId = Convert.ToInt32(Request.Form["newsCategorySelect_" + stockId.ToString()]); StockNew stockNew = StockNewService.GetStockNew(stockId); stock_New stockNewDestination = new stock_New(); stock_NewsGroup stock_NewsGroupDestination = new stock_NewsGroup(); stock_NewsGroup stock_NewsGroupHome = new stock_NewsGroup(); stockNewDestination.NewsTitle = stockNew.NewsTitle; stockNewDestination.NewsDescription = stockNew.NewsDescription; stockNewDestination.NewsContent = stockNew.NewsContent; stockNewDestination.NewsDate = DateTime.Now.AddHours(-7); stockNewDestination.IsApproved = true; stockNewDestination.LanguageID = 2;// should be dymamic stockNewDestination.NewsSource = stockNew.NewsSource; pos = stockNewDestination.NewsTitle.Trim().IndexOf(':'); symbolId = 0; if (pos > 0) symbolId = GetStockSymbolId(stockNewDestination.NewsTitle.Substring(0, pos)); if (symbolId > 0) { stockNew.ShareSymbol = stockNewDestination.NewsTitle.Substring(0, pos); } stockNewDestination.SymbolID = (symbolId > 0 ? symbolId : new int()); stock_NewService.Createstock_New(stockNewDestination); stock_NewsGroupDestination.NewsID = stockNewDestination.NewsID; stock_NewsGroupDestination.NewsGroup = newGroupId; stock_NewsGroupService.Createstock_NewsGroup(stock_NewsGroupDestination); if (selectedItemsGroupNews != null) { if (selectedItemsGroupNews.IndexOf(selectedItemId) >= 0) { stock_NewsGroupHome.NewsID = stockNewDestination.NewsID; stock_NewsGroupHome.NewsGroup = 5; stock_NewsGroupService.Createstock_NewsGroup(stock_NewsGroupHome); } } StoredToApprovedNews(stockNew); StockNewService.DeleteStockNew(stockId); } }