public void test_line_starts_with_on() { var msg_body = @"Blah-blah-blah On blah-blah-blah"; Quotations.ExtractFromPlain(msg_body).ShouldBe(msg_body); }
protected override void WriteElement(XElement command) { if (AllTrades != null && 0 < AllTrades.Count()) { var trades = new XElement("alltrades"); command.Add(trades); foreach (var id in AllTrades) { trades.Add(new XElement("secid", id)); } } if (Quotations != null && 0 < Quotations.Count()) { var quotations = new XElement("quotations"); command.Add(quotations); foreach (var id in Quotations) { quotations.Add(new XElement("secid", id)); } } if (Quotes != null && 0 < Quotes.Count()) { var quotes = new XElement("quotes"); command.Add(quotes); foreach (var id in Quotes) { quotes.Add(new XElement("secid", id)); } } }
public void test_link_breaks_quotation_markers_sequence() { // link starts and ends on the same line var msg_body = @"Blah On Thursday, October 25, 2012 at 3:03 PM, life is short. on Bob wrote: > > Post a response by replying to this email > (http://example.com/c/YzOTYzMmE) > > life is short. (http://example.com/c/YzMmE) > "; Quotations.ExtractFromPlain(msg_body).ShouldBe("Blah"); // link starts after some text on one line and ends on another msg_body = @"Blah On Monday, 24 September, 2012 at 3:46 PM, bob wrote: > [Ticket #50] test from bob > > View ticket (http://example.com/action _nonce=3dd518) > "; Quotations.ExtractFromPlain(msg_body).ShouldBe("Blah"); }
public void test_reply_and_quotation_splitter_share_line() { // reply lines and 'On <date> <person> wrote:' splitter pattern //# are on the same line var msg_body = @"reply On Wed, Apr 4, 2012 at 3:59 PM, [email protected] wrote: > Hi"; Quotations.ExtractFromPlain(msg_body).ShouldBe("reply"); // test pattern '--- On <date> <person> wrote:' with reply text on // the same line msg_body = @"reply--- On Wed, Apr 4, 2012 at 3:59 PM, [email protected] wrote: > Hi"; Quotations.ExtractFromPlain(msg_body).ShouldBe("reply"); // test pattern '--- On <date> <person> wrote:' with reply text containing // '-' symbol msg_body = @"reply bla-bla - bla--- On Wed, Apr 4, 2012 at 3:59 PM, [email protected] wrote: > Hi"; var reply = @"reply bla-bla - bla"; Quotations.ExtractFromPlain(msg_body).ShouldBe(reply); }
public void test_preprocess_1() { var msg = "Hello\n" + "See <http://google.com\n" + "> for more\n" + "information On Nov 30, 2011, at 12:47 PM, Somebody <\n" + "416ffd3258d4d2fa4c85cfa4c44e1721d66e3e8f4\n" + "@example.com>" + "wrote:\n" + "\n" + "> Hi"; // test the link is rewritten // "On <date> <person> wrote:" pattern starts from a new line var prepared_msg = "Hello\n" + "See @@http://google.com\n" + "@@ for more\n" + "information\n" + " On Nov 30, 2011, at 12:47 PM, Somebody <\n" + "416ffd3258d4d2fa4c85cfa4c44e1721d66e3e8f4\n" + "@example.com>" + "wrote:\n" + "\n" + "> Hi"; Quotations.Preprocess(msg, "\n").ShouldBe(prepared_msg); }
public async Task <ActionResult> PostAsync(Quotation model) { if (!this.ModelState.IsValid) { return(this.InvalidModelState(this.ModelState)); } var meta = await AppUsers.GetCurrentAsync().ConfigureAwait(true); model.UserId = meta.UserId; model.OfficeId = meta.OfficeId; model.AuditUserId = meta.UserId; model.AuditTs = DateTimeOffset.UtcNow; model.TransactionTimestamp = DateTimeOffset.UtcNow; try { long tranId = await Quotations.PostAsync(this.Tenant, model).ConfigureAwait(true); return(this.Ok(tranId)); } catch (Exception ex) { return(this.Failed(ex.Message, HttpStatusCode.InternalServerError)); } }
public void test_quotation_marker_false_positive() { var msg_body = @"Visit us now for assistance... >>> >>> http://www.domain.com <<< Visit our site by clicking the link above"; Quotations.ExtractFromPlain(msg_body).ShouldBe(msg_body); }
public void test_process_marked_lines_3() { // text after splitter without markers is quotation var markers = "tst".ToCharArray(); var lines = new[] { "1", "2", "3" }; Quotations.ProcessMarkedLines(lines, markers).Lines.ShouldBe(new[] { "1" }); }
public void test_process_marked_lines_2() { // no splitter => no markers var markers = "tmm".ToCharArray(); var lines = new[] { "1", "2", "3" }; Quotations.ProcessMarkedLines(lines, markers).Lines.ShouldBe(lines); }
public void test_process_marked_lines_5() { // message + <quotation without markers> + nested quotation var markers = "tstsmt".ToCharArray(); var lines = new[] { "1", "2", "3", "4", "5", "6" }; Quotations.ProcessMarkedLines(lines, markers).Lines.ShouldBe(new[] { "1" }); }
public void test_process_marked_lines_4() { // message + quotation + signature var markers = "tsmt".ToCharArray(); var lines = new[] { "1", "2", "3", "4" }; Quotations.ProcessMarkedLines(lines, markers).Lines.ShouldBe(new[] { "1", "4" }); }
public List <Quotation> GetLastDayQuotations(DateTime dateTime) { var previousDay = dateTime.DayOfWeek == DayOfWeek.Sunday ? dateTime.AddDays(-2).Date : (dateTime.DayOfWeek == DayOfWeek.Monday ? dateTime.AddDays(-3) : dateTime.AddDays(-1)); return(Quotations.Where(x => x.Time.Day == previousDay.Date.Day).ToList()); }
private void btn_add_Click(object sender, EventArgs e) { String name = cmb_in.SelectedItem.ToString(); Quotations sas = new Quotations(); DataTable dt = sas.addQuot(name); dataGridView1.DataSource = dt; }
public OperationsStatus InsertQuotations(Quotations quotationsObj) { OperationsStatus operationsStatusObj = new OperationsStatus(); try { SqlParameter statusCode = null; using (SqlConnection con = _databaseFactory.GetDBConnection()) { using (SqlCommand cmd = new SqlCommand()) { if (con.State == ConnectionState.Closed) { con.Open(); } cmd.Connection = con; cmd.CommandText = "[InsertQuotations]"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@QuotationDate", SqlDbType.SmallDateTime).Value = quotationsObj.logDetails.CreatedDate; cmd.Parameters.Add("@ProductID", SqlDbType.Int).Value = quotationsObj.ProductID; cmd.Parameters.Add("@CustomerID", SqlDbType.Int).Value = quotationsObj.CustomerID; cmd.Parameters.Add("@RequiredDate", SqlDbType.SmallDateTime).Value = quotationsObj.RequiredDate; cmd.Parameters.Add("@SourceIP", SqlDbType.NVarChar, 50).Value = quotationsObj.SourceIP; cmd.Parameters.Add("@Message", SqlDbType.NVarChar, -1).Value = quotationsObj.Message; cmd.Parameters.Add("@ProductSpecXML", SqlDbType.Xml).Value = _attributesRepository.GetAttributeXML(quotationsObj.AttributeValues); cmd.Parameters.Add("@CreatedBy", SqlDbType.NVarChar, 250).Value = quotationsObj.logDetails.CreatedBy; cmd.Parameters.Add("@CreatedDate", SqlDbType.SmallDateTime).Value = quotationsObj.logDetails.CreatedDate; statusCode = cmd.Parameters.Add("@StatusOut", SqlDbType.SmallInt); statusCode.Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); switch (statusCode.Value.ToString()) { case "0": operationsStatusObj.StatusCode = Int16.Parse(statusCode.Value.ToString()); operationsStatusObj.StatusMessage = constObj.InsertFailure; break; case "1": operationsStatusObj.StatusCode = Int16.Parse(statusCode.Value.ToString()); operationsStatusObj.StatusMessage = constObj.InsertSuccess; break; default: break; } } } } catch (Exception ex) { throw ex; } return(operationsStatusObj); }
public void test_from_block_starts_with_date() { var msg_body = @"Blah Date: Wed, 16 May 2012 00:15:02 -0600 To: [email protected]"; Quotations.ExtractFromPlain(msg_body).ShouldBe("Blah"); }
public void test_pattern_date_email_with_unicode() { var msg_body = @"Replying ok 2011/4/7 Nathan \xd0\xb8ova <*****@*****.**> > Cool beans, scro"; Quotations.ExtractFromPlain(msg_body).ShouldBe("Replying ok"); }
public void test_process_marked_lines_1() { // quotations and last message lines are mixed // consider all to be a last message var markers = "tsemmtetm".ToCharArray(); var lines = Enumerable.Range(1, markers.Length).Select(i => i.ToString()).ToArray(); Quotations.ProcessMarkedLines(lines, markers).Lines.ShouldBe(lines); }
private void DeleteQuotation() { if (SelectedQuotation != null) { _unitOfWork.QuotationRepository.Delete(SelectedQuotation.QuotationModel); _unitOfWork.Save(); Quotations.Remove(SelectedQuotation); } }
public void test_short_quotation() { var msg_body = @"Hi On 04/19/2011 07:10 AM, Roman Tkachenko wrote: > Hello"; Quotations.ExtractFromPlain(msg_body).ShouldBe("Hi"); }
public void test_reply_after_quotations() { var msg_body = @"On 04/19/2011 07:10 AM, Roman Tkachenko wrote: > > Test Test reply"; Quotations.ExtractFromPlain(msg_body).ShouldBe("Test reply"); }
public void test_too_many_lines() { var msg_body = "test message" + String.Join("\n", Enumerable.Repeat("line", 1005)) + @" //-----Original Message----- Test"; Quotations.ExtractFromPlain(msg_body).ShouldBe(msg_body); }
public OperationsStatus UpdateQuotations(Quotations quotationsObj) { OperationsStatus operationsStatusObj = new OperationsStatus(); try { SqlParameter outparameter = null; using (SqlConnection con = _databaseFactory.GetDBConnection()) { using (SqlCommand cmd = new SqlCommand()) { if (con.State == ConnectionState.Closed) { con.Open(); } cmd.Connection = con; cmd.CommandText = "[UpdateQuotations]"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ID", SqlDbType.Int).Value = quotationsObj.ID; cmd.Parameters.Add("@Price", SqlDbType.Decimal).Value = quotationsObj.Price; cmd.Parameters.Add("@AdditionalCharges", SqlDbType.Decimal).Value = quotationsObj.AdditionalCharges; cmd.Parameters.Add("@DiscountAmt", SqlDbType.Decimal).Value = quotationsObj.DiscountAmt; cmd.Parameters.Add("@TaxAmt", SqlDbType.Decimal).Value = quotationsObj.TaxAmt; cmd.Parameters.Add("@QuotationStatus", SqlDbType.VarChar, 50).Value = quotationsObj.Status; cmd.Parameters.Add("@UpdatedBy", SqlDbType.NVarChar, 250).Value = quotationsObj.logDetails.UpdatedBy; cmd.Parameters.Add("@UpdatedDate", SqlDbType.SmallDateTime).Value = quotationsObj.logDetails.UpdatedDate; outparameter = cmd.Parameters.Add("@Status", SqlDbType.SmallInt); outparameter.Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); switch (outparameter.Value.ToString()) { case "0": operationsStatusObj.StatusCode = Int16.Parse(outparameter.Value.ToString()); operationsStatusObj.StatusMessage = constObj.UpdateFailure; break; case "1": operationsStatusObj.StatusCode = Int16.Parse(outparameter.Value.ToString()); operationsStatusObj.StatusMessage = constObj.UpdateSuccess; operationsStatusObj.ReturnValues = quotationsObj.ID; break; default: break; } } } } catch (Exception ex) { throw ex; } return(operationsStatusObj); }
public IActionResult UpdateQuotation(Quotations quote) { _quotationRepo.Update(quote); ServiceAndQuotation serviceAndQuotation = new ServiceAndQuotation { Service = _serviceRepo.GetIdBy(quote.ServiceID), Quotation = _quotationRepo.GetAll().Where(a => a.ServiceID == quote.ServiceID).ToList() }; return(View("ShowService", serviceAndQuotation)); }
public IActionResult CreateQuotation(string title, int price, string serviceType) { Quotations quotation = new Quotations(); quotation.Price = price; quotation.QuotationName = title; quotation.ServiceName = serviceType; _quotationRepo.Create(quotation); return(View("Create", _quotationRepo.GetAll().ToList())); }
public void test_process_marked_lines_10() { // inline reply with link wrapped in paranthesis var markers = "tsmtm".ToCharArray(); var lines = new[] { "text", "splitter", ">", "inline reply (http://example.com)", ">" }; Quotations.ProcessMarkedLines(lines, markers).Lines.ShouldBe(lines); }
public void test_preprocess_2() { var msg = @" > <http://teemcl.mailgun.org/u/**aD1mZmZiNGU5ODQwMDNkZWZlMTExNm** > MxNjQ4Y2RmOTNlMCZyPXNlcmdleS5v**YnlraG92JTQwbWFpbGd1bmhxLmNvbS** > Z0PSUyQSZkPWUwY2U<http://example.org/u/aD1mZmZiNGU5ODQwMDNkZWZlMTExNmMxNjQ4Y> "; Quotations.Preprocess(msg, "\n").ShouldBe(msg); }
public void test_pattern_on_date_somebody_wrote_allows_space_in_front() { var msg_body = @"Thanks Thanmai On Mar 8, 2012 9:59 AM, ""Example.com"" < *****@*****.**> wrote: >** > Blah-blah-blah"; Quotations.ExtractFromPlain(msg_body).ShouldBe("Thanks Thanmai"); }
public void test_weird_date_format_in_date_block() { var msg_body = @"Blah Date: Fri=2C 28 Sep 2012 10:55:48 +0000 From: [email protected] To: [email protected] Subject: [Ticket #8] Test "; Quotations.ExtractFromPlain(msg_body).ShouldBe("Blah"); }
public Subscribe Create(bool unsubscribe, AllTrades trades, Quotations quotations, Quotes quotes) { var model = new Subscribe { Id = (unsubscribe) ? CommandNames.Unsubscribe : CommandNames.Subscribe, Trades = trades, Quotations = quotations, Quotes = quotes }; return(model); }
public void test_pattern_on_date_somebody_sent() { var msg_body = @"Test reply On 11-Apr-2011, at 6:54 PM, Roman Tkachenko <*****@*****.**> sent: > > Test > > Roman"; Quotations.ExtractFromPlain(msg_body).ShouldBe("Test reply"); }