示例#1
0
        private void AcceptNewABN(object sender, RoutedEventArgs e)
        {
            var data = ((ABNData)DataContext);

            ABNHelper.SetupInfoFile(data);
            ABNHelper.UpdatedBusinessCard();
            this.Close();
        }
示例#2
0
        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);
        }
示例#3
0
        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();
        }
示例#4
0
        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();
        }
示例#5
0
        public static DataInvoice[] GetAllInvoices()
        {
            List <DataInvoice> invoices = new List <DataInvoice>();

            string[] abns = ABNHelper.GetAllABNs();
            foreach (string abn in abns)
            {
                string dir = abn + @"\Invoices";
                if (Directory.Exists(dir))
                {
                    string[] Invoices = Directory.GetFiles(dir);
                    foreach (string s in Invoices)
                    {
                        DataInvoice invoice = new DataInvoice();
                        invoice.ABN      = ABNHelper.FormatABN(Path.GetFileName(abn));
                        invoice.FilePath = s;
                        invoices.Add(invoice);
                    }
                }
            }

            return(invoices.ToArray());
        }
示例#6
0
        public async Task DisplayPop3SubjectsAsync()
        {
            BotVisitor v = new BotVisitor();

            for (int i = 0; i < Pop3?.Count; i++)
            {
                //Pop3.DeleteMessage(i);
                MimeMessage message = Pop3.GetMessage(i);
                v.Visit(message);
                Console.WriteLine("Subject: {0}", message.Subject);
                List <string> Messages = new List <string>();
                if (message.Attachments != null)
                {
                    foreach (MimeEntity mime in message.Attachments)
                    {
                        if (mime.IsAttachment)
                        {
                            var    mp   = (MimePart)mime;
                            string path = Path.Combine(@"D:\Desktop\Hub Test Folder", mime.ContentType.Name);
                            Console.WriteLine("Name: " + mime.ContentType.Name);
                            using (var stream = File.Create(path))
                            {
                                mp.Content.DecodeTo(stream);
                            }
                            ProcessedInvoice[] processedInvoices = await DataProcessing.ProcessInvoices(path);

                            Messages.Add($"<p>\t  - Processed {mime.ContentType.Name} as Invoice for {ABNHelper.GetCompanyName(processedInvoices[0].ABN)}</p>");
                            //File.Delete(path);
                        }
                    }
                }


                EmailService   service = new EmailService();
                MailboxAddress address = message.From.Mailboxes.First();
                Console.WriteLine(address);
                string body = "<h3><b><u>Items Processed:</h3></b></u> \n";
                for (int j = 0; j < Messages.Count; j++)
                {
                    body += Messages[j] + '\n';
                }

                //    service.Send("*****@*****.**", address.Address, $"Re: {message.Subject}", body );
            }
            Pop3.DeleteAllMessages();
        }
示例#7
0
 public static string GetCompanyName(string abn)
 {
     return(ABNHelper.GetCompanyName(abn));
 }