a20caab995753445bce2eb61c1a1a3c21c47f641.svn-base 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Data.OleDb;
  10. using System.Collections;
  11. namespace IControls_ExcelVerify
  12. {
  13. public partial class IControls_ExcelVerify : Form
  14. {
  15. // 결과를 저장할 리스트
  16. public ArrayList ListResult = new ArrayList();
  17. public int No = 0;
  18. // 디버깅 용도
  19. public int Debug_Row = 0;
  20. public int Debug_Col = 0;
  21. public string Debug_SheetName = null;
  22. public string Debug_EtcMessage = null;
  23. public IControls_ExcelVerify()
  24. {
  25. InitializeComponent();
  26. this.listView_VerifyResult.Columns[0].Width = 40;
  27. this.listView_VerifyResult.Columns[1].Width = 270;
  28. this.listView_VerifyResult.Columns[2].Width = 40;
  29. this.listView_VerifyResult.Columns[3].Width = 40;
  30. this.listView_VerifyResult.Columns[4].Width = 500;
  31. }
  32. private void button_ExcelOpen_Click(object sender, EventArgs e)
  33. {
  34. OpenFileDialog openFileDialog = new OpenFileDialog();
  35. // 엑셀파일 연동시에 다이얼로그창은 프로젝트 경로에 따라서 Field 폴더에 곧바로 접근할 수있도록 함
  36. //openFileDialog.InitialDirectory = _Data.Project_Path + "\\" + _Data.Project_Name;
  37. // 필터 처리
  38. // openFileDialog.Filter = "(*.xls*)|*.xls*";
  39. if (openFileDialog.ShowDialog() == DialogResult.OK)
  40. {
  41. if (OpenTest(openFileDialog.FileName) == true)
  42. {
  43. this.textBox_ExcelPath.Text = openFileDialog.FileName;
  44. MessageBox.Show("엑셀 열기 완료");
  45. }
  46. else
  47. {
  48. this.textBox_ExcelPath.Text = null;
  49. MessageBox.Show("엑셀 열기 실패");
  50. }
  51. }
  52. this.listView_VerifyResult.Items.Clear();
  53. }
  54. // Export (다이얼로그 창 없이 바로 생성)
  55. public EXCEL_DOC_TYPE Export_File_Check(string FileFullPath)
  56. {
  57. string Ext = FileFullPath.Substring(FileFullPath.LastIndexOf(".") + 1, FileFullPath.Length - FileFullPath.LastIndexOf(".") - 1);
  58. Ext = Ext.ToLower();
  59. if (Ext.Equals("xls"))
  60. {
  61. return EXCEL_DOC_TYPE.Xls;
  62. }
  63. else if (Ext.Equals("xlsx"))
  64. {
  65. return EXCEL_DOC_TYPE.Xlsx;
  66. }
  67. else
  68. {
  69. ////_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 250, 150, _Text.FailFormatInform, 0);
  70. return EXCEL_DOC_TYPE.Not;
  71. }
  72. }
  73. public string ConnectionString(string FileFullPath)
  74. {
  75. string result = null;
  76. switch (Export_File_Check(FileFullPath))
  77. {
  78. case EXCEL_DOC_TYPE.Xls:
  79. result = @"Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + FileFullPath + ";Extended Properties='Excel 8.0;HDR=No;IMEX=1';Persist Security Info=False";
  80. break;
  81. case EXCEL_DOC_TYPE.Xlsx:
  82. result = @"Provider=Microsoft.ACE.OLEDB.12.0;Data source=" + FileFullPath + ";Extended Properties='Excel 12.0;HDR=No;IMEX=1';Persist Security Info=False";
  83. break;
  84. }
  85. return result;
  86. }
  87. // 엑셀 열기 테스트
  88. public bool OpenTest(string FileFullPath)
  89. {
  90. try
  91. {
  92. OleDbConnection Connection = new OleDbConnection(ConnectionString(FileFullPath));
  93. Connection.Open();
  94. return true;
  95. }
  96. catch (Exception e)
  97. {
  98. MessageBox.Show(e.ToString());
  99. return false;
  100. }
  101. }
  102. // 리스트에 데이타 추가
  103. private void ListView_AddItem(string No, string SheetName, string Row, string Col, string Comment)
  104. {
  105. string[] Data1 = { No, SheetName, Row, Col, Comment };
  106. ListViewItem item = new ListViewItem(Data1);
  107. listView_VerifyResult.Items.Add(item);
  108. }
  109. // 로그 출력
  110. private void Display_Log()
  111. {
  112. // 먼저 초기화 하고 진행한다
  113. this.listView_VerifyResult.Items.Clear();
  114. for (int i = 0; i < ListResult.Count; i++)
  115. {
  116. string[] Temp = ListResult[i].ToString().Split('^');
  117. if (Temp.Length == 5)
  118. ListView_AddItem(Temp[0], Temp[1], Temp[2], Temp[3], Temp[4]);
  119. }
  120. }
  121. // 리스트에 추가
  122. private void List_Add(string sheetname, string row, string col, string comment)
  123. {
  124. No++;
  125. ListResult.Add(
  126. No.ToString() + "^" +
  127. sheetname + "^" +
  128. row + "^" +
  129. col + "^" +
  130. comment);
  131. }
  132. // 검증 시작
  133. private void button_VerifyStart_Click(object sender, EventArgs e)
  134. {
  135. if (this.textBox_ExcelPath.Text == null)
  136. {
  137. MessageBox.Show("엑셀파일을 먼저 지정해주세요");
  138. return;
  139. }
  140. // 로그 리스트 초기화
  141. ListResult.Clear();
  142. No = 0;
  143. // 검증시작
  144. Import_Point(this.textBox_ExcelPath.Text);
  145. // 데이타 출력
  146. Display_Log();
  147. MessageBox.Show("검증 작업 완료! (문제있는 경우에만 내역이 출력됨)");
  148. }
  149. // Import
  150. public bool Import_Point(string FileFullPath)
  151. {
  152. // 중계기 번호
  153. int RepeaterRowNum = 0;
  154. // 디버깅 변수 초기화
  155. Debug_Row = 0;
  156. Debug_Col = 0;
  157. Debug_SheetName = null;
  158. Debug_EtcMessage = null;
  159. string CheckConnectionString = ConnectionString(FileFullPath);
  160. if (CheckConnectionString == null)
  161. {
  162. MessageBox.Show(" 파일 확장자를 확인해주세요");
  163. return false;
  164. }
  165. // 엑셀 문서 접근
  166. OleDbConnection Connection = new OleDbConnection(CheckConnectionString);
  167. //return false;
  168. try
  169. {
  170. // 엑셀 문서 읽기
  171. Connection.Open();
  172. // 시트명을 가져온다
  173. DataTable worksheets = Connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
  174. ///
  175. /// 1. 코드값 저장
  176. ///
  177. /// 코드 시트가 있는지 확인하고 없다면 루틴을 돌지 않도록 한다
  178. /// 또한 _Data.Class_ExcelCode 에 코드 정보를 저장하여 차후에 사용하도록 클래스를 저장한다
  179. ///
  180. if (Import_Point_GetCode(worksheets, Connection) == false)
  181. {
  182. // 코드 시트가 잘못되었습니다
  183. MessageBox.Show("코드 시트가 잘못되었습니다");
  184. if (Connection != null) Connection.Close();
  185. return false;
  186. }
  187. ///
  188. /// 2. 포인트 정보 저장
  189. ///
  190. /// 포인트 정보를 저장하는 리스트이다 (가장 중요한 리스트이다, 시트별-중계기별-입출력포인트 순으로 클래스화 하여 저장한다)
  191. ///
  192. // 초기화
  193. _Data.List_ExcelPoint.Clear();
  194. // 엑셀 시트 수에 맞게 데이타를 읽어 온다
  195. for (int i = 0; i < worksheets.Rows.Count; i++)
  196. {
  197. // 시트명
  198. string sheetname = worksheets.Rows[i]["TABLE_NAME"].ToString();
  199. // 읽지 않는 시트인지 판별
  200. if (Import_Point_CheckSheetName(sheetname) == true)
  201. {
  202. // Debug
  203. Debug_SheetName = sheetname.Replace("$", "");
  204. // 읽은 정보를 데이타셋에 매칭
  205. OleDbCommand Command = new OleDbCommand("Select * From [" + sheetname + "]", Connection);
  206. OleDbDataAdapter dapt = new OleDbDataAdapter(Command);
  207. DataSet ds = new DataSet();
  208. dapt.Fill(ds);
  209. ///
  210. /// _Excel_Sheet 클래스 생성
  211. ///
  212. _Excel_Sheet Excel_Sheet = new _Excel_Sheet();
  213. // 시트명
  214. Excel_Sheet.Sheet_Name = sheetname;
  215. // 통신 보드
  216. Excel_Sheet.BOARD_ID = Read_Data(ds, 1, 0);
  217. // 계통
  218. Excel_Sheet.LOOP_NO = Read_Data(ds, 1, 1);
  219. // 중계기 총개수
  220. Excel_Sheet.Repeater_Count = Int32.Parse(Read_Data(ds, 1, 2));
  221. // 시트안에 중계기 개수 만큼 루프 생성
  222. for (int j = 0; j < Excel_Sheet.Repeater_Count; j++)
  223. {
  224. ///
  225. /// _Excel_Repeater 클래스 생성
  226. ///
  227. _Excel_Repeater Excel_Repeater = new _Excel_Repeater();
  228. // 중계기 타입
  229. string Temp_Repeater_Type = Read_Data(ds, 4 + (j * 5), 1);
  230. if (Temp_Repeater_Type == null || Temp_Repeater_Type.Trim().Length == 0)
  231. {
  232. Debug_Row = 4 + (j * 5) + 1;
  233. Debug_Col = 1 + 1;
  234. List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "중계기 타입 정보가 없습니다");
  235. //throw new Exception();
  236. }
  237. else if (Temp_Repeater_Type == "None")
  238. {
  239. ;// 사용하지 않는 중계기는 무시한다
  240. }
  241. else
  242. {
  243. // 중계기 검사 타입
  244. if (Read_Data(ds, 4 + (j * 5), 1) == "4*4")
  245. Excel_Repeater.TYPE = POINT_TYPE.REPEATER_4_4;
  246. else if (Read_Data(ds, 4 + (j * 5), 1) == "2*2")
  247. Excel_Repeater.TYPE = POINT_TYPE.REPEATER_2_2;
  248. else if (Read_Data(ds, 4 + (j * 5), 1) == "연감지기")
  249. Excel_Repeater.TYPE = POINT_TYPE.ANALOG_SMOKE;
  250. else if (Read_Data(ds, 4 + (j * 5), 1) == "열감지기")
  251. Excel_Repeater.TYPE = POINT_TYPE.ANALOG_HEAT;
  252. else
  253. // 중계기 타입이 없다면 예외
  254. {
  255. Debug_Row = 4 + (j * 5) + 1;
  256. Debug_Col = 1;
  257. //throw new Exception();
  258. List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "중계기 타입 정보가 잘못되었습니다");
  259. }
  260. // 2*2 에 2개 이상의 회로가 있다면 예외처리
  261. int Temp_RepeaterRowNum = 0;
  262. string Temp_Info = null;
  263. int Temp_Info_Cnt = 0;
  264. if (Excel_Repeater.TYPE == POINT_TYPE.REPEATER_2_2)
  265. {
  266. for (int k = 1; k <= 4; k++)
  267. {
  268. // 중계기 행번호
  269. Temp_RepeaterRowNum = 4 + (j * 5);
  270. // 위치정보
  271. Temp_Info += Read_Data(ds, Temp_RepeaterRowNum + k, 2);
  272. Temp_Info += Read_Data(ds, Temp_RepeaterRowNum + k, 3);
  273. Temp_Info += Read_Data(ds, Temp_RepeaterRowNum + k, 4);
  274. Temp_Info += Read_Data(ds, Temp_RepeaterRowNum + k, 5);
  275. Temp_Info += Read_Data(ds, Temp_RepeaterRowNum + k, 6);
  276. Temp_Info += Read_Data(ds, Temp_RepeaterRowNum + k, 7);
  277. Temp_Info += Read_Data(ds, Temp_RepeaterRowNum + k, 8);
  278. // 내용이 있다면
  279. if (Temp_Info != null && Temp_Info.Length != 0)
  280. Temp_Info_Cnt++;
  281. // 초기화
  282. Temp_Info = null;
  283. }
  284. // 중계기 회로가 2*2 인데 더 많은 정보가 있으므로 틀리다
  285. if (Temp_Info_Cnt > 2)
  286. {
  287. Debug_Row = 4 + (j * 5) + 1;
  288. Debug_Col = 1;
  289. //throw new Exception();
  290. List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "중계기 회로가 2*2 인데 더 많은 정보가 있으므로 틀립니다");
  291. }
  292. }
  293. // 중계기 아이디
  294. Excel_Repeater.REPEATER_ID = Read_Data(ds, 4 + (j * 5), 0);
  295. // 중계기 아이디가 없다면 예외
  296. if (Excel_Repeater.REPEATER_ID == null || Excel_Repeater.REPEATER_ID.Trim().Length == 0)
  297. {
  298. Debug_Row = 4 + (j * 5) + 1;
  299. Debug_Col = 0;
  300. //throw new Exception();
  301. List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "중계기 아이디가 없습니다");
  302. }
  303. // 중계기 위치 정보
  304. Excel_Repeater.Excel_Position.Building = Read_Data(ds, 4 + (j * 5), 2);
  305. Excel_Repeater.Excel_Position.Stair = Read_Data(ds, 4 + (j * 5), 3);
  306. Excel_Repeater.Excel_Position.Floor = Read_Data(ds, 4 + (j * 5), 4);
  307. // 중계기 위치 정보 없다면 예외
  308. if (Excel_Repeater.Excel_Position.Building == null || Excel_Repeater.Excel_Position.Building.Trim().Length == 0)
  309. {
  310. Debug_Row = 4 + (j * 5) + 1;
  311. Debug_Col = 2;
  312. //throw new Exception();
  313. List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "중계기 건물 위치 정보 없습니다");
  314. }
  315. if (Excel_Repeater.Excel_Position.Stair == null || Excel_Repeater.Excel_Position.Stair.Trim().Length == 0)
  316. {
  317. Debug_Row = 4 + (j * 5) + 1;
  318. Debug_Col = 3;
  319. //throw new Exception();
  320. List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "중계기 계단 위치 정보 없습니다");
  321. }
  322. if (Excel_Repeater.Excel_Position.Floor == null || Excel_Repeater.Excel_Position.Floor.Trim().Length == 0)
  323. {
  324. Debug_Row = 4 + (j * 5) + 1;
  325. Debug_Col = 4;
  326. //throw new Exception();
  327. List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "중계기 층 위치 정보 없습니다");
  328. }
  329. // 위치 코드 사용여부 체크
  330. string Temp_Repeater_Position_Name = Code_Position_Name_Create(
  331. Excel_Repeater.Excel_Position.Building, Excel_Repeater.Excel_Position.Stair, Excel_Repeater.Excel_Position.Floor);
  332. // 위치 코드가 잘못되었다
  333. if (Code_Position_Enable_Check(Temp_Repeater_Position_Name) == false)
  334. {
  335. Debug_EtcMessage = _Text.FailDataInform_NotCodePostionName;
  336. //throw new Exception();
  337. List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "위치 코드가 잘못되었습니다. 사용하지 않는 정보가 있습니다.");
  338. }
  339. // 중계기 명칭
  340. Excel_Repeater.NAME = Read_Data(ds, 4 + (j * 5), 5);
  341. // 중계기 명칭 없다면 예외
  342. if (Excel_Repeater.NAME == null || Excel_Repeater.NAME.Trim().Length == 0)
  343. {
  344. Debug_Row = 4 + (j * 5) + 1;
  345. Debug_Col = 5;
  346. //throw new Exception();
  347. List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "중계기 명칭 없습니다.");
  348. }
  349. // 중계기 타입에 상관없이 무조건 4행 단위로 읽는다
  350. for (int k = 1; k <= 4; k++)
  351. {
  352. // 중계기 행번호
  353. RepeaterRowNum = 4 + (j * 5);
  354. // 디바이스 아이디(중계기타입 아래칸)은 제대로된 순번을 넣어야한다
  355. if (Read_Data(ds, RepeaterRowNum + k, 1) != k.ToString())
  356. {
  357. Debug_Row = 4 + (j * 5) + k + 1;
  358. Debug_Col = 1;
  359. //throw new Exception();
  360. List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "디바이스 아이디는(중계기타입 아래칸) 중계기 타입에 상관없이 무조건 1~4 넣어야 합니다");
  361. }
  362. ///
  363. /// _Excel_Point 클래스 생성 (입력부)
  364. ///
  365. // 디바이스 명칭이 없다면 제외
  366. if (ds.Tables[0].Rows[RepeaterRowNum + k][5] != null && ds.Tables[0].Rows[RepeaterRowNum + k][5].ToString().Length != 0)
  367. {
  368. string TempDeviceName = Read_Data(ds, RepeaterRowNum + k, 5);
  369. TempDeviceName = TempDeviceName.Trim();
  370. if (TempDeviceName != null && TempDeviceName.Length != 0)
  371. {
  372. _Excel_Point Excel_Point_Input = new _Excel_Point();
  373. // 입력 포인트 타입
  374. Excel_Point_Input.TYPE = POINT_TYPE.I;
  375. // 입력 포인트 PortNum
  376. Excel_Point_Input.PortNum = ds.Tables[0].Rows[RepeaterRowNum + k][1].ToString();
  377. // 입력 포인트 위치 정보
  378. Excel_Point_Input.Excel_Position.Building = Read_Data(ds, RepeaterRowNum + k, 2);
  379. Excel_Point_Input.Excel_Position.Stair = Read_Data(ds, RepeaterRowNum + k, 3);
  380. Excel_Point_Input.Excel_Position.Floor = Read_Data(ds, RepeaterRowNum + k, 4);
  381. // 위치 코드 사용여부 체크
  382. string Temp_Point_Position_Name = Code_Position_Name_Create(
  383. Excel_Point_Input.Excel_Position.Building, Excel_Point_Input.Excel_Position.Stair, Excel_Point_Input.Excel_Position.Floor);
  384. if (Code_Position_Enable_Check(Temp_Point_Position_Name) == false)
  385. {
  386. Debug_EtcMessage = _Text.FailDataInform_NotCodePostionName;
  387. //throw new Exception();
  388. List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), Debug_EtcMessage);
  389. }
  390. // 입력 포인트 명칭
  391. Excel_Point_Input.NAME = TempDeviceName;
  392. // 입력 포인트 코드
  393. Excel_Point_Input.Code_FullName = Read_Data(ds, RepeaterRowNum + k, 6);
  394. string[] TempCode = Excel_Point_Input.Code_FullName.Split(' ');
  395. Excel_Point_Input.Code_Type = TempCode[0];
  396. Excel_Point_Input.Code_Name = TempCode[1];
  397. // 리스트에 추가
  398. Excel_Repeater.List_Point.Add(Excel_Point_Input);
  399. }
  400. }
  401. // 단, 명칭은 없지만, 코드가 존재하는 경우는 예외다
  402. else
  403. {
  404. // 코드가 존재하는 경우
  405. if (ds.Tables[0].Rows[RepeaterRowNum + k][6] != null && ds.Tables[0].Rows[RepeaterRowNum + k][6].ToString().Trim().Length != 0)
  406. {
  407. // 명칭이 없는 경우만
  408. if (ds.Tables[0].Rows[RepeaterRowNum + k][5] == null || ds.Tables[0].Rows[RepeaterRowNum + k][5].ToString().Trim().Length == 0)
  409. {
  410. Debug_Row = RepeaterRowNum + k + 1;
  411. Debug_Col = 5 + 1;
  412. //throw new Exception();
  413. List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "입력 포인트 명칭이 없습니다");
  414. }
  415. }
  416. }
  417. ///
  418. /// _Excel_Point 클래스 생성 (출력부)
  419. ///
  420. // 디바이스 명칭이 없다면 제외
  421. if (ds.Tables[0].Rows[RepeaterRowNum + k][7] != null && ds.Tables[0].Rows[RepeaterRowNum + k][7].ToString().Length != 0)
  422. {
  423. string TempDeviceName = Read_Data(ds, RepeaterRowNum + k, 7);
  424. TempDeviceName = TempDeviceName.Trim();
  425. if (TempDeviceName != null && TempDeviceName.Length != 0)
  426. {
  427. _Excel_Point Excel_Point_Output = new _Excel_Point();
  428. // 출력 포인트 타입
  429. Excel_Point_Output.TYPE = POINT_TYPE.O;
  430. // 출력 포인트 PortNum
  431. Excel_Point_Output.PortNum = ds.Tables[0].Rows[RepeaterRowNum + k][1].ToString();
  432. // 출력 포인트 위치 정보
  433. Excel_Point_Output.Excel_Position.Building = Read_Data(ds, RepeaterRowNum + k, 2);
  434. Excel_Point_Output.Excel_Position.Stair = Read_Data(ds, RepeaterRowNum + k, 3);
  435. Excel_Point_Output.Excel_Position.Floor = Read_Data(ds, RepeaterRowNum + k, 4);
  436. // 위치 코드 사용여부 체크
  437. string Temp_Point_Position_Name = Code_Position_Name_Create(
  438. Excel_Point_Output.Excel_Position.Building, Excel_Point_Output.Excel_Position.Stair, Excel_Point_Output.Excel_Position.Floor);
  439. if (Code_Position_Enable_Check(Temp_Point_Position_Name) == false)
  440. {
  441. Debug_EtcMessage = _Text.FailDataInform_NotCodePostionName;
  442. //throw new Exception();
  443. List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), Debug_EtcMessage);
  444. }
  445. // 출력 포인트 명칭
  446. Excel_Point_Output.NAME = TempDeviceName;
  447. // 출력 포인트 코드
  448. Excel_Point_Output.Code_FullName = Read_Data(ds, RepeaterRowNum + k, 8);
  449. string[] TempCode = Excel_Point_Output.Code_FullName.Split(' ');
  450. Excel_Point_Output.Code_Type = TempCode[0];
  451. Excel_Point_Output.Code_Name = TempCode[1];
  452. // 리스트에 추가
  453. Excel_Repeater.List_Point.Add(Excel_Point_Output);
  454. }
  455. }
  456. // 단, 명칭은 없지만, 코드가 존재하는 경우는 예외다
  457. else
  458. {
  459. // 코드가 존재하는 경우
  460. if (ds.Tables[0].Rows[RepeaterRowNum + k][8] != null && ds.Tables[0].Rows[RepeaterRowNum + k][8].ToString().Trim().Length != 0)
  461. {
  462. // 명칭이 없는 경우만
  463. if (ds.Tables[0].Rows[RepeaterRowNum + k][7] == null || ds.Tables[0].Rows[RepeaterRowNum + k][7].ToString().Trim().Length == 0)
  464. {
  465. Debug_Row = RepeaterRowNum + k + 1;
  466. Debug_Col = 7 + 1;
  467. //throw new Exception();
  468. List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "출력 포인트 명칭이 없습니다");
  469. }
  470. }
  471. }
  472. }
  473. // 리스트에 추가
  474. Excel_Sheet.List_Repeater.Add(Excel_Repeater);
  475. }
  476. }
  477. // 리스트에 추가
  478. _Data.List_ExcelPoint.Add(Excel_Sheet);
  479. }
  480. }
  481. ///
  482. /// 3. 포인트 위치 정보에 따라 실제로 사용한는 위치 코드값을 재정리
  483. /// 실제로 사용되는 위치코드만 재정리
  484. ///
  485. Code_Postion_Create();
  486. // 단, 엑셀시트 클래스안에 중계기클래스가 없다면 잘못된 포맷이다
  487. int RepeterAllCount = 0;
  488. foreach (_Excel_Sheet Excel_Sheet in _Data.List_ExcelPoint)
  489. foreach (_Excel_Repeater Excel_Repeater in Excel_Sheet.List_Repeater)
  490. RepeterAllCount++;
  491. if (RepeterAllCount == 0)
  492. {
  493. // 파일 포맷이 잘못되었습니다
  494. //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 250, 150, _Text.FailFormatInform, 0);
  495. // return false;
  496. List_Add(_Text.None, Debug_Row.ToString(), Debug_Col.ToString(), "엑셀시트 클래스안에 중계기클래스가 없다면 잘못된 포맷입니다");
  497. }
  498. /////
  499. ///// 4. 그룹 정보 저장
  500. /////
  501. //if (Import_Point_GetGroup(worksheets, Connection) == false)
  502. //{
  503. // // 연동그룹 시트가 잘못되었습니다
  504. // //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 250, 150, _Text.FailGroupInform, 0);
  505. // return false;
  506. //}
  507. /////
  508. ///// 5. 맵 정보 저장
  509. /////
  510. //if (Import_Point_GetMap(worksheets, Connection) == false)
  511. //{
  512. // // 연동설정 시트가 잘못되었습니다
  513. // //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 250, 150, _Text.FailMapInform, 0);
  514. // return false;
  515. //}
  516. // 엑셀 읽기 세션 해제
  517. if (Connection != null) Connection.Close();
  518. return true;
  519. }
  520. catch // (Exception e)
  521. {
  522. string Error = " 시트명:" + Debug_SheetName + " 행:" + Debug_Row + " 열:" + Debug_Col;
  523. // 추가 메세지가 필요한 경우
  524. string Message = null;
  525. // 추가 메세지가 없는 경우에는 "데이타가 잘못되었습니다" 문구 출력
  526. if (Debug_EtcMessage != null)
  527. Message = Debug_EtcMessage + Error;
  528. else
  529. Message = _Text.FailDataInform + Error;
  530. // 데이타가 잘못되었습니다
  531. ////_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 600, 150, Message, 0);
  532. // LOG
  533. //_Event.DebugView_SendMessage_Write(_Text.NotReadExcelFile + Error + " 의 정보를 확인해주세요 " + e.ToString());
  534. List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "데이타가 잘못되었습니다. 예외지점을 재확인바랍니다");
  535. // 엑셀 읽기 세션 해제
  536. if (Connection != null) Connection.Close();
  537. return false;
  538. }
  539. }
  540. // 코드값 읽기
  541. public bool Import_Point_GetCode(DataTable Sheets, OleDbConnection Connection)
  542. {
  543. try
  544. {
  545. // 코드 시트명을 가져온다
  546. for (int i = 0; i < Sheets.Rows.Count; i++)
  547. {
  548. // 만약 가져오지 못한다면 실패로 처리함, 코드 시트명은 고정되어 있다! => 코드$
  549. if (Sheets.Rows[i]["TABLE_NAME"].ToString() == "코드$")
  550. {
  551. // 시트명
  552. string sheetname = Sheets.Rows[i]["TABLE_NAME"].ToString();
  553. Debug_SheetName = sheetname.Replace("$", "");
  554. OleDbCommand Command = new OleDbCommand("Select * From [코드$]", Connection);
  555. OleDbDataAdapter dapt = new OleDbDataAdapter(Command);
  556. DataSet ds = new DataSet();
  557. dapt.Fill(ds);
  558. ///
  559. /// 코드값들을 읽는다
  560. ///
  561. // 건물 이름
  562. ArrayList List_Building_Name = new ArrayList();
  563. ArrayList List_Building_Position = new ArrayList();
  564. ArrayList List_Building_Emergency = new ArrayList();
  565. // 계단
  566. ArrayList List_Stair_Name = new ArrayList();
  567. ArrayList List_Stair_Position = new ArrayList();
  568. ArrayList List_Stair_Emergency = new ArrayList();
  569. // 층
  570. ArrayList List_Floor_Name = new ArrayList();
  571. ArrayList List_Floor_Position = new ArrayList();
  572. ArrayList List_Floor_Emergency = new ArrayList();
  573. // 입력
  574. ArrayList List_Input_TypeName = new ArrayList();
  575. // 출력
  576. ArrayList List_Output_TypeName = new ArrayList();
  577. ArrayList List_Output_SEQ = new ArrayList();
  578. ArrayList List_Output_USE = new ArrayList();
  579. // IO 보드
  580. ArrayList List_IOBoard_Name = new ArrayList();
  581. ArrayList List_IOBoard_ComPort = new ArrayList();
  582. ArrayList List_IOBoard_BoardID = new ArrayList();
  583. ArrayList List_IOBoard_LoopNo = new ArrayList();
  584. ArrayList List_IOBoard_RepeaterID = new ArrayList();
  585. ArrayList List_IOBoard_DeviceID = new ArrayList();
  586. ArrayList List_IOBoard_InOut = new ArrayList();
  587. ArrayList List_IOBoard_AddRepeaterYesNo = new ArrayList();
  588. ArrayList List_IOBoard_AddRepeaterType = new ArrayList();
  589. // 이벤트 타입
  590. ArrayList List_EventType_Type = new ArrayList();
  591. ArrayList List_EventType_Name = new ArrayList();
  592. // 아날로그 감지기 레벨 및 시간
  593. ArrayList List_Analog_Level = new ArrayList();
  594. ArrayList List_FireDay_Time = new ArrayList();
  595. // 건물코드 읽기
  596. List_Building_Name = Get_CodeData_Until_Null(ds, 3, 0);
  597. List_Building_Position = Get_CodeData_Until_Null(ds, 3, 1);
  598. List_Building_Emergency = Get_CodeData_Until_Null(ds, 3, 2);
  599. // 계단코드 읽기
  600. List_Stair_Name = Get_CodeData_Until_Null(ds, 3, 3);
  601. List_Stair_Position = Get_CodeData_Until_Null(ds, 3, 4);
  602. List_Stair_Emergency = Get_CodeData_Until_Null(ds, 3, 5);
  603. // 층코드 읽기
  604. List_Floor_Name = Get_CodeData_Until_Null(ds, 3, 6);
  605. List_Floor_Position = Get_CodeData_Until_Null(ds, 3, 7);
  606. List_Floor_Emergency = Get_CodeData_Until_Null(ds, 3, 8);
  607. // 입력코드 읽기
  608. List_Input_TypeName = Get_CodeData_Until_Null(ds, 3, 10);
  609. // 출력코드 읽기
  610. List_Output_TypeName = Get_CodeData_Until_Null(ds, 3, 12);
  611. List_Output_SEQ = Get_CodeData_Until_Null(ds, 3, 13);
  612. List_Output_USE = Get_CodeData_Until_Null(ds, 3, 14);
  613. // IO 보드 읽기
  614. List_IOBoard_Name = Get_CodeData_Until_Null(ds, 3, 18);
  615. List_IOBoard_ComPort = Get_CodeData_Until_Null(ds, 3, 19);
  616. List_IOBoard_BoardID = Get_CodeData_Until_Null(ds, 3, 20);
  617. List_IOBoard_LoopNo = Get_CodeData_Until_Null(ds, 3, 21);
  618. List_IOBoard_RepeaterID = Get_CodeData_Until_Null(ds, 3, 22);
  619. List_IOBoard_DeviceID = Get_CodeData_Until_Null(ds, 3, 23);
  620. List_IOBoard_InOut = Get_CodeData_Until_Null(ds, 3, 24);
  621. List_IOBoard_AddRepeaterYesNo = Get_CodeData_Until_Null(ds, 3, 25);
  622. List_IOBoard_AddRepeaterType = Get_CodeData_Until_Null(ds, 3, 26);
  623. // 이벤트 타입 읽기
  624. List_EventType_Type = Get_CodeData_Until_Null(ds, 3, 28);
  625. List_EventType_Name = Get_CodeData_Until_Null(ds, 3, 29);
  626. // 아날로그 감지기 레벨 및 시간
  627. List_Analog_Level = Get_CodeData_Until_Null(ds, 3, 32);
  628. List_FireDay_Time = Get_CodeData_Until_Null(ds, 3, 34);
  629. // 단, 코드 값중에 하나라도 빈값이라면 취소
  630. if (List_Building_Name.Count == 0 || List_Building_Position.Count == 0 || List_Building_Emergency.Count == 0
  631. || List_Stair_Name.Count == 0 || List_Stair_Position.Count == 0 || List_Stair_Emergency.Count == 0
  632. || List_Floor_Name.Count == 0 || List_Floor_Position.Count == 0 || List_Floor_Emergency.Count == 0)
  633. {
  634. List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError1);
  635. //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError1, 0);
  636. //return false;
  637. }
  638. if (List_Input_TypeName.Count == 0 || List_Output_TypeName.Count == 0 || List_Output_SEQ.Count == 0 || List_Output_USE.Count == 0)
  639. {
  640. List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError7);
  641. //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError7, 0);
  642. //return false;
  643. }
  644. if (List_IOBoard_Name.Count == 0 || List_IOBoard_ComPort.Count == 0 || List_IOBoard_BoardID.Count == 0
  645. || List_IOBoard_LoopNo.Count == 0 || List_IOBoard_RepeaterID.Count == 0 || List_IOBoard_DeviceID.Count == 0
  646. || List_IOBoard_InOut.Count == 0 || List_IOBoard_AddRepeaterYesNo.Count == 0 || List_IOBoard_AddRepeaterYesNo.Count == 0)
  647. {
  648. List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError8);
  649. //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError8, 0);
  650. //return false;
  651. }
  652. if (List_EventType_Type.Count == 0 || List_EventType_Name.Count == 0)
  653. {
  654. List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError9);
  655. //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError9, 0);
  656. //return false;
  657. }
  658. //
  659. // 단, 코드의 3가지는 모두 개수가 동일해야한다. 또한 출력코드 및 IO 보드 및 이벤트 타입은 데이타 레코드수가 동일해야한다
  660. //
  661. if ((List_Building_Name.Count != List_Building_Position.Count) || (List_Building_Name.Count != List_Building_Emergency.Count))
  662. {
  663. List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError2_1);
  664. //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError2, 0);
  665. //return false;
  666. }
  667. if ((List_Stair_Name.Count != List_Stair_Position.Count) || (List_Stair_Name.Count != List_Stair_Emergency.Count))
  668. {
  669. List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError2_2);
  670. //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError2, 0);
  671. // return false;
  672. }
  673. if ((List_Floor_Name.Count != List_Floor_Position.Count) || (List_Floor_Name.Count != List_Floor_Emergency.Count))
  674. {
  675. List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError2_3);
  676. //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError2, 0);
  677. //return false;
  678. }
  679. if (List_Output_TypeName.Count + List_Output_SEQ.Count + List_Output_USE.Count != List_Output_TypeName.Count * 3)
  680. {
  681. List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError4);
  682. //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError4, 0);
  683. //return false;
  684. }
  685. if (List_IOBoard_Name.Count + List_IOBoard_ComPort.Count + List_IOBoard_BoardID.Count + List_IOBoard_LoopNo.Count + List_IOBoard_RepeaterID.Count
  686. + List_IOBoard_DeviceID.Count + List_IOBoard_InOut.Count + List_IOBoard_AddRepeaterYesNo.Count + List_IOBoard_AddRepeaterType.Count != List_IOBoard_Name.Count * 9)
  687. {
  688. List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError5);
  689. //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError5, 0);
  690. //return false;
  691. }
  692. if (List_EventType_Type.Count != List_EventType_Name.Count)
  693. {
  694. List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError6);
  695. //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError6, 0);
  696. //return false;
  697. }
  698. ///
  699. /// 데이타베이스 연동을 위한 클래스를 생성한다
  700. ///
  701. // 위치코드 및 비상코드를 생성한다 (건물-계단-층 순으로 고유의 6자리 코드를 생성한다
  702. // 또한 여기에 명칭을 정리한다. 이 경우에 공백으로 각 데이타를 구분하도록 한다
  703. // ex : 101동 - 1계단 - None => 101동 1계단
  704. // ex : 101동 - None - B1F => 101동 B1F
  705. _Data.HASH_CodePosition.Clear();
  706. _Data.LIST_CodePosition_NAME.Clear();
  707. foreach (string BuildingName in List_Building_Name)
  708. {
  709. foreach (string StairName in List_Stair_Name)
  710. {
  711. foreach (string FloorName in List_Floor_Name)
  712. {
  713. // 클래스 생성
  714. _Code_Position Code_Position = new _Code_Position();
  715. ///
  716. /// 아이디
  717. ///
  718. //Code_Position.Code_Position_ID =
  719. // _Convert.String_to_Int_TwoType(List_Building.IndexOf(BuildingName).ToString()) +
  720. // _Convert.String_to_Int_TwoType(List_Stair.IndexOf(StairName).ToString()) +
  721. // _Convert.String_to_Int_TwoType(List_Floor.IndexOf(FloorName).ToString());
  722. // 인덱스는 동일하므로
  723. int Temp_Index_Building = List_Building_Name.IndexOf(BuildingName);
  724. int Temp_Index_Stair = List_Stair_Name.IndexOf(StairName);
  725. int Temp_Index_Floor = List_Floor_Name.IndexOf(FloorName);
  726. ///
  727. /// 위치코드
  728. ///
  729. Code_Position.Code_Position_ID =
  730. _Convert.String_to_Int_TwoType(List_Building_Position[Temp_Index_Building].ToString()) +
  731. _Convert.String_to_Int_TwoType(List_Stair_Position[Temp_Index_Stair].ToString()) +
  732. _Convert.String_to_Int_TwoType(List_Floor_Position[Temp_Index_Floor].ToString());
  733. ///
  734. /// 비상방송코드
  735. ///
  736. Code_Position.Code_Emergency_ID =
  737. _Convert.String_to_Int_TwoType(List_Building_Emergency[Temp_Index_Building].ToString()) +
  738. _Convert.String_to_Int_TwoType(List_Stair_Emergency[Temp_Index_Stair].ToString()) +
  739. _Convert.String_to_Int_TwoType(List_Floor_Emergency[Temp_Index_Floor].ToString());
  740. ///
  741. /// 이름
  742. ///
  743. Code_Position.Code_Position_NAME = Code_Position_Name_Create(BuildingName, StairName, FloorName);
  744. // 사용여부 해제
  745. Code_Position.Enable = false;
  746. // 해쉬 추가
  747. // (디폴트로 생성되는 위치 코드 리스트이며 차후에 Import_Point 함수에서 실제로 사용되는 위치만 추출해서 변경된다
  748. // ID 를 참조하는게 아니라 이름을 기준으로 참조하므로 사용에 주의
  749. if (_Hash.Add(_Data.HASH_CodePosition, Code_Position.Code_Position_NAME, Code_Position) == true)
  750. {
  751. _Data.LIST_CodePosition_NAME.Add(Code_Position.Code_Position_NAME);
  752. }
  753. }
  754. }
  755. }
  756. //
  757. // 입력코드 및 출력코드를 생성한결과에 데이타베이스의 TB_DEVICE_TYPE 에 저장하기 위한 필드들을 매칭시켜 저장해둔다
  758. //
  759. _Data.LIST_CodeDeviceType.Clear();
  760. // 입력
  761. foreach (string Input_TypeName in List_Input_TypeName)
  762. {
  763. _Code_Device_Type Table_Device_Type = new _Code_Device_Type();
  764. // 데이타를 추출한다 (예시 : IA 일반화재입력)
  765. string[] Temp_Input_TypeName = Input_TypeName.Split(' ');
  766. if (Temp_Input_TypeName.Length != 2)
  767. {
  768. List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError3_1);
  769. //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError3, 0);
  770. //return false;
  771. }
  772. // 데이타 저장
  773. Table_Device_Type.DEVICE_TYPE = Temp_Input_TypeName[0];
  774. Table_Device_Type.DEVICE_TYPE_NAME = Temp_Input_TypeName[1];
  775. Table_Device_Type.SYMBOL_TYPE = "I";
  776. Table_Device_Type.SEQ_NO = "0";
  777. Table_Device_Type.USE_FLAG = "Y";
  778. // 클래스에 추가
  779. _Data.LIST_CodeDeviceType.Add(Table_Device_Type);
  780. }
  781. // 출력
  782. foreach (string Output_TypeName in List_Output_TypeName)
  783. {
  784. _Code_Device_Type Table_Device_Type = new _Code_Device_Type();
  785. // 데이타를 추출한다 (예시 : OA 주경종)
  786. string[] Temp_Output_TypeName = Output_TypeName.Split(' ');
  787. if (Temp_Output_TypeName.Length != 2)
  788. {
  789. List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError3_2);
  790. //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError3, 0);
  791. //return false;
  792. }
  793. // 데이타 저장
  794. Table_Device_Type.DEVICE_TYPE = Temp_Output_TypeName[0];
  795. Table_Device_Type.DEVICE_TYPE_NAME = Temp_Output_TypeName[1];
  796. Table_Device_Type.SYMBOL_TYPE = "O";
  797. Table_Device_Type.SEQ_NO = List_Output_SEQ[List_Output_TypeName.IndexOf(Output_TypeName)].ToString();
  798. Table_Device_Type.USE_FLAG = List_Output_USE[List_Output_TypeName.IndexOf(Output_TypeName)].ToString(); ;
  799. // 클래스에 추가
  800. _Data.LIST_CodeDeviceType.Add(Table_Device_Type);
  801. }
  802. //
  803. // IO보드를 생성한결과에 데이타베이스의 TB_DEVICE 에 저장하기 위한 필드들을 매칭시켜 저장해둔다
  804. //
  805. // 중복된 내용이 있다면 사용불가
  806. ArrayList Temp_IOBoard_Name = new ArrayList();
  807. foreach (string Name in List_IOBoard_Name)
  808. {
  809. if (Temp_IOBoard_Name.Contains(Name) == false)
  810. Temp_IOBoard_Name.Add(Name);
  811. }
  812. if (Temp_IOBoard_Name.Count != List_IOBoard_Name.Count)
  813. {
  814. List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError11);
  815. }
  816. _Data.LIST_CodeIOBoard.Clear();
  817. // IO
  818. foreach (string IOBoard_Name in List_IOBoard_Name)
  819. {
  820. _Code_IO_Board IO_Board = new _Code_IO_Board();
  821. // 데이타 저장
  822. IO_Board.IOBOARD_NAME = IOBoard_Name;
  823. IO_Board.IOBOARD_COM_PORT = List_IOBoard_ComPort[List_IOBoard_Name.IndexOf(IOBoard_Name)].ToString();
  824. IO_Board.IOBOARD_BOARD_ID = List_IOBoard_BoardID[List_IOBoard_Name.IndexOf(IOBoard_Name)].ToString();
  825. IO_Board.IOBOARD_LOOP_NO = List_IOBoard_LoopNo[List_IOBoard_Name.IndexOf(IOBoard_Name)].ToString();
  826. IO_Board.IOBOARD_REPEATER_ID = List_IOBoard_RepeaterID[List_IOBoard_Name.IndexOf(IOBoard_Name)].ToString();
  827. IO_Board.IOBOARD_DEVICE_ID = List_IOBoard_DeviceID[List_IOBoard_Name.IndexOf(IOBoard_Name)].ToString();
  828. IO_Board.IOBOARD_INOUT = List_IOBoard_InOut[List_IOBoard_Name.IndexOf(IOBoard_Name)].ToString();
  829. IO_Board.IOBOARD_ADDREPEATER_YN = List_IOBoard_AddRepeaterYesNo[List_IOBoard_Name.IndexOf(IOBoard_Name)].ToString();
  830. IO_Board.IOBOARD_ADDREPEATER_TYPE = List_IOBoard_AddRepeaterType[List_IOBoard_Name.IndexOf(IOBoard_Name)].ToString();
  831. // 클래스에 추가
  832. _Data.LIST_CodeIOBoard.Add(IO_Board);
  833. }
  834. //
  835. // 이벤트타입 생성한결과에 데이타베이스의 TB_EVENT_TYPE 에 저장하기 위한 필드들을 매칭시켜 저장해둔다
  836. //
  837. _Data.LIST_CodeEventType.Clear();
  838. // 이벤트 타입
  839. foreach (string EventType in List_EventType_Type)
  840. {
  841. _Code_Event_Type Event_Type = new _Code_Event_Type();
  842. // 데이타 저장
  843. Event_Type.EVENT_TYPE = EventType;
  844. Event_Type.EVENT_TYPE_NAME = List_EventType_Name[List_EventType_Type.IndexOf(EventType)].ToString();
  845. // 클래스에 추가
  846. _Data.LIST_CodeEventType.Add(Event_Type);
  847. }
  848. if(_Data.LIST_CodeEventType.Count == 0)
  849. List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError10);
  850. //
  851. // 아날로그 감지 레벨 및 시간
  852. //
  853. _Data.LIST_CodeAnalogLevel.Clear();
  854. // 0 : falut, 1 : PreFire, 2 : FireDay, 3 : FireNight
  855. if (List_Analog_Level.Count == 4)
  856. _Data.LIST_CodeAnalogLevel = (ArrayList)List_Analog_Level.Clone();
  857. else if(List_Analog_Level.Count != 0)
  858. List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError12);
  859. _Data.LIST_CodeFireDayTime.Clear();
  860. if (List_FireDay_Time.Count == 4)
  861. {
  862. int start_Hour = _Convert.Null_to_IntZero(List_FireDay_Time[0]);
  863. int start_Minute = _Convert.Null_to_IntZero(List_FireDay_Time[1]);
  864. int end_Hour = _Convert.Null_to_IntZero(List_FireDay_Time[2]);
  865. int end_Minute = _Convert.Null_to_IntZero(List_FireDay_Time[3]);
  866. if ((start_Hour > end_Hour) || (start_Hour == end_Hour && start_Minute > end_Minute))
  867. {
  868. List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError12);
  869. }
  870. _Data.LIST_CodeFireDayTime = (ArrayList)List_FireDay_Time.Clone();
  871. }
  872. else if (List_FireDay_Time.Count != 0)
  873. List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError12);
  874. return true;
  875. }
  876. }
  877. return false;
  878. }
  879. catch // (Exception e)
  880. {
  881. //_Event.DebugView_SendMessage_Write(e.ToString());
  882. return false;
  883. }
  884. }
  885. // 코드 시트에 있는 값을 읽어오는 함수
  886. // 행단위로 검색하되 공백이 나오면 더이상 읽지 않도록 한다
  887. // 참고로 Col 을 지정하여 열에 접근할수 있도록 한다
  888. public ArrayList Get_CodeData_Until_Null(DataSet Ds, int StartRow, int FixedCol)
  889. {
  890. // 결과
  891. ArrayList result = new ArrayList();
  892. try
  893. {
  894. // 시작행
  895. int Count = StartRow;
  896. // 널값이 나올때까지
  897. while (Ds.Tables[0].Rows[Count][FixedCol] != null && Ds.Tables[0].Rows[Count][FixedCol].ToString() != "null"
  898. && Ds.Tables[0].Rows[Count][FixedCol].ToString().Length != 0)
  899. {
  900. // 선후공백은 제거한다
  901. string data = Ds.Tables[0].Rows[Count][FixedCol].ToString();
  902. data = data.Trim();
  903. result.Add(data);
  904. Count++;
  905. }
  906. return result;
  907. }
  908. catch
  909. {
  910. return result;
  911. }
  912. }
  913. //
  914. // 그룹 및 맵 정보를 가져오는 함수
  915. // 행단위로 검색하되 지정한 총개수만큼만 가져오도록 한다
  916. public ArrayList Get_CodeData_Until_AllCnt(DataSet Ds, int StartRow, int FixedCol, int AllCnt)
  917. {
  918. // 결과
  919. ArrayList result = new ArrayList();
  920. // 시작행
  921. int Count = StartRow;
  922. // 지정한 카운트 만큼
  923. while (Ds.Tables[0].Rows[Count][FixedCol] != null
  924. && Ds.Tables[0].Rows[Count][FixedCol].ToString().Length != 0)
  925. {
  926. // 선후공백은 제거한다
  927. string data = Ds.Tables[0].Rows[Count][FixedCol].ToString();
  928. data = data.Trim();
  929. result.Add(data);
  930. Count++;
  931. if (Count >= AllCnt + StartRow) break;
  932. }
  933. return result;
  934. }
  935. // $ 가 없는지 체크하는 함수
  936. public bool CheckSheetName_Character(string SheetName)
  937. {
  938. string temp = SheetName;
  939. temp = temp.Replace("$", "");
  940. if (temp.Length == SheetName.Length)
  941. return false; // $ 가 없다!
  942. else
  943. return true;
  944. }
  945. // $ 뒤에 글자가 있는지 확인 (단 ' 를 제외하고)
  946. public bool CheckSheetName_Character_After(string SheetName)
  947. {
  948. string[] temp = null;
  949. temp = SheetName.Split('$');
  950. if (temp.Length != 2) // 앞에서 $가 반드시 존재하는 조건을 걸었으므로 반드시 2개가 나온다
  951. return false;
  952. else if (temp.Length == 2 && (temp[1] == "'" || temp[1] == "")) // 2개로 쪼개지지만 끝은 ' 혹은 공백이다
  953. return true;
  954. else
  955. return false;
  956. }
  957. // 시트명 중복을 제외시키는 함수
  958. public bool CheckSheetName_SameData(string SheetName)
  959. {
  960. foreach (_Excel_Sheet Excel_Sheet in _Data.List_ExcelPoint)
  961. {
  962. if (Excel_Sheet.Sheet_Name == SheetName)
  963. return false;
  964. }
  965. return true;
  966. }
  967. // 시트명 예외처리..
  968. // 원래는 정확한 데이타가 들어와야 하지만 예외처리 조건이 너무 많다..테스트 결과 몇가지 규칙을 알아내었다.. 2013.04.19
  969. // 1. 시트명에는 반드시 뒤에 $가 들어온다
  970. // 2. 숫자로 시작되는 시트명에는 작은따옴표가 앞뒤로 붙는다 -> '101동$'
  971. // 3. 영문 혹은 한글로 시작되는 시트명에는 작은따옴표가 없다 -> 주차장$
  972. // 4. 특수문자 혹은 공백으로 시작되는 시트명에는 작은따옴표가 앞뒤로 붙는다 -> ' 101동$' , '@101동$'
  973. // 5. '101동'$Print_Area 와 같이 뒤에 이상한 문자열이 따르는 경우가 있다
  974. // 6. 주차장1$Print_Titles 와 같이 뒤에 이상한 문자열이 따르는 경우가 있다.
  975. //
  976. // 처리방법은 다음과 같다
  977. // 1. 특별 제외는 2개이다. 수량$,코드$ 는 엑셀포맷에 있지만 읽을수 없는 내용이므로 제외시킨다.
  978. // 2. $가 없다면 시트명이 아니다
  979. // 3. $뒤에 글자가 있는 것은 시트명이 아니다 (단, ' 를 제외하고)
  980. // 4. 한번 읽었던 시트명은 더 읽을수가 없다 (즉, 중복처리)
  981. // 5. 따옴표가 있든 없는 읽은 값을 그대로 사용하면 된다.
  982. public bool Import_Point_CheckSheetName(string SheetName)
  983. {
  984. // 수량$, 코드$는 읽을수 없다
  985. if (SheetName == "수량$"
  986. || SheetName == "코드$"
  987. || SheetName == "연동그룹$"
  988. || SheetName == "연동설정$"
  989. )
  990. return false;
  991. // $가 없다면 시트명이 아니다
  992. else if (CheckSheetName_Character(SheetName) == false)
  993. return false;
  994. // $ 뒤에 글자가 있는건 시트명이 아니다
  995. else if (CheckSheetName_Character_After(SheetName) == false)
  996. return false;
  997. // 중복처리
  998. else if (CheckSheetName_SameData(SheetName) == false)
  999. return false;
  1000. else
  1001. return true;
  1002. }
  1003. // 위치 데이타를 토대로 클래스에 사용될 위치 이름 생성
  1004. public string Code_Position_Name_Create(string BuildingName, string StairName, string FloorName)
  1005. {
  1006. string TempResultPostionName = null;
  1007. // 빌딩 : None 은 언급하지 않는다
  1008. if (BuildingName != _Text.None) TempResultPostionName = BuildingName;
  1009. // 공백처리
  1010. if (TempResultPostionName != null) TempResultPostionName = TempResultPostionName.Trim();
  1011. // 층 : None 은 언급하지 않는다
  1012. if (StairName != _Text.None) TempResultPostionName = TempResultPostionName + _Text.Blank + StairName;
  1013. // 공백처리
  1014. if (TempResultPostionName != null) TempResultPostionName = TempResultPostionName.Trim();
  1015. // 계단 : None 은 언급하지 않는다
  1016. if (FloorName != _Text.None) TempResultPostionName = TempResultPostionName + _Text.Blank + FloorName;
  1017. // 공백처리
  1018. if (TempResultPostionName != null) TempResultPostionName = TempResultPostionName.Trim();
  1019. // 모두 공백이라면 None 으로 처리한다
  1020. if (TempResultPostionName == null) TempResultPostionName = _Text.None;
  1021. return TempResultPostionName;
  1022. }
  1023. // 이름으로 해쉬테이블에 조회해서 있다면 사용여부 변수를 true 변환
  1024. public bool Code_Position_Enable_Check(string CodePosition_Name)
  1025. {
  1026. if (_Data.HASH_CodePosition.ContainsKey(CodePosition_Name) == true)
  1027. {
  1028. // 사용여부
  1029. ((_Code_Position)_Data.HASH_CodePosition[CodePosition_Name]).Enable = true;
  1030. return true;
  1031. }
  1032. return false;
  1033. }
  1034. // 사용여부를 토대로 나머지는 모두 지워버림
  1035. public void Code_Postion_Create()
  1036. {
  1037. // 결과를 저장
  1038. Hashtable Result_HASH_CodePosition = new Hashtable();
  1039. ArrayList Result_LIST_CodePosition_NAME = new ArrayList();
  1040. foreach (string CodePosition_NAME in _Data.LIST_CodePosition_NAME)
  1041. {
  1042. // cyim 2013.6.20 코드정보는 사용을 하든 안하든 무조건 추가하도록 만든다, 다만 중복은 허용하지 않도록 만든다
  1043. // cyim 2013.6.26 FPER 에서 로딩속도가 너무 오래걸리므로 일단 사용하는것으로만 처리한다
  1044. if (((_Code_Position)_Data.HASH_CodePosition[CodePosition_NAME]).Enable == true)
  1045. {
  1046. // 중복허용안함
  1047. if (Result_LIST_CodePosition_NAME.Contains(CodePosition_NAME) == false)
  1048. {
  1049. // 해쉬에 추가
  1050. Result_HASH_CodePosition.Add(CodePosition_NAME, ((_Code_Position)_Data.HASH_CodePosition[CodePosition_NAME]));
  1051. // 리스트에 추가
  1052. Result_LIST_CodePosition_NAME.Add(CodePosition_NAME);
  1053. }
  1054. }
  1055. }
  1056. // 사용여부가 true 인것만 저장함
  1057. _Data.HASH_CodePosition = Result_HASH_CodePosition;
  1058. _Data.LIST_CodePosition_NAME = Result_LIST_CodePosition_NAME;
  1059. }
  1060. public string Read_Data(DataSet ds, int row, int col)
  1061. {
  1062. // 디버깅으로 사용되는 데이타
  1063. Debug_Row = row + 1;
  1064. Debug_Col = col + 1;
  1065. // 반환값
  1066. return ds.Tables[0].Rows[row][col].ToString();
  1067. }
  1068. }
  1069. }