خرید بک لینک

Vote count: 0

I am ruing a small app in sharepoint that produces the data needed for someone in our company. In short it pulls data from an Azure database into a datatable, and then converts that datatable to excel. This can take about a minute or two and sometimes, because we are in New Zealand and are using a remote server in the USA, they get timeouts and one of the worksheets won't load.

So what it does when it builds the excel is it iterates through a list of suppliers, and a list of financial weeks getting the data for each and creating a seperate worksheet in excel per datatable. Ideally, what I would like would be to add a new row to a grid view that the user sees, as the report is been built, stating whether that financial week and supplier was successfully added, or not, as the excel report is creating in the backend. This would allow the user to be more aware of the progress, and allow them to know if there has been a problem rather than guessing.

It's a lot of code so I will try to show you the relevant parts.

Method that pulls and creates excel

    public void excelThreadCall()
    {
        DataTable updateDataTable = new DataTable();
        gridView.DataSource = updateDataTable;
        //Payments only download chosen Financial Week
        using (XLWorkbook workbook = new XLWorkbook())
        {
            //gradeWeek = selectedGradeWeek.SelectedValue;
            foreach (ListItem supplier in selectedSuppliers.Items)
            {
                if (supplier.Selected)
                {
                    foreach (ListItem fWeek in selectedfWeeks.Items)
                    {
                        if (fWeek.Selected)
                        {
                            string checkEmptyTableSQL = @"SELECT COUNT(*) FROM FleshvGraded WHERE Supplier_Code = '" + supplier.Value + "' AND PO_Revision = " + fWeek.Value;
                            int rowCount = Convert.ToInt32(getVariable(checkEmptyTableSQL));

                            if (rowCount > 0)
                            {

                                foreach (ListItem report in selectedReports.Items)
                                {
                                    //SQL Strings
                                    string sqlIntakeDate = @"SELECT Week_Ending_Date FROM Fiscal_Calendar WHERE Fiscal_Week = LEFT(" + fWeek + ", 2) AND Fiscal_Year = CONCAT(20, RIGHT(" + fWeek + ", 2))";
                                    string sqlPO = @"SELECT DISTINCT PO_No FROM FvGSummaryAll WHERE Supplier_Code = '" + supplier.Value + "' AND f_Week = " + fWeek.Value;
                                    string sqlAllSerials = "SELECT * FROM FvGData WHERE Supplier_Code = '" + supplier.Value + "' AND Kill_Week = " + killWeek.Value

                                    //variables
                                    DateTime weekEnding = Convert.ToDateTime(getVariable(sqlIntakeDate));
                                    DateTime weekStarting = weekEnding.AddDays(-5);
                                    string fWeekString = fWeek.ToString();
                                    string poNoString = getVariable(sqlPO).ToString();
                                    string intakeDateString = weekStarting.Day + "/" + weekStarting.Month + "/" + weekStarting.Year + " to " + weekEnding.Day + "/" + weekEnding.Month + "/" + weekEnding.Year;

                                    //adds summary variables to dictionary
                                    Dictionary<string, string> summaryVariablesDict = new Dictionary<string, string>();
                                    summaryVariablesDict.Add("f Week", fWeekString);
                                    //other values added to Dict

                                    //Adds WorkSheets based on above data
                                    if (report.Selected && report.Value.Equals("allserials"))
                                    {
                                        string worksheetName = supplier.Value + " Data " + fWeek.Value;
                                        DataTable dataTable = getDataTable(sqlAllSerials);
                                        createWorkSheet(workbook, worksheetName, dataTable);
                                    }
                                    //Other Reports follow

                                    **//what I hope to do - need this to show in the grid view immediatley not end of method
                                    updateDataTable.Rows.Add(suppler, fweek, "successful");
                                    gridView.DataBind();**

                                }
                            }
                        }
                    }
                }
            }
            workbook.SaveAs(filePath);
        }
    }

So currently this exists in another class but it's no problem for me to move it to the aspx page, and so I have taken liberties to just show you what I need to do in this method. So if it doesn't make complete sense in that respect (i.e. I wouldn't declare the datasource for the grid in the method normally).

The problem I have is that it will wait until the end of the method before updating the grid view via the postback and then the user gets it all at once. I was hoping there is a way to update the gridview at each iteration or even every few seconds if we use a timer, but can't find a way to implement this.

So long story short, how can I update the gridview from this method where the results appear immediately on the users UI, and not wait until the end of the method.

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 1 ارديبهشت 1395 ساعت: 4:44

صفحه بندی