/// <summary> /// 资讯操作日志事件处理 /// </summary> private void RecommendOperationLogEventModule_After(RecommendItem sender, CommonEventArgs eventArgs) { if (eventArgs.EventOperationType == EventOperationType.Instance().Create() || eventArgs.EventOperationType == EventOperationType.Instance().Delete()) { TenantTypeService tenantTypeService = new TenantTypeService(); TenantType tenantType = tenantTypeService.Get(sender.TenantTypeId); if (tenantType == null) return; OperationLogEntry entry = new OperationLogEntry(eventArgs.OperatorInfo); entry.ApplicationId = tenantType.ApplicationId; entry.Source = tenantType.Name; entry.OperationType = eventArgs.EventOperationType; entry.OperationObjectName = sender.ItemName; entry.OperationObjectId = sender.ItemId; entry.Description = string.Format(ResourceAccessor.GetString("OperationLog_Pattern_" + eventArgs.EventOperationType), tenantType.Name + "推荐", entry.OperationObjectName); OperationLogService logService = Tunynet.DIContainer.Resolve<OperationLogService>(); logService.Create(entry); } }
public ActionResult _RecommendItem(string tenantTypeId, long itemId = 0, string itemName = null, string recommendItemTypeId = null, bool showLink = false, long recommendId = 0, bool showInList = true, long userId = 0) { RecommendItem recommendItem = null; if (recommendId > 0) { recommendItem = recommendService.Get(recommendId); if (recommendItem == null) return HttpNotFound(); tenantTypeId = recommendItem.TenantTypeId; itemId = recommendItem.ItemId; recommendItemTypeId = recommendItem.TypeId; ViewData["RecommendTypeName"] = recommendItem.RecommendItemType.Name; ViewData["RecommendTypeId"] = recommendItem.TypeId; } if (!authorizer.RecommendItem_Manage(tenantTypeId)) { return Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Body = "没有管理推荐内容的权限", Title = "没有权限", StatusMessageType = StatusMessageType.Hint })); } IEnumerable<RecommendItemType> itemTypes = recommendService.GetRecommendTypes(tenantTypeId); IEnumerable<RecommendItem> recommendItems = recommendService.Gets(itemId, tenantTypeId); //已修改 RecommendItemEditModel itemEditModel = new RecommendItemEditModel(); ViewData["recommendItems"] = recommendItems; //已修改 ViewData["TypeId"] = new SelectList(itemTypes, "TypeId", "Name", recommendItemTypeId); if (recommendId != 0) { itemEditModel = recommendItem.AsEditModel(); ViewData["HasFeaturedImage"] = recommendItem.RecommendItemType.HasFeaturedImage; } else { if (itemTypes != null && itemTypes.Count() > 0 && string.IsNullOrEmpty(recommendItemTypeId)) { //已修改 recommendItemTypeId = itemTypes.First().TypeId; } if (!string.IsNullOrEmpty(recommendItemTypeId)) { recommendItem = recommendService.Get(itemId, recommendItemTypeId); RecommendItemType recommendType = recommendService.GetRecommendType(recommendItemTypeId); ViewData["HasFeaturedImage"] = recommendType.HasFeaturedImage; ViewData["RecommendTypeName"] = recommendType.Name; ViewData["RecommendTypeId"] = recommendType.TypeId; if (recommendItem != null && !recommendItem.IsLink) { ViewData["ExpiredDate"] = recommendItem.ExpiredDate; itemEditModel = recommendItem.AsEditModel(); } else { RecommendItem newItem = RecommendItem.New(); newItem.ItemName = itemName; newItem.ItemId = itemId; newItem.TenantTypeId = tenantTypeId; newItem.ExpiredDate = DateTime.UtcNow.AddMonths(1); newItem.UserId = userId; itemEditModel = newItem.AsEditModel(); } } else { StatusMessageData message = null; TenantTypeService tenantTypeService = new TenantTypeService(); TenantType tenantType = tenantTypeService.Get(tenantTypeId); if (tenantType == null) { message = new StatusMessageData(StatusMessageType.Hint, "没有推荐类别"); } else { message = new StatusMessageData(StatusMessageType.Hint, tenantType.Name + "下没有推荐类别"); } ViewData["statusMessageData"] = message; } } ViewData["showLink"] = showLink || itemEditModel.IsLink; ViewData["showInList"] = showInList; return View(itemEditModel); }
/// <summary> /// 重建缩略图 /// </summary> /// <returns></returns> public ActionResult RebuildingThumbnails() { IEnumerable<TenantAttachmentSettings> tenantAttachmentSettings = TenantAttachmentSettings.GetAll(); ViewData["TenantAttachmentSettings"] = tenantAttachmentSettings; ViewData["TenantLogoSettings"] = TenantLogoSettings.GetAll(); IStoreProvider storeProvider = DIContainer.Resolve<IStoreProvider>(); string rootPath = WebUtility.GetPhysicalFilePath("~"); string uploadsPath = storeProvider.StoreRootPath; if (storeProvider.StoreRootPath.StartsWith(rootPath)) uploadsPath = uploadsPath.Replace(rootPath, ""); ViewData["uploadsPath"] = uploadsPath; Dictionary<string, string> ApplicationName = new Dictionary<string, string>(); TenantTypeService tenantTypeService = new TenantTypeService(); IEnumerable<TenantType> tenantTypes = tenantTypeService.Gets(null, null); foreach (var item in tenantTypes) { TenantType type = tenantTypeService.Get(item.TenantTypeId); ApplicationName[item.TenantTypeId] = type != null ? type.Name : item.Name; } ViewData["ApplicationName"] = ApplicationName; return View(); }
/// <summary> /// 推荐积分处理 /// </summary> /// <param name="sender">推荐实体</param> /// <param name="eventArgs">事件参数</param> void RecommendPointModule_After(RecommendItem sender, CommonEventArgs eventArgs) { if (eventArgs.EventOperationType != EventOperationType.Instance().Create()) { return; } string pointItemKey = string.Empty; PointService pointService = new PointService(); string description = string.Empty; TenantTypeService tenantTypeService = new TenantTypeService(); var urlGetter = RecommendUrlGetterFactory.Get(sender.TenantTypeId); NoticeService noticeService = new NoticeService(); Notice notice = Notice.New(); notice.TypeId = NoticeTypeIds.Instance().Hint(); //notice.TemplateName = "FollowUser"; notice.UserId = sender.UserId; notice.LeadingActorUserId = sender.ReferrerId; notice.LeadingActor = sender.ReferrerName; notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.ReferrerId)); notice.RelativeObjectId = sender.UserId; notice.RelativeObjectName = sender.ItemName; notice.RelativeObjectUrl = sender.DetailUrl; if (sender.TenantTypeId == TenantTypeIds.Instance().User()) { pointItemKey = PointItemKeys.Instance().RecommendUser(); description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_RecommendUser")); notice.TemplateName = NoticeTemplateNames.Instance().ManagerRecommendedUser(); } else { pointItemKey = PointItemKeys.Instance().RecommendContent(); TenantType tenantType = tenantTypeService.Get(sender.TenantTypeId); if (tenantType == null) return; description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_RecommendContent"), tenantType.Name, sender.ItemName); notice.TemplateName = NoticeTemplateNames.Instance().ManagerRecommended(); } noticeService.Create(notice); pointService.GenerateByRole(sender.UserId, pointItemKey, description); }