/// <summary> /// This method is used when the Administrator clicks the View Recent Reports button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void RecentReportsButton_Click(object sender, EventArgs e) { FilterPOCO filter = new FilterPOCO(); // Create the filter object for adding the filter details filter.startingDate = DateTime.Today.AddDays(-7); // Last 7 days ago filter.endDate = DateTime.Now; // Current time and day filter.siteID = int.Parse(HospitalDDL.SelectedValue); // Retrieve selected site filter.mealID = 0; // Defaults to "All Meals" Session["filter"] = filter; // Create the session to be passed to the SubmittedSurveyList page Response.Redirect("~/Admin/ReportPage.aspx"); // Redirect to the ReportPage with the filter details }
/// <summary> /// Validate if the are correct filter parameters are passed and redirect the administartor to the report page if all the filter is valid. /// </summary> /// <param name="sender">Contains a reference to the control/object that raised the event.</param> /// <param name="e">Contains the event data.</param> protected void ViewButton_Click(object sender, EventArgs e) { // Initialize filter POCO FilterPOCO filter = new FilterPOCO(); // Get the value from the StartingPerioud calendar input string startingPeriodInput = String.Format("{0}", Request.Form["StartingPeriodInput"]); // Check if the starting period is empty or the starting perioud is not a valid date and time format if (startingPeriodInput != "" || DateTime.TryParseExact(startingPeriodInput, "yyyy-MM-dd HH:mm:ss:ffffff", null, System.Globalization.DateTimeStyles.None, out DateTime dateToParse)) { // Get the value from the EndingPeriod calendar input string endingPeriodInput = Request.Form["EndingPeriodInput"]; // Set the filter startingDate filter.startingDate = DateTime.ParseExact(startingPeriodInput + " 00:00:00:000000", "yyyy-MM-dd HH:mm:ss:ffffff", null); // check if the filter date is greate if (filter.startingDate < DateTime.Now) { if (endingPeriodInput != "" || DateTime.TryParseExact(endingPeriodInput, "yyyy-MM-dd HH:mm:ss:ffffff", null, System.Globalization.DateTimeStyles.None, out dateToParse)) { filter.endDate = DateTime.ParseExact(endingPeriodInput + " 23:59:59:999999", "yyyy-MM-dd HH:mm:ss:ffffff", null); if (filter.startingDate <= filter.endDate) { this.startingInputValue = startingPeriodInput; this.endingInputValue = endingPeriodInput; filter.siteID = int.Parse(HospitalDropDownList.SelectedValue); filter.mealID = int.Parse(MealDropDownList.SelectedValue); Alert.Visible = false; Session["filter"] = filter; Response.Redirect("~/Admin/ReportPage.aspx"); } else { Alert.Text = failedHeader + String.Format("Starting date must be before the end date."); Alert.Visible = true; } } else { Alert.Text = failedHeader + "Please select an ending period"; Alert.Visible = true; } } else { Alert.Text = failedHeader + String.Format("Starting date cannot be after today's date."); Alert.Visible = true; } } else { Alert.Text = failedHeader + "Please select a starting period"; Alert.Visible = true; } }
/// <summary> /// When the page loads, first the filter session data is brought in from the previous page and assigned to the FilterPOCO filter object. /// Then this method checks if the admin logged in to access this page, and is redirected to login if not. /// If the filter is null then the admin is redirected back to the previous page to prevent browsing to this page directly with no filter data. /// </summary> /// <param name="sender">Contains a reference to the control/object that raised the event.</param> /// <param name="e">Contains the event data.</param> protected void Page_Load(object sender, EventArgs e) { filter = (FilterPOCO)(Session["filter"]); if (Session["securityID"] == null) // Redirect admin to login if not logged in { Response.Redirect("~/Admin/Login.aspx"); } else if (!IsPostBack) { if (filter == null) // check and redirect to the previous page if the filter is null { Response.Redirect("ViewSurveyFilter.aspx"); } } }
} // this is in order to get and set the end date input text on page reload /// <summary> /// This method is used when the admin clicks on the "View" button to view the individual survey for that particular row in the listview /// </summary> /// <param name="sender">Contains a reference to the control/object that raised the event.</param> /// <param name="e">Contains the event data.</param> protected void ViewButton_Click(object sender, EventArgs e) { MessageUserControl.TryRun(() => { FilterPOCO filter = new FilterPOCO(); // create the filter object for adding the filter details to string startingPeriodInput = Request.Form["StartingPeriodInput"]; string endingPeriodInput = Request.Form["EndingPeriodInput"]; if (startingPeriodInput != "") // check if there was any date entered or selected in the StartingPeriodInput text field { filter.startingDate = DateTime.ParseExact(startingPeriodInput + " 00:00:00:000000", "yyyy-MM-dd HH:mm:ss:ffffff", null); if (filter.startingDate <= DateTime.Now) // check that the starting date is on or before todays date { if (endingPeriodInput != "") // check if there was any date entered or selected in the EndingPeriodInput text field { filter.endDate = DateTime.ParseExact(endingPeriodInput + " 23:59:59:000000", "yyyy-MM-dd HH:mm:ss:ffffff", null); if (filter.startingDate > filter.endDate) { throw new Exception("Starting date must be before the end date."); } filter.siteID = int.Parse(HospitalDropDownList.SelectedValue); filter.mealID = int.Parse(MealDropDownList.SelectedValue); if (UnitDropDownList.Enabled == false) // if the UnitDropDownList is not enabled (all hospitals is selected in the HospitalDropDownList) then set the filter.unitID to 0 { filter.unitID = 0; } else // else, get the selected value of the unit drop down list and populate the filter.adminID with that value { filter.unitID = int.Parse(UnitDropDownList.SelectedValue); } Session["filter"] = filter; // create the session to be passed to the SubmittedSurveyList page Response.Redirect("SubmittedSurveyList.aspx"); // now redirect to the SubmittedSurveyList page with the filter details } else // else, display an error to enter a date for the ending period { throw new Exception("Please select an ending period"); } } else // if the start date is set after today's date display an error to the admin { throw new Exception("Starting date cannot be after today's date."); } } else // else, display an error to enter a date for the starting period { throw new Exception("Please select a starting period"); } }, "Success", "Redirecting to the survey list page."); }
/// <summary> /// Default Web Page Method use to initialize pages and check if the user is logged in and if it passes the required filters for generating reports. /// </summary> /// <param name="sender">Contains a reference to the control/object that raised the event.</param> /// <param name="e">Contains the event data.</param> protected void Page_Load(object sender, EventArgs e) { // Set the visibility for Alert Message Label to hidden. Alert.Visible = false; // Check if the user is logged in. Redirect to Admin Login page if the user doesn't have a securityId if (Session["securityID"] == null) { Response.Redirect("~/Admin/Login.aspx"); } else { // Initialize and set filter variable with the type of FilterPOCO and retrieve the Session state with an ID of "filter" that is passed from the ViewReportFilter page // to be use for the generating report. FilterPOCO filter = (FilterPOCO)(Session["filter"]); // Check if the filter has a value. Redirect the user to ViewReportFilter page if the the filter doesn't have any values. if (filter == null) { Response.Redirect("~/Admin/ViewReportFilter.aspx"); } else { // Instantiate Report Controller, Meal Controller, Site Controller, Site Name, FinalReportPOCO and Meal variable. ReportController reportMgr = new ReportController(); MealController mealMgr = new MealController(); Meal meal = new Meal(); FinalReportPOCO report = new FinalReportPOCO(); SiteController siteMgr = new SiteController(); string siteName = ""; // Initialize report by calling GenerateOverAllReport method from Report Controller which return a FinalReportPOCO object. report = reportMgr.GenerateOverAllReport(filter.startingDate, filter.endDate, filter.siteID, filter.mealID); // Initialize Site Name variable by calling DisplaySiteName method from Site Controller which return a string. siteName = siteMgr.DisplaySiteName(filter.siteID); // Check if siteName is null, change the Site Name variable to "All sites". if (siteName == null) { siteName = "All sites"; } // Initialize Meal variable by calling GetMeal method from Meal Controller which return a Meal object. meal = mealMgr.GetMeal(filter.mealID); // Check if meal variable is null. if (meal == null) { // If meal variable is null change the FilterDescription Label Text to the described markup. FilterDescription.Text = "Report from " + siteName + " from " + filter.startingDate.ToString("MMMM-dd-yyyy") + " to " + filter.endDate.ToString("MMMM-dd-yyyy") + " with no meal filter."; } else { // If meal variable is not null change the FilterDescription Label Text to the described markup. FilterDescription.Text = "Report from " + siteName + " from " + filter.startingDate.ToString("MMMM-dd-yyyy") + " to " + filter.endDate.ToString("MMMM-dd-yyyy") + " with a meal filter of " + meal.meal_name + "."; } // Set the TotalNumberOfSubmittedSurvey Label Text to the described markup. TotalNumberOfSubmittedSurvey.Text = "Total number of submitted survey with the given criteria: " + report.SubmittedSurveyList.Count().ToString() + " surveys submitted."; // Check if the SubmittedSurveyList from report variable has atleast 1 survey. if (report.SubmittedSurveyList.Count < 1) { // Hide TotalNumberOfSubmittedSurvey Label. TotalNumberOfSubmittedSurvey.Visible = false; // Display EmptyMessage Label. EmptyMessage.Visible = true; // Set EmptyMessage Label to "No Submitted Survey Found. Please check your filter". EmptyMessage.Text = "No Submitted Survey Found. Please check your filter"; } } } }
[WebMethod] // This attribute allows XML Web service created using ASP.NET to be the callable from remote Web Clients. public static string GetChartData(int chartId) { // Instantiate Report POCO, Chart POCO, Chart POCO List, Preferred Response Order List, Sorted Response Variable, and Report Controller variables FinalReportPOCO report = new FinalReportPOCO(); List <ChartPOCO> responses = new List <ChartPOCO>(); ChartPOCO response = null; // List of Preferred Response Order based on the Question Responses answers List <String> preferencesForOrderByFirstOption = new List <String> { "Very Good", "Good", "Fair", "Poor", "Don't Know/No Opinion", "No Response" }; List <String> preferencesForOrderBySecondOption = new List <String> { "Portion sizes are too small", "Portion sizes are just right", "Portion sizes are too large", "No Response" }; List <String> preferencesForOrderByThirdOption = new List <String> { "Always", "Usually", "Occasionally", "Never", "I do not have any specific dietary requirements", "No Response" }; List <String> preferencesForOrderByFourthOption = new List <String> { "Very Good", "Good", "Fair", "Never", "Poor", "Very Poor" }; IEnumerable <ChartPOCO> sortedResponses = null; ReportController reportMgr = new ReportController(); // Get the Filter to be use as a parameter to get the data for report. FilterPOCO filter = (FilterPOCO)(HttpContext.Current.Session["filter"]); // Initialize report by calling GenerateOverAllReport method from Report Controller which return a FinalReportPOCO object. report = reportMgr.GenerateOverAllReport(filter.startingDate, filter.endDate, filter.siteID, filter.mealID); // Check if the the retrieve report has atleast 1 survey submitted. if (report.SubmittedSurveyList.Count > 0) { // Check to see if what ajax call is accessing the data and process the desired value to be retrieves. // Retrieves data for Chart1 for Question 1A. if (chartId == 1) { // Loop to the specific List from report POCO based on the chart. for (int counter = 0; counter < report.QuestionTwoValueCount.Count; counter++) { //Instantiate new ChartPOCO response = new ChartPOCO(); // Check and handle if the retrieve string is empty if (report.QuestionTwoValueList[counter].Equals("")) { response.Text = "No Response"; } else { response.Text = report.QuestionTwoValueList[counter]; } // Set the Chart POCO attributes based on the current Object being looped in. response.Value = report.QuestionTwoValueCount[counter]; response.Title = report.Question[0]; response.Color = COLOR_VALUE[counter]; response.BorderColor = BORDER_COLOR_VALUE[counter]; // Add the ChartPOCO Object to the ChartPOCO List responses.Add(response); // Clear the ChartPOCO Object response = null; } // Sort the responses based on the preferred option declared and assigned it to the sortedResponse variable of IEnumerable type. sortedResponses = responses.OrderBy(item => preferencesForOrderByFirstOption.IndexOf(item.Text)); } // Check to see if what ajax call is accessing the data and process the desired value to be retrieves. // Retrieves data for Chart2 for Question 1B. else if (chartId == 2) { // Loop to the specific List from report POCO based on the chart. for (int counter = 0; counter < report.QuestionThreeValueCount.Count; counter++) { //Instantiate new ChartPOCO response = new ChartPOCO(); // Check and handle if the retrieve string is empty if (report.QuestionThreeValueList[counter].Equals("")) { response.Text = "No Response"; } else { response.Text = report.QuestionThreeValueList[counter]; } // Set the Chart POCO attributes based on the current Object being looped in. response.Value = report.QuestionThreeValueCount[counter]; response.Title = report.Question[1]; response.Color = COLOR_VALUE[counter]; response.BorderColor = BORDER_COLOR_VALUE[counter]; // Add the ChartPOCO Object to the ChartPOCO List responses.Add(response); // Clear the ChartPOCO Object response = null; } // Sort the responses based on the preferred option declared and assigned it to the sortedResponse variable of IEnumerable type. sortedResponses = responses.OrderBy(item => preferencesForOrderByFirstOption.IndexOf(item.Text)); } // Check to see if what ajax call is accessing the data and process the desired value to be retrieves. // Retrieves data for Chart3 for Question 1C. else if (chartId == 3) { // Loop to the specific List from report POCO based on the chart. for (int counter = 0; counter < report.QuestionFourValueCount.Count; counter++) { //Instantiate new ChartPOCO response = new ChartPOCO(); // Check and handle if the retrieve string is empty if (report.QuestionFourValueList[counter].Equals("")) { response.Text = "No Response"; } else { response.Text = report.QuestionFourValueList[counter]; } // Set the Chart POCO attributes based on the current Object being looped in. response.Value = report.QuestionFourValueCount[counter]; response.Title = report.Question[2]; response.Color = COLOR_VALUE[counter]; response.BorderColor = BORDER_COLOR_VALUE[counter]; // Add the ChartPOCO Object to the ChartPOCO List responses.Add(response); // Clear the ChartPOCO Object response = null; } // Sort the responses based on the preferred option declared and assigned it to the sortedResponse variable of IEnumerable type. sortedResponses = responses.OrderBy(item => preferencesForOrderByFirstOption.IndexOf(item.Text)); } // Check to see if what ajax call is accessing the data and process the desired value to be retrieves. // Retrieves data for Chart4 for Question 1D. else if (chartId == 4) { // Loop to the specific List from report POCO based on the chart. for (int counter = 0; counter < report.QuestionFiveValueCount.Count; counter++) { //Instantiate new ChartPOCO response = new ChartPOCO(); // Check and handle if the retrieve string is empty if (report.QuestionFiveValueList[counter].Equals("")) { response.Text = "No Response"; } else { response.Text = report.QuestionFiveValueList[counter]; } // Set the Chart POCO attributes based on the current Object being looped in. response.Value = report.QuestionFiveValueCount[counter]; response.Title = report.Question[3]; response.Color = COLOR_VALUE[counter]; response.BorderColor = BORDER_COLOR_VALUE[counter]; // Add the ChartPOCO Object to the ChartPOCO List responses.Add(response); // Clear the ChartPOCO Object response = null; } // Sort the responses based on the preferred option declared and assigned it to the sortedResponse variable of IEnumerable type. sortedResponses = responses.OrderBy(item => preferencesForOrderByFirstOption.IndexOf(item.Text)); } // Check to see if what ajax call is accessing the data and process the desired value to be retrieves. // Retrieves data for Chart5 for Question 1E. else if (chartId == 5) { // Loop to the specific List from report POCO based on the chart. for (int counter = 0; counter < report.QuestionSixValueCount.Count; counter++) { //Instantiate new ChartPOCO response = new ChartPOCO(); // Check and handle if the retrieve string is empty if (report.QuestionSixValueList[counter].Equals("")) { response.Text = "No Response"; } else { response.Text = report.QuestionSixValueList[counter]; } // Set the Chart POCO attributes based on the current Object being looped in. response.Value = report.QuestionSixValueCount[counter]; response.Title = report.Question[4]; response.Color = COLOR_VALUE[counter]; response.BorderColor = BORDER_COLOR_VALUE[counter]; // Add the ChartPOCO Object to the ChartPOCO List responses.Add(response); // Clear the ChartPOCO Object response = null; } // Sort the responses based on the preferred option declared and assigned it to the sortedResponse variable of IEnumerable type. sortedResponses = responses.OrderBy(item => preferencesForOrderByFirstOption.IndexOf(item.Text)); } // Check to see if what ajax call is accessing the data and process the desired value to be retrieves. // Retrieves data for Chart6 for Question 2. else if (chartId == 6) { // Loop to the specific List from report POCO based on the chart. for (int counter = 0; counter < report.QuestionEightValueCount.Count; counter++) { //Instantiate new ChartPOCO response = new ChartPOCO(); // Check and handle if the retrieve string is empty if (report.QuestionEightValueList[counter].Equals("")) { response.Text = "No Response"; } else { response.Text = report.QuestionEightValueList[counter]; } // Set the Chart POCO attributes based on the current Object being looped in. response.Value = report.QuestionEightValueCount[counter]; response.Title = report.Question[5]; response.Color = COLOR_VALUE[counter]; response.BorderColor = BORDER_COLOR_VALUE[counter]; // Add the ChartPOCO Object to the ChartPOCO List responses.Add(response); // Clear the ChartPOCO Object response = null; } // Sort the responses based on the preferred option declared and assigned it to the sortedResponse variable of IEnumerable type. sortedResponses = responses.OrderBy(item => preferencesForOrderBySecondOption.IndexOf(item.Text)); } // Check to see if what ajax call is accessing the data and process the desired value to be retrieves. // Retrieves data for Chart7 for Question 3. else if (chartId == 7) { // Loop to the specific List from report POCO based on the chart. for (int counter = 0; counter < report.QuestionNineValueCount.Count; counter++) { //Instantiate new ChartPOCO response = new ChartPOCO(); // Check and handle if the retrieve string is empty if (report.QuestionNineValueList[counter].Equals("")) { response.Text = "No Response"; } else { response.Text = report.QuestionNineValueList[counter]; } // Set the Chart POCO attributes based on the current Object being looped in. response.Value = report.QuestionNineValueCount[counter]; response.Title = report.Question[6]; response.Color = COLOR_VALUE[counter]; response.BorderColor = BORDER_COLOR_VALUE[counter]; // Add the ChartPOCO Object to the ChartPOCO List responses.Add(response); // Clear the ChartPOCO Object response = null; } // Sort the responses based on the preferred option declared and assigned it to the sortedResponse variable of IEnumerable type. sortedResponses = responses.OrderBy(item => preferencesForOrderByThirdOption.IndexOf(item.Text)); } // Check to see if what ajax call is accessing the data and process the desired value to be retrieves. // Retrieves data for Chart8 for Question 4. else if (chartId == 8) { // Loop to the specific List from report POCO based on the chart. for (int counter = 0; counter < report.QuestionTenValueCount.Count; counter++) { //Instantiate new ChartPOCO response = new ChartPOCO(); // Check and handle if the retrieve string is empty if (report.QuestionTenValueList[counter].Equals("")) { response.Text = "No Response"; } else { response.Text = report.QuestionTenValueList[counter]; } // Set the Chart POCO attributes based on the current Object being looped in. response.Value = report.QuestionTenValueCount[counter]; response.Title = report.Question[7]; response.Color = COLOR_VALUE[counter]; response.BorderColor = BORDER_COLOR_VALUE[counter]; // Add the ChartPOCO Object to the ChartPOCO List responses.Add(response); // Clear the ChartPOCO Object response = null; } // Sort the responses based on the preferred option declared and assigned it to the sortedResponse variable of IEnumerable type. sortedResponses = responses.OrderBy(item => preferencesForOrderByFourthOption.IndexOf(item.Text)); } } // Convert sortedResponses variable of type IEnumerable to Serialze JSON Ojject using JsonConvert.SerializeObject method. // Return sortedResponses of type JSON Object return(JsonConvert.SerializeObject(sortedResponses)); }
public void LineChartFiler(string message) { try { FilterPOCO filterData = JsonUtility.FromJson <FilterPOCO>(message); if (filterData == null) { Console.Log("Invalid data"); } if (filterData.LayerID == "Vshale") { filterData.LayerID = "VShale"; } if (Enum.TryParse(filterData.LayerID, out Layers layer)) { Console.Log("Data received: " + layer.ToString() + " : " + filterData.IsEnabled + " : " + filterData.Min + " : " + filterData.Max); if (filterData.IsEnabled) { LayerShaderController.EnableLayer(layer); } else { LayerShaderController.DisableLayer(layer); } switch (layer) { case Layers.Elevation: filterData.Min = Remap(filterData.Min, ElevationMin, ElevationMax, 0, 1); filterData.Max = Remap(filterData.Max, ElevationMin, ElevationMax, 0, 1); break; case Layers.Porosity: filterData.Min = Remap(filterData.Min, PorosityMin, PorosityMax, 0, 1); filterData.Max = Remap(filterData.Max, PorosityMin, PorosityMax, 0, 1); break; case Layers.Thickness: filterData.Min = Remap(filterData.Min, ThicknessMin, ThicknessMax, 0, 1); filterData.Max = Remap(filterData.Max, ThicknessMin, ThicknessMax, 0, 1); break; case Layers.TOC: filterData.Min = Remap(filterData.Min, TOCMin, TOCMax, 0, 1); filterData.Max = Remap(filterData.Max, TOCMin, TOCMax, 0, 1); break; case Layers.VShale: filterData.Min = Remap(filterData.Min, VShaleMin, VShaleMax, 0, 1); filterData.Max = Remap(filterData.Max, VShaleMin, VShaleMax, 0, 1); break; } LayerShaderController.SetTop(filterData.Max, layer); LayerShaderController.SetBottom(filterData.Min, layer); } else { Console.Log($"NOT SUPPORTER LAYER TYPE {filterData.LayerID}"); } } catch (Exception ex) { Console.Log(ex.Message); } }