コード例 #1
0
        public List <InvoiceEmail> ReadCSV(string _filepath)
        {
            List <InvoiceEmail> invoiceEmails = new List <InvoiceEmail>();

            using (TextFieldParser parser = new TextFieldParser(_filepath))
            {
                parser.Delimiters = new string[] { "," };
                var fields  = parser.ReadFields();
                var headers = fields;
                fields = parser.ReadFields();
                while (fields != null)
                {
                    if (fields != null)
                    {
                        InvoiceEmail invoiceEmail = new InvoiceEmail();
                        try
                        {
                            invoiceEmail = GetRow(headers.ToList(), fields.ToList());
                            invoiceEmails.Add(invoiceEmail);
                        }
                        catch (Exception)
                        {
                        }
                    }
                    fields = parser.ReadFields();
                }
            }
            invoiceEmails = invoiceEmails.Where(a => a.Email.Contains("@")).ToList();
            return(invoiceEmails);
        }
コード例 #2
0
 public void SendFeedbackEmail(List <InvoiceEmail> invoiceEmails, DataGridView dgv, string subject)
 {
     for (int i = 0; i < invoiceEmails.Count; i++)
     {
         InvoiceEmail invoiceEmail = invoiceEmails.ElementAt(i);
         string       ToMail       = invoiceEmail.Email;
         string       FromMail     = "*****@*****.**";
         SmtpClient   client       = new SmtpClient();
         client.UseDefaultCredentials = false;
         client.Credentials           = new NetworkCredential("*****@*****.**", "Laxmi2121");
         client.Port           = 2525;
         client.Host           = "mail.dealsdeals.co.uk";
         client.DeliveryMethod = SmtpDeliveryMethod.Network;
         client.EnableSsl      = false;
         MailAddress From        = new MailAddress(FromMail, "DealsDeals");
         MailAddress To          = new MailAddress(ToMail, invoiceEmail.BuyerAddress.FullName);
         MailMessage mailMessage = new MailMessage(From, To);
         mailMessage.Subject    = "Feedback for your recent eBay Order " + invoiceEmail.ItemNumber;
         mailMessage.IsBodyHtml = false;
         mailMessage.Body       = GetFeedbackMessageBody(invoiceEmail);
         try
         {
             client.Send(mailMessage);
             dgv.Rows[i].Cells["Status"].Value = "Sent";
         }
         catch (Exception ex)
         {
             dgv.Rows[i].Cells["Status"].Value = "Not Sent";
         }
     }
 }
コード例 #3
0
        public async Task <ActionResult <IInvoiceView> > Add([FromBody] InvoiceEmail invoiceEmail)
        {
            try
            {
                var grain  = _orleansService.Client.GetGrain <IInvoiceEmailCommand>(0);
                var result = await grain.InvoiceEmail(invoiceEmail);

                if (result.__CQRSSuccessful)
                {
                    return(new ActionResult <IInvoiceView>(result));
                }
                else
                {
                    return(new ContentResult()
                    {
                        StatusCode = result.__CQRSStatusCode, Content = result.__CQRSErrorMessage, ContentType = "text/plain"
                    });
                }
            }
            catch (Exception e)
            {
                LogFactory.GetLogger().Log(LogLevel.Error, e);
                return(new ContentResult()
                {
                    StatusCode = 500, Content = "Fatal API Error", ContentType = "text/plain"
                });
            }
        }
コード例 #4
0
        public async Task UpdateEmailNotificationsForAccount(InvoiceEmail invoiceEmail, RequestOptions inputOptions)
        {
            if (invoiceEmail.AccountId.Equals(Guid.Empty))
            {
                throw new ArgumentException("invoiceEmail#AccountId can not be empty");
            }

            var uri = Configuration.ACCOUNTS_PATH + "/" + invoiceEmail.AccountId + "/" + Configuration.EMAIL_NOTIFICATIONS;
            await _client.Put(uri, invoiceEmail, inputOptions);
        }
コード例 #5
0
        private string GetFeedbackMessageBody(InvoiceEmail invoiceEmail)
        {
            string body = "Hi " + invoiceEmail.BuyerAddress.FullName + nl(2);

            body += "Thank you very much for your purchase of " + invoiceEmail.Sale.ItemTitle + nl(2);
            body += "I was just checking through my feedback page and noticed you have not yet left feedback for this purchase. If everything was satisfactory please consider leaving feedback by clicking on the link." + nl(2);
            body += "http://feedback.ebay.com/ws/eBayISAPI.dll?LeaveFeedback2&useridto=" + invoiceEmail.UserId + "&item=" + invoiceEmail.ItemNumber + "&transactid=" + invoiceEmail.TransactionId + nl(2);
            body += "It only takes a few seconds and really helps me out.  Also you will receive a 10 % discount code from www.dealdeals.co.uk" + nl(3);
            body += "Best wishes" + nl(2);
            body += "Joshua" + nl(1);
            body += "www.dealsdeals.co.uk";


            return(body);
        }
コード例 #6
0
        public async Task When_UpdatingEmailNotificationsForAccount_Then_TheSettingsAreReturnedCorrectly(bool notificationSetting)
        {
            // arrange
            var invoiceEmail = new InvoiceEmail {
                AccountId = AccountId, IsNotifiedForInvoices = notificationSetting
            };
            await Client.UpdateEmailNotificationsForAccount(invoiceEmail, RequestOptions);

            // act
            var setting = await Client.GetEmailNotificationsForAccount(AccountId, RequestOptions);

            // assert
            Assert.That(setting, Is.Not.Null);
            Assert.That(setting.AccountId, Is.EqualTo(AccountId));
            Assert.That(setting.IsNotifiedForInvoices, Is.EqualTo(notificationSetting));
        }
コード例 #7
0
        public List<SyncInvoice> GetSelectedInvoices()
        {
            var oSyncInvoices = new List<SyncInvoice>();
             var emailTemplate = new InvoiceEmail();

             foreach (DataGridViewRow oRow in m_grdInvoices.Rows)
             {
            var dataItem = oRow.DataBoundItem as InvoiceRow;

            DataGridViewCheckBoxCell oCheckboxColumn = oRow.Cells["IsSync"] as DataGridViewCheckBoxCell;
            if (oCheckboxColumn.Value == oCheckboxColumn.TrueValue)
            {
               DataGridViewCell oInvoiceIDCell = oRow.Cells["ID"];
               DataGridViewCheckBoxCell oInvoiceEmailCell = oRow.Cells["IsEmail"] as DataGridViewCheckBoxCell;

               SyncInvoice oSyncInvoice = new SyncInvoice();
               oSyncInvoice.ID = (string)oInvoiceIDCell.Value;
               if (oInvoiceEmailCell.Value == oInvoiceEmailCell.TrueValue)
               {
                  oSyncInvoice.IsEmail = true;
                  if (dataItem != null)
                  {
                     if (dataItem.CustomEmail)
                     {
                        oSyncInvoice.EmailSubject = dataItem.EmailSubject;
                        oSyncInvoice.EmailBody = dataItem.EmailBody;
                     }
                     else
                     {
                        oSyncInvoice.EmailSubject = emailTemplate.EmailSubject;
                        oSyncInvoice.EmailBody = emailTemplate.EmailBody;
                     }
                  }
               }
               else
               {
                  oSyncInvoice.IsEmail = false;
               }

               oSyncInvoices.Add(oSyncInvoice);
            }
             }

             return oSyncInvoices;
        }
コード例 #8
0
        public bool SendEmail(string invoiceId, InvoiceEmail email)
        {
            var request = CreateBasicRequest(Method.POST, "/{id}/send_email");

            request.RequestFormat = DataFormat.Json;

            request.AddUrlSegment("id", invoiceId);
            request.AddJsonBody(new InvoiceEmailWrapper {
                invoice = email
            });

            var response = Client.Execute(request);

            if (response != null)
            {
                return(response.StatusCode == HttpStatusCode.OK);
            }

            return(false);
        }
コード例 #9
0
        public InvoiceEmail GetRow(List <string> headers, List <string> fields)
        {
            InvoiceEmail invoiceEmail = new InvoiceEmail();

            for (int i = 0; i < fields.Count; i++)
            {
                switch (headers.ElementAt(i).ToLower())
                {
                case ("buyer email"):
                    invoiceEmail.Email = fields.ElementAt(i);
                    break;

                case "buyer name":
                    invoiceEmail.BuyerAddress.FullName = fields.ElementAt(i);
                    invoiceEmail.Name = fields.ElementAt(i);
                    break;

                case "buyer address 1":
                    invoiceEmail.BuyerAddress.Address1 = fields.ElementAt(i);
                    break;

                case "buyer address 2":
                    invoiceEmail.BuyerAddress.Address2 = fields.ElementAt(i);
                    break;

                case "buyer city":
                    invoiceEmail.BuyerAddress.Town = fields.ElementAt(i);
                    break;

                case "buyer county":
                    invoiceEmail.BuyerAddress.County = fields.ElementAt(i);
                    break;

                case "buyer postcode":
                    invoiceEmail.BuyerAddress.PostCode = fields.ElementAt(i);
                    break;

                case "buyer country":
                    invoiceEmail.BuyerAddress.Country = fields.ElementAt(i);
                    break;



                case "post to name":
                    invoiceEmail.PosttoAddress.FullName = fields.ElementAt(i);
                    break;

                case "post to address 1":
                    invoiceEmail.PosttoAddress.Address1 = fields.ElementAt(i);
                    break;

                case "post to address 2":
                    invoiceEmail.PosttoAddress.Address2 = fields.ElementAt(i);
                    break;

                case "post to city":
                    invoiceEmail.PosttoAddress.Town = fields.ElementAt(i);
                    break;

                case "post to county":
                    invoiceEmail.PosttoAddress.County = fields.ElementAt(i);
                    break;

                case "post to postcode":
                    invoiceEmail.PosttoAddress.PostCode = fields.ElementAt(i);
                    break;

                case "post to country":
                    invoiceEmail.PosttoAddress.Country = fields.ElementAt(i);
                    break;


                case "sales record number":
                    invoiceEmail.Sale.SalesRecordNumber = fields.ElementAt(i);
                    break;

                //showing sale date on paid on date
                case "sale date":
                    invoiceEmail.Sale.PaidOnDate = fields.ElementAt(i);
                    break;

                case "item title":
                    invoiceEmail.Sale.ItemTitle = fields.ElementAt(i);
                    break;

                case "quantity":
                    invoiceEmail.Sale.Quantity = fields.ElementAt(i);
                    break;

                case "sold for":
                    invoiceEmail.Sale.SalePrice = fields.ElementAt(i);
                    break;

                case "custom label":
                    invoiceEmail.Sale.CustomLabel = GetStringorNumber(fields.ElementAt(i));
                    break;

                case "postage and packaging":
                    invoiceEmail.Sale.PostageAndPackaging = fields.ElementAt(i);
                    break;

                case "total price":
                    invoiceEmail.Sale.TotalPrice = fields.ElementAt(i);
                    break;

                case "delivery service":
                    invoiceEmail.Sale.DeliveryService = fields.ElementAt(i);
                    break;

                case "payment method":
                    invoiceEmail.Sale.PaymentMethod = fields.ElementAt(i);
                    break;

                case "transaction id":
                    invoiceEmail.TransactionId = GetStringorNumber(fields.ElementAt(i));
                    break;

                case "user id":
                    invoiceEmail.UserId = fields.ElementAt(i);
                    break;

                case "item number":
                    invoiceEmail.ItemNumber = GetStringorNumber(fields.ElementAt(i));
                    break;

                default:
                    break;
                }
            }
            return(invoiceEmail);
        }
コード例 #10
0
 public InvoiceEmailWrapper()
 {
     invoice = new InvoiceEmail();
 }
コード例 #11
0
        private string GetSellMessageBody(InvoiceEmail invoiceEmail)
        {
            decimal saleprice       = CalculateSalePrice(invoiceEmail.Sale.SalePrice);
            decimal totalPrice      = saleprice * Convert.ToInt32(invoiceEmail.Sale.Quantity);
            decimal postageshipping = CalculateSalePrice(invoiceEmail.Sale.PostageAndPackaging);

            //decimal tax = 0;
            //if (invoiceEmail.BuyerAddress.Country.Equals("United Kingdom"))
            //{
            //    tax = (Convert.ToDecimal("20") / Convert.ToDecimal("120")) * totalPrice;
            //}
            //decimal subTotal = totalPrice - tax;

            string title = "";

            try
            {
                title = invoiceEmail.Sale.ItemTitle.Substring(0, 50);
            }
            catch (Exception)
            {
                title = invoiceEmail.Sale.ItemTitle;
            }

            //decimal grandTotal = CalculateSalePrice(invoiceEmail.Sale.TotalPrice);
            decimal grandTotal = CalculateSalePrice(invoiceEmail.Sale.TotalPrice);
            string  currency   = GetCurrency(invoiceEmail.Sale.SalePrice);
            string  body       = @"<div style='color:black !important; background: #ecebeb;overflow: hidden;padding: 2%;padding-left: 3px;padding-right: 3px'>
    <div style='background: white;padding: 10px;overflow: hidden;border: 1px solid #cccccc;box-shadow: 0px 3px 9px -4px black;'>
        <img style='height:100px;width: auto' src='https://docs.google.com/uc?id=1sQrh4B8D96n9DgdniuHep6tCe8wVoYHZ'/>
        <div style='float:right;text-align: right'>
            <p style='margin: 5px'>HDM Retail LTD</p>
            <p style='margin: 5px'>8 Lammas Close</p>
            <p style='margin: 5px'>Solihull</p>
            <p style='margin: 5px'>B92 8PA</p>
            <p style='margin: 5px'>VAT No: GB 232760325</p>
        </div>
    </div>
    <div style='background: white;overflow: hidden;'>
        <div style='padding:5px'>
            <div style='background: powderblue;overflow: hidden;'>
                <div style='width:60%;padding-left: 10px;padding-top: 20px;float: left;border-right: 1px dotted #6e6e6e'>
                    <p style='margin-bottom:20px;font-size: 20px'><b>Thank you for your order from DealsDeals</b></p>
                    <p >Please visit our website at <b>www.dealsdeals.co.uk</b> for more great offers</p>
                </div>
                <div style='width:30%; float:right;padding-left: 10px'>
                    <p style='margin-bottom:20px'><b>Order questions?</b></p>
                    <p><b>Call Us: </b>0800 448 8228</p>
                    <p><b>Email: </b>[email protected]</p>
                </div>
            </div>
        </div>
        <div style='text-align: center;padding:5px'>
            <h3 style='margin-top: 10px;margin-bottom: 5px'>Your Invoice #" + invoiceEmail.Sale.SalesRecordNumber + @"</h3>
            <p style='margin-top: 10px;margin-bottom: 5px'>Placed on " + invoiceEmail.Sale.PaidOnDate + @"</p>
            <p style='margin-top: 5px;margin-bottom: 5px'>Please visit our website www.dealsdeals.co.uk</p>
            <p style='margin-top: 5px;margin-bottom: 5px'>There is a 10% discount when you use voucher code Ebay10 at checkout</p>
            <div style='border:1px solid #e5e5e5'>
                <div style='background:gainsboro;overflow: hidden;padding-top: 2px;padding-bottom: 2px'>
                    <p style='padding:10px;width:40%;float: left;text-align: left;margin:0px;'><b>ITEM IN ORDER</b></p>
                    <div style='width:40%;float:right;text-align: right'>
                        <p style='padding:10px;width:25%;float:left;margin:0px'><b>QTY</b></p>
                        <p style='padding:10px;width:40%;float:right;margin:0px'><b>PRICE</b></p>
                    </div>
                </div>
                <div style='overflow: hidden;padding-top: 2px;padding-bottom: 2px'>
                    <p style='padding:10px;padding-bottom: 5px;width:50%;float: left;text-align: left;margin:0px;'><b>" + title + @"</b></p>
                    <div style='width:40%;float:right;text-align: right'>
                        <p style='padding:10px;padding-bottom: 5px;width:25%;float:left;margin:0px'>" + invoiceEmail.Sale.Quantity + @"</p>
                        <p style='padding:10px;padding-bottom: 5px;width:40%;float:right;margin:0px'>" + currency + saleprice.ToString() + @"</p>
                    </div>
                    <div style='clear:both'></div>
                    <p style='text-align:left;padding: 0px;margin:0px;padding-left: 10px'>SKU: " + invoiceEmail.Sale.CustomLabel + @"</p>
                </div>
            </div>
            <hr/>
            <div style='background: powderblue;padding:10px;text-align: left;overflow:hidden'>
				<div style='width:30%;float:right;text-align:right;padding-right:10px;overflow:hidden'>
					<p>"                     + currency + String.Format("{0:0.00}", totalPrice) + @"</p> 
					<p>"                     + currency + String.Format("{0:0.00}", postageshipping) + @"</p>   
					<p>"                     + currency + String.Format("{0:0.00}", grandTotal) + @"</p>
				</div>
				<div style='width:60%;float:right;text-align:right;padding-right:10px;overflow:hidden'>
					<p>Subtotal</p>   
					<p>Shipping & Handling</p>   
					<p>Grand Total</p>
				</div>
            </div>
        </div>
        <div style='padding:3%;padding-top: 5px;overflow:hidden'> 
            <div style='width:40%;float: left;'>
                <p style='margin-top:5px;margin-bottom:5px'><b>BILL TO:</b></p>
                <p style='margin-top:3px;margin-bottom:0px'>" + invoiceEmail.BuyerAddress.FullName + @"</p>
                <p style='margin-top:3px;margin-bottom:0px'>" + invoiceEmail.BuyerAddress.Address1 + @"</p>
                <p style='margin-top:3px;margin-bottom:0px'> " + invoiceEmail.BuyerAddress.Address2 + @"</p>
                <p style='margin-top:3px;margin-bottom:0px'>" + invoiceEmail.BuyerAddress.Town + @"</p>
                <p style='margin-top:3px;margin-bottom:0px'> " + invoiceEmail.BuyerAddress.County + @"</p>
                <p style='margin-top:3px;margin-bottom:0px'> " + invoiceEmail.BuyerAddress.PostCode + @"</p>
                <p style='margin-top:3px;margin-bottom:0px'>" + invoiceEmail.BuyerAddress.Country + @"</p>
            </div>
            <div style='width:40%;float:right'>
                <p style='margin-top:5px;margin-bottom:5px'><b>SHIP TO:</b></p>
                <p style='margin-top:3px;margin-bottom:0px'>" + invoiceEmail.PosttoAddress.FullName + @"</p>
                <p style='margin-top:3px;margin-bottom:0px'>" + invoiceEmail.PosttoAddress.Address1 + @"</p>
                <p style='margin-top:3px;margin-bottom:0px'> " + invoiceEmail.PosttoAddress.Address2 + @"</p>
                <p style='margin-top:3px;margin-bottom:0px'>" + invoiceEmail.PosttoAddress.Town + @"</p>
                <p style='margin-top:3px;margin-bottom:0px'> " + invoiceEmail.PosttoAddress.County + @"</p>
                <p style='margin-top:3px;margin-bottom:0px'> " + invoiceEmail.PosttoAddress.PostCode + @"</p>
                <p style='margin-top:3px;margin-bottom:0px'>" + invoiceEmail.PosttoAddress.Country + @"</p>
            </div>
        </div>
        <div style='padding-left:20px;padding-right:20px'> 
            <div style='width:40%;float: left;'>
                <p style='margin-top:5px;margin-bottom:5px'><b>SHIPPING METHOD:</b></p>
                <pstyle='margin-top:3px;margin-bottom:0px'>Select shipping method: " + invoiceEmail.Sale.DeliveryService + @"</p>
            </div>
            <div style='width:40%;float:right'>
                <p style='margin-top:5px;margin-bottom:5px'><b>PAYMENT METHOD:</b></p>
                <pstyle='margin-top:3px;margin-bottom:0px'>" + invoiceEmail.Sale.PaymentMethod + @"</p>
            </div>
        </div>
    </div>
    <div style='text-align: center;padding-top: 15px;font-size: 20px;'>
        Thank You, DealsDeals
    </div>
</div>";

            return(body);
        }
コード例 #12
0
        public async Task CanRaiseInvoiceAndBankExplanation()
        {
            // Create a random contact:
            var source  = Helper.NewContact();
            var contact = await this.Client.CreateContactAsync(source);

            Assert.NotNull(contact.Url);

            // Create an invoice for this contact
            var items = new List <InvoiceItem>
            {
                new InvoiceItem()
                {
                    ItemType     = InvoiceItemType.NoUnit,
                    Price        = 100,
                    Description  = "Some things",
                    Quantity     = 100,
                    SalesTaxRate = 20
                }
            };

            var invoice = new Invoice
            {
                Contact            = contact.Url,
                DatedOn            = DateTime.Now.AddDays(-1),
                DueOn              = DateTime.Now.AddDays(1),
                PaymentTermsInDays = 25,
                InvoiceItems       = items,
                Currency           = "GBP",
                Comments           = "Thanks, all done."
            };

            try
            {
                invoice = await this.Client.CreateInvoice(invoice);
            }
            catch (FreeAgentException e)
            {
                Console.WriteLine(e.InnerException.ToString());
            }
            Assert.NotNull(invoice.Url);

            // Now we need to create an email for the invoice
            var email = new InvoiceEmail
            {
                Email =
                    new InvoiceEmailDetail
                {
                    Body    = "Hello there, here you are.",
                    Subject = "Your invoice",
                }
            };

            await this.Client.CreateInvoiceEmail(invoice.GetId(), email);

            var bankAccount = await Client.GetBankAccountsAsync();

            // Create a bank account explanation for the new invoice now.
            var explanation = new BankTransactionExplanation
            {
                BankAccount          = bankAccount.First().Url,
                DatedOn              = DateTime.Now,
                PaidInvoice          = invoice.Url,
                GrossValue           = invoice.TotalValue,
                ForeignCurrencyValue = 0
            };

            explanation = await this.Client.CreateBankTransactionExplanationAsync(explanation);

            Assert.NotNull(explanation.Url);

            // And for my final trick, I shall now get the PDF of that invoice.
            var pdf = await this.Client.GetInvoicePdfAsync(invoice.GetId());

            Assert.NotNull(pdf?.Content);
        }
コード例 #13
0
 public async Task UpdateEmailNotificationsForAccount(InvoiceEmail invoiceEmail, RequestOptions inputOptions)
 {
     await _notificationManager.UpdateEmailNotificationsForAccount(invoiceEmail, inputOptions);
 }