9f80977037948b3a1d3f83a2a5fa56962dfb5d1c.svn-base 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Xml;
  6. using System.IO;
  7. using System.Data;
  8. using System.Collections;
  9. namespace IControls_FireManager
  10. {
  11. // 파일입출력 관련 함수는 여기 클래스에서 전담한다
  12. public static class _File
  13. {
  14. // 프로그램 경로 (경로추가시 여기에 추가요망)
  15. public static string ProgramPath = Environment.CurrentDirectory + "\\";
  16. // 프로그램 환경설정 파일명 (설정파일이 여러개라면 여기에 추가요망)
  17. public static string ProgramFileName_Config = "Program_Configuration.xml";
  18. public static string ProgramFileName_DevType= "DevType.xml";
  19. public static string ProgramFileName_FieldSetting = "FieldSetting.xml";
  20. // _Receiver.xml 제거 : cyim 2012.8.29 -> 복구 2013.5.27
  21. public static string ProgramFileName_Receiver = "Receiver.xml";
  22. // 프로그램 에러로그 파일명
  23. public static string ProgramFileName_Log_Error = "Log_Error.txt";
  24. ///
  25. /// Program_Configuration.xml
  26. ///
  27. // 프로그램 환경설정 파일 읽기
  28. public static bool Read_ProgramConfiguration()
  29. {
  30. try
  31. {
  32. // XML 파일 경로 찾기
  33. string FilePath = ProgramPath + ProgramFileName_Config;
  34. ///
  35. /// 프로그램
  36. ///
  37. _Data.Program_Version = _Xml.Get_Value(new XmlTextReader(FilePath), "Program", "Version");
  38. //_Data.Program_Version = System.Windows.Forms.Application.ProductVersion;
  39. ///
  40. /// 프로젝트
  41. ///
  42. _Data.Project_Path = _Xml.Get_Value(new XmlTextReader(FilePath), "Project", "Path");
  43. _Data.Project_ExcelOpenCheck = _Xml.Get_Value(new XmlTextReader(FilePath), "Project", "ExcelOpenCheck");
  44. _Data.Project_MapGroupIDTypeNumber = _Xml.Get_Value(new XmlTextReader(FilePath), "Project", "MapGroupIDTypeNumber"); // cyim 2016.04.01 : 6자리 혹은 4자리로 맵아이디와 그룹아이디 지정할수 있도록함
  45. ///
  46. /// 데이타베이스 환경 설정
  47. ///
  48. // 데이터베이스 아이피
  49. _Data.DB_IP = _Xml.Get_Value(new XmlTextReader(FilePath), "Database", "IP");
  50. // 데이터베이스 접근 아이디
  51. _Data.DB_ID = _Xml.Get_Value(new XmlTextReader(FilePath), "Database", "ID");
  52. // 데이타베이스 접근 패스워드
  53. _Data.DB_PassWord = _Xml.Get_Value(new XmlTextReader(FilePath), "Database", "PassWord");
  54. ///
  55. /// Janus
  56. ///
  57. _Data.Style_PanelVisualStyle = _Style.Get_PanelVisualStyle(_Xml.Get_Value(new XmlTextReader(FilePath), "Janus", "PanelVisualStyle"));
  58. _Data.Style_VisualStyle = _Style.Get_VisualStyle(_Xml.Get_Value(new XmlTextReader(FilePath), "Janus", "VisualStyle"));
  59. _Data.Style_Office2007ColorScheme = _Style.Get_Office2007ColorScheme(_Xml.Get_Value(new XmlTextReader(FilePath), "Janus", "Office2007ColorScheme"));
  60. return true;
  61. }
  62. catch (Exception e)
  63. {
  64. // LOG
  65. _Event.DebugView_SendMessage_Write(e.ToString());
  66. return false;
  67. }
  68. }
  69. // 프로그램 환경설정 파일 쓰기
  70. public static void Write_ProgramConfiguration()
  71. {
  72. // XML 파일 경로 찾기
  73. string FilePath = ProgramPath + ProgramFileName_Config;
  74. // 시스템 기본값이 저장될 파일 지정
  75. TextWriter streamWriter = new StreamWriter(FilePath);
  76. // 스트림 생성
  77. XmlTextWriter writer = new XmlTextWriter(streamWriter);
  78. try
  79. {
  80. StringBuilder strPacket = new StringBuilder();
  81. // 헤더
  82. strPacket.Append(_Xml.Set_XMLHeader());
  83. strPacket.Append(_Xml.Set_XMLComment(_Text.XML_Comment_1th));
  84. // 바디 시작
  85. strPacket.Append(_Xml.Set_BodyHeader(Xml_Body_Type.Program_Configuration, true));
  86. // 태그 : Program
  87. strPacket.Append(_Xml.Set_XMLComment(_Text.XML_Comment_2th));
  88. strPacket.Append(_Xml.Set_Body("Program", null,
  89. "Version=" + _Data.Program_Version, true));
  90. // 태그 : Project
  91. strPacket.Append(_Xml.Set_XMLComment(_Text.XML_Comment_3th));
  92. strPacket.Append(_Xml.Set_Body("Project", null,
  93. "Path=" + _Data.Project_Path +
  94. ";ExcelOpenCheck=" + _Data.Project_ExcelOpenCheck +
  95. ";MapGroupIDTypeNumber=" + _Data.Project_MapGroupIDTypeNumber, true)); // cyim 2016.04.01 : 6자리 혹은 4자리로 맵아이디와 그룹아이디 지정할수 있도록함
  96. // 태그 : Database
  97. strPacket.Append(_Xml.Set_XMLComment(_Text.XML_Comment_4th));
  98. strPacket.Append(_Xml.Set_Body("Database", null,
  99. "IP=" + _Data.DB_IP +
  100. ";ID=" + _Data.DB_ID +
  101. ";PassWord=" + _Data.DB_PassWord, true));
  102. // 태그 : Janus
  103. strPacket.Append(_Xml.Set_XMLComment(_Text.XML_Comment_5th));
  104. strPacket.Append(_Xml.Set_Body("Janus", null,
  105. "PanelVisualStyle=" + _Data.Style_PanelVisualStyle.ToString() +
  106. ";VisualStyle=" + _Data.Style_VisualStyle.ToString() +
  107. ";Office2007ColorScheme=" + _Data.Style_Office2007ColorScheme.ToString(), true));
  108. // 바디 종료
  109. strPacket.Append(_Xml.Set_BodyHeader(Xml_Body_Type.Program_Configuration, false));
  110. // 쓰기
  111. writer.WriteRaw(strPacket.ToString());
  112. writer.Close();
  113. }
  114. catch (Exception e)
  115. {
  116. // LOG
  117. _Event.DebugView_SendMessage_Write(e.ToString());
  118. if (writer != null)
  119. writer.Close();
  120. }
  121. }
  122. // _Receiver.xml 제거 : cyim 2012.8.29 -> 복구 2013.5.27
  123. ///
  124. /// Receiver.xml
  125. ///
  126. // 파일 쓰기
  127. public static void Write_Receiver_XML(string ProjectPath)
  128. {
  129. // XML 파일 경로 찾기 (주의할점 : ProgramPath 가 아니므로 반드시 \\ 추가)
  130. string FilePath = ProjectPath + "\\" + _Text.DEFALUT_FOLDER_TEMP + "\\" + ProgramFileName_Receiver;
  131. // 시스템 기본값이 저장될 파일 지정
  132. TextWriter streamWriter = new StreamWriter(FilePath);
  133. // 스트림 생성
  134. XmlTextWriter writer = new XmlTextWriter(streamWriter);
  135. try
  136. {
  137. StringBuilder strPacket = new StringBuilder();
  138. // 헤더
  139. strPacket.Append(_Xml.Set_XMLHeader());
  140. strPacket.Append(_Xml.Set_XMLComment(_Text.XML_Comment_6th));
  141. // 바디 시작
  142. strPacket.Append(_Xml.Set_BodyHeader(Xml_Body_Type.FIRE_Receiver, true));
  143. // 태그 : Receiver
  144. strPacket.Append(_Xml.Set_XMLComment(_Text.XML_Comment_7th));
  145. // 내용
  146. string TempId = null;
  147. foreach (string RECEIVER_ID in _Data.LIST_XMLRECEIVER_ID)
  148. TempId = TempId + RECEIVER_ID + _Text.Blank; // 공백으로 아이디 구분
  149. if(TempId != null)
  150. TempId = TempId.TrimEnd();
  151. strPacket.Append(_Xml.Set_Body("Receiver", null,
  152. "ID=" + TempId, true));
  153. // 바디 종료
  154. strPacket.Append(_Xml.Set_BodyHeader(Xml_Body_Type.FIRE_Receiver, false));
  155. // 쓰기
  156. writer.WriteRaw(strPacket.ToString());
  157. writer.Close();
  158. // LOG
  159. _Event.DebugView_SendMessage_Write(_Text.FieldSetting_Xml_Save);
  160. }
  161. catch (Exception e)
  162. {
  163. // LOG
  164. _Event.DebugView_SendMessage_Write(e.ToString());
  165. }
  166. }
  167. // 파일 읽기
  168. public static bool Read_Receiver_XML(string ProjectPath)
  169. {
  170. try
  171. {
  172. // XML 파일 경로 찾기
  173. string FilePath = ProjectPath + "\\" + _Text.DEFALUT_FOLDER_TEMP + "\\" + ProgramFileName_Receiver;
  174. ///
  175. /// ID
  176. ///
  177. string Temp_ID = _Xml.Get_Value(new XmlTextReader(FilePath), "Receiver", "ID");
  178. // 파일이 없다!
  179. if (Temp_ID == null) return false;
  180. string[] Temp_ID_Array = _Convert.String_to_ArrayString(_Text.BlankChar, Temp_ID);
  181. foreach(string ID in Temp_ID_Array)
  182. {
  183. if (_Data.LIST_XMLRECEIVER_ID.Contains(ID) == false && ID.Trim().Length != 0)
  184. _Data.LIST_XMLRECEIVER_ID.Add(ID);
  185. }
  186. return true;
  187. }
  188. catch
  189. {
  190. return false;
  191. }
  192. }
  193. ///
  194. /// FieldSetting.xml
  195. ///
  196. // 저장된 페이지 해쉬 테이블과 리스트를 이용해서 페이지의 순번을 지정하기
  197. private static void Create_Page_ID_Order(string RECEIVER_ID)
  198. {
  199. int PAGE_ID_Order = 0; // 페이지 아이디
  200. // 메인은 무조건 0 이다.
  201. foreach (string PAGE_ID in ((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).LIST_PAGE_ID)
  202. {
  203. if (PAGE_ID == _Data.CREATE_PAGE_ID(RECEIVER_ID,_Text.Main))
  204. {
  205. ((_Page)((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).HASH_PAGE[PAGE_ID]).ID = PAGE_ID_Order++.ToString();
  206. break;
  207. }
  208. }
  209. // 메인이 아닌것
  210. foreach (string PAGE_ID in ((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).LIST_PAGE_ID)
  211. {
  212. if (PAGE_ID != _Data.CREATE_PAGE_ID(RECEIVER_ID, _Text.Main))
  213. {
  214. ((_Page)((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).HASH_PAGE[PAGE_ID]).ID = PAGE_ID_Order++.ToString();
  215. }
  216. }
  217. }
  218. // 점프 페이지 이름 -> 아이디
  219. public static string Create_Page_ID_Order(string RECEIVER_ID, string JumpPageName)
  220. {
  221. foreach (string PAGE_ID in ((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).LIST_PAGE_ID)
  222. {
  223. if (((_Page)((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).HASH_PAGE[PAGE_ID]).NodeText == JumpPageName)
  224. return ((_Page)((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).HASH_PAGE[PAGE_ID]).ID;
  225. }
  226. return null;
  227. }
  228. // 점프 페이지 이름 <- 아이디
  229. public static string Read_Page_ID_Order(ArrayList Result, string JumpPageID)
  230. {
  231. foreach (_FieldSetting FieldSetting in Result)
  232. {
  233. if (FieldSetting.ID == JumpPageID)
  234. return FieldSetting.Name;
  235. }
  236. return null;
  237. }
  238. // 회로번호 생성
  239. // MO-01-0-001-1 -> MO010100011 즉 수신기 아이디를 2자리로 변환하여 넣기
  240. public static string Create_Device_Oper_ID(string PictureBox_Device_Oper_ID, string Receiver_ID)
  241. {
  242. if (PictureBox_Device_Oper_ID == null || PictureBox_Device_Oper_ID.Length == 0)
  243. return null;
  244. string[] Datas = PictureBox_Device_Oper_ID.Split('-');
  245. return Datas[0] + _Convert.String_to_Int_TwoType(Receiver_ID) + Datas[1] + Datas[2] + Datas[3] + Datas[4];
  246. }
  247. // 회로번호 읽기
  248. // MO-01-0-001-1 <- MO010100011
  249. public static string Read_Device_Oper_ID(string XML_Device_Oper_ID)
  250. {
  251. if (XML_Device_Oper_ID == null || XML_Device_Oper_ID.Length == 0 || XML_Device_Oper_ID == _Text.Blank)
  252. return null;
  253. // 스트링 문자열을 배열로 변환한다 , 단 수신기 아이디는 제외한다
  254. string result = null;
  255. result = result + XML_Device_Oper_ID[0].ToString();
  256. result = result + XML_Device_Oper_ID[1].ToString();
  257. result = result + "-";
  258. result = result + XML_Device_Oper_ID[4].ToString();
  259. result = result + XML_Device_Oper_ID[5].ToString();
  260. result = result + "-";
  261. result = result + XML_Device_Oper_ID[6].ToString();
  262. result = result + "-";
  263. result = result + XML_Device_Oper_ID[7].ToString();
  264. result = result + XML_Device_Oper_ID[8].ToString();
  265. result = result + XML_Device_Oper_ID[9].ToString();
  266. result = result + "-";
  267. result = result + XML_Device_Oper_ID[10].ToString();
  268. return result;
  269. }
  270. // 맵디자이너의 내용을 토대로 저장한다
  271. public static void Write_FieldSetting_XML(string RECEIVER_ID, string ProjectPath)
  272. {
  273. // XML 파일 경로 찾기 (주의할점 : ProgramPath 가 아니므로 반드시 \\ 추가)
  274. string FilePath = ProjectPath + "\\" + ProgramFileName_FieldSetting;
  275. // 시스템 기본값이 저장될 파일 지정
  276. TextWriter streamWriter = new StreamWriter(FilePath);
  277. // 스트림 생성
  278. XmlTextWriter writer = new XmlTextWriter(streamWriter);
  279. try
  280. {
  281. StringBuilder strPacket = new StringBuilder();
  282. // 헤더
  283. strPacket.Append(_Xml.Set_XMLHeader());
  284. // 바디 시작
  285. strPacket.Append(_Xml.Set_BodyHeader(Xml_Body_Type.FIRE_FieldSetting, true));
  286. ///
  287. /// 메인부터 저장
  288. ///
  289. // 페이지의 아이디를 지정한다
  290. Create_Page_ID_Order(RECEIVER_ID);
  291. // 순번에 맞게
  292. for (int i = 0; i < ((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).LIST_PAGE_ID.Count; i++)
  293. {
  294. foreach (string PAGE_ID in ((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).LIST_PAGE_ID)
  295. {
  296. if (((_Page)((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).HASH_PAGE[PAGE_ID]).ID == i.ToString())
  297. {
  298. _Page Page = ((_Page)((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).HASH_PAGE[PAGE_ID]);
  299. // 페이지 시작 태그
  300. strPacket.Append(_Xml.Set_Body_NotEnd("Field", null,
  301. "Receiver_ID=" + Page.Receiver_ID +
  302. ";ID=" + Page.ID +
  303. ";Name=" + Page.NodeText +
  304. ";IMAGE=" + Page.PictureBoxItem_BackGround.FileName, true));
  305. // 디바이스 아이콘
  306. foreach (string ICON_ID in Page.LIST_ICON_ID)
  307. {
  308. if (((_PictureBoxItem)Page.HASH_ICON[ICON_ID]).ItemType == Item_Type.Device)
  309. {
  310. _PictureBoxItem PictureBoxItem = ((_PictureBoxItem)Page.HASH_ICON[ICON_ID]);
  311. // 특별히 디바이스 아이콘의 경우 회로번호는 전부 - 를 제거한다. 또한 회로번호의 경우 앞부분에 수신기 아이디를 포함한다(두자리)
  312. string temp_Device_ID = Create_Device_Oper_ID(PictureBoxItem.Device_Oper_ID, Page.Receiver_ID);
  313. strPacket.Append(_Xml.Set_Body("Device", null,
  314. "ID=" + temp_Device_ID +
  315. ";Xposition=" + PictureBoxItem.Location.X +
  316. ";Yposition=" + PictureBoxItem.Location.Y +
  317. ";DevIconID=" + PictureBoxItem.Device_Icon_ID, true));
  318. }
  319. }
  320. // 버튼 아이콘
  321. foreach (string ICON_ID in Page.LIST_ICON_ID)
  322. {
  323. if (((_PictureBoxItem)Page.HASH_ICON[ICON_ID]).ItemType == Item_Type.Button)
  324. {
  325. _PictureBoxItem PictureBoxItem = ((_PictureBoxItem)Page.HASH_ICON[ICON_ID]);
  326. // 버튼 아이콘의 점프 페이지는 이름이 아닌 아이디로 대체한다 (HASH_PAGE 접근시 키는 수신기ID-페이지명)
  327. string temp_JumpField_ID =null;
  328. if (PictureBoxItem.Button_JumpPageName != null
  329. && PictureBoxItem.Button_JumpPageName.Length != 0
  330. && PictureBoxItem.Button_JumpPageName != _Text.None) // None 은 결국 null 로 대체된다
  331. {
  332. // 점프페이지 이름을 토대로 페이지 아이디를 추출해야한다
  333. temp_JumpField_ID = Create_Page_ID_Order(RECEIVER_ID,PictureBoxItem.Button_JumpPageName);
  334. //temp_JumpField_ID = ((_Page)((_RECEIVER)_Data.HASH_RECEIVER[RECEIVER_ID]).HASH_PAGE[_Data.CREATE_PAGE_ID(RECEIVER_ID, PictureBoxItem.Button_JumpPageName)]).ID;
  335. }
  336. // 점프필드에는 널값이 들어가면 수신기UI 가 에러처리됨 - 2013.6.18
  337. temp_JumpField_ID = _Data.Get_Verify_ID(temp_JumpField_ID);
  338. strPacket.Append(_Xml.Set_Body("Button", null,
  339. "ID=" + "B" + PictureBoxItem.Name + // 특별히 버튼 아이콘의 경우 "B" 를 추가한다
  340. ";Xposition=" + PictureBoxItem.Location.X +
  341. ";Yposition=" + PictureBoxItem.Location.Y +
  342. ";Image=" + PictureBoxItem.FileName +
  343. ";NAME=" + _Text.Null +
  344. ";JumpField=" + temp_JumpField_ID +
  345. ";Width=" + PictureBoxItem.Image.Size.Width +
  346. ";Height=" + PictureBoxItem.Image.Size.Height, true));
  347. }
  348. }
  349. // 페이지 종료 태그
  350. strPacket.Append("</Field>\r\n");
  351. break;
  352. }
  353. }
  354. }
  355. // 바디 종료
  356. strPacket.Append(_Xml.Set_BodyHeader(Xml_Body_Type.FIRE_FieldSetting, false));
  357. // 쓰기
  358. writer.WriteRaw(strPacket.ToString());
  359. writer.Close();
  360. // LOG
  361. _Event.DebugView_SendMessage_Write(_Text.FieldSetting_Xml_Save);
  362. }
  363. catch (Exception e)
  364. {
  365. // LOG
  366. _Event.DebugView_SendMessage_Write(e.ToString());
  367. }
  368. }
  369. // 파일 읽기
  370. public static ArrayList Read_FieldSetting_XML(string ProjectPath)
  371. {
  372. try
  373. {
  374. // XML 파일 경로 찾기
  375. string FilePath = ProjectPath + "\\" + ProgramFileName_FieldSetting;
  376. // 결과 리스트
  377. ArrayList Result = new ArrayList();
  378. // XML 파일 읽기
  379. XmlDocument xmldoc = new XmlDocument();
  380. xmldoc.Load(FilePath);
  381. XmlElement Page = xmldoc.DocumentElement;
  382. XmlNodeList Fields = Page.ChildNodes;
  383. foreach (XmlNode Field in Fields)
  384. {
  385. _FieldSetting FieldSetting = new _FieldSetting();
  386. FieldSetting.Receiver_ID = Field.Attributes["Receiver_ID"].Value.ToString();
  387. FieldSetting.ID = Field.Attributes["ID"].Value.ToString();
  388. FieldSetting.Name = Field.Attributes["Name"].Value.ToString();
  389. FieldSetting.IMAGE = Field.Attributes["IMAGE"].Value.ToString();
  390. XmlNodeList nodes = Field.ChildNodes;
  391. foreach (XmlNode node in nodes)
  392. {
  393. if (node.Name == "Device")
  394. {
  395. _FieldSetting_Device FieldSetting_Device = new _FieldSetting_Device();
  396. FieldSetting_Device.ID = node.Attributes["ID"].Value.ToString();
  397. FieldSetting_Device.Xposition = node.Attributes["Xposition"].Value.ToString();
  398. FieldSetting_Device.Yposition = node.Attributes["Yposition"].Value.ToString();
  399. FieldSetting_Device.DevIconID = node.Attributes["DevIconID"].Value.ToString();
  400. FieldSetting.Device.Add(FieldSetting_Device);
  401. }
  402. else if (node.Name == "Button")
  403. {
  404. _FieldSetting_Button FieldSetting_Button = new _FieldSetting_Button();
  405. FieldSetting_Button.ID = node.Attributes["ID"].Value.ToString();
  406. FieldSetting_Button.Xposition = node.Attributes["Xposition"].Value.ToString();
  407. FieldSetting_Button.Yposition = node.Attributes["Yposition"].Value.ToString();
  408. FieldSetting_Button.Image = node.Attributes["Image"].Value.ToString();
  409. FieldSetting_Button.NAME = node.Attributes["NAME"].Value.ToString();
  410. FieldSetting_Button.JumpField = node.Attributes["JumpField"].Value.ToString();
  411. FieldSetting_Button.Width = node.Attributes["Width"].Value.ToString();
  412. FieldSetting_Button.Height = node.Attributes["Height"].Value.ToString();
  413. FieldSetting.Button.Add(FieldSetting_Button);
  414. }
  415. }
  416. Result.Add(FieldSetting);
  417. }
  418. return Result;
  419. }
  420. catch (Exception e)
  421. {
  422. // LOG
  423. _Event.DebugView_SendMessage_Write(e.ToString());
  424. return null;
  425. }
  426. }
  427. ///
  428. /// DevType.XML
  429. ///
  430. // 아이콘 파일명을 통해서 조회하기
  431. public static _DevTypeXML Read_DevType_By_FileName(string filename)
  432. {
  433. foreach (string DevTypeID in _Data.LIST_XMLDEVTYPE_ID)
  434. {
  435. if (((_DevTypeXML)_Data.HASH_XMLDEVTYPE[DevTypeID]).FILENAME == filename)
  436. return ((_DevTypeXML)_Data.HASH_XMLDEVTYPE[DevTypeID]);
  437. }
  438. return null;
  439. }
  440. // 아이콘 아이디를 통해서 조회하기
  441. public static _DevTypeXML Read_DevType_FileName_by_IconID(string IconID)
  442. {
  443. foreach (string XMLDEVTYPE_ID in _Data.LIST_XMLDEVTYPE_ID)
  444. {
  445. if (((_DevTypeXML)_Data.HASH_XMLDEVTYPE[XMLDEVTYPE_ID]).ID == IconID)
  446. return ((_DevTypeXML)_Data.HASH_XMLDEVTYPE[XMLDEVTYPE_ID]);
  447. }
  448. return null;
  449. }
  450. // 파일 읽기
  451. public static bool Read_DevType_XML(string ProjectPath)
  452. {
  453. try
  454. {
  455. // XML 파일 경로 찾기
  456. string FilePath = ProjectPath + "\\" + ProgramFileName_DevType;
  457. // 일반 텍스트로 읽고
  458. string xml = File.ReadAllText(FilePath);
  459. System.IO.StringReader reader = new StringReader(xml);
  460. // 데이타셋
  461. DataSet ds = new DataSet();
  462. // XML 파일을 인코딩
  463. ds.ReadXml(reader, XmlReadMode.Auto);
  464. // 데이타셋의 테이블 두번째 바디부터 행별로 가져온다
  465. DataRowCollection rows = ds.Tables[1].Rows;
  466. // 클래스를 각각 해쉬에 추가
  467. foreach (DataRow row in rows)
  468. {
  469. _DevTypeXML DevType = new _DevTypeXML();
  470. DevType.ID = row["ID"].ToString();
  471. DevType.FILENAME = row["IMAGE"].ToString();
  472. DevType.NAME = row["NAME"].ToString();
  473. // 해쉬 추가
  474. if (_Hash.Add(_Data.HASH_XMLDEVTYPE, DevType.ID, DevType) == true)
  475. {
  476. _Data.LIST_XMLDEVTYPE_ID.Add(DevType.ID);
  477. }
  478. }
  479. return true;
  480. }
  481. catch (Exception e)
  482. {
  483. // LOG
  484. _Event.DebugView_SendMessage_Write(e.ToString());
  485. return false;
  486. }
  487. }
  488. ///
  489. /// 프로젝트 폴더 생성
  490. ///
  491. public static void Create_ProjectFolder(string ProjectPath, string ProjectName)
  492. {
  493. // 현재 프로젝트 폴더를 생성한다
  494. // 예시)
  495. // 용인성복
  496. // - Temp
  497. // 타겟 경로
  498. string TargetPath_Project = ProjectPath + "\\" + ProjectName;
  499. string TargetPath_Temp = ProjectPath + "\\" + ProjectName + "\\" + _Text.DEFALUT_FOLDER_TEMP;
  500. // 폴더 생성
  501. Create_Folder(ProjectPath, ProjectName);
  502. Create_Folder(TargetPath_Project, _Text.DEFALUT_FOLDER_TEMP);
  503. // 원본 경로
  504. string SourcePath_Temp = ProgramPath + "\\" + _Text.DEFAULT_PROJECT_NAME + "\\" + _Text.DEFALUT_FOLDER_TEMP;
  505. // 폴더 복사
  506. Copy_Folder(SourcePath_Temp, TargetPath_Temp);
  507. }
  508. ///
  509. /// 수신기 폴더 생성
  510. ///
  511. public static void Create_ReceiverFolder(string ProjectPath, string ProjectName, string RECEIVER_ID)
  512. {
  513. try
  514. {
  515. // 현재 수신기 아이디를 토대로 폴더를 생성한다
  516. // 예시)
  517. // 용인성복
  518. // - Temp
  519. // - Receiver1
  520. // - DB
  521. // - mapview
  522. // - field
  523. // - symbol
  524. // - xml
  525. // 수신기 폴더명
  526. string ReiceiverFolderName = _Text.DEFAULT_FOLDER_RECEIVER_PREFIX + RECEIVER_ID;
  527. // 타겟 경로
  528. string TargetPath_Project = ProjectPath + "\\" + ProjectName;
  529. string TargetPath_Receiver = ProjectPath + "\\" + ProjectName + "\\" + ReiceiverFolderName;
  530. string TargetPath_DB = ProjectPath + "\\" + ProjectName + "\\" + ReiceiverFolderName + "\\" + _Text.DEFAULT_FOLDER_DB;
  531. string TargetPath_Mapview = ProjectPath + "\\" + ProjectName + "\\" + ReiceiverFolderName + "\\" + _Text.DEFAULT_FOLDER_MAPVIEW;
  532. // 폴더 생성
  533. Create_Folder(TargetPath_Project, ReiceiverFolderName);
  534. Create_Folder(TargetPath_Receiver, _Text.DEFAULT_FOLDER_DB);
  535. Create_Folder(TargetPath_Receiver, _Text.DEFAULT_FOLDER_MAPVIEW);
  536. Create_Folder(TargetPath_Mapview, _Text.DEFAULT_FOLDER_FIELD);
  537. Create_Folder(TargetPath_Mapview, _Text.DEFAULT_FOLDER_SYMBOL);
  538. Create_Folder(TargetPath_Mapview, _Text.DEFAULT_FOLDER_XML);
  539. // 원본 경로
  540. string SourcePath_Receiver = ProgramPath + "\\" + _Text.DEFAULT_PROJECT_NAME + "\\" + _Text.DEFAULT_FOLDER_RECEIVER_1;
  541. string SourcePath_DB = ProgramPath + "\\" + _Text.DEFAULT_PROJECT_NAME + "\\" + _Text.DEFAULT_FOLDER_RECEIVER_1 + "\\" + _Text.DEFAULT_FOLDER_DB;
  542. string SourcePath_Mapview = ProgramPath + "\\" + _Text.DEFAULT_PROJECT_NAME + "\\" + _Text.DEFAULT_FOLDER_RECEIVER_1 + "\\" + _Text.DEFAULT_FOLDER_MAPVIEW;
  543. // 폴더 복사
  544. Copy_Folder(SourcePath_Receiver, TargetPath_Receiver);
  545. Copy_Folder(SourcePath_DB, TargetPath_DB);
  546. Copy_Folder(SourcePath_Mapview, TargetPath_Mapview);
  547. Copy_Folder(SourcePath_Mapview + "\\" + _Text.DEFAULT_FOLDER_FIELD, TargetPath_Mapview + "\\" + _Text.DEFAULT_FOLDER_FIELD);
  548. Copy_Folder(SourcePath_Mapview + "\\" + _Text.DEFAULT_FOLDER_SYMBOL, TargetPath_Mapview + "\\" + _Text.DEFAULT_FOLDER_SYMBOL);
  549. Copy_Folder(SourcePath_Mapview + "\\" + _Text.DEFAULT_FOLDER_XML, TargetPath_Mapview + "\\" + _Text.DEFAULT_FOLDER_XML);
  550. }
  551. catch (Exception e)
  552. {
  553. // LOG
  554. _Event.DebugView_SendMessage_Write(e.ToString());
  555. }
  556. }
  557. ///
  558. /// 폴더
  559. ///
  560. // 폴더 생성
  561. public static bool Create_Folder(string path, string foldername)
  562. {
  563. try
  564. {
  565. // 폴더 만들기
  566. if (!System.IO.Directory.Exists(path + "\\" + foldername))
  567. {
  568. System.IO.Directory.CreateDirectory(path + "\\" + foldername);
  569. }
  570. return true;
  571. }
  572. catch (Exception e)
  573. {
  574. // LOG
  575. _Event.DebugView_SendMessage_Write(e.ToString());
  576. return false;
  577. }
  578. }
  579. // 폴더 삭제
  580. public static bool Delete_Folder(string path, string foldername)
  581. {
  582. try
  583. {
  584. System.IO.Directory.Delete(path + "\\" + foldername, true);
  585. return true;
  586. }
  587. catch //(Exception e)
  588. {
  589. // LOG
  590. //_Event.DebugView_SendMessage_Write(e.ToString());
  591. return false;
  592. }
  593. }
  594. // 폴더명 가져오기
  595. public static string Get_Folder(string path)
  596. {
  597. try
  598. {
  599. string result = null;
  600. string [] Directories = null;
  601. Directories = System.IO.Directory.GetDirectories(path);
  602. foreach(string Directorie in Directories)
  603. {
  604. result = result + Directorie.Replace(path,_Text.Null) + _Text.SemiColon;
  605. }
  606. if(result!=null)
  607. result = result.TrimEnd(_Convert.Split_Key);
  608. return result;
  609. }
  610. catch (Exception e)
  611. {
  612. // LOG
  613. _Event.DebugView_SendMessage_Write(e.ToString());
  614. return null;
  615. }
  616. }
  617. // 폴더명으로 부터 폴더 리스트 가져오기
  618. public static string Get_FolderNameList(string path)
  619. {
  620. try
  621. {
  622. string result = null;
  623. string[] Files = null;
  624. Files = System.IO.Directory.GetDirectories(path);
  625. foreach (string File in Files)
  626. {
  627. result = result + File.Replace(path + "\\", _Text.Null) + _Text.SemiColon;
  628. }
  629. if (result != null)
  630. result = result.TrimEnd(_Convert.Split_Key);
  631. return result;
  632. }
  633. catch (Exception e)
  634. {
  635. // LOG
  636. _Event.DebugView_SendMessage_Write(e.ToString());
  637. return null;
  638. }
  639. }
  640. // 폴더명으로 부터 파일 이름 리스트 가져오기
  641. public static string Get_FileNameList(string path)
  642. {
  643. try
  644. {
  645. string result = null;
  646. string[] Files = null;
  647. Files = System.IO.Directory.GetFiles(path);
  648. foreach (string File in Files)
  649. {
  650. result = result + File.Replace(path + "\\", _Text.Null) + _Text.SemiColon;
  651. }
  652. if (result != null)
  653. result = result.TrimEnd(_Convert.Split_Key);
  654. return result;
  655. }
  656. catch (Exception e)
  657. {
  658. // LOG
  659. _Event.DebugView_SendMessage_Write(e.ToString());
  660. return null;
  661. }
  662. }
  663. // 폴더 복사
  664. public static void Copy_Folder(string sourcePath, string targetPath)
  665. {
  666. // 소스 폴더 -> DB폴더의 파일을 모두 가져옴
  667. string[] files = System.IO.Directory.GetFiles(sourcePath);
  668. // 타겟 폴더 -> DB폴더로 파일을 하나씩 복사
  669. foreach (string file in files)
  670. {
  671. string fileName = System.IO.Path.GetFileName(file);
  672. string destfile = System.IO.Path.Combine(targetPath, fileName);
  673. // 단 기존의 파일이 없다면 복사한다
  674. if (!File.Exists(destfile))
  675. System.IO.File.Copy(file, destfile, true);
  676. }
  677. }
  678. ///
  679. /// 파일 정보
  680. ///
  681. public static FileInfo Read_FileInfo(string path)
  682. {
  683. try
  684. {
  685. FileInfo Info = new FileInfo(path);
  686. return Info;
  687. }
  688. catch (Exception e)
  689. {
  690. // LOG
  691. _Event.DebugView_SendMessage_Write(e.ToString());
  692. return null;
  693. }
  694. }
  695. ///
  696. /// 에러로그
  697. ///
  698. // 프로그램 에러로그 파일 쓰기
  699. public static void Write_Log(string txt)
  700. {
  701. try
  702. {
  703. string path = ProgramPath + ProgramFileName_Log_Error;
  704. if (!File.Exists(path))
  705. {
  706. // Create a file to write to.
  707. string createText = txt + "\r\n";// Environment.NewLine;
  708. File.WriteAllText(path, createText);
  709. }
  710. else
  711. {
  712. // This text is always added, making the file longer over time
  713. // if it is not deleted.
  714. string appendText = txt + "\r\n";
  715. File.AppendAllText(path, appendText);
  716. }
  717. }
  718. catch (Exception e)
  719. {
  720. // LOG
  721. _Event.DebugView_SendMessage_Write(e.ToString());
  722. }
  723. }
  724. // 프로그램 에러로그 파일 삭제
  725. public static void Delete_Log()
  726. {
  727. try
  728. {
  729. string path = ProgramPath + ProgramFileName_Log_Error;
  730. if (File.Exists(path))
  731. {
  732. File.Delete(path);
  733. }
  734. }
  735. catch (Exception e)
  736. {
  737. // LOG
  738. _Event.DebugView_SendMessage_Write(e.ToString());
  739. }
  740. }
  741. }
  742. }