/// <summary> /// Convert docx to html by service /// </summary> /// <param name="pageId"></param> /// <param name="content"></param> /// <returns></returns> public string ConvertDocxToHtmlByService(int pageId, byte[] content) { var attachmentPath = _siteSettingService.GetSetting <string>(SettingNames.WordDocUploadsFolderPhysicalPath); var serverMediaFolder = HttpContext.Current.Server.MapPath(Path.Combine(attachmentPath, pageId.ToString(CultureInfo.InvariantCulture))); var pageIdMediaRelativePath = Path.Combine(attachmentPath, pageId.ToString(CultureInfo.InvariantCulture)) + "/"; return(ToHtml(serverMediaFolder, pageIdMediaRelativePath, new MemoryStream(content))); }
/// <summary> /// Get page log model /// </summary> /// <param name="id"></param> /// <param name="total"> </param> /// <param name="index"></param> /// <returns></returns> public WidgetTemplateLogListingModel GetLogs(int id, int total = 0, int index = 1) { var pageSize = _siteSettingService.GetSetting <int>(SettingNames.LogsPageSize); var template = GetById(id); if (template != null) { var logs = template.WidgetTemplateLogs.OrderByDescending(l => l.Created) .GroupBy(l => l.SessionId) .Skip((index - 1) * pageSize) .Take(pageSize) .ToList() .Select(l => new WidgetTemplateLogsModel { SessionId = l.First().SessionId, Creator = new SimpleUserModel(l.First().CreatedBy), From = l.Last().Created, To = l.First().Created, Total = l.Count(), Logs = l.Select(i => new WidgetTemplateLogItem(i)).ToList() }).ToList(); total = total + logs.Sum(l => l.Logs.Count); var model = new WidgetTemplateLogListingModel { Id = template.Id, Name = template.Name, Total = total, Logs = logs, LoadComplete = total == template.WidgetTemplateLogs.Count }; return(model); } return(null); }
/// <summary> /// Replace all widget in the content /// </summary> /// <param name="content"></param> /// <param name="maxLoop"></param> /// <returns></returns> public string Render(string content, int?maxLoop = null) { if (!maxLoop.HasValue) { maxLoop = _siteSettingService.GetSetting <int>(SettingNames.WidgetMaxLoop); } return(content.ResolveContent(maxLoop.Value)); }
/// <summary> /// Render widget /// </summary> /// <param name="parameters"></param> /// <returns></returns> public override string Render(string[] parameters) { var script = string.Empty; if (WorkContext.EnableLiveSiteMode) { script = _siteSettingService.GetSetting <string>(SettingNames.GoogleAnalyticConfiguration); } return(script); }
/// <summary> /// Return the content of RobotsSetting as a file. /// </summary> /// <returns></returns> public ActionResult Robots() { var enableLiveSiteMode = _siteSettingService.GetSetting <bool>(SettingNames.EnableLiveSiteMode); var robotsSetting = _siteSettingService.LoadSetting <RobotsSetting>(); if (enableLiveSiteMode) { return(Content(robotsSetting.LiveSiteModeContent, "text/plain")); } return(Content(robotsSetting.TestSiteModeContent, "text/plain")); }
/// <summary> /// Save document feedback /// </summary> /// <param name="model"></param> /// <returns></returns> public ResponseModel SaveCustomerFeedback(DocumentFeedbackModel model) { if (WorkContext.CurrentUser == null) { throw new EzCMSUnauthorizeException(); } var protectedDocumentEmailTo = _siteSettingService.GetSetting <string>(SettingNames.ProtectedDocumentEmailTo); var emailModel = new ProtectedDocumentEmailModel { Email = WorkContext.CurrentUser.Email, FullName = WorkContext.CurrentUser.FullName, Comment = model.Comment, Path = model.RelativePath }; var emailResponse = _emailTemplateService.ParseEmail(EmailEnums.EmailTemplateType.ProtectedDocumentForm, emailModel); if (emailResponse == null) { return(new ResponseModel { Success = false, Message = T("ProtectedDocument_Message_MissingProtectedDocumentFeedbackEmailTemplate") }); } var emailLog = new EmailLog { To = protectedDocumentEmailTo, ToName = protectedDocumentEmailTo, From = WorkContext.CurrentUser.Email, FromName = WorkContext.CurrentUser.FullName, CC = emailResponse.CC, Bcc = emailResponse.BCC, Subject = emailResponse.Subject, Body = emailResponse.Body, Priority = EmailEnums.EmailPriority.Medium }; var response = _emailLogService.CreateEmail(emailLog, true); return(response.Success ? response.SetMessage(T("ProtectedDocument_Message_FeedbackSuccessfully")) : response.SetMessage(T("ProtectedDocument_Message_FeedbackFailure"))); }
/// <summary> /// Search contacts by keyword /// </summary> /// <param name="keyword"></param> /// <returns></returns> public List <AutoCompleteModel> SearchContacts(string keyword) { var pageSize = _siteSettingService.GetSetting <int>(SettingNames.AutoCompleteSize); return(_contactRepository.Fetch(c => c.Email.Contains(keyword)).Take(pageSize).ToList() .Select(c => new AutoCompleteModel { id = c.Id, value = string.Format("{0} {1} | {2} | {3} | {4}", c.Title, c.FullName, c.Email, c.PreferredPhoneNumber ?? c.PhoneHome ?? c.PhoneWork, c.AddressLine1 ?? c.AddressLine2), label = string.Format("{0} {1} | {2} | {3} | {4}", c.Title, c.FullName, c.Email, c.PreferredPhoneNumber ?? c.PhoneHome ?? c.PhoneWork, c.AddressLine1 ?? c.AddressLine2) }).ToList()); }
public JsonResult GoogleAnalyticApiSetup(GoogleAnalyticApiSetting model) { if (ModelState.IsValid) { var setting = _siteSettingService.GetSetting(model.GetSetup().Name); var manageModel = _siteSettingService.GetSettingManageModel(setting.Id); manageModel.Value = SerializeUtilities.Serialize(model); var response = _siteSettingService.SaveSettingManageModel(manageModel); return(Json(response)); } return(Json(new ResponseModel { Success = false, Message = ModelState.BuildValidationMessages() })); }
public ActionResult Edit(SiteSettingManageModel model, SubmitType submit) { if (ModelState.IsValid) { var setting = _siteSettingService.GetSetting(model.SettingName); var updateSuccess = true; var settingParser = HostContainer.GetInstances <IComplexSetting>().FirstOrDefault(parser => parser.GetSetup().Name.Equals(setting.Name)); if (settingParser != null) { if (TryUpdateModel((dynamic)settingParser)) { model.Value = SerializeUtilities.Serialize(settingParser); } else { updateSuccess = false; } } if (updateSuccess) { var response = _siteSettingService.SaveSettingManageModel(model); SetResponseMessage(response); if (response.Success) { switch (submit) { case SubmitType.Save: return(RedirectToAction("Index")); default: return(RedirectToAction("Edit", new { id = model.Id })); } } } SetErrorMessage(T("SiteSetting_Message_UpdateFailure")); return(RedirectToAction("Edit", new { id = model.Id })); } return(View(model)); }
/// <summary> /// Load setting by key and parsing to type /// </summary> /// <typeparam name="T"></typeparam> /// <param name="key"></param> /// <returns></returns> public T SValue <T>(string key) { return(_siteSettingService.GetSetting <T>(key)); }