public static DataCompany GetCompany(string abn) { string dir = ABNHelper.GetDirectory(abn); string filePath = dir + "/CompanyInfo.info"; if (File.Exists(dir + "/CompanyInfo.info")) { DataCompany company = JsonConvert.DeserializeObject <DataCompany>(File.ReadAllText(filePath)); return(company); } return(null); }
internal static void SaveChanges(DataCompany dataCompany) { string dir = ABNHelper.GetDirectory(dataCompany.ABN); string filePath = dir + "/CompanyInfo.info"; DocumentReference d = App.db.Collection("Trades").Document(dataCompany.CompanyName); d.SetAsync(dataCompany); string s = JsonConvert.SerializeObject(dataCompany); StreamWriter writer = new StreamWriter(filePath); writer.Write(s); writer.Flush(); writer.Close(); }
static void TryABN(ProcessedInvoice inv) { if (String.IsNullOrEmpty(inv.ABN)) { PromptTextDialog promptTextDialog = new PromptTextDialog(); promptTextDialog.SetCaption("Can't find ABN, please specify $$"); promptTextDialog.ShowDialog(); inv.ABN = promptTextDialog.Text; } if (!ABNHelper.DoesABNExist(inv.ABN)) { string text = $"ABN Not found: {inv.ABN}, would you like to create a new folder for {inv.ABN}?"; var response = MessageBox.Show(text, "ABN not found", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes); if (response == MessageBoxResult.Yes) { NewABN newABN = new NewABN(); newABN.InvoiceFile = inv.FilePath; newABN.DataContext = new ABNData() { ABN = inv.ABN, Email = inv.Email, Phone = inv.Phone, CompanyName = inv.CompanyName }; newABN.Show(); } } string path = ABNHelper.GetDirectory(inv.ABN); string iPath = path + @"\Invoices\"; ABNHelper.CreateDirectoryFromPath(iPath); string tPath = iPath + System.IO.Path.GetFileName(inv.FilePath); if (!File.Exists(tPath)) { File.Copy(inv.FilePath, tPath, false); } InvoiceHelper.OnInvoiceAdded(); }