/// <summary>
        /// Creates File if necessary
        /// </summary>
        /// <param name="filename">Filename</param>
        public static void CreateFile(string filename)
        {
            StreamWriter writer = File.CreateText(filename);

            writer.Close();
            Logfiles.FileCreatedLog(filename);
        }
Esempio n. 2
0
        public static void InitializingSuccededLog()
        {
            List <string> log = new List <string>();

            log.Add("Initialisierung mit korrekter Datei erfolgt");
            Logfiles.PrintLogs(log);
        }
Esempio n. 3
0
        public static void FileCreatedLog(string filename)
        {
            List <string> log = new List <string>();

            log.Add("FileCreatedLog");
            log.Add("Datei \"" + filename + "\" erstellt");
            Logfiles.PrintLogs(log);
        }
Esempio n. 4
0
        public static void SongAddedLog(string songname)
        {
            List <string> log = new List <string>();

            log.Add("SongAddedLog");
            log.Add("Song \"" + songname + "\" hinzugefügt");
            Logfiles.PrintLogs(log);
        }
Esempio n. 5
0
        public static void SongAlreadyExistsLog(string cclinumber)
        {
            List <string> log = new List <string>();

            log.Add("SongAlreadyExistsLog");
            log.Add("Eintrag \"" + cclinumber + "\" schon vorhanden");
            Logfiles.PrintLogs(log);
        }
        //absoulte path for output file missing
        /// <summary>
        /// Writes Songinfos to Output File
        /// </summary>
        /// <param name="songname">Songname</param>
        /// <param name="songNumber">CCLI-Number</param>
        public static void NewSong(string songname, int songNumber)
        {
            StreamWriter output = new StreamWriter("Output.ccli", true);

            output.Write(songNumber);
            output.Write(" - ");
            output.Write(songname);
            output.WriteLine();
            output.Close();
            Logfiles.SongAddedLog(songname);
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            string inputFileDirectory = "";

            if (args.Length == 1 && args[0].EndsWith(".txt"))
            {
                Logfiles.InitializingSuccededLog();
                inputFileDirectory = args[0];
            }
            else
            {
                Console.WriteLine("Bitte mit einer .TXT Datei öffnen!");
                Errorlogs.OpenedWithWrongArgumentsLog(args);
                Console.WriteLine("Zum Beenden Enter drücken.");
                Console.ReadLine();
                Environment.Exit(0);
            }

            StreamReader inputReader = new StreamReader(inputFileDirectory);
            string       currentReaderLine;

            string[] linesInOutputFile = new string[0];

            try
            {
                //Reads every line in the Output File to check for duplicates later
                linesInOutputFile = File.ReadAllLines("Output.ccli");
            }
            catch (FileNotFoundException e)
            {
                //Creates File Output.ccli if necessary
                Errorlogs.FileNotFoundLog(e);
                OutputHandling.CreateFile(e.FileName);
            }

            //Reads Input File
            while ((currentReaderLine = inputReader.ReadLine()) != null)
            {
                int cclinumber;
                if (int.TryParse(currentReaderLine, out cclinumber))
                {
                    InputIsAnInteger(cclinumber, linesInOutputFile);
                }
                else
                {
                    Console.WriteLine("Bitte nur CCLI-Nummern angeben!");
                }
            }

            inputReader.Close();
            Console.WriteLine("Enter drücken zum Beenden");
            Console.ReadLine();
        }
Esempio n. 8
0
        private static void InputIsAnInteger(int input, string[] linesInOutputFile)
        {
            Song song      = new Song(input);
            bool duplicate = song.IsSongNumberAlreadyExisting(linesInOutputFile);

            if (duplicate)
            {
                Logfiles.SongAlreadyExistsLog(song);
            }
            else
            {
                song.AddNewSongByNumber();
            }
        }