예제 #1
0
        public async Task <ResponseMessage <TaskContentResponse> > AddTaskWithoutPolicy([FromBody, BindRequired] TaskInfoRequest task)
        {
            var Response = new ResponseMessage <TaskContentResponse>();

            if (task == null)
            {
                Response.Code = ResponseCodeDefines.ModelStateInvalid;
                Response.Msg  = "请求参数不正确";
            }
            try
            {
                Response.Ext = await _taskManage.AddTaskWithoutPolicy(task, string.Empty, string.Empty, string.Empty, string.Empty);

                //添加后如果开始时间在2分钟以内,需要调度一次
                if ((DateTimeFormat.DateTimeFromString(task.TaskContent.Begin) - DateTime.Now).TotalSeconds < 120)
                {
                    await _taskManage.UpdateComingTasks();
                }

                var _globalinterface = ApplicationContext.Current.ServiceProvider.GetRequiredService <IIngestGlobalInterface>();
                if (_globalinterface != null)
                {
                    GlobalInternals re = new GlobalInternals()
                    {
                        funtype = IngestDBCore.GlobalInternals.FunctionType.SetGlobalState, State = GlobalStateName.ADDTASK
                    };
                    var response1 = await _globalinterface.SubmitGlobalCallBack(re);

                    if (response1.Code != ResponseCodeDefines.SuccessCode)
                    {
                        Logger.Error("SetGlobalState modtask error");
                    }
                }

                //SetGTMTaskInfo
                //添加后如果开始时间在2分钟以内,需要调度一次
                //这玩意我完全不知道有啥,放弃,后面改
                //if ((GlobalFun.DateTimeFromString(pIn.taskAdd.strBegin) - DateTime.Now).TotalSeconds < 120)
                //    TASKSERVICE.UpdateComingTasks();
            }
            catch (Exception e)
            {
                if (e.GetType() == typeof(SobeyRecException))//sobeyexcep会自动打印错误
                {
                    SobeyRecException se = e as SobeyRecException;
                    Response.Code = se.ErrorCode.ToString();
                    Response.Msg  = se.Message;
                }
                else
                {
                    Response.Code = ResponseCodeDefines.ServiceError;
                    Response.Msg  = "AddTaskWithoutPolicy error info:" + e.ToString();
                    Logger.Error(Response.Msg);
                }
            }
            return(Response);
        }
예제 #2
0
        public async Task <ResponseMessage <TaskContentResponse> > ModifyTask([FromQuery, BindRequired] int taskid, [FromBody, BindRequired] TaskContentRequest req)
        {
            var Response = new ResponseMessage <TaskContentResponse>();

            if (req == null)
            {
                Response.Code = ResponseCodeDefines.ModelStateInvalid;
                Response.Msg  = "请求参数不正确";
            }

            try
            {
                Response.Ext = await _taskManage.ModifyTask <TaskContentResponse>(req, string.Empty, string.Empty, string.Empty, string.Empty);

                //添加后如果开始时间在2分钟以内,需要调度一次
                if ((DateTimeFormat.DateTimeFromString(req.Begin) - DateTime.Now).TotalSeconds < 120)
                {
                    await _taskManage.UpdateComingTasks();
                }

                var _globalinterface = ApplicationContext.Current.ServiceProvider.GetRequiredService <IIngestGlobalInterface>();
                if (_globalinterface != null)
                {
                    GlobalInternals re = new GlobalInternals()
                    {
                        funtype = IngestDBCore.GlobalInternals.FunctionType.SetGlobalState, State = GlobalStateName.MODTASK
                    };
                    var response1 = await _globalinterface.SubmitGlobalCallBack(re);

                    if (response1.Code != ResponseCodeDefines.SuccessCode)
                    {
                        Logger.Error("SetGlobalState modtask error");
                    }
                }
            }
            catch (Exception e)
            {
                if (e.GetType() == typeof(SobeyRecException))//sobeyexcep会自动打印错误
                {
                    SobeyRecException se = e as SobeyRecException;
                    Response.Code = se.ErrorCode.ToString();
                    Response.Msg  = se.Message;
                }
                else
                {
                    Response.Code = ResponseCodeDefines.ServiceError;
                    Response.Msg  = "TaskIDByTaskGUID error info:" + e.ToString();
                    Logger.Error(Response.Msg);
                }
            }
            return(Response);
        }
예제 #3
0
        public async Task <PostModifyTaskDb_OUT> PostModifyTaskDb([FromBody] PostModifyTaskDb_IN pIn)
        {
            var Response = new PostModifyTaskDb_OUT
            {
                bRet   = true,
                errStr = "OK"
            };

            try
            {
                await _taskManage.ModifyTask <TaskContent>(pIn.taskModify, string.Empty, pIn.TaskMetaData, pIn.MaterialMetaData, string.Empty);

                //添加后如果开始时间在2分钟以内,需要调度一次
                if ((DateTimeFormat.DateTimeFromString(pIn.taskModify.strBegin) - DateTime.Now).TotalSeconds < 120)
                {
                    await _taskManage.UpdateComingTasks();
                }

                var _globalinterface = ApplicationContext.Current.ServiceProvider.GetRequiredService <IIngestGlobalInterface>();
                if (_globalinterface != null)
                {
                    GlobalInternals re = new GlobalInternals()
                    {
                        funtype = IngestDBCore.GlobalInternals.FunctionType.SetGlobalState, State = GlobalStateName.MODTASK
                    };
                    var response1 = await _globalinterface.SubmitGlobalCallBack(re);

                    if (response1.Code != ResponseCodeDefines.SuccessCode)
                    {
                        Logger.Error("SetGlobalState modtask error");
                    }
                }

                return(Response);
            }
            catch (Exception e)
            {
                if (e.GetType() == typeof(SobeyRecException))//sobeyexcep会自动打印错误
                {
                    SobeyRecException se = e as SobeyRecException;
                    Response.errStr = se.ErrorCode.ToString();
                }
                else
                {
                    Response.errStr = "error info:" + e.ToString();
                    Logger.Error("GetAllChannelCapturingTask" + e.ToString());
                }
                return(Response);
            }
            return(Response);
        }
예제 #4
0
        public async Task <GroupTaskParam_OUT> DeleteGroupTaskById([FromQuery] int nTaskID)
        {
            var Response = new GroupTaskParam_OUT
            {
                bRet   = true,
                errStr = "OK"
            };

            if (nTaskID < 1)
            {
                Response.bRet = false;
                return(Response);
            }
            try
            {
                Response.taskResults = await _taskManage.DeleteGroupTaskAsync(nTaskID);

                var _globalinterface = ApplicationContext.Current.ServiceProvider.GetRequiredService <IIngestGlobalInterface>();
                if (_globalinterface != null)
                {
                    GlobalInternals re = new GlobalInternals()
                    {
                        funtype = IngestDBCore.GlobalInternals.FunctionType.SetGlobalState, State = GlobalStateName.MODTASK
                    };
                    var response1 = await _globalinterface.SubmitGlobalCallBack(re);

                    if (response1.Code != ResponseCodeDefines.SuccessCode)
                    {
                        Logger.Error("SetGlobalState modtask error");
                    }
                }

                return(Response);
            }
            catch (Exception e)
            {
                Response.bRet = false;
                if (e.GetType() == typeof(SobeyRecException))//sobeyexcep会自动打印错误
                {
                    SobeyRecException se = e as SobeyRecException;
                    Response.errStr = se.ErrorCode.ToString();
                }
                else
                {
                    Response.errStr = "DeleteGroupTaskById error info:" + e.ToString();
                    Logger.Error(Response.errStr);
                }
                return(Response);
            }
        }
예제 #5
0
        public async Task <ResponseMessage <List <int> > > DeleteGroupTask([FromRoute, BindRequired] int taskid)
        {
            var Response = new ResponseMessage <List <int> >();

            if (taskid < 1)
            {
                Response.Code = ResponseCodeDefines.ModelStateInvalid;
                Response.Msg  = "请求参数不正确";
            }
            try
            {
                Response.Ext = await _taskManage.DeleteGroupTaskAsync(taskid);

                var _globalinterface = ApplicationContext.Current.ServiceProvider.GetRequiredService <IIngestGlobalInterface>();
                if (_globalinterface != null)
                {
                    GlobalInternals re = new GlobalInternals()
                    {
                        funtype = IngestDBCore.GlobalInternals.FunctionType.SetGlobalState, State = GlobalStateName.MODTASK
                    };
                    var response1 = await _globalinterface.SubmitGlobalCallBack(re);

                    if (response1.Code != ResponseCodeDefines.SuccessCode)
                    {
                        Logger.Error("SetGlobalState modtask error");
                    }
                }
            }
            catch (Exception e)
            {
                if (e.GetType() == typeof(SobeyRecException))//sobeyexcep会自动打印错误
                {
                    SobeyRecException se = e as SobeyRecException;
                    Response.Code = se.ErrorCode.ToString();
                    Response.Msg  = se.Message;
                }
                else
                {
                    Response.Code = ResponseCodeDefines.ServiceError;
                    Response.Msg  = "DeleteGroupTask error info:" + e.ToString();
                    Logger.Error(Response.Msg);
                }
            }
            return(Response);
        }
        public async Task <ResponseMessage> SubmitGlobalCallBack(GlobalInternals examineResponse)
        {
            using (var scope = ApplicationContext.Current.ServiceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                var reqService = scope.ServiceProvider.GetRequiredService <GlobalController>();

                switch (examineResponse.funtype)
                {
                case FunctionType.SetGlobalState:
                    return(await reqService.SetGlobalState(examineResponse.State));

                default:
                    break;
                }
                //var response = await scope.ServiceProvider.GetRequiredService<GlobalController>()
                //    .SubmitGlobalCallback();

                //return Mapper.Map<ResponseMessage>(response);
            }

            return(null);
        }
 public async Task <ResponseMessage> GetGlobalCallBack(GlobalInternals examineResponse)
 {
     throw new NotImplementedException();
 }
예제 #8
0
        public async Task <ModifyTask_out> ModifyTask([FromBody] ModifyTask_in pIn)
        {
            var Response = new ModifyTask_out
            {
                bRet   = true,
                errStr = "OK"
            };

            try
            {
                string CaptureMeta  = string.Empty;
                string ContentMeta  = string.Empty;
                string MatiralMeta  = string.Empty;
                string PlanningMeta = string.Empty;
                foreach (var item in pIn.metadatas)
                {
                    if (item.emtype == MetaDataType.emCapatureMetaData)
                    {
                        CaptureMeta = item.strMetadata;
                    }
                    else if (item.emtype == MetaDataType.emStoreMetaData)
                    {
                        MatiralMeta = item.strMetadata;
                    }
                    else if (item.emtype == MetaDataType.emContentMetaData)
                    {
                        ContentMeta = item.strMetadata;
                    }
                    else if (item.emtype == MetaDataType.emPlanMetaData)
                    {
                        PlanningMeta = item.strMetadata;
                    }
                }

                await _taskManage.ModifyTask <TaskContent>(pIn.taskModify, CaptureMeta, ContentMeta, MatiralMeta, PlanningMeta);

                //添加后如果开始时间在2分钟以内,需要调度一次
                if ((DateTimeFormat.DateTimeFromString(pIn.taskModify.strBegin) - DateTime.Now).TotalSeconds < 120)
                {
                    await _taskManage.UpdateComingTasks();
                }

                var _globalinterface = ApplicationContext.Current.ServiceProvider.GetRequiredService <IIngestGlobalInterface>();
                if (_globalinterface != null)
                {
                    GlobalInternals re = new GlobalInternals()
                    {
                        funtype = IngestDBCore.GlobalInternals.FunctionType.SetGlobalState, State = GlobalStateName.MODTASK
                    };
                    var response1 = await _globalinterface.SubmitGlobalCallBack(re);

                    if (response1.Code != ResponseCodeDefines.SuccessCode)
                    {
                        Logger.Error("SetGlobalState modtask error");
                    }
                }

                return(Response);
            }
            catch (Exception e)
            {
                if (e.GetType() == typeof(SobeyRecException))//sobeyexcep会自动打印错误
                {
                    SobeyRecException se = e as SobeyRecException;
                    Response.errStr = se.ErrorCode.ToString();
                }
                else
                {
                    Response.errStr = "error info:" + e.ToString();
                    Logger.Error("GetAllChannelCapturingTask" + e.ToString());
                }
                return(Response);
            }
            return(Response);
        }
예제 #9
0
        public async Task <AddTaskSvr_OUT> PostAddTaskSvr([FromBody] AddTaskSvr_IN pIn)
        {
            var Response = new AddTaskSvr_OUT
            {
                bRet   = true,
                errStr = "OK"
            };

            try
            {
                string CaptureMeta  = string.Empty;
                string ContentMeta  = string.Empty;
                string MatiralMeta  = string.Empty;
                string PlanningMeta = string.Empty;
                foreach (var item in pIn.metadatas)
                {
                    if (item.emtype == MetaDataType.emCapatureMetaData)
                    {
                        CaptureMeta = item.strMetadata;
                    }
                    else if (item.emtype == MetaDataType.emStoreMetaData)
                    {
                        MatiralMeta = item.strMetadata;
                    }
                    else if (item.emtype == MetaDataType.emContentMetaData)
                    {
                        ContentMeta = item.strMetadata;
                    }
                    else if (item.emtype == MetaDataType.emPlanMetaData)
                    {
                        PlanningMeta = item.strMetadata;
                    }
                }
                Response.newTaskId = (await _taskManage.AddTaskWithoutPolicy <AddTaskSvr_IN>(pIn, CaptureMeta, ContentMeta, MatiralMeta, PlanningMeta)).TaskID;

                var _globalinterface = ApplicationContext.Current.ServiceProvider.GetRequiredService <IIngestGlobalInterface>();
                if (_globalinterface != null)
                {
                    GlobalInternals re = new GlobalInternals()
                    {
                        funtype = IngestDBCore.GlobalInternals.FunctionType.SetGlobalState, State = GlobalStateName.ADDTASK
                    };
                    var response1 = await _globalinterface.SubmitGlobalCallBack(re);

                    if (response1.Code != ResponseCodeDefines.SuccessCode)
                    {
                        Logger.Error("SetGlobalState modtask error");
                    }
                }


                return(Response);
            }
            catch (Exception e)
            {
                Response.bRet = false;
                if (e.GetType() == typeof(SobeyRecException))//sobeyexcep会自动打印错误
                {
                    SobeyRecException se = e as SobeyRecException;
                    Response.errStr = se.ErrorCode.ToString();
                }
                else
                {
                    Response.errStr = "PostAddTaskSvr error info:" + e.ToString();
                    Logger.Error(Response.errStr);
                }
                return(Response);
            }
        }