static async Task Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var rfqs = QuoteGenerator.GetDemoQuoteStream(totalRfqs: 300, pause: 100, spread: 1500);

            // start background add RFQ's to queue as they come in
            var stream = Task.Run(async() =>
            {
                await foreach (var rfq in rfqs)
                {
                    _rfqs.Enqueue(rfq);
                }
            });

            //_rfqs = new ConcurrentQueue<RFQ>(rfqs);

            // if we get here we are done.

            // print out the grand total.

            // wait for the stream to finish sending us all the quotes

            stream.Wait();

            // need another means of tracking when we're done, possibly  a slimLock
            // so that all threads can finish processing all the quotes.

            while (!_rfqs.IsEmpty)
            {
                // wait for all threads to process all the quotes
            }
        }
예제 #2
0
        // adding rows in invoice products gridview
        private void PopulateProductsGrid(int addRows)
        {
            try
            {
                // get dataset and datable object from cache.
                DataSet data = QuoteGenerator.GetDataSetForGridView(Session);
                if (data != null)
                {
                    // removing all rows in collection
                    data.Tables[0].Rows.Clear();

                    for (int indx = 1; indx <= addRows; indx++)
                    {
                        // Add the temp data row to the tables for each row.
                        data.Tables[0].Rows.Add(indx, "", 0.0, 1, 0.0, 0.0, 0.0, 0.0);
                    }

                    grdInvoiceProducts.DataSource = data;
                    grdInvoiceProducts.DataBind();
                }
            }
            catch (Exception exc)
            {
                lblMessage.Text = exc.Message;
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            string url = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "sample.boo");

            // user needs the vacation module of the application, and has 200 users total.

            var info = new RequirementsInformation(200, "vacations");

            Console.WriteLine("Requesting quote for module \"vacations\" with 200 users\r\n");

            List <SystemModule> modules = QuoteGenerator.Generate(url, info);

            DisplayModuleRequirements(modules);

            Console.WriteLine("\r\nPress enter to exit...");

            Console.ReadLine();
        }
예제 #4
0
        // products gridview row data bound event to populate VAT dropdown list
        protected void grdInvoiceProducts_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    // getting object of VAT dropdown list for each row
                    DropDownList ddlProductVAT = (DropDownList)e.Row.FindControl("ddlProductVAT");

                    // verify dropdown list object is not null
                    if (ddlProductVAT != null)
                    {
                        // call populate VAT dropdown list
                        QuoteGenerator.PopulateVATDropdownList(ref ddlProductVAT, this.Session);
                    }
                }
            }
            catch (Exception exc)
            {
                lblMessage.Text = exc.Message;
            }
        }
예제 #5
0
        private void MergeWithWordTemplate(string templatePath, string outputPath, string imagePath)
        {
            try
            {
                lblMessage.Text = "";

                // Check for license and apply if exists
                string licenseFile = Server.MapPath("~/App_Data/Aspose.Words.lic");
                if (File.Exists(licenseFile))
                {
                    License license = new License();
                    license.SetLicense(licenseFile);
                }

                Document doc = QuoteGenerator.GetUnmergedTemplateObject(templatePath + "MailMerge_Template.doc", Session);
                if (doc != null)
                {
                    // Fill the fields in the document with user data.
                    DataSet data = QuoteGenerator.GetDataSetForGridView(Session);
                    if (data != null)
                    {
                        decimal itemtotalBeforeVAT       = 0;
                        decimal itemtotalVATAmount       = 0;
                        decimal itemtotalAmount          = 0;
                        decimal grandTotalAllItemsAmount = 0;

                        if (grdInvoiceProducts.Rows.Count > 0)
                        {
                            // removing all rows in collection
                            data.Tables[0].Rows.Clear();

                            System.Web.UI.WebControls.TextBox txtProductDescription;
                            System.Web.UI.WebControls.TextBox txtProductPrice;
                            System.Web.UI.WebControls.TextBox txtProductQuantity;
                            DropDownList ddlProductVAT;

                            foreach (GridViewRow gr in grdInvoiceProducts.Rows)
                            {
                                // find control in each gridview rows
                                txtProductDescription = (System.Web.UI.WebControls.TextBox)gr.FindControl("txtProductDescription");
                                txtProductPrice       = (System.Web.UI.WebControls.TextBox)gr.FindControl("txtProductPrice");
                                txtProductQuantity    = (System.Web.UI.WebControls.TextBox)gr.FindControl("txtProductQuantity");
                                ddlProductVAT         = (DropDownList)gr.FindControl("ddlProductVAT");

                                // varify the found controls should not be null
                                if (txtProductDescription != null && txtProductPrice != null && txtProductQuantity != null && ddlProductVAT != null)
                                {
                                    // varify the found controls should not be empty
                                    if (txtProductDescription.Text.Trim() != "" && txtProductPrice.Text.Trim() != "" && txtProductQuantity.Text.Trim() != "" && ddlProductVAT.Items.Count > 0)
                                    {
                                        // actual amount price X quantity
                                        itemtotalBeforeVAT = (decimal.Parse(txtProductPrice.Text.Trim()) * decimal.Parse(txtProductQuantity.Text.Trim()));

                                        // VAT amount = (actual X VAT)/100
                                        itemtotalVATAmount = ((itemtotalBeforeVAT * decimal.Parse(ddlProductVAT.SelectedItem.Value.Trim())) / 100);

                                        // Total amount including VAT
                                        itemtotalAmount           = itemtotalBeforeVAT + itemtotalVATAmount;
                                        grandTotalAllItemsAmount += itemtotalAmount;

                                        // Add the temp data row to the tables for each row.
                                        data.Tables[0].Rows.Add(gr.Cells[0].Text, txtProductDescription.Text.Trim(), decimal.Parse(txtProductPrice.Text.Trim()), decimal.Parse(txtProductQuantity.Text.Trim()), itemtotalBeforeVAT, decimal.Parse(ddlProductVAT.SelectedItem.Value), itemtotalVATAmount, itemtotalAmount);
                                    }
                                }
                            }
                        }

                        if (imagePath != "")
                        {
                            Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
                            if (shape != null)
                            {
                                shape.ImageData.ImageBytes = File.ReadAllBytes(imagePath);
                            }
                        }
                        else
                        {
                            Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
                            if (shape != null)
                            {
                                shape.Remove();
                            }
                        }
                        // updating fix fields using simple aspose mail merge
                        doc.MailMerge.Execute(
                            new string[] { "CompanyName", "CompanyAddress", "CompanyZipState", "CompanyCountry", "CustomerName", "CustomerAddress", "CustomerZipState", "CustomerCountry", "InvoiceTotalAmount", "DocCaption", "DocDate", "DocNo", "DocDescription", "DocTC" },
                            new object[] { txtCompanyName.Text.Trim(), txtCompanyAddress.Text.Trim(), txtCompanyStateZip.Text.Trim(), txtCompanyCountry.Text.Trim(), txtCustomerName.Text.Trim(), txtCustomerAddress.Text.Trim(), txtCustomerStateZip.Text.Trim(), txtCustomerCountry.Text.Trim(), grandTotalAllItemsAmount, txtDocCaption.Text.Trim(), txtDocDate.Text.Trim(), txtDocNo.Text.Trim(), txtDescription.Text.Trim(), txtTC.Text.Trim() });

                        doc.MailMerge.ExecuteWithRegions(data);

                        // removing unused fields in template
                        doc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveEmptyParagraphs | MailMergeCleanupOptions.RemoveContainingFields | MailMergeCleanupOptions.RemoveUnusedFields;

                        // updating document layout, to be cached and re-use
                        doc.UpdatePageLayout();

                        // Saves the document to disk.
                        string fname = System.Guid.NewGuid().ToString() + "." + QuoteGenerator.GetSaveFormat(ExportTypeDropDown.SelectedValue);
                        doc.Save(outputPath + fname);
                        Response.Clear();
                        Response.Buffer = true;
                        Response.AddHeader("content-disposition", "attachment;filename=ExportedFile_" + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Month.ToString() + "_" + DateTime.Now.Year.ToString() + "_" + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + "_" + DateTime.Now.Millisecond.ToString() + "." + QuoteGenerator.GetSaveFormat(ExportTypeDropDown.SelectedValue));
                        Response.Charset     = "";
                        Response.ContentType = "application/pdf";
                        Response.Cache.SetCacheability(HttpCacheability.NoCache);

                        Response.ContentType = "Application/" + QuoteGenerator.GetSaveFormat(ExportTypeDropDown.SelectedValue);
                        //Get the physical path to the file.
                        string FilePath = MapPath(GetDataDir_OutputDocs() + fname);

                        //Write the file directly to the HTTP content output stream.
                        Response.WriteFile(FilePath);
                        Response.Flush();

                        // delete file as its already in stream and available for user to download/save/view.
                        FileInfo file = new FileInfo(FilePath);
                        if (file.Exists)//check file exsit or not
                        {
                            file.Delete();
                        }
                        file = new FileInfo(imagePath);
                        if (file.Exists)//check file exsit or not
                        {
                            file.Delete();
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                lblMessage.Text = exc.Message;
                Response.Clear();
                Response.Flush();
            }
        }