public ConversionHandler(MappingDict mapping, QueueDrainOrders Orders) { InitializeComponent(); mappingDict = mapping; map(); fullMapping.queueDrainOrders = Orders; //Newtonsoft.Json.JsonSerializerSettings settings = new Newtonsoft.Json.JsonSerializerSettings(); //string json = Newtonsoft.Json.JsonConvert.SerializeObject(fullMapping, settings); //json = fixJSON(json); string json = fullMapping.Serialize(); string mappingFile = Path.GetTempFileName(); File.WriteAllText(mappingFile, json); Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.DefaultExt = ".tbx"; dlg.Filter = "JSON Files (*.json)|*.json"; bool?result = dlg.ShowDialog(); if (result == true) { if (File.Exists(dlg.FileName)) { File.Delete(dlg.FileName); } //File.WriteAllText(dlg.FileName, tbxOutput); //File.Move(tbxOutput.Replace("/", "\\"), dlg.FileName); File.Move(mappingFile, dlg.FileName); } textblock_conversionStatus.Text = "Your mapping file has been created and can be found:\n " + dlg.FileName + "\n\nUse the converter here: http://www.tbxinfo.net/scripts/cgi-bin/mt2tbx.cgi"; }
public ConversionHandler(MappingDict mapping, QueueDrainOrders Orders) { InitializeComponent(); mappingDict = mapping; map(); fullMapping.queueDrainOrders = Orders; //Newtonsoft.Json.JsonSerializerSettings settings = new Newtonsoft.Json.JsonSerializerSettings(); //string json = Newtonsoft.Json.JsonConvert.SerializeObject(fullMapping, settings); //json = fixJSON(json); string json = fullMapping.Serialize(); string mappingFile = Path.GetTempFileName(); int saveOption = Singleton.Instance.getSaveOption(); if (saveOption == 1) // Mapping and Conversion { File.WriteAllText(mappingFile, json); Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.DefaultExt = ".tbx"; dlg.Filter = "JSON Files (*.json)|*.json"; bool?result = dlg.ShowDialog(); if (result == true) { if (File.Exists(dlg.FileName)) { File.Delete(dlg.FileName); } //File.WriteAllText(dlg.FileName, tbxOutput); //File.Move(tbxOutput.Replace("/", "\\"), dlg.FileName); File.Move(mappingFile, dlg.FileName); } ConverterApp mt2tbx = new ConverterApp(); mt2tbx.deserializeFile(json, Singleton.Instance.getPath(), Singleton.Instance.getDialect(), true); } else if (saveOption == 2) // Will be handled in a different Dialogue { throw new Exception("Mapping not handled!!!"); } else if (saveOption == 3) // Just Mapping File { File.WriteAllText(mappingFile, json); Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.DefaultExt = ".tbx"; dlg.Filter = "JSON Files (*.json)|*.json"; bool?result = dlg.ShowDialog(); if (result == true) { if (File.Exists(dlg.FileName)) { File.Delete(dlg.FileName); } //File.WriteAllText(dlg.FileName, tbxOutput); //File.Move(tbxOutput.Replace("/", "\\"), dlg.FileName); File.Move(mappingFile, dlg.FileName); } } }