[後台] 修改後端排程流程
This commit is contained in:
		
							parent
							
								
									92682051a4
								
							
						
					
					
						commit
						1ca9f9c2ff
					
				@ -97,47 +97,47 @@ namespace BackendWorkerService
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    #region 背景執行計畫(設定1min執行一次)
 | 
			
		||||
                    services.AddSingleton<ExecutionBackgroundServicePlanJob>();
 | 
			
		||||
                    services.AddSingleton(
 | 
			
		||||
                    new JobSchedule(jobType: typeof(ExecutionBackgroundServicePlanJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:ExecutionBackgroundServicePlanJob"))
 | 
			
		||||
                    );
 | 
			
		||||
                    #endregion
 | 
			
		||||
                    //#region 背景執行計畫(設定1min執行一次)
 | 
			
		||||
                    //services.AddSingleton<ExecutionBackgroundServicePlanJob>();
 | 
			
		||||
                    //services.AddSingleton(
 | 
			
		||||
                    //new JobSchedule(jobType: typeof(ExecutionBackgroundServicePlanJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:ExecutionBackgroundServicePlanJob"))
 | 
			
		||||
                    //);
 | 
			
		||||
                    //#endregion
 | 
			
		||||
 | 
			
		||||
                    #region 訊息通知(設定每 30min 執行一次)
 | 
			
		||||
                    services.AddSingleton<MessageNotificationJob>();
 | 
			
		||||
                    services.AddSingleton(
 | 
			
		||||
                    new JobSchedule(jobType: typeof(MessageNotificationJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:MessageNotificationJob"))
 | 
			
		||||
                    );
 | 
			
		||||
                    #endregion
 | 
			
		||||
                    //#region 訊息通知(設定每 30min 執行一次)
 | 
			
		||||
                    //services.AddSingleton<MessageNotificationJob>();
 | 
			
		||||
                    //services.AddSingleton(
 | 
			
		||||
                    //new JobSchedule(jobType: typeof(MessageNotificationJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:MessageNotificationJob"))
 | 
			
		||||
                    //);
 | 
			
		||||
                    //#endregion
 | 
			
		||||
 | 
			
		||||
                    #region 定時將特定資料表加入至派送任務(設定每日 2AM 執行一次)
 | 
			
		||||
                    services.AddSingleton<RegularUpdateDBTableJob>();
 | 
			
		||||
                    services.AddSingleton(
 | 
			
		||||
                    new JobSchedule(jobType: typeof(RegularUpdateDBTableJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:RegularUpdateDBTableJob"))
 | 
			
		||||
                    );
 | 
			
		||||
                    #endregion
 | 
			
		||||
                    //#region 定時將特定資料表加入至派送任務(設定每日 2AM 執行一次)
 | 
			
		||||
                    //services.AddSingleton<RegularUpdateDBTableJob>();
 | 
			
		||||
                    //services.AddSingleton(
 | 
			
		||||
                    //new JobSchedule(jobType: typeof(RegularUpdateDBTableJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:RegularUpdateDBTableJob"))
 | 
			
		||||
                    //);
 | 
			
		||||
                    //#endregion
 | 
			
		||||
 | 
			
		||||
                    #region 資料派送(設定每 5min 執行一次)
 | 
			
		||||
                    services.AddSingleton<DataDeliveryJob>();
 | 
			
		||||
                    services.AddSingleton(
 | 
			
		||||
                    new JobSchedule(jobType: typeof(DataDeliveryJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:DataDeliveryJob"))
 | 
			
		||||
                    );
 | 
			
		||||
                    #endregion
 | 
			
		||||
                    //#region 資料派送(設定每 5min 執行一次)
 | 
			
		||||
                    //services.AddSingleton<DataDeliveryJob>();
 | 
			
		||||
                    //services.AddSingleton(
 | 
			
		||||
                    //new JobSchedule(jobType: typeof(DataDeliveryJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:DataDeliveryJob"))
 | 
			
		||||
                    //);
 | 
			
		||||
                    //#endregion
 | 
			
		||||
 | 
			
		||||
                    #region 停車場管理(設定每 5秒 執行一次)
 | 
			
		||||
                    services.AddSingleton<ParkingJob>();
 | 
			
		||||
                    services.AddSingleton(
 | 
			
		||||
                    new JobSchedule(jobType: typeof(ParkingJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:ParkingJob"))
 | 
			
		||||
                    );
 | 
			
		||||
                    #endregion
 | 
			
		||||
                    //#region 停車場管理(設定每 5秒 執行一次)
 | 
			
		||||
                    //services.AddSingleton<ParkingJob>();
 | 
			
		||||
                    //services.AddSingleton(
 | 
			
		||||
                    //new JobSchedule(jobType: typeof(ParkingJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:ParkingJob"))
 | 
			
		||||
                    //);
 | 
			
		||||
                    //#endregion
 | 
			
		||||
 | 
			
		||||
                    #region 電錶歸檔(設定每 小時 執行一次)
 | 
			
		||||
                    services.AddSingleton<ArchiveElectricMeterHourJob>();
 | 
			
		||||
                    services.AddSingleton(
 | 
			
		||||
                    new JobSchedule(jobType: typeof(ArchiveElectricMeterHourJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:ArchiveElectricMeterHourJob"))
 | 
			
		||||
                    );
 | 
			
		||||
                    #endregion
 | 
			
		||||
                    //#region 電錶歸檔(設定每 小時 執行一次)
 | 
			
		||||
                    //services.AddSingleton<ArchiveElectricMeterHourJob>();
 | 
			
		||||
                    //services.AddSingleton(
 | 
			
		||||
                    //new JobSchedule(jobType: typeof(ArchiveElectricMeterHourJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:ArchiveElectricMeterHourJob"))
 | 
			
		||||
                    //);
 | 
			
		||||
                    //#endregion
 | 
			
		||||
                    #region 電錶歸檔(設定每 天 執行一次)
 | 
			
		||||
                    services.AddSingleton<ArchiveElectricMeterDayJob>();
 | 
			
		||||
                    services.AddSingleton(
 | 
			
		||||
 | 
			
		||||
@ -200,71 +200,71 @@ namespace BackendWorkerService.Quartz.Jobs
 | 
			
		||||
                        doc.Load("root/PowerfulRain.xml");
 | 
			
		||||
                        var json = JsonConvert.SerializeXmlNode(doc);
 | 
			
		||||
                        var haveinfo = json.Split("info");
 | 
			
		||||
                        if (haveinfo.Length > 2)
 | 
			
		||||
                        {
 | 
			
		||||
                            var observation = JsonConvert.DeserializeObject<RainAPIInfoList>(json);
 | 
			
		||||
                            var area = observation.Alert.Info[0].Area.Where(a => a.Geocode.Value == "63").Select(a => a.AreaDesc).FirstOrDefault();
 | 
			
		||||
                            var sql = $"select id from api_rain where msgType = '{observation.Alert.MsgType}' and onset = '{observation.Alert.Info[0].Onset.ToString("yyyy-MM-dd HH:mm:ss")}' and expires = '{observation.Alert.Info[0].Expires.ToString("yyyy-MM-dd HH:mm:ss")}'";
 | 
			
		||||
                            var NeedCallApi = await backendRepository.GetOneAsync<int>(sql);
 | 
			
		||||
                        //if (haveinfo.Length > 2)
 | 
			
		||||
                        //{
 | 
			
		||||
                        //    var observation = RainApi.Welcome.FromJson(json);
 | 
			
		||||
                        //    var area = observation.Alert.Info[0].Area.Where(a => a.Geocode.Value == "63").Select(a => a.AreaDesc).FirstOrDefault();
 | 
			
		||||
                        //    var sql = $"select id from api_rain where msgType = '{observation.Alert.MsgType}' and onset = '{observation.Alert.Info[0].Onset.ToString("yyyy-MM-dd HH:mm:ss")}' and expires = '{observation.Alert.Info[0].Expires.ToString("yyyy-MM-dd HH:mm:ss")}'";
 | 
			
		||||
                        //    var NeedCallApi = await backendRepository.GetOneAsync<int>(sql);
 | 
			
		||||
 | 
			
		||||
                            Dictionary<string, object> RainAPIdb = new Dictionary<string, object>()
 | 
			
		||||
                            {
 | 
			
		||||
                                { "@msgType", observation.Alert.MsgType},
 | 
			
		||||
                                { "@headline", observation.Alert.Info[0].Headline},
 | 
			
		||||
                                { "@areaDesc", area},
 | 
			
		||||
                                { "@onset", observation.Alert.Info[0].Onset},
 | 
			
		||||
                                { "@expires", observation.Alert.Info[0].Expires},
 | 
			
		||||
                                { "@created_by", "system"},
 | 
			
		||||
                                { "@created_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
 | 
			
		||||
                            };
 | 
			
		||||
                            var id = await backendRepository.AddOneByCustomTableReturnId(RainAPIdb, "api_rain");
 | 
			
		||||
                            if (NeedCallApi != 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                var val = RainValue(observation.Alert.MsgType, observation.Alert.Info[0].Headline);
 | 
			
		||||
                                if (val < 5)
 | 
			
		||||
                                {
 | 
			
		||||
                                    var ReStr = Fetch_PostWithJSONFormat($@"{obixApiConfig.ApiBase}obix/config/Arena/D2/CWB/L110/CAP/D2_CWB_L110_CAP_MET1/SeverityLEVL_RAIN/set", val.ToString());
 | 
			
		||||
                                    UpdatedNiagara("api_rain", ReStr, id);
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        //    Dictionary<string, object> RainAPIdb = new Dictionary<string, object>()
 | 
			
		||||
                        //    {
 | 
			
		||||
                        //        { "@msgType", observation.Alert.MsgType},
 | 
			
		||||
                        //        { "@headline", observation.Alert.Info[0].Headline},
 | 
			
		||||
                        //        { "@areaDesc", area},
 | 
			
		||||
                        //        { "@onset", observation.Alert.Info[0].Onset},
 | 
			
		||||
                        //        { "@expires", observation.Alert.Info[0].Expires},
 | 
			
		||||
                        //        { "@created_by", "system"},
 | 
			
		||||
                        //        { "@created_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
 | 
			
		||||
                        //    };
 | 
			
		||||
                        //    var id = await backendRepository.AddOneByCustomTableReturnId(RainAPIdb, "api_rain");
 | 
			
		||||
                        //    if (NeedCallApi != 0)
 | 
			
		||||
                        //    {
 | 
			
		||||
                        //        var val = RainValue(observation.Alert.MsgType, observation.Alert.Info[0].Headline);
 | 
			
		||||
                        //        if (val < 5)
 | 
			
		||||
                        //        {
 | 
			
		||||
                        //            var ReStr = Fetch_PostWithJSONFormat($@"{obixApiConfig.ApiBase}obix/config/Arena/D2/CWB/L110/CAP/D2_CWB_L110_CAP_MET1/SeverityLEVL_RAIN/set", val.ToString());
 | 
			
		||||
                        //            UpdatedNiagara("api_rain", ReStr, id);
 | 
			
		||||
                        //        }
 | 
			
		||||
                        //    }
 | 
			
		||||
 | 
			
		||||
                            FolderFunction folderFunction = new FolderFunction();
 | 
			
		||||
                            folderFunction.DeleteFile("root/PowerfulRain.xml");
 | 
			
		||||
                            await task_Detail.InsertWorkTime_End("WeatherAPI", "api_rain");
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            var observation = JsonConvert.DeserializeObject<RainAPI>(json);
 | 
			
		||||
                            var area = observation.Alert.Info.Area.Where(a => a.Geocode.Value == "63").Select(a => a.AreaDesc).FirstOrDefault();
 | 
			
		||||
                            var sql = $"select id from api_rain where msgType = '{observation.Alert.MsgType}' and onset = '{observation.Alert.Info.Onset.ToString("yyyy-MM-dd HH:mm:ss")}' and expires = '{observation.Alert.Info.Expires.ToString("yyyy-MM-dd HH:mm:ss")}'";
 | 
			
		||||
                            var NeedCallApi = await backendRepository.GetOneAsync<int>(sql);
 | 
			
		||||
                        //    FolderFunction folderFunction = new FolderFunction();
 | 
			
		||||
                        //    folderFunction.DeleteFile("root/PowerfulRain.xml");
 | 
			
		||||
                        //    await task_Detail.InsertWorkTime_End("WeatherAPI", "api_rain");
 | 
			
		||||
                        //}
 | 
			
		||||
                        //else
 | 
			
		||||
                        //{
 | 
			
		||||
                        //    var observation = RainApi.Welcome.FromJson(json);
 | 
			
		||||
                        //    var area = observation.Alert.Info[0].Area.Where(a => a.Geocode.Value == "63").Select(a => a.AreaDesc).FirstOrDefault();
 | 
			
		||||
                        //    var sql = $"select id from api_rain where msgType = '{observation.Alert.MsgType}' and onset = '{observation.Alert.Info[0].Onset.ToString("yyyy-MM-dd HH:mm:ss")}' and expires = '{observation.Alert.Info[0].Expires.ToString("yyyy-MM-dd HH:mm:ss")}'";
 | 
			
		||||
                        //    var NeedCallApi = await backendRepository.GetOneAsync<int>(sql);
 | 
			
		||||
 | 
			
		||||
                            Dictionary<string, object> RainAPIdb = new Dictionary<string, object>()
 | 
			
		||||
                            {
 | 
			
		||||
                                { "@msgType", observation.Alert.MsgType},
 | 
			
		||||
                                { "@headline", observation.Alert.Info.Headline},
 | 
			
		||||
                                { "@areaDesc", area},
 | 
			
		||||
                                { "@onset", observation.Alert.Info.Onset.ToString("yyyy-MM-dd HH:mm:ss")},
 | 
			
		||||
                                { "@expires", observation.Alert.Info.Expires.ToString("yyyy-MM-dd HH:mm:ss")},
 | 
			
		||||
                                { "@created_by", "system"},
 | 
			
		||||
                                { "@created_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
 | 
			
		||||
                            };
 | 
			
		||||
                            var id = await backendRepository.AddOneByCustomTableReturnId(RainAPIdb, "api_rain");
 | 
			
		||||
                            if (NeedCallApi != 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                var val = RainValue(observation.Alert.MsgType, observation.Alert.Info.Headline);
 | 
			
		||||
                                if (val < 5)
 | 
			
		||||
                                {
 | 
			
		||||
                                    var ReStr = Fetch_PostWithJSONFormat($@"{obixApiConfig.ApiBase}obix/config/Arena/D2/CWB/L110/CAP/D2_CWB_L110_CAP_MET1/SeverityLEVL_RAIN/set", val.ToString());
 | 
			
		||||
                                    UpdatedNiagara("api_rain", ReStr, id);
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        //    Dictionary<string, object> RainAPIdb = new Dictionary<string, object>()
 | 
			
		||||
                        //    {
 | 
			
		||||
                        //        { "@msgType", observation.Alert.MsgType},
 | 
			
		||||
                        //        { "@headline", observation.Alert.Info[0].Headline},
 | 
			
		||||
                        //        { "@areaDesc", area},
 | 
			
		||||
                        //        { "@onset", observation.Alert.Info[0].Onset.ToString("yyyy-MM-dd HH:mm:ss")},
 | 
			
		||||
                        //        { "@expires", observation.Alert.Info[0].Expires.ToString("yyyy-MM-dd HH:mm:ss")},
 | 
			
		||||
                        //        { "@created_by", "system"},
 | 
			
		||||
                        //        { "@created_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
 | 
			
		||||
                        //    };
 | 
			
		||||
                        //    var id = await backendRepository.AddOneByCustomTableReturnId(RainAPIdb, "api_rain");
 | 
			
		||||
                        //    if (NeedCallApi != 0)
 | 
			
		||||
                        //    {
 | 
			
		||||
                        //        var val = RainValue(observation.Alert.MsgType, observation.Alert.Info[0].Headline);
 | 
			
		||||
                        //        if (val < 5)
 | 
			
		||||
                        //        {
 | 
			
		||||
                        //            var ReStr = Fetch_PostWithJSONFormat($@"{obixApiConfig.ApiBase}obix/config/Arena/D2/CWB/L110/CAP/D2_CWB_L110_CAP_MET1/SeverityLEVL_RAIN/set", val.ToString());
 | 
			
		||||
                        //            UpdatedNiagara("api_rain", ReStr, id);
 | 
			
		||||
                        //        }
 | 
			
		||||
                        //    }
 | 
			
		||||
 | 
			
		||||
                            FolderFunction folderFunction = new FolderFunction();
 | 
			
		||||
                            folderFunction.DeleteFile("root/PowerfulRain.xml");
 | 
			
		||||
                            await task_Detail.InsertWorkTime_End("WeatherAPI", "api_rain");
 | 
			
		||||
                        //    FolderFunction folderFunction = new FolderFunction();
 | 
			
		||||
                        //    folderFunction.DeleteFile("root/PowerfulRain.xml");
 | 
			
		||||
                        //    await task_Detail.InsertWorkTime_End("WeatherAPI", "api_rain");
 | 
			
		||||
 | 
			
		||||
                        }
 | 
			
		||||
                        //}
 | 
			
		||||
                    }
 | 
			
		||||
                    catch (Exception ex)
 | 
			
		||||
                    {
 | 
			
		||||
@ -284,71 +284,71 @@ namespace BackendWorkerService.Quartz.Jobs
 | 
			
		||||
                        var json = JsonConvert.SerializeXmlNode(doc);
 | 
			
		||||
                        var haveinfo = json.Split("info");
 | 
			
		||||
 | 
			
		||||
                        if (haveinfo.Length > 2)
 | 
			
		||||
                        {
 | 
			
		||||
                            var observation = JsonConvert.DeserializeObject<RainAPIInfoList>(json);
 | 
			
		||||
                            var area = observation.Alert.Info[0].Area.Where(a => a.Geocode.Value == "63").Select(a => a.AreaDesc).FirstOrDefault();
 | 
			
		||||
                            var sql = $"select id from api_typhoon where msgType = '{observation.Alert.MsgType}' and onset = '{observation.Alert.Info[0].Onset.ToString("yyyy-MM-dd HH:mm:ss")}' and expires = '{observation.Alert.Info[0].Expires.ToString("yyyy-MM-dd HH:mm:ss")}'";
 | 
			
		||||
                            var NeedCallApi = await backendRepository.GetOneAsync<int>(sql);
 | 
			
		||||
                            Dictionary<string, object> EarthquakeAPIdb = new Dictionary<string, object>()
 | 
			
		||||
                            {
 | 
			
		||||
                                { "@msgType", observation.Alert.MsgType},
 | 
			
		||||
                                { "@headline", observation.Alert.Info[0].Headline},
 | 
			
		||||
                                { "@areaDesc", area},
 | 
			
		||||
                                { "@urgency",observation.Alert.Info[0].Urgency},
 | 
			
		||||
                                { "@severity",observation.Alert.Info[0].Severity},
 | 
			
		||||
                                { "@onset", observation.Alert.Info[0].Onset},
 | 
			
		||||
                                { "@expires", observation.Alert.Info[0].Expires},
 | 
			
		||||
                                { "@created_by", "system"},
 | 
			
		||||
                                { "@created_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
 | 
			
		||||
                            };
 | 
			
		||||
                            var id = await backendRepository.AddOneByCustomTableReturnId(EarthquakeAPIdb, "api_typhoon");
 | 
			
		||||
                            if (NeedCallApi != 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                if (observation.Alert.Info[0].Urgency != null && observation.Alert.Info[0].Urgency != "Expected")
 | 
			
		||||
                                {
 | 
			
		||||
                        //if (haveinfo.Length > 2)
 | 
			
		||||
                        //{
 | 
			
		||||
                        //    var observation = TyphoonApi.Welcome.FromJson(json);
 | 
			
		||||
                        //    var area = observation.Alert.Info.Area.Where(a => a.Geocode.Value == "63").Select(a => a.AreaDesc).FirstOrDefault();
 | 
			
		||||
                        //    var sql = $"select id from api_typhoon where msgType = '{observation.Alert.MsgType}' and onset = '{observation.Alert.Info[0].Onset.ToString("yyyy-MM-dd HH:mm:ss")}' and expires = '{observation.Alert.Info[0].Expires.ToString("yyyy-MM-dd HH:mm:ss")}'";
 | 
			
		||||
                        //    var NeedCallApi = await backendRepository.GetOneAsync<int>(sql);
 | 
			
		||||
                        //    Dictionary<string, object> EarthquakeAPIdb = new Dictionary<string, object>()
 | 
			
		||||
                        //    {
 | 
			
		||||
                        //        { "@msgType", observation.Alert.MsgType},
 | 
			
		||||
                        //        { "@headline", observation.Alert.Info[0].Headline},
 | 
			
		||||
                        //        { "@areaDesc", area},
 | 
			
		||||
                        //        { "@urgency",observation.Alert.Info[0].Urgency},
 | 
			
		||||
                        //        { "@severity",observation.Alert.Info[0].Severity},
 | 
			
		||||
                        //        { "@onset", observation.Alert.Info[0].Onset},
 | 
			
		||||
                        //        { "@expires", observation.Alert.Info[0].Expires},
 | 
			
		||||
                        //        { "@created_by", "system"},
 | 
			
		||||
                        //        { "@created_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
 | 
			
		||||
                        //    };
 | 
			
		||||
                        //    var id = await backendRepository.AddOneByCustomTableReturnId(EarthquakeAPIdb, "api_typhoon");
 | 
			
		||||
                        //    if (NeedCallApi != 0)
 | 
			
		||||
                        //    {
 | 
			
		||||
                        //        if (observation.Alert.Info[0].Urgency != null && observation.Alert.Info[0].Urgency != "Expected")
 | 
			
		||||
                        //        {
 | 
			
		||||
 | 
			
		||||
                                    var ReStr = Fetch_PostWithJSONFormat($@"{obixApiConfig.ApiBase}obix/config/Arena/D2/CWB/L110/CAP/D2_CWB_L110_CAP_MET2/SeverityLEVL_Typhoon/set", observation.Alert.Info[0].Urgency);
 | 
			
		||||
                                    UpdatedNiagara("api_typhoon", ReStr, id);
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            FolderFunction folderFunction = new FolderFunction();
 | 
			
		||||
                            folderFunction.DeleteFile("root/Typhoon.xml");
 | 
			
		||||
                            await task_Detail.InsertWorkTime_End("WeatherAPI", "api_typhoon");
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            var observation = JsonConvert.DeserializeObject<RainAPI>(json);
 | 
			
		||||
                            var area = observation.Alert.Info.Area.Where(a => a.Geocode.Value == "63").Select(a => a.AreaDesc).FirstOrDefault();
 | 
			
		||||
                            var sql = $"select id from api_typhoon where msgType = '{observation.Alert.MsgType}' and onset = '{observation.Alert.Info.Onset.ToString("yyyy-MM-dd HH:mm:ss")}' and expires = '{observation.Alert.Info.Expires.ToString("yyyy-MM-dd HH:mm:ss")}'";
 | 
			
		||||
                            var NeedCallApi = await backendRepository.GetOneAsync<int>(sql);
 | 
			
		||||
                            Dictionary<string, object> EarthquakeAPIdb = new Dictionary<string, object>()
 | 
			
		||||
                            {
 | 
			
		||||
                                { "@msgType", observation.Alert.MsgType},
 | 
			
		||||
                                { "@headline", observation.Alert.Info.Headline},
 | 
			
		||||
                                { "@areaDesc", area},
 | 
			
		||||
                                { "@urgency",observation.Alert.Info.Urgency},
 | 
			
		||||
                                { "@severity",observation.Alert.Info.Severity},
 | 
			
		||||
                                { "@onset", observation.Alert.Info.Onset.ToString("yyyy-MM-dd HH:mm:ss")},
 | 
			
		||||
                                { "@expires", observation.Alert.Info.Expires.ToString("yyyy-MM-dd HH:mm:ss")},
 | 
			
		||||
                                { "@created_by", "system"},
 | 
			
		||||
                                { "@created_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
 | 
			
		||||
                            };
 | 
			
		||||
                            var id = await backendRepository.AddOneByCustomTableReturnId(EarthquakeAPIdb, "api_typhoon");
 | 
			
		||||
                            if (NeedCallApi != 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                if (observation.Alert.Info.Urgency != null && observation.Alert.Info.Urgency != "Expected")
 | 
			
		||||
                                {
 | 
			
		||||
                        //            var ReStr = Fetch_PostWithJSONFormat($@"{obixApiConfig.ApiBase}obix/config/Arena/D2/CWB/L110/CAP/D2_CWB_L110_CAP_MET2/SeverityLEVL_Typhoon/set", observation.Alert.Info[0].Urgency);
 | 
			
		||||
                        //            UpdatedNiagara("api_typhoon", ReStr, id);
 | 
			
		||||
                        //        }
 | 
			
		||||
                        //    }
 | 
			
		||||
                        //    FolderFunction folderFunction = new FolderFunction();
 | 
			
		||||
                        //    folderFunction.DeleteFile("root/Typhoon.xml");
 | 
			
		||||
                        //    await task_Detail.InsertWorkTime_End("WeatherAPI", "api_typhoon");
 | 
			
		||||
                        //}
 | 
			
		||||
                        //else
 | 
			
		||||
                        //{
 | 
			
		||||
                        //    var observation = TyphoonApi.Welcome.FromJson(json);
 | 
			
		||||
                        //    //var area = observation.Alert.Info.Area.Where(a => a.Geocode.Value == "63").Select(a => a.AreaDesc).FirstOrDefault();
 | 
			
		||||
                        //    var sql = $"select id from api_typhoon where msgType = '{observation.Alert.MsgType}' and onset = '{observation.Alert.Info.Onset.ToString("yyyy-MM-dd HH:mm:ss")}' and expires = '{observation.Alert.Info.Expires.ToString("yyyy-MM-dd HH:mm:ss")}'";
 | 
			
		||||
                        //    var NeedCallApi = await backendRepository.GetOneAsync<int>(sql);
 | 
			
		||||
                        //    Dictionary<string, object> EarthquakeAPIdb = new Dictionary<string, object>()
 | 
			
		||||
                        //    {
 | 
			
		||||
                        //        { "@msgType", observation.Alert.MsgType},
 | 
			
		||||
                        //        { "@headline", observation.Alert.Info.Headline},
 | 
			
		||||
                        //        //{ "@areaDesc", area},
 | 
			
		||||
                        //        { "@urgency",observation.Alert.Info.Urgency},
 | 
			
		||||
                        //        { "@severity",observation.Alert.Info.Severity},
 | 
			
		||||
                        //        { "@onset", observation.Alert.Info.Onset.ToString("yyyy-MM-dd HH:mm:ss")},
 | 
			
		||||
                        //        { "@expires", observation.Alert.Info.Expires.ToString("yyyy-MM-dd HH:mm:ss")},
 | 
			
		||||
                        //        { "@created_by", "system"},
 | 
			
		||||
                        //        { "@created_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
 | 
			
		||||
                        //    };
 | 
			
		||||
                        //    var id = await backendRepository.AddOneByCustomTableReturnId(EarthquakeAPIdb, "api_typhoon");
 | 
			
		||||
                        //    if (NeedCallApi != 0)
 | 
			
		||||
                        //    {
 | 
			
		||||
                        //        if (observation.Alert.Info.Urgency != null && observation.Alert.Info.Urgency != "Expected")
 | 
			
		||||
                        //        {
 | 
			
		||||
 | 
			
		||||
                                    var ReStr = Fetch_PostWithJSONFormat($@"{obixApiConfig.ApiBase}obix/config/Arena/D2/CWB/L110/CAP/D2_CWB_L110_CAP_MET2/SeverityLEVL_Typhoon/set", observation.Alert.Info.Urgency);
 | 
			
		||||
                                    UpdatedNiagara("api_typhoon", ReStr, id);
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            FolderFunction folderFunction = new FolderFunction();
 | 
			
		||||
                            folderFunction.DeleteFile("root/Typhoon.xml");
 | 
			
		||||
                            await task_Detail.InsertWorkTime_End("WeatherAPI", "api_typhoon");
 | 
			
		||||
                        //            var ReStr = Fetch_PostWithJSONFormat($@"{obixApiConfig.ApiBase}obix/config/Arena/D2/CWB/L110/CAP/D2_CWB_L110_CAP_MET2/SeverityLEVL_Typhoon/set", observation.Alert.Info.Urgency);
 | 
			
		||||
                        //            UpdatedNiagara("api_typhoon", ReStr, id);
 | 
			
		||||
                        //        }
 | 
			
		||||
                        //    }
 | 
			
		||||
                        //    FolderFunction folderFunction = new FolderFunction();
 | 
			
		||||
                        //    folderFunction.DeleteFile("root/Typhoon.xml");
 | 
			
		||||
                        //    await task_Detail.InsertWorkTime_End("WeatherAPI", "api_typhoon");
 | 
			
		||||
 | 
			
		||||
                        }
 | 
			
		||||
                        //}
 | 
			
		||||
 | 
			
		||||
                    }
 | 
			
		||||
                    catch (Exception ex)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										228
									
								
								BackendWorkerService/Services/Implement/RainApi.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										228
									
								
								BackendWorkerService/Services/Implement/RainApi.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,228 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Text;
 | 
			
		||||
 | 
			
		||||
// <auto-generated />
 | 
			
		||||
//
 | 
			
		||||
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
 | 
			
		||||
//
 | 
			
		||||
//    using QuickType;
 | 
			
		||||
//
 | 
			
		||||
//    var welcome = Welcome.FromJson(jsonString);
 | 
			
		||||
 | 
			
		||||
namespace RainApi
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
    using System.Globalization;
 | 
			
		||||
    using Newtonsoft.Json;
 | 
			
		||||
    using Newtonsoft.Json.Converters;
 | 
			
		||||
 | 
			
		||||
    public partial class Welcome
 | 
			
		||||
    {
 | 
			
		||||
        [JsonProperty("?xml")]
 | 
			
		||||
        public Xml Xml { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("alert")]
 | 
			
		||||
        public Alert Alert { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public partial class Alert
 | 
			
		||||
    {
 | 
			
		||||
        [JsonProperty("@xmlns")]
 | 
			
		||||
        public string Xmlns { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("identifier")]
 | 
			
		||||
        public string Identifier { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("sender")]
 | 
			
		||||
        public string Sender { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("sent")]
 | 
			
		||||
        public DateTimeOffset Sent { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("status")]
 | 
			
		||||
        public string Status { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("msgType")]
 | 
			
		||||
        public string MsgType { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("scope")]
 | 
			
		||||
        public string Scope { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("references")]
 | 
			
		||||
        public string References { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("info")]
 | 
			
		||||
        public Info[] Info { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public partial class Info
 | 
			
		||||
    {
 | 
			
		||||
        [JsonProperty("language")]
 | 
			
		||||
        public string Language { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("category")]
 | 
			
		||||
        public string Category { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("event")]
 | 
			
		||||
        public string Event { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("responseType")]
 | 
			
		||||
        public string ResponseType { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("urgency")]
 | 
			
		||||
        public string Urgency { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("severity")]
 | 
			
		||||
        public string Severity { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("certainty")]
 | 
			
		||||
        public string Certainty { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("eventCode")]
 | 
			
		||||
        public EventCode EventCode { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("effective")]
 | 
			
		||||
        public DateTimeOffset Effective { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("onset")]
 | 
			
		||||
        public DateTimeOffset Onset { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("expires")]
 | 
			
		||||
        public DateTimeOffset Expires { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("senderName")]
 | 
			
		||||
        public string SenderName { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("headline")]
 | 
			
		||||
        public string Headline { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("description")]
 | 
			
		||||
        public string Description { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("web")]
 | 
			
		||||
        public Uri Web { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("parameter")]
 | 
			
		||||
        public EventCode[] Parameter { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("area")]
 | 
			
		||||
        public Area[] Area { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public partial class Area
 | 
			
		||||
    {
 | 
			
		||||
        [JsonProperty("areaDesc")]
 | 
			
		||||
        public string AreaDesc { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("geocode")]
 | 
			
		||||
        public EventCode Geocode { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public partial class EventCode
 | 
			
		||||
    {
 | 
			
		||||
        [JsonProperty("valueName")]
 | 
			
		||||
        public ValueName ValueName { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("value")]
 | 
			
		||||
        public string Value { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public partial class Xml
 | 
			
		||||
    {
 | 
			
		||||
        [JsonProperty("@version")]
 | 
			
		||||
        public string Version { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("@encoding")]
 | 
			
		||||
        public string Encoding { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public enum ValueName { AlertColor, AlertTitle, ProfileCapTwpEvent10, SeverityLevel, TaiwanGeocode103, WebsiteColor };
 | 
			
		||||
 | 
			
		||||
    public partial class Welcome
 | 
			
		||||
    {
 | 
			
		||||
        public static Welcome FromJson(string json) => JsonConvert.DeserializeObject<Welcome>(json, QuickType.Converter.Settings);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static class Serialize
 | 
			
		||||
    {
 | 
			
		||||
        public static string ToJson(this Welcome self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    internal static class Converter
 | 
			
		||||
    {
 | 
			
		||||
        public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
 | 
			
		||||
        {
 | 
			
		||||
            MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
 | 
			
		||||
            DateParseHandling = DateParseHandling.None,
 | 
			
		||||
            Converters =
 | 
			
		||||
            {
 | 
			
		||||
                ValueNameConverter.Singleton,
 | 
			
		||||
                new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
 | 
			
		||||
            },
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    internal class ValueNameConverter : JsonConverter
 | 
			
		||||
    {
 | 
			
		||||
        public override bool CanConvert(Type t) => t == typeof(ValueName) || t == typeof(ValueName?);
 | 
			
		||||
 | 
			
		||||
        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            if (reader.TokenType == JsonToken.Null) return null;
 | 
			
		||||
            var value = serializer.Deserialize<string>(reader);
 | 
			
		||||
            switch (value)
 | 
			
		||||
            {
 | 
			
		||||
                case "Taiwan_Geocode_103":
 | 
			
		||||
                    return ValueName.TaiwanGeocode103;
 | 
			
		||||
                case "alert_color":
 | 
			
		||||
                    return ValueName.AlertColor;
 | 
			
		||||
                case "alert_title":
 | 
			
		||||
                    return ValueName.AlertTitle;
 | 
			
		||||
                case "profile:CAP-TWP:Event:1.0":
 | 
			
		||||
                    return ValueName.ProfileCapTwpEvent10;
 | 
			
		||||
                case "severity_level":
 | 
			
		||||
                    return ValueName.SeverityLevel;
 | 
			
		||||
                case "website_color":
 | 
			
		||||
                    return ValueName.WebsiteColor;
 | 
			
		||||
            }
 | 
			
		||||
            throw new Exception("Cannot unmarshal type ValueName");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            if (untypedValue == null)
 | 
			
		||||
            {
 | 
			
		||||
                serializer.Serialize(writer, null);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            var value = (ValueName)untypedValue;
 | 
			
		||||
            switch (value)
 | 
			
		||||
            {
 | 
			
		||||
                case ValueName.TaiwanGeocode103:
 | 
			
		||||
                    serializer.Serialize(writer, "Taiwan_Geocode_103");
 | 
			
		||||
                    return;
 | 
			
		||||
                case ValueName.AlertColor:
 | 
			
		||||
                    serializer.Serialize(writer, "alert_color");
 | 
			
		||||
                    return;
 | 
			
		||||
                case ValueName.AlertTitle:
 | 
			
		||||
                    serializer.Serialize(writer, "alert_title");
 | 
			
		||||
                    return;
 | 
			
		||||
                case ValueName.ProfileCapTwpEvent10:
 | 
			
		||||
                    serializer.Serialize(writer, "profile:CAP-TWP:Event:1.0");
 | 
			
		||||
                    return;
 | 
			
		||||
                case ValueName.SeverityLevel:
 | 
			
		||||
                    serializer.Serialize(writer, "severity_level");
 | 
			
		||||
                    return;
 | 
			
		||||
                case ValueName.WebsiteColor:
 | 
			
		||||
                    serializer.Serialize(writer, "website_color");
 | 
			
		||||
                    return;
 | 
			
		||||
            }
 | 
			
		||||
            throw new Exception("Cannot marshal type ValueName");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static readonly ValueNameConverter Singleton = new ValueNameConverter();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										283
									
								
								BackendWorkerService/Services/Implement/TyphoonApi.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										283
									
								
								BackendWorkerService/Services/Implement/TyphoonApi.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,283 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Text;
 | 
			
		||||
 | 
			
		||||
// <auto-generated />
 | 
			
		||||
//
 | 
			
		||||
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
 | 
			
		||||
//
 | 
			
		||||
//    using QuickType;
 | 
			
		||||
//
 | 
			
		||||
//    var welcome = Welcome.FromJson(jsonString);
 | 
			
		||||
 | 
			
		||||
namespace TyphoonApi
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
    using System.Globalization;
 | 
			
		||||
    using Newtonsoft.Json;
 | 
			
		||||
    using Newtonsoft.Json.Converters;
 | 
			
		||||
 | 
			
		||||
    public partial class Welcome
 | 
			
		||||
    {
 | 
			
		||||
        [JsonProperty("?xml")]
 | 
			
		||||
        public Xml Xml { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("alert")]
 | 
			
		||||
        public Alert Alert { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public partial class Alert
 | 
			
		||||
    {
 | 
			
		||||
        [JsonProperty("@xmlns")]
 | 
			
		||||
        public string Xmlns { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("identifier")]
 | 
			
		||||
        public string Identifier { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("sender")]
 | 
			
		||||
        public string Sender { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("sent")]
 | 
			
		||||
        public DateTimeOffset Sent { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("status")]
 | 
			
		||||
        public string Status { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("msgType")]
 | 
			
		||||
        public string MsgType { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("scope")]
 | 
			
		||||
        public string Scope { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("references")]
 | 
			
		||||
        public string References { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("info")]
 | 
			
		||||
        public Info Info { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public partial class Info
 | 
			
		||||
    {
 | 
			
		||||
        [JsonProperty("language")]
 | 
			
		||||
        public string Language { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("category")]
 | 
			
		||||
        public string Category { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("event")]
 | 
			
		||||
        public string Event { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("responseType")]
 | 
			
		||||
        public string ResponseType { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("urgency")]
 | 
			
		||||
        public string Urgency { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("severity")]
 | 
			
		||||
        public string Severity { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("certainty")]
 | 
			
		||||
        public string Certainty { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("eventCode")]
 | 
			
		||||
        public EventCode EventCode { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("effective")]
 | 
			
		||||
        public DateTimeOffset Effective { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("onset")]
 | 
			
		||||
        public DateTimeOffset Onset { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("expires")]
 | 
			
		||||
        public DateTimeOffset Expires { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("senderName")]
 | 
			
		||||
        public string SenderName { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("headline")]
 | 
			
		||||
        public string Headline { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("description")]
 | 
			
		||||
        public Description Description { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("web")]
 | 
			
		||||
        public Uri Web { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("parameter")]
 | 
			
		||||
        public EventCode[] Parameter { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("area")]
 | 
			
		||||
        public Area[] Area { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public partial class Area
 | 
			
		||||
    {
 | 
			
		||||
        [JsonProperty("areaDesc")]
 | 
			
		||||
        public string AreaDesc { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("polygon")]
 | 
			
		||||
        public string Polygon { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public partial class Description
 | 
			
		||||
    {
 | 
			
		||||
        [JsonProperty("typhoon-info")]
 | 
			
		||||
        public TyphoonInfo TyphoonInfo { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("section")]
 | 
			
		||||
        public DescriptionSection[] Section { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public partial class DescriptionSection
 | 
			
		||||
    {
 | 
			
		||||
        [JsonProperty("@title")]
 | 
			
		||||
        public string Title { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("#text")]
 | 
			
		||||
        public string Text { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public partial class TyphoonInfo
 | 
			
		||||
    {
 | 
			
		||||
        [JsonProperty("section")]
 | 
			
		||||
        public TyphoonInfoSection[] Section { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public partial class TyphoonInfoSection
 | 
			
		||||
    {
 | 
			
		||||
        [JsonProperty("@title")]
 | 
			
		||||
        public string Title { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("#text", NullValueHandling = NullValueHandling.Ignore)]
 | 
			
		||||
        public string Text { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("typhoon_name", NullValueHandling = NullValueHandling.Ignore)]
 | 
			
		||||
        public string TyphoonName { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("cwb_typhoon_name", NullValueHandling = NullValueHandling.Ignore)]
 | 
			
		||||
        public string CwbTyphoonName { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("analysis", NullValueHandling = NullValueHandling.Ignore)]
 | 
			
		||||
        public Analysis Analysis { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("prediction", NullValueHandling = NullValueHandling.Ignore)]
 | 
			
		||||
        public Analysis Prediction { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public partial class Analysis
 | 
			
		||||
    {
 | 
			
		||||
        [JsonProperty("time")]
 | 
			
		||||
        public DateTimeOffset Time { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("position")]
 | 
			
		||||
        public string Position { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("max_winds")]
 | 
			
		||||
        public Gust MaxWinds { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("gust")]
 | 
			
		||||
        public Gust Gust { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("pressure")]
 | 
			
		||||
        public Gust Pressure { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("radius_of_15mps")]
 | 
			
		||||
        public Gust RadiusOf15Mps { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("scale", NullValueHandling = NullValueHandling.Ignore)]
 | 
			
		||||
        public Scale[] Scale { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public partial class Gust
 | 
			
		||||
    {
 | 
			
		||||
        [JsonProperty("@unit")]
 | 
			
		||||
        public string Unit { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("#text")]
 | 
			
		||||
        [JsonConverter(typeof(ParseStringConverter))]
 | 
			
		||||
        public long Text { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public partial class Scale
 | 
			
		||||
    {
 | 
			
		||||
        [JsonProperty("@lang")]
 | 
			
		||||
        public string Lang { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("#text")]
 | 
			
		||||
        public string Text { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public partial class EventCode
 | 
			
		||||
    {
 | 
			
		||||
        [JsonProperty("valueName")]
 | 
			
		||||
        public string ValueName { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("value")]
 | 
			
		||||
        public string Value { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public partial class Xml
 | 
			
		||||
    {
 | 
			
		||||
        [JsonProperty("@version")]
 | 
			
		||||
        public string Version { get; set; }
 | 
			
		||||
 | 
			
		||||
        [JsonProperty("@encoding")]
 | 
			
		||||
        public string Encoding { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public partial class Welcome
 | 
			
		||||
    {
 | 
			
		||||
        public static Welcome FromJson(string json) => JsonConvert.DeserializeObject<Welcome>(json, QuickType.Converter.Settings);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static class Serialize
 | 
			
		||||
    {
 | 
			
		||||
        public static string ToJson(this Welcome self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    internal static class Converter
 | 
			
		||||
    {
 | 
			
		||||
        public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
 | 
			
		||||
        {
 | 
			
		||||
            MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
 | 
			
		||||
            DateParseHandling = DateParseHandling.None,
 | 
			
		||||
            Converters =
 | 
			
		||||
            {
 | 
			
		||||
                new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
 | 
			
		||||
            },
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    internal class ParseStringConverter : JsonConverter
 | 
			
		||||
    {
 | 
			
		||||
        public override bool CanConvert(Type t) => t == typeof(long) || t == typeof(long?);
 | 
			
		||||
 | 
			
		||||
        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            if (reader.TokenType == JsonToken.Null) return null;
 | 
			
		||||
            var value = serializer.Deserialize<string>(reader);
 | 
			
		||||
            long l;
 | 
			
		||||
            if (Int64.TryParse(value, out l))
 | 
			
		||||
            {
 | 
			
		||||
                return l;
 | 
			
		||||
            }
 | 
			
		||||
            throw new Exception("Cannot unmarshal type long");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
 | 
			
		||||
        {
 | 
			
		||||
            if (untypedValue == null)
 | 
			
		||||
            {
 | 
			
		||||
                serializer.Serialize(writer, null);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            var value = (long)untypedValue;
 | 
			
		||||
            serializer.Serialize(writer, value.ToString());
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static readonly ParseStringConverter Singleton = new ParseStringConverter();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1155
									
								
								BackendWorkerService/root/PowerfulRain.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1155
									
								
								BackendWorkerService/root/PowerfulRain.xml
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										64
									
								
								BackendWorkerService/root/Typhoon.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								BackendWorkerService/root/Typhoon.xml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,64 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<alert xmlns="urn:oasis:names:tc:emergency:cap:1.2">
 | 
			
		||||
    
 | 
			
		||||
    <identifier>CWB-Weather_typhoon-warning_202305311430001</identifier>
 | 
			
		||||
    <sender>weather@cwb.gov.tw</sender>
 | 
			
		||||
    <sent>2023-05-31T14:22:22+08:00</sent>
 | 
			
		||||
    <status>Actual</status>
 | 
			
		||||
    <msgType>Update</msgType>
 | 
			
		||||
    <scope>Public</scope>
 | 
			
		||||
    <references>weather@cwb.gov.tw,CWB-Weather_typhoon-warning_202305311130001,2023-05-31T11:24:11+08:00</references>
 | 
			
		||||
    <info>
 | 
			
		||||
        <language>zh-TW</language>
 | 
			
		||||
        <category>Met</category>
 | 
			
		||||
        <event>颱風</event>
 | 
			
		||||
        <responseType>Monitor</responseType>
 | 
			
		||||
        <urgency>Future</urgency>
 | 
			
		||||
        <severity>Moderate</severity>
 | 
			
		||||
        <certainty>Likely</certainty>
 | 
			
		||||
        <eventCode>
 | 
			
		||||
            <valueName>profile:CAP-TWP:Event:1.0</valueName>
 | 
			
		||||
            <value>typhoon</value>
 | 
			
		||||
        </eventCode>
 | 
			
		||||
        <effective>2023-05-31T14:30:00+08:00</effective>
 | 
			
		||||
        <onset>2023-05-31T14:30:00+08:00</onset>
 | 
			
		||||
        <expires>2023-05-31T18:30:00+08:00</expires>
 | 
			
		||||
        <senderName>中央氣象局</senderName>
 | 
			
		||||
        <headline>海上颱風警報</headline>
 | 
			
		||||
        <description>
 | 
			
		||||
<typhoon-info><section title="警報報數">15</section><section title="警報類別">SEA</section><section title="颱風編號">2</section><section title="颱風資訊"><typhoon_name>MAWAR</typhoon_name><cwb_typhoon_name>瑪娃</cwb_typhoon_name><analysis><time>2023-05-31T06:00:00+00:00</time><position>22.20,125.20</position><max_winds unit="m/s">33</max_winds><gust unit="m/s">43</gust><pressure unit="hPa">970</pressure><radius_of_15mps unit="km">300</radius_of_15mps><scale lang="zh-TW">中度颱風</scale><scale lang="en">TYPHOON</scale></analysis><prediction><time>2023-06-01T06:00:00+00:00</time><position>24.80,126.20</position><max_winds unit="m/s">30</max_winds><gust unit="m/s">38</gust><pressure unit="hPa">975</pressure><radius_of_15mps unit="km">250</radius_of_15mps></prediction></section></typhoon-info><section title="命名與位置">中度颱風 瑪娃(國際命名 MAWAR)31日14時的中心位置在北緯 22.2 度,東經 125.2 度,即在鵝鑾鼻的東方約 440 公里之海面上。</section><section title="強度與半徑">中心氣壓 970 百帕,近中心最大風速每秒 33 公尺(約每小時 119 公里),相當於 12 級風,瞬間最大陣風每秒 43 公尺(約每小時 155 公里),相當於 14 級風,七級風暴風半徑 300 公里,十級風暴風半徑 100 公里。</section><section title="移速與預測">以每小時14公里速度,向北北東進行,預測1日14時的中心位置在北緯 24.8 度,東經 126.2 度,即在宜蘭的東方約 450 公里之海面上。</section><section title="颱風動態">根據最新資料顯示,第2號颱風中心目前在鵝鑾鼻東方海面,向北北東移動,其暴風圈正掠過臺灣東南部近海,對巴士海峽及臺灣東半部海面構成威脅。預計此颱風未來強度有稍減弱且暴風圈亦有縮小的趨勢。</section><section title="警戒區域及事項">巴士海峽、臺灣東南部海面(含蘭嶼、綠島)、臺灣東北部海面航行及作業船隻應嚴加戒備。</section><section title="豪雨特報">颱風外圍環流影響,易有短延時強降雨,今(31)日宜蘭縣、新北市及臺中市山區有局部大雨或豪雨發生,大臺北、桃園、新竹、花蓮地區及南投山區(奇萊山區)有局部大雨發生的機率,請注意強陣風,山區請注意落石及坍方。</section><section title="注意事項">*巴士海峽及臺灣附近各海面風浪明顯偏大;基隆北海岸、南部、東半部(含蘭嶼、綠島)、恆春半島沿海及澎湖、馬祖易有長浪發生,尤其東半部(含蘭嶼、綠島)、基隆北海岸、恆春半島沿海易有4至5米浪高,請避免前往海邊活動。*陸上強風特報:今(31)日臺南至苗栗沿海空曠地區及澎湖、蘭嶼、綠島易有9至10級強陣風,新竹以北、基隆北海岸、東半部沿海空曠地區、臺南至苗栗地區、恆春半島、金門、馬祖亦有較強陣風,請特別注意。*颱風外圍沉降影響,今(31日)白天臺南、高雄、屏東及金門有局部36度以上高溫出現的機率,請注意。*30日0時至31日14時出現較大累積雨量如下:宜蘭縣翠峰湖316.0毫米,臺中市南湖圈谷232.0毫米。*本警報單之颱風半徑為平均半徑,第2號颱風之7級風暴風半徑近似正圓,平均半徑約為300公里。颱風詳細特性請參考本局颱輔助說明(https://www.cwb.gov.tw/Data/typhoon/TY_PDF.pdf)。*若此颱風行徑無特殊變化,本局預計於今(31)日17時30分解除海上颱風警報。</section>
 | 
			
		||||
        </description>
 | 
			
		||||
        <web>https://www.cwb.gov.tw/V8/C/P/Warning/FIFOWS.html</web>
 | 
			
		||||
        <parameter>
 | 
			
		||||
            <valueName>alert_title</valueName>
 | 
			
		||||
            <value>颱風警報</value>
 | 
			
		||||
        </parameter>
 | 
			
		||||
        <parameter>
 | 
			
		||||
            <valueName>severity_level</valueName>
 | 
			
		||||
            <value>海上颱風警報</value>
 | 
			
		||||
        </parameter>
 | 
			
		||||
        <parameter>
 | 
			
		||||
            <valueName>alert_color</valueName>
 | 
			
		||||
            <value>橙色</value>
 | 
			
		||||
        </parameter>
 | 
			
		||||
        <parameter>
 | 
			
		||||
            <valueName>website_color</valueName>
 | 
			
		||||
            <value>255,0,0</value>
 | 
			
		||||
        </parameter>
 | 
			
		||||
        
 | 
			
		||||
  
 | 
			
		||||
        <area>
 | 
			
		||||
            <areaDesc>巴士海峽東部</areaDesc>
 | 
			
		||||
            <polygon>20.00,121.50 20.00,121.00 20.50,121.00 21.00,121.00 21.50,121.00 22.00,121.00 22.00,121.50 22.00,122.00 22.00,122.50 22.00,123.00 21.50,123.00 21.00,123.00 20.50,123.00 20.00,123.00 20.00,122.50 20.00,122.00 20.00,121.50</polygon>
 | 
			
		||||
        </area>
 | 
			
		||||
        <area>
 | 
			
		||||
            <areaDesc>臺灣東北部海面</areaDesc>
 | 
			
		||||
            <polygon>23.50,122.00 23.50,121.50 23.70,121.54 23.90,121.60 23.98,121.61 24.00,121.61 24.03,121.62 24.04,121.61 24.06,121.60 24.08,121.61 24.18,121.66 24.21,121.68 24.29,121.74 24.29,121.75 24.30,121.77 24.33,121.76 24.41,121.78 24.43,121.78 24.45,121.80 24.46,121.80 24.46,121.82 24.47,121.83 24.48,121.84 24.50,121.85 24.53,121.85 24.56,121.85 24.59,121.85 24.61,121.84 24.61,121.83 24.62,121.82 24.64,121.82 24.75,121.80 24.76,121.80 24.79,121.81 24.84,121.81 24.85,121.82 24.87,121.83 24.93,121.88 24.96,121.91 24.98,121.95 24.99,121.97 24.99,121.98 25.00,121.99 25.00,122.00 25.00,122.00 25.00,122.50 25.00,123.00 24.50,123.00 24.00,123.00 23.50,123.00 23.50,122.50 23.50,122.00</polygon>
 | 
			
		||||
        </area>
 | 
			
		||||
        <area>
 | 
			
		||||
            <areaDesc>臺灣東南部海面</areaDesc>
 | 
			
		||||
            <polygon>22.00,121.50 22.00,121.00 22.00,120.86 22.04,120.88 22.10,120.88 22.23,120.88 22.28,120.87 22.29,120.87 22.32,120.87 22.34,120.88 22.50,120.94 22.54,120.96 22.57,120.97 22.61,121.00 22.64,121.01 22.66,121.03 22.71,121.08 22.72,121.11 22.72,121.12 22.73,121.13 22.74,121.14 22.76,121.17 22.90,121.26 23.00,121.31 23.09,121.36 23.33,121.45 23.40,121.47 23.41,121.48 23.42,121.48 23.49,121.50 23.50,121.50 23.50,122.00 23.50,122.50 23.50,123.00 23.00,123.00 22.50,123.00 22.00,123.00 22.00,122.50 22.00,122.00 22.00,121.50</polygon>
 | 
			
		||||
        </area>
 | 
			
		||||
    </info>
 | 
			
		||||
 | 
			
		||||
</alert>
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user