Пример #1
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //생성 :
        //추가 :
        //목적 : 초기화 함수
        //설명 :
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public bool Initialize(CProcessDatabase objProcessDatabase)
        {
            bool bReturn   = false;
            var  pDocument = CDocument.GetDocument;

            do
            {
                // 상위 클래스 이어줌
                base.m_objProcessDatabase = objProcessDatabase;
                CConfig objConfig = pDocument.m_objConfig;
                // 데이터베이스 파라메터
                CConfig.CDatabaseParameter objDatabaseParameter = objConfig.GetDatabaseParameter();
                // SQLite 초기화
                m_objSQLite = new CSQLite();
                CErrorReturn objReturn = m_objSQLite.HLInitialize(string.Format(@"{0}\{1}.db3", objConfig.GetDatabaseHistoryPath(), objDatabaseParameter.strDatabaseHistory));
                if (true == objReturn.m_bError)
                {
                    break;
                }
                // SQLite Connect
                objReturn = m_objSQLite.HLConnect();
                if (true == objReturn.m_bError)
                {
                    break;
                }
                // History Align 초기화
                m_objManagerTableHistoryAlign = new CManagerTable();
                if (false == m_objManagerTableHistoryAlign.HLInitialize(
                        m_objSQLite,
                        string.Format(@"{0}\{1}.txt", objConfig.GetDatabaseTablePath(), objDatabaseParameter.strTableHistoryAlign), ""))
                {
                    break;
                }
                //              // History Inspection 초기화
                //              m_objManagerTableHistoryInspection = new CManagerTable();
                //              if( false == m_objManagerTableHistoryInspection.HLInitialize(
                //                  m_objSQLite,
                //                  string.Format( @"{0}\{1}.txt", objConfig.GetDatabaseTablePath(), objDatabaseParameter.strTableHistoryInspection ), "" ) ) break;

                // Process History Delete 초기화
                m_objProcessDatabaseHistoryDelete = new CProcessDatabaseHistoryDelete();
                if (false == m_objProcessDatabaseHistoryDelete.Initialize(m_objProcessDatabase, m_objSQLite))
                {
                    break;
                }

                bReturn = true;
            } while(false);

            return(bReturn);
        }
Пример #2
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //생성 :
        //추가 :
        //목적 : 초기화 함수
        //설명 :
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public bool Initialize(CProcessDatabase objProcessDatabase)
        {
            bool bReturn   = false;
            var  pDocument = CDocument.GetDocument;

            do
            {
                // 상위 클래스 이어줌
                base.m_objProcessDatabase = objProcessDatabase;
                CConfig objConfig = pDocument.m_objConfig;
                // 데이터베이스 파라메터
                CConfig.CDatabaseParameter objDatabaseParameter = objConfig.GetDatabaseParameter();
                // SQLite 초기화
                m_objSQLite = new CSQLite();
                CErrorReturn objReturn = m_objSQLite.HLInitialize(string.Format(@"{0}\{1}.db3", objConfig.GetCurrentPath(), objDatabaseParameter.strDatabaseInformation));
                if (true == objReturn.m_bError)
                {
                    break;
                }
                // SQLite Connect
                objReturn = m_objSQLite.HLConnect();
                if (true == objReturn.m_bError)
                {
                    break;
                }
                // Information UI Text 초기화
                m_objManagerTableInformationUIText = new CManagerTable();
                if (false == m_objManagerTableInformationUIText.HLInitialize(
                        m_objSQLite,
                        string.Format(@"{0}\{1}.txt", objConfig.GetDatabaseTablePath(), objDatabaseParameter.strTableInformationUIText),
                        string.Format(@"{0}\{1}.txt", objConfig.GetDatabaseRecordPath(), objDatabaseParameter.strRecordInformationUIText)))
                {
                    break;
                }
                // Information User Message 초기화
                m_objManagerTableInformationUserMessage = new CManagerTable();
                if (false == m_objManagerTableInformationUserMessage.HLInitialize(
                        m_objSQLite,
                        string.Format(@"{0}\{1}.txt", objConfig.GetDatabaseTablePath(), objDatabaseParameter.strTableInformationUserMessage),
                        string.Format(@"{0}\{1}.txt", objConfig.GetDatabaseRecordPath(), objDatabaseParameter.strRecordInformationUserMessage)))
                {
                    break;
                }

                bReturn = true;
            } while(false);

            return(bReturn);
        }
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //생성 :
        //추가 :
        //목적 : 초기화 함수
        //설명 :
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public bool Initialize(CProcessDatabase objProcessDatabase, CSQLite objSQLite)
        {
            bool bReturn = false;

            do
            {
                // 프로세스 데이터베이스 이어줌
                m_objProcessDatabase = objProcessDatabase;
                // SQLite 이어줌
                m_objSQLite = objSQLite;
                // 타이머에 대한 콜백 메서드 정의
                m_objSystemTimer = new Timer(SetDeleteHistory);
                // 지연시간, 기간 (ms) 한 시간마다 주기로 호출되게 설정
                m_objSystemTimer.Change(1000, ( int )new TimeSpan(1, 0, 0).TotalMilliseconds);

                bReturn = true;
            } while(false);

            return(bReturn);
        }
Пример #4
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //생성 :
        //추가 :
        //목적 : 초기화
        //설명 :
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public bool HLInitialize(CSQLite objSQLite, string strTableFullPath, string strRecordFullPath)
        {
            bool bReturn = false;

            do
            {
                try {
                    // SQLite 이어줌
                    m_objSQLite = objSQLite;
                    // Txt 파일 클래스
                    CTxtFile objTxtFile = new CTxtFile();
                    // 이름 제외한 폴더 경로
                    string strTablePathOnly = Path.GetDirectoryName(strTableFullPath);
                    // 파일 이름 (확장자를 포함)
                    string strTableExtendName = Path.GetFileName(strTableFullPath);
                    // 확장자를 제거한 파일 이름
                    m_strTableName = Path.GetFileNameWithoutExtension(strTableFullPath);
                    // 확장자
                    string strTableExtendOnly = Path.GetExtension(strTableFullPath);
                    // 테이블이 이미 생성되어 있으면 생성 쿼리문 건너뜀
                    bool bExistence = new bool();
                    if (false == HLGetTableExistence(m_strTableName, ref bExistence))
                    {
                        break;
                    }
                    if (false == bExistence)
                    {
                        // 테이블 생성
                        DataTable objDataTable = new DataTable();
                        // .csv 파일은 읽지 않는 걸로 수정
                        if (".txt" == strTableExtendOnly.ToLower())
                        {
                            objDataTable = objTxtFile.GetDataTableFromTxt(string.Format(@"{0}\{1}", strTablePathOnly, strTableExtendName), true);
                        }
                        else
                        {
                            string strThrowLog = string.Format("CManagerTable HLInitialize There is no {0} file.", strTableExtendName);
                            throw new System.ArgumentException(strThrowLog);
                        }
                        if (false == HLSetTableCreate(m_strTableName, objDataTable))
                        {
                            break;
                        }
                    }
                    // 테이블 스키마 정보 얻음
                    DataTable objSchemaInfo = new DataTable();
                    if (false == HLGetTableInformation(m_strTableName, ref objSchemaInfo))
                    {
                        break;
                    }
                    // 테이블 스키마 에트리뷰트 이름, 타입 가져옴
                    DataRow[] objSchemaInfoRow = objSchemaInfo.Select();
                    m_strTableSchemaName = new string[objSchemaInfoRow.Length];
                    m_strTableSchemaType = new string[objSchemaInfoRow.Length];
                    for (int iLoopRow = 0; iLoopRow < objSchemaInfoRow.Length; iLoopRow++)
                    {
                        m_strTableSchemaName[iLoopRow] = objSchemaInfoRow[iLoopRow].ItemArray[( int )enumSchemaInfo.SCHEMA_INFO_NAME].ToString();
                        m_strTableSchemaType[iLoopRow] = objSchemaInfoRow[iLoopRow].ItemArray[( int )enumSchemaInfo.SCHEMA_INFO_TYPE].ToString();
                        // pk에 해당하는 row값 저장
                        if ("1" == objSchemaInfoRow[iLoopRow].ItemArray[( int )enumSchemaInfo.SCHEMA_INFO_PK].ToString())
                        {
                            m_iPkIndex = iLoopRow;
                        }
                    }
                    // 레코드 파일이 있으면 레코드 INSERT 쿼리문 실행
                    if (null != strRecordFullPath && "" != strRecordFullPath)
                    {
                        // 이름 제외한 폴더 경로
                        string strRecordPathOnly = Path.GetDirectoryName(strRecordFullPath);
                        // 파일 이름 (확장자를 포함)
                        string strRecordExtendName = Path.GetFileName(strRecordFullPath);
                        // 확장자를 제거한 파일 이름
                        string strRecordName = Path.GetFileNameWithoutExtension(strRecordFullPath);
                        // 확장자
                        string strRecordExtendOnly = Path.GetExtension(strRecordFullPath);
                        // 레코드 데이터 밀어넣기 전에 테이블에 데이터 삭제
                        if (false == HLSetTableDataDelete(m_strTableName))
                        {
                            break;
                        }
                        // 테이블에 레코드 삽입
                        DataTable objDataTable = new DataTable();
                        // .csv 파일은 읽지 않는 걸로 수정
                        if (".txt" == strRecordExtendOnly.ToLower())
                        {
                            objDataTable = objTxtFile.GetDataTableFromTxt(string.Format(@"{0}\{1}", strRecordPathOnly, strRecordExtendName), true);
                        }
                        else
                        {
                            string strThrowLog = string.Format("CManagerTable HLInitialize There is no {0} file.", strTableExtendName);
                            throw new System.ArgumentException(strThrowLog);
                        }
                        if (false == HLSetTableDataInsert(m_strTableName, objDataTable))
                        {
                            break;
                        }
                    }
                    // 해당 테이블에 전체 Select 결과를 저장
                    string strQuery = string.Format("select * from {0}", m_strTableName);
                    m_objDataTable = new DataTable();
                    m_objSQLite.HLReload(strQuery, ref m_objDataTable);
                }
                catch (Exception ex) {
                    Trace.WriteLine(ex.Message);
                }

                bReturn = true;
            } while(false);

            return(bReturn);
        }