数据解析入库(vs2015)

    xiaoxiao2026-03-13  11

    1.在core/Mapuni.Job.Model/Master中新建类:Source_Industry_Area

        构建区域源小时数据表

        [StoredAs("T_Src_AreaHourData")]

        public class T_Src_AreaHourData     {         [KeyProperty]         public string AreaCode { get; set; }//区域源编码         [KeyProperty]         public string STATIONCODE { get; set; }//站点编码         [KeyProperty]         public DateTime MONITORTIME { get; set; }//作预报的时间         [KeyProperty]         public DateTime FORECASTTIME { get; set; }//预报时间         public decimal CONTRIBUTIONNUMBER { get; set; }//贡献量         public decimal CONTRIBUTIONPERCENT { get; set; }//贡献量占的百分比         public int TIMES { get; set; }//时次     }

    2.在mapuni.Job/Jobs中新建类:AreaSRCHourJob.cs

        private readonly IMasterRepository<T_Src_AreaHourData> _forecastHourRepository;

    3.在 mapuni.Job/Jobs/CMAQJob.cs中已经 定义了公共类(public class TxtItem)

       在AreaSRCHourJob.cs中不能重复定义TxtItem

        要重写获取文件的方法:private IList<TxtItem> GetFiles(){}

        1>获取日期文件夹

          DateTime outTime = DateTime.Now;             //获取日期文件夹             var dateDirs =                 from fileInfo1 in _fileProvider.GetDirectoryContents(BasePath)                 where fileInfo1.IsDirectory &&                       DateTime.TryParseExact(fileInfo1.Name, "yyyyMMdd", null, DateTimeStyles.None, out outTime)                 select new { FileInfo = fileInfo1, Path = Path.Combine(BasePath, fileInfo1.Name), DateTime = outTime };

    4.protected override void ExecuteInternal(Dictionary<string, string> jobData)

        _forecastHourRepository.AddList(daydatas);

    5.在mapuni.Job/Common中新建类:SRC_Commen.cs.cs

    6.Startup.cs中添加任务

        //20160817源解析数据入库    case "AreaSRCHourJob":    RecurringJob.AddOrUpdate<AreaSRCHourJob>(jobItem.Key, x => x.Execute(jobItem.Value.JobMaps), jobItem.Value.Corn);    break;

    转载请注明原文地址: https://ju.6miu.com/read-1307912.html
    最新回复(0)