Ejemplo n.º 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 });
        }
Ejemplo n.º 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 });
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }