コード例 #1
0
ファイル: LaPlataData.cs プロジェクト: Eric7Apps/BlogSource
        internal bool AddLaPlataRec( LaPlataRecord Rec )
        {
            if( Rec == null )
              return false;

            LaPlataRecArray[LaPlataRecArrayLast] = Rec;
            SortIndexArray[LaPlataRecArrayLast] = LaPlataRecArrayLast;
            LaPlataRecArrayLast++;

            if( LaPlataRecArrayLast >= LaPlataRecArray.Length )
              {
              try
              {
              Array.Resize( ref LaPlataRecArray, LaPlataRecArray.Length + (1024 * 4));
              Array.Resize( ref SortIndexArray, LaPlataRecArray.Length );
              }
              catch( Exception Except )
            {
            MForm.ShowStatus( "Error: Couldn't resize the arrays." );
            MForm.ShowStatus( Except.Message );
            return false;
            }
              }

            return true;
        }
コード例 #2
0
ファイル: LaPlataData.cs プロジェクト: Eric7Apps/BlogSource
        internal bool ReadFromFile()
        {
            string FileName = MForm.GetDataDirectory() + "Parcels.csv";
            // ECTime RecTime = new ECTime();

            try
            {
            string Line;
            using( StreamReader SReader = new StreamReader( FileName  ))
              {
              int HowMany = 0;
              while( SReader.Peek() >= 0 )
            {
            Line = SReader.ReadLine();
            if( Line == null )
              continue;

            // Keep the tabs here.
            // Line = Line.Trim();
            if( Line.Length < 3 )
              continue;

            if( Line.StartsWith( "APN,C,12\tOWNER,C,50\t" ))
              continue;

            if( !Line.Contains( "\t" ))
              continue;

            LaPlataRecord Rec = new LaPlataRecord( MForm );
            if( !Rec.StringToObject( Line ))
              continue;

            if( !AddLaPlataRec( Rec ))
              break; // Out of RAM.

            HowMany++;
            }

              MForm.ShowStatus( " " );
              MForm.ShowStatus( "Records: " + HowMany.ToString( "N0" ));
              }

            // Don't sort the whole thing.  At least not with a bubble sort.
            // Sort a small subset of results.
            // SortByName();
            return true;

            }
            catch( Exception Except )
              {
              MForm.ShowStatus( "Could not read the La Plata data file." );
              MForm.ShowStatus( Except.Message );
              return false;
              }
        }