예제 #1
0
        /// <summary>
        /// 更新最后执行时间
        /// </summary>
        /// <param name="taskId"></param>
        /// <returns></returns>
        public async Task UpdateLastRunTime(int taskId)
        {
            string sql = @"UPDATE TaskOptions SET LastRunTime = @LastRunTime WHERE Id = @id";

            using var con = new DapperDbContexts().Connection;
            await con.ExecuteAsync(sql, new { LastRunTime = DateTime.Now, id = taskId });
        }
예제 #2
0
        /// <summary>
        /// 删除任务
        /// </summary>
        /// <returns></returns>
        public async Task Delete(int id)
        {
            string sql = @"DELETE FROM TaskOptions WHERE Id = @id";

            using var con = new DapperDbContexts().Connection;
            await con.ExecuteAsync(sql, new { id = id });
        }
예제 #3
0
        /// <summary>
        /// 写日志
        /// </summary>
        /// <param name="log"></param>
        public async Task WriteLog(Log log)
        {
            string sql = @"INSERT INTO Log (ExecutionTime,ClientIpAddress,BrowserInfo,UserName,Content) VALUES
                        (@ExecutionTime,@ClientIpAddress,@BrowserInfo,@UserName,@Content)";

            using var con = new DapperDbContexts().Connection;
            await con.ExecuteAsync(sql, log);
        }
예제 #4
0
        /// <summary>
        /// 写日志
        /// </summary>
        /// <param name="log"></param>
        public async Task WriteLog(TaskLog log)
        {
            string sql = @"INSERT INTO TaskLog (TaskId,ExecutionTime,ExecutionDuration,Msg,TaskLogStatus) VALUES
                        (@TaskId,@ExecutionTime,@ExecutionDuration,@Msg,@TaskLogStatus)";

            using var con = new DapperDbContexts().Connection;
            await con.ExecuteAsync(sql, log);
        }
예제 #5
0
        /// <summary>
        /// 添加任务
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        public async Task Add(TaskOptions task)
        {
            string sql = @"INSERT INTO TaskOptions(TaskName,GroupName,Interval,ApiUrl,AuthKey,AuthValue,Describe,RequestType,LastRunTime,Status)
                        VALUES (@TaskName,@GroupName,@Interval,@ApiUrl,@AuthKey,@AuthValue,@Describe,@RequestType,@LastRunTime,@Status)";

            using var con = new DapperDbContexts().Connection;
            await con.ExecuteAsync(sql, task);
        }
예제 #6
0
        /// <summary>
        /// 修改任务
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        public async Task Edit(TaskOptions task)
        {
            string sql = @"UPDATE TaskOptions SET TaskName = @TaskName,GroupName = @GroupName,Interval = @Interval
                    ,ApiUrl = @ApiUrl,AuthKey = @AuthKey,AuthValue = @AuthValue,Describe = @Describe,RequestType = @RequestType
                    ,LastRunTime = @LastRunTime,Status = @Status WHERE Id = @Id";

            using var con = new DapperDbContexts().Connection;
            await con.ExecuteAsync(sql, task);
        }