Example #1
0
        public async Task <IEnumerable <News.DataStructure.News> > TopCountAsync(Guid congressId, int?top)
        {
            try
            {
                var congressNewsBo = new CongressNewsBO();
                var byDescending   = await congressNewsBo.SelectAsync(ConnectionHandler, x => x.News,
                                                                      news => news.CongressId == congressId && news.News.Enabled && news.News.Pined,
                                                                      new OrderByModel <CongressNews>() { Expression = x => x.News.PublishDate + "" + x.News.PublishTime, OrderType = OrderType.DESC });

                var @select = await congressNewsBo.SelectAsync(ConnectionHandler, x => x.News,
                                                               news => news.CongressId == congressId && news.News.Enabled && !news.News.Pined,
                                                               new OrderByModel <CongressNews>()
                                                               { Expression = x => x.News.PublishDate + "" + x.News.PublishTime, OrderType = OrderType.DESC });

                byDescending.AddRange(@select);
                return(top != null && top > 0
                     ? byDescending.Take((int)top)
                     : byDescending);
            }
            catch (KnownException ex)
            {
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
        }
Example #2
0
        public void NewsSearch(IConnectionHandler connectionHandler, Guid congressId, string txtvalue, List <Tools.ModelView.SerachResultvalue> resultvalues)
        {
            var @select = NewsComponent.Instance.NewsContentFacade.Where(
                x => x.Body.Contains(txtvalue) || x.Lead.Contains(txtvalue) || x.Title1.Contains(txtvalue) ||
                x.Title2.Contains(txtvalue));

            if ([email protected]())
            {
                return;
            }
            var enumerable = @select.Select(x => x.Id);

            var newses1 =
                new CongressNewsBO().Select(connectionHandler, x => x.News,
                                            c => c.CongressId == congressId && c.NewsId.In(enumerable));

            if (!newses1.Any())
            {
                return;
            }
            foreach (var VARIABLE in newses1)
            {
                var firstOrDefault = @select.FirstOrDefault(x => x.Id == VARIABLE.Id);
                if (firstOrDefault == null)
                {
                    continue;
                }
                var resultvalue = new Tools.ModelView.SerachResultvalue();
                resultvalue.Key         = VARIABLE.Id.ToString();
                resultvalue.ResultValue = firstOrDefault.Title1;
                resultvalue.SearchType  = Enums.SearchType.News;
                resultvalues.Add(resultvalue);
            }
        }
Example #3
0
        public override bool Delete(params object[] keys)
        {
            try
            {
                this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                this.NewsConnection.StartTransaction(IsolationLevel.ReadUncommitted);
                var obj = new CongressNewsBO().Get(this.ConnectionHandler, keys);
                if (!new CongressNewsBO().Delete(this.ConnectionHandler, keys))
                {
                    throw new Exception(Resources.Congress.ErrorInDeleteCongressNews);
                }
                if (!NewsComponent.Instance.NewsTransactionalFacade(this.NewsConnection).Delete(obj.NewsId))
                {
                    throw new Exception("خطایی در حذف اخبار وجود دارد");
                }



                this.ConnectionHandler.CommitTransaction();
                this.NewsConnection.CommitTransaction();
                return(true);
            }
            catch (KnownException ex)
            {
                this.ConnectionHandler.RollBack();
                this.NewsConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                this.ConnectionHandler.RollBack();
                this.NewsConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
        }
Example #4
0
        public IEnumerable <News.DataStructure.News> TopCount(Guid congressId, int?top)
        {
            try
            {
                var congressNewsBo = new CongressNewsBO();
                var shamsiDate     = DateTime.Now.ShamsiDate() + "-" + DateTime.Now.GetTime();
                var byDescending   = congressNewsBo.Select(ConnectionHandler, x => x.News,
                                                           x => x.CongressId == congressId && x.News.Enabled && x.News.Pined && (x.News.ExpireDate == null || string.IsNullOrEmpty(x.News.ExpireDate) || ((x.News.ExpireDate + "-" + x.News.ExpireTime).CompareTo(shamsiDate) > 0)),
                                                           new OrderByModel <CongressNews>()
                {
                    Expression = x => x.News.PublishDate + "" + x.News.PublishTime, OrderType = OrderType.DESC
                });

                var @select = congressNewsBo.Select(ConnectionHandler, x => x.News,
                                                    x => x.CongressId == congressId && x.News.Enabled && !x.News.Pined && (x.News.ExpireDate == null || string.IsNullOrEmpty(x.News.ExpireDate) || ((x.News.ExpireDate + "-" + x.News.ExpireTime).CompareTo(shamsiDate) > 0)),
                                                    new OrderByModel <CongressNews>()
                {
                    Expression = x => x.News.PublishDate + "" + x.News.PublishTime, OrderType = OrderType.DESC
                });

                byDescending.AddRange(@select);
                return(top != null && top > 0
                     ? byDescending.Take((int)top)
                     : byDescending);
            }
            catch (KnownException ex)
            {
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
        }