public IActionResult Post([FromBody] TopicFormModel model) { if (!_topicPermissions.IsAllowedToCreate(User.Identity.GetUserIdentity())) { return(Forbidden()); } if (ModelState.IsValid) { if (!TopicStatus.IsStatusValid(model.Status)) { ModelState.AddModelError("Status", "Invalid Topic Status"); } else { var result = _topicManager.AddTopic(User.Identity.GetUserIdentity(), model); if (result.Success) { return(Ok(result)); } } } return(BadRequest(ModelState)); }
/// <summary> /// 批量修改文章状态 /// </summary> /// <param name="?"></param> /// <param name="status"></param> /// <param name="user"></param> /// <returns></returns> public static bool BatchUpdateTopicStatus(List <int> topicSysNoList, TopicStatus status, CurrentUser user) { //AjaxResult ajaxResult = new AjaxResult() { Success = true, Message = string.Empty }; List <TopicInfo> topicList = new List <TopicInfo>(); #region check foreach (int topicSysNo in topicSysNoList) { var topic = LoadTopicInfoBySysNo(topicSysNo); if (status == TopicStatus.Published && topic.TopicStatus != TopicStatus.Init && topic.TopicStatus != TopicStatus.Offline) { throw new BusinessException(LangHelper.GetText("只有草稿和撤下状态才能发布!")); //ajaxResult.Success = false; //ajaxResult.Message = "只有草稿和撤下状态才能发布!"; //return ajaxResult; } if (status == TopicStatus.Void && topic.TopicStatus != TopicStatus.Init && topic.TopicStatus != TopicStatus.Offline) { throw new BusinessException(LangHelper.GetText("只有草稿和撤下状态才能作废!")); //ajaxResult.Success = false; //ajaxResult.Message = "只有草稿和撤下状态才能发布!"; //return ajaxResult; } if (status == TopicStatus.Delete && topic.TopicStatus != TopicStatus.Init && topic.TopicStatus != TopicStatus.Offline && topic.TopicStatus != TopicStatus.Void) { throw new BusinessException(LangHelper.GetText("只有草稿,撤下以及作废状态才能删除!")); //ajaxResult.Success = false; //ajaxResult.Message = "只有草稿和撤下状态才能发布!"; //return ajaxResult; } topicList.Add(new TopicInfo() { SysNo = topicSysNo, TopicStatus = status, EditUserSysNo = user.UserSysNo, EditUserName = user.UserDisplayName, EditDate = DateTime.Now }); } #endregion using (ITransaction transaction = TransactionManager.Create()) { foreach (var topic in topicList) { if (status == TopicStatus.Published) { TopicDA.PublishTopic(topic); } else { TopicDA.UpdateTopicStatus(topic); } } transaction.Complete(); } return(true); }
public IActionResult ChangeStatus([FromRoute] int topicId, [FromBody] TopicStatus topicStatus) { if (!_topicPermissions.IsAssociatedTo(User.Identity.GetUserIdentity(), topicId)) { return(Forbidden()); } if (!_topicManager.IsValidTopicId(topicId)) { return(NotFound()); } if (!topicStatus.IsStatusValid()) { ModelState.AddModelError("status", "Invalid Status"); return(BadRequest(ModelState)); } if (topicStatus.IsDone() && _topicManager.GetReviews(topicId).Any(r => !r.Status.IsReviewed())) { return(Conflict()); } if (_topicManager.ChangeTopicStatus(User.Identity.GetUserIdentity(), topicId, topicStatus.Status)) { return(Ok()); } return(NotFound()); }
public static string ToString(this TopicStatus status) { switch (status) { case TopicStatus.NotApproved: { return("Не проверен"); } case TopicStatus.Approved: { return("Проверен"); } case TopicStatus.Deleted: { return("Удален"); } case TopicStatus.Archive: { return("В архиве"); } case TopicStatus.Draft: default: { return("Черновик"); } } }
public TopicOperationResult ChangeTopicStatus(int topicId, TopicStatus status) { return(new TopicOperationResult() { IsSucceed = RandomHelper.Bool(), ErrorMessage = "gaga" }); }
public virtual DataPage <ForumPost> GetPageList(int topicId, int pageSize, int memberId) { if (memberId > 0) { return(db.findPage <ForumPost>("TopicId=" + topicId + " and Creator.Id=" + memberId + " and " + TopicStatus.GetShowCondition() + " order by Id asc", pageSize)); } return(db.findPage <ForumPost>("TopicId=" + topicId + " and " + TopicStatus.GetShowCondition() + " order by Id asc", pageSize)); }
public UserTopic(Guid UserId, Guid TopicId, TopicStatus Status) { this.UserTopicID = Guid.NewGuid(); this.UserId = UserId; this.TopicId = TopicId; this.Status = Status; this.CreatedDate = DateTime.UtcNow; }
public virtual int GetPageCount(int topicId, int pageSize) { String strCondition = "TopicId=" + topicId + " and " + TopicStatus.GetShowCondition(); int count = ForumPost.count(strCondition); int page = count / pageSize; int imod = count % pageSize; return(imod > 0 ? page + 1 : page); }
public virtual List <ForumTopic> GetByAppAndReplies(int appId, int count, int days) { EntityInfo ei = Entity.GetInfo(typeof(User)); String t = ei.Dialect.GetTimeQuote(); String fs = " and Created between " + t + "{0}" + t + " and " + t + "{1}" + t + " "; DateTime now = DateTime.Now; String dc = string.Format(fs, now.AddDays(-days + 1).ToShortDateString(), now.AddDays(1).ToShortDateString()); // 加1表示包含今天 return(ForumTopic.find("AppId=" + appId + " and " + TopicStatus.GetShowCondition() + dc + " order by Replies desc, Id desc").list(count)); }
private List <IBinderValue> getNewTopic(int count, Type ownerType) { if (count <= 0) { count = 10; } List <ForumTopic> list = db.find <ForumTopic>(TopicStatus.GetShowCondition() + " and OwnerType=:otype order by Id desc") .set("otype", ownerType.FullName) .list(count); return(SysForumTopicService.populateBinderValue(list)); }
public TopicsControllerTest() { _tester = new ControllerTester <TopicsController>(); TopicFormModel = new TopicFormModel { Title = "Schloss Neuhaus", Status = "InReview", Description = "Castle" }; TopicStatus = new TopicStatus { Status = "InProgress" }; }
public ForumTopicInfo(int id, string title, TopicStatus topicStatus, User?author, ApproximateSize?size, int?seedsCount, int?leechesCount, int repliesCount, int?downloadsCount, DateTime lastMessageAt, User?lastMessageUser) { Id = id; Title = title; TopicStatus = topicStatus; Author = author; Size = size; SeedsCount = seedsCount; LeechesCount = leechesCount; RepliesCount = repliesCount; DownloadsCount = downloadsCount; LastMessageAt = lastMessageAt; LastMessageUser = lastMessageUser; }
public SearchTopicInfo(int id, string title, TopicStatus topicStatus, Forum forum, IReadOnlyList <string> tags, User?author, long sizeInBytes, int seedsCount, int leechesCount, int downloadsCount, DateTime createdAt) { Id = id; Title = title; TopicStatus = topicStatus; Forum = forum; Tags = tags; Author = author; SizeInBytes = sizeInBytes; SeedsCount = seedsCount; LeechesCount = leechesCount; DownloadsCount = downloadsCount; CreatedAt = createdAt; }
private List <IBinderValue> getNewPost(int boardId, int count, Type ownerType) { if (count <= 0) { count = 10; } String bd = boardId > 0 ? " and ForumBoardId=" + boardId : ""; List <ForumPost> list = db.find <ForumPost>(TopicStatus.GetShowCondition() + bd + " and OwnerType=:otype order by Id desc") .set("otype", ownerType.FullName) .list(count); return(populateBinderValue(list)); }
// TODO: Consider moving SetUserTopic to TopicService. private void SetUserTopic(Guid UserId, Guid TopicId, TopicStatus topicStatus) { if (UserId == this.Actor.UserId || this.Actor.Roles.Contains("Admin")) { var dbUserTopic = TopicService.GetUserTopics(UserId, TopicId).FirstOrDefault(); if (dbUserTopic == null) { var newUserTopic = new UserTopic(UserId, TopicId, topicStatus); this.mainContext.UserTopics.Add(newUserTopic); } this.mainContext.SaveChanges(); } }
/// <summary> /// Gets the topics for a given site and status from the db. /// </summary> /// <param name="readerCreator"></param> /// <param name="siteId"></param> /// <param name="status"></param> /// <returns></returns> static public TopicElementList GetTopicListFromDatabase(IDnaDataReaderCreator readerCreator, int siteId, TopicStatus status, bool includeArchived) { var topicList = new TopicElementList{Status = status}; using (var reader = readerCreator.CreateDnaDataReader("gettopicsforsiteid2")) { reader.AddParameter("isiteid", siteId); reader.AddParameter("itopicstatus", (int)status); reader.AddParameter("includearchived", includeArchived ? 1 : 0); reader.Execute(); while(reader.Read()) { topicList.Topics.Add(TopicElement.GetTopicFromReader(reader)); } } return topicList; }
public virtual List <IBinderValue> GetNewBoardTopic(String ids, int count) { if (count <= 0) { count = 10; } String sids = checkIds(ids); if (strUtil.IsNullOrEmpty(sids)) { return(new List <IBinderValue>()); } String bd = " and ForumBoardId in ( " + sids + " )"; List <ForumTopic> list = db.find <ForumTopic>(TopicStatus.GetShowCondition() + bd + " and OwnerType=:otype order by Id desc") .set("otype", typeof(Site).FullName) .list(count); return(SysForumTopicService.populateBinderValue(list)); }
public virtual void UpdateLastInfo(ForumBoard fb) { ForumTopic topic = ForumTopic .find("ForumBoardId=" + fb.Id + " and " + TopicStatus.GetShowCondition() + " order by Id desc") .first(); LastUpdateInfo info = new LastUpdateInfo(); info.PostId = topic.Id; info.PostType = typeof(ForumTopic).Name; info.PostTitle = topic.Title; User user = topic.Creator; info.CreatorName = user.Name; info.CreatorUrl = user.Url; info.UpdateTime = topic.Created; fb.LastUpdateInfo = info; fb.Updated = info.UpdateTime; db.update(fb); }
public virtual List <ForumTopic> GetByAppAndViews(int appId, int count) { return(ForumTopic.find("AppId=" + appId + " and " + TopicStatus.GetShowCondition() + " order by Hits desc, Id desc").list(count)); }
public virtual DataPage <ForumTopic> GetPickedByApp(int appId, int pageSize) { return(ForumTopic.findPage("AppId=" + appId + " and IsPicked=1 and " + TopicStatus.GetShowCondition(), pageSize)); }
private FrontPageTopicElementList GenerateFrontPageTopicElementListObj(TopicStatus status, DateTime lastUpdated) { var frontPageTopicElementList = new FrontPageTopicElementList() { Status = status, LastUpdated = lastUpdated }; frontPageTopicElementList.Topics.Add(new FrontPageElement() { Title = "test" }); return frontPageTopicElementList; }
public virtual DataPage <ForumTopic> GetByUserAndApp(int appId, int userId, int pageSize) { if (userId <= 0 || appId <= 0) { return(DataPage <ForumTopic> .GetEmpty()); } return(ForumTopic.findPage("AppId=" + appId + " and CreatorId=" + userId + " and " + TopicStatus.GetShowCondition(), pageSize)); }
public virtual DataPage <ForumTopic> GetByUser(int userId, int pageSize) { if (userId <= 0) { return(DataPage <ForumTopic> .GetEmpty()); } return(ForumTopic.findPage("CreatorId=" + userId + " and OwnerType='" + typeof(Site).FullName + "' and " + TopicStatus.GetShowCondition(), pageSize)); }
public virtual int GetPostPage(int postId, int topicId, int pageSize) { int count = ForumPost.count("Id<=" + postId + " and TopicId=" + topicId + " and " + TopicStatus.GetShowCondition()); return(getPage(count, pageSize)); }
public virtual List <ForumTopic> GetByApp(int appId, int count) { return(ForumTopic.find("AppId=" + appId + " and " + TopicStatus.GetShowCondition()).list(count)); }
//-------------------------------------------------------------------------------- public virtual DataPage <ForumTopic> Search(int appId, string key, int pageSize) { if (strUtil.IsNullOrEmpty(key)) { return(DataPage <ForumTopic> .GetEmpty()); } String q = strUtil.SqlClean(key, 10); return(ForumTopic.findPage("AppId=" + appId + " and Title like '%" + q + "%' and " + TopicStatus.GetShowCondition(), pageSize)); }
public virtual int GetBoardPage(int topicId, int boardId, int pageSize) { int count = ForumTopic.count("Id>=" + topicId + " and ForumBoardId=" + boardId + " and " + TopicStatus.GetShowCondition()); return(getPage(count, pageSize)); }
public void CreateDb() { TraceEvent teDebug = CreateEvent(TraceEventType.Debug, "Debug"); TraceEvent teActivity = CreateEvent(TraceEventType.Activity, "Activity"); TraceEvent teInfo = CreateEvent(TraceEventType.Info, "Info"); TraceEvent teError = CreateEvent(TraceEventType.Error, "Error"); uow.TraceEvents.Insert(teDebug); uow.TraceEvents.Insert(teActivity); uow.TraceEvents.Insert(teInfo); uow.TraceEvents.Insert(teError); WorkflowStatus wsInProgress = CreateStatus(WorkflowStatusType.InProgress, "InProgress"); WorkflowStatus wsCompleted = CreateStatus(WorkflowStatusType.Completed, "Completed"); WorkflowStatus wsAborted = CreateStatus(WorkflowStatusType.Aborted, "Aborted"); WorkflowStatus wsTerminated = CreateStatus(WorkflowStatusType.Terminated, "Terminated"); uow.WorkflowStatuses.Insert(wsInProgress); uow.WorkflowStatuses.Insert(wsCompleted); uow.WorkflowStatuses.Insert(wsAborted); uow.WorkflowStatuses.Insert(wsTerminated); SketchStatus skSaved = CreateSketchStatus("Saved", "Sketch Saved"); SketchStatus skDeployedDev = CreateSketchStatus("DeployedDev", "Deployed to dev"); SketchStatus skDeployedProd = CreateSketchStatus("DeployedProd", "Deployed to prod"); SketchStatus skSentToSketch = CreateSketchStatus("SentToSketch", "Sent To Sketch"); SketchStatus skAborted = CreateSketchStatus("Aborted", "Abort workflow deployment"); uow.SketchStatuses.Insert(skSaved); uow.SketchStatuses.Insert(skDeployedDev); uow.SketchStatuses.Insert(skDeployedProd); uow.SketchStatuses.Insert(skSentToSketch); uow.SketchStatuses.Insert(skAborted); WorkflowCode wc1 = CreateWorkflowCode("SampleWf1", "this is a sample wf code for testing (1)"); uow.WorkflowCodes.Insert(wc1); WorkflowConfiguration wfc1 = CreateWorkflowConfiguration(wc1, "BasicHttpBinding_FlowTasks", "", ""); uow.WorkflowConfigurations.Insert(wfc1); WorkflowCode wc2 = CreateWorkflowCode("SampleWf2", "this is a sample wf code for testing (2)"); uow.WorkflowCodes.Insert(wc2); WorkflowConfiguration wfc2 = CreateWorkflowConfiguration(wc2, "BasicHttpBinding_IFlowTasksOperations2", "http://localhost/Flow.Tasks.Workflows/SampleWf2.xamlx", "BasicHttpBinding_FlowTasks"); uow.WorkflowConfigurations.Insert(wfc2); WorkflowCode wc3 = CreateWorkflowCode("SampleWf3", "this is a sample wf code for testing (3)"); uow.WorkflowCodes.Insert(wc3); WorkflowConfiguration wfc3 = CreateWorkflowConfiguration(wc3, "BasicHttpBinding_IFlowTasksOperations3", "http://localhost/Flow.Tasks.Workflows/SampleWf3.xamlx", "BasicHttpBinding_FlowTasks"); uow.WorkflowConfigurations.Insert(wfc3); WorkflowCode wc4 = CreateWorkflowCode("SampleWf4", "this is a sample wf code for testing (4)"); uow.WorkflowCodes.Insert(wc4); WorkflowConfiguration wfc4 = CreateWorkflowConfiguration(wc4, "BasicHttpBinding_IFlowTasksOperations4", "http://localhost/Flow.Tasks.Workflows/SampleWf4.xamlx", "BasicHttpBinding_FlowTasks"); uow.WorkflowConfigurations.Insert(wfc4); WorkflowCode wc5 = CreateWorkflowCode("SampleWf5", "this is a sample wf code for testing (5)"); uow.WorkflowCodes.Insert(wc5); WorkflowConfiguration wfc5 = CreateWorkflowConfiguration(wc5, "BasicHttpBinding_IFlowTasksOperations5", "http://localhost/Flow.Tasks.Workflows/SampleWf5.xamlx", "BasicHttpBinding_FlowTasks"); uow.WorkflowConfigurations.Insert(wfc5); WorkflowCode wc6 = CreateWorkflowCode("SampleWf6", "this is a sample wf code for testing (6)"); uow.WorkflowCodes.Insert(wc6); WorkflowConfiguration wfc6 = CreateWorkflowConfiguration(wc6, "BasicHttpBinding_IFlowTasksOperations6", "http://localhost/Flow.Tasks.Workflows/SampleWf6.xamlx", "BasicHttpBinding_FlowTasks"); uow.WorkflowConfigurations.Insert(wfc6); WorkflowCode wc7 = CreateWorkflowCode("SampleWf7", "this is a sample wf code for testing (7)"); uow.WorkflowCodes.Insert(wc7); WorkflowConfiguration wfc7 = CreateWorkflowConfiguration(wc7, "BasicHttpBinding_IFlowTasksOperations7", "http://localhost/Flow.Tasks.Workflows/SampleWf7.xamlx", "BasicHttpBinding_FlowTasks"); uow.WorkflowConfigurations.Insert(wfc7); WorkflowCode wc8 = CreateWorkflowCode("SampleWf8", "this is a sample wf code for testing (8)"); uow.WorkflowCodes.Insert(wc8); WorkflowConfiguration wfc8 = CreateWorkflowConfiguration(wc8, "BasicHttpBinding_IFlowTasksOperations8", "http://localhost/ServiceWorkflowsVB/SampleWf8.xamlx", "BasicHttpBinding_FlowTasks"); uow.WorkflowConfigurations.Insert(wfc8); WorkflowCode wc9 = CreateWorkflowCode("SampleWf9", "this is a sample wf code for testing (9)"); uow.WorkflowCodes.Insert(wc9); WorkflowConfiguration wfc9 = CreateWorkflowConfiguration(wc9, "BasicHttpBinding_IFlowTasksOperations9", "http://localhost/ServiceWorkflowsVB/SampleWf9.xamlx", "BasicHttpBinding_FlowTasks"); uow.WorkflowConfigurations.Insert(wfc9); // Topic TopicStatus topicNew = CreateTopicStatus("New", "New topic message"); TopicStatus topicRead = CreateTopicStatus("Read", "Read topic message"); uow.TopicStatuses.Insert(topicNew); uow.TopicStatuses.Insert(topicRead); }
public virtual int CountTopic(int forumBoardId) { return(db.find <ForumTopic>("ForumBoardId=" + forumBoardId + " and " + TopicStatus.GetShowCondition()).count()); }
internal void EventHandler(IntPtr EventPtr, IntPtr arg) { const uint topicTrigger = (uint)(V_EVENT.INCONSISTENT_TOPIC | V_EVENT.ALL_DATA_DISPOSED); const uint writerTrigger = (uint)(V_EVENT.OFFERED_DEADLINE_MISSED | V_EVENT.LIVELINESS_LOST | V_EVENT.OFFERED_INCOMPATIBLE_QOS | V_EVENT.PUBLICATION_MATCHED); const uint readerTrigger = (uint)(V_EVENT.SAMPLE_REJECTED | V_EVENT.LIVELINESS_CHANGED | V_EVENT.SAMPLE_LOST | V_EVENT.REQUESTED_DEADLINE_MISSED | V_EVENT.REQUESTED_INCOMPATIBLE_QOS | V_EVENT.SUBSCRIPTION_MATCHED); // The DATA_AVAILABLE and DATA_ON_READERS events are left out of the readerTrigger because // they don't have a v_readerStatus that has to be copied. Debug.Assert(EventPtr != IntPtr.Zero); v_listenerEvent listenerEvent = Marshal.PtrToStructure(EventPtr, listenerEventType) as v_listenerEvent; if (listenerEvent.kind == (uint)V_EVENT.TRIGGER) { // Nothing to deliver, so ignore. return; } ListenerEvent ev = new ListenerEvent(listenerEvent.kind); ev.Source = SacsSuperClass.fromUserData(listenerEvent.source) as Entity; if (ev.Source == null) { // Apparently the Source Entity has already been deleted. return; } if ((listenerEvent.kind & (uint)(V_EVENT.OBJECT_DESTROYED | V_EVENT.PREPARE_DELETE)) == 0) { ev.Target = SacsSuperClass.fromUserData(listenerEvent.userData) as Entity; if (listenerEvent.eventData != IntPtr.Zero) { if ((listenerEvent.kind & topicTrigger) != 0) { v_topicStatus vTopicStatus = (v_topicStatus)Marshal.PtrToStructure(listenerEvent.eventData, typeof(v_topicStatus)) as v_topicStatus; TopicStatus topicStatus = new TopicStatus(); vTopicStatusMarshaler.CopyOut(ref vTopicStatus, topicStatus); ev.Status = topicStatus; } else if ((listenerEvent.kind & writerTrigger) != 0) { v_writerStatus vWriterStatus = (v_writerStatus)Marshal.PtrToStructure(listenerEvent.eventData, typeof(v_writerStatus)) as v_writerStatus; WriterStatus writerStatus = new WriterStatus(); vWriterStatusMarshaler.CopyOut(ref vWriterStatus, writerStatus); ev.Status = writerStatus; } else if ((listenerEvent.kind & readerTrigger) != 0) { v_readerStatus vReaderStatus = (v_readerStatus)Marshal.PtrToStructure(listenerEvent.eventData, typeof(v_readerStatus)) as v_readerStatus; ReaderStatus readerStatus = new ReaderStatus(); vReaderStatusMarshaler.CopyOut(ref vReaderStatus, readerStatus); ev.Status = readerStatus; } else { v_status vStatus = (v_status)Marshal.PtrToStructure(listenerEvent.eventData, typeof(v_status)) as v_status; EntityStatus status = new EntityStatus(); vStatusMarshaler.CopyOut(ref vStatus, status); ev.Status = status; } } else { ev.Status = null; } } Events.Add(ev); }
public virtual int CountPost(long forumBoardId) { return(db.find <ForumPost>("ForumBoardId=" + forumBoardId + " and " + TopicStatus.GetShowCondition()).count()); }
public virtual DataPage <ForumPost> GetPageByApp(int appId, int pageSize) { return(db.findPage <ForumPost>("AppId=" + appId + " and " + TopicStatus.GetShowCondition(), pageSize)); }