/// <summary> /// CAP 메시지를 기반으로 헤드라인 문자열 작성. /// </summary> /// <param name="msg"></param> /// <returns></returns> public string MakeHeadline(CAP msg) { System.Diagnostics.Debug.Assert(msg != null); try { StringBuilder builder = new StringBuilder(); foreach (InfoType msgInfo in msg.Info) { if (msgInfo.Language.ToUpper() == BasisData.DEFAULT_LANGUAGECODE.ToUpper()) { builder.Append(msgInfo.Headline); break; } } if (builder.Length < 1) { OrderMode modeInfo = BasisData.FindOrderModeInfoByCode(msg.MessageStatus.Value); if (modeInfo == null || string.IsNullOrEmpty(modeInfo.Name)) { FileLogManager.GetInstance().WriteLog("[CAPInfo] MakeHeadline ( 헤드라인 정보 작성 실패. 모드 정보를 찾을 수 없습니다. )"); throw new Exception("[CAPInfo] 헤드라인 정보 작성 실패. 모드 정보를 찾을 수 없습니다."); } if (msg.Info == null || msg.Info.Count < 1 || string.IsNullOrEmpty(msg.Info[0].Event)) { FileLogManager.GetInstance().WriteLog("[CAPInfo] MakeHeadline ( 헤드라인 정보 작성 실패. 이벤트 코드 정보를 찾을 수 없습니다. )"); throw new Exception("[CAPInfo] 헤드라인 정보 작성 실패. 이벤트 코드 정보를 찾을 수 없습니다."); } string disasterKindName = msg.Info[0].Event; string targets = ExtractTargetNamesFromCAP(msg); if (string.IsNullOrEmpty(targets)) { FileLogManager.GetInstance().WriteLog("[CAPInfo] MakeHeadline ( 헤드라인 정보 작성 실패. 발령 대상 정보를 찾을 수 없습니다. )"); throw new Exception("[CAPInfo] 헤드라인 정보 작성 실패. 발령 대상 정보를 찾을 수 없습니다."); } builder.Append(msg.SentDateTime.ToString()); builder.Append(" [" + modeInfo.Name + "]"); builder.Append(" [" + targets.Replace(',', '/') + "] 대상으로"); builder.Append(" [" + disasterKindName + "]"); builder.Append(" 발령"); } return(builder.ToString()); } catch (Exception ex) { System.Console.WriteLine("[CAPInfo] MakeHeadline( Exception=[ " + ex.ToString() + "] )"); FileLogManager.GetInstance().WriteLog("[CAPInfo] MakeHeadline ( Exception=[" + ex.ToString() + "] )"); throw new Exception("[CAPInfo] 헤드라인 정보 작성 실패. 처리 중 예외가 발생하였습니다."); } }
public OrderRecord ToOrderRecord() { OrderRecord recordInfo = new OrderRecord(); try { recordInfo.CAPID = this.CAPData.MessageID; recordInfo.OrderedTime = this.CAPData.SentDateTime; recordInfo.RefType = this.RefType; recordInfo.RefRecordID = this.RefRecordID; recordInfo.LocationKind = this.LocationKind; if (this.Mode != null) { recordInfo.OrderMode = this.Mode.Code; } else { // [2016-03-31] 기본 발령 정보를 시험으로 생성 - by Gonzi //recordInfo.OrderMode = StatusType.Actual; recordInfo.OrderMode = StatusType.Test; } if (this.Disaster != null && this.Disaster.Kind != null && !string.IsNullOrEmpty(this.Disaster.Kind.Code)) { recordInfo.DisasterKindCode = this.Disaster.Kind.Code; } else { recordInfo.DisasterKindCode = string.Empty; } recordInfo.ClearState = new AlertingClearState(); recordInfo.ClearState.DeepCopyFrom(BasisData.AlertingClearStateInfo[this.clearAlertState]); if (this.CAPData != null) { recordInfo.CapText = this.CAPData.WriteToXML(); } else { recordInfo.CapText = string.Empty; } } catch (Exception ex) { System.Console.WriteLine("[OrderInfo] ToOrderRecord( Exception=[" + ex.ToString() + "] )"); FileLogManager.GetInstance().WriteLog("[OrderInfo] ToOrderRecord ( Exception=[" + ex.ToString() + "] )"); return(null); } return(recordInfo); }
public ProfileHashCheckReqData(uint requestID, uint totalCount) { if (totalCount <= 0) { FileLogManager.GetInstance().WriteLog("[DataSyncInfo] ProfileHashCheckReqData ( Invalid Total Count. )"); throw new Exception("Invalid Total Count."); } this.reqEventID = requestID; this.totalCnt = totalCount; this.lstProfileHash = new List <SASProfileHash>((int)totalCount); for (int index = 0; index < totalCount; index++) { SASProfileHash hash = new SASProfileHash(); this.lstProfileHash.Add(hash); } }
public ProfileUpdateReqData(uint requestID, uint totalCount, ProfileUpdateMode mode) { if (totalCount <= 0) { FileLogManager.GetInstance().WriteLog("[DataSyncInfo] ProfileUpdateReqData ( Invalid Total Count. )"); throw new Exception("Invalid Total Count."); } this.reqEventID = requestID; this.totalCnt = totalCount; this.mode = mode; this.lstSASProfile = new List <SASProfile>((int)totalCount); for (int index = 0; index < totalCount; index++) { SASProfile system = new SASProfile(); this.lstSASProfile.Add(system); } }
public static RegionProfile FindRegion(string regionCode) { if (string.IsNullOrEmpty(regionCode)) { return(null); } if (!IsRegionDataLoaded()) { return(null); } RegionProfile profile = null; try { if (Regions.LstRegion.ContainsKey(regionCode)) { profile = Regions.LstRegion[regionCode]; } else { bool isFound = false; bool check2 = true; foreach (RegionProfile region1 in Regions.LstRegion.Values) { if (region1.LstSubRegion == null || region1.LstSubRegion.Count <= 0) { continue; } if (check2) { check2 = false; isFound = region1.LstSubRegion.ContainsKey(regionCode); // 시군구 if (isFound) { profile = region1.LstSubRegion[regionCode]; break; } } foreach (RegionProfile region2 in region1.LstSubRegion.Values) { if (region2.LstSubRegion == null || region2.LstSubRegion.Count <= 0) { continue; } isFound = region2.LstSubRegion.ContainsKey(regionCode); if (isFound) { profile = region2.LstSubRegion[regionCode]; break; } } if (isFound) { break; } } } } catch (Exception ex) { System.Console.WriteLine("[BasisData] FindRegion ( Exception: " + ex.ToString() + " )"); FileLogManager.GetInstance().WriteLog("[BasisData] FindRegion ( Exception: " + ex.ToString() + " )"); } return(profile); }
public string GetHeadlineString() { if (this == null) { return(string.Empty); } try { CAPHelper helper = new CAPHelper(); StringBuilder headline = new StringBuilder(); string association = string.Empty; if (this.LocationKind == OrderLocationKind.Other) { association = "[연계] "; } CAP msg = new CAP(this.CapText); string headlineNormal = helper.MakeHeadline(msg); if (string.IsNullOrEmpty(headlineNormal)) { headline.Append(headlineNormal); } if (headline.Length < 1) { OrderMode mode = BasisData.FindOrderModeInfoByCode(this.OrderMode); if (mode == null) { headline.Append(this.OrderedTime + " [ Unknown ]"); } else { headline.Append(this.OrderedTime + " [" + mode.Name + "]"); } string targets = helper.ExtractTargetNamesFromCAP(msg); if (!string.IsNullOrEmpty(targets)) { headline.Append("[" + targets.Replace(',', '/') + "] 대상으로"); } else { headline.Append("[ Unknown ] 대상으로"); } string disasterName = "Unknown"; if (msg.Info != null && msg.Info.Count > 0) { disasterName = msg.Info[0].Event; } else { DisasterKind disasterKind = BasisData.FindDisasterKindByCode(this.DisasterKindCode); if (disasterKind != null) { disasterName = disasterKind.Name; } } headline.Append(" [" + disasterName + "]"); headline.Append(" 발령"); if (this.RefType == OrderReferenceType.Cancel) { headline.Append(" 취소"); } } return(association + headline.ToString()); } catch (Exception ex) { System.Console.WriteLine("[OrderInfo] GetHeadlineString( Exception=[" + ex.ToString() + "] )"); FileLogManager.GetInstance().WriteLog("[OrderInfo] GetHeadlineString ( Exception=[" + ex.ToString() + "] )"); return(string.Empty); } }
/// <summary> /// Xml 데이터에서 기상특보통보문 데이터를 클래스로 파싱. /// </summary> /// <returns></returns> public SWRWarningItemProfile GetWarningItemProfile() { System.Diagnostics.Debug.Assert(this != null); System.Diagnostics.Debug.Assert(!string.IsNullOrEmpty(this.originalWarningItemReport)); SWRWarningItemProfile profile = new SWRWarningItemProfile(); try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(this.originalWarningItemReport); XmlNodeList xNodes = xmlDoc.SelectNodes("/swr/item"); if (xNodes == null || xNodes.Count <= 0) { return(null); } foreach (XmlNode item in xNodes) { foreach (XmlNode node in item.ChildNodes) { string value = node.InnerText; switch (node.Name) { case "stnId": { profile.StationID = value; } break; case "tmFc": { DateTime temp = new DateTime(); if (DateTime.TryParse(value, out temp)) { profile.AnnounceTime = temp; } } break; case "tmSeq": { int temp = 0; if (int.TryParse(value, out temp)) { profile.SequenceNo = temp; } } break; case "warFc": { profile.CommandCode = value; } break; case "t1": { profile.Title = value; } break; case "t2": { profile.TargetAreas = value; } break; case "t3": { profile.EffectStartInfo = value; } break; case "t4": { profile.Contents = value; } break; case "t5": { DateTime temp = new DateTime(); if (DateTime.TryParse(value, out temp)) { profile.PresentConditionTime = temp; } } break; case "t6": { profile.PresentConditionContents = value; } break; case "t7": { profile.PreliminaryConditionContents = value; } break; case "other": { profile.Other = value; } break; default: { // 이외에 빠진 항목은 없는지 확인하자 System.Console.WriteLine("[SpecialWeatherReportInfo] GetWarningItemProfile( Unknown Element: " + node.Name + " )"); } break; } } } } catch (Exception ex) { System.Console.WriteLine("[SpecialWeatherReportInfo] GetWarningItemProfile( Exception Occured: " + ex.ToString() + " )"); FileLogManager.GetInstance().WriteLog("[SpecialWeatherReportInfo] GetWarningItemProfile ( Exception=[" + ex.ToString() + "] )"); return(null); } return(profile); }