Beispiel #1
0
        public void MyClass_Parse_And_Report4(string inputLog, string outputTxt)
        {
            // log 포맷 시간(19)#타입(2)#메시지코드(9)
            // 입력받은 text log 파일을 열어, #으로 split 한 후 각 type 별로 분리하고 카운팅한 결과를 output text에 저장
            MyClass_Files_Reader srcFile  = new MyClass_Files_Reader(inputLog);
            MyClass_Strings      strClass = new MyClass_Strings();
            string res = srcFile.readLine();             // 1 line read

            string[] line = srcFile.readLines(inputLog); // read all lines
            int      num  = line.Count();                // total count

#if DEBUG_PRINT_ENABLE
            MyClass_Dprint.debugPrint("read lines:" + num);
#endif
            int            typeCount = strClass.countingAllTypes(line, delimiter, 1);
            string[]       logTypes  = strClass.getAllTypes(line, delimiter, 1);
            MyClass_Thread myThread  = new MyClass_Thread();
            // Example #4: Append new text to an existing file.
            // The using statement automatically flushes AND CLOSES the stream and calls
            // IDisposable.Dispose on the stream object.
            using (System.IO.StreamWriter outFile = new System.IO.StreamWriter(outputTxt, false))
            {
                foreach (string s in logTypes)
                {
                    //string[] data = strClass.StringSplit(s, delimiter);
                    int cnt = strClass.getCountOfType(line, delimiter, 1, s);
                    // 타입별 출력 파일 생성
                    MyClass_Files_Writer fileWriter = new MyClass_Files_Writer("TYPELOG_4_" + s + ".TXT");
                    // file writer 클래스에 thread safty하도록 lock 추가. (여러 thread에서 동시에 write의 경우 처리)


                    string[] strResult = strClass.getLinesOfType(line, delimiter, 1, s);// 입력된 타입에 해당되는 로그 만 추출한다.
                    foreach (string _line in strResult)
                    {
                        // 이부분 multi thread로 바꾼다.
#if DEBUG_PRINT_ENABLE
                        MyClass_Dprint.debugPrint("type: " + s);
                        MyClass_Dprint.debugPrint("line: " + _line);
#endif
                        myThread.StartConvertAndWrite(fileWriter, _line, delimiter, 2);
                    }
#if DEBUG_PRINT_ENABLE
                    MyClass_Dprint.debugPrint("type:" + s + " total num:" + cnt);
#endif
                    outFile.WriteLine(s + "#" + cnt);
                }
            }
        }
Beispiel #2
0
        public void MyClass_Parse_And_Report3(string inputLog, string outputTxt)
        {
            // log 포맷 시간(19)#타입(2)#메시지코드(9)
            // 입력받은 text log 파일을 열어, #으로 split 한 후 각 type 별로 분리하고 카운팅한 결과를 output text에 저장
            MyClass_Files_Reader srcFile  = new MyClass_Files_Reader(inputLog);
            MyClass_Strings      strClass = new MyClass_Strings();
            string res = srcFile.readLine();             // 1 line read

            string[] line = srcFile.readLines(inputLog); // read all lines
            int      num  = line.Count();                // total count

#if DEBUG_PRINT_ENABLE
            MyClass_Dprint.debugPrint("read lines:" + num);
#endif
            int            typeCount = strClass.countingAllTypes(line, delimiter, 1);
            string[]       logTypes  = strClass.getAllTypes(line, delimiter, 1);
            MyClass_Thread myThread  = new MyClass_Thread();
            // Example #4: Append new text to an existing file.
            // The using statement automatically flushes AND CLOSES the stream and calls
            // IDisposable.Dispose on the stream object.
            using (System.IO.StreamWriter outFile =
                       new System.IO.StreamWriter(outputTxt, false))
            {
                foreach (string s in logTypes)
                {
                    //string[] data = strClass.StringSplit(s, delimiter);
                    int cnt = strClass.getCountOfType(line, delimiter, 1, s);

                    string[] strResult = strClass.getLinesOfType(line, delimiter, 1, s);// 타입별 로그를 추출한다.
                    foreach (string _line in strResult)
                    {
                        // convert and write to file
                        using (System.IO.StreamWriter file = new System.IO.StreamWriter("TYPELOG_3_" + s + ".TXT", false))
                        {
                            string convertedStr = strClass.convertStringMsg(_line, delimiter, 2);
                            {
                                file.WriteLine(convertedStr);
                            }
                        }
                    }
#if DEBUG_PRINT_ENABLE
                    MyClass_Dprint.debugPrint("type:" + s + " total num:" + cnt);
#endif
                    outFile.WriteLine(s + "#" + cnt);
                }
            }
        }
Beispiel #3
0
        public void MyClass_Parse_And_Report2(string inputLog, string outputTxt)
        {
            // log 포맷 시간(19)#타입(2)#메시지코드(9)
            // 입력받은 text log 파일을 열어, #으로 split 한 후 각 type 별로 분리하고 카운팅한 결과를 output text에 저장
            MyClass_Files_Reader srcFile  = new MyClass_Files_Reader(inputLog);
            MyClass_Strings      strClass = new MyClass_Strings();
            string res = srcFile.readLine();             // 1 line read

            string[] line = srcFile.readLines(inputLog); // read all lines
            int      num  = line.Count();                // total count

#if DEBUG_PRINT_ENABLE
            MyClass_Dprint.debugPrint("read lines:" + num);
#endif
            int      typeCount = strClass.countingAllTypes(line, delimiter, 1);
            string[] logTypes  = strClass.getAllTypes(line, delimiter, 1);

            // Example #4: Append new text to an existing file.
            // The using statement automatically flushes AND CLOSES the stream and calls
            // IDisposable.Dispose on the stream object.
            using (System.IO.StreamWriter outFile =
                       new System.IO.StreamWriter(outputTxt, true))
            {
                //outFile.WriteLine("Fourth line");
                // scan types
                foreach (string s in logTypes)
                {
                    //string[] data = strClass.StringSplit(s, delimiter);
                    int cnt = strClass.getCountOfType(line, delimiter, 1, s);
#if DEBUG_PRINT_ENABLE
                    MyClass_Dprint.debugPrint("type:" + s + " total num:" + cnt);
#endif
                    outFile.WriteLine(s + "#" + cnt);
                }
            }
        }