Пример #1
0
    protected void btnDownload_Click(object sender, EventArgs e)
    {
        if (ExportStatistic.IsRun == false)
        {
            ExportStatistic.Init();
            ExportStatistic.IsRun = true;
            linkCancel.Visible    = true;
            OutDiv.Visible        = true;
            btnDownload.Visible   = false;
            try
            {
                // Directory
                FileHelpers.CreateDirectory(_strFilePath);
                ExportStatistic.TotalRow = ProductService.GetProductCountByOffer(6);

                var tr = new Thread(Save);
                ExportStatistic.ThreadImport = tr;
                tr.Start();
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
                lError.Text    = ex.Message;
                lError.Visible = true;
            }
        }
    }
Пример #2
0
 protected void linkCancel_Click(object sender, EventArgs e)
 {
     if (!ExportStatistic.ThreadImport.IsAlive)
     {
         return;
     }
     ExportStatistic.IsRun = false;
     ExportStatistic.Init();
 }
Пример #3
0
    protected void btnDownload_Click(object sender, EventArgs e)
    {
        if (lError.Visible)
        {
            return;
        }

        if (ExportStatistic.IsRun == false)
        {
            divAction.Visible    = false;
            divbtnAction.Visible = false;
            choseDiv.Visible     = false;
            _separator           = (Separators.SeparatorsEnum)Convert.ToInt32(ddlSeparetors.SelectedValue);
            _encoding            = (Encodings.EncodingsEnum)Convert.ToInt32(ddlEncoding.SelectedValue);

            ExportStatistic.Init();
            ExportStatistic.IsRun = true;
            linkCancel.Visible    = true;
            OutDiv.Visible        = true;
            btnDownload.Visible   = false;
            try
            {
                // Directory
                FileHelpers.CreateDirectory(_strFilePath);
                ExportStatistic.TotalRow = ProductService.GetProductsCount();
                var tr = new Thread(Save);
                ExportStatistic.ThreadImport = tr;
                tr.IsBackground = true;
                tr.Start();
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
                MsgErr(ex.Message);
            }
        }
    }
Пример #4
0
    protected void btnDownload_Click(object sender, EventArgs e)
    {
        if (ExportStatistic.IsRun == false)
        {
            List <Order> orders = null;
            orders = chkStatus.Checked ? OrderService.GetOrdersByStatusId(Convert.ToInt32(ddlStatus.SelectedValue)) : OrderService.GetAllOrders();
            if (chkDate.Checked)
            {
                DateTime?d = null;
                try
                {
                    d = DateTime.Parse(txtDateFrom.Text);
                }
                catch (Exception)
                {
                }
                if (d.HasValue)
                {
                    orders.RemoveAll(o => o.OrderDate < d);
                }
                d = null;
                try
                {
                    d = DateTime.Parse(txtDateTo.Text);
                }
                catch (Exception)
                {
                }
                if (d.HasValue)
                {
                    orders.RemoveAll(o => o.OrderDate > d);
                }
            }
            if (orders.Count != 0)
            {
                ExportStatistic.Init();
                ExportStatistic.IsRun    = true;
                ExportStatistic.TotalRow = orders.Count;


                linkCancel.Visible  = true;
                OutDiv.Visible      = true;
                btnDownload.Visible = false;
                pnSearch.Visible    = false;
                try
                {
                    // Directory
                    if (!Directory.Exists(_strFilePath))
                    {
                        Directory.CreateDirectory(_strFilePath);
                    }

                    var tr = new Thread(Save);
                    ExportStatistic.ThreadImport = tr;
                    tr.Start(orders);
                }
                catch (Exception ex)
                {
                    //Debug.LogError(ex, sender, e);
                    Debug.LogError(ex);
                    lError.Text    = ex.Message;
                    lError.Visible = true;
                }
            }
        }
        else
        {
            lError.Visible = true;
            lError.Text    = Resource.Admin_Restrict_Action_In_demo;
        }
    }