Ejemplo n.º 1
0
        public Dictionary <Referee, bool> GetAllForArticle(Guid congressId, Guid articleId, bool isSpecial = false)
        {
            try
            {
                var list              = new RefereeBO().OrderBy(this.ConnectionHandler, x => x.EnterpriseNode.RealEnterpriseNode.FirstName + " " + x.EnterpriseNode.RealEnterpriseNode.LastName, x => x.CongressId == congressId);
                var getAllForArticle  = new Dictionary <Referee, bool>();
                var refereeCartableBo = new RefereeCartableBO();
                var addedList         = refereeCartableBo.Select(this.ConnectionHandler, x => x.RefereeId, x => x.ArticleId == articleId && x.IsActive, true);
                var listAllCartable   = refereeCartableBo.Select(this.ConnectionHandler, new Expression <Func <RefereeCartable, object> >[] { x => x.RefereeId, x => x.Status }, x => x.Referee.CongressId == congressId, true);

                foreach (var referee in list)
                {
                    var res = addedList.Any(x => x == referee.Id);
                    if (!res && referee.IsSpecial != isSpecial)
                    {
                        continue;
                    }
                    referee.AllArticleCount           = listAllCartable.Count(x => x.RefereeId == referee.Id);
                    referee.WaitForAnswerArticleCount = listAllCartable.Count(x => x.RefereeId == referee.Id && x.Status == (byte)Enums.FinalState.WaitForAnswer);
                    getAllForArticle.Add(referee, res);
                }
                return(getAllForArticle);
            }
            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);
            }
        }
Ejemplo n.º 2
0
        public override bool Delete(params object[] keys)
        {
            try
            {
                this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                this.EnterpriseNodeConnection.StartTransaction(IsolationLevel.ReadUncommitted);
                var obj = new RefereeBO().Get(this.ConnectionHandler, keys);

                var byFilter = new RefereeCartableBO().Any(this.ConnectionHandler,
                                                           cartable => cartable.RefereeId == obj.Id);
                if (byFilter)
                {
                    throw new Exception(Resources.Congress.ErrorInDeleteRefereeBecauseHisCartablContainArticle);
                }
                var refereePivotBo = new RefereePivotBO();
                var list           = refereePivotBo.Select(this.ConnectionHandler, x => x.PivotId, x => x.RefereeId == obj.Id);
                foreach (var refereePivot in list)
                {
                    if (!refereePivotBo.Delete(this.ConnectionHandler, obj.Id, refereePivot))
                    {
                        throw new Exception(Resources.Congress.ErrorInEditReferee);
                    }
                }
                if (!new RefereeBO().Delete(this.ConnectionHandler, keys))
                {
                    throw new Exception(Resources.Congress.ErrorInDeleteReferee);
                }
                if (
                    !EnterpriseNodeComponent.Instance.EnterpriseNodeTransactionalFacade(this.EnterpriseNodeConnection)
                    .Delete(keys))
                {
                    return(false);
                }

                this.ConnectionHandler.CommitTransaction();
                this.EnterpriseNodeConnection.CommitTransaction();
                return(true);
            }
            catch (KnownException ex)
            {
                this.ConnectionHandler.RollBack();
                this.EnterpriseNodeConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                this.ConnectionHandler.RollBack();
                this.EnterpriseNodeConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
        }
Ejemplo n.º 3
0
        public bool SpecialRefereeAssignArticle(Guid congressId, RefereeCartable refereeCartable, Guid answeredrefreeId, string comments,
                                                HttpPostedFileBase attachment, List <Guid> refreeIdlist)
        {
            ModelView.ModifyResult <RefereeCartable> keyValuePairs;
            var refereeBo = new RefereeBO();

            try
            {
                this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);
                keyValuePairs = new RefereeCartableBO().SpecialRefereeAssignArticle(this.ConnectionHandler,
                                                                                    this.FileManagerConnection,
                                                                                    congressId, refereeCartable, answeredrefreeId, comments, attachment, refreeIdlist);

                this.ConnectionHandler.CommitTransaction();
                this.FileManagerConnection.CommitTransaction();
            }
            catch (KnownException ex)
            {
                this.ConnectionHandler.RollBack();
                this.FileManagerConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                this.ConnectionHandler.RollBack();
                this.FileManagerConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            try
            {
                if (keyValuePairs.SendInform)
                {
                    refereeBo.InformRefereeAddArticle(this.ConnectionHandler, congressId, keyValuePairs.InformList);
                }
            }
            catch (Exception)
            {
            }
            return(keyValuePairs.Result);
        }
Ejemplo n.º 4
0
        public bool AssigneArticleToRefreeCartabl(Guid congressId, Guid articleId, Guid flowsender, List <Guid> refereesId)
        {
            ModelView.ModifyResult <RefereeCartable> keyValuePairs;

            var refereeBo = new RefereeBO();

            try
            {
                this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);
                keyValuePairs = new RefereeCartableBO().AssigneArticleToRefreeCartabl(this.ConnectionHandler, this.FileManagerConnection, articleId, flowsender, refereesId);
                this.ConnectionHandler.CommitTransaction();
                this.FileManagerConnection.CommitTransaction();
            }
            catch (KnownException ex)
            {
                this.ConnectionHandler.RollBack();
                this.FileManagerConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                this.ConnectionHandler.RollBack();
                this.FileManagerConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }

            try
            {
                if (keyValuePairs.SendInform)
                {
                    refereeBo.InformRefereeAddArticle(this.ConnectionHandler, congressId, keyValuePairs.InformList);
                }
            }
            catch (Exception)
            {
            }
            return(keyValuePairs.Result);
        }
Ejemplo n.º 5
0
        public List <dynamic> SearchDynamic(Guid congressId, Article article, string serachvalue,
                                            FormStructure formStructure, Enums.AscendingDescending ascendingDescending, Enums.SortAccordingToArticle articleflow)
        {
            try
            {
                List <dynamic> searchArticleList = new ArticleBO().SearchDynamic(ConnectionHandler, congressId, article, serachvalue, ascendingDescending, articleflow);
                if (!searchArticleList.Any())
                {
                    return(searchArticleList);
                }

                List <Guid> @select = new List <Guid>();
                if (searchArticleList.Any())
                {
                    List <Guid> idlist = searchArticleList.Select(user1 => (Guid)user1.Id).ToList();
                    @select = new RefereeCartableBO().Select(ConnectionHandler, x => x.ArticleId,
                                                             x => x.ArticleId.In(idlist), true);
                }

                foreach (dynamic item in searchArticleList)
                {
                    item.HasRefereeOpinion     = @select.Any(x => x.Equals(item.Id));
                    item.HasRefereeAttachment  = item.HasRefereeOpinion;
                    item.AllowPrintCertificate = true;
                    item.Abstract           = item.Abstract == null ? "" : ((string)item.Abstract).RemoveHtml();
                    item.ArticleOrginalText = item.ArticleOrginalText == null ? "" : ((string)item.ArticleOrginalText).RemoveHtml();
                }
                return(searchArticleList);
            }
            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);
            }
        }
Ejemplo n.º 6
0
        public IEnumerable <Article> GetAllForZipFile(Guid congressId, Article article, string serachvalue,
                                                      FormStructure formStructure, Enums.AscendingDescending ascendingDescending, Enums.SortAccordingToArticle articleflow)
        {
            try
            {
                List <Article> search = new ArticleBO().Search(ConnectionHandler, congressId, article, serachvalue, ascendingDescending, articleflow, formStructure);
                if (!search.Any())
                {
                    return(null);
                }

                List <Guid> @select = new RefereeCartableBO().Select(ConnectionHandler, x => x.ArticleId,
                                                                     x => x.ArticleId.In(search.Select(i => i.Id)), true);
                foreach (Article item in search)
                {
                    if (!string.IsNullOrEmpty(item.Abstract))
                    {
                        item.Abstract = Regex.Replace(item.Abstract, "<.*?>", "");
                    }

                    item.HasRefereeOpinion     = @select.Any(x => x.Equals(item.Id));
                    item.HasRefereeAttachment  = item.HasRefereeOpinion;
                    item.AllowPrintCertificate = true;
                    item.Abstract           = item.Abstract == null ? "" : item.Abstract.RemoveHtml();
                    item.ArticleOrginalText = item.ArticleOrginalText == null ? "" : item.ArticleOrginalText.RemoveHtml();
                }
                return(search);
            }
            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);
            }
        }
Ejemplo n.º 7
0
        public IEnumerable <ArticleFlow> GetArticleFlow(Guid congressId, Guid articelId, Guid?filterId = null, bool?isReferee = null, bool?isuser = null)
        {
            try
            {
                var predicateBuilder = new PredicateBuilder <ArticleFlow>();
                predicateBuilder.And(x => x.ArticleId == articelId);

                if (filterId.HasValue)
                {
                    predicateBuilder.And(x => x.ReceiverId == filterId || x.SenderId == filterId);
                    if (isuser.HasValue && isuser == true)
                    {
                        var guids = new RefereeBO().Select(this.ConnectionHandler, x => x.Id, x => x.CongressId == congressId);
                        if (guids.Any())
                        {
                            predicateBuilder.And(x => (x.SenderId == null || x.SenderId.NotIn(guids)) && (x.ReceiverId == null || x.ReceiverId.Value.NotIn(guids)));
                        }
                    }
                    if (isReferee.HasValue && isReferee.Value)
                    {
                        var users = new UserBO().Select(this.ConnectionHandler, c => c.Id, c => c.CongressId == congressId);
                        if (users.Any())
                        {
                            predicateBuilder.And(x => (x.SenderId == null || x.SenderId.NotIn(users)) && (x.ReceiverId == null || x.ReceiverId.Value.NotIn(users)));
                        }
                    }
                }

                var list    = new ArticleFlowBO().OrderByDescending(this.ConnectionHandler, x => x.SaveDate + "" + x.SaveTime, predicateBuilder.GetExpression());
                var @select = new RefereeCartableBO().Select(base.ConnectionHandler,
                                                             new Expression <Func <RefereeCartable, object> >[] { x => x.Status, x => x.RefereeId },
                                                             i => i.ArticleId == articelId,
                                                             new OrderByModel <RefereeCartable>()
                {
                    Expression = x => x.InsertDate, OrderType = OrderType.DESC
                });
                foreach (var item in list)
                {
                    if (item.Status != null)
                    {
                        item.LastRefreeView = ((Enums.FinalState)item.Status).GetDescriptionInLocalization();
                    }
                    else if (item.Sender != null)
                    {
                        var refereeCartable = @select.FirstOrDefault(i => i.RefereeId == item.SenderId);
                        if (refereeCartable != null)
                        {
                            item.LastRefreeView = ((Enums.FinalState)refereeCartable.Status).GetDescriptionInLocalization();
                        }
                    }
                    item.Remark = item.Remark.Replace("\r\n", "<br />");
                }
                return(list);
            }
            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);
            }
        }
Ejemplo n.º 8
0
        public IEnumerable <ModelView.UserArticleAbstract> SearchArticle(Guid congressId, Article article, string serachvalue, FormStructure formStructure, Enums.AscendingDescending ascendingDescending, Enums.SortAccordingToArticle articleflow)
        {
            try
            {
                ArticleBO      articleBo = new ArticleBO();
                List <Article> list      = articleBo.Search(ConnectionHandler, congressId, article, serachvalue, ascendingDescending, articleflow, formStructure);
                if (!list.Any())
                {
                    return(null);
                }

                List <ModelView.UserArticleAbstract> outlist = new List <ModelView.UserArticleAbstract>();
                List <ArticleAuthors> articleAuthorses       = new ArticleAuthorsBO().Where(ConnectionHandler, c => c.ArticleId.In(list.Select(i => i.Id)));
                Homa homa = new HomaBO().Get(ConnectionHandler, congressId);
                ConfigurationContent configcontent = new ConfigurationContentBO().Get(ConnectionHandler, congressId, homa.Configuration.CardLanguageId);
                List <Guid>          @select       = new RefereeCartableBO().Select(ConnectionHandler, x => x.ArticleId, x => x.ArticleId.In(list.Select(i => i.Id)));
                foreach (Article item in list)
                {
                    ModelView.UserArticleAbstract model = new ModelView.UserArticleAbstract();
                    item.HasRefereeOpinion     = @select.Any(x => x.Equals(item.Id));
                    item.HasRefereeAttachment  = item.HasRefereeOpinion;
                    item.AllowPrintCertificate = true;

                    List <ArticleAuthors> authorbo = articleAuthorses.Where(c => c.ArticleId == item.Id).OrderBy(c => c.Order).ToList();
                    string auters = "";
                    if (string.IsNullOrEmpty(item.Title))
                    {
                        foreach (ArticleAuthors author in authorbo)
                        {
                            auters += "," + author.Name + ":" + (author.IsDirector == false ? "" : "Director" + ":") + author.Address;
                        }
                        if (!string.IsNullOrEmpty(auters))
                        {
                            model.Authors = auters.Substring(1);
                        }
                    }
                    if (string.IsNullOrEmpty(auters))
                    {
                        foreach (ArticleAuthors author in authorbo)
                        {
                            auters += "," + author.Name + ":" + (author.IsDirector == false ? "" : "مسوول" + ":") + author.Address;
                        }
                        if (!string.IsNullOrEmpty(auters))
                        {
                            model.Authors = auters.Substring(1);
                        }
                    }
                    if (configcontent != null && configcontent.LogoId.HasValue && configcontent.Logo != null)
                    {
                        model.CongressLogo = configcontent.Logo.Content;
                    }

                    model.Id = item.Id.ToString();
                    model.OrginalTextFile = item.ArticleOrginalText == null ? "" : item.ArticleOrginalText.RemoveHtml();
                    model.Abstract        = item.Abstract == null ? "" : item.Abstract.RemoveHtml();
                    model.CongressTitle   = homa.CongressTitle;
                    model.Description     = item.Description;
                    model.Title           = item.Title;
                    model.Keyword         = item.Keyword;
                    if (item.Pivot != null)
                    {
                        model.Pivot = item.Pivot.Title;
                    }

                    outlist.Add(model);
                }
                return(outlist);
            }
            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);
            }
        }