12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Data.OleDb;
- using System.Collections;
- namespace IControls_ExcelVerify
- {
-
- public partial class IControls_ExcelVerify : Form
- {
- // 결과를 저장할 리스트
- public ArrayList ListResult = new ArrayList();
- public int No = 0;
- // 디버깅 용도
- public int Debug_Row = 0;
- public int Debug_Col = 0;
- public string Debug_SheetName = null;
- public string Debug_EtcMessage = null;
- public IControls_ExcelVerify()
- {
- InitializeComponent();
- this.listView_VerifyResult.Columns[0].Width = 40;
- this.listView_VerifyResult.Columns[1].Width = 270;
- this.listView_VerifyResult.Columns[2].Width = 40;
- this.listView_VerifyResult.Columns[3].Width = 40;
- this.listView_VerifyResult.Columns[4].Width = 500;
- }
- private void button_ExcelOpen_Click(object sender, EventArgs e)
- {
- OpenFileDialog openFileDialog = new OpenFileDialog();
- // 엑셀파일 연동시에 다이얼로그창은 프로젝트 경로에 따라서 Field 폴더에 곧바로 접근할 수있도록 함
- //openFileDialog.InitialDirectory = _Data.Project_Path + "\\" + _Data.Project_Name;
- // 필터 처리
- // openFileDialog.Filter = "(*.xls*)|*.xls*";
- if (openFileDialog.ShowDialog() == DialogResult.OK)
- {
- if (OpenTest(openFileDialog.FileName) == true)
- {
- this.textBox_ExcelPath.Text = openFileDialog.FileName;
- MessageBox.Show("엑셀 열기 완료");
- }
- else
- {
- this.textBox_ExcelPath.Text = null;
- MessageBox.Show("엑셀 열기 실패");
- }
- }
- this.listView_VerifyResult.Items.Clear();
- }
- // Export (다이얼로그 창 없이 바로 생성)
- public EXCEL_DOC_TYPE Export_File_Check(string FileFullPath)
- {
- string Ext = FileFullPath.Substring(FileFullPath.LastIndexOf(".") + 1, FileFullPath.Length - FileFullPath.LastIndexOf(".") - 1);
- Ext = Ext.ToLower();
- if (Ext.Equals("xls"))
- {
- return EXCEL_DOC_TYPE.Xls;
- }
- else if (Ext.Equals("xlsx"))
- {
- return EXCEL_DOC_TYPE.Xlsx;
- }
- else
- {
- ////_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 250, 150, _Text.FailFormatInform, 0);
- return EXCEL_DOC_TYPE.Not;
- }
- }
- public string ConnectionString(string FileFullPath)
- {
- string result = null;
- switch (Export_File_Check(FileFullPath))
- {
- case EXCEL_DOC_TYPE.Xls:
- result = @"Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + FileFullPath + ";Extended Properties='Excel 8.0;HDR=No;IMEX=1';Persist Security Info=False";
- break;
- case EXCEL_DOC_TYPE.Xlsx:
- result = @"Provider=Microsoft.ACE.OLEDB.12.0;Data source=" + FileFullPath + ";Extended Properties='Excel 12.0;HDR=No;IMEX=1';Persist Security Info=False";
- break;
- }
- return result;
- }
- // 엑셀 열기 테스트
- public bool OpenTest(string FileFullPath)
- {
- try
- {
- OleDbConnection Connection = new OleDbConnection(ConnectionString(FileFullPath));
- Connection.Open();
- return true;
- }
- catch (Exception e)
- {
- MessageBox.Show(e.ToString());
- return false;
- }
- }
- // 리스트에 데이타 추가
- private void ListView_AddItem(string No, string SheetName, string Row, string Col, string Comment)
- {
- string[] Data1 = { No, SheetName, Row, Col, Comment };
- ListViewItem item = new ListViewItem(Data1);
- listView_VerifyResult.Items.Add(item);
- }
- // 로그 출력
- private void Display_Log()
- {
- // 먼저 초기화 하고 진행한다
- this.listView_VerifyResult.Items.Clear();
- for (int i = 0; i < ListResult.Count; i++)
- {
- string[] Temp = ListResult[i].ToString().Split('^');
- if (Temp.Length == 5)
- ListView_AddItem(Temp[0], Temp[1], Temp[2], Temp[3], Temp[4]);
- }
- }
- // 리스트에 추가
- private void List_Add(string sheetname, string row, string col, string comment)
- {
- No++;
- ListResult.Add(
- No.ToString() + "^" +
- sheetname + "^" +
- row + "^" +
- col + "^" +
- comment);
- }
- // 검증 시작
- private void button_VerifyStart_Click(object sender, EventArgs e)
- {
- if (this.textBox_ExcelPath.Text == null)
- {
- MessageBox.Show("엑셀파일을 먼저 지정해주세요");
- return;
- }
- // 로그 리스트 초기화
- ListResult.Clear();
- No = 0;
- // 검증시작
- Import_Point(this.textBox_ExcelPath.Text);
-
- // 데이타 출력
- Display_Log();
- MessageBox.Show("검증 작업 완료! (문제있는 경우에만 내역이 출력됨)");
- }
-
- // Import
- public bool Import_Point(string FileFullPath)
- {
- // 중계기 번호
- int RepeaterRowNum = 0;
- // 디버깅 변수 초기화
- Debug_Row = 0;
- Debug_Col = 0;
- Debug_SheetName = null;
- Debug_EtcMessage = null;
- string CheckConnectionString = ConnectionString(FileFullPath);
- if (CheckConnectionString == null)
- {
- MessageBox.Show(" 파일 확장자를 확인해주세요");
- return false;
- }
-
- // 엑셀 문서 접근
- OleDbConnection Connection = new OleDbConnection(CheckConnectionString);
- //return false;
- try
- {
- // 엑셀 문서 읽기
- Connection.Open();
- // 시트명을 가져온다
- DataTable worksheets = Connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
- ///
- /// 1. 코드값 저장
- ///
- /// 코드 시트가 있는지 확인하고 없다면 루틴을 돌지 않도록 한다
- /// 또한 _Data.Class_ExcelCode 에 코드 정보를 저장하여 차후에 사용하도록 클래스를 저장한다
- ///
- if (Import_Point_GetCode(worksheets, Connection) == false)
- {
- // 코드 시트가 잘못되었습니다
- MessageBox.Show("코드 시트가 잘못되었습니다");
- if (Connection != null) Connection.Close();
- return false;
- }
- ///
- /// 2. 포인트 정보 저장
- ///
- /// 포인트 정보를 저장하는 리스트이다 (가장 중요한 리스트이다, 시트별-중계기별-입출력포인트 순으로 클래스화 하여 저장한다)
- ///
- // 초기화
- _Data.List_ExcelPoint.Clear();
- // 엑셀 시트 수에 맞게 데이타를 읽어 온다
- for (int i = 0; i < worksheets.Rows.Count; i++)
- {
- // 시트명
- string sheetname = worksheets.Rows[i]["TABLE_NAME"].ToString();
- // 읽지 않는 시트인지 판별
- if (Import_Point_CheckSheetName(sheetname) == true)
- {
- // Debug
- Debug_SheetName = sheetname.Replace("$", "");
- // 읽은 정보를 데이타셋에 매칭
- OleDbCommand Command = new OleDbCommand("Select * From [" + sheetname + "]", Connection);
- OleDbDataAdapter dapt = new OleDbDataAdapter(Command);
- DataSet ds = new DataSet();
- dapt.Fill(ds);
- ///
- /// _Excel_Sheet 클래스 생성
- ///
- _Excel_Sheet Excel_Sheet = new _Excel_Sheet();
- // 시트명
- Excel_Sheet.Sheet_Name = sheetname;
- // 통신 보드
- Excel_Sheet.BOARD_ID = Read_Data(ds, 1, 0);
- // 계통
- Excel_Sheet.LOOP_NO = Read_Data(ds, 1, 1);
- // 중계기 총개수
- Excel_Sheet.Repeater_Count = Int32.Parse(Read_Data(ds, 1, 2));
- // 시트안에 중계기 개수 만큼 루프 생성
- for (int j = 0; j < Excel_Sheet.Repeater_Count; j++)
- {
- ///
- /// _Excel_Repeater 클래스 생성
- ///
- _Excel_Repeater Excel_Repeater = new _Excel_Repeater();
- // 중계기 타입
- string Temp_Repeater_Type = Read_Data(ds, 4 + (j * 5), 1);
- if (Temp_Repeater_Type == null || Temp_Repeater_Type.Trim().Length == 0)
- {
- Debug_Row = 4 + (j * 5) + 1;
- Debug_Col = 1 + 1;
- List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "중계기 타입 정보가 없습니다");
- //throw new Exception();
- }
- else if (Temp_Repeater_Type == "None")
- {
- ;// 사용하지 않는 중계기는 무시한다
- }
- else
- {
- // 중계기 검사 타입
- if (Read_Data(ds, 4 + (j * 5), 1) == "4*4")
- Excel_Repeater.TYPE = POINT_TYPE.REPEATER_4_4;
- else if (Read_Data(ds, 4 + (j * 5), 1) == "2*2")
- Excel_Repeater.TYPE = POINT_TYPE.REPEATER_2_2;
- else if (Read_Data(ds, 4 + (j * 5), 1) == "연감지기")
- Excel_Repeater.TYPE = POINT_TYPE.ANALOG_SMOKE;
- else if (Read_Data(ds, 4 + (j * 5), 1) == "열감지기")
- Excel_Repeater.TYPE = POINT_TYPE.ANALOG_HEAT;
- else
- // 중계기 타입이 없다면 예외
- {
- Debug_Row = 4 + (j * 5) + 1;
- Debug_Col = 1;
- //throw new Exception();
- List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "중계기 타입 정보가 잘못되었습니다");
- }
- // 2*2 에 2개 이상의 회로가 있다면 예외처리
- int Temp_RepeaterRowNum = 0;
- string Temp_Info = null;
- int Temp_Info_Cnt = 0;
- if (Excel_Repeater.TYPE == POINT_TYPE.REPEATER_2_2)
- {
- for (int k = 1; k <= 4; k++)
- {
- // 중계기 행번호
- Temp_RepeaterRowNum = 4 + (j * 5);
- // 위치정보
- Temp_Info += Read_Data(ds, Temp_RepeaterRowNum + k, 2);
- Temp_Info += Read_Data(ds, Temp_RepeaterRowNum + k, 3);
- Temp_Info += Read_Data(ds, Temp_RepeaterRowNum + k, 4);
- Temp_Info += Read_Data(ds, Temp_RepeaterRowNum + k, 5);
- Temp_Info += Read_Data(ds, Temp_RepeaterRowNum + k, 6);
- Temp_Info += Read_Data(ds, Temp_RepeaterRowNum + k, 7);
- Temp_Info += Read_Data(ds, Temp_RepeaterRowNum + k, 8);
- // 내용이 있다면
- if (Temp_Info != null && Temp_Info.Length != 0)
- Temp_Info_Cnt++;
- // 초기화
- Temp_Info = null;
- }
- // 중계기 회로가 2*2 인데 더 많은 정보가 있으므로 틀리다
- if (Temp_Info_Cnt > 2)
- {
- Debug_Row = 4 + (j * 5) + 1;
- Debug_Col = 1;
- //throw new Exception();
- List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "중계기 회로가 2*2 인데 더 많은 정보가 있으므로 틀립니다");
- }
- }
- // 중계기 아이디
- Excel_Repeater.REPEATER_ID = Read_Data(ds, 4 + (j * 5), 0);
- // 중계기 아이디가 없다면 예외
- if (Excel_Repeater.REPEATER_ID == null || Excel_Repeater.REPEATER_ID.Trim().Length == 0)
- {
- Debug_Row = 4 + (j * 5) + 1;
- Debug_Col = 0;
- //throw new Exception();
- List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "중계기 아이디가 없습니다");
- }
- // 중계기 위치 정보
- Excel_Repeater.Excel_Position.Building = Read_Data(ds, 4 + (j * 5), 2);
- Excel_Repeater.Excel_Position.Stair = Read_Data(ds, 4 + (j * 5), 3);
- Excel_Repeater.Excel_Position.Floor = Read_Data(ds, 4 + (j * 5), 4);
- // 중계기 위치 정보 없다면 예외
- if (Excel_Repeater.Excel_Position.Building == null || Excel_Repeater.Excel_Position.Building.Trim().Length == 0)
- {
- Debug_Row = 4 + (j * 5) + 1;
- Debug_Col = 2;
- //throw new Exception();
- List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "중계기 건물 위치 정보 없습니다");
- }
- if (Excel_Repeater.Excel_Position.Stair == null || Excel_Repeater.Excel_Position.Stair.Trim().Length == 0)
- {
- Debug_Row = 4 + (j * 5) + 1;
- Debug_Col = 3;
- //throw new Exception();
- List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "중계기 계단 위치 정보 없습니다");
- }
- if (Excel_Repeater.Excel_Position.Floor == null || Excel_Repeater.Excel_Position.Floor.Trim().Length == 0)
- {
- Debug_Row = 4 + (j * 5) + 1;
- Debug_Col = 4;
- //throw new Exception();
- List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "중계기 층 위치 정보 없습니다");
- }
- // 위치 코드 사용여부 체크
- string Temp_Repeater_Position_Name = Code_Position_Name_Create(
- Excel_Repeater.Excel_Position.Building, Excel_Repeater.Excel_Position.Stair, Excel_Repeater.Excel_Position.Floor);
- // 위치 코드가 잘못되었다
- if (Code_Position_Enable_Check(Temp_Repeater_Position_Name) == false)
- {
- Debug_EtcMessage = _Text.FailDataInform_NotCodePostionName;
- //throw new Exception();
- List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "위치 코드가 잘못되었습니다. 사용하지 않는 정보가 있습니다.");
- }
- // 중계기 명칭
- Excel_Repeater.NAME = Read_Data(ds, 4 + (j * 5), 5);
- // 중계기 명칭 없다면 예외
- if (Excel_Repeater.NAME == null || Excel_Repeater.NAME.Trim().Length == 0)
- {
- Debug_Row = 4 + (j * 5) + 1;
- Debug_Col = 5;
- //throw new Exception();
- List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "중계기 명칭 없습니다.");
- }
- // 중계기 타입에 상관없이 무조건 4행 단위로 읽는다
- for (int k = 1; k <= 4; k++)
- {
- // 중계기 행번호
- RepeaterRowNum = 4 + (j * 5);
- // 디바이스 아이디(중계기타입 아래칸)은 제대로된 순번을 넣어야한다
- if (Read_Data(ds, RepeaterRowNum + k, 1) != k.ToString())
- {
- Debug_Row = 4 + (j * 5) + k + 1;
- Debug_Col = 1;
- //throw new Exception();
- List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "디바이스 아이디는(중계기타입 아래칸) 중계기 타입에 상관없이 무조건 1~4 넣어야 합니다");
- }
- ///
- /// _Excel_Point 클래스 생성 (입력부)
- ///
- // 디바이스 명칭이 없다면 제외
- if (ds.Tables[0].Rows[RepeaterRowNum + k][5] != null && ds.Tables[0].Rows[RepeaterRowNum + k][5].ToString().Length != 0)
- {
- string TempDeviceName = Read_Data(ds, RepeaterRowNum + k, 5);
- TempDeviceName = TempDeviceName.Trim();
- if (TempDeviceName != null && TempDeviceName.Length != 0)
- {
- _Excel_Point Excel_Point_Input = new _Excel_Point();
- // 입력 포인트 타입
- Excel_Point_Input.TYPE = POINT_TYPE.I;
- // 입력 포인트 PortNum
- Excel_Point_Input.PortNum = ds.Tables[0].Rows[RepeaterRowNum + k][1].ToString();
- // 입력 포인트 위치 정보
- Excel_Point_Input.Excel_Position.Building = Read_Data(ds, RepeaterRowNum + k, 2);
- Excel_Point_Input.Excel_Position.Stair = Read_Data(ds, RepeaterRowNum + k, 3);
- Excel_Point_Input.Excel_Position.Floor = Read_Data(ds, RepeaterRowNum + k, 4);
- // 위치 코드 사용여부 체크
- string Temp_Point_Position_Name = Code_Position_Name_Create(
- Excel_Point_Input.Excel_Position.Building, Excel_Point_Input.Excel_Position.Stair, Excel_Point_Input.Excel_Position.Floor);
- if (Code_Position_Enable_Check(Temp_Point_Position_Name) == false)
- {
- Debug_EtcMessage = _Text.FailDataInform_NotCodePostionName;
- //throw new Exception();
- List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), Debug_EtcMessage);
- }
- // 입력 포인트 명칭
- Excel_Point_Input.NAME = TempDeviceName;
- // 입력 포인트 코드
- Excel_Point_Input.Code_FullName = Read_Data(ds, RepeaterRowNum + k, 6);
- string[] TempCode = Excel_Point_Input.Code_FullName.Split(' ');
- Excel_Point_Input.Code_Type = TempCode[0];
- Excel_Point_Input.Code_Name = TempCode[1];
- // 리스트에 추가
- Excel_Repeater.List_Point.Add(Excel_Point_Input);
- }
- }
- // 단, 명칭은 없지만, 코드가 존재하는 경우는 예외다
- else
- {
- // 코드가 존재하는 경우
- if (ds.Tables[0].Rows[RepeaterRowNum + k][6] != null && ds.Tables[0].Rows[RepeaterRowNum + k][6].ToString().Trim().Length != 0)
- {
- // 명칭이 없는 경우만
- if (ds.Tables[0].Rows[RepeaterRowNum + k][5] == null || ds.Tables[0].Rows[RepeaterRowNum + k][5].ToString().Trim().Length == 0)
- {
- Debug_Row = RepeaterRowNum + k + 1;
- Debug_Col = 5 + 1;
- //throw new Exception();
- List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "입력 포인트 명칭이 없습니다");
- }
- }
- }
- ///
- /// _Excel_Point 클래스 생성 (출력부)
- ///
- // 디바이스 명칭이 없다면 제외
- if (ds.Tables[0].Rows[RepeaterRowNum + k][7] != null && ds.Tables[0].Rows[RepeaterRowNum + k][7].ToString().Length != 0)
- {
- string TempDeviceName = Read_Data(ds, RepeaterRowNum + k, 7);
- TempDeviceName = TempDeviceName.Trim();
- if (TempDeviceName != null && TempDeviceName.Length != 0)
- {
- _Excel_Point Excel_Point_Output = new _Excel_Point();
- // 출력 포인트 타입
- Excel_Point_Output.TYPE = POINT_TYPE.O;
- // 출력 포인트 PortNum
- Excel_Point_Output.PortNum = ds.Tables[0].Rows[RepeaterRowNum + k][1].ToString();
- // 출력 포인트 위치 정보
- Excel_Point_Output.Excel_Position.Building = Read_Data(ds, RepeaterRowNum + k, 2);
- Excel_Point_Output.Excel_Position.Stair = Read_Data(ds, RepeaterRowNum + k, 3);
- Excel_Point_Output.Excel_Position.Floor = Read_Data(ds, RepeaterRowNum + k, 4);
- // 위치 코드 사용여부 체크
- string Temp_Point_Position_Name = Code_Position_Name_Create(
- Excel_Point_Output.Excel_Position.Building, Excel_Point_Output.Excel_Position.Stair, Excel_Point_Output.Excel_Position.Floor);
- if (Code_Position_Enable_Check(Temp_Point_Position_Name) == false)
- {
- Debug_EtcMessage = _Text.FailDataInform_NotCodePostionName;
- //throw new Exception();
- List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), Debug_EtcMessage);
- }
- // 출력 포인트 명칭
- Excel_Point_Output.NAME = TempDeviceName;
- // 출력 포인트 코드
- Excel_Point_Output.Code_FullName = Read_Data(ds, RepeaterRowNum + k, 8);
- string[] TempCode = Excel_Point_Output.Code_FullName.Split(' ');
- Excel_Point_Output.Code_Type = TempCode[0];
- Excel_Point_Output.Code_Name = TempCode[1];
- // 리스트에 추가
- Excel_Repeater.List_Point.Add(Excel_Point_Output);
- }
- }
- // 단, 명칭은 없지만, 코드가 존재하는 경우는 예외다
- else
- {
- // 코드가 존재하는 경우
- if (ds.Tables[0].Rows[RepeaterRowNum + k][8] != null && ds.Tables[0].Rows[RepeaterRowNum + k][8].ToString().Trim().Length != 0)
- {
- // 명칭이 없는 경우만
- if (ds.Tables[0].Rows[RepeaterRowNum + k][7] == null || ds.Tables[0].Rows[RepeaterRowNum + k][7].ToString().Trim().Length == 0)
- {
- Debug_Row = RepeaterRowNum + k + 1;
- Debug_Col = 7 + 1;
- //throw new Exception();
- List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "출력 포인트 명칭이 없습니다");
- }
- }
- }
- }
- // 리스트에 추가
- Excel_Sheet.List_Repeater.Add(Excel_Repeater);
- }
- }
- // 리스트에 추가
- _Data.List_ExcelPoint.Add(Excel_Sheet);
- }
- }
- ///
- /// 3. 포인트 위치 정보에 따라 실제로 사용한는 위치 코드값을 재정리
- /// 실제로 사용되는 위치코드만 재정리
- ///
- Code_Postion_Create();
- // 단, 엑셀시트 클래스안에 중계기클래스가 없다면 잘못된 포맷이다
- int RepeterAllCount = 0;
- foreach (_Excel_Sheet Excel_Sheet in _Data.List_ExcelPoint)
- foreach (_Excel_Repeater Excel_Repeater in Excel_Sheet.List_Repeater)
- RepeterAllCount++;
- if (RepeterAllCount == 0)
- {
- // 파일 포맷이 잘못되었습니다
- //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 250, 150, _Text.FailFormatInform, 0);
- // return false;
- List_Add(_Text.None, Debug_Row.ToString(), Debug_Col.ToString(), "엑셀시트 클래스안에 중계기클래스가 없다면 잘못된 포맷입니다");
- }
- /////
- ///// 4. 그룹 정보 저장
- /////
- //if (Import_Point_GetGroup(worksheets, Connection) == false)
- //{
- // // 연동그룹 시트가 잘못되었습니다
- // //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 250, 150, _Text.FailGroupInform, 0);
- // return false;
- //}
- /////
- ///// 5. 맵 정보 저장
- /////
- //if (Import_Point_GetMap(worksheets, Connection) == false)
- //{
- // // 연동설정 시트가 잘못되었습니다
- // //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 250, 150, _Text.FailMapInform, 0);
- // return false;
- //}
- // 엑셀 읽기 세션 해제
- if (Connection != null) Connection.Close();
- return true;
- }
- catch // (Exception e)
- {
- string Error = " 시트명:" + Debug_SheetName + " 행:" + Debug_Row + " 열:" + Debug_Col;
- // 추가 메세지가 필요한 경우
- string Message = null;
- // 추가 메세지가 없는 경우에는 "데이타가 잘못되었습니다" 문구 출력
- if (Debug_EtcMessage != null)
- Message = Debug_EtcMessage + Error;
- else
- Message = _Text.FailDataInform + Error;
- // 데이타가 잘못되었습니다
- ////_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 600, 150, Message, 0);
-
- // LOG
- //_Event.DebugView_SendMessage_Write(_Text.NotReadExcelFile + Error + " 의 정보를 확인해주세요 " + e.ToString());
- List_Add(Debug_SheetName, Debug_Row.ToString(), Debug_Col.ToString(), "데이타가 잘못되었습니다. 예외지점을 재확인바랍니다");
- // 엑셀 읽기 세션 해제
- if (Connection != null) Connection.Close();
- return false;
- }
- }
- // 코드값 읽기
- public bool Import_Point_GetCode(DataTable Sheets, OleDbConnection Connection)
- {
- try
- {
- // 코드 시트명을 가져온다
- for (int i = 0; i < Sheets.Rows.Count; i++)
- {
- // 만약 가져오지 못한다면 실패로 처리함, 코드 시트명은 고정되어 있다! => 코드$
- if (Sheets.Rows[i]["TABLE_NAME"].ToString() == "코드$")
- {
- // 시트명
- string sheetname = Sheets.Rows[i]["TABLE_NAME"].ToString();
- Debug_SheetName = sheetname.Replace("$", "");
-
- OleDbCommand Command = new OleDbCommand("Select * From [코드$]", Connection);
- OleDbDataAdapter dapt = new OleDbDataAdapter(Command);
- DataSet ds = new DataSet();
- dapt.Fill(ds);
-
- ///
- /// 코드값들을 읽는다
- ///
- // 건물 이름
- ArrayList List_Building_Name = new ArrayList();
- ArrayList List_Building_Position = new ArrayList();
- ArrayList List_Building_Emergency = new ArrayList();
- // 계단
- ArrayList List_Stair_Name = new ArrayList();
- ArrayList List_Stair_Position = new ArrayList();
- ArrayList List_Stair_Emergency = new ArrayList();
- // 층
- ArrayList List_Floor_Name = new ArrayList();
- ArrayList List_Floor_Position = new ArrayList();
- ArrayList List_Floor_Emergency = new ArrayList();
- // 입력
- ArrayList List_Input_TypeName = new ArrayList();
- // 출력
- ArrayList List_Output_TypeName = new ArrayList();
- ArrayList List_Output_SEQ = new ArrayList();
- ArrayList List_Output_USE = new ArrayList();
- // IO 보드
- ArrayList List_IOBoard_Name = new ArrayList();
- ArrayList List_IOBoard_ComPort = new ArrayList();
- ArrayList List_IOBoard_BoardID = new ArrayList();
- ArrayList List_IOBoard_LoopNo = new ArrayList();
- ArrayList List_IOBoard_RepeaterID = new ArrayList();
- ArrayList List_IOBoard_DeviceID = new ArrayList();
- ArrayList List_IOBoard_InOut = new ArrayList();
- ArrayList List_IOBoard_AddRepeaterYesNo = new ArrayList();
- ArrayList List_IOBoard_AddRepeaterType = new ArrayList();
- // 이벤트 타입
- ArrayList List_EventType_Type = new ArrayList();
- ArrayList List_EventType_Name = new ArrayList();
- // 아날로그 감지기 레벨 및 시간
- ArrayList List_Analog_Level = new ArrayList();
- ArrayList List_FireDay_Time = new ArrayList();
- // 건물코드 읽기
- List_Building_Name = Get_CodeData_Until_Null(ds, 3, 0);
- List_Building_Position = Get_CodeData_Until_Null(ds, 3, 1);
- List_Building_Emergency = Get_CodeData_Until_Null(ds, 3, 2);
- // 계단코드 읽기
- List_Stair_Name = Get_CodeData_Until_Null(ds, 3, 3);
- List_Stair_Position = Get_CodeData_Until_Null(ds, 3, 4);
- List_Stair_Emergency = Get_CodeData_Until_Null(ds, 3, 5);
- // 층코드 읽기
- List_Floor_Name = Get_CodeData_Until_Null(ds, 3, 6);
- List_Floor_Position = Get_CodeData_Until_Null(ds, 3, 7);
- List_Floor_Emergency = Get_CodeData_Until_Null(ds, 3, 8);
- // 입력코드 읽기
- List_Input_TypeName = Get_CodeData_Until_Null(ds, 3, 10);
- // 출력코드 읽기
- List_Output_TypeName = Get_CodeData_Until_Null(ds, 3, 12);
- List_Output_SEQ = Get_CodeData_Until_Null(ds, 3, 13);
- List_Output_USE = Get_CodeData_Until_Null(ds, 3, 14);
- // IO 보드 읽기
- List_IOBoard_Name = Get_CodeData_Until_Null(ds, 3, 18);
- List_IOBoard_ComPort = Get_CodeData_Until_Null(ds, 3, 19);
- List_IOBoard_BoardID = Get_CodeData_Until_Null(ds, 3, 20);
- List_IOBoard_LoopNo = Get_CodeData_Until_Null(ds, 3, 21);
- List_IOBoard_RepeaterID = Get_CodeData_Until_Null(ds, 3, 22);
- List_IOBoard_DeviceID = Get_CodeData_Until_Null(ds, 3, 23);
- List_IOBoard_InOut = Get_CodeData_Until_Null(ds, 3, 24);
- List_IOBoard_AddRepeaterYesNo = Get_CodeData_Until_Null(ds, 3, 25);
- List_IOBoard_AddRepeaterType = Get_CodeData_Until_Null(ds, 3, 26);
- // 이벤트 타입 읽기
- List_EventType_Type = Get_CodeData_Until_Null(ds, 3, 28);
- List_EventType_Name = Get_CodeData_Until_Null(ds, 3, 29);
- // 아날로그 감지기 레벨 및 시간
- List_Analog_Level = Get_CodeData_Until_Null(ds, 3, 32);
- List_FireDay_Time = Get_CodeData_Until_Null(ds, 3, 34);
- // 단, 코드 값중에 하나라도 빈값이라면 취소
- if (List_Building_Name.Count == 0 || List_Building_Position.Count == 0 || List_Building_Emergency.Count == 0
- || List_Stair_Name.Count == 0 || List_Stair_Position.Count == 0 || List_Stair_Emergency.Count == 0
- || List_Floor_Name.Count == 0 || List_Floor_Position.Count == 0 || List_Floor_Emergency.Count == 0)
- {
- List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError1);
- //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError1, 0);
- //return false;
- }
- if (List_Input_TypeName.Count == 0 || List_Output_TypeName.Count == 0 || List_Output_SEQ.Count == 0 || List_Output_USE.Count == 0)
- {
- List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError7);
- //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError7, 0);
- //return false;
- }
- if (List_IOBoard_Name.Count == 0 || List_IOBoard_ComPort.Count == 0 || List_IOBoard_BoardID.Count == 0
- || List_IOBoard_LoopNo.Count == 0 || List_IOBoard_RepeaterID.Count == 0 || List_IOBoard_DeviceID.Count == 0
- || List_IOBoard_InOut.Count == 0 || List_IOBoard_AddRepeaterYesNo.Count == 0 || List_IOBoard_AddRepeaterYesNo.Count == 0)
- {
- List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError8);
- //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError8, 0);
- //return false;
- }
- if (List_EventType_Type.Count == 0 || List_EventType_Name.Count == 0)
- {
- List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError9);
- //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError9, 0);
- //return false;
- }
- //
- // 단, 코드의 3가지는 모두 개수가 동일해야한다. 또한 출력코드 및 IO 보드 및 이벤트 타입은 데이타 레코드수가 동일해야한다
- //
- if ((List_Building_Name.Count != List_Building_Position.Count) || (List_Building_Name.Count != List_Building_Emergency.Count))
- {
- List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError2_1);
- //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError2, 0);
- //return false;
- }
- if ((List_Stair_Name.Count != List_Stair_Position.Count) || (List_Stair_Name.Count != List_Stair_Emergency.Count))
- {
- List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError2_2);
- //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError2, 0);
- // return false;
- }
- if ((List_Floor_Name.Count != List_Floor_Position.Count) || (List_Floor_Name.Count != List_Floor_Emergency.Count))
- {
- List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError2_3);
- //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError2, 0);
- //return false;
- }
- if (List_Output_TypeName.Count + List_Output_SEQ.Count + List_Output_USE.Count != List_Output_TypeName.Count * 3)
- {
- List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError4);
- //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError4, 0);
- //return false;
- }
- if (List_IOBoard_Name.Count + List_IOBoard_ComPort.Count + List_IOBoard_BoardID.Count + List_IOBoard_LoopNo.Count + List_IOBoard_RepeaterID.Count
- + List_IOBoard_DeviceID.Count + List_IOBoard_InOut.Count + List_IOBoard_AddRepeaterYesNo.Count + List_IOBoard_AddRepeaterType.Count != List_IOBoard_Name.Count * 9)
- {
- List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError5);
- //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError5, 0);
- //return false;
- }
- if (List_EventType_Type.Count != List_EventType_Name.Count)
- {
- List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError6);
- //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError6, 0);
- //return false;
- }
- ///
- /// 데이타베이스 연동을 위한 클래스를 생성한다
- ///
- // 위치코드 및 비상코드를 생성한다 (건물-계단-층 순으로 고유의 6자리 코드를 생성한다
- // 또한 여기에 명칭을 정리한다. 이 경우에 공백으로 각 데이타를 구분하도록 한다
- // ex : 101동 - 1계단 - None => 101동 1계단
- // ex : 101동 - None - B1F => 101동 B1F
- _Data.HASH_CodePosition.Clear();
- _Data.LIST_CodePosition_NAME.Clear();
- foreach (string BuildingName in List_Building_Name)
- {
- foreach (string StairName in List_Stair_Name)
- {
- foreach (string FloorName in List_Floor_Name)
- {
- // 클래스 생성
- _Code_Position Code_Position = new _Code_Position();
- ///
- /// 아이디
- ///
- //Code_Position.Code_Position_ID =
- // _Convert.String_to_Int_TwoType(List_Building.IndexOf(BuildingName).ToString()) +
- // _Convert.String_to_Int_TwoType(List_Stair.IndexOf(StairName).ToString()) +
- // _Convert.String_to_Int_TwoType(List_Floor.IndexOf(FloorName).ToString());
- // 인덱스는 동일하므로
- int Temp_Index_Building = List_Building_Name.IndexOf(BuildingName);
- int Temp_Index_Stair = List_Stair_Name.IndexOf(StairName);
- int Temp_Index_Floor = List_Floor_Name.IndexOf(FloorName);
- ///
- /// 위치코드
- ///
- Code_Position.Code_Position_ID =
- _Convert.String_to_Int_TwoType(List_Building_Position[Temp_Index_Building].ToString()) +
- _Convert.String_to_Int_TwoType(List_Stair_Position[Temp_Index_Stair].ToString()) +
- _Convert.String_to_Int_TwoType(List_Floor_Position[Temp_Index_Floor].ToString());
- ///
- /// 비상방송코드
- ///
- Code_Position.Code_Emergency_ID =
- _Convert.String_to_Int_TwoType(List_Building_Emergency[Temp_Index_Building].ToString()) +
- _Convert.String_to_Int_TwoType(List_Stair_Emergency[Temp_Index_Stair].ToString()) +
- _Convert.String_to_Int_TwoType(List_Floor_Emergency[Temp_Index_Floor].ToString());
- ///
- /// 이름
- ///
- Code_Position.Code_Position_NAME = Code_Position_Name_Create(BuildingName, StairName, FloorName);
- // 사용여부 해제
- Code_Position.Enable = false;
- // 해쉬 추가
- // (디폴트로 생성되는 위치 코드 리스트이며 차후에 Import_Point 함수에서 실제로 사용되는 위치만 추출해서 변경된다
- // ID 를 참조하는게 아니라 이름을 기준으로 참조하므로 사용에 주의
- if (_Hash.Add(_Data.HASH_CodePosition, Code_Position.Code_Position_NAME, Code_Position) == true)
- {
- _Data.LIST_CodePosition_NAME.Add(Code_Position.Code_Position_NAME);
- }
- }
- }
- }
- //
- // 입력코드 및 출력코드를 생성한결과에 데이타베이스의 TB_DEVICE_TYPE 에 저장하기 위한 필드들을 매칭시켜 저장해둔다
- //
- _Data.LIST_CodeDeviceType.Clear();
- // 입력
- foreach (string Input_TypeName in List_Input_TypeName)
- {
- _Code_Device_Type Table_Device_Type = new _Code_Device_Type();
- // 데이타를 추출한다 (예시 : IA 일반화재입력)
- string[] Temp_Input_TypeName = Input_TypeName.Split(' ');
- if (Temp_Input_TypeName.Length != 2)
- {
- List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError3_1);
- //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError3, 0);
- //return false;
- }
- // 데이타 저장
- Table_Device_Type.DEVICE_TYPE = Temp_Input_TypeName[0];
- Table_Device_Type.DEVICE_TYPE_NAME = Temp_Input_TypeName[1];
- Table_Device_Type.SYMBOL_TYPE = "I";
- Table_Device_Type.SEQ_NO = "0";
- Table_Device_Type.USE_FLAG = "Y";
- // 클래스에 추가
- _Data.LIST_CodeDeviceType.Add(Table_Device_Type);
- }
- // 출력
- foreach (string Output_TypeName in List_Output_TypeName)
- {
- _Code_Device_Type Table_Device_Type = new _Code_Device_Type();
- // 데이타를 추출한다 (예시 : OA 주경종)
- string[] Temp_Output_TypeName = Output_TypeName.Split(' ');
- if (Temp_Output_TypeName.Length != 2)
- {
- List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError3_2);
- //_Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 550, 150, _Text.CodeError3, 0);
- //return false;
- }
- // 데이타 저장
- Table_Device_Type.DEVICE_TYPE = Temp_Output_TypeName[0];
- Table_Device_Type.DEVICE_TYPE_NAME = Temp_Output_TypeName[1];
- Table_Device_Type.SYMBOL_TYPE = "O";
- Table_Device_Type.SEQ_NO = List_Output_SEQ[List_Output_TypeName.IndexOf(Output_TypeName)].ToString();
- Table_Device_Type.USE_FLAG = List_Output_USE[List_Output_TypeName.IndexOf(Output_TypeName)].ToString(); ;
- // 클래스에 추가
- _Data.LIST_CodeDeviceType.Add(Table_Device_Type);
- }
- //
- // IO보드를 생성한결과에 데이타베이스의 TB_DEVICE 에 저장하기 위한 필드들을 매칭시켜 저장해둔다
- //
- // 중복된 내용이 있다면 사용불가
- ArrayList Temp_IOBoard_Name = new ArrayList();
- foreach (string Name in List_IOBoard_Name)
- {
- if (Temp_IOBoard_Name.Contains(Name) == false)
- Temp_IOBoard_Name.Add(Name);
- }
- if (Temp_IOBoard_Name.Count != List_IOBoard_Name.Count)
- {
- List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError11);
- }
- _Data.LIST_CodeIOBoard.Clear();
- // IO
- foreach (string IOBoard_Name in List_IOBoard_Name)
- {
- _Code_IO_Board IO_Board = new _Code_IO_Board();
- // 데이타 저장
- IO_Board.IOBOARD_NAME = IOBoard_Name;
- IO_Board.IOBOARD_COM_PORT = List_IOBoard_ComPort[List_IOBoard_Name.IndexOf(IOBoard_Name)].ToString();
- IO_Board.IOBOARD_BOARD_ID = List_IOBoard_BoardID[List_IOBoard_Name.IndexOf(IOBoard_Name)].ToString();
- IO_Board.IOBOARD_LOOP_NO = List_IOBoard_LoopNo[List_IOBoard_Name.IndexOf(IOBoard_Name)].ToString();
- IO_Board.IOBOARD_REPEATER_ID = List_IOBoard_RepeaterID[List_IOBoard_Name.IndexOf(IOBoard_Name)].ToString();
- IO_Board.IOBOARD_DEVICE_ID = List_IOBoard_DeviceID[List_IOBoard_Name.IndexOf(IOBoard_Name)].ToString();
- IO_Board.IOBOARD_INOUT = List_IOBoard_InOut[List_IOBoard_Name.IndexOf(IOBoard_Name)].ToString();
- IO_Board.IOBOARD_ADDREPEATER_YN = List_IOBoard_AddRepeaterYesNo[List_IOBoard_Name.IndexOf(IOBoard_Name)].ToString();
- IO_Board.IOBOARD_ADDREPEATER_TYPE = List_IOBoard_AddRepeaterType[List_IOBoard_Name.IndexOf(IOBoard_Name)].ToString();
- // 클래스에 추가
- _Data.LIST_CodeIOBoard.Add(IO_Board);
- }
- //
- // 이벤트타입 생성한결과에 데이타베이스의 TB_EVENT_TYPE 에 저장하기 위한 필드들을 매칭시켜 저장해둔다
- //
- _Data.LIST_CodeEventType.Clear();
- // 이벤트 타입
- foreach (string EventType in List_EventType_Type)
- {
- _Code_Event_Type Event_Type = new _Code_Event_Type();
- // 데이타 저장
- Event_Type.EVENT_TYPE = EventType;
- Event_Type.EVENT_TYPE_NAME = List_EventType_Name[List_EventType_Type.IndexOf(EventType)].ToString();
- // 클래스에 추가
- _Data.LIST_CodeEventType.Add(Event_Type);
- }
- if(_Data.LIST_CodeEventType.Count == 0)
- List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError10);
- //
- // 아날로그 감지 레벨 및 시간
- //
- _Data.LIST_CodeAnalogLevel.Clear();
- // 0 : falut, 1 : PreFire, 2 : FireDay, 3 : FireNight
- if (List_Analog_Level.Count == 4)
- _Data.LIST_CodeAnalogLevel = (ArrayList)List_Analog_Level.Clone();
- else if(List_Analog_Level.Count != 0)
- List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError12);
- _Data.LIST_CodeFireDayTime.Clear();
- if (List_FireDay_Time.Count == 4)
- {
- int start_Hour = _Convert.Null_to_IntZero(List_FireDay_Time[0]);
- int start_Minute = _Convert.Null_to_IntZero(List_FireDay_Time[1]);
- int end_Hour = _Convert.Null_to_IntZero(List_FireDay_Time[2]);
- int end_Minute = _Convert.Null_to_IntZero(List_FireDay_Time[3]);
- if ((start_Hour > end_Hour) || (start_Hour == end_Hour && start_Minute > end_Minute))
- {
- List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError12);
- }
- _Data.LIST_CodeFireDayTime = (ArrayList)List_FireDay_Time.Clone();
- }
- else if (List_FireDay_Time.Count != 0)
- List_Add(Debug_SheetName, _Text.None, _Text.None, _Text.CodeError12);
- return true;
- }
- }
- return false;
- }
- catch // (Exception e)
- {
- //_Event.DebugView_SendMessage_Write(e.ToString());
- return false;
- }
- }
- // 코드 시트에 있는 값을 읽어오는 함수
- // 행단위로 검색하되 공백이 나오면 더이상 읽지 않도록 한다
- // 참고로 Col 을 지정하여 열에 접근할수 있도록 한다
- public ArrayList Get_CodeData_Until_Null(DataSet Ds, int StartRow, int FixedCol)
- {
- // 결과
- ArrayList result = new ArrayList();
- try
- {
- // 시작행
- int Count = StartRow;
- // 널값이 나올때까지
- while (Ds.Tables[0].Rows[Count][FixedCol] != null && Ds.Tables[0].Rows[Count][FixedCol].ToString() != "null"
- && Ds.Tables[0].Rows[Count][FixedCol].ToString().Length != 0)
- {
- // 선후공백은 제거한다
- string data = Ds.Tables[0].Rows[Count][FixedCol].ToString();
- data = data.Trim();
- result.Add(data);
- Count++;
- }
- return result;
- }
- catch
- {
- return result;
- }
-
- }
- //
- // 그룹 및 맵 정보를 가져오는 함수
- // 행단위로 검색하되 지정한 총개수만큼만 가져오도록 한다
- public ArrayList Get_CodeData_Until_AllCnt(DataSet Ds, int StartRow, int FixedCol, int AllCnt)
- {
- // 결과
- ArrayList result = new ArrayList();
- // 시작행
- int Count = StartRow;
- // 지정한 카운트 만큼
- while (Ds.Tables[0].Rows[Count][FixedCol] != null
- && Ds.Tables[0].Rows[Count][FixedCol].ToString().Length != 0)
- {
- // 선후공백은 제거한다
- string data = Ds.Tables[0].Rows[Count][FixedCol].ToString();
- data = data.Trim();
- result.Add(data);
- Count++;
- if (Count >= AllCnt + StartRow) break;
- }
- return result;
- }
- // $ 가 없는지 체크하는 함수
- public bool CheckSheetName_Character(string SheetName)
- {
- string temp = SheetName;
- temp = temp.Replace("$", "");
- if (temp.Length == SheetName.Length)
- return false; // $ 가 없다!
- else
- return true;
- }
- // $ 뒤에 글자가 있는지 확인 (단 ' 를 제외하고)
- public bool CheckSheetName_Character_After(string SheetName)
- {
- string[] temp = null;
- temp = SheetName.Split('$');
- if (temp.Length != 2) // 앞에서 $가 반드시 존재하는 조건을 걸었으므로 반드시 2개가 나온다
- return false;
- else if (temp.Length == 2 && (temp[1] == "'" || temp[1] == "")) // 2개로 쪼개지지만 끝은 ' 혹은 공백이다
- return true;
- else
- return false;
- }
- // 시트명 중복을 제외시키는 함수
- public bool CheckSheetName_SameData(string SheetName)
- {
- foreach (_Excel_Sheet Excel_Sheet in _Data.List_ExcelPoint)
- {
- if (Excel_Sheet.Sheet_Name == SheetName)
- return false;
- }
- return true;
- }
- // 시트명 예외처리..
- // 원래는 정확한 데이타가 들어와야 하지만 예외처리 조건이 너무 많다..테스트 결과 몇가지 규칙을 알아내었다.. 2013.04.19
- // 1. 시트명에는 반드시 뒤에 $가 들어온다
- // 2. 숫자로 시작되는 시트명에는 작은따옴표가 앞뒤로 붙는다 -> '101동$'
- // 3. 영문 혹은 한글로 시작되는 시트명에는 작은따옴표가 없다 -> 주차장$
- // 4. 특수문자 혹은 공백으로 시작되는 시트명에는 작은따옴표가 앞뒤로 붙는다 -> ' 101동$' , '@101동$'
- // 5. '101동'$Print_Area 와 같이 뒤에 이상한 문자열이 따르는 경우가 있다
- // 6. 주차장1$Print_Titles 와 같이 뒤에 이상한 문자열이 따르는 경우가 있다.
- //
- // 처리방법은 다음과 같다
- // 1. 특별 제외는 2개이다. 수량$,코드$ 는 엑셀포맷에 있지만 읽을수 없는 내용이므로 제외시킨다.
- // 2. $가 없다면 시트명이 아니다
- // 3. $뒤에 글자가 있는 것은 시트명이 아니다 (단, ' 를 제외하고)
- // 4. 한번 읽었던 시트명은 더 읽을수가 없다 (즉, 중복처리)
- // 5. 따옴표가 있든 없는 읽은 값을 그대로 사용하면 된다.
- public bool Import_Point_CheckSheetName(string SheetName)
- {
- // 수량$, 코드$는 읽을수 없다
- if (SheetName == "수량$"
- || SheetName == "코드$"
- || SheetName == "연동그룹$"
- || SheetName == "연동설정$"
- )
- return false;
- // $가 없다면 시트명이 아니다
- else if (CheckSheetName_Character(SheetName) == false)
- return false;
- // $ 뒤에 글자가 있는건 시트명이 아니다
- else if (CheckSheetName_Character_After(SheetName) == false)
- return false;
- // 중복처리
- else if (CheckSheetName_SameData(SheetName) == false)
- return false;
- else
- return true;
- }
- // 위치 데이타를 토대로 클래스에 사용될 위치 이름 생성
- public string Code_Position_Name_Create(string BuildingName, string StairName, string FloorName)
- {
- string TempResultPostionName = null;
- // 빌딩 : None 은 언급하지 않는다
- if (BuildingName != _Text.None) TempResultPostionName = BuildingName;
- // 공백처리
- if (TempResultPostionName != null) TempResultPostionName = TempResultPostionName.Trim();
- // 층 : None 은 언급하지 않는다
- if (StairName != _Text.None) TempResultPostionName = TempResultPostionName + _Text.Blank + StairName;
- // 공백처리
- if (TempResultPostionName != null) TempResultPostionName = TempResultPostionName.Trim();
- // 계단 : None 은 언급하지 않는다
- if (FloorName != _Text.None) TempResultPostionName = TempResultPostionName + _Text.Blank + FloorName;
- // 공백처리
- if (TempResultPostionName != null) TempResultPostionName = TempResultPostionName.Trim();
- // 모두 공백이라면 None 으로 처리한다
- if (TempResultPostionName == null) TempResultPostionName = _Text.None;
- return TempResultPostionName;
- }
- // 이름으로 해쉬테이블에 조회해서 있다면 사용여부 변수를 true 변환
- public bool Code_Position_Enable_Check(string CodePosition_Name)
- {
- if (_Data.HASH_CodePosition.ContainsKey(CodePosition_Name) == true)
- {
- // 사용여부
- ((_Code_Position)_Data.HASH_CodePosition[CodePosition_Name]).Enable = true;
- return true;
- }
- return false;
- }
- // 사용여부를 토대로 나머지는 모두 지워버림
- public void Code_Postion_Create()
- {
- // 결과를 저장
- Hashtable Result_HASH_CodePosition = new Hashtable();
- ArrayList Result_LIST_CodePosition_NAME = new ArrayList();
- foreach (string CodePosition_NAME in _Data.LIST_CodePosition_NAME)
- {
- // cyim 2013.6.20 코드정보는 사용을 하든 안하든 무조건 추가하도록 만든다, 다만 중복은 허용하지 않도록 만든다
- // cyim 2013.6.26 FPER 에서 로딩속도가 너무 오래걸리므로 일단 사용하는것으로만 처리한다
- if (((_Code_Position)_Data.HASH_CodePosition[CodePosition_NAME]).Enable == true)
- {
- // 중복허용안함
- if (Result_LIST_CodePosition_NAME.Contains(CodePosition_NAME) == false)
- {
- // 해쉬에 추가
- Result_HASH_CodePosition.Add(CodePosition_NAME, ((_Code_Position)_Data.HASH_CodePosition[CodePosition_NAME]));
- // 리스트에 추가
- Result_LIST_CodePosition_NAME.Add(CodePosition_NAME);
- }
- }
- }
- // 사용여부가 true 인것만 저장함
- _Data.HASH_CodePosition = Result_HASH_CodePosition;
- _Data.LIST_CodePosition_NAME = Result_LIST_CodePosition_NAME;
- }
- public string Read_Data(DataSet ds, int row, int col)
- {
- // 디버깅으로 사용되는 데이타
- Debug_Row = row + 1;
- Debug_Col = col + 1;
- // 반환값
- return ds.Tables[0].Rows[row][col].ToString();
- }
- }
- }
|