Exemple #1
0
        public void InitialColumn(string path, string iniFilename)
        {
            IniFileName INI;
            var         FolderPah = path + "\\" + iniFilename + ".ini";

            INI = new INI.IniFileName(FolderPah);
            if (!File.Exists(FolderPah))
            {
                if (iniFilename == "OA")
                {
                    INI.IniWriteValue("ColumnName", "Column1", "ChName");
                    INI.IniWriteValue("ColumnName", "Column2", "AnaName");
                    INI.IniWriteValue("ColumnName", "Column3", "OAvalue");
                    INI.IniWriteValue("ColumnName", "Column4", "Unit");
                    INI.IniWriteValue("ColumnName", "Column5", "StartBand");
                    INI.IniWriteValue("ColumnName", "Column6", "EndBand");
                    INI.IniWriteValue("ColumnName", "Column7", "Warning");
                    INI.IniWriteValue("ColumnName", "Column8", "Alarm");
                    INI.IniWriteValue("ColumnName", "Column9", "Datadate");
                    INI.IniWriteValue("ColumnType", "Type1", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type2", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type3", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type4", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type5", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type6", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type7", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type8", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type9", "date");
                }
                if (iniFilename == "UI")
                {
                    INI.IniWriteValue("ColumnName", "Column1", "RowCh0");
                    INI.IniWriteValue("ColumnName", "Column2", "RowCh1");
                    INI.IniWriteValue("ColumnName", "Column3", "RowCh2");
                    INI.IniWriteValue("ColumnName", "Column4", "RowCh3");
                    INI.IniWriteValue("ColumnName", "Column5", "FFTCh0");
                    INI.IniWriteValue("ColumnName", "Column6", "FFTCh1");
                    INI.IniWriteValue("ColumnName", "Column7", "FFTCh2");
                    INI.IniWriteValue("ColumnName", "Column8", "FFTCh3");
                    INI.IniWriteValue("ColumnName", "Column9", "NormalDataRecord");
                    INI.IniWriteValue("ColumnName", "Column10", "TextDataRecord");
                    INI.IniWriteValue("ColumnName", "Column11", "NormalSechedule");
                    INI.IniWriteValue("ColumnName", "Column12", "NormalAverages");
                    INI.IniWriteValue("ColumnName", "Column13", "DDS");
                    INI.IniWriteValue("ColumnName", "Column14", "HDSpaces");
                    INI.IniWriteValue("ColumnName", "Column15", "BandWidth");
                    INI.IniWriteValue("ColumnName", "Column16", "Resolution");
                    INI.IniWriteValue("ColumnType", "Type1", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type2", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type3", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type4", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type5", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type6", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type7", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type8", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type9", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type10", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type11", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type12", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type13", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type14", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type15", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type16", "VARCHAR");
                }
                if (iniFilename == "Channel")
                {
                    INI.IniWriteValue("ColumnName", "Column1", "Channe1Number");
                    INI.IniWriteValue("ColumnName", "Column2", "ChannelEnable");
                    INI.IniWriteValue("ColumnName", "Column3", "ChannelType");
                    INI.IniWriteValue("ColumnName", "Column4", "ChannelSense");
                    INI.IniWriteValue("ColumnName", "Column5", "ChannelHPFilter");
                    INI.IniWriteValue("ColumnName", "Column6", "ChannelMode");
                    INI.IniWriteValue("ColumnType", "Type1", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type2", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type3", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type4", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type5", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type6", "VARCHAR");
                }
                if (iniFilename == "Monitor")
                {
                    INI.IniWriteValue("ColumnName", "Column1", "OATableName");
                    INI.IniWriteValue("ColumnName", "Column2", "MonitorName");
                    INI.IniWriteValue("ColumnName", "Column3", "MonitorUnit");
                    INI.IniWriteValue("ColumnName", "Column4", "MonitorStartFreq");
                    INI.IniWriteValue("ColumnName", "Column5", "MonitorEndFreq");
                    INI.IniWriteValue("ColumnName", "Column6", "MonitorWarning");
                    INI.IniWriteValue("ColumnName", "Column7", "MonitorAlarm");
                    INI.IniWriteValue("ColumnType", "Type1", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type2", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type3", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type4", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type5", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type6", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type6", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type7", "VARCHAR");
                }
                if (iniFilename == "OAName")
                {
                    INI.IniWriteValue("ColumnName", "Column1", "OAName");
                    INI.IniWriteValue("ColumnType", "Type1", "VARCHAR");
                }
                if (iniFilename == "AlarmLog")
                {
                    INI.IniWriteValue("ColumnName", "Column1", "AlarmMessage");
                    INI.IniWriteValue("ColumnName", "Column2", "Datadate");
                    INI.IniWriteValue("ColumnType", "Type1", "VARCHAR");
                    INI.IniWriteValue("ColumnType", "Type2", "date");
                }
            }

            string[] SectionHeader = INI.GetSectionNames();
            string[] temp1         = new string[INI.GetEntryNames(SectionHeader[0]).Length];
            ColumnNamelist     = new string[INI.GetEntryNames(SectionHeader[0]).Length];
            ColumnNameWithType = new string[INI.GetEntryNames(SectionHeader[0]).Length];
            int Secctionindex, Coulmnindex;

            try
            {
                if (SectionHeader != null)
                {
                    Secctionindex = 0;
                    Coulmnindex   = 0;
                    foreach (string SecHead in SectionHeader)
                    {
                        string[] Entry = INI.GetEntryNames(SecHead);

                        if (Entry != null)
                        {
                            foreach (string EntName in Entry)
                            {
                                temp1[Coulmnindex] = (string)INI.GetEntryValue(SecHead, EntName);
                                if (Secctionindex > 0)
                                {
                                    ColumnNameWithType[Coulmnindex] = ColumnNamelist[Coulmnindex] + " " + temp1[Coulmnindex];
                                }
                                else
                                {
                                    ColumnNamelist[Coulmnindex] = temp1[Coulmnindex];
                                }

                                Coulmnindex++;
                            }
                            Coulmnindex = 0;
                        }
                        Secctionindex++;
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            //	Sets the INI filename and location to be used.
            //	remember to use a double slash "\\" instead of a single for folder levels.
            IniFileName INI      = new INI.IniFileName("C:\\test.ini");
            MCMDataBase database = new MCMDataBase();

            string[] SectionHeader = INI.GetSectionNames();
            string   TableName;

            string[] temp1 = new string[INI.GetEntryNames(SectionHeader[0]).Length];
            string[] temp2 = new string[INI.GetEntryNames(SectionHeader[0]).Length];;
            int      i, j;

            // Use the Try comman to gather the information, if an error occurs then throw an exception.
            // and display the error.
            try
            {
                // set the SectionHeader into an Dynamic Singlelevel Array.
                // the Information is gathered from the GetSectionNames function INI namespace of the ReadINI Class.

                // Checks to see if the SectionHeader has returned null.
                if (SectionHeader != null)
                {
                    // Returns a list EntryKey's for each of the SectionHeader(s).
                    i = 0;
                    j = 0;
                    foreach (string SecHead in SectionHeader)
                    {
                        // Write the SectionHeader to the display.
                        //Console.WriteLine(SecHead);

                        // Sets the Entry Dynamic Array for the each of the EntryKeys within the Section Header.
                        // If you already know the SectionHeader and just need to list the Entry's
                        // then enter the name instead of the SecHead in the GetEntrNames function.
                        // ie.  INI.GetEntryNames("TestSecHead")

                        string[] Entry = INI.GetEntryNames(SecHead);
                        // Checks to see if there's an Entry under the SectionHeader and the Entry has not returned a null
                        if (Entry != null)
                        {
                            // Enumerates a list of Keys For each of the Entry.
                            foreach (string EntName in Entry)
                            {
                                // writes to display the value for the Entry key.
                                // If you already know the SectionHeader and the Entry Key values then, replace all the code
                                // after the INIFileName line, with the following
                                // Console.WriteLine(" {0} = {1}","TestKey",INI.GetEntryValue("TestSecHead","TestKey"));
                                // this will display the Value for the Entry key under the given SectionHeader.

                                //Console.WriteLine(" {0} = {1}",EntName,INI.GetEntryValue(SecHead,EntName));
                                temp1[j] = (string)INI.GetEntryValue(SecHead, EntName);
                                if (i > 0)
                                {
                                    temp2[j] = temp2[j] + " " + temp1[j];
                                    Console.WriteLine(temp2[j]);
                                }
                                else
                                {
                                    temp2[j] = temp1[j];
                                }

                                j++;
                            }
                            j = 0;
                        }
                        i++;
                    }
                }
            }
            // If an error if thrown, catch the exception error



            catch (Exception ex)
            {
                // Write the exception error to the display.
                Console.WriteLine("Error:  " + ex);
            }
            database.Connect("MCMtrend");
            TableName = "Vincentdata";
            database.CreateTable(TableName, temp2);
            // Waits for a "Enter" key to be used. I use this like a pause button.
            Console.ReadLine();
        }