Example #1
0
    public void SaveCSVData()
    {
        //Debug.Log(clickPos); //타일맵 중심을 기준으로 0,0  한칸당 1씩 = tile의 사이즈가 1, 1이라서 그런듯
        //Debug.Log(tileMap.GetTile(clickPos)); //
        //Debug.Log(tileMap.cellSize);  //타일 크기 (1,1,0)
        //Debug.Log(tileMap.size);      //타일맵 x*y 크기 알려줌 Vector3

        Vector3    size = tileMap.size;
        Vector3Int cellPos;


        using (var writer = new CSVFileWriter(path + fileName + ".csv"))
        {
            List <string> columns = new List <string>();

            for (int i = 0; i < size.x; i++)
            {
                columns.Add("_" + i);
            }

            writer.WriteRow(columns);
            columns.Clear();

            string type;

            //ㄴPath Tower, Wall 구분해야함 3레이어

            for (int i = ((int)size.y / 2 - 1); i > -(size.y / 2) - 1; i--) //중앙을 기준으로 위
            {
                //j = -18 / 2 = -9               -9 < 9             9++
                for (int j = -(int)size.x / 2; j < size.x / 2; j++) //중앙을 기준으로 오른쪽
                {
                    Debug.Log($"Pos : {j}, {i} " + tileMap.GetTile(new Vector3Int(j, i, 0)).name);
                    columns.Add(tileMap.GetTile(new Vector3Int(j, i, 0)).name.ToString());
                }

                writer.WriteRow(columns); //줄바꿈
                columns.Clear();
            }

            writer.WriteRow(columns); //줄바꿈
            columns.Clear();


            //Wall tileMap
            for (int i = ((int)size.y / 2 - 1); i > -(size.y / 2) - 1; i--) //중앙을 기준으로 위
            {
                //j = -18 / 2 = -9               -9 < 9             9++
                for (int j = -(int)size.x / 2; j < size.x / 2; j++) //중앙을 기준으로 오른쪽
                {
                    Debug.Log($"Pos : {j}, {i} " + wallTileMap.GetTile(new Vector3Int(j, i, 0)).name);
                    columns.Add(wallTileMap.GetTile(new Vector3Int(j, i, 0)).name.ToString());
                }

                writer.WriteRow(columns); //줄바꿈
                columns.Clear();
            }
        }
    }
Example #2
0
        public override void WriteTicket(Ticket ticket, string fileName)
        {
            CSVFileWriter fw = new CSVFileWriter();

            TicketList.Add(ticket);

            var dataline = ParseContext.DoParseForData(ticket);

            fw.writeToFile(dataline, fileName);
        }
Example #3
0
        public void TestCsvWriterEmpty()
        {
            StringWriter  stringWriter  = new StringWriter();
            CSVFileWriter csvFileWriter = new CSVFileWriter(stringWriter);
            DataTable     dataTable     = new DataTable();

            csvFileWriter.WriteFromDataTable(dataTable);
            csvFileWriter.Close();
            Assert.AreEqual(Environment.NewLine, stringWriter.ToString());
        }
Example #4
0
        public static bool DumpStrings()
        {
            string dialogueFileDir = Path.Combine(rootDir, unpackedGameFilesDir, @"PSP_GAME\USRDIR\St000"); // at the moment there's only one directory with files that have strings and only files with strings in that directory, so this is a quick way of processing. if any non-string files are added to this directory or any string files are found in other directories more advanced filtering will be necessary.

            string[] fileList = Directory.GetFiles(dialogueFileDir);

            if (!Directory.Exists(dialogueFileDir))
            {
                string errorMessage = string.Format("Could not find directory {0}.", dialogueFileDir);
                MessageBox.Show(errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            var nameCollection = new StringCollection();
            Dictionary <string, StringCollection> stringFiles = new Dictionary <string, StringCollection>();

            foreach (string file in fileList)
            {
                string fileName    = Path.Combine(dialogueFileDir, file);
                var    fileStrings = new StringCollection(GetSubPath(file, Path.Combine(rootDir, unpackedGameFilesDir)));

                FileStream   fs = new FileStream(fileName, FileMode.Open);
                BinaryReader br = new BinaryReader(fs);

                var testParser = new FileParser();
                var parsedFile = testParser.ParseFile(br, Path.GetFileName(file), null);

                foreach (IElement element in parsedFile.instructions)
                {
                    if (element is IHasName)
                    {
                        var name = (element as IHasName).GetName();
                        nameCollection.AddString(name, name); // using name as ID and value since we want a single entry for each name - saves messing with IDs
                    }
                    if (element is IHasStrings)
                    {
                        var temp = element as IHasStrings;
                        temp.AddStrings(fileStrings);
                    }
                }

                br.Close();
                fs.Close();

                if (fileStrings.NumberOfKeys > 0)
                {
                    var    subPath             = GetSubPath(file, Path.Combine(rootDir, unpackedGameFilesDir));
                    string spreadsheetFileName = Path.Combine(rootDir, editableGameFiesDir, subPath);
                    var    spreadsheet         = new CSVFileWriter();
                    spreadsheet.WriteCSVFile(spreadsheetFileName, parsedFile.instructions, fileStrings);
                }
            }

            return(true);
        }
Example #5
0
        public void TestCsvWriterCommasInHeader()
        {
            StringWriter  stringWriter  = new StringWriter();
            CSVFileWriter csvFileWriter = new CSVFileWriter(stringWriter);
            DataTable     dataTable     = CsvTestsSamples.CommasInHeaderDataTable();

            csvFileWriter.WriteFromDataTable(dataTable);
            csvFileWriter.Close();
            string expected = CsvTestsSamples.CommasInHeaderCsvContents();

            Assert.AreEqual(expected, stringWriter.ToString());
        }
Example #6
0
    static void Main(string[] args)
    {
        string logFile = "log.txt";

        // delimiter config
        char inFileDelimiter  = ',';
        char inFileEnclosure  = '"';
        char outFileDelimiter = ';';
        char outFileEnclosure = '"';

        using (StreamWriter logWriter = File.AppendText(logFile))
        {
            try
            {
                if (args.Length == 0)
                {
                    throw new Exception("Das Programm benoetigt mindestens eine Eingabe-Datei!");
                }

                foreach (string inFile in args)
                {
                    CSVFile inCsv = CSVFileReader.Open(inFile,
                                                       Encoding.GetEncoding("iso-8859-1"),
                                                       inFileDelimiter,
                                                       inFileEnclosure
                                                       );

                    CSVFile outCsv = CSVFileConverter.Convert(inCsv);

                    string outFile = inFile + ".konvertiert.csv";

                    CSVFileWriter writer = new CSVFileWriter(outFile,
                                                             Encoding.GetEncoding("iso-8859-1"),
                                                             outFileDelimiter,
                                                             outFileEnclosure
                                                             );

                    writer.WriteCsv(outCsv);
                }
            }
            catch (Exception e)
            {
                logWriter.WriteLine(e.ToString());

                Console.WriteLine("Ein Fehler ist aufgetreten. Weitere Informationen befinden sich in der Log-Datei.\n\n> {0}\n", e.Message);
                Console.WriteLine("Enter zum Beenden druecken...");
                Console.ReadLine();
            }
        }
    }
 public static IFileWriter GetFileWriter(string fileExtension)
 {
     IFileWriter fileWriter = null;
     switch (fileExtension){
         case ".txt":
             fileWriter = new TextFileWriter();
             break;
         case ".csv":
             fileWriter = new CSVFileWriter();
             break;
         case ".xml":
             fileWriter = new XMLFileWriter();
             break;
         default:
             return null;
     }
     return fileWriter;
 }
Example #8
0
    public void SaveBinaryPathToCSV()
    {
        using (var writer = new CSVFileWriter(Application.dataPath + "/Resources/Binary_Path.csv"))
        {
            List <string> columns = new List <string>()
            {
                "Count", "Path"
            };                                                            // making Index Row

            writer.WriteRow(columns);
            columns.Clear();

            foreach (var item in binary_path)
            {
                columns.Add(item.Key.ToString());
                columns.Add(item.Value.ToString());

                writer.WriteRow(columns);
                columns.Clear();
            }
        }
    }
        static void Main22(string[] args)
        {
            var writer = new CSVFileWriter("test.csv");

            var csv_elem_1 = new CSVFileInfo("blabla", "v1.3", "222");
            var csv_elem_2 = new CSVFileInfo("blsssa", "2.3", "112");
            var csv_elem_3 = new CSVFileInfo("bl", "v22.3", "332");

            writer.WriteCSV(csv_elem_1);
            writer.WriteCSV(csv_elem_2);
            writer.WriteCSV(csv_elem_3);
            writer.Flush();
            writer.Close();


            var reader = new CSVFileReader("test.csv");
            var list   = reader.ReadCSV <CSVFileInfo>();


            foreach (var elem in list)
            {
                foreach (var single_elem in elem.GetCSVData)
                {
                    Console.Write(single_elem.ToString() + " ");
                }

                Console.WriteLine();
            }

            Console.WriteLine();
            var controller = new CSVFileController();

            controller.Add(@"D:\Game's\RivaTuner Statistics Server\EncoderServer.exe");
            controller.Load("test.csv");
            Console.WriteLine(controller.GetAtIndex(0)[1]);

            Console.ReadKey();
        }
        public void Write(string filePath, IEnumerable<Sale> sales)
        {
            using (var csvWriter = new CSVFileWriter(filePath))
            {
                foreach(var sale in sales)
                {
                    var saleDate = sale.SaleDate;
                    var clientName = sale.Client.Name;
                    var productName = sale.Product.ProductName;
                    var cost = sale.Product.Cost;

                    var values = new object[] { saleDate, clientName, productName, cost };
                    csvWriter.WriteLine(values);
                }
            }
        }
        static void Main(string[] args)
        {
            var factory = RabbitFactory.GetFactory();

            if (args.Length == 0)
            {
                Logger.Log("Enter a consumer ID:", true);
                consumerId = Console.ReadLine();

                Logger.Log("Enter a broker ID (if random leave empty):", true);
                var broker = Console.ReadLine();

                if (string.IsNullOrWhiteSpace(broker))
                {
                    brokerId += GetRandomBroker();
                }
                else
                {
                    brokerId += broker;
                }
                Logger.Log($"Broker ID: {brokerId}", true);
            }
            else
            {
                consumerId = args[0];
                Logger.Log($"Consumer ID: {consumerId}", true);

                if (args.Length == 1)
                {
                    brokerId += GetRandomBroker();
                }
                else
                {
                    brokerId += args[1];
                }
                Logger.Log($"Broker ID: {brokerId}", true);
            }
            var publicationsQueueName = $"C{consumerId}";


            Subscriptions sub = new Subscriptions(brokerId, consumerId);

            var    subFeedThreadReference = new ThreadStart(sub.SendSubscriptions);
            Thread subFeedThread          = new Thread(subFeedThreadReference);

            subFeedThread.Start();


            using (var connection = factory.CreateConnection())
            {
                using (var channel = connection.CreateModel())
                {
                    channel.QueueDeclare(queue: publicationsQueueName,
                                         durable: true,
                                         exclusive: false,
                                         autoDelete: false,
                                         arguments: null);
                    channel.BasicQos(prefetchSize: 0, prefetchCount: 1, global: false);

                    var consumer = new EventingBasicConsumer(channel);
                    consumer.Received += ConsumePublications;
                    channel.BasicConsume(queue: publicationsQueueName,
                                         autoAck: true,
                                         consumer: consumer);
                    Logger.Log("Awaiting Messages...", true);

                    Console.ReadLine();
                    consumer.Received -= ConsumePublications;
                    Logger.Log("Writing to file latency results...");

                    CSVFileWriter f = new CSVFileWriter(consumerId, latency: Latencies);
                    f.WriteAllLatenciesInCSV();
                    Logger.Log("Finishd...");
                }
            }
        }