Пример #1
0
        /// <summary>
        /// 获取一个新的文件名,格式({collectId_collectTaskId_fileName})
        /// </summary>
        /// <param name="uri"></param>
        /// <returns></returns>
        public string newFileName(string uri)
        {
            if (string.IsNullOrEmpty(uri))
            {
                return("");
            }
            var idx = uri.LastIndexOf("/");

            if (idx >= 0)
            {
                uri = uri.Substring(idx + 1);
            }
            var collect = CallContextManager.GetCollectInfo();

            if (collect == null)
            {
                throw new Exception("未能从当前线程上下文中获取对象 ollectInfo");
            }
            var task = CallContextManager.GetCollectTaskInfo();

            return($"{collect.Id}_{(task == null ? 0 : task.Id)}_{uri}");
        }
Пример #2
0
        /// <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));
        }