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); }
public bool AdminUpdate(Guid adminId, Article obj, List <ArticleAuthors> articleAuthorses, string comment, HttpPostedFileBase flowFile, HttpPostedFileBase orginalFileId, HttpPostedFileBase abstractFileId, FormStructure formModel) { bool result; ArticleBO articleBo = new ArticleBO(); ModelView.InFormEntitiyList <Article> articles = new ModelView.InFormEntitiyList <Article>(); try { ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted); FormGeneratorConnection.StartTransaction(IsolationLevel.ReadUncommitted); Article oldsatus = articleBo.Get(ConnectionHandler, obj.Id); articleBo.AdminUpdate(ConnectionHandler, FileManagerConnection, FormGeneratorConnection, adminId, obj, articleAuthorses, orginalFileId, abstractFileId, comment, flowFile, formModel); ConnectionHandler.CommitTransaction(); FileManagerConnection.CommitTransaction(); FormGeneratorConnection.CommitTransaction(); result = true; if (oldsatus.Status != obj.Status) { articles.Add(obj, Resources.Congress.ArticleChangeStatusEmail, Resources.Congress.ArticleChangeStatusSMS); } } 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 { articleBo.InformArticle(ConnectionHandler, obj.CongressId, articles); } catch (Exception) { } return(result); }
public void InformRefereeAddArticle(IConnectionHandler connectionHandler, Guid congressId, ModelView.InFormEntitiyList <RefereeCartable> keyValuePairs) { if (!keyValuePairs.Any()) { return; } var refereeBo = new RefereeBO(); var arti = keyValuePairs.FirstOrDefault(); var referee = refereeBo.Get(connectionHandler, arti.obj.RefereeId); var homa1 = new HomaBO().Get(connectionHandler, congressId); var articleBo = new ArticleBO(); var config = homa1.Configuration; if (config.RefereeInformType == null) { return; } CustomMessage custommessage = new CustomMessageBO().FirstOrDefault(connectionHandler, x => x.CongressId == congressId && x.Type == Enums.MessageInformType.RefereeArticle); foreach (var article in keyValuePairs) { var article1 = articleBo.Get(connectionHandler, article.obj.ArticleId); if (article1 == null) { continue; } var name = referee.EnterpriseNode.DescriptionFieldWithGender; var homaCompleteUrl = homa1.GetHomaCompleteUrl(); var homaArticleRefereePanelUrl = homa1.GetHomaArticleRefereePanelUrl(article1.Id, referee.Id); var email = string.Format(article.EmailBody, homa1.CongressTitle, name, article1.Title, homaCompleteUrl, homaArticleRefereePanelUrl); var sms = string.Format(article.SmsBody, homa1.CongressTitle, name, article1.Code); if (custommessage != null) { if (!string.IsNullOrEmpty(custommessage.EmailText)) { email = custommessage.EmailText.Replace($"[{Enums.RefereeArticleMessageKey.FullName.ToString()}]", name); email = email.Replace($"[{Enums.RefereeArticleMessageKey.Username.ToString()}]", referee.Username); email = email.Replace($"[{Enums.RefereeArticleMessageKey.ArticleCode.ToString()}]", article1.Code.ToString()); email = email.Replace($"[{Enums.RefereeArticleMessageKey.ArticleTitle.ToString()}]", article1.Title); email = email.Replace($"[{Enums.RefereeArticleMessageKey.CongressTitle.ToString()}]", homa1.CongressTitle); email = email.Replace($"[{Enums.RefereeArticleMessageKey.CongressAddress.ToString()}]", homaCompleteUrl); } if (!string.IsNullOrEmpty(custommessage.SmsText)) { sms = custommessage.SmsText.Replace($"[{Enums.RefereeArticleMessageKey.FullName.ToString()}]", name); sms = sms.Replace($"[{Enums.RefereeArticleMessageKey.Username.ToString()}]", referee.Username); sms = sms.Replace($"[{Enums.RefereeArticleMessageKey.ArticleCode.ToString()}]", article1.Code.ToString()); sms = sms.Replace($"[{Enums.RefereeArticleMessageKey.ArticleTitle.ToString()}]", article1.Title); sms = sms.Replace($"[{Enums.RefereeArticleMessageKey.CongressTitle.ToString()}]", homa1.CongressTitle); sms = sms.Replace($"[{Enums.RefereeArticleMessageKey.CongressAddress.ToString()}]", homaCompleteUrl); } } var inform = new Message.Tools.ModelView.MessageModel() { Email = referee.EnterpriseNode.Email, Mobile = referee.EnterpriseNode.Cellphone, EmailTitle = homa1.CongressTitle, EmailBody = email, SMSBody = sms }; new HomaBO().SendInform((byte)config.RefereeInformType, inform, config, homa1.CongressTitle); MessageComponenet.SentInternalMessageInstance.MailBoxFacade.SendInternalMail(homa1.OwnerId, config.CongressId, new[] { referee.EnterpriseNode.Id.ToString() }, homa1.CongressTitle, inform.SMSBody); } }
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); }