예제 #1
0
 /// <summary>
 /// Handler for button, Moves stream to end -1 line
 /// </summary>
 private void Move_to_end_Click(object sender, EventArgs e)
 {
     if (stream_exists == true)
     {
         Stream_controler.Move_Stream(stream_container, (int)MoveMode.End);
     }
 }
예제 #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


        /// <summary>
        /// Handler for button, Moves stream to start
        /// </summary>
        private void Move_to_start_Click_1(object sender, EventArgs e)
        {
            if (stream_exists == true)
            {
                Stream_controler.Move_Stream(stream_container, (int)MoveMode.Start);
            }
        }
예제 #3
0
        /// <summary>
        /// Handler open file dialog, creates stream and it's reader
        /// </summary>
        private void openFileDialog1_FileOk_1(object sender, CancelEventArgs e)
        {
            stream_container = new Streams_Container();

            stream_container.stream_reader = Stream_controler.Create_Reader(openFileDialog1.FileName);
            stream_container.base_stream   = Stream_controler.Get_Base_Stream(stream_container.stream_reader);

            stream_container.input_file_path = openFileDialog1.FileName;

            stream_exists = true;
        }
예제 #4
0
        private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            string save_path;

            save_path = saveFileDialog1.FileName;

            if (save_path != null)
            {
                stream_container.stream_writer = new StreamWriter(save_path);
                Stream_controler.Generate_log(stream_container, input_filename);
            }
        }
예제 #5
0
 /// <summary>
 /// Handler for button, Shows current line
 /// </summary>
 private void Move_by_amount_Click(object sender, EventArgs e)
 {
     if (stream_exists == true)
     {
         try
         {
             amount = Convert.ToInt16(textBox_amount.Text);
             Stream_controler.Move_Stream(stream_container, (int)MoveMode.Amount, amount);
         }
         catch
         {
         }
     }
 }
/*
 *      /// <summary>
 *      /// Iterates through whole file and counts number of lines in it (Resets stream to origin)
 *      /// </summary>
 *     public static int Get_line_lenght(Streams_Container s_container)
 *     {
 *          int lenght = 0;
 *
 *          s_container = Move_Stream(s_container, (int)MoveMode.Start);
 *
 *          while(s_container.stream_reader.ReadLine()!=null)
 *          {
 *              lenght++;
 *          }
 *
 *          return lenght;
 *     }
 */

        public static void Generate_log(Streams_Container sc, string filename)
        {
            StreamWriter sw = sc.stream_writer;

            string line;

            long length = new System.IO.FileInfo((sc.input_file_path)).Length;

            sw.WriteLine("Big Data reader log");
            sw.WriteLine("Filename: " + filename);
            sw.WriteLine();
            sw.WriteLine(length);
            sw.WriteLine();
            sw.WriteLine("First 20 lines: ");
            sw.WriteLine();
            Stream_controler.Move_Stream(sc, (int)MoveMode.Start);
            for (int i = 0; i < 20; i++)
            {
                sw.WriteLine(sc.stream_reader.ReadLine());
            }
            sw.WriteLine();
            sw.WriteLine("Last 20 lines: ");
            sw.WriteLine();
            Stream_controler.Move_Stream(sc, (int)MoveMode.End);
            for (int i = 0; i < 20; i++)
            {
                line = sc.stream_reader.ReadLine();
                if (line == null)
                {
                    break;
                }
                sw.WriteLine(line);
            }
            sw.WriteLine();
            sw.WriteLine("End of log");

            sw.Flush();
            sw.Close();
        }