예제 #1
0
        public async Task <int> UserTemplateInsertAsync(int templateID, string userCode, string templateName, string templateContent)
        {
            var usertemplate = await Store.GetUsertemplateAsync(a => a.Where(x => x.Usercode == userCode && x.Templatename == templateName && x.Templateid != templateID && x.Templateid > 0), true);

            if (usertemplate != null)
            {
                SobeyRecException.ThrowSelfOneParam(templateName, GlobalDictionary.GLOBALDICT_CODE_THE_USER_TEMPLATE_HAS_EXISTS_ONEPARAM, null, string.Format(GlobalDictionary.Instance.GetMessageByCode(GlobalDictionary.GLOBALDICT_CODE_THE_USER_TEMPLATE_HAS_EXISTS_ONEPARAM),
                                                                                                                                                              templateName), null);
                return(-1);
            }

            if (templateID <= 0)
            {
                templateID = IngestGlobalDBContext.next_val("DBP_SQ_UESRTEMPLATEID");
            }

            //DBACCESS.AddUserTemplate(userTemplate);
            if (!string.IsNullOrWhiteSpace(templateContent))
            {
                int byteLength = Encoding.UTF8.GetByteCount(templateContent);
                templateContent = FillBlankToString(templateContent, byteLength);
            }
            await Store.InsertUserTemplateAsync(templateID, userCode, templateName, templateContent);

            return(templateID);
        }
예제 #2
0
        public async Task <ResponseMessage <int> > GetChannelUnitMapID([FromRoute, BindRequired] int channel)
        {
            var Response = new ResponseMessage <int>();

            try
            {
                var f = await _deviceManage.GetChannelUnitMap(channel);

                if (f != null)
                {
                    Response.Ext = f.UnitID;
                }
                else
                {
                    Response.Ext = -1;
                }
            }
            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  = "error info:" + e.ToString();
                    Logger.Error(Response.Msg);
                }
            }
            return(Response);
        }
예제 #3
0
        public async Task <GetTaskByID_OUT> GetTaskByID(int nTaskID)
        {
            var Response = new GetTaskByID_OUT
            {
                bRet   = true,
                errStr = "OK",
            };

            try
            {
                Response.taskConten = await _taskManage.GetTaskInfoByID <TaskContent>(nTaskID);

                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);
            }
        }
예제 #4
0
        public async Task <ResponseMessage <List <RouterInResponse> > > AllRouterInPortInfo()
        {
            var Response = new ResponseMessage <List <RouterInResponse> >();

            try
            {
                Response.Ext = await _deviceManage.GetAllRouterInPortAsync <RouterInResponse>();
            }
            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  = "error info:" + e.ToString();
                    Logger.Error(Response.Msg);
                }
            }
            return(Response);
        }
예제 #5
0
        public async Task <ResponseMessage <List <CaptureChannelInfoResponse> > > ChannelsByProgrammeId([FromRoute, BindRequired] int programmeId, [FromQuery, BindRequired] int status)
        {
            var Response = new ResponseMessage <List <CaptureChannelInfoResponse> >();

            try
            {
                Response.Ext = await _deviceManage.GetChannelsByProgrammeIdAsync <CaptureChannelInfoResponse>(programmeId, status);
            }
            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  = "error info:" + e.ToString();
                    Logger.Error(Response.Msg);
                }
            }
            return(Response);
        }
예제 #6
0
        public async Task <GetAllChannelCapturingTask_OUT> GetAllChannelCapturingTask()
        {
            var Response = new GetAllChannelCapturingTask_OUT
            {
                bRet   = true,
                errStr = "OK"
            };

            try
            {
                Response.content = await _taskManage.GetAllChannelCapturingTask <TaskContent>();

                Response.nVaildDataCount = Response.content.Count;
                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);
            }
        }
예제 #7
0
        public async Task <GetTaskIDByTaskGUID_OUT> GetTaskIDByTaskGUID([FromQuery] string strTaskGUID)
        {
            var Response = new GetTaskIDByTaskGUID_OUT
            {
                bRet   = true,
                errStr = "OK"
            };

            try
            {
                Response.nTaskID = await _taskManage.GetTaskIDByTaskGUID(strTaskGUID);

                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("GetTaskIDByTaskGUID" + e.ToString());
                }
                return(Response);
            }
        }
예제 #8
0
        public async Task <ResponseMessage <string> > UpdateTaskMetaData([FromRoute, BindRequired] int taskid, [FromQuery, BindRequired] int tasktype, [FromBody, BindRequired] List <PropertyResponse> lst)
        {
            var Response = new ResponseMessage <string>();

            if (taskid < 1)
            {
                Response.Code = ResponseCodeDefines.ModelStateInvalid;
                Response.Msg  = "请求参数不正确";
            }
            try
            {
                Response.Ext = await _taskManage.UpdateMetadataPropertyAsync(taskid, tasktype, lst);
            }
            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  = "UpdateTaskMetaData error info:" + e.ToString();
                    Logger.Error(Response.Msg);
                }
            }
            return(Response);
        }
예제 #9
0
        public async Task <ResponseMessage <CMUserInfo> > GetUserInfoByCode([FromQuery] string strUserCode)
        {
            ResponseMessage <CMUserInfo> Response = new ResponseMessage <CMUserInfo>();

            try
            {
                Response = await _GlobalManager.GetUserInfoByUserCodeAsync <CMUserInfo>(strUserCode);
            }
            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  = "error info:" + e.ToString();
                    Logger.Error(Response.Msg);
                }
            }
            return(Response);
        }
예제 #10
0
        public async Task <ResponseMessage> ModifyUserTempalteContent([FromQuery] int nTemplateID, [FromBody] string strTemplateContent)
        {
            ResponseMessage Response = new ResponseMessage();

            if (nTemplateID <= 0)
            {
                Response.Msg  = "TemplateID is smaller or equal 0.";
                Response.Code = ResponseCodeDefines.ArgumentNullError;
            }
            try
            {
                await _GlobalManager.UpdateUserTempalteContent(nTemplateID, strTemplateContent);

                Response.Code = ResponseCodeDefines.SuccessCode;
            }
            catch (System.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  = "error info:" + e.ToString();
                    Logger.Error(Response.Msg);
                }
            }
            return(Response);
        }
예제 #11
0
        public async Task <OldPostParam_Out> OldPostLockObject([FromBody] PostLockObject_param_in pIn)
        {
            OldPostParam_Out pOut = new OldPostParam_Out();

            try
            {
                if (pIn.ObjectID < 0)
                {
                    Logger.Error("ObjectID < 0 ,参数传递错误");
                    SobeyRecException.ThrowSelfNoParam(pIn.ObjectID.ToString(), GlobalDictionary.GLOBALDICT_CODE_LOCK_OBJECTID_WRONG, Logger, null);
                }
                if (pIn.ObjectTypeID < OTID.OTID_VTR || pIn.ObjectTypeID > OTID.OTID_OTHER)
                {
                    SobeyRecException.ThrowSelfNoParam(pIn.ObjectTypeID.ToString(), GlobalDictionary.GLOBALDICT_CODE_LOCK_OBJECT_TPYEID_IS_NOT_EXIST, Logger, null);
                }
                if (string.IsNullOrEmpty(pIn.userName))//   == "" || pIn.userName == string.Empty)
                {
                    pIn.userName = "******";
                }
                if (pIn.TimeOut < 0)
                {
                    SobeyRecException.ThrowSelfNoParam(pIn.TimeOut.ToString(), GlobalDictionary.GLOBALDICT_CODE_LOCK_OBJECT_TIMEOUT_IS_WRONG, Logger, null);
                }

                pOut.bRet = await _GlobalManager.SetLockObject(pIn.ObjectID, pIn.ObjectTypeID, pIn.userName, pIn.TimeOut);
            }
            catch (Exception ex)
            {
                pOut.errStr = ex.Message;
                Logger.Error("PostlockObject 异常发生: " + ex.ToString());
                pOut.bRet = false;
            }

            return(pOut);
        }
예제 #12
0
        public async Task <ResponseMessage <List <DbpGlobalState> > > GetGlobalState()
        {
            ResponseMessage <List <DbpGlobalState> > Response = new ResponseMessage <List <DbpGlobalState> >();

            try
            {
                Response.Ext = await _GlobalManager.GetAllGlobalStateAsync <List <DbpGlobalState> >();

                if (Response.Ext.Count < 1)
                {
                    Response.Code = ResponseCodeDefines.PartialFailure;
                    Response.Msg  = "No record in the table";
                }
                Response.Code = ResponseCodeDefines.SuccessCode;
            }
            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  = "error info:" + e.ToString();
                    Logger.Error(Response.Msg);
                }
            }

            return(Response);
        }
예제 #13
0
        public async Task <ResponseMessage <string> > GetParamTemplateByID([FromQuery] int nCaptureParamID, [FromQuery] int nFlag)
        {
            ResponseMessage <string> Response = new ResponseMessage <string>();

            try
            {
                //读取采集参数模板
                string temp = await _GlobalManager.GetParamTemplateByIDAsync(nCaptureParamID, nFlag);

                if (string.IsNullOrEmpty(temp))
                {
                    Response.Msg  = "There's no CaptureParam!";
                    Response.Code = ResponseCodeDefines.PartialFailure;
                    return(Response);
                }
                Response.Ext  = temp;
                Response.Code = ResponseCodeDefines.SuccessCode;
            }
            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  = "error info:" + e.ToString();
                    Logger.Error(Response.Msg);
                }
            }
            return(Response);
        }
예제 #14
0
        public async Task <ResponseMessage> SetValue([FromQuery] string strKey, [FromQuery] string strValue)
        {
            ResponseMessage Response = new ResponseMessage();

            try
            {
                if (strValue == null)
                {
                    strValue = "";
                }
                await _GlobalManager.UpdateGlobalValueAsync(strKey, strValue);

                Response.Code = ResponseCodeDefines.SuccessCode;
            }
            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  = "error info:" + e.ToString();
                    Logger.Error(Response.Msg);
                }
            }
            return(Response);
        }
예제 #15
0
        public async Task <ResponseMessage> SetGlobalState([FromQuery] string strLabel)
        {
            var Response = new ResponseMessage();

            if (strLabel == null || strLabel == string.Empty)
            {
                Response.Code = ResponseCodeDefines.ArgumentNullError;
                Response.Msg  = "请求参数不正确";
                return(Response);
            }
            try
            {
                await _GlobalManager.UpdateGlobalStateAsync(strLabel);
            }
            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  = "error info:" + e.ToString();
                    Logger.Error(Response.Msg);
                }
            }

            return(Response);
        }
예제 #16
0
        /// <summary> Try执行 </summary>
        /// <typeparam name="T">返回类型</typeparam>
        /// <param name="action">执行内容</param>
        private async Task <T> TryInvoke <T>(Func <T, Task> action) where T : Base_param
        {
            T Response = default;

            try
            {
                await action(Response);
            }
            catch (Exception e)
            {
                if (e.GetType() == typeof(SobeyRecException))//sobeyexcep会自动打印错误
                {
                    SobeyRecException se = e as SobeyRecException;
                    Response.bRet   = false;
                    Response.errStr = se.Message;
                }
                else
                {
                    Response.bRet   = false;
                    Response.errStr = $"error info:{e.ToString()}";
                    Logger.Error(Response.errStr);
                }
            }
            return(Response);
        }
예제 #17
0
        public async Task <ResponseMessage <string> > GetValueString([FromQuery] string strKey)
        {
            var Response = new ResponseMessage <string>();

            if (string.IsNullOrEmpty(strKey))
            {
                Response.Code = ResponseCodeDefines.ArgumentNullError;
                Response.Msg  = "请求参数不正确";
                return(Response);
            }
            try
            {
                Response.Ext = await _GlobalManager.GetValueStringAsync(strKey);
            }
            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  = "error info:" + e.ToString();
                    Logger.Error(Response.Msg);
                }
            }

            return(Response);
        }
예제 #18
0
 public async Task <GetQueryTaskMetaData_param> OldGetTaskMetaData([FromQuery] int nTaskID, [FromQuery] int Type)
 {
     if (nTaskID < 1)
     {
         var Response = new GetQueryTaskMetaData_param
         {
             bRet   = false,
             errStr = "OK"
         };
         return(Response);
     }
     try
     {
         return(await _taskManage.GetTaskMetadataAsync <GetQueryTaskMetaData_param>(nTaskID, Type));
     }
     catch (Exception e)
     {
         var Response = new GetQueryTaskMetaData_param()
         {
             bRet = false
         };
         if (e.GetType() == typeof(SobeyRecException))//sobeyexcep会自动打印错误
         {
             SobeyRecException se = e as SobeyRecException;
             Response.errStr = se.ErrorCode.ToString();
         }
         else
         {
             Response.errStr = "OldGetTaskMetaData error info:" + e.ToString();
             Logger.Error(Response.errStr);
         }
         return(Response);
     }
 }
예제 #19
0
        public async Task UpdateUsersettingsAsync(DbpUsersettings usersetting)
        {
            try
            {
                if (!Context.DbpUsersetting.AsNoTracking().Any(x => x.Usercode == usersetting.Usercode && x.Settingtype == usersetting.Settingtype))
                {
                    //add
                    Context.DbpUsersetting.Add(usersetting);
                }
                else
                {
                    //update
                    Context.Attach(usersetting);
                    Context.Entry(usersetting).Property(x => x.Settingtext).IsModified     = true;
                    Context.Entry(usersetting).Property(x => x.Settingtextlong).IsModified = true;
                }

                await Context.SaveChangesAsync();
            }
            catch (System.Exception ex)
            {
                Logger.Error(ex.ToString());
                //SobeyRecException.ThrowSelf(Locallanguage.LoadString("Fill SetUserSetting Exception "),ex,2,10013019);
                SobeyRecException.ThrowSelfNoParam("UpdateUsersettingsAsync", GlobalDictionary.GLOBALDICT_CODE_FILL_USER_SETUSERSETTING_EXCEPTION, Logger, ex);
            }
        }
예제 #20
0
        public async Task <ResponseMessage <TaskMaterialMetaResponse> > GetTaskMaterialMetaData([FromRoute, BindRequired] int taskid)
        {
            var Response = new ResponseMessage <TaskMaterialMetaResponse>();

            if (taskid < 1)
            {
                Response.Code = ResponseCodeDefines.ModelStateInvalid;
                Response.Msg  = "请求参数不正确";
            }
            try
            {
                Response.Ext = await _taskManage.GetTaskMaterialMetadataAsync(taskid);
            }
            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  = "GetTaskMaterialMetaData error info:" + e.ToString();
                    Logger.Error(Response.Msg);
                }
            }
            return(Response);
        }
예제 #21
0
        public async Task <ResponseMessage <TaskContentResponse> > GetTaskInfoByID([FromQuery, BindRequired] int taskid)
        {
            var Response = new ResponseMessage <TaskContentResponse>();

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

            try
            {
                Response.Ext = await _taskManage.GetTaskInfoByID <TaskContentResponse>(taskid);
            }
            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);
        }
예제 #22
0
        public async Task <ResponseMessage <List <UserTemplate> > > GetUserAllTemplates([FromQuery] string strUserCode)
        {
            ResponseMessage <List <UserTemplate> > Response = new ResponseMessage <List <UserTemplate> >();

            if (strUserCode == string.Empty)
            {
                Response.Msg  = "UserCode is null.";
                Response.Code = ResponseCodeDefines.ArgumentNullError;
            }
            try
            {
                Response.Ext = await _GlobalManager.GetUserAllTemplatesAsync <UserTemplate>(strUserCode);

                Response.Code = ResponseCodeDefines.SuccessCode;
            }
            catch (System.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  = "error info:" + e.ToString();
                    Logger.Error(Response.Msg);
                }
            }
            return(Response);
        }
예제 #23
0
        public async Task <ResponseMessage <List <TaskContentResponse> > > GetAllChannelCapturingTaskInfo()
        {
            var Response = new ResponseMessage <List <TaskContentResponse> >();

            try
            {
                Response.Ext = await _taskManage.GetAllChannelCapturingTask <TaskContentResponse>();
            }
            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  = "GetAllChannelCapturingTaskInfo error info:" + e.ToString();
                    Logger.Error(Response.Msg);
                }
            }
            return(Response);
        }
예제 #24
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);
        }
예제 #25
0
        public async Task <bool> UnLockRowsAsync(DbpObjectstateinfo objectstateinfo, int TimeOut)
        {
            bool result = false;

            try
            {
                int      nTime  = -1;
                DateTime dtLock = new DateTime();

                try
                {
                    System.Globalization.DateTimeFormatInfo dtfi = new System.Globalization.CultureInfo("en-US", false).DateTimeFormat;
                    dtfi.ShortTimePattern = "t";
                    //DateTime dt = DateTime.Parse("02-28-12 03:07PM", dtfi);
                    nTime = Convert.ToInt32(objectstateinfo.Timeout);

                    dtLock = DateTime.Parse(objectstateinfo.Begintime.ToString(), dtfi);
                }
                catch (System.Exception ex)
                {
                    //Logger.Error(ex.ToString());
                    Logger.Error("UnLockRowsAsync 时间格式转换不对: " + ex.Message);
                    return(false);
                }

                DateTime AddMillSec = dtLock.AddMilliseconds(nTime);

                DateTime dtNow = DateTime.Now;

                var selectResult = await Context.DbpObjectstateinfo.SingleOrDefaultAsync(x => x.Objectid == objectstateinfo.Objectid && x.Objecttypeid == objectstateinfo.Objecttypeid && x.Username == objectstateinfo.Username);

                if (AddMillSec < dtNow) //锁超时
                {
                    result = true;
                    //UpdateLock(userName, dtNow, Convert.ToInt32(TimeOut), objectID, objectTypeID);
                    if (selectResult != null)
                    {
                        selectResult.Begintime = dtNow;
                        selectResult.Timeout   = Convert.ToInt32(TimeOut);
                    }
                }
                //UnLock(objectID, objectTypeID, userName);
                if (selectResult != null)
                {
                    selectResult.Locklock = null;
                    await Context.SaveChangesAsync();
                }
                return(result);
            }
            catch (Exception ex)
            {
                SobeyRecException.ThrowSelfNoParam(objectstateinfo.Objectid.ToString(), GlobalDictionary.GLOBALDICT_CODE_EXECUTE_COMMAND_ERROR, Logger, ex);
                result = false;
                throw ex;
            }
        }
예제 #26
0
        public async Task <PostSetTaskMetaData_OUT> PostSetTaskMetaData([FromBody] PostSetTaskMetaData_IN pIn)
        {
            if (pIn == null)
            {
                var Response = new PostSetTaskMetaData_OUT
                {
                    bRet   = false,
                    errStr = "OK"
                };
                return(Response);
            }
            try
            {
                PostSetTaskMetaData_OUT pOut = new PostSetTaskMetaData_OUT();
                if (pIn.MateData == null)
                {
                    pOut.errStr = "MetaData";
                    pOut.bRet   = false;
                }

                if (pIn.MateData.Length <= 0 && pIn.Type != MetaDataType.emAmfsData)
                {
                    pOut.errStr = "MetaData";
                    pOut.bRet   = false;
                }

                if (pIn.Type == MetaDataType.emAmfsData)
                {
                    pIn.MateData = System.Guid.NewGuid().ToString();
                }

                await _taskManage.UpdateTaskMetaDataAsync(pIn.nTaskID, pIn.Type, pIn.MateData);

                pOut.bRet = true;
                return(pOut);
            }
            catch (Exception e)
            {
                var Response = new PostSetTaskMetaData_OUT()
                {
                    bRet = false
                };
                if (e.GetType() == typeof(SobeyRecException))//sobeyexcep会自动打印错误
                {
                    SobeyRecException se = e as SobeyRecException;
                    Response.errStr = se.ErrorCode.ToString();
                }
                else
                {
                    Response.errStr = "PostSetTaskMetaData error info:" + e.ToString();
                    Logger.Error(Response.errStr);
                }
                return(Response);
            }
        }
예제 #27
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);
        }
예제 #28
0
        public async Task UpdateUserTempalteContent(int nTemplateID, string strTemplateContent)
        {
            DbpUsertemplate userTemplate = await Store.GetUsertemplateAsync(a => a.Where(x => x.Templateid == nTemplateID), true);

            if (userTemplate != null && userTemplate.Templateid <= 0)
            {
                SobeyRecException.ThrowSelfOneParam(nTemplateID.ToString(), GlobalDictionary.GLOBALDICT_CODE_CAN_NOT_FIND_THE_TEMPLATE_ID_IS_ONEPARAM, null, string.Format(GlobalDictionary.Instance.GetMessageByCode(GlobalDictionary.GLOBALDICT_CODE_CAN_NOT_FIND_THE_TEMPLATE_ID_IS_ONEPARAM),
                                                                                                                                                                           nTemplateID), null);
                return;
            }

            await Store.ModifyUserTempalteContent(nTemplateID, strTemplateContent);
        }
예제 #29
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);
        }
예제 #30
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);
            }
        }