public int Update(CollectTaskInfo taskInfo) { var sqlBuffer = new StringBuilder(); sqlBuffer.Append("UPDATE CollectTasks SET "); sqlBuffer.Append($"Status = {(int)taskInfo.Status}, RetryCount = {taskInfo.RetryCount} "); sqlBuffer.Append($"WHERE Id = {taskInfo.Id}"); return(SqliteProxy.Execute(sqlBuffer.ToString())); }
public int Insert(CollectTaskInfo taskInfo) { var sqlBuffer = new StringBuilder(); sqlBuffer.Append("INSERT INTO CollectTasks (ParentId,CollectId,Uri,ScriptFilePath,Status,RetryCount) "); sqlBuffer.Append($"SELECT {taskInfo.ParentId},{taskInfo.CollectId},'{taskInfo.Uri}','{taskInfo.ScriptFilePath}',{(int)taskInfo.Status},{taskInfo.RetryCount} "); sqlBuffer.Append($"WHERE NOT EXISTS (SELECT * FROM CollectTasks WHERE Uri = '{taskInfo.Uri}')"); return(SqliteProxy.Execute(sqlBuffer.ToString())); }
public object Invoke(CollectInfo collectInfo, CollectTaskInfo taskInfo) { CallContextManager.SetCollectInfo(collectInfo); CallContextManager.SetCollectTaskInfo(taskInfo); var scriptPath = taskInfo != null ? taskInfo.ScriptFilePath : collectInfo.ScriptFilePath; if (this._scriptPath == null || this._scriptPath != scriptPath) { this._scriptPath = scriptPath; this.ScriptEngine.Execute(this.GetInvokeScript()); } return(this.ScriptEngine.Invoke("___func___")); }
/// <summary> /// 创建新任务 /// </summary> /// <param name="task">{ uri:xx,script:xx }</param> public int add(dynamic task) { var collect = CallContextManager.GetCollectInfo(); if (collect == null) { throw new Exception("未能从当前线程上下文中获取对象 ollectInfo"); } var parentTask = CallContextManager.GetCollectTaskInfo(); var newTask = new CollectTaskInfo(); newTask.CollectId = collect.Id; newTask.RetryCount = 0; newTask.ScriptFilePath = task.script; newTask.Status = CollectTaskStatus.None; newTask.Uri = task.uri; if (parentTask != null) { newTask.ParentId = parentTask.Id; newTask.Uri = new Uri(new Uri(parentTask.Uri), newTask.Uri).ToString(); } return(this._taskRepository.Insert(newTask)); }
/// <summary> /// 设置绑定到当前线程上下文的 CollectTaskInfo /// </summary> /// <returns></returns> public static void SetCollectTaskInfo(CollectTaskInfo collectTaskInfo) { CallContext.SetData(KEY_COLLECT_TASK_INFO, collectTaskInfo); }
public void Update(CollectTaskInfo taskInfo) { throw new NotImplementedException(); }
public void Insert(CollectTaskInfo taskInfo) { throw new NotImplementedException(); }