static void Main(string[] args) { //初始化缓存引擎 KVStoreManager.SetEngine(new KVStoreEngine()); while (true) { if (MediaQueueHelper.Instance.ListCount == 0) { Console.WriteLine("========================================================".Log()); Console.WriteLine("正在初始化...".Log()); Console.WriteLine("检查需要被执行的任务...".Log()); var mediaTaskQo = new MediaTaskQO(); mediaTaskQo.Equal(MediaTaskQO.QueryEnums.Disabled, 0); var mediaResult = mediaService.GetMediataskDtosByPara(mediaTaskQo, false); var taskRemainCount = mediaResult != null ? mediaResult.Count : 0; Console.WriteLine($"当前任务数为{taskRemainCount}...".Log()); if (taskRemainCount > 0) { Console.WriteLine("正在将任务添加至队列中....".Log()); mediaResult.ForEach(m => { MediaQueueHelper.Instance.AddQueue(m.Url, m.MediaTaskId); }); Console.WriteLine("添加完成....".Log()); } Console.WriteLine("初始化结束...".Log()); Console.WriteLine("处理队列中....".Log()); MediaQueueHelper.Instance.Start(); Console.WriteLine(Environment.NewLine); Console.WriteLine(Environment.NewLine); } } }
/// <summary> /// 通用查询 /// </summary> /// <param name="queryEntity"></param> /// <param name="isCache"></param> /// <returns>MediaTaskEntity信息列表</returns> public List <MediaTaskEntity> GetMediataskDtosByPara(MediaTaskQO queryEntity, Boolean isCache) { var qm = new QueryHelper(new MediaRepository()); List <Guid> ids = qm.GetGuidIDsByConditions(queryEntity, isCache); if (ids == null || ids.Count == 0) { return(new List <MediaTaskEntity>()); } return(GetMediatasks(ids.ToArray())); }
/// <summary> /// 分页通用查询 /// </summary> /// <param name="queryEntity"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="totalCount"></param> /// <param name="pageCount"></param> /// <param name="isCache"></param> /// <returns>MediaTaskEntity信息列表</returns> public List <MediaTaskEntity> GetMediataskDtosByParaForPage(MediaTaskQO queryEntity, Int32 pageIndex, Int32 pageSize, out Int32 totalCount, out Int32 pageCount, Boolean isCache) { var qm = new QueryHelper(new MediaRepository()); List <Guid> ids = qm.GetGuidIDsByConditions(queryEntity, pageIndex, pageSize, out totalCount, out pageCount, isCache); if (ids == null || ids.Count == 0) { return(new List <MediaTaskEntity>()); } return(GetMediatasks(ids.ToArray())); }
//分析 private async void button1_Click(object sender, EventArgs e) { await System.Threading.Tasks.Task.Run(() => { while (!AnalyCancelToken.IsCancellationRequested) { if (MediaQueueHelper.Instance.ListCount == 0) { Print("正在初始化...".Log()); Print("检查需要被执行的任务...".Log()); var mediaTaskQo = new MediaTaskQO(); mediaTaskQo.Equal(MediaTaskQO.QueryEnums.Disabled, 0); var mediaResult = mediaService.GetMediataskDtosByPara(mediaTaskQo, false); var taskRemainCount = mediaResult != null ? mediaResult.Count : 0; Print($"当前任务数为{taskRemainCount}...".Log()); if (taskRemainCount > 0) { Print("正在将任务添加至队列中....".Log()); mediaResult.ForEach(m => { MediaQueueHelper.Instance.AddQueue(m.Url, m.MediaTaskId); }); Print("添加完成....".Log()); } Print("初始化结束...".Log()); Print("处理队列中....".Log()); MediaQueueHelper.Instance.Start(); Console.WriteLine(Environment.NewLine); } else { if (DefineMessageQueue.ItemQueue.Count > 0) { var message = DefineMessageQueue.OutFromQueue(); Print(message + Environment.NewLine); } } } }, AnalyCancelToken.Token); }