public virtual stock_NewsGroup Createstock_NewsGroupFromReader(IDataReader reader)
 {
     stock_NewsGroup item = new stock_NewsGroup();
     try
     {
         if (!reader.IsDBNull(reader.GetOrdinal("ID"))) item.ID = (int)reader["ID"];
         if (!reader.IsDBNull(reader.GetOrdinal("NewsID"))) item.NewsID = (int)reader["NewsID"];
         if (!reader.IsDBNull(reader.GetOrdinal("NewsGroup"))) item.NewsGroup = (int)reader["NewsGroup"];
     }
     catch (Exception ex)
     {
         // log this exception
         log4net.Util.LogLog.Error(ex.Message, ex);
         // wrap it and rethrow
         throw new ApplicationException(SR.DataAccessCreatestock_NewsGroupFromReaderException, ex);
     }
     return item;
 }
 public static void Updatestock_NewsGroup(stock_NewsGroup stock_NewsGroup)
 {            
     try
     {
         stock_NewsGroupDAO stock_NewsGroupDAO = new stock_NewsGroupDAO();
         stock_NewsGroupDAO.Updatestock_NewsGroup(stock_NewsGroup);
     }
     catch (ApplicationException)
     {
         throw;
     }
     catch (Exception ex)
     {
         // log this exception
         log4net.Util.LogLog.Error(ex.Message, ex);
         // wrap it and rethrow
         throw new ApplicationException(SR.BusinessUpdatestock_NewsGroupException, ex);
     }
 }        
 public virtual void Updatestock_NewsGroup(stock_NewsGroup stock_NewsGroup)
 {
     try
     {
         //Database database = DatabaseFactory.CreateDatabase();
         Database database = DatabaseFactory.CreateDatabase("DestinationConnection");
         DbCommand dbCommand = database.GetStoredProcCommand("spstock_NewsGroupsUpdate");            
         
         database.AddInParameter(dbCommand, "@ID", DbType.Int32, stock_NewsGroup.ID);
         database.AddInParameter(dbCommand, "@NewsID", DbType.Int32, stock_NewsGroup.NewsID);
         database.AddInParameter(dbCommand, "@NewsGroup", DbType.Int32, stock_NewsGroup.NewsGroup);
         
         database.ExecuteNonQuery(dbCommand);
     }
     catch (Exception ex)
     {
         // log this exception
         log4net.Util.LogLog.Error(ex.Message, ex);
         // wrap it and rethrow
         throw new ApplicationException(SR.DataAccessUpdatestock_NewsGroupException, ex);
     }
 }
        public bool FeedItemIntoWebSite(Int16 sourceId)
        {
            bool returnVal = true;            
            StockNewCollection stockNewCollection;
            DestinationEntities.stock_New stockNewDestination = new DestinationEntities.stock_New();
            DestinationEntities.stock_NewsGroup stock_NewsGroupDestination = new DestinationEntities.stock_NewsGroup();
            DestinationEntities.stock_NewsGroup stock_NewsGroupHome = new DestinationEntities.stock_NewsGroup();

            Int32 totalRows = 0;
            int pos, symbolId;            
            Int32 newGroupId;
            newGroupId = 2; //nhom tin cong bo thong tin
            try
            {
                stockNewCollection = StockNewService.GetStockNewListBySource(sourceId, StockNewColumns.NewsId, "ASC", 1, 10, out totalRows);
                foreach (StockNew stockNew in stockNewCollection)
                {
                    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());
                    DestinationBusiness.stock_NewService.Createstock_New(stockNewDestination);

                    stock_NewsGroupDestination.NewsID = stockNewDestination.NewsID;
                    stock_NewsGroupDestination.NewsGroup = newGroupId;
                    DestinationBusiness.stock_NewsGroupService.Createstock_NewsGroup(stock_NewsGroupDestination);

                    stock_NewsGroupHome.NewsID = stockNewDestination.NewsID;
                    stock_NewsGroupHome.NewsGroup = 5;
                    DestinationBusiness.stock_NewsGroupService.Createstock_NewsGroup(stock_NewsGroupHome);
                    Ultility.Error("stock id: " + stockNew.NewsId.ToString());
                    StoredToApprovedNews(stockNew);
                    StockNewService.DeleteStockNew((int)stockNew.NewsId);
                }
            }
            catch (Exception ex)
            {
                Ultility.Error(ex.InnerException);
                returnVal = false;
            }
            return returnVal;
        }
    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);      
        }
    }
    private void ApprovedNewStockList()
    {
        string selectedItems = Request.Form["selectedItem"];
        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();

            stockNewDestination.NewsTitle = stockNew.NewsTitle;
            stockNewDestination.NewsDescription = stockNew.NewsDescription;
            stockNewDestination.NewsContent = stockNew.NewsContent;
            stockNewDestination.NewsDate = stockNew.NewsDate;
            stockNewDestination.IsApproved = false;
            stockNewDestination.LanguageID = 2;// should be dymamic 
            stockNewDestination.NewsSource = stockNew.NewsSource;
            pos = stockNewDestination.NewsTitle.IndexOf(':');
            symbolId = 0;
            if (linkId == 2)
            {
                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);
            StoredToApprovedNews(stockNew);
            StockNewService.DeleteStockNew(stockId);
        }
    }