/// <summary> /// Replaces the specified subject. /// </summary> /// <param name="subject">The subject.</param> /// <param name="body">The body.</param> public override void Replace(ref string subject, ref string body) { if (!SiteAction.ObjectID.HasValue) { return; } PortalSettings = DataManager.PortalSettings.SelectMapBySiteId(SiteAction.SiteID, true); ReplaceUserInfo(ref body); if (PortalSettings != null) { PortalLink = DataManager.PortalSettings.SelectPortalLink(PortalSettings.SiteID); RequirementLinkTemplate = RequirementLinkTemplate.Replace("#PortalLink#", PortalLink); } var requirementComment = ContentCommentRepository.SelectById(SiteAction.SiteID, (Guid)SiteAction.ObjectID, CommentTables.tbl_RequirementComment); var requirement = DataManager.Requirement.SelectById(SiteAction.SiteID, requirementComment.ContentID); if (requirement == null) { return; } if (requirement.CompanyID.HasValue) { subject = subject.Replace("#Requirement.Notification.Company#", requirement.tbl_Company.Name); body = body.Replace("#Requirement.Notification.Company#", requirement.tbl_Company.Name); } else { subject = subject.Replace("#Requirement.Notification.Company#", string.Empty); body = body.Replace("#Requirement.Notification.Company#", string.Empty); } var replyLink = "Ответить"; var shortDescription = requirement.ShortDescription; if (PortalSettings != null) { var requirementLink = string.Format(RequirementLinkTemplate, requirement.ID); replyLink = string.Format("<a href='{0}'>Ответить</a>", requirementLink); shortDescription = string.Format("<a href='{0}'>{1}</a>", requirementLink, shortDescription); } body = body.Replace("#Requirement.ShortDescription#", shortDescription) .Replace("#Requirement.Comment#", requirementComment.Comment) .Replace("#Requirement.Comment.ReplyLink#", replyLink); }
public static ContentComment GetComment(string commentId, string commentType) { try { var result = ContentCommentRepository.SelectById(CurrentUser.Instance.SiteID, Guid.Parse(commentId), commentType.ToEnum <CommentTables>(), true); return(result); } catch (Exception ex) { Log.Error(string.Format("ContentComment GetCommentText({0}, {1})", commentId, commentType), ex); return(null); } }
public static bool DeleteComment(string commentId, string commentType) { try { var contentComment = ContentCommentRepository.SelectById(CurrentUser.Instance.SiteID, Guid.Parse(commentId), commentType.ToEnum <CommentTables>()); if (contentComment != null && !string.IsNullOrEmpty(contentComment.FileName)) { var fsp = new FileSystemProvider(); fsp.Delete(CurrentUser.Instance.SiteID, EnumHelper.GetEnumDescription(commentType.ToEnum <CommentTables>()), contentComment.FileName, FileType.Attachment); } ContentCommentRepository.Delete(CurrentUser.Instance.SiteID, Guid.Parse(commentId), commentType.ToEnum <CommentTables>()); return(true); } catch (Exception ex) { Log.Error(string.Format("ContentComment DeleteComment({0}, {1})", commentId, commentType), ex); return(false); } }
public static string CheckOfficialAnswer(string contentId, string commentId, string commentType) { try { ContentCommentRepository.UpdateOfficialAnswers(CurrentUser.Instance.SiteID, Guid.Parse(contentId), commentType.ToEnum <CommentTables>()); var guidCommentId = Guid.Parse(commentId); var toUpdatePublicationComment = ContentCommentRepository.SelectById(CurrentUser.Instance.SiteID, guidCommentId, commentType.ToEnum <CommentTables>()); if (toUpdatePublicationComment != null) { toUpdatePublicationComment.IsOfficialAnswer = true; ContentCommentRepository.Update(CurrentUser.Instance.SiteID, toUpdatePublicationComment, commentType.ToEnum <CommentTables>()); } return(string.Empty); } catch (Exception ex) { Log.Error(string.Format("ContentComment CheckOfficialAnswer({0}, {1}, {2})", contentId, commentId, commentType), ex); return("error"); } }
/// <summary> /// Replaces the specified subject. /// </summary> /// <param name="subject">The subject.</param> /// <param name="body">The body.</param> public override void Replace(ref string subject, ref string body) { if (!SiteAction.ObjectID.HasValue) { return; } PortalSettings = DataManager.PortalSettings.SelectMapBySiteId(SiteAction.SiteID, true); ReplaceUserInfo(ref body); if (PortalSettings != null) { PortalLink = DataManager.PortalSettings.SelectPortalLink(PortalSettings.SiteID); RequestLinkTemplate = RequestLinkTemplate.Replace("#PortalLink#", PortalLink); } var invoiceComment = ContentCommentRepository.SelectById(SiteAction.SiteID, (Guid)SiteAction.ObjectID, CommentTables.tbl_InvoiceComment); var invoice = DataManager.Invoice.SelectById(SiteAction.SiteID, invoiceComment.ContentID); if (invoice == null) { return; } subject = subject.Replace("#Invoice.Number#", invoice.Number).Replace("#Invoice.CreatedAt#", invoice.CreatedAt.ToString("dd.MM.yyyy")); body = body.Replace("#Invoice.Number#", invoice.Number).Replace("#Invoice.CreatedAt#", invoice.CreatedAt.ToString("dd.MM.yyyy")).Replace("#Invoice.Comment#", invoiceComment.Comment); if (invoice.BuyerCompanyID.HasValue) { var company = DataManager.Company.SelectById(SiteAction.SiteID, invoice.BuyerCompanyID.Value); subject = subject.Replace("#Invoice.Notification.Company#", company.Name); body = body.Replace("#Invoice.Notification.Company#", company.Name); } else { subject = subject.Replace("#Invoice.Notification.Company#", string.Empty); body = body.Replace("#Invoice.Notification.Company#", string.Empty); } }
public static string UpdateCommentText(string commentId, string commentText, string commentType) { try { var comment = ContentCommentRepository.SelectById(CurrentUser.Instance.SiteID, Guid.Parse(commentId), commentType.ToEnum <CommentTables>()); if (comment != null && comment.SiteID == CurrentUser.Instance.SiteID) { commentText = Sanitizer.GetSafeHtmlFragment(commentText); comment.Comment = commentText; ContentCommentRepository.Update(CurrentUser.Instance.SiteID, comment, commentType.ToEnum <CommentTables>()); return(comment.Comment.ToHtml()); } return(string.Empty); } catch (Exception ex) { Log.Error(string.Format("ContentComment UpdateCommentText({0}, {1}, {2})", commentId, commentText, commentType), ex); return(null); } }