Esempio n. 1
0
        public bool SentArticle(Article article, HttpPostedFileBase orginalFileId, FormStructure formModel)
        {
            ModelView.InFormEntitiyList <RefereeCartable> keyValuePairs = new ModelView.InFormEntitiyList <RefereeCartable>();
            bool      result;
            RefereeBO refereeBo = new RefereeBO();

            try
            {
                ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);
                FormGeneratorConnection.StartTransaction(IsolationLevel.ReadUncommitted);

                if (orginalFileId != null)
                {
                    article.OrginalFileId =
                        FileManagerComponent.Instance.FileTransactionalFacade(FileManagerConnection)
                        .Insert(orginalFileId);
                }
                new ArticleBO().SetStatus(article);
                ArticleBO articleBo = new ArticleBO();
                FormGeneratorComponent.Instance.FormDataTransactionalFacade(FormGeneratorConnection).ModifyFormData(formModel);
                articleBo.Update(ConnectionHandler, article);
                articleBo.SendArticle(ConnectionHandler, FileManagerConnection, article, keyValuePairs);
                ConnectionHandler.CommitTransaction();
                FileManagerConnection.CommitTransaction();
                FormGeneratorConnection.CommitTransaction();
                result = true;
            }
            catch (KnownException ex)
            {
                ConnectionHandler.RollBack();
                FileManagerConnection.RollBack();
                FormGeneratorConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                ConnectionHandler.RollBack();
                FileManagerConnection.RollBack();
                FormGeneratorConnection.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            try
            {
                if (result)
                {
                    refereeBo.InformRefereeAddArticle(ConnectionHandler, article.CongressId, keyValuePairs);
                }
            }
            catch (Exception)
            {
            }
            return(result);
        }
Esempio n. 2
0
        public ModelView.ModifyResult <RefereeCartable> AssigneArticleToRefreeCartabl(IConnectionHandler connectionHandler, IConnectionHandler filemanagerconection, Guid articleId, Guid flowsender, List <Guid> refereesId, bool specialrefereesender = false)
        {
            var keyValuePairs = new ModelView.ModifyResult <RefereeCartable>();
            var articleBo     = new ArticleBO();
            var article       = articleBo.Get(connectionHandler, articleId);
            var config        = new ConfigurationBO().ValidConfig(connectionHandler, article.CongressId);

            article.FinalState = (byte)Enums.FinalState.WaitForAnswer;
            bool articleSpecialReferee = config.SentArticleSpecialReferee;

            if (refereesId.Count > 0)
            {
                if (config.SentArticleSpecialReferee)
                {
                    if (specialrefereesender)
                    {
                        articleSpecialReferee = false;
                        article.Status        = (byte)Enums.ArticleState.WaitForRefereeOpinion;
                    }
                    else
                    {
                        article.Status = (byte)Enums.ArticleState.SentToSpecialReferee;
                    }
                }
                else
                {
                    article.Status = (byte)Enums.ArticleState.WaitForRefereeOpinion;
                }
            }
            if (!articleBo.Update(connectionHandler, article))
            {
                return(keyValuePairs);
            }
            if (
                !this.UpdateRefreeCartabl(connectionHandler, filemanagerconection,
                                          article, flowsender, refereesId, articleSpecialReferee))
            {
                return(keyValuePairs);
            }
            foreach (var guid in refereesId)
            {
                keyValuePairs.AddInform(
                    new RefereeCartable()
                {
                    RefereeId = guid, ArticleId = articleId
                }, Resources.Congress.RefereeInformArticleEmail,
                    Resources.Congress.RefereeInformArticleSMS);
            }

            keyValuePairs.Result     = true;
            keyValuePairs.SendInform = true;
            return(keyValuePairs);
        }
Esempio n. 3
0
        public bool AdminUpdateArticles(Guid congressId, List <Article> model)
        {
            ModelView.InFormEntitiyList <Article> articles = new ModelView.InFormEntitiyList <Article>();
            bool      result;
            ArticleBO articleBo = new ArticleBO();

            try
            {
                ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                var transactionTransactionalFacade = PaymentComponenets.Instance.TransactionTransactionalFacade(PaymentConnection);
                var list = articleBo.Where(ConnectionHandler, x => x.Id.In(model.Select(article => article.Id)));
                foreach (Article obj in list)
                {
                    articleBo.AdminSetStatus(obj);
                    if (obj.PayStatus.HasValue)
                    {
                        obj.PayStatus = obj.PayStatus;
                        if (obj.PayStatus == (byte)Enums.ArticlepayState.PayConfirm && obj.TransactionId != null)
                        {
                            transactionTransactionalFacade.Done((Guid)obj.TransactionId);
                        }
                    }
                    articleBo.Update(ConnectionHandler, obj);
                    articles.Add(obj, Resources.Congress.ArticleChangeStatusEmail, Resources.Congress.ArticleChangeStatusSMS);
                }
                ConnectionHandler.CommitTransaction();
                result = true;
            }
            catch (KnownException ex)
            {
                ConnectionHandler.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                ConnectionHandler.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            try
            {
                if (result)
                {
                    articleBo.InformArticle(ConnectionHandler, congressId, articles);
                }
            }
            catch (Exception)
            {
            }
            return(result);
        }
Esempio n. 4
0
        public bool UpdateStatus(Guid congressId, List <Guid> guids, FinalState status)
        {
            ModelView.InFormEntitiyList <Article> articles = new ModelView.InFormEntitiyList <Article>();
            bool      result;
            ArticleBO articleBo = new ArticleBO();

            try
            {
                ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
                if (!guids.Any())
                {
                    return(true);
                }

                List <Article> list = articleBo.Where(ConnectionHandler, x => x.Id.In(guids));
                foreach (Article item in list)
                {
                    item.FinalState = (byte)status;
                    articleBo.AdminSetStatus(item);
                    articleBo.Update(ConnectionHandler, item);
                    articles.Add(item, Resources.Congress.ArticleChangeStatusEmail, Resources.Congress.ArticleChangeStatusSMS);
                }
                ConnectionHandler.CommitTransaction();
                result = true;
            }
            catch (KnownException ex)
            {
                ConnectionHandler.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                ConnectionHandler.RollBack();
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            try
            {
                if (result)
                {
                    articleBo.InformArticle(ConnectionHandler, congressId, articles);
                }
            }
            catch (Exception)
            {
            }
            return(result);
        }
Esempio n. 5
0
        public bool AnswerArticle(IConnectionHandler connectionHandler, IConnectionHandler filemanagerconnection, Guid congressId,
                                  RefereeCartable refereeCartable, Guid answeredrefreeId, string comments,
                                  HttpPostedFileBase attachment)
        {
            var articleBo     = new ArticleBO();
            var articleFlowBo = new ArticleFlowBO();
            var config        = new ConfigurationBO().ValidConfig(connectionHandler, congressId);
            var refree        = new RefereeBO().Get(connectionHandler, answeredrefreeId);


            if (!this.ModifyCartabl(connectionHandler, refereeCartable.ArticleId, answeredrefreeId,
                                    refereeCartable.Status, refereeCartable.Visited, false))
            {
                return(false);
            }

            var article = articleBo.Get(connectionHandler, refereeCartable.ArticleId);

            article.FinalState = (byte)Enums.FinalState.WaitForAnswer;
            if (config.SentArticleSpecialReferee)
            {
                article.Status = refree.IsSpecial
                    ? (byte)Enums.ArticleState.WaitForScientificTeacher
                    : (byte)Enums.ArticleState.WaitforSpecialRefereeOpinion;
            }
            else
            {
                article.Status = (byte)Enums.ArticleState.WaitForScientificTeacher;
            }

            if (!articleBo.Update(connectionHandler, article))
            {
                throw new Exception(string.Format(Resources.Congress.ErrorInEditArticleCongress, Extention.GetAtricleTitle(article.CongressId)));
            }

            var lastSenderId = new ArticleFlowBO().SelectFirstOrDefault(connectionHandler, x => x.SenderId,
                                                                        x => x.ReceiverId == answeredrefreeId && x.ArticleId == article.Id,
                                                                        new OrderByModel <ArticleFlow>()
            {
                Expression = x => x.SaveDate + "" + x.SaveTime,
                OrderType  = OrderType.DESC
            });


            var lastrefree = new RefereeBO().Get(connectionHandler, lastSenderId);

            if (lastrefree != null && lastrefree.IsSpecial)
            {
                var lastrefereeCartable = new RefereeCartable();
                lastrefereeCartable = this.FirstOrDefaultWithOrderByDescending(connectionHandler, x => x.InsertDate,
                                                                               x => x.ArticleId == article.Id && x.RefereeId == lastrefree.Id);

                if (lastrefereeCartable != null)
                {
                    if (!this.ModifyCartabl(connectionHandler, lastrefereeCartable.ArticleId, lastSenderId,
                                            (byte)Enums.FinalState.RefereeAnswered, lastrefereeCartable.Visited, false))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (!this.ModifyCartabl(connectionHandler, article.Id, lastSenderId, (byte)Enums.FinalState.WaitForAnswer, false, true))
                    {
                        return(false);
                    }
                }

                if (!articleFlowBo.AddFlow(connectionHandler, filemanagerconnection, answeredrefreeId, lastSenderId != Guid.Empty ? lastSenderId : (Guid?)null, refereeCartable.ArticleId,
                                           refereeCartable.Status, comments, attachment))
                {
                    return(false);
                }
            }
            else
            {
                var articleFlow =
                    articleFlowBo.FirstOrDefaultWithOrderBy(connectionHandler, x => x.SaveDate + " " + x.SaveTime,
                                                            x => x.ArticleId == refereeCartable.ArticleId && x.ReceiverId == answeredrefreeId);
                var senderId = articleFlow != null ? articleFlow.SenderId : (Guid?)null;
                if (!articleFlowBo.AddFlow(connectionHandler, filemanagerconnection, answeredrefreeId, senderId,
                                           refereeCartable.ArticleId, refereeCartable.Status, comments, attachment))
                {
                    return(false);
                }
            }

            return(true);
        }