public fcldata_R fcldata(fcldata_P p) { fcldata_R model = null; p.key = GetSettings.CertKey; ResultXmlWithUpdateModel xmlResult = GetResultXmlWithUpdate(TrafficInfoDirection.fcldata, p.ToXmlFileName(), ClassSerialize(p)); if (xmlResult.IsSuccess) { model = XmlToModel <fcldata_R>(xmlResult.ResultText); } return(model); }
public NIncidentIdentity_R NIncidentIdentity(NIncidentIdentity_P p) { NIncidentIdentity_R model = null; p.key = GetSettings.CertKey; ResultXmlWithUpdateModel xmlResult = GetResultXmlWithUpdate(TrafficInfoDirection.NIncidentIdentity, p.ToXmlFileName(), ClassSerialize(p)); if (xmlResult.IsSuccess) { model = XmlToModel <NIncidentIdentity_R>(xmlResult.ResultText); } return(model); }
public NCCTVInfo_R NCCTVImage(NCCTVImage_P p) { NCCTVInfo_R model = null; p.key = GetSettings.CertKey; ResultXmlWithUpdateModel xmlResult = GetResultXmlWithUpdate(TrafficInfoDirection.NCCTVImage, p.ToXmlFileName(), ClassSerialize(p)); if (xmlResult.IsSuccess) { model = XmlToModel <NCCTVInfo_R>(xmlResult.ResultText); } return(model); }
public ResultXmlWithUpdateModel GetResultXmlWithUpdate(TrafficInfoDirection direction, string xmlPath, string urlParams) { ResultXmlWithUpdateModel rtn = new ResultXmlWithUpdateModel(false, ResultXmlWithUpdateErrorKind.None, string.Empty); TrafficInfoSettingsModel settings = GetSettings; // 혹시라도 xmlPath변수에 저장 디렉토리가 있는지 확인해서 없으면 연결해준다. if (xmlPath.IndexOf(settings.ApiXmlPath) == -1) { xmlPath = Path.Combine(settings.ApiXmlPath, xmlPath); // 각 API 네이밍별로 디렉토리가 구성되도록 해야하기 때문에 // 디렉토리 명을 가져와서 있는지 확인하고 없으면 만든다. string tmpPathDir = Path.GetDirectoryName(xmlPath); if (!Directory.Exists(tmpPathDir)) { Directory.CreateDirectory(tmpPathDir); } } XmlDocument xdRtn = new XmlDocument(); XmlHandling xmlHand = new XmlHandling(); string xml = GetResultXml(direction, urlParams); if (!string.IsNullOrEmpty(xml)) // 통신해서 가져온 내용이 있으면 { // 가져온 XML이 이상한 놈인지 아닌지 검사한다 Tuple <bool, ResultXmlWithUpdateErrorKind, string> tplAvailable = XmlAvailableCheck(xml); if (tplAvailable.Item1 == false) { rtn = new ResultXmlWithUpdateModel(false, tplAvailable.Item2, tplAvailable.Item3); } else { if (File.Exists(xmlPath)) // 파일이 있는지 찾아서 있으면 { // 파일 내용을 받아온 xml을 로컬 xml 파일에 갱신한다. XmlDocument xdResult = xmlHand.GetXmlDocByString(xml); XmlDocument xdTarget = xmlHand.GetXmlDocByFilePath(xmlPath); xdRtn = xmlHand.GetXmlDocWithUpdateProceed(xmlPath, xdTarget, xdResult); } else { // XML 파일이 없으면 생성하고 거기다가 갱신한다. XmlDocument xdResult = xmlHand.GetXmlDocByString(xml); XmlNode resultResp = xdResult.SelectSingleNode("//response"); XmlDocument xdTmp = new XmlDocument(); XmlDeclaration xDeclare = xdTmp.CreateXmlDeclaration("1.0", "UTF-8", null); xdTmp.AppendChild(xDeclare); XmlNode responselist = xdTmp.CreateElement("responselist"); responselist.InnerXml = resultResp.OuterXml; xdTmp.AppendChild(responselist); xdTmp.Save(xmlPath); // 리턴 될 XmlDocument에도 전달해준다 xdRtn.LoadXml(xml); } rtn = new ResultXmlWithUpdateModel(true, ResultXmlWithUpdateErrorKind.None, xdRtn.OuterXml); } } else { rtn = new ResultXmlWithUpdateModel(false, ResultXmlWithUpdateErrorKind.Empty, string.Empty); } return(rtn); }