// 주소 클릭시 이벤트 함수 void addressItem_Click(object sender, EventArgs e) { ToolStripItem clickedItem = sender as ToolStripItem; AddressLine tmpAL = (AddressLine)clickedItem.Tag; currentSelectedIndex = tmpAL.IndexNo; // 수집 주소 labelAddr.Text = tmpAL.Address; // 수집 간격 옵션 labelCrawlTerm.Text = "수집간격 - " + UtilManager.ConvertCrawlTerm(tmpAL.CrawlTerm); // 수집 상태 if ("R" == tmpAL.CrawlStatus) { labelRunStatus.Text = Fonts.fa.recycle + " " + UtilManager.ConvertCrawlStatus(tmpAL.CrawlStatus); } else { labelRunStatus.Text = Fonts.fa.hand_stop_o + " " + UtilManager.ConvertCrawlStatus(tmpAL.CrawlStatus); } currentSelectedRunStatus = tmpAL.CrawlStatus; // 로그 loManagerForAddress.StopOutput(); loManagerForAddress = new LogOutputManager(tmpAL.IndexNo, textBoxPrivateLog); }
/* * http://newsky2.kma.go.kr/service/SecndSrtpdFrcstInfoService2/ForecastSpaceData? * serviceKey=73Jjl5lZRvBRKkGsPnGmZ7EL9JtwsWNi3hhCIN8cpVJzMdRRgyzntwz2lHmTKeR1tp7NWzoihNGGazcDEFgh8w%3D%3D * &base_date=20180626 * &base_time=0500 * &nx=60 * &ny=127 * &numOfRows=500 * &pageSize=500 * &pageNo=1 * &startPage=1 * &_type=json * */ private static async Task <ForecastTimeSpaceResult> GetForecastSpace(string url, string nx, string ny) { string baseDate = UtilManager.GetBaseDateTimeForForecastTime().Substring(0, 8); string baseTime = UtilManager.GetBaseDateTimeForForecastTime().Substring(8, 4); string page = url + "serviceKey=" + ServiceKey + "&base_date=" + baseDate + "&base_time=0500" + "&nx=" + nx + "&ny=" + ny + "&numOfRows=500" + "&pageSize=500" + "&pageNo=1" + "&startPage=1" + "&_type=json"; using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); using (HttpResponseMessage response = await client.GetAsync(page)) using (HttpContent content = response.Content) { var stringResult = await content.ReadAsStringAsync(); ForecastTimeSpaceResult result = JsonConvert.DeserializeObject <ForecastTimeSpaceResult>(stringResult); return(result); } } }
public List <string> ReadFwjournalLands() { IMongoCollection <BsonDocument> collection = Db.GetCollection <BsonDocument>("lands"); var filter = new BsonDocument(); List <string> distinctResult = collection.Distinct <string>("address", filter).ToList(); for (int i = 0; i < distinctResult.Count; i++) { distinctResult[i] = UtilManager.TrimAddress(distinctResult[i]); } return(distinctResult); }
public void WriteAddress(string address, double nx, double ny) { // 인덱스번호 얻기 StreamReader sr = new StreamReader(new FileStream(FwjIni, FileMode.OpenOrCreate)); long fileSize = sr.BaseStream.Length; sr.Close(); string maxAddressIndex = null; if (0 == fileSize) { MessageBox.Show("영농일지 주소 정보가 없습니다3"); } else { sr = new StreamReader(new FileStream(FwjIni, FileMode.OpenOrCreate)); string readLine = sr.ReadLine(); // DB 접속정보 읽기 if (null == (readLine = sr.ReadLine())) // 주소정보 읽기 시작 { maxAddressIndex = "f0"; } else { List <string> addressindexes = new List <string>(); while (null != readLine) // 주소정보 읽기 시작 { string[] addressInfo = readLine.Split('|'); string addressIndex = addressInfo[0]; addressindexes.Add(addressIndex); readLine = sr.ReadLine(); } maxAddressIndex = UtilManager.GetMaxAddressIndex(addressindexes); } sr.Close(); } // 쓰기 StreamWriter sw = new StreamWriter(FwjIni, true, System.Text.Encoding.Default); sw.WriteLine(maxAddressIndex + "|" + address + "|" + nx + "|" + ny + "|" + "1H" + "|" + "S"); sw.Close(); }
// 현재 주소 버튼 메뉴 초기화 private void InitializeContextMenuStripAddress() { // 이미 메뉴에 아이템이 생성되어 있다면 모두 지움 if (0 < contextMenuStripAddress.Items.Count) { contextMenuStripAddress.Items.Clear(); } // fwjournal.ini 읽어서 주소 메뉴에 추가 FwjournalIniManager fiManager = new FwjournalIniManager(); fiManager.ReadAddress(); foreach (var address in fiManager.Addresses) { /* * ToolStripItem addressItem = contextMenuStripAddress.Items.Add(address.Address + " " + * UtilManager.ConvertCrawlTerm(address.CrawlTerm) + " " + * UtilManager.ConvertCrawlStatus(address.CrawlStatus)); */ ToolStripItem addressItem = contextMenuStripAddress.Items.Add(address.Address.PadRight(25, '-') + UtilManager.ConvertCrawlTerm(address.CrawlTerm).PadRight(25, '-') + UtilManager.ConvertCrawlStatus(address.CrawlStatus)); addressItem.Tag = address; addressItem.Click += new EventHandler(addressItem_Click); addressItem.ForeColor = Color.White; } // address.ini 읽어서 메뉴에 추가 AddressIniManager aiManager = new AddressIniManager(); aiManager.ReadAddress(); foreach (var address in aiManager.Addresses) { /* * ToolStripItem addressItem = contextMenuStripAddress.Items.Add(address.Address + " " + * UtilManager.ConvertCrawlTerm(address.CrawlTerm) + " " + * UtilManager.ConvertCrawlStatus(address.CrawlStatus)); */ ToolStripItem addressItem = contextMenuStripAddress.Items.Add(address.Address.PadRight(25, '-') + UtilManager.ConvertCrawlTerm(address.CrawlTerm).PadRight(25, '-') + UtilManager.ConvertCrawlStatus(address.CrawlStatus)); addressItem.Tag = address; addressItem.Click += new EventHandler(addressItem_Click); addressItem.ForeColor = Color.White; } }
// 툴바 리셋 void ResetToolBar() { // fwjournal.ini 읽기 FwjournalIniManager fiManager = new FwjournalIniManager(); fiManager.ReadAddress(); // 현재주소 버튼 labelAddr.Text = fiManager.Addresses[0].Address; // 수집옵션 버튼 labelCrawlTerm.Text = "수집간격 - " + UtilManager.ConvertCrawlTerm(fiManager.Addresses[0].CrawlTerm); // 수집상태 버튼 labelRunStatus.Text = Fonts.fa.recycle + " " + UtilManager.ConvertCrawlStatus(fiManager.Addresses[0].CrawlStatus); // 변수 초기화 currentSelectedIndex = "f0"; currentSelectedRunStatus = fiManager.Addresses[0].CrawlStatus; }
// 수집간격 옵션 클릭시 이벤트 함수 void optionItem_Click(object sender, EventArgs e) { ToolStripItem clickedItem = sender as ToolStripItem; labelCrawlTerm.Text = "수집간격 - " + UtilManager.ConvertCrawlTerm(clickedItem.Tag.ToString()); if (currentSelectedIndex.Contains("f")) { FwjournalIniManager fjiManager = new FwjournalIniManager(); fjiManager.WriteCrawlTerm(currentSelectedIndex, clickedItem.Tag.ToString()); } else { AddressIniManager aiManager = new AddressIniManager(); aiManager.WriteCrawlTerm(currentSelectedIndex, clickedItem.Tag.ToString()); } // 현재 주소 리스트 초기화 InitializeContextMenuStripAddress(); RunCrawlAndCheck(); }
// 수집 상태 토글 버튼 private void buttonRunStatus_Click(object sender, EventArgs e) { // Console.WriteLine("buttonRunStatus_Click"); FwjournalIniManager fjiManager = new FwjournalIniManager(); AddressIniManager aiManager = new AddressIniManager(); if ("R" == currentSelectedRunStatus) { PauseJob(); labelRunStatus.Text = Fonts.fa.hand_stop_o + " " + UtilManager.ConvertCrawlStatus("S"); currentSelectedRunStatus = "S"; if (currentSelectedIndex.Contains("f")) { fjiManager.WriteCrawlStatus(currentSelectedIndex, "S"); } else { aiManager.WriteCrawlStatus(currentSelectedIndex, "S"); } } else { ResumeJob(); labelRunStatus.Text = Fonts.fa.recycle + " " + UtilManager.ConvertCrawlStatus("R"); currentSelectedRunStatus = "R"; if (currentSelectedIndex.Contains("f")) { fjiManager.WriteCrawlStatus(currentSelectedIndex, "R"); } else { aiManager.WriteCrawlStatus(currentSelectedIndex, "R"); } } // 현재 주소 리스트 초기화 InitializeContextMenuStripAddress(); }
/* * http://openapi.airkorea.or.kr/openapi/services/rest/MsrstnInfoInqireSvc/getTMStdrCrdnt? * umdName=일도이동 * &pageNo=1 * &numOfRows=10 * &ServiceKey=73Jjl5lZRvBRKkGsPnGmZ7EL9JtwsWNi3hhCIN8cpVJzMdRRgyzntwz2lHmTKeR1tp7NWzoihNGGazcDEFgh8w%3D%3D * &_returnType=json * */ private static async Task <AirDataResult> GetAirData(string url, string umd) { JusoResult jibunJuso = await GetJibunJuso(umd); string page = url + "umdName=" + UtilManager.GetUmdFromAddress(jibunJuso.results.juso[0].jibunAddr) + "&pageNo=1" + "&numOfRows=10" + "&ServiceKey=" + ServiceKeyForAir + "&_returnType=json"; Console.WriteLine("GetAirData says: {0}", page); using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); using (HttpResponseMessage response = await client.GetAsync(page)) using (HttpContent content = response.Content) { // TmX, TmY 조회 var stringResult = await content.ReadAsStringAsync(); AirDataMetaResult resultTmXY = JsonConvert.DeserializeObject <AirDataMetaResult>(stringResult); // 측정소명 조회 AirDataMetaResult resultStationName = await GetStationName("http://openapi.airkorea.or.kr/openapi/services/rest/MsrstnInfoInqireSvc/getNearbyMsrstnList?", resultTmXY.list[0].tmX, resultTmXY.list[0].tmY); // 측정값 조회 AirDataResult result = await GetAirMeasure("http://openapi.airkorea.or.kr/openapi/services/rest/ArpltnInforInqireSvc/getMsrstnAcctoRltmMesureDnsty?", resultStationName.list[0].stationName); return(result); } } }
// 툴바 초기화 void InitializeToolBar() { // fwjournal.ini 읽기 FwjournalIniManager fiManager = new FwjournalIniManager(); fiManager.ReadAddress(); // 현재주소 버튼 labelCurrentAddr.Parent = buttonAddr; labelCurrentAddr.BackColor = Color.Transparent; Fonts.Reload(16); labelCurrentAddr.Font = Fonts.FontAwesome; labelCurrentAddr.Text = "현재주소 " + Fonts.fa.sort_down; labelCurrentAddr.MouseEnter += OnMouseEnterButtonAddr; labelCurrentAddr.MouseLeave += OnMouseLeaveButtonAddr; labelAddr.Parent = buttonAddr; labelAddr.BackColor = Color.Transparent; labelAddr.MouseEnter += OnMouseEnterButtonAddr; labelAddr.MouseLeave += OnMouseLeaveButtonAddr; buttonAddr.BackColor = Color.FromArgb(45, 45, 48); buttonAddr.MouseEnter += OnMouseEnterButtonAddr; buttonAddr.MouseLeave += OnMouseLeaveButtonAddr; if (0 < fiManager.Addresses.Count) { labelAddr.Text = fiManager.Addresses[0].Address; } // 수집옵션 버튼 labelCrawlOption.Parent = buttonCrawlOption; labelCrawlOption.BackColor = Color.Transparent; labelCrawlOption.Font = Fonts.FontAwesome; labelCrawlOption.Text = Fonts.fa.cogs + " 수집옵션"; labelCrawlOption.MouseEnter += OnMouseEnterButtonCrawlOption; labelCrawlOption.MouseLeave += OnMouseLeaveButtonCrawlOption; labelCrawlTerm.Parent = buttonCrawlOption; labelCrawlTerm.BackColor = Color.Transparent; labelCrawlTerm.MouseEnter += OnMouseEnterButtonCrawlOption; labelCrawlTerm.MouseLeave += OnMouseLeaveButtonCrawlOption; buttonCrawlOption.BackColor = Color.FromArgb(45, 45, 48); buttonCrawlOption.MouseEnter += OnMouseEnterButtonCrawlOption; buttonCrawlOption.MouseLeave += OnMouseLeaveButtonCrawlOption; if (0 < fiManager.Addresses.Count) { labelCrawlTerm.Text = "수집간격 - " + UtilManager.ConvertCrawlTerm(fiManager.Addresses[0].CrawlTerm); } // 수집상태 버튼 labelRunStatus.Parent = buttonRunStatus; labelRunStatus.BackColor = Color.Transparent; labelRunStatus.Font = Fonts.FontAwesome; // labelRunStatus.Text = Fonts.fa.recycle + " " + "수집중"; labelRunStatus.MouseEnter += OnMouseEnterButtonRunStatus; labelRunStatus.MouseLeave += OnMouseLeaveButtonRunStatus; labelRunLastTime.Parent = buttonRunStatus; labelRunLastTime.BackColor = Color.Transparent; labelRunLastTime.MouseEnter += OnMouseEnterButtonRunStatus; labelRunLastTime.MouseLeave += OnMouseLeaveButtonRunStatus; buttonRunStatus.BackColor = Color.FromArgb(45, 45, 48); buttonRunStatus.MouseEnter += OnMouseEnterButtonRunStatus; buttonRunStatus.MouseLeave += OnMouseLeaveButtonRunStatus; if (0 < fiManager.Addresses.Count) { labelRunStatus.Text = Fonts.fa.recycle + " " + UtilManager.ConvertCrawlStatus(fiManager.Addresses[0].CrawlStatus); } // 변수 초기화 currentSelectedIndex = "f0"; if (0 < fiManager.Addresses.Count) { currentSelectedRunStatus = fiManager.Addresses[0].CrawlStatus; } }
private WeatherCrawlerData GetAssembledWCD(string address, string nx, string ny, bool isExistCD, List <CurrentData> existCD) { // 데이터 수집 var resultForForecastGrib = RunHCMForForecastGrib(nx, ny); var resultForAirData = RunHCMAirData(UtilManager.GetUmdFromAddress(address)); var resultForForecastTime = RunHCMForForecastTime(nx, ny); var resultForForecastSpace = RunHCMForForecastSpace(nx, ny); // 데이터 생성 WeatherCrawlerData wcd = new WeatherCrawlerData(); wcd.address = address; wcd.nx = Int32.Parse(nx); wcd.ny = Int32.Parse(ny); // currentData ForecastGribResult reassembledFGR = null; try { reassembledFGR = UtilManager.ReassembleDataForForecastGrib(resultForForecastGrib.Result); } catch (System.AggregateException e) { Console.WriteLine("ForecastGribResult AggregateException : {0}", e.Message); L4Logger l4Logger = new L4Logger("common.log"); l4Logger.Add("ForecastGribResult System.AggregateException!"); l4Logger.Close(); return(null); } if (null == reassembledFGR) { Console.WriteLine("reassembledFGR_Null_Exception"); L4Logger l4Logger = new L4Logger("common.log"); l4Logger.Add("reassembledFGR Null Exception!"); l4Logger.Close(); return(null); } CurrentData tmpCD = new CurrentData(); tmpCD.insertDate = UtilManager.GetNowDateTime(); tmpCD.weather = new Weather(); tmpCD.weather.baseDate = reassembledFGR.response.body.items.item[0].baseDate.ToString(); tmpCD.weather.baseTime = reassembledFGR.response.body.items.item[0].baseTime; tmpCD.weather.pty = UtilManager.GetObsrValueFromCategory(reassembledFGR, "PTY"); tmpCD.weather.reh = UtilManager.GetObsrValueFromCategory(reassembledFGR, "REH"); tmpCD.weather.rn1 = UtilManager.GetObsrValueFromCategory(reassembledFGR, "RN1"); tmpCD.weather.sky = UtilManager.GetObsrValueFromCategory(reassembledFGR, "SKY"); tmpCD.weather.t1h = UtilManager.GetObsrValueFromCategory(reassembledFGR, "T1H"); AirDataResult adr = null; try { adr = resultForAirData.Result; } catch (System.AggregateException e) { Console.WriteLine("AggregateException : {0}", e.Message); L4Logger l4Logger = new L4Logger("common.log"); l4Logger.Add("System.AggregateException!"); l4Logger.Close(); return(null); } if (null == adr) { Console.WriteLine("adr is Null"); L4Logger l4Logger = new L4Logger("common.log"); l4Logger.Add("adr is Null Exception!"); l4Logger.Close(); return(null); } tmpCD.air = new Air(); tmpCD.air.dataTime = adr.list[0].dataTime; if ("-" == adr.list[0].so2Value) { tmpCD.air.so2Value = -1; } else { tmpCD.air.so2Value = Double.Parse(adr.list[0].so2Value); } if ("-" == adr.list[0].coValue) { tmpCD.air.coValue = -1; } else { tmpCD.air.coValue = Double.Parse(adr.list[0].coValue); } if ("-" == adr.list[0].o3Value) { tmpCD.air.o3Value = -1; } else { tmpCD.air.o3Value = Double.Parse(adr.list[0].o3Value); } if ("-" == adr.list[0].no2Value) { tmpCD.air.no2Value = -1; } else { tmpCD.air.no2Value = Double.Parse(adr.list[0].no2Value); } if ("-" == adr.list[0].pm10Value) { tmpCD.air.pm10Value = -1; } else { tmpCD.air.pm10Value = Double.Parse(adr.list[0].pm10Value); } if ("-" == adr.list[0].pm25Value) { tmpCD.air.pm25Value = -1; } else { tmpCD.air.pm25Value = Double.Parse(adr.list[0].pm25Value); } wcd.currentData = new List <CurrentData>(); if (isExistCD) { wcd.currentData = existCD; } wcd.currentData.Add(tmpCD); // twoHour int[] fctTimeTable = { 3, 2, 4, 3, 2, 4, 3, 2, 4, 3, 2, 4, 3, 2, 4, 3, 2, 4, 3, 2, 4, 3, 2, 4 }; string ftsrHour = UtilManager.GetFTSRHour(); int fctTimeIndex = fctTimeTable[Int32.Parse(ftsrHour)]; ForecastTimeSpaceResult ftsr = null; try { ftsr = resultForForecastTime.Result; } catch (System.AggregateException e) { Console.WriteLine("resultForForecastTime AggregateException : {0}", e.Message); L4Logger l4Logger = new L4Logger("common.log"); l4Logger.Add("resultForForecastTime System.AggregateException!"); l4Logger.Close(); return(null); } if (null == ftsr) { Console.WriteLine("ftsr is Null"); L4Logger l4Logger = new L4Logger("common.log"); l4Logger.Add("ftsr is Null Exception!"); l4Logger.Close(); return(null); } Fcst tmpFcst = new Fcst(); tmpFcst.insertDate = UtilManager.GetNowDateTime(); // twoHour - 1Hour string startDateTime = UtilManager.GetStartDateTime(ftsr); string startDate = startDateTime.Substring(0, 8); string startTime = startDateTime.Substring(8, 4); Item2 tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, startDate, startTime, "PTY"); tmpFcst.weather = new List <FcstWeather>(); FcstWeather tmpFW = new FcstWeather(); tmpFW.fcstDate = tmpItem.fcstDate.ToString(); tmpFW.fcstTime = tmpItem.fcstTime.ToString(); tmpFW.pty = tmpItem.fcstValue; tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, startDate, startTime, "RN1"); tmpFW.rn1 = tmpItem.fcstValue; tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, startDate, startTime, "SKY"); tmpFW.sky = tmpItem.fcstValue; tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, startDate, startTime, "T1H"); tmpFW.t1h = tmpItem.fcstValue; tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, startDate, startTime, "REH"); tmpFW.reh = tmpItem.fcstValue; tmpFcst.weather.Add(tmpFW); // twoHour - 2Hour string startDatePlusOneHour = UtilManager.GetStartDateTimePlusOneHour(startDateTime); string plusOneHourDate = startDatePlusOneHour.Substring(0, 8); string plusOneHourTime = startDatePlusOneHour.Substring(8, 4); tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, plusOneHourDate, plusOneHourTime, "PTY"); tmpFW = new FcstWeather(); tmpFW.fcstDate = tmpItem.fcstDate.ToString(); tmpFW.fcstTime = tmpItem.fcstTime.ToString(); tmpFW.pty = tmpItem.fcstValue; tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, plusOneHourDate, plusOneHourTime, "RN1"); tmpFW.rn1 = tmpItem.fcstValue; tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, plusOneHourDate, plusOneHourTime, "SKY"); tmpFW.sky = tmpItem.fcstValue; tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, plusOneHourDate, plusOneHourTime, "T1H"); tmpFW.t1h = tmpItem.fcstValue; tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, plusOneHourDate, plusOneHourTime, "REH"); tmpFW.reh = tmpItem.fcstValue; tmpFcst.weather.Add(tmpFW); // twoHour - 3Hour if (3 <= fctTimeIndex) { string startDatePlusTwoHour = UtilManager.GetStartDateTimePlusTwoHour(startDateTime); string plusTwoHourDate = startDatePlusTwoHour.Substring(0, 8); string plusTwoHourTime = startDatePlusTwoHour.Substring(8, 4); tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, plusTwoHourDate, plusTwoHourTime, "PTY"); tmpFW = new FcstWeather(); tmpFW.fcstDate = tmpItem.fcstDate.ToString(); tmpFW.fcstTime = tmpItem.fcstTime.ToString(); tmpFW.pty = tmpItem.fcstValue; tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, plusTwoHourDate, plusTwoHourTime, "RN1"); tmpFW.rn1 = tmpItem.fcstValue; tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, plusTwoHourDate, plusTwoHourTime, "SKY"); tmpFW.sky = tmpItem.fcstValue; tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, plusTwoHourDate, plusTwoHourTime, "T1H"); tmpFW.t1h = tmpItem.fcstValue; tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, plusTwoHourDate, plusTwoHourTime, "REH"); tmpFW.reh = tmpItem.fcstValue; tmpFcst.weather.Add(tmpFW); } // twoHour - 4Hour if (4 == fctTimeIndex) { string startDatePlusThreeHour = UtilManager.GetStartDateTimePlusThreeHour(startDateTime); string plusThreeHourDate = startDatePlusThreeHour.Substring(0, 8); string plusThreeHourTime = startDatePlusThreeHour.Substring(8, 4); tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, plusThreeHourDate, plusThreeHourTime, "PTY"); tmpFW = new FcstWeather(); tmpFW.fcstDate = tmpItem.fcstDate.ToString(); tmpFW.fcstTime = tmpItem.fcstTime.ToString(); tmpFW.pty = tmpItem.fcstValue; tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, plusThreeHourDate, plusThreeHourTime, "RN1"); tmpFW.rn1 = tmpItem.fcstValue; tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, plusThreeHourDate, plusThreeHourTime, "SKY"); tmpFW.sky = tmpItem.fcstValue; tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, plusThreeHourDate, plusThreeHourTime, "T1H"); tmpFW.t1h = tmpItem.fcstValue; tmpItem = UtilManager.GetFcstWeatherFromTimeNCategory(ftsr, plusThreeHourDate, plusThreeHourTime, "REH"); tmpFW.reh = tmpItem.fcstValue; tmpFcst.weather.Add(tmpFW); } wcd.twoHour = tmpFcst; // tomorrow ftsr = resultForForecastSpace.Result; if (null == ftsr) { Console.WriteLine("resultForForecastSpace.Result is null"); L4Logger l4Logger = new L4Logger("common.log"); l4Logger.Add("resultForForecastSpace.Result is null!"); l4Logger.Close(); return(null); } Fcst2 tmpFcst2 = new Fcst2(); tmpFcst2.insertDate = UtilManager.GetNowDateTime(); string tomorrowDate = UtilManager.GetTomorrowDate(); List <Item2> tmpItemsPTY = UtilManager.GetFcstSpaceFromDateNCategory(ftsr, tomorrowDate, "PTY"); if (null == tmpItemsPTY) { return(null); } List <Item2> tmpItemsR06 = UtilManager.GetFcstSpaceFromDateNCategory(ftsr, tomorrowDate, "R06"); if (null == tmpItemsR06) { return(null); } List <Item2> tmpItemsSKY = UtilManager.GetFcstSpaceFromDateNCategory(ftsr, tomorrowDate, "SKY"); if (null == tmpItemsSKY) { return(null); } List <Item2> tmpItemsT3H = UtilManager.GetFcstSpaceFromDateNCategory(ftsr, tomorrowDate, "T3H"); if (null == tmpItemsT3H) { return(null); } List <Item2> tmpItemsREH = UtilManager.GetFcstSpaceFromDateNCategory(ftsr, tomorrowDate, "REH"); if (null == tmpItemsREH) { return(null); } tmpFcst2.weather = new List <FcstWeather2>(); for (int i = 0; i < tmpItemsPTY.Count; i++) { FcstWeather2 tmpFW2 = new FcstWeather2(); tmpFW2.fcstDate = tmpItemsPTY[i].fcstDate; tmpFW2.fcstTime = tmpItemsPTY[i].fcstTime; tmpFW2.pty = tmpItemsPTY[i].fcstValue; if (0 == i % 2) { tmpFW2.r06 = tmpItemsR06[i / 2].fcstValue; } tmpFW2.sky = tmpItemsSKY[i].fcstValue; tmpFW2.t3h = tmpItemsT3H[i].fcstValue; tmpFW2.reh = tmpItemsREH[i].fcstValue; tmpFcst2.weather.Add(tmpFW2); } wcd.tomorrow = tmpFcst2; // afterTomorrow tmpFcst2 = new Fcst2(); tmpFcst2.insertDate = UtilManager.GetNowDateTime(); string afterTomorrowDate = UtilManager.GetAfterTomorrowDate(); tmpItemsPTY = UtilManager.GetFcstSpaceFromDateNCategory(ftsr, afterTomorrowDate, "PTY"); tmpItemsR06 = UtilManager.GetFcstSpaceFromDateNCategory(ftsr, afterTomorrowDate, "R06"); tmpItemsSKY = UtilManager.GetFcstSpaceFromDateNCategory(ftsr, afterTomorrowDate, "SKY"); tmpItemsT3H = UtilManager.GetFcstSpaceFromDateNCategory(ftsr, afterTomorrowDate, "T3H"); tmpItemsREH = UtilManager.GetFcstSpaceFromDateNCategory(ftsr, afterTomorrowDate, "REH"); tmpFcst2.weather = new List <FcstWeather2>(); for (int i = 0; i < tmpItemsPTY.Count; i++) { FcstWeather2 tmpFW2 = new FcstWeather2(); tmpFW2.fcstDate = tmpItemsPTY[i].fcstDate; tmpFW2.fcstTime = tmpItemsPTY[i].fcstTime; tmpFW2.pty = tmpItemsPTY[i].fcstValue; if (0 == i % 2) { tmpFW2.r06 = tmpItemsR06[i / 2].fcstValue; } tmpFW2.sky = tmpItemsSKY[i].fcstValue; tmpFW2.t3h = tmpItemsT3H[i].fcstValue; tmpFW2.reh = tmpItemsREH[i].fcstValue; tmpFcst2.weather.Add(tmpFW2); } wcd.afterTomorrow = tmpFcst2; return(wcd); }