lixiaojun
2023-03-20 14801a2e40bc79833c41151a37fe4cb0acbc5c7f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IStation.Untity;
 
namespace IStation.DataProvider
{
 
 
    /// <summary>
    /// 数据任务
    /// </summary>
    [DisallowConcurrentExecution]//此特性标识 必须等待这次任务执行完成后,才能执行下次任务
    public class DataJob : IJob
    {
        /// <summary>
        /// 
        /// </summary>
        public async Task Execute(IJobExecutionContext context)
        {
            try
            {
                await Task.Run(() =>
                {
                    var srcList = JsonStore.GetCurrentRecord();
                    var response= HttpRequestHelper.Post(ConfigHelper.StoreUrl,JsonHelper.Object2Json(srcList));
                    var result = JsonHelper.Json2Object<Result>(response);
                    if (result.Code == 0)
                    {
                        if (result.Data)
                        {
                            LogHelper.Info($"成功插入{srcList.Count}条数据!");
                        }
                        else
                        {
                            LogHelper.Info($"数据插入失败,原因:{result.Message}");
                        }
                    }
                    else
                    {
                        LogHelper.Info($"数据插入失败,原因:{result.Message}");
                    }
                });
            }
            catch (Exception ex)
            {
                var e = new JobExecutionException(ex);
                IStation.LogHelper.Error("数据任务", ex);
                throw e;
            }
        }
 
 
 
    }
}