public TaskProfile() { CreateMap <TaskMetadataResponse, DbpTaskMetadata>() .ForMember(a => a.Metadatalong, (map) => map.MapFrom(b => b.Metadata)); CreateMap <DbpTaskMetadata, TaskMetadataResponse>() .ForMember(a => a.Metadata, (map) => map.MapFrom(b => b.Metadatalong)); CreateMap <DbpTaskMetadata, GetQueryTaskMetaData_param>() .ForMember(a => a.MetaData, (map) => map.MapFrom(b => b.Metadatalong)) .AfterMap((a, b) => { if (!string.IsNullOrEmpty(a.Metadatalong)) { b.bRet = true; b.errStr = "OK"; } }); CreateMap <DbpTaskCustommetadata, TaskCustomMetadataResponse>(); CreateMap <DbpTaskCustommetadata, GetTaskCustomMetadata_OUT>(); CreateMap <TaskContentResponse, DbpTask>() .ForMember(a => a.Recunitid, (map) => map.MapFrom(b => b.Unit)) .ForMember(a => a.Category, (map) => map.MapFrom(b => b.Classify)) .ForMember(a => a.Description, (map) => map.MapFrom(b => b.TaskDesc)) .ForMember(a => a.Starttime, (map) => map.MapFrom(b => DateTimeFormat.DateTimeFromString(b.Begin))) .ForMember(a => a.Endtime, (map) => map.MapFrom(b => DateTimeFormat.DateTimeFromString(b.End))) .ForMember(a => a.Sgroupcolor, (map) => map.MapFrom(b => b.GroupColor)) .ForMember(a => a.Stampimagetype, (map) => map.MapFrom(b => b.StampImageType)) .ForMember(a => a.Taskpriority, (map) => map.MapFrom(b => b.Priority)) .ForMember(a => a.Backtype, (map) => map.MapFrom(b => b.CooperantType)); CreateMap <DbpTask, TaskContentResponse>() .ForMember(a => a.Unit, (map) => map.MapFrom(b => b.Recunitid)) .ForMember(a => a.Classify, (map) => map.MapFrom(b => b.Category)) .ForMember(a => a.TaskDesc, (map) => map.MapFrom(b => b.Description)) .ForMember(a => a.Begin, (map) => map.MapFrom(b => DateTimeFormat.DateTimeToString(b.Starttime))) .ForMember(a => a.End, (map) => map.MapFrom(b => DateTimeFormat.DateTimeToString(b.Endtime))) .ForMember(a => a.GroupColor, (map) => map.MapFrom(b => b.Sgroupcolor)) .ForMember(a => a.StampImageType, (map) => map.MapFrom(b => b.Stampimagetype)) .ForMember(a => a.Priority, (map) => map.MapFrom(b => b.Taskpriority)) .ForMember(a => a.CooperantType, (map) => map.MapFrom(b => b.Backtype)); CreateMap <DbpTask, TaskContent>() .ForMember(a => a.nTaskID, (y) => y.MapFrom(b => b.Taskid)) .ForMember(a => a.strTaskName, (y) => y.MapFrom(b => b.Taskname)) .ForMember(a => a.strTaskDesc, (y) => y.MapFrom(b => b.Description)) .ForMember(a => a.strClassify, (y) => y.MapFrom(b => b.Category)) .ForMember(a => a.nChannelID, (y) => y.MapFrom(b => b.Channelid)) .ForMember(a => a.nUnit, (y) => y.MapFrom(b => b.Recunitid)) .ForMember(a => a.strUserCode, (y) => y.MapFrom(b => b.Usercode)) .ForMember(a => a.nSignalID, (y) => y.MapFrom(b => b.Signalid)) .ForMember(a => a.strBegin, (y) => y.MapFrom(b => DateTimeFormat.DateTimeToString(b.Starttime))) .ForMember(a => a.strEnd, (y) => y.MapFrom(b => DateTimeFormat.DateTimeToString(b.Endtime))) .ForMember(a => a.emTaskType, (y) => y.MapFrom(b => b.Tasktype)) .ForMember(a => a.emCooperantType, (y) => y.MapFrom(b => b.Backtype)) .ForMember(a => a.emState, (y) => y.MapFrom(b => b.State)) .ForMember(a => a.strStampImage, (y) => y.MapFrom(b => b.Description)) .ForMember(a => a.strTaskGUID, (y) => y.MapFrom(b => b.Taskguid)) .ForMember(a => a.nBackupVTRID, (y) => y.MapFrom(b => b.Backupvtrid)) .ForMember(a => a.emPriority, (y) => y.MapFrom(b => b.Taskpriority)) .ForMember(a => a.nStampTitleIndex, (y) => y.MapFrom(b => b.Stamptitleindex)) .ForMember(a => a.nStampImageType, (y) => y.MapFrom(b => b.Stampimagetype)) .ForMember(a => a.nSGroupColor, (y) => y.MapFrom(b => b.Sgroupcolor)); CreateMap <TaskContent, TaskContentResponse>() .ForMember(x => x.TaskID, (y) => y.MapFrom(z => z.nTaskID)) .ForMember(x => x.TaskName, (y) => y.MapFrom(z => z.strTaskName)) .ForMember(x => x.TaskDesc, (y) => y.MapFrom(z => z.strTaskDesc)) .ForMember(x => x.Classify, (y) => y.MapFrom(z => z.strClassify)) .ForMember(x => x.ChannelID, (y) => y.MapFrom(z => z.nChannelID)) .ForMember(x => x.Unit, (y) => y.MapFrom(z => z.nUnit)) .ForMember(x => x.UserCode, (y) => y.MapFrom(z => z.strUserCode)) .ForMember(x => x.SignalID, (y) => y.MapFrom(z => z.nSignalID)) .ForMember(x => x.Begin, (y) => y.MapFrom(z => z.strBegin)) .ForMember(x => x.End, (y) => y.MapFrom(z => z.strEnd)) .ForMember(x => x.TaskType, (y) => y.MapFrom(z => z.emTaskType)) .ForMember(x => x.CooperantType, (y) => y.MapFrom(z => z.emCooperantType)) .ForMember(x => x.State, (y) => y.MapFrom(z => z.emState)) .ForMember(x => x.StampImage, (y) => y.MapFrom(z => z.strStampImage)) .ForMember(x => x.TaskGUID, (y) => y.MapFrom(z => z.strTaskGUID)) .ForMember(x => x.BackupVTRID, (y) => y.MapFrom(z => z.nBackupVTRID)) .ForMember(x => x.Priority, (y) => y.MapFrom(z => z.emPriority)) .ForMember(x => x.StampTitleIndex, (y) => y.MapFrom(z => z.nStampTitleIndex)) .ForMember(x => x.StampImageType, (y) => y.MapFrom(z => z.nStampImageType)) .ForMember(x => x.GroupColor, (y) => y.MapFrom(z => z.nSGroupColor)); CreateMap <AddTaskSvr_IN, TaskInfoResponse>() .ForMember(d => d.TaskContent, y => y.MapFrom(s => s.taskAdd)) .ForMember(d => d.TaskSource, y => y.MapFrom(s => s.taskSrc)); //ReverseMap }
public override async ValueTask<int> HandleTaskAsync(TaskFullInfo task, ChannelInfo channel) { Logger.Info($"NormalTaskHandler HandleTaskAsync retrytimes {task.RetryTimes}"); int taskid = task.TaskContent.TaskId; if (task.ContentMeta == null || string.IsNullOrEmpty(task.CaptureMeta)) { await UnlockTaskAsync(taskid, taskState.tsNo, dispatchState.dpsRedispatch, syncState.ssSync); return 0; } if (task.StartOrStop && task.OpType != opType.otDel) { if (task.TaskContent.TaskType == TaskType.TT_MANUTASK)//已经执行的手动任务不需要执行,未执行的手动任务需要继续执行 { if (task.TaskContent.State == taskState.tsExecuting || task.TaskContent.State == taskState.tsManuexecuting) { await UnlockTaskAsync(taskid, taskState.tsExecuting, dispatchState.dpsDispatched, syncState.ssSync); return taskid; } } else if (task.TaskContent.TaskType == TaskType.TT_TIEUP) { await HandleTieupTaskAsync(task.TaskContent); return taskid; } else { if (DateTimeFormat.DateTimeFromString(task.TaskContent.End) < DateTime.Now)//普通任务进行时间有效性判断, { task.StartOrStop = false;//禁止监听任务 return taskid; } } if (channel.CurrentDevState == Device_State.DISCONNECTTED) { await UnlockTaskAsync(taskid, taskState.tsNo, dispatchState.dpsRedispatch, syncState.ssSync); return IsNeedRedispatchask(task); } if (await StartTaskAsync(task, channel) > 0) { //成功 await UnlockTaskAsync(taskid, taskState.tsExecuting, dispatchState.dpsDispatched, syncState.ssSync); return taskid; } else { //使用备份信号 //我擦,居然可以不用写,stop才有 Logger.Info("start error. begin to use backupsignal"); if (task.TaskContent.TaskType == TaskType.TT_OPENEND || task.TaskContent.TaskType == TaskType.TT_OPENENDEX) { await UnlockTaskAsync(taskid, taskState.tsInvaild, dispatchState.dpsDispatched, syncState.ssSync); } else { await UnlockTaskAsync(taskid, taskState.tsNo, dispatchState.dpsRedispatch, syncState.ssSync); } //重调度还失败,要看看是否超过了,超过就从列表去了 return IsNeedRedispatchask(task); } } else { Logger.Info($"task stop timespan {(DateTimeFormat.DateTimeFromString(task.TaskContent.End) - DateTime.Now).TotalSeconds}"); task.TaskContent.End = DateTimeFormat.DateTimeToString(DateTime.Now); if (task.TaskContent.TaskType != TaskType.TT_MANUTASK || (task.TaskContent.TaskType == TaskType.TT_MANUTASK && task.OpType == opType.otDel)) { //里面有IsNeedRedispatchask(task); var backinfo = await StopTaskAsync(task, channel); //所有的删除都让入库去做,这里不删除 //开始删除素材 if (task.OpType == opType.otDel) { await UnlockTaskAsync(task.TaskContent.TaskId, taskState.tsComplete, dispatchState.dpsInvalid, syncState.ssSync); //DeleteClip(); } return backinfo; } } return 0; }