/// <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); }
/// <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); RequestLinkTemplate = RequestLinkTemplate.Replace("#PortalLink#", PortalLink); } var request = DataManager.Request.SelectById(SiteAction.SiteID, (Guid)SiteAction.ObjectID); if (request != null) { var serviceLevel = request.tbl_ServiceLevel; tbl_Contact responsible = null; tbl_Contact contact = null; tbl_Company company = null; if (request.ResponsibleID.HasValue) { responsible = DataManager.Contact.SelectById(SiteAction.SiteID, (Guid)request.ResponsibleID); } if (request.ContactID.HasValue) { contact = DataManager.Contact.SelectById(SiteAction.SiteID, (Guid)request.ContactID); } company = request.tbl_Company; subject = ReplaceText(subject, request, serviceLevel, responsible, contact, company); body = ReplaceText(body, request, serviceLevel, responsible, contact, company); if (body.Contains("#Requirement.RegisteredList#")) { var requirements = DataManager.Requirement.SelectByRequestId(request.SiteID, request.ID); ProceedRegisteredRequirements(ref body, requirements); } if (company != null) { body = body.Replace("#Request.Notification.Company#", company.Name); subject = subject.Replace("#Request.Notification.Company#", company.Name); } else { body = body.Replace("#Request.Notification.Company#", string.Empty); subject = subject.Replace("#Request.Notification.Company#", string.Empty); } } var requirement = DataManager.Requirement.SelectById(SiteAction.SiteID, (Guid)SiteAction.ObjectID); if (requirement != null) { var shortDescription = requirement.ShortDescription; var requirementLink = string.Format(RequirementLinkTemplate, requirement.ID); shortDescription = string.Format("<a href='{0}'>{1}</a>", requirementLink, shortDescription); body = body.Replace("#Requirement.ShortDescription#", shortDescription); if (requirement.CompanyID.HasValue) { body = body.Replace("#Requirement.Notification.Company#", requirement.tbl_Company.Name); subject = subject.Replace("#Requirement.Notification.Company#", requirement.tbl_Company.Name); } else { body = body.Replace("#Requirement.Notification.Company#", string.Empty); subject = subject.Replace("#Requirement.Notification.Company#", string.Empty); } } if (((body.Contains("#Requirement.WorkedList#") || body.Contains("#Requirement.CompanyList#") || body.Contains("#Requirement.CompletedList#")) && SiteAction.ContactID.HasValue)) { var serviceLevelContact = DataManager.ServiceLevelContact.SelectById((Guid)SiteAction.ObjectID); if (serviceLevelContact != null) { body = body.Replace("#Requirement.Notification.Company#", serviceLevelContact.tbl_ServiceLevelClient.tbl_Company.Name); subject = subject.Replace("#Requirement.Notification.Company#", serviceLevelContact.tbl_ServiceLevelClient.tbl_Company.Name); var startDate = SiteAction.ActionDate.Date; var endDate = SiteAction.ActionDate.Date; RequestNotificationService.GetDatesRangeByServiceLevelContact(serviceLevelContact, SiteAction.ActionDate.Date, ref startDate, ref endDate); var requirements = new List <tbl_Requirement>(); switch ((ServiceLevelIncludeToInform)serviceLevelContact.IncludeToInformID) { case ServiceLevelIncludeToInform.All: requirements = DataManager.Requirement.SelectAllByCompanyId(serviceLevelContact.tbl_ServiceLevelClient.ClientID, startDate, endDate).ToList(); break; case ServiceLevelIncludeToInform.Personal: requirements = DataManager.Requirement.SelectPersonal(serviceLevelContact.ContactID, startDate, endDate).ToList(); break; } body = body.Replace("#Requirement.CompanyList#", string.Empty); ProceedWorkedRequirements(ref body, requirements.Where(o => !o.tbl_RequirementStatus.IsLast).ToList(), startDate, endDate); ProceedCompletedRequirements(ref body, requirements.Where(o => o.tbl_RequirementStatus.IsLast).ToList()); } } }