public async Task UpdateNewsArticlesWordsWeights()
        {
            var docs = await NewsCollection.Find(_ => _.WW == null).SortByDescending(_ => _.Date).ToListAsync();

            foreach (var n in docs)
            {
                logger.Info($"Setting words weights for {n.Guid}");

                var words = await GetArticleWords(n.Header + " " + n.Text);

                var ww = new List <ArticleWordWeight>();

                foreach (var g in words.OrderBy(_ => _.Word).GroupBy(_ => _.Word))
                {
                    var w = g.First();
                    w.Weight = g.Count() / (double)words.Length;
                    ww.Add(w);
                }

                var filter = Builders <NewsDbModel> .Filter.Eq(_ => _.Guid, n.Guid);

                var update = Builders <NewsDbModel> .Update.Set(_ => _.WW, ww);

                await NewsCollection.UpdateOneAsync(filter, update);
            }
        }
Exemplo n.º 2
0
        public void Update_SetNewValues_ReturnUpdatedNews(int newsId, string title,
                                                          string text, bool allowComments)
        {
            // Arrange
            var news = new News
            {
                Id            = newsId,
                Title         = title,
                Text          = text,
                AllowComments = allowComments
            };
            var newsCollection = new NewsCollection().Data;

            Use <INewsProvider>()
            .Setup(c => c.GetAll())
            .Returns(newsCollection);

            // Act
            var actualResult = Sub.Update(news);

            // Assert
            Use <INewsProvider>().Verify(c => c.Update(It.IsAny <News>()), Times.Once);
            Assert.AreEqual(newsId, actualResult.Id);
            Assert.AreEqual(title, actualResult.Title);
            Assert.AreEqual(text, actualResult.Text);
            Assert.AreEqual(allowComments, actualResult.AllowComments);
        }
        public async Task FillNewsTags()
        {
            var weights = (await WwCollection.Find(_ => true).ToListAsync()).ToDictionary(_ => _.Word, __ => __.Weight);

            foreach (var n in await NewsCollection.Find(_ => _.Tags == null && _.WW != null).ToListAsync())
            {
                var articleWeights = n.WW
                                     .Select(_ => new ArticleWordWeight
                {
                    Weight = _.Weight * GetWordWeight(weights, _.Word),
                    Word   = _.Word,
                    POS    = _.POS,
                    AddTps = _.AddTps
                }).Where(_ => _.POS == "S" && _.Word.Length > 2)
                                     .OrderByDescending(_ => _.Weight);
                var simpleNouns = articleWeights.Where(_ => _.AddTps == "None").Take(5);
                var famnames    = articleWeights.Where(_ => _.AddTps == "FAMN").Take(5);
                var geos        = articleWeights.Where(_ => _.AddTps == "GEO").Take(5);
                var tags        = new List <string>(simpleNouns.Concat(famnames).Concat(geos).Select(_ => _.Word).MakeUnique());

                tags.Shuffle();

                var filter = Builders <NewsDbModel> .Filter.Eq(_ => _.Guid, n.Guid);

                var update = Builders <NewsDbModel> .Update.Set(_ => _.Tags, tags);

                await NewsCollection.UpdateOneAsync(filter, update);

                logger.Info($"Added tags for {n.Guid}");
            }
        }
Exemplo n.º 4
0
        private async void GetNewsForOrg()
        {
            //ArticleCollection.Clear();
            HttpClient client = new HttpClient();
            var        uri    = new Uri(
                string.Format(
                    $"https://newsapi.org/v2/top-headlines?sources={NewsOrgEnteredByUser}&apiKey=b49235adad6d4e0392cfa2970d4de6f4"));
            var response = await client.GetAsync(uri);

            NewsArticle newsData = null;

            if (response.IsSuccessStatusCode)
            {
                var content = await response.Content.ReadAsStringAsync();

                newsData = NewsArticle.FromJson(content);



                for (int i = 0; i < newsData.Articles.Count; i++)
                {
                    ArticleCollection.Add(newsData.Articles[i]);
                }
            }
            NewsCollection.Add(newsData);
        }
Exemplo n.º 5
0
 public NewsCollection FetchAll()
 {
     NewsCollection coll = new NewsCollection();
     Query qry = new Query(News.Schema);
     coll.LoadAndCloseReader(qry.ExecuteReader());
     return coll;
 }
Exemplo n.º 6
0
        // load items from database with pagination
        public async void LoadFromDatabaseAsync()
        {
            try
            {
                Debug.WriteLine("{0} {1}", Skip, Take);
                IsBusy = true;
                var collection = await NewsManager.DefaultManager.GetNewsFromCategoryAsync(Category, Skip, Take);

                foreach (var item in collection)
                {
                    if (User.CurrentUser.Bookmarks.Contains(item))
                    {
                        item.IsBookmarkedByUser = true;
                    }
                    NewsCollection.Add(item);
                }
                Skip += Take;
            } catch (Exception e)
            {
                Debug.WriteLine(e);
            } finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 7
0
 private void BindingData()
 {
     try
     {
         NewsCollection col = null;
         col = this.LoadData();
         if (col == null)
         {
             col                = new NewsCollection();
             lblcount.Text      = "Có 0" + " record";
             rptData.DataSource = col;
             rptData.DataBind();
         }
         else
         {
             lblcount.Text          = "Có " + col.Count.ToString() + " record";
             lblcount.ForeColor     = System.Drawing.Color.Blue;
             anpPager.RecordCount   = col.Count;
             anpPager.PageSize      = Convert.ToInt32(ddlPageSize.SelectedValue);
             anpPager.ShowFirstLast = false;
             col = this.GetSubData(col, anpPager.StartRecordIndex - 1, anpPager.EndRecordIndex);
             rptData.DataSource = col;
             rptData.DataBind();
         }
     }
     catch (Exception ex)
     {
         Global.WriteLogError("BindingData()" + ex);
     }
 }
Exemplo n.º 8
0
        void BindData()
        {
            NewsCollection newsCollection = NewsManager.GetAllNews(0);

            gvNews.DataSource = newsCollection;
            gvNews.DataBind();
        }
        public async Task UpdateWordsWeightsDictionary()
        {
            logger.Info("Updating global words weights dictionary.");

            await newsDatabase.DropCollectionAsync(NEWS_WORD_WEIGHTS_COLLECTION_NAME);

            Dictionary <string, double> wordWeights = new Dictionary <string, double>();

            var docs = await NewsCollection.Find(_ => _.WW != null).SortByDescending(_ => _.Date).ToListAsync();

            foreach (var n in docs)
            {
                FillWordWeightsDictionary(wordWeights, n.WW.Select(_ => _.Word).ToArray());
            }

            foreach (var k in wordWeights.Keys.ToList())
            {
                wordWeights[k] = Math.Log10((double)docs.Count / wordWeights[k]);
            }

            var resultDict = wordWeights.OrderBy(_ => _.Value).Select(_ => new WordWeightDbModel {
                Word = _.Key, Weight = _.Value
            }).ToList();

            await WwCollection.InsertManyAsync(resultDict);

            logger.Info($"Number of: words {resultDict.Count}, docs {docs.Count}");
        }
Exemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ModuleType = q("module").Trim();
            Admin_Load("", "html", ModuleType);
            this.ThumbsSize.Items.Clear();
            ListItem  li;
            DataTable dtThumbs = new JumboECMS.DAL.Normal_ThumbsDAL().GetDataTable(ModuleType);

            for (int i = 0; i < dtThumbs.Rows.Count; i++)
            {
                li       = new ListItem();
                li.Value = dtThumbs.Rows[i]["iWidth"].ToString() + "|" + dtThumbs.Rows[i]["iHeight"].ToString();
                li.Text  = dtThumbs.Rows[i]["Title"].ToString();
                if (this.MainModule.DefaultThumbs == Str2Int(dtThumbs.Rows[i]["ID"].ToString()))
                {
                    li.Selected = true;
                }
                else
                {
                    li.Selected = false;
                }
                this.ThumbsSize.Items.Add(li);
            }
            dtThumbs.Clear();
            dtThumbs.Dispose();
            if (q("photo") != "")
            {
                NewsCollection nc = new NewsCollection();
                this.Image1.ImageUrl = nc.LocalFileUrl(site.Url, site.MainSite, q("photo"), this.MainModule.UploadPath, true, 0, 0);
            }
        }
Exemplo n.º 11
0
        public async Task UpdateNewsTweet(string guid, string tweetId, DateTime date)
        {
            var filter = Builders <NewsDbModel> .Filter.Eq(_ => _.Guid, guid);

            var update = Builders <NewsDbModel> .Update.Set(_ => _.Tweet, new Tweet { TweetId = tweetId, Date = date });

            await NewsCollection.UpdateOneAsync(filter, update);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Возвращает коллекцию полных новостей из архива для заданного пользователя.
 /// </summary>
 /// <returns></returns>
 public static PagingResult GetArchiveNews(PagingArgs args, int? personID)
 {
     NewsCollection coll = new NewsCollection();
     string[] offices = GetUserOfficesStringIDs(personID);
     int total_count;
     coll.FillFromDataSet(DBManager.GetArchiveNews(args, out total_count, offices));
     return new PagingResult(coll, total_count);
 }
Exemplo n.º 13
0
        /// <summary>
        /// Возвращает коллекцию актуальных новостей для заданного пользователя.
        /// </summary>
        /// <param name="personID"></param>
        /// <returns></returns>
        public static NewsCollection GetActualNews(int personID)
        {
            NewsCollection fullColl = new NewsCollection();
            string[] offices = GetUserOfficesStringIDs(personID);
            fullColl.FillFromDataSet(DBManager.GetActualNews(offices));

            return fullColl;
        }
Exemplo n.º 14
0
 void BindNews()
 {
     NewsCollection newsCollection = new NewsCollection();
     //coll.Where(DocCat.Columns.Active, 1);
     newsCollection.Load();
     grdNews.DataSource = newsCollection;
     grdNews.DataBind();
     //pnlMain.UpdateAfterCallBack = true;
 }
Exemplo n.º 15
0
        /// <summary>
        /// Gets news item collection
        /// </summary>
        /// <param name="LanguageID">Language identifier. 0 if you want to get all news</param>
        /// <param name="NewsCount">News item count. 0 if you want to get all news</param>
        /// <returns>News item collection</returns>
        public static NewsCollection GetNews(int LanguageID, int NewsCount)
        {
            bool             showHidden   = NopContext.Current.IsAdmin;
            DBNewsCollection dbCollection = DBProviderManager <DBNewsProvider> .Provider.GetNews(LanguageID, NewsCount, showHidden);

            NewsCollection collection = DBMapping(dbCollection);

            return(collection);
        }
Exemplo n.º 16
0
 public async Task AddNews(NewsArticle news)
 {
     await NewsCollection.InsertOneAsync(new NewsDbModel
     {
         Guid   = Guid.NewGuid().ToString(),
         Header = news.Header,
         Text   = news.Text,
         Date   = news.Date,
         Url    = news.Url
     });
 }
Exemplo n.º 17
0
 private void BindData()
 {
     if (NewsManager.NewsEnabled)
     {
         NewsCollection newsCollection = NewsManager.GetAllNews(LanguageId);
         rptrNews.DataSource = newsCollection;
         rptrNews.DataBind();
     }
     else
     {
         rptrNews.Visible = false;
     }
 }
Exemplo n.º 18
0
        protected void BindData()
        {
            NewsCollection newsCollection = NewsManager.GetAllNews(0);

            if (newsCollection.Count > 0)
            {
                rptrNews.DataSource = newsCollection;
                rptrNews.DataBind();
            }
            else
            {
                this.Visible = false;
            }
        }
Exemplo n.º 19
0
    private NewsCollection GetSubData(NewsCollection Source, int start, int end)
    {
        int            iTotalRecord = Source.Count;
        NewsCollection subSource    = new NewsCollection();

        if (Source != null)
        {
            for (int i = start; i < end; i++)
            {
                subSource.Add(Source[i]);
            }
        }
        return(subSource);
    }
Exemplo n.º 20
0
        /// <summary>
        /// Reads channels from database by inputted date
        /// </summary>
        /// <param name="date"></param>
        /// <returns>Collection of channels</returns>
        public NewsCollection GetChannelsFromDbByDate(string date)
        {
            var newsCollection = new NewsCollection();

            if (Config == null)
            {
                return(newsCollection);
            }
            foreach (ChannelElement channel in Config.Channels)
            {
                newsCollection.Channels.Add(GetArticlesByDateAndChannel(channel, date));
            }
            return(newsCollection);
        }
        public async Task GetAsync_GetAllNews_ReturnAllNews()
        {
            // Arrange
            var expectedNewsCollection = new NewsCollection().Data;

            Use <INewsRepository>()
            .Setup(s => s.QueryAsync(It.IsAny <NewsSpecifications>()))
            .ReturnsAsync(expectedNewsCollection);

            // Act
            var actualResult = await Sub.GetAsync();

            // Assert
            CollectionAssert.AreEqual(expectedNewsCollection, actualResult);
        }
Exemplo n.º 22
0
        public void Query_SpecificationIsNull_ReturnAllNews()
        {
            // Arrange
            var newsCollection = new NewsCollection().Data;

            Use <INewsProvider>()
            .Setup(c => c.GetAll())
            .Returns(newsCollection);

            // Act
            var actualResult = Sub.Query().ToList();

            // Assert
            CollectionAssert.AreEqual(newsCollection, actualResult);
        }
Exemplo n.º 23
0
        private List <Source> GetAllTheDifferentSources(NewsCollection allArticles)
        {
            var sources = new List <Source>();

            foreach (var article in allArticles.Articles)
            {
                var containingSource = sources.Any(x => x.Name == article.Source.Name);

                if (!containingSource)
                {
                    article.Source.SourceGuid = Guid.NewGuid();
                    sources.Add(article.Source);
                }
            }
            return(sources);
        }
Exemplo n.º 24
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            this.txtTitle.Text   = JumboECMS.Utils.Strings.SafetyStr(this.txtTitle.Text);
            this.txtSummary.Text = GetCutString(JumboECMS.Utils.Strings.HtmlEncode(this.txtSummary.Text), 200).Trim();
            //格式化标签
            this.txtTags.Text = JumboECMS.Utils.Strings.SafetyStr(this.txtTags.Text);
            //格式化地址
            this.txtPhotoUrl.Text = this.txtPhotoUrl.Text.Replace("\'", "").Replace("\"", "").Replace("\r\n", "\r");
            string[] PhotoUrlArr = txtPhotoUrl.Text.Split(new string[] { "\r" }, StringSplitOptions.RemoveEmptyEntries);
            int      iWidth = 0, iHeight = 0;
            string   ThumbsUrl = "";//缩略图地址

            new JumboECMS.DAL.Normal_ModuleDAL().GetThumbsSize(this.MainModule.Type, ref iWidth, ref iHeight);
            for (int i = 0; i < PhotoUrlArr.Length; i++)
            {
                string[] ThisPhotoInfo  = PhotoUrlArr[i].Split(new string[] { "|||" }, StringSplitOptions.RemoveEmptyEntries); //一行图片信息
                string   ThisPhotoUrl   = ThisPhotoInfo[ThisPhotoInfo.Length - 1];                                             //图片地址
                string   thumbnailImage = ThisPhotoUrl.Replace(".jpg", "_thumbs.jpg");                                         //默认缩略图
                if (ThisPhotoUrl.StartsWith("http://") || ThisPhotoUrl.StartsWith("https://"))                                 //远程图片
                {
                    thumbnailImage = ThisPhotoUrl;
                    //保存远程图片的缩略图
                    if (this.chkSaveRemoteThumbs.Checked)
                    {
                        NewsCollection nc = new NewsCollection();
                        thumbnailImage = nc.GetThumtnail(site.Url, site.MainSite, ThisPhotoUrl, MainModule.UploadPath, true, iWidth, iHeight);
                    }
                }
                else
                {
                    if (!JumboECMS.Utils.DirFile.FileExists(thumbnailImage))
                    {
                        JumboECMS.Utils.ImageHelp.LocalImage2Thumbs(Server.MapPath(ThisPhotoUrl), Server.MapPath(thumbnailImage), iWidth, iHeight, "Fill");
                    }
                }
                if (i > 0)
                {
                    ThumbsUrl += "\r";
                }
                ThumbsUrl += thumbnailImage;
                if (this.txtImg.Text == "" && i == 0)
                {
                    this.txtImg.Text = thumbnailImage;
                }
            }
            this.txtThumbsUrl.Text = ThumbsUrl;
        }
        public async Task GetAsync_FindAllCommentsByNewsId_ReturnCommentsForNews(int newsId)
        {
            // Arrange
            var expectedCommentsCollection = new NewsCollection().Data
                                             .First(w => w.Id == newsId)
                                             .Comments;

            Use <ICommentsRepository>()
            .Setup(s => s.QueryAsync(It.IsAny <CommentSpecifications>()))
            .ReturnsAsync(expectedCommentsCollection);

            // Act
            var actualResult = await Sub.GetAsync(newsId);

            // Assert
            CollectionAssert.AreEqual(expectedCommentsCollection, actualResult);
        }
Exemplo n.º 26
0
        private List <Article> GetTheArticles(NewsCollection allArticles, List <Source> sources)
        {
            var dtoArticles = new List <Article>();

            foreach (var article in allArticles.Articles)
            {
                foreach (var source in sources)
                {
                    if (source.Name == article.Source.Name)
                    {
                        article.SourceGuid = source.SourceGuid;
                        dtoArticles.Add(article);
                    }
                }
            }
            return(dtoArticles);
        }
Exemplo n.º 27
0
    private NewsCollection LoadData()
    {
        NewsCollection col = null;

        try
        {
            Data objdata = new Data(Global.ConnectionSql);
            News obj     = new News();
            obj.DataObject = objdata;
            col            = obj.GetList(string.Empty);
        }
        catch (Exception ex)
        {
            Global.WriteLogError("LoadProduct()" + ex);
        }
        return(col);
    }
Exemplo n.º 28
0
        private static NewsCollection DBMapping(DBNewsCollection dbCollection)
        {
            if (dbCollection == null)
            {
                return(null);
            }

            NewsCollection collection = new NewsCollection();

            foreach (DBNews dbItem in dbCollection)
            {
                News item = DBMapping(dbItem);
                collection.Add(item);
            }

            return(collection);
        }
        public async Task GetAsync_FindNonExistentNews_ReturnNotFound(int newsId)
        {
            // Arrange
            var expectedNewsQuery = new NewsCollection().Data
                                    .Where(w => w.Id == newsId)
                                    .ToList();

            Use <INewsRepository>()
            .Setup(s => s.QueryAsync(It.IsAny <NewsSpecifications>()))
            .ReturnsAsync(expectedNewsQuery);

            // Act
            var actualResult = await Sub.GetAsync(newsId);

            // Assert
            Assert.IsInstanceOf <NotFoundResult>(actualResult);
        }
Exemplo n.º 30
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     this.txtTitle.Text = JumboECMS.Utils.Strings.SafetyStr(this.txtTitle.Text);
     //保存远程图片
     if (this.chkSaveRemotePhoto.Checked)
     {
         string         cBody = FCKeditor1.Value;
         NewsCollection nc = new NewsCollection();
         int            iWidth = 0, iHeight = 0;
         new JumboECMS.DAL.Normal_ModuleDAL().GetThumbsSize(this.MainModule.Type, ref iWidth, ref iHeight);
         System.Collections.ArrayList bodyArray = nc.ProcessRemotePhotos(site.Url, site.MainSite, cBody, this.MainModule.UploadPath, site.Url, true, iWidth, iHeight);
         FCKeditor1.Value = bodyArray[0].ToString();
         if (bodyArray.Count < 3)
         {
             //if (this.chkAutoCatchThumbs.Checked)//自动清除缩略图
             //    this.txtImg.Text = "";
         }
         else
         {
             if (this.chkAutoCatchThumbs.Checked)
             {//自动加缩略图
                 if (this.txtImg.Text == "" || this.txtImg.Text.StartsWith("http://") || this.txtImg.Text.StartsWith("https://"))
                 {
                     this.txtImg.Text = nc.GetThumtnail(site.Url, site.MainSite, bodyArray[1].ToString(), this.MainModule.UploadPath, true, iWidth, iHeight);
                 }
             }
         }
         //不多余
         if (this.txtImg.Text.StartsWith("http://") || this.txtImg.Text.StartsWith("https://"))
         {
             this.txtImg.Text = nc.GetThumtnail(site.Url, site.MainSite, this.txtImg.Text, this.MainModule.UploadPath, true, iWidth, iHeight);
         }
     }
     if (this.txtSummary.Text.Length == 0)
     {
         this.txtSummary.Text = GetCutString(JumboECMS.Utils.Strings.NoHTML(FCKeditor1.Value), 200).Trim();
     }
     else
     {
         this.txtSummary.Text = GetCutString(JumboECMS.Utils.Strings.HtmlEncode(this.txtSummary.Text), 200).Trim();
     }
     //格式化标签
     this.txtTags.Text = JumboECMS.Utils.Strings.SafetyStr(this.txtTags.Text);
 }
Exemplo n.º 31
0
 private byte[] ToQueryMsg()
 {
     byte[] serverBuffer = null;
     try
     {
         DataTable      dt       = new MessageService().GetMessageToSend().Tables[0];;
         NewsCollection newsList = new NewsCollection();
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             newsList.Add(new NewsMessage(dt.Rows[i]["Id"].ToString(), dt.Rows[i]["Theme"].ToString()));
         }
         P2P.WellKnown.S2C.GetMsgsResponseMessage msgListReponse = new P2P.WellKnown.S2C.GetMsgsResponseMessage(newsList);
         serverBuffer = FormatterHelper.Serialize(msgListReponse);
     }
     catch
     {
     }
     return(serverBuffer);
 }
Exemplo n.º 32
0
        public void Update_UseInvalidNewsId_ReturnNull(int newsId)
        {
            // Arrange
            var news = new News
            {
                Id = newsId
            };
            var newsCollection = new NewsCollection().Data;

            Use <INewsProvider>()
            .Setup(c => c.GetAll())
            .Returns(newsCollection);

            // Act
            var actualResult = Sub.Update(news);

            // Assert
            Assert.IsNull(actualResult);
        }
        public async Task GetAsync_FindNonExistentComment_ReturnNotFound(int newsId, int commentId)
        {
            // Arrange
            var expectedCommentQuery = new NewsCollection().Data
                                       .FirstOrDefault(w => w.Id == newsId)
                                       ?.Comments.Where(w => w.Id == commentId)
                                       .ToList()
                                       ?? new List <Comment>();

            Use <ICommentsRepository>()
            .Setup(s => s.QueryAsync(It.IsAny <CommentSpecifications>()))
            .ReturnsAsync(expectedCommentQuery);

            // Act
            var actualResult = await Sub.GetAsync(newsId, commentId);

            // Assert
            Assert.IsInstanceOf <NotFoundResult>(actualResult);
        }
Exemplo n.º 34
0
    private NewsCollection LoadData()
    {
        Data           objdata = new Data(Global.ConnectionSql);
        NewsCollection col     = null;

        try
        {
            News obj = new News();
            obj.DataObject = objdata;
            col            = obj.GetList(txtSearch.Text.Trim());
        }
        catch (Exception ex)
        {
            Global.WriteLogError("LoadProduct()" + ex);
        }
        finally
        {
            objdata.DeConnect();
        }
        return(col);
    }
Exemplo n.º 35
0
        public RedmineServiceContext(Uri serviceUri, string apiKey)
        {
            _serviceUri		= serviceUri;
            _apiKey			= apiKey;

            _news			= new NewsCollection(this);
            _projects		= new ProjectsCollection(this);
            _issues			= new IssuesCollection(this);
            _users			= new UsersCollection(this);
            _userRoles		= new UserRolesCollection(this);
            _relations		= new IssueRelationsCollection(this);
            _trackers		= new IssueTrackersCollection(this);
            _statuses		= new IssueStatusesCollection(this);
            _priorities		= new IssuePrioritiesCollection(this);
            _categories		= new IssueCategoriesCollection(this);
            _versions		= new ProjectVersionsCollection(this);
            _attachments	= new AttachmentsCollection(this);
            _customFields	= new CustomFieldsCollection(this);
            _queries		= new QueriesCollection(this);

            _syncRoot		= new object();
        }
Exemplo n.º 36
0
        public NewsCollection GetNewsForHomePage(byte maxNewsCount)
        {
            var newsCollection = new NewsCollection();
            var dt = sqlHelper.GetDataTable("select top(" + maxNewsCount + ") * from News order by NewsDate  desc ");

            if (dt.Rows.Count > 0)
            {
                for (var i = 0; i < dt.Rows.Count; i++)
                {
                    var news = new News
                    {
                        Id = Convert.ToInt32(dt.Rows[i]["Id"].ToString()),
                        Tittle = dt.Rows[i]["Title"].ToString(),
                        Description = dt.Rows[i]["Description"].ToString(),
                        ImageUrl = dt.Rows[i]["ImageUrl"].ToString(),
                        Author = dt.Rows[i]["Author"].ToString(),
                        Date = dt.Rows[i]["NewsDate"].ToString()
                    };
                    newsCollection.Add(news);
                }
            }
            return newsCollection;
        }
Exemplo n.º 37
0
 /// <summary>
 /// Поиск новостей.
 /// </summary>
 /// <param name="args"> аргументы пэйджинга</param>
 /// <param name="strSearchTerms"> слова для поиска</param>
 /// <param name="iSearchAuthorID">ID автора</param>
 /// <param name="iNewsStatus">Статус новости</param>
 /// <param name="personID">ID пользователя,просматривающего страницу</param>
 /// <param name="officeID">ID офиса</param>
 /// <param name="iPeriod">период для поиска</param>
 /// <returns></returns>
 public static PagingResult SearchNews(PagingArgs args,
                                         String searchTerms,
                                         int searchAuthorID,
                                         UlterSystems.PortalLib.DB.DBManager.NewsStatus newsStatus,
                                         int personID,
                                         int officeID,
                                         UlterSystems.PortalLib.DB.DBManager.SearchPeriod period
                                         )
 {
     NewsCollection coll = new NewsCollection();
     int total_count;
     string[] offices = GetUserOfficesStringIDs(personID);
     coll.FillFromDataSet(DBManager.SearchNews(args, out total_count, searchTerms, searchAuthorID, newsStatus, officeID, offices, period));
     return new PagingResult(coll, total_count);
 }
Exemplo n.º 38
0
 public NewsCollection FetchByID(object NewsId)
 {
     NewsCollection coll = new NewsCollection().Where("newsId", NewsId).Load();
     return coll;
 }
Exemplo n.º 39
0
 public NewsCollection FetchByQuery(Query qry)
 {
     NewsCollection coll = new NewsCollection();
     coll.LoadAndCloseReader(qry.ExecuteReader());
     return coll;
 }