private async Task Run(String typeOfTask) { userName = HttpContext.Current.User.Identity.Name; userName = userName.Substring(userName.IndexOf('\\') + 1); ScoringDAL dbAccess = new ScoringDAL(); progress = "Retrieving values from UI..."; try { if (typeOfTask == "History Compare") { DataTable tblCompareIDs = getPrevCompareTable(); String[] processedCompareList = new String[8]; CultureInfo provider = CultureInfo.InvariantCulture; if (tblCompareIDs != null) { foreach (DataRow compareIDRow in tblCompareIDs.Rows) { if (compareIDRow.ItemArray[0].ToString() == Request.Form["rdoCompareID"].ToString()) { String[] datesArray = compareIDRow.ItemArray[2].ToString().Split(new String[] { "vs" }, StringSplitOptions.None); String prevDateTime2 = Convert.ToDateTime(datesArray[0]).ToString("yyyyMMdd_HHmmss"); String currentDateTime2 = Convert.ToDateTime(datesArray[1]).ToString("yyyyMMdd_HHmmss"); compareID = compareIDRow.ItemArray[1] + "_" + prevDateTime2 + "_" + currentDateTime2 + "_" + compareIDRow.ItemArray[3] + "_" + compareIDRow.ItemArray[4] + "_" + compareIDRow.ItemArray[5] + "_" + compareIDRow.ItemArray[6] + "_" + compareIDRow.ItemArray[7]; dbAccess.RefreshData("", "", "", "", "", "", "", "", "", userName, compareID); } } } // compareID = lbCurrentUserGenCIDs.SelectedValue; //Response.Redirect(HttpUtility.HtmlEncode("http://" + Server.MachineName + "/ScoringApp1/ScoringForm.aspx?id=" + compareID), false); } else { String model, version, mode, env, restriction, customer; String previousDate, currentDate; String loadTime = DateTime.Now.ToString(); String prevTime = Convert.ToDateTime(ddlPrevTime.SelectedValue.ToString()).ToString("HHmmss"); String currentTime = Convert.ToDateTime(ddlCurrentTime.SelectedValue.ToString()).ToString("HHmmss"); //Assigning default values for the variables previousDate = (hifPrevDate.Value == "") ? "20130210" : hifPrevDate.Value; currentDate = (hifCurrentDate.Value == "") ? "20130522" : hifCurrentDate.Value; previousDate = cdrPrevDate.SelectedDate.ToString("yyyyMMdd") + "_" + prevTime; currentDate = cdrCurrentDate.SelectedDate.ToString("yyyyMMdd") + "_" + currentTime; model = (hifModel.Value == "") ? "Risk View" : hifModel.Value; version = hifVersion.Value; mode = hifMode.Value; env = hifEnv.Value; restriction = hifRestriction.Value; customer = hifCustomer.Value; userName = HttpContext.Current.User.Identity.Name; userName = userName.Substring(userName.IndexOf('\\') + 1); compareID = model + "_" + previousDate + "_" + currentDate + "_" + version + "_" + mode + "_" + env + "_" + restriction + "_" + customer; Session["compareID"] = compareID; progress = "Running queries to generate data..."; //Task refreshDataTask = dbAccess.RefreshData(previousDate, currentDate, model, version, mode, env, restriction, customer, loadTime, userName, compareID); //await Task.WhenAny(refreshDataTask); dbAccess.RefreshData(previousDate, currentDate, model, version, mode, env, restriction, customer, loadTime, userName, compareID); ////RefreshDataAsync(previousDate, currentDate, tableType); //progress = "Generating Excel..."; ////dbAccess.GenerateExcel(); //summaryPath = (compareID == "") ? "Archive/noCompareID.xlsx" : "Archive/" + compareID + "-Summary.xlsx"; //Task generateSummaryExcelTask = dbAccess.getSummaryReport(summaryPath); //summaryPath = HttpUtility.HtmlEncode("http://" + Server.MachineName + "/ScoringApp1/" + summaryPath); //await Task.WhenAny(generateSummaryExcelTask); ////btnGetSummaryReport.Enabled = true; //progress = "Summary Report Generated!"; //Thread.Sleep(2000); //progress = "Generating Detailed Report..."; //detailedPath = (compareID == "") ? "Archive/noCompareID.xlsx" : "Archive/" + compareID + "-Detailed.xlsx"; //Task generateDetailedExcelTask = dbAccess.getDetailedReport(detailedPath); //detailedPath = HttpUtility.HtmlEncode("http://" + Server.MachineName + "/ScoringApp1/" + detailedPath); //await Task.WhenAny(generateDetailedExcelTask); //progress = "Detailed Report Generated!"; ////Thread.Sleep(5000); //Response.Redirect(HttpUtility.HtmlEncode("http://" + Server.MachineName + "/ScoringApp1/ScoringForm.aspx?id=" + compareID), false); } } catch (Exception ex) { throw ex; } //progress = "Excel Generated"; }
/// <summary> /// main execution code for running the comparisons /// </summary> private void Run(String typeOfTask) { //Current application user name userName = HttpContext.Current.User.Identity.Name; userName = userName.Substring(userName.IndexOf('\\') + 1); ScoringDAL dbAccess = new ScoringDAL(); //changing the progress that is to be displayed on the loading division progress = "Retrieving values from UI..."; try { //if the type of task is to compare based on the previous compareIDs, //then the stored proc is called with just the username and the compareID if (typeOfTask == "History Compare") { //getting all the compareIDs as a list. This list was sent to the //client during page load, as an ajax call from jquery. //When the datatable in prev comparison screen is clicked, //jquery returns the serial number on the grid, through which we fetch the compareID Dictionary<String, String> compareIDs = new Dictionary<String, String>(); compareIDs = dbAccess.getAllExistingCompareIDs(); Int32 compareIDSerial = (hifCompareIDSerial.Value == null) ? 0 : Convert.ToInt32(hifCompareIDSerial.Value); int i = 0; foreach (KeyValuePair<String, String> userCompareIDs in compareIDs) { i = i + 1; if (i == compareIDSerial + 1) { compareID = userCompareIDs.Key; } } //calling DAL method that calls the stored procedure dbAccess.RefreshData("", "", "", "", "", "", "", "", "", userName, compareID); progress = "Results populated in the database. Please refresh the specific excel to see the results."; } else { //this is the case where the user requested that the comparison results be generated at real time //server validation for dates if (!(cdrPrevDate.SelectedDate == Convert.ToDateTime("1/1/0001 12:00:00 AM") || cdrCurrentDate.SelectedDate == Convert.ToDateTime("1/1/0001 12:00:00 AM"))) { String model, version, mode, env, restriction, customer; String previousDate, currentDate; String loadTime = DateTime.Now.ToString(); //getting all the required values from the user interface, //that will be passed to the stored proc at the backend String prevTime = Convert.ToDateTime(ddlPrevTime.SelectedValue.ToString()).ToString("HHmmss"); String currentTime = Convert.ToDateTime(ddlCurrentTime.SelectedValue.ToString()).ToString("HHmmss"); previousDate = cdrPrevDate.SelectedDate.ToString("yyyyMMdd") + "_" + prevTime; currentDate = cdrCurrentDate.SelectedDate.ToString("yyyyMMdd") + "_" + currentTime; model = (hifModel.Value == "") ? "Risk View" : hifModel.Value; version = hifVersion.Value.Substring(1); mode = hifMode.Value; env = hifEnv.Value; restriction = hifRestriction.Value; customer = hifCustomer.Value; userName = HttpContext.Current.User.Identity.Name; userName = userName.Substring(userName.IndexOf('\\') + 1); //preparing a compareID that is passed to the stored proc compareID = model + "_" + previousDate + "_" + currentDate + "_" + version + "_" + mode + "_" + env + "_" + restriction + "_" + customer; //storing the compareID as a session variable Session["compareID"] = compareID; //changing the display status of the application progress = "Running queries to generate comparison results..."; //calling the DAL method using the parameters passed dbAccess.RefreshData(previousDate, currentDate, model, version, mode, env, restriction, customer, loadTime, userName, compareID); //updating the display status progress = "Results populated in the database. Please refresh the specific excel to see the results."; } else { //error while validating the calendar dates progress = "Please enter the values for all the previous and current comparison dates"; } } } catch (Exception ex) { throw ex; } }