Example #1
0
        public void writeToCSVFile()
        {
            this.fileCreated = true;
            //add disconnected players tp log
            int firstRows = 5 + getNumOfPlayers();
            var toFile    = writeToFile;

            if (toFile != null)
            {
                if (!Program.LogAgents)
                {
                    firstRows = 5 + numOfHumanPlayers;
                }
                toFile.Insert(firstRows, "disconnected player id, round");
                int j = firstRows + 1;
                for (int i = 0; i < this.playersDisconnected.Count; i++)
                {
                    toFile.Insert(j, this.playersDisconnected[i]);
                    j++;
                }

                for (int i = 0; i < toFile.Count; i++)
                {
                    file.write(toFile[i]);
                }
            }
            file.Close();
        }
Example #2
0
        //Writes and stores the total seats available for events for further bookings.
        private void WriteAndStoreData()
        {
            StreamWriter WriteData;

            //Clears the file to store a whole new data.
            using (var fs = new FileStream("AvailPlaces", FileMode.Truncate))
            {
                fs.Close();
            }
            WriteData = File.AppendText("AvailPlaces");

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    WriteData.WriteLine(result[i, j].ToString());
                }
            }
            WriteData.Close();
        }
Example #3
0
        //Writes the data into the file.
        private void FileDetailsWrite()
        {
            StreamWriter WriteData;

            string MyFileName = String.Format(DateTime.Now.ToString(DATEFORMAT), "MyFileName");

            if (File.Exists(MyFileName))
            {   //checks if the file exists for that day and writes the data
                if (MyFileName != DateTime.Now.ToString(DATEFORMAT))
                {
                    string NewFile = DateTime.Now.ToString(DATEFORMAT);
                    WriteData = File.CreateText(NewFile);
                    WriteData.Close();
                    WriteData = File.AppendText(NewFile);
                    for (int i = 0; i < EventNameList.Count; i++)
                    {
                        //both the if and else according to the condition writes all the multiple bookings made into file
                        WriteData.WriteLine(TransactionList[i].ToString());
                        WriteData.WriteLine(TotalSeatList[i].ToString());
                        WriteData.WriteLine(EventNameList[i]);
                        WriteData.WriteLine(LocationNameList[i]);
                        WriteData.WriteLine(MealPlanNameList[i]);
                        WriteData.WriteLine(TotalAmountList[i].ToString());
                        WriteData.WriteLine("                    ");
                    }
                    WriteData.Close();
                }
                else
                {
                    WriteData = File.AppendText(MyFileName);
                    for (int i = 0; i < EventNameList.Count; i++)
                    {
                        WriteData.WriteLine(TransactionList[i].ToString());
                        WriteData.WriteLine(TotalSeatList[i].ToString());
                        WriteData.WriteLine(EventNameList[i]);
                        WriteData.WriteLine(LocationNameList[i]);
                        WriteData.WriteLine(MealPlanNameList[i]);
                        WriteData.WriteLine(TotalAmountList[i].ToString());
                        WriteData.WriteLine("                    ");
                    }
                    WriteData.Close();
                }
            }
            else
            {
                WriteData = File.CreateText(MyFileName);
                WriteData.Close();
                WriteData = File.AppendText(MyFileName);

                for (int i = 0; i < EventNameList.Count; i++)
                {
                    WriteData.WriteLine(TransactionList[i].ToString());
                    WriteData.WriteLine(TotalSeatList[i].ToString());
                    WriteData.WriteLine(EventNameList[i]);
                    WriteData.WriteLine(LocationNameList[i]);
                    WriteData.WriteLine(MealPlanNameList[i]);
                    WriteData.WriteLine(TotalAmountList[i].ToString());
                    WriteData.WriteLine("                    ");
                }
                WriteData.Close();
            }
        }