public QuoteObject getInvoice(string subject) { WebRequest req = HttpWebRequest.Create("https://webshockinnovations.com/invoiceapi/api.php?getinvoice=true&subject=" + subject); WebResponse res = req.GetResponse(); StreamReader reader = new StreamReader(res.GetResponseStream()); string json = reader.ReadToEnd(); List <QuoteObject> invoices = Newtonsoft.Json.JsonConvert.DeserializeObject <List <QuoteObject> >(json); QuoteObject invoice = invoices[0]; return(invoice); }
private static void PopulateDatabase(QuotableContext context) { var author1 = new AuthorObject() { FirstName = "Hermione", LastName = "Granger" }; var author2 = new AuthorObject() { FirstName = "Albus", LastName = "Dumbledore" }; var author3 = new AuthorObject() { FirstName = "Harry", LastName = "Potter" }; var quote1 = new QuoteObject(); quote1.Quote = "Fear of a name only increases fear of the thing itself."; var quote2 = new QuoteObject(); quote2.Quote = "It is our choices, Harry, that show what we truly are, far more than our abilities."; var quote3 = new QuoteObject(); quote3.Quote = "I solemnly swear I am up to no good."; var qa1 = new QuotesAndAuthorsObject() { Quote = quote1, Author = author1 }; var qa2 = new QuotesAndAuthorsObject() { Quote = quote2, Author = author2 }; var qa3 = new QuotesAndAuthorsObject() { Quote = quote3, Author = author3 }; context.AddRange(qa1, qa2, qa3); context.SaveChanges(); }
public IEnumerable <QuoteObject> GetQuote(int QuoteHeaderID) { var quotes = new List <QuoteObject>(); using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SSIRentConnectionString"].ConnectionString)) using (SqlCommand command = connection.CreateCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "sp_Quotes_rptQuote"; command.Parameters.AddWithValue("@QuoteHeaderID", QuoteHeaderID); command.Connection.Open(); using (SqlDataReader dr = command.ExecuteReader()) { while (dr.Read()) { var quote = new QuoteObject { Number = dr["QuoteNumber"].ToString(), Date = dr["QuoteDate"].ToString(), Status = dr["ApprovalStatus"].ToString(), Type = dr["ClassificationType"].ToString(), ItemDescription = dr["ItemDescription"].ToString(), OrderedBy = dr["Ordered by"].ToString(), Dispatcher = dr["Name"].ToString(), PONumber = dr["PONumber"].ToString(), JobNumber = dr["JobNumber"].ToString(), OrderNumber = dr["OrderNumber"].ToString(), InvoiceTo = dr["Customer"].ToString(), ShipVia = dr["ShipVia"].ToString(), ShipTo = dr["Shipto"].ToString(), Lease = dr["LeaseOCSG"].ToString(), AFE = dr["AFE"].ToString(), Area = dr["AreaBlock"].ToString(), RigNum = dr["RigNo"].ToString(), WellNum = dr["WellNo"].ToString(), State = dr["State"].ToString(), Parish = dr["Parish"].ToString(), JobType = dr["JobType"].ToString(), Contractor = dr["Contractor"].ToString(), Quantity = dr["Quantity"] == DBNull.Value ? 0 : Convert.ToInt32(dr["Quantity"]), MinRentalDays = dr["MinimumRentalDays"] == DBNull.Value ? 0 : Convert.ToInt32(dr["MinimumRentalDays"]), NetAddDay = dr["NetAddDay"] == DBNull.Value ? 0 : Convert.ToDouble(dr["NetAddDay"]), NetMin = dr["NetMin"] == DBNull.Value ? 0 : Convert.ToDouble(dr["NetMin"]), DiscountRate = (Math.Round(Convert.ToDecimal(dr["DiscountRate"]), 2) * 100).ToString() + "%", EstimatedDays = dr["EstimatedDays"] == DBNull.Value ? 0 : Convert.ToInt32(dr["EstimatedDays"]), EstimatedDaysRental = dr["EstimatedDaysRental"] == DBNull.Value ? 0 : Convert.ToDouble(dr["EstimatedDaysRental"]), CalculateEstimatedDays = Convert.ToBoolean(dr["CalculateEstimatedDays"]), CreateUserID = Convert.ToInt32(dr["CreateUserID"]), QuotePriceBook = Convert.ToInt32(dr["QuotePriceBook"]), AlternateCustomerNumber = dr["AlternateCustomerNumber"].ToString(), AlternateJobType = dr["AlternateJobType"].ToString(), HasDiscrepancyReport = dr["HasDiscrepancyReport"] == DBNull.Value ? false : Convert.ToBoolean(dr["HasDiscrepancyReport"]), Salesmen = GetSalesmen(QuoteHeaderID), Revision = dr["RevisionCount"].ToString() }; quotes.Add(quote); } } return(quotes); } }
public Task <QuoteObject> UpdateQuoteAsync(QuoteObject task) { throw new NotImplementedException(); }
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Literal dispatcher = (Literal)repeater1.Controls[0].Controls[0].FindControl("dispatcher"); Literal invoiceTo = (Literal)repeater1.Controls[0].Controls[0].FindControl("invoiceTo"); Literal orderedby = (Literal)repeater1.Controls[0].Controls[0].FindControl("orderedby"); Literal ponumber = (Literal)repeater1.Controls[0].Controls[0].FindControl("ponumber"); Literal jobnumber = (Literal)repeater1.Controls[0].Controls[0].FindControl("jobnumber"); Literal ordernumber = (Literal)repeater1.Controls[0].Controls[0].FindControl("ordernumber"); Literal shipvia = (Literal)repeater1.Controls[0].Controls[0].FindControl("shipvia"); Literal shipto = (Literal)repeater1.Controls[0].Controls[0].FindControl("shipto"); Literal lease = (Literal)repeater1.Controls[0].Controls[0].FindControl("lease"); Literal date = (Literal)repeater1.Controls[0].Controls[0].FindControl("date"); // Literal status = (Literal)repeater1.Controls[0].Controls[0].FindControl("status"); Literal afe = (Literal)repeater1.Controls[0].Controls[0].FindControl("afe"); Literal area = (Literal)repeater1.Controls[0].Controls[0].FindControl("area"); Literal rig = (Literal)repeater1.Controls[0].Controls[0].FindControl("rig"); Literal well = (Literal)repeater1.Controls[0].Controls[0].FindControl("well"); Literal state = (Literal)repeater1.Controls[0].Controls[0].FindControl("state"); Literal parish = (Literal)repeater1.Controls[0].Controls[0].FindControl("parish"); Literal jobtype = (Literal)repeater1.Controls[0].Controls[0].FindControl("jobtype"); Literal contractor = (Literal)repeater1.Controls[0].Controls[0].FindControl("contractor"); Literal priceStrategy = (Literal)repeater1.Controls[0].Controls[0].FindControl("priceStrategy"); Literal alternateJobType = (Literal)repeater1.Controls[0].Controls[0].FindControl("ajobtype"); Literal ajobtypeTitle = (Literal)repeater1.Controls[0].Controls[0].FindControl("ajobtypeTitle"); Label QuoteNum = (Label)repeater1.Controls[0].Controls[0].FindControl("LabelQuoteNumber"); Label Revision = (Label)repeater1.Controls[0].Controls[0].FindControl("LabelRevision"); Label LabelStatus = (Label)repeater1.Controls[0].Controls[0].FindControl("LabelStatus"); Literal Salesmen = (Literal)repeater1.Controls[0].Controls[0].FindControl("Salesmen"); dynamic dataitem = e.Item.DataItem as dynamic; QuoteObject q = (QuoteObject)dataitem; if (fixheaderonce == 0) //don't need to run this code evertime hence the variable fixheaderonce { dispatcher.Text = q.Dispatcher; invoiceTo.Text = q.InvoiceTo; orderedby.Text = q.OrderedBy; ponumber.Text = q.PONumber; jobnumber.Text = q.JobNumber; ordernumber.Text = q.OrderNumber; shipvia.Text = q.ShipVia; shipto.Text = q.ShipTo; lease.Text = q.Lease; date.Text = q.Date; // status..Text = q.Status; afe.Text = q.AFE; area.Text = q.Area; rig.Text = q.RigNum; well.Text = q.WellNum; state.Text = q.State; parish.Text = q.Parish; jobtype.Text = q.JobType; contractor.Text = q.Contractor; Salesmen.Text = q.Salesmen.TrimEnd(','); if (q.QuotePriceBook == 1) { priceStrategy.Text = "Supreme Book Pricing"; } if (q.QuotePriceBook == 2) { priceStrategy.Text = "Customer Pricing"; } if (q.QuotePriceBook == 3) { alternateJobType.Text = q.AlternateJobType; ajobtypeTitle.Text = "Alternate Job Type:"; priceStrategy.Text = "Alternate Customer - " + q.AlternateCustomerNumber; } QuoteNum.Text = q.Number; Revision.Text = q.Revision; CreateUserID = q.CreateUserID; QuoteStatus = q.Status; HasDiscrepancyReport = q.HasDiscrepancyReport; EstDays = q.EstimatedDays; EstDaysRental = q.EstimatedDaysRental; CalculateEstimatedDays = q.CalculateEstimatedDays; LabelStatus.Text = q.Status; fixheaderonce = 2; CheckBox hCheckBox1 = (CheckBox)repeater1.Controls[0].Controls[0].FindControl("CheckBox1"); Panel PanelDiscrep = (Panel)repeater1.Controls[0].Controls[0].FindControl("PanelDiscrep"); if (q.HasDiscrepancyReport) { PanelDiscrep.Visible = true; } } Literal PrintType = (Literal)e.Item.FindControl("PrintType"); if (q.Type != currentPrintType) { PrintType.Text = q.Type; if (currentPrintType != "") { //Get Previous Items Controls int pIndex = e.Item.ItemIndex - 1; RepeaterItem previousItem = (RepeaterItem)repeater1.Items[pIndex]; Panel PanelTotals = (Panel)previousItem.FindControl("PanelTotals"); Literal TypeTotal = (Literal)previousItem.FindControl("LiteralTypeTotal"); Literal MinTotal = (Literal)previousItem.FindControl("MinTotal"); Literal AddDayTotal = (Literal)previousItem.FindControl("AddDayTotal"); PanelTotals.Visible = true; TypeTotal.Text = currentPrintType + " Total:"; MinTotal.Text = string.Format("{0:C}", min); AddDayTotal.Text = string.Format("{0:C}", addday); finalMin += min; finalAddDay += addday; min = 0; addday = 0; } min = min + q.NetMin; addday = addday + q.NetAddDay; currentPrintType = q.Type; } else { min = min + q.NetMin; addday = addday + q.NetAddDay; PrintType.Visible = false; } } if (e.Item.ItemType == ListItemType.Footer) { //-----------------------------------Final SubTotal-------------------------------- int pindex = repeater1.Items.Count - 1; RepeaterItem LastItem = (RepeaterItem)repeater1.Items[pindex]; Panel PanelTotals = (Panel)LastItem.FindControl("PanelTotals"); //CheckBox CheckBox1 = (CheckBox)LastItem.FindControl("CheckBox1"); CheckBox CheckBox1 = (CheckBox)repeater1.Controls[repeater1.Controls.Count - 1].Controls[0].FindControl("CheckBox1"); Literal TypeTotal = (Literal)LastItem.FindControl("LiteralTypeTotal"); Literal MinTotal = (Literal)LastItem.FindControl("MinTotal"); Literal AddDayTotal = (Literal)LastItem.FindControl("AddDayTotal"); PanelTotals.Visible = true; TypeTotal.Text = currentPrintType + " Total:"; MinTotal.Text = string.Format("{0:C}", min); AddDayTotal.Text = string.Format("{0:C}", addday); finalMin += min; finalAddDay += addday; ((Label)e.Item.FindControl("LabelTotalMin")).Text = string.Format("{0:C}", finalMin); ((Label)e.Item.FindControl("LabelTotalAddDay")).Text = string.Format("{0:C}", finalAddDay); Panel PanelButtons = (Panel)e.Item.FindControl("PanelButtons"); Panel PanelDiscrep = (Panel)e.Item.FindControl("PanelDiscrep"); Panel PanelEstDays = (Panel)e.Item.FindControl("PanelEstDays"); if (CreateUserID != Convert.ToInt32(Session["UserID"]) && HasDiscrepancyReport) { //Don'te show Approve / Reject buttons yet until after discrep acknowledgement has been made PanelDiscrep.Visible = true; if (QuoteStatus != "Pending Approval") { CheckBox1.Visible = false; } } else { if (CreateUserID != Convert.ToInt32(Session["UserID"]) && QuoteStatus == "Pending Approval") { PanelButtons.Visible = true; if (Session["DisAck"] != null) { PanelDiscrep.Visible = true; CheckBox1.Enabled = false; } } } if (CalculateEstimatedDays) { PanelEstDays.Visible = true; ((Label)e.Item.FindControl("LabelEstDays")).Text = EstDays.ToString(); ((Label)e.Item.FindControl("LabelDaysRental")).Text = string.Format("{0:C}", EstDaysRental); } min = 0; addday = 0; } }
private bool ProcessDialogRequest(SkillRequest input, SkillResponse response) { var intentRequest = input.Request; string speech_message = string.Empty; bool processed = false; switch (intentRequest.Intent.Name) { case "GetClientInvoice": speech_message = GetClientInfo(intentRequest); WebRequest req = HttpWebRequest.Create("https://webshockinnovations.com/invoiceapi/api.php?name=" + speech_message); WebResponse res = req.GetResponse(); StreamReader reader = new StreamReader(res.GetResponseStream()); string json = reader.ReadToEnd(); List <InvoiceObject> invoices = Newtonsoft.Json.JsonConvert.DeserializeObject <List <InvoiceObject> >(json); InvoiceObject invoice = invoices[0]; speech_message = "There are " + invoices.Count.ToString() + " invoices " + invoice.customer_name + " at company " + invoice.customer_company_name; if (!string.IsNullOrEmpty(speech_message)) { response.Response.OutputSpeech = new SsmlOutputSpeech(); (response.Response.OutputSpeech as SsmlOutputSpeech).Ssml = SsmlDecorate(speech_message); } processed = true; break; case "Help": speech_message = "With this skill you can add customers, companies, and create invoices. Say customer help, company help, and invoice help to learn how to do each."; if (!string.IsNullOrEmpty(speech_message)) { response.Response.OutputSpeech = new SsmlOutputSpeech(); (response.Response.OutputSpeech as SsmlOutputSpeech).Ssml = SsmlDecorate(speech_message); } processed = true; break; case "CustomerHelp": speech_message = "Say get customers to see all customers. To add a new customer, say New customer {customer_name} with email {customer_email} and company {customer_company_name} with phone {customer_phone_number} and address {customer_street_address}"; if (!string.IsNullOrEmpty(speech_message)) { response.Response.OutputSpeech = new SsmlOutputSpeech(); (response.Response.OutputSpeech as SsmlOutputSpeech).Ssml = SsmlDecorate(speech_message); } processed = true; break; case "CompanyHelp": speech_message = "Say get companies to see all companies. To add a new company, say new company {company_name} with email {email} and phone {phone_number} with address {street_address}"; if (!string.IsNullOrEmpty(speech_message)) { response.Response.OutputSpeech = new SsmlOutputSpeech(); (response.Response.OutputSpeech as SsmlOutputSpeech).Ssml = SsmlDecorate(speech_message); } processed = true; break; case "InvoiceHelp": speech_message = "Say get invoice of {customer} to get invoices for a customer. To create an invoice say Create invoice for {customer} with subject {subject} and description {description}. To add a product to an invoice say add {quantity} of {product} at {price} to {subject}"; if (!string.IsNullOrEmpty(speech_message)) { response.Response.OutputSpeech = new SsmlOutputSpeech(); (response.Response.OutputSpeech as SsmlOutputSpeech).Ssml = SsmlDecorate(speech_message); } processed = true; break; case "GetCustomers": WebRequest customerreq = HttpWebRequest.Create("https://webshockinnovations.com/invoiceapi/api.php?getcustomers=true"); WebResponse customerres = customerreq.GetResponse(); StreamReader customerreader = new StreamReader(customerres.GetResponseStream()); string customerjson = customerreader.ReadToEnd(); List <InvoiceObject> customers = Newtonsoft.Json.JsonConvert.DeserializeObject <List <InvoiceObject> >(customerjson); speech_message = "There are " + customers.Count.ToString() + " customers. "; foreach (InvoiceObject customern in customers) { speech_message += customern.customer_name + ", "; } if (!string.IsNullOrEmpty(speech_message)) { response.Response.OutputSpeech = new SsmlOutputSpeech(); (response.Response.OutputSpeech as SsmlOutputSpeech).Ssml = SsmlDecorate(speech_message); } processed = true; break; case "GetCompanies": WebRequest companyreq = HttpWebRequest.Create("https://webshockinnovations.com/invoiceapi/api.php?getcompanies=true"); WebResponse companyres = companyreq.GetResponse(); StreamReader companyreader = new StreamReader(companyres.GetResponseStream()); string companyjson = companyreader.ReadToEnd(); List <CompanyObject> companies = Newtonsoft.Json.JsonConvert.DeserializeObject <List <CompanyObject> >(companyjson); speech_message = "There are " + companies.Count.ToString() + " companies. "; foreach (CompanyObject companyn in companies) { speech_message += companyn.company_name + ", "; } if (!string.IsNullOrEmpty(speech_message)) { response.Response.OutputSpeech = new SsmlOutputSpeech(); (response.Response.OutputSpeech as SsmlOutputSpeech).Ssml = SsmlDecorate(speech_message); } processed = true; break; case "AddClient": speech_message = AddClient(intentRequest); string customer = speech_message; string company_id = "8"; InvoiceObject customerdata = getCustomer(customer); string urlAddress = "https://webshockinnovations.com/invoiceapi/api.php"; Slot departslot; string subject = ""; string description = ""; if (intentRequest.Intent.Slots.TryGetValue("subject", out departslot)) { subject = departslot.Value.ToString(); } if (intentRequest.Intent.Slots.TryGetValue("description", out departslot)) { description = departslot.Value.ToString(); } using (WebClient client = new WebClient()) { NameValueCollection postData = new NameValueCollection() { { "subject", subject }, { "description", description }, { "customer_id", customerdata.id }, { "company_id", company_id }, }; speech_message = "Creating invoice for " + speech_message + " with subject " + subject; // client.UploadValues returns page's source as byte array (byte[]) // so it must be transformed into a string string pagesource = Encoding.UTF8.GetString(client.UploadValues(urlAddress, postData)); } if (!string.IsNullOrEmpty(speech_message)) { response.Response.OutputSpeech = new SsmlOutputSpeech(); (response.Response.OutputSpeech as SsmlOutputSpeech).Ssml = SsmlDecorate(speech_message); } processed = true; break; case "AddCustomer": speech_message = "what"; string addcustomerurl = "https://webshockinnovations.com/invoiceapi/api.php"; Slot addcustomerslot; string customer_company_name = ""; string customer_email = ""; string customer_name = ""; string customer_phone_number = ""; string customer_street_address = ""; if (intentRequest.Intent.Slots.TryGetValue("customer_company_name", out addcustomerslot)) { customer_company_name = addcustomerslot.Value.ToString(); } if (intentRequest.Intent.Slots.TryGetValue("customer_email", out addcustomerslot)) { customer_email = addcustomerslot.Value.ToString(); } if (intentRequest.Intent.Slots.TryGetValue("customer_name", out addcustomerslot)) { customer_name = addcustomerslot.Value.ToString(); } if (intentRequest.Intent.Slots.TryGetValue("customer_phone_number", out addcustomerslot)) { customer_phone_number = addcustomerslot.Value.ToString(); } if (intentRequest.Intent.Slots.TryGetValue("customer_street_address", out addcustomerslot)) { customer_street_address = addcustomerslot.Value.ToString(); } using (WebClient client = new WebClient()) { NameValueCollection postData = new NameValueCollection() { { "add_customer", "true" }, { "customer_company_name", customer_company_name }, { "customer_email", customer_email }, { "customer_name", customer_name }, { "customer_phone_number", customer_phone_number }, { "customer_street_address", customer_street_address }, }; speech_message = "Adding customer " + customer_name; // client.UploadValues returns page's source as byte array (byte[]) // so it must be transformed into a string string pagesource = Encoding.UTF8.GetString(client.UploadValues(addcustomerurl, postData)); } if (!string.IsNullOrEmpty(speech_message)) { response.Response.OutputSpeech = new SsmlOutputSpeech(); (response.Response.OutputSpeech as SsmlOutputSpeech).Ssml = SsmlDecorate(speech_message); } processed = true; break; case "AddCompany": string addcompanyurl = "https://webshockinnovations.com/invoiceapi/api.php"; Slot addcompanyslot; string company_name = ""; string email = ""; string phone_number = ""; string street_address = ""; if (intentRequest.Intent.Slots.TryGetValue("company_name", out addcompanyslot)) { company_name = addcompanyslot.Value.ToString(); } if (intentRequest.Intent.Slots.TryGetValue("email", out addcompanyslot)) { email = addcompanyslot.Value.ToString(); } if (intentRequest.Intent.Slots.TryGetValue("phone_number", out addcompanyslot)) { phone_number = addcompanyslot.Value.ToString(); } if (intentRequest.Intent.Slots.TryGetValue("street_address", out addcompanyslot)) { street_address = addcompanyslot.Value.ToString(); } using (WebClient client = new WebClient()) { NameValueCollection postData = new NameValueCollection() { { "add_company", "true" }, { "company_name", company_name }, { "email", email }, { "phone_number", phone_number }, { "street_address", street_address }, }; speech_message = "Adding company " + company_name; // client.UploadValues returns page's source as byte array (byte[]) // so it must be transformed into a string string pagesource = Encoding.UTF8.GetString(client.UploadValues(addcompanyurl, postData)); } if (!string.IsNullOrEmpty(speech_message)) { response.Response.OutputSpeech = new SsmlOutputSpeech(); (response.Response.OutputSpeech as SsmlOutputSpeech).Ssml = SsmlDecorate(speech_message); } processed = true; break; case "AddProduct": speech_message = AddProduct(intentRequest); string invoice_subject = speech_message; QuoteObject quote = getInvoice(invoice_subject); string url = "https://webshockinnovations.com/invoiceapi/api.php"; Slot slot; string product = ""; string quantity = ""; string price = ""; if (intentRequest.Intent.Slots.TryGetValue("product", out slot)) { product = slot.Value.ToString(); } if (intentRequest.Intent.Slots.TryGetValue("quantity", out slot)) { quantity = slot.Value.ToString(); } if (intentRequest.Intent.Slots.TryGetValue("price", out slot)) { price = slot.Value.ToString(); } using (WebClient client = new WebClient()) { NameValueCollection postData = new NameValueCollection() { { "add_invoice", "true" }, { "product", product }, { "quantity", quantity }, { "price", price }, { "quote_id", quote.id }, }; speech_message = "Adding " + product + " to invoice " + invoice_subject;; // client.UploadValues returns page's source as byte array (byte[]) // so it must be transformed into a string string pagesource = Encoding.UTF8.GetString(client.UploadValues(url, postData)); } if (!string.IsNullOrEmpty(speech_message)) { response.Response.OutputSpeech = new SsmlOutputSpeech(); (response.Response.OutputSpeech as SsmlOutputSpeech).Ssml = SsmlDecorate(speech_message); } processed = true; break; } return(processed); }