示例#1
0
 public tableListWord(tableList t)
 {
     this.name   = t.getName();
     this.rows   = t.getRows();
     this.header = t.getHeader();
     this.merge  = t.getMerge();
     //this.circleIndex = t.circleIndex;
 }
示例#2
0
        public tableListWord(tableList t, int[] indexField)
        {
            this.name   = t.getName();
            this.header = t.getHeader();

            header = new string[indexField.Length];     // exception null or 0 element.
            string[] htmp = t.getHeader();

            // clone header
            for (int i = 0; i < indexField.Length; i++)
            {
                if (indexField[i] < htmp.Length)
                {
                    header[i] = htmp[indexField[i]];
                }
                else
                {
                    header[i] = "";
                }
            }

            // clone rows
            for (int i = 0; i < t.getRowNumber(); i++)
            {
                object[] tmps1 = t.getRow(i);
                object[] tmps2 = new object[indexField.Length]; // exception null or 0 element.
                for (int j = 0; j < indexField.Length; j++)
                {
                    if (indexField[j] < htmp.Length)
                    {
                        tmps2[j] = tmps1[indexField[j]];
                    }
                    else
                    {
                        tmps2[j] = "";
                    }
                }
                addRow(tmps2);
            }

            //this.circleIndex = t.circleIndex;
        }
示例#3
0
        public object translate(string text, string mode, SetOfTableList tables)
        { /* please check undefined case */
          //String ans = "";

            /* mode case */
            if (mode.Equals("s") || mode.Equals("p"))
            {
                /* get table name */
                int i = 0;
                int k = 3;
                while (i < text.Length && k != 0)
                {
                    if (text[i] == '@')
                    {
                        k--;
                    }
                    i++;
                }
                if (i == text.Length)
                {
                    return(null);
                }
                string tableName = text.Substring(0, i - 1);
                /* get key */
                int j = i;
                k = 1;
                while (i < text.Length && k != 0)
                {
                    if (text[i] == '@')
                    {
                        k--;
                    }
                    i++;
                }
                string key = text.Substring(j, i - j - 1);  //fixed

                /* get indexField */

                /*j = i;
                 * k = 1;
                 * while (i < text.length() && k != 0) {
                 *  if (text.charAt(i) == '@') {
                 *      k--;
                 *  }
                 *  i++;
                 * }*/
                int indexField = int.Parse(text.Substring(i));  /// may use tryParse

                tableList table = tables.getTableList(tableName);
                if (table != null)
                {
                    if (mode.Equals("s"))
                    {
                        return(table.searchField(key, indexField));
                    }
                    else if (mode.Equals("p"))
                    {
                        return(table.searchPrefixField(key, indexField));
                    }
                }
            }
            else if (mode.Equals("T"))  //////////////////////////////////////////////////////////////////////////
            {
                /* get table name */
                int i = 0;
                int k = 3;
                while (i < text.Length && k != 0)
                {
                    if (text[i] == '@')
                    {
                        k--;
                    }
                    i++;
                }
                if (i == text.Length)
                {
                    return(null);
                }
                string tableName = text.Substring(0, i - 1);
                /* get a sequence of column */
                int j = i;
                k = 1;
                int c = 0;
                while (i < text.Length && k != 0)
                {
                    if (text[i] == '@')
                    {
                        k--;
                    }
                    else if (text[i] == '-')
                    {
                        c++;
                    }
                    i++;
                }
                int[]    col      = new int[c + 1];
                string[] header   = new string[c + 1];
                string[] colWidth = null;
                string   strtmp   = text.Substring(j, i - j - 1); //fixed
                c = 0;
                k = 0;
                for (int m = 0; m < strtmp.Length; m++)
                {
                    if (strtmp[m] == '-')
                    {
                        col[c] = int.Parse(strtmp.Substring(k, m - k));     /// may use tryParse fixed//fixed
                        c++;
                        k = m + 1;
                    }
                }
                col[c] = int.Parse(strtmp.Substring(k));    /// may use tryParse

                /* get header */
                ///////////////////////////////////
                j = i;
                k = 1;
                while (i < text.Length && k != 0)
                {
                    if (text[i] == '@')
                    {
                        k--;
                    }
                    i++;
                }
                if (k == 0) // add column width
                {
                    strtmp = text.Substring(j, i - j - 1);

                    colWidth = new string[header.Length];
                    c        = 0;
                    k        = 0;
                    string strtmp2 = text.Substring(i);
                    for (int m = 0; m < strtmp2.Length; m++)
                    {
                        if (strtmp2[m] == '-')
                        {
                            colWidth[c] = strtmp2.Substring(k, m - k);     //fixed
                            c++;
                            k = m + 1;
                        }
                    }
                    colWidth[c] = strtmp2.Substring(k);
                }
                else
                {
                    strtmp = text.Substring(j);
                }

                ///////////////////////////////////
                c = 0;
                k = 0;
                //strtmp = text.Substring(i);
                for (int m = 0; m < strtmp.Length; m++)
                {
                    if (strtmp[m] == '-')
                    {
                        header[c] = strtmp.Substring(k, m - k);     //fixed
                        c++;
                        k = m + 1;
                    }
                }
                header[c] = strtmp.Substring(k);

                tableList table = tables.getTableList(tableName);
                if (table != null)
                {
                    tableListWord tlwtmp = new tableListWord(table, col);   //// may be also add border
                    tlwtmp.addHeader(header);
                    if (colWidth != null)
                    {
                        tlwtmp.addColWidth(colWidth);
                    }
                    return(tlwtmp);       ////////////////////////////////////// change
                }
            }
            else if (mode.Equals("e"))
            {
                /* get table name */
                int i = 0;
                int k = 3;
                while (i < text.Length && k != 0)
                {
                    if (text[i] == '@')
                    {
                        k--;
                    }
                    i++;
                }
                if (i == text.Length)
                {
                    return(null);
                }
                string tableName = text.Substring(0, i - 1);

                /* get indexField */
                int j = i;
                k = 1;
                while (i < text.Length && k != 0)
                {
                    if (text[i] == '@')
                    {
                        k--;
                    }
                    i++;
                }
                //String acol = text.substring(j, i-1);
                int indexField = int.Parse(text.Substring(j, i - j - 1));   /// may use tryParse//fixed

                /* get a sequence of element */
                j = i;
                k = 1;
                int c = 0;
                while (i < text.Length && k != 0)
                {
                    if (text[i] == '|')
                    {
                        if (i + 1 >= text.Length)
                        {
                            return(null);
                        }
                        else if (text[i + 1] == '|')
                        {
                            i++;
                        }
                        else if (text[i + 1] == '-')
                        {
                            i++;
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else if (text[i] == '@')
                    {
                        k--;
                    }
                    else if (text[i] == '-')
                    {
                        c++;
                    }
                    i++;
                }
                string[] element = new string[c + 1];
                string[] value   = new string[c + 2];
                string   strtmp  = text.Substring(j, i - j - 1); //fixed
                for (int z = 0; z <= c; z++)
                {
                    element[z] = "";
                    value[z]   = "";
                }
                value[c + 1] = "";

                c = 0;
                k = 0;
                for (int m = 0; m < strtmp.Length; m++)
                {
                    if (strtmp[m] == '|')
                    {
                        if (m + 1 >= strtmp.Length)
                        {
                            return(null);
                        }
                        else if (strtmp[m + 1] == '|')
                        {
                            element[c] += strtmp.Substring(k, m - k) + "|";
                            m++;
                            k = m + 1;
                        }
                        else if (strtmp[m + 1] == '-')
                        {
                            element[c] += strtmp.Substring(k, m - k) + "-";
                            m++;
                            k = m + 1;
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else if (strtmp[m] == '-')
                    {
                        element[c] += strtmp.Substring(k, m - k); //fixed
                        c++;
                        k = m + 1;
                    }
                }
                element[c] += strtmp.Substring(k);

                /* get a sequence of value */
                c      = 0;
                k      = 0;
                strtmp = text.Substring(i);
                for (int m = 0; m < strtmp.Length; m++)
                {
                    if (strtmp[m] == '|')
                    {
                        if (m + 1 >= strtmp.Length)
                        {
                            return(null);
                        }
                        else if (strtmp[m + 1] == '|')
                        {
                            value[c] += strtmp.Substring(k, m - k) + "|";
                            m++;
                            k = m + 1;
                        }
                        else if (strtmp[m + 1] == '-')
                        {
                            value[c] += strtmp.Substring(k, m - k) + "-";
                            m++;
                            k = m + 1;
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else if (strtmp[m] == '-')
                    {
                        value[c] += strtmp.Substring(k, m - k);  //fixed
                        c++;
                        k = m + 1;
                    }
                }
                if (c == value.Length - 1)
                { // there is else case
                    value[c] += strtmp.Substring(k);
                }
                else if (c == value.Length - 2)
                { // non else case
                    value[c]    += strtmp.Substring(k);
                    value[c + 1] = "";
                }

                tableList table = tables.getTableList(tableName);
                if (table != null)
                {
                    object[] tmps = table.getRow(0);
                    if (indexField < tmps.Length && tmps[indexField] is string)
                    {
                        for (j = 0; j < element.Length; j++)
                        {
                            if (((string)tmps[indexField]).Equals(element[j]))
                            {
                                return(value[j]);
                            }
                        }
                        return(value[j]);
                    }
                }

                return(null);
            }
            else if (mode.Equals("E"))
            {
                /* get table name */
                int i = 0;
                int k = 3;
                while (i < text.Length && k != 0)
                {
                    if (text[i] == '@')
                    {
                        k--;
                    }
                    i++;
                }
                if (i == text.Length)
                {
                    return(null);
                }
                string tableName = text.Substring(0, i - 1);

                /* get key indexField */
                int j = i;
                k = 1;
                while (i < text.Length && k != 0)
                {
                    if (text[i] == '@')
                    {
                        k--;
                    }
                    i++;
                }
                //String acol = text.substring(j, i-1);
                int keyIndexField = int.Parse(text.Substring(j, i - j - 1));   /// may use tryParse//fixed

                /* get key */
                j = i;
                k = 1;
                while (i < text.Length && k != 0)
                {
                    if (text[i] == '@')
                    {
                        k--;
                    }
                    i++;
                }
                string key = text.Substring(j, i - j - 1);  //fixed

                /* get indexField */
                j = i;
                k = 1;
                while (i < text.Length && k != 0)
                {
                    if (text[i] == '@')
                    {
                        k--;
                    }
                    i++;
                }
                int indexField = int.Parse(text.Substring(j, i - j - 1));   /// may use tryParse//fixed

                /* get a sequence of element */
                j = i;
                k = 1;
                int c = 0;
                while (i < text.Length && k != 0)
                {
                    if (text[i] == '|')
                    {
                        if (i + 1 >= text.Length)
                        {
                            return(null);
                        }
                        else if (text[i + 1] == '|')
                        {
                            i++;
                        }
                        else if (text[i + 1] == '-')
                        {
                            i++;
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else if (text[i] == '@')
                    {
                        k--;
                    }
                    else if (text[i] == '-')
                    {
                        c++;
                    }
                    i++;
                }
                string[] element = new string[c + 1];
                string[] value   = new string[c + 3];
                string   strtmp  = text.Substring(j, i - j - 1); //fixed
                for (int z = 0; z <= c; z++)
                {
                    element[z] = "";
                    value[z]   = "";
                }
                value[c + 1] = "";

                c = 0;
                k = 0;
                for (int m = 0; m < strtmp.Length; m++)
                {
                    if (strtmp[m] == '|')
                    {
                        if (m + 1 >= strtmp.Length)
                        {
                            return(null);
                        }
                        else if (strtmp[m + 1] == '|')
                        {
                            element[c] += strtmp.Substring(k, m - k) + "|";
                            m++;
                            k = m + 1;
                        }
                        else if (strtmp[m + 1] == '-')
                        {
                            element[c] += strtmp.Substring(k, m - k) + "-";
                            m++;
                            k = m + 1;
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else if (strtmp[m] == '-')
                    {
                        element[c] += strtmp.Substring(k, m - k); //fixed
                        c++;
                        k = m + 1;
                    }
                }
                element[c] += strtmp.Substring(k);

                /* get a sequence of value */
                c      = 0;
                k      = 0;
                strtmp = text.Substring(i);
                for (int m = 0; m < strtmp.Length; m++)
                {
                    if (strtmp[m] == '|')
                    {
                        if (m + 1 >= strtmp.Length)
                        {
                            return(null);
                        }
                        else if (strtmp[m + 1] == '|')
                        {
                            value[c] += strtmp.Substring(k, m - k) + "|";
                            m++;
                            k = m + 1;
                        }
                        else if (strtmp[m + 1] == '-')
                        {
                            value[c] += strtmp.Substring(k, m - k) + "-";
                            m++;
                            k = m + 1;
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else if (strtmp[m] == '-')
                    {
                        value[c] += strtmp.Substring(k, m - k);  //fixed
                        c++;
                        k = m + 1;
                    }
                }
                if (c == value.Length - 1)
                { // there is else case
                    value[c] += strtmp.Substring(k);
                }
                else if (c == value.Length - 2)
                { // non else case
                    value[c]    += strtmp.Substring(k);
                    value[c + 1] = "";
                }
                else if (c == value.Length - 3)
                { // non else case
                    value[c]    += strtmp.Substring(k);
                    value[c + 1] = "";
                    value[c + 2] = "";
                }

                tableList table = tables.getTableList(tableName);
                if (table != null)
                {
                    strtmp = (string)table.searchField(keyIndexField, key, indexField);
                    if (strtmp != null)
                    {
                        for (j = 0; j < element.Length; j++)
                        {
                            if (strtmp.Equals(element[j]))
                            {
                                return(value[j]);
                            }
                        }
                        return(value[j]);
                    }
                    else
                    {
                        return(value[value.Length - 1]);
                    }
                }

                return(null);
            }
            else if (mode.Equals("c"))
            {
                /* get table name */
                int i = 0;
                int k = 3;
                while (i < text.Length && k != 0)
                {
                    if (text[i] == '@')
                    {
                        k--;
                    }
                    i++;
                }
                if (i == text.Length)
                {
                    return(null);
                }
                string tableName = text.Substring(0, i - 1);
                /* get indexField */
                int       indexField = int.Parse(text.Substring(i)); /// may use tryParse
                tableList table      = tables.getTableList(tableName);
                if (table != null)
                {
                    object[] tmps = table.getRow(0);
                    if (indexField < tmps.Length && tmps[indexField] is string)
                    {
                        return((string)tmps[indexField]);
                    }
                }
            }
            else if (mode.Equals("x"))
            {
                /* get table name */
                int i = 0;
                int k = 3;
                while (i < text.Length && k != 0)
                {
                    if (text[i] == '@')
                    {
                        k--;
                    }
                    i++;
                }
                if (i == text.Length)
                {
                    return(null);
                }
                string tableName = text.Substring(0, i - 1);
                /* get a sequence of output */
                string[] output = new string[2];
                string   strtmp = text.Substring(i);
                int      c      = 0;
                k = 0;
                for (int m = 0; m < strtmp.Length; m++)
                {
                    if (strtmp[m] == '-')
                    {
                        output[c] = strtmp.Substring(k, m - k); //fixed
                        c++;
                        k = m + 1;
                    }
                }
                output[c] = strtmp.Substring(k);

                tableList table = tables.getTableList(tableName);
                if (table == null)
                {
                    return(output[0]);
                }
                else
                {
                    return(output[1]);
                }
            }
            else if (mode.Equals("X"))
            {
                /* get table name */
                int i = 0;
                int k = 3;
                while (i < text.Length && k != 0)
                {
                    if (text[i] == '@')
                    {
                        k--;
                    }
                    i++;
                }
                if (i == text.Length)
                {
                    return(null);
                }
                string tableName = text.Substring(0, i - 1);
                /* get key */
                int j = i;
                k = 1;
                while (i < text.Length && k != 0)
                {
                    if (text[i] == '@')
                    {
                        k--;
                    }
                    i++;
                }
                string key = text.Substring(j, i - j - 1);  //fixed

                /* get indexField */
                j = i;
                k = 1;
                while (i < text.Length && k != 0)
                {
                    if (text[i] == '@')
                    {
                        k--;
                    }
                    i++;
                }
                int indexField = int.Parse(text.Substring(j, i - j - 1));   /// may use tryParse//fixed

                /* get a sequence of output */
                string[] output = new string[2];
                string   strtmp = text.Substring(i);
                int      c      = 0;
                k = 0;
                for (int m = 0; m < strtmp.Length; m++)
                {
                    if (strtmp[m] == '-')
                    {
                        output[c] = strtmp.Substring(k, m - k); //fixed
                        c++;
                        k = m + 1;
                    }
                }
                output[c] = strtmp.Substring(k);

                tableList table = tables.getTableList(tableName);
                if (table != null)
                {
                    object tmp = table.searchField(indexField, key, indexField);
                    if (tmp != null && tmp is string && key.Equals((string)tmp))
                    {
                        return(output[1]);
                    }
                }
                return(output[0]);
            }

            return(null);
        }
示例#4
0
        }// End of PM configuration

        // Function that set and get Database config file and insert to database.
        public void databaseConfigGen(string projectCode, string quarter)
        {
            string timeStamp = GetTimestamp(DateTime.Now);
            string tempPath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory.ToString(), "TEMP", "DB_" + timeStamp);
            Directory.CreateDirectory(tempPath);
            string fileName = DBConfigUpload.FileName.ToString();
            string filePath = Path.Combine(tempPath, fileName);
            DBConfigUpload.PostedFile.SaveAs(Path.Combine(tempPath, fileName));

            string backupDatabaseFile = BackupDatabaseFile.FileName.ToString();
            string backupDatabaseFilePath = Path.Combine(tempPath, backupDatabaseFile);
            BackupDatabaseFile.PostedFile.SaveAs(Path.Combine(tempPath, backupDatabaseFile));

            string backupControlFile = BackupControlFile.FileName.ToString();
            string backupControlFilePath = Path.Combine(tempPath, backupControlFile);
            BackupControlFile.PostedFile.SaveAs(Path.Combine(tempPath, backupControlFile));

            string backupArcheiveFile = BackupArchieveFile.FileName.ToString();
            string backupArcheiveFilePath = Path.Combine(tempPath, backupArcheiveFile);
            BackupArchieveFile.PostedFile.SaveAs(Path.Combine(tempPath, backupArcheiveFile));
            string backupDBF, backupCFF, backupALF;

            string alertFile = AlertLogFile.FileName.ToString();
            string alertFilePath = Path.Combine(tempPath, alertFile);
            AlertLogFile.PostedFile.SaveAs(Path.Combine(tempPath, alertFile));

            using (TextReader reader = File.OpenText(backupDatabaseFilePath)) {
                backupDBF = reader.ReadToEnd();                
            }

            using (TextReader reader = File.OpenText(backupControlFilePath))
            {
               backupCFF = reader.ReadToEnd();

            }

            using (TextReader reader = File.OpenText(backupArcheiveFilePath))
            {
               backupALF = reader.ReadToEnd();

            }
            dbHelper.InsertBackupDatabase(projectCode, quarter, backupDBF, backupCFF, backupALF);

            string alertLog;
            List<object> alertObj = new List<object>();
            using (TextReader reader = File.OpenText(alertFilePath))
            {
                while ((alertLog = reader.ReadLine()) != null)
                {
                    //if(alertLog.Contains("ora-"))
                       // alertObj.Add(alertLog);
                    dbHelper.InsertAlert(projectCode, quarter, alertLog);
                }
            }

             

            SetOfTableList tables = null;
            OracleInformation oracleInfo = new OracleInformation();

            using (TextReader logFile = File.OpenText(filePath))
            {
                tables = oracleInfo.readInputLog(logFile);
            }
                tableListWord tableWord;
                string binFolderPath = Server.MapPath("bin");
                string path = binFolderPath + "/Debug/config/4_1.txt";

            using (TextReader inFile = File.OpenText(path))
            {
                tableWord = oracleInfo.readOutputTable(inFile, tables);
                List<object[]> database4_1Obj = new List<object[]>();
                for (int k = 0; k < tableWord.getRowNumber(); k++)
                {
                    if (tableWord.getRow(k)[0].Equals("Temp tablespace size"))
                    {
                        object[] obj1 = (object[])tableWord.getRows()[k];
                        tableListWord obj2 = (tableListWord)obj1[1];
                        List<object[]> database4_1_1Obj = new List<object[]>();
                        for (int z = 0; z < obj2.getRows().Count; z++)
                        {
                            object[] subDetail = (object[])obj2.getRows()[z];
                            database4_1_1Obj.Add(new object[] { subDetail[0].ToString(), subDetail[1].ToString()});
                        }
                        dbHelper.InsertTempTableSize(projectCode, quarter, database4_1_1Obj);
                    }
                    else if (tableWord.getRow(k)[0].Equals("Tablespace size"))
                    {
                        object[] obj1 = (object[])tableWord.getRows()[k];
                        tableListWord obj2 = (tableListWord)obj1[1];
                        List<object[]> database4_1_2Obj = new List<object[]>();
                        for (int z = 0; z < obj2.getRows().Count; z++)
                        {
                            object[] subDetail = (object[])obj2.getRows()[z];
                            database4_1_2Obj.Add(new object[] { subDetail[0].ToString(), subDetail[1].ToString() });
                        }
                        dbHelper.InsertTableSize(projectCode, quarter, database4_1_2Obj);
                    }
                    else
                    {
                        database4_1Obj.Add(new object[] { tableWord.getRow(k)[0], tableWord.getRow(k)[1] });
                    }
                }
                dbHelper.InsertDatabaseConfiguration(projectCode, quarter, database4_1Obj);
            }
            path = binFolderPath + "/Debug/config/4_2.txt";
            using (TextReader inFile = File.OpenText(path))
            {
                tableWord = oracleInfo.readOutputTable(inFile, tables);
                List<object[]> database4_2Obj = new List<object[]>();
                for (int k = 0; k < tableWord.getRowNumber(); k++)
                {
                    database4_2Obj.Add(new object[] { tableWord.getRow(k)[0], tableWord.getRow(k)[1] });
                }
                dbHelper.InsertDatabaseParameter(projectCode, quarter, database4_2Obj);
            }   
            tableList tableTmp = null;
            tableTmp = tables.getTableList("4_4@Database file@1");
            if (tableTmp != null)
            {
                List<object[]> databaseFileList = new List<object[]>();
                tableWord = new tableListWord(tableTmp);
                for (int k = 0; k < tableWord.getRowNumber(); k++)
                {
                    databaseFileList.Add(new object[] { tableWord.getRow(k)[0], tableWord.getRow(k)[1], tableWord.getRow(k)[2], tableWord.getRow(k)[3], tableWord.getRow(k)[4], tableWord.getRow(k)[5] });
                }
                dbHelper.InsertDatabaseFile(projectCode, quarter, databaseFileList);
            }

            tableTmp = null;
            tableTmp = tables.getTableList("4_5@Temp file@1");
            if (tableTmp != null)
            {
                List<object[]> tempFileList = new List<object[]>();
                tableWord = new tableListWord(tableTmp);
                for (int k = 0; k < tableWord.getRowNumber(); k++)
                {
                    tempFileList.Add(new object[] { tableWord.getRow(k)[0], tableWord.getRow(k)[1], tableWord.getRow(k)[2], tableWord.getRow(k)[3], tableWord.getRow(k)[4], tableWord.getRow(k)[5] });
                }
                dbHelper.InsertTempFile(projectCode, quarter, tempFileList);
            }

            tableTmp = null;
            tableTmp = tables.getTableList("4_6@Redo log file@1");
            if (tableTmp != null)
            {
                List<object[]> redoLogList = new List<object[]>();
                tableWord = new tableListWord(tableTmp);
                /// Convert B to MB (***warning: available only MB is string that represent integer)
                for (int k = 0; k < tableWord.getRowNumber(); k++)
                {
                    object[] rowTmp = tableWord.getRow(k);
                    if (rowTmp[2] is string)
                    {
                        rowTmp[2] = (float.Parse((string)(rowTmp[2])) / (1024 * 1024)).ToString();
                        redoLogList.Add(new object[] { tableWord.getRow(k)[0], tableWord.getRow(k)[1], rowTmp[2]});
                    }
                    else
                    {
                        redoLogList.Add(new object[] { tableWord.getRow(k)[0], tableWord.getRow(k)[1], tableWord.getRow(k)[2] });
                    }
                }
                dbHelper.InsertRedoLogFile(projectCode, quarter, redoLogList);
            }
            tableTmp = null;
            tableTmp = tables.getTableList("4_7@Controlfile@1");
            if (tableTmp != null)
            {
                List<object> controlFileList = new List<object>();
                tableWord = new tableListWord(tableTmp);
                for (int k = 0; k < tableWord.getRowNumber(); k++)
                {
                    controlFileList.Add(tableWord.getRow(k)[0]);
                }
                dbHelper.InsertControlFile(projectCode, quarter, controlFileList);
            }

            tableTmp = null;
            tableTmp = tables.getTableList("4_8@Jobs@1");
            if (tableTmp != null)
            {
                List<object[]> dailyList = new List<object[]>();
                int[] indexA = { 1024, 3, 1024 };
                tableWord = new tableListWord(tableTmp, indexA);
                for (int k = 0; k < tableWord.getRowNumber(); k++)
                {
                    dailyList.Add(new object[] { tableWord.getRow(k)[0], tableWord.getRow(k)[1], tableWord.getRow(k)[2] });
                }
                dbHelper.InsertDiaryWorksheet(projectCode, quarter, dailyList);
            }
            path = binFolderPath + "/Debug/config/4_9.txt";
            using (TextReader inFile = File.OpenText(path))
            {
                tableWord = oracleInfo.readOutputTable(inFile, tables);
                List<object[]> monthLyList = new List<object[]>();
                for (int k = 0; k < tableWord.getRowNumber(); k++)
                {
                    monthLyList.Add(new object[] { tableWord.getRow(k)[0], tableWord.getRow(k)[1], tableWord.getRow(k)[2] });
                }
                dbHelper.InsertMonthlyWorksheet(projectCode, quarter, monthLyList);
            }

            //////////////////////////////////////////////////////////    O5    ////////////////////////////////////////////////////////// 
            
            path = binFolderPath + "/Debug/config/5_1.txt";
            using (TextReader inFile = File.OpenText(path))
            {
                tableWord = oracleInfo.readOutputTable(inFile, tables);
                List<object[]> performanceReview = new List<object[]>();

                for (int k = 0; k < tableWord.getRowNumber(); k++)
                {
                    if (k == 0)
                    {
                        object[] obj1 = (object[])tableWord.getRows()[k];
                        tableListWord obj2 = (tableListWord)obj1[1];
                        List<object[]> hitRatioList = new List<object[]>();
                        for (int z = 0; z < obj2.getRows().Count; z++)
                        {
                            object[] subDetail = (object[])obj2.getRows()[z];
                            hitRatioList.Add(new object[] {subDetail[0].ToString(), subDetail[1].ToString()});
                        }
                        dbHelper.InsertHitRatio(projectCode, quarter, hitRatioList);
                    }
                    else if (k == 1)
                    {
                        object[] obj1 = (object[])tableWord.getRows()[k];
                        tableListWord obj2 = (tableListWord)obj1[1];
                        List<object[]> pinRatioList = new List<object[]>();
                        for (int z = 0; z < obj2.getRows().Count; z++)
                        {
                            object[] subDetail = (object[])obj2.getRows()[z];
                            pinRatioList.Add(new object[] {subDetail[0].ToString(), subDetail[1].ToString(), subDetail[2].ToString() });
                        }
                        dbHelper.InsertHitRatio(projectCode, quarter, pinRatioList);
                    }
                    else if (k == 14)
                    {
                        object[] obj1 = (object[])tableWord.getRows()[k];
                        tableListWord obj2 = (tableListWord)obj1[1];
                        List<object[]> undoList = new List<object[]>();
                        for (int z = 0; z < obj2.getRows().Count; z++)
                        {
                            object[] subDetail = (object[])obj2.getRows()[z];
                            undoList.Add(new object[] { subDetail[0].ToString(), subDetail[1].ToString(), subDetail[2].ToString() });
                        }
                        dbHelper.InsertUndoSegmentsSize(projectCode, quarter, undoList);
                    }
                    else
                    {
                        performanceReview.Add(new object[] { tableWord.getRow(k)[0], tableWord.getRow(k)[1] });
                    }
                }
                dbHelper.InsertPerformanceReview(projectCode, quarter, performanceReview);
            }

            // Table fress space.
            tableTmp = null;
            tableTmp = tables.getTableList("6_1@Table free space@1");
            if (tableTmp != null)
            {
                tableWord = new tableListWord(tableTmp);
                List<object[]> list = new List<object[]>();
                for (int k = 0; k < tableWord.getRowNumber(); k++)
                {
                    list.Add(new object[] { tableWord.getRow(k)[0], tableWord.getRow(k)[1], tableWord.getRow(k)[2], tableWord.getRow(k)[3], tableWord.getRow(k)[4] });
                }
                dbHelper.InsertTablespaceFreespace(projectCode, quarter, list);
            }

            // Temptable and tablespace
            tableTmp = null;
            tableTmp = tables.getTableList("7_1@default tbs/temp per user@1");
            if (tableTmp != null)
            {
                List<object[]> list = new List<object[]>();
                tableWord = new tableListWord(tableTmp);
                for (int k = 0; k < tableWord.getRowNumber(); k++)
                {
                    list.Add(new object[] { tableWord.getRow(k)[0], tableWord.getRow(k)[1], tableWord.getRow(k)[2]});
                }
                dbHelper.InsertTablespaceAndTempTablespace(projectCode, quarter, list);
            }

            // Database registration Insert.
            tableTmp = null;
            tableTmp = tables.getTableList("8_1@dba registry@1");
            if (tableTmp != null)
            {
                List<object[]> list = new List<object[]>();
                tableWord = new tableListWord(tableTmp);
                for (int k = 0; k < tableWord.getRowNumber(); k++)
                {
                    list.Add(new object[] { tableWord.getRow(k)[0], tableWord.getRow(k)[1], tableWord.getRow(k)[2], tableWord.getRow(k)[3] });
                }
                dbHelper.InsertDatabaseRegistry(projectCode, quarter, list);
            }

            // Growth Rate Insert.
            string currentAllocate, currentUsed, allocateGrowth, useGrowth;
            currentAllocate = currAlloc.Text;
            currentUsed = usedAlloc.Text;
            allocateGrowth = allocGrowth.Text;
            useGrowth = usedGrowth.Text;

            object[] growthRateList = new object[] { currentAllocate, currentUsed, allocateGrowth, useGrowth };
            dbHelper.InsertDatabaseGrowthRate(projectCode, quarter, growthRateList);



            //Delete Folder temp.
            Directory.Delete(tempPath,true);
        }
示例#5
0
 /* return change from bool(java) to int(C#) */
 public int addTableList(tableList t)
 {
     return(tables.Add(t));
 }
示例#6
0
 public bool equals(tableList t)
 {
     //System.out.println (name + "-VS-" + t.getName());
     return(t.getName().Equals(name));
 }
示例#7
0
        public tableList readPerfMon(string path)
        {
            string line = null;
            string strtmp = null, strtmp2 = null;

            string[]  strtmps   = null, strtmps2 = null, fields;
            int[]     charInCol = null;
            char[]    deli1     = new char[] { ',', '"' };
            char[]    deli2     = new char[] { '\\' };
            tableList tableTmp  = null;
            tableList tableTmp2 = null;

            using (TextReader inFile = File.OpenText(Path.Combine(path, @"test.csv")))
            {
                if ((line = inFile.ReadLine()) != null)
                {
                    fields = line.Trim().Split(deli1, StringSplitOptions.RemoveEmptyEntries);

                    decimal[] sum   = new decimal[fields.Length];
                    double[]  min   = new double[fields.Length];
                    double[]  max   = new double[fields.Length];
                    int[]     count = new int[fields.Length];

                    bool hasEmpty = true;
                    while ((line = inFile.ReadLine()) != null && hasEmpty)
                    {
                        strtmps  = line.Trim().Split(deli1, StringSplitOptions.RemoveEmptyEntries);
                        hasEmpty = false;
                        for (int i = 1; i < strtmps.Length; i++)
                        {
                            if (strtmps[i].Trim().Length == 0)
                            {
                                hasEmpty = true;
                                break;
                            }
                        }
                    }
                    if (strtmps != null)
                    {
                        for (int i = 1; i < strtmps.Length; i++)
                        {
                            sum[i]   = decimal.Parse(strtmps[i]);
                            min[i]   = (double)sum[i];
                            max[i]   = min[i];
                            count[i] = 1;
                        }

                        while ((line = inFile.ReadLine()) != null)
                        {
                            strtmps = line.Trim().Split(deli1, StringSplitOptions.RemoveEmptyEntries);
                            for (int i = 1; i < strtmps.Length; i++)
                            {
                                decimal dTmp;
                                if (decimal.TryParse(strtmps[i], out dTmp))
                                {
                                    sum[i] += dTmp;
                                    if ((double)dTmp < min[i])
                                    {
                                        min[i] = (double)dTmp;
                                    }
                                    if ((double)dTmp > max[i])
                                    {
                                        max[i] = (double)dTmp;
                                    }
                                    count[i]++;
                                }
                            }
                        }

                        // create index
                        int[] index = new int[fields.Length];
                        for (int i = 0; i < fields.Length; i++)
                        {
                            index[i] = i;
                        }
                        indexQuickSort(fields, index, 0, fields.Length - 1);

                        tableTmp = new tableList("PM@MSSQL@PerfMon");
                        strtmps  = new string[] { "Performance object", "Counter", "Min", "Max", "Avg." };
                        tableTmp.addHeader(strtmps);

                        strtmp = "";
                        int[] merge = null;
                        for (int i = 1; i < fields.Length; i++)
                        {
                            strtmps  = fields[index[i]].Split(deli2, StringSplitOptions.RemoveEmptyEntries);
                            strtmps2 = new string[5];
                            if (strtmps[1].Equals(strtmp))
                            {
                                strtmps2[0] = "";
                                merge[2]++;
                            }
                            else
                            {
                                if (merge != null && merge[0] != merge[2])
                                {
                                    tableTmp.addMerge(merge);
                                    merge = null;
                                }

                                merge = new int[] { i + 1, 1, i + 1, 1 };
                                //merge = new int[4];// { i + 1, 1, i + 1, 1 };
                                //merge[0] = i + 1;
                                //merge[1] = 1;
                                //merge[2] = i + 1;
                                //merge[3] = 1;
                                strtmps2[0] = strtmps[1];
                                strtmp      = strtmps[1];
                            }
                            strtmps2[1] = strtmps[2];// +merge[0] + " " + merge[1] + " " + merge[2] + " " + merge[3];
                            strtmps2[2] = rearrangeNumber(min[index[i]].ToString("#,##0.###"));
                            strtmps2[3] = rearrangeNumber(max[index[i]].ToString("#,##0.###"));
                            strtmps2[4] = rearrangeNumber((sum[index[i]] / count[index[i]]).ToString("#,##0.###"));

                            tableTmp.addRow(strtmps2);
                        }
                        if (merge != null && merge[0] != merge[2])
                        {
                            tableTmp.addMerge(merge);
                        }

                        return(tableTmp);
                    }
                }
            }

            return(null);
        }
示例#8
0
        public SetOfTableList readInputLog(TextReader reader)
        {
            SetOfTableList tables = new SetOfTableList();
            string         line = null;
            string         topic = null, tableName = null, strtmp = null;

            string[]  strtmps   = null, fields;
            int[]     charInCol = null;
            int       state     = 0;
            int       tableNum  = 0;
            tableList tableTmp  = null;

            /*
             *      reading state
             *	0 = initial
             *  1 = already collect a table name / ready to get header of fields
             *  2 = may be collect header of fields (tmp) / ready to get number of character of fields
             *  3 = already collect charInCol / create a tableList / ready to get rows
             */

            while ((line = reader.ReadLine()) != null)
            {
                int c = checkCase(line);
                if (c == 1)
                {
                    topic = getCenter(line, 3, '#');
                    //System.out.println("case:1(" + topic + ")");
                    state = 0;
                }
                else if (c == 2)
                {
                    tableName = getCenter(line, 3, '-');
                    //System.out.println("case:2(" + tableName + ")");
                    tableNum = 1;
                    state    = 1;
                }
                else if (c == 3)
                {
                    if (state == 3)
                    {
                        //tableTmp.printTable(); // this for check table
                        if (tableTmp != null)
                        {
                            //System.out.println(" %%%%%% tables == null %%%%%");
                            tables.addTableList(tableTmp);
                        }
                    }
                    //System.out.println("case:3");
                    state = 0;
                }
                else
                {
                    //System.out.println(line.trim());
                    if (state == 1)
                    {
                        if (line.Length > 0)
                        {
                            strtmp = line;
                            state  = 2;
                        }
                    }
                    else if (state == 2)
                    {
                        // First, check delimiter between header and rows
                        string s    = line.Trim();
                        bool   deli = true;
                        if (s.Length == 0)
                        {
                            deli = false;
                        }
                        for (int i = 0; i < s.Length && deli; i++)
                        {
                            if (!(s[i] == '-' || s[i] == ' ') || (s[i] == ' ' && s[i - 1] != '-'))
                            {
                                deli = false;
                                //System.out.println ("It's not deli");
                            }
                        }
                        // Then create a header
                        if (deli)
                        {
                            strtmps   = line.Trim().Split(new char[] { ' ' });
                            charInCol = new int[strtmps.Length];
                            fields    = new string[strtmps.Length];
                            int pos = 0;
                            for (int i = 0; i < charInCol.Length; i++)
                            {
                                charInCol[i] = strtmps[i].Length;
                                Debug.WriteLine("Position = " + pos + ", i = " + i + ", Strtmp = " + strtmp);
                                fields[i] = strtmp.Substring(pos, charInCol[i]).Trim(); //fixed
                                pos      += charInCol[i] + 1;
                            }
                            //for (int i = 0; i < charInCol.length; i++) {
                            //	System.out.println(fields[i]);
                            //}
                            //System.out.println(header + "@" + tableName + "@" + tableNum);

                            tableTmp = new tableList(topic + "@" + tableName + "@" + tableNum);
                            tableTmp.addHeader(fields);
                            //tableTmp.printTable();
                            tableNum++;

                            state = 3;
                        }
                        else
                        {
                            if (line.Length > 0)
                            {
                                strtmp = line;
                            }
                            else
                            {
                                state = 1;
                            }
                        }
                    }
                    else if (state == 3)
                    {
                        if (line.Length > 0)
                        {
                            //strtmps = line.trim().split(" ");
                            fields = new string[charInCol.Length];
                            int pos = 0;
                            for (int i = 0; i < charInCol.Length; i++)
                            {
                                fields[i] = rearrangeNumber(line.Substring(pos, charInCol[i]).Trim()); //fixed
                                pos      += charInCol[i] + 1;
                            }
                            // consider to concat with previous?
                            if (fields[0].Equals(""))
                            {
                                for (int i = 1; i < charInCol.Length; i++)
                                {
                                    if (!fields[i].Equals(""))
                                    {
                                        strtmps[i] += (fields[i].Trim());
                                        pos        += charInCol[i] + 1;
                                    }
                                }
                            }
                            else
                            {
                                strtmps = fields;
                                tableTmp.addRow(fields); ////////////////////////////////////////////////////////////////////////////////////////////////////////
                            }
                        }
                        else
                        {
                            //tableTmp.printTable(); // this for check table
                            if (tableTmp != null)
                            {
                                //System.out.println(" %%%%%% tables == null %%%%%");
                                tables.addTableList(tableTmp);
                            }
                            state = 1;
                        }
                    }
                }
            }
            return(tables);
        }