// [Fact] public void parseOldEtsyEmails() { AirtableOrders ATbase = new AirtableOrders(); string fullFile = File.ReadAllText(@"C:\Users\Al\Dropbox\3DPros - General\Tools\EmailParser\etsyOrderEmailDump\Takeout\Mail\etsy order.mbox"); string[] emails = fullFile.Split("X-Gmail-Labels: Inbox,Unread,etsy order"); var emailDataList = new List <EmailData>(); var badDataList = new List <EmailData>(); string csv = ""; foreach (string item in emails) { try { var cleanString = item.Replace("=", ""); cleanString = cleanString.Replace("\n", ""); cleanString = cleanString.Replace("\r", ""); string rawdate = Regex.Match(cleanString, @"[a-zA-Z]{3}, \d{2} [a-zA-Z]{3} 20\d{2}").Groups[0].Value; DateTime emaildate = DateTime.MinValue; DateTime.TryParse(rawdate, out emaildate); var emailInfo = new EmailData() { RawEmail = item, Email = Regex.Match(cleanString, @"""mailto:([^\""]*)\""").Groups[1].Value.Trim(), ID = Regex.Match(cleanString, @"http:\/\/www\.etsy\.com\/your\/orders\/(\d{10})").Groups[1].Value, ItemNames = Regex.Match(cleanString, @"Item:\s*?(.*)--").Groups[1].Value, date = emaildate, RawDate = rawdate }; if (emailInfo.Email != "" && emailInfo.ID != "") { emailDataList.Add(emailInfo); csv += emailInfo.Email + "\t" + emailInfo.ID + "\t" + emailInfo.ItemNames + "\t" + emailInfo.date.ToString() + "\n"; var record = ATbase.GetRecordByOrderID(emailInfo.ID, out _); if (record != null) { if (record.CustomerEmail == "") { record.CustomerEmail = emailInfo.Email; ATbase.CreateOrderRecord(record, true); Thread.Sleep(250); } } } else { badDataList.Add(emailInfo); } } catch { } } }
public void TestMethod1() { AirtableOrders ATbase = new AirtableOrders(); var order = ATbase.newOrderData(1234567); order.Notes = "this is a test order"; order.ShippingCost = 10.21; order.TotalPrice = 504.23; order.Description = "test order"; // order.PrintOperator = "Al Billington"; // order.Shipper = "Leah"; // order.ShippingCharge = Math.Min(7; order.MaterialCost = 12.34; order.DueDate = DateTime.Now; order.Channel = "Etsy"; ATbase.CreateOrderRecord(order); ATbase.CreateOrderRecord(order); }
public void CreateAndUpdateOrder() { AirtableOrders ATbase = new AirtableOrders(true); string orderID = "1234567"; var order = ATbase.newOrderData(orderID); order.Notes = "this is a test order"; order.ShippingCost = 10.21; order.Description = "test\n order"; order.Channel = "Direct"; order.AsanaTaskID = "3242342634652352"; order.PrintOperator = "Kyle Perkuhn"; ATbase.CreateOrderRecord(order); order.TotalPrice = 504.23; order.ValueOfInventory = 233.04; order.AmountRefunded = 5; // order.ShipDate = DateTime.Now; var retrievedRecord = ATbase.GetRecordByOrderID(orderID, out _); Assert.Equal(order.Notes, retrievedRecord.Notes); Assert.Equal(order.ShippingCost, retrievedRecord.ShippingCost); Assert.Equal(order.Description, retrievedRecord.Description); Assert.Equal(order.Channel, retrievedRecord.Channel); Assert.Equal(order.AsanaTaskID, retrievedRecord.AsanaTaskID); Assert.NotEqual(order.TotalPrice, retrievedRecord.TotalPrice); ATbase.CreateOrderRecord(order, true); retrievedRecord = ATbase.GetRecordByOrderID(orderID, out _); Assert.Equal(order.TotalPrice, retrievedRecord.TotalPrice); Assert.Equal(order.ValueOfInventory, retrievedRecord.ValueOfInventory); ATbase.DeleteOrderRecord(order); }