コード例 #1
0
        }     //processFile

        /// ////////////////////////////////////////////////////////////////////
        /// <summary>
        /// ////////////////////////////////////////////////////////////////////
        /// </summary>
        /// <param name="strDataSrcFile"></param>
        private EProcessFileType _CheckProcessFileType(System.String strDataSrcFile, DataProcessParam pDataProcessParam)
        {
            bool bCheckExtensionHCCpp = false;
            bool bCheckFileContainKey = false;

            EProcessFileType nEProcessFileType = EProcessFileType.EProcessFileType_DoNothing;

            //check extension  .h .c .cpp
            bCheckExtensionHCCpp = false;
            m_FileSystemCheckExtension.reSetFullPath(strDataSrcFile);
            bCheckExtensionHCCpp = m_FileSystemCheckExtension.checkExtenion_h_c_cpp();
            if (false == bCheckExtensionHCCpp)
            {
                nEProcessFileType = EProcessFileType.EProcessFileType_Copy;
                return(nEProcessFileType);
            }

            //check file contain Key
            bCheckFileContainKey = false;
            m_FileSystemCheckContainKey.reSetFullPath(strDataSrcFile);
            bCheckFileContainKey = m_FileSystemCheckContainKey.checkContainKey(pDataProcessParam);
            if (false == bCheckFileContainKey)
            {
                nEProcessFileType = EProcessFileType.EProcessFileType_Copy;
                return(nEProcessFileType);
            }

            //need process
            nEProcessFileType = EProcessFileType.EProcessFileType_ChangeCodeInfile;
            return(nEProcessFileType);
        } //processFile
コード例 #2
0
        }//button_DoWork_Click

        private void BackgroundWorkerAnalystFile_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            Boolean bProcessSubDir = true;

            MessageBox.Show("begin work");

            log4net.LogManager.GetLogger("ExeLogger").Info(System.String.Format("begin work"));


            DataProcessParam pDataProcessParam = null;

            pDataProcessParam = new DataProcessParam();
            pDataProcessParam.m_strStringSrc    = this.m_strStringSrc;
            pDataProcessParam.m_strStringDest   = this.m_strStringDest;
            pDataProcessParam.m_strDataSrcPath  = this.m_strDataSrcPath;
            pDataProcessParam.m_strDataDestPath = this.m_strDataDestPath;

            //CreateDirectory DstLogPath
            m_FileSYstemFolder.createDirectory(this.m_strDataDestPath);
            //this.m_strDataSrcPath = this.textBox_Path.Text;
            processFilesInPath(this.m_strDataSrcPath, this.m_strDataDestPath, bProcessSubDir, pDataProcessParam);

            log4net.LogManager.GetLogger("ExeLogger").Info(System.String.Format("end work!"));

            MessageBox.Show("end work!");
        }//BackgroundWorkerAnalystFile_DoWork
コード例 #3
0
        public System.String processLine(System.String strLine, DataProcessParam pDataProcessParam)
        {
            System.String    strDestLine;
            ECheckContainKey nECheckContainKey;

            strDestLine = strLine;

            nECheckContainKey = ECheckContainKey.ECheckContainKey_NoKey;
            m_LineCheckContainKey.setLine(strDestLine);
            nECheckContainKey = m_LineCheckContainKey.checkContainKeyType(pDataProcessParam);

            while (true)
            {
                strDestLine = _ProcessLineByType(strDestLine, nECheckContainKey, pDataProcessParam);

                nECheckContainKey = ECheckContainKey.ECheckContainKey_NoKey;
                m_LineCheckContainKey.setLine(strDestLine);
                nECheckContainKey = m_LineCheckContainKey.checkContainKeyType(pDataProcessParam);
                if (ECheckContainKey.ECheckContainKey_NoKey == nECheckContainKey)
                {
                    break;//while
                }
            }

            return(strDestLine);
        }
コード例 #4
0
 // Copy constructor.
 public DataProcessParam(DataProcessParam previousObject)
 {
     this.m_strStringSrc    = previousObject.m_strStringSrc;
     this.m_strStringDest   = previousObject.m_strStringDest;
     this.m_strDataSrcPath  = previousObject.m_strDataSrcPath;
     this.m_strDataDestPath = previousObject.m_strDataDestPath;
 }
コード例 #5
0
        public System.Boolean checkContainKey(DataProcessParam pDataProcessParam)
        {
            System.Boolean         bCheckRes      = false;
            System.IO.StreamReader fileReadHander = null;

            //System.IO.FileInfo fileinfo = new System.IO.FileInfo(strDataSrcFile);

            fileReadHander = new System.IO.StreamReader(m_strFullPath);

            System.String strGetLineSrc = System.String.Empty;
            // Read and display lines from the file until the end of
            // the file is reached.
            while ((strGetLineSrc = fileReadHander.ReadLine()) != null)
            {
                //check each line
                m_LineCheckContainKey.reSetLine(strGetLineSrc);
                bCheckRes = m_LineCheckContainKey.checkContainKey(pDataProcessParam);

                if (bCheckRes)
                {
                    break;
                }
            }

            fileReadHander.Close();

            return(bCheckRes);
        }
コード例 #6
0
        public ECheckContainKey checkContainKeyType(DataProcessParam pDataProcessParam)
        {
            ECheckContainKey nECheckContainKey = ECheckContainKey.ECheckContainKey_NoKey;

            System.Int32 nIndexOfValue = -1;

            nECheckContainKey = ECheckContainKey.ECheckContainKey_NoKey;

            nIndexOfValue = m_strLine.IndexOf(pDataProcessParam.m_strStringSrc);
            if (-1 != nIndexOfValue)
            {
                nECheckContainKey = ECheckContainKey.ECheckContainKey_HaveKey;
                return(nECheckContainKey);
            }

            return(nECheckContainKey);
        }
コード例 #7
0
        public System.Boolean checkContainKey(DataProcessParam pDataProcessParam)
        {
            System.Boolean bCheckRes = false;

            bCheckRes = false;
            if (m_strLine.Length <= 0)
            {
                return(bCheckRes);
            }
            //m_strLine = m_strLine.ToLower();

            m_nECheckContainKey = ECheckContainKey.ECheckContainKey_NoKey;
            m_nECheckContainKey = checkContainKeyType(pDataProcessParam);

            if (ECheckContainKey.ECheckContainKey_HaveKey == m_nECheckContainKey)
            {
                bCheckRes = true;
            }

            return(bCheckRes);
        }
コード例 #8
0
        public void _ProcessEachLine(System.String strLineSrc, System.IO.StreamWriter fileWriterHander, DataProcessParam pDataProcessParam)
        {
            System.Boolean   bCheckContainKey = false;
            System.String    strLineDest      = System.String.Empty;
            EProcessLineType nProcessLineType = EProcessLineType.EProcessLineType_Copy;

            //log4net.LogManager.GetLogger("ExeLogger").Info(System.String.Format("_ProcessEachLine {0}", strLineSrc));

            bCheckContainKey = false;
            m_LineCheckContainKey.reSetLine(strLineSrc);
            bCheckContainKey = m_LineCheckContainKey.checkContainKey(pDataProcessParam);
            if (bCheckContainKey)
            {
                nProcessLineType = EProcessLineType.EProcessLineType_ChangeCode;
            }

            switch (nProcessLineType)
            {
            case EProcessLineType.EProcessLineType_Copy:
            {
                strLineDest = strLineSrc;
                fileWriterHander.WriteLine(strLineDest);
                break;
            }

            case EProcessLineType.EProcessLineType_ChangeCode:
            {
                //process
                strLineDest  = "//";
                strLineDest += strLineSrc;
                fileWriterHander.WriteLine(strLineDest);

                strLineDest = strLineSrc;
                strLineDest = m_processLineLongToInt32.processLine(strLineSrc, pDataProcessParam);
                fileWriterHander.WriteLine(strLineDest);
                break;
            }

            default:
            {
                //copy
                fileWriterHander.WriteLine(strLineSrc);
                break;
            }
            }//switch

            return;
        }
コード例 #9
0
        public void processFile(System.String strDataSrcFile, System.String strDataDestFile, DataProcessParam pDataProcessParam)
        {
            System.IO.StreamReader fileReadHander   = null;
            System.IO.StreamWriter fileWriterHander = null;

            m_strDataSrcFile  = strDataSrcFile;
            m_strDataDestFile = strDataDestFile;

            //System.IO.FileInfo fileinfo = new System.IO.FileInfo(strDataSrcFile);
            fileReadHander   = new System.IO.StreamReader(strDataSrcFile);
            fileWriterHander = new System.IO.StreamWriter(strDataDestFile);

            System.String strGetLineSrc = System.String.Empty;
            // Read and display lines from the file until the end of
            // the file is reached.
            while ((strGetLineSrc = fileReadHander.ReadLine()) != null)
            {
                _ProcessEachLine(strGetLineSrc, fileWriterHander, pDataProcessParam);
            }//end while

            fileReadHander.Close();
            fileWriterHander.Close();
        }
コード例 #10
0
        }//processFilesInPath

        public void processFile(System.String strDataSrcFile, System.String strDataDestFile, DataProcessParam pDataProcessParam)
        {
            //m_processFileCopy.processFile(strDataSrcFile, strDataDestFile);
            m_ProcessFileChangCodeInfile.processFile(strDataSrcFile, strDataDestFile, pDataProcessParam);
        }//processFile
コード例 #11
0
        }//BackgroundWorkerAnalystFile_RunWorkerCompleted

        //===============================================================
        public void processFilesInPath(System.String strDataSrcPath, System.String strDataDestPath, Boolean bProcessSubDir, DataProcessParam pDataProcessParam)
        {
            System.IO.DirectoryInfo dirInfoSrcPath;
            FileInfo[] filelist = null;

            dirInfoSrcPath = new System.IO.DirectoryInfo(strDataSrcPath);
            //bDataSrcPathExists = System.IO.Directory.Exists(strDataSrcPath);
            if (false == dirInfoSrcPath.Exists)
            {
                log4net.LogManager.GetLogger("ExeLogger").Error(System.String.Format("error! processFilesInPath  DataSrcPath not Exists"));
                //MessageBox.Show("error! processFilesInPath  DataSrcPath not Exists");
                //System.String strLog = String.Format("Error: That path not exists  strPath ={0}", strPath);
                return;
            }


            m_FileSYstemFolder.createDirectory(strDataDestPath);

            filelist = dirInfoSrcPath.GetFiles("*.*");//"*.log"

            foreach (FileInfo item in filelist)
            {
                System.String strSrcFullName  = item.FullName;
                System.String strSrcFileName  = item.Name;
                System.String strDestFileName = System.String.Empty;
                strDestFileName = System.IO.Path.Combine(strDataDestPath, strSrcFileName);

                processFile(strSrcFullName, strDestFileName, pDataProcessParam);
            }


            if (bProcessSubDir)
            {
                foreach (DirectoryInfo subDi in dirInfoSrcPath.GetDirectories())
                {
                    System.String strDataSrcSubPath  = System.String.Empty;
                    System.String strDataDestSubPath = System.String.Empty;

                    strDataSrcSubPath  = subDi.FullName;
                    strDataDestSubPath = System.IO.Path.Combine(strDataDestPath, subDi.Name);

                    processFilesInPath(strDataSrcSubPath, strDataDestSubPath, bProcessSubDir, pDataProcessParam);
                }
            }
        }//processFilesInPath
コード例 #12
0
        public void processFile(System.String strDataSrcFile, System.String strDataDestFile, DataProcessParam pDataProcessParam)
        {
            m_nEProcessFileType = _CheckProcessFileType(strDataSrcFile, pDataProcessParam);


//             {
//                 System.Diagnostics.StackTrace StackTraceTmp = new System.Diagnostics.StackTrace(true);
//                 System.Diagnostics.StackFrame StackFrameTmp = StackTraceTmp.GetFrame(0);
//                 NLog.LogManager.GetCurrentClassLogger().Info(" {0}:{1} {2} {3}", StackFrameTmp.GetFileName(), StackFrameTmp.GetFileLineNumber(),
//                     "processFile ", strDataSrcFile);
//             }


            switch (m_nEProcessFileType)
            {
            case EProcessFileType.EProcessFileType_ChangeCodeInfile:
                log4net.LogManager.GetLogger("ExeLogger").Info(System.String.Format("EProcessFileType_ChangeCodeInfile {0}", strDataSrcFile));
                m_processFileLongToInt32.processFile(strDataSrcFile, strDataDestFile, pDataProcessParam);
                break;

            default:
                m_processFileCopy.processFile(strDataSrcFile, strDataDestFile);
                break;
            } //switch
        }     //processFile
コード例 #13
0
        private System.String _ProcessLineByType(System.String strLine, ECheckContainKey nECheckContainKey, DataProcessParam pDataProcessParam)
        {
            System.String strDestLine;
            System.String strOldValueForReplace;
            System.String strNewValueForReplace;


            switch (nECheckContainKey)
            {
            case ECheckContainKey.ECheckContainKey_NoKey:
                strDestLine = strLine;
                break;

            case ECheckContainKey.ECheckContainKey_HaveKey:
                strOldValueForReplace = pDataProcessParam.m_strStringSrc;
                strNewValueForReplace = pDataProcessParam.m_strStringDest;
                strDestLine           = _Process_ECheckContainKey(strLine, strOldValueForReplace, strNewValueForReplace);
                break;

            default:
                strDestLine = strLine;
                break;
            }

            return(strDestLine);
        }