public ActionResult GraphView(VTGraphModel model) { List <VTSPCObject> list = logic.getSPCInfo(model.FinalAssembly, model.DataToken, model.HeaderToken, model.Amount); Highcharts chart = helper.generateSPC(list); model.Go = true; model.ChartHTML = chart.ToHtmlString(); return(View(model)); }
public ActionResult MainForm(VTViewModel model, string buttontype) { if (ModelState.IsValid) { string EmployeeID = ""; // Determine to use VTID or EmployeeID, depdending on the properties settings. if (VT.Properties.Settings.Default.UsingBinaryBadgeID) { try { EmployeeID = helper.VTIDtoEMPID(model.EmployeeID); } catch { model.DisplayMessage = "Please Scan your VT ID"; return(View(model)); } } else { EmployeeID = model.EmployeeID; } if (buttontype == "Go") { // Time how long getForm takes Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); // GET Fields depending on the serial number. model.ListFields = logic.getFormInfo(model.SerialNumber, EmployeeID); stopwatch.Stop(); // Write to a text file to catch the elapsed time. DateTime today_date = new DateTime(); today_date = DateTime.Now; using (StreamWriter writer = new StreamWriter("C:\\log\\timerlog_" + today_date.ToString("MM-dd-yyyy") + ".txt", true)) { writer.WriteLine(DateTime.Now); writer.WriteLine("Serial Number: " + model.SerialNumber + " | Process: " + model.ListFields[0].HeaderName + " | USING GETFORM"); writer.WriteLine("Badge ID: " + model.EmployeeID); writer.WriteLine("Time Elapsed: " + stopwatch.Elapsed); writer.WriteLine(" "); } if (model.ListFields[0].return_num == "0") { model.Go = true; ViewData["HEADER"] = model.ListFields[0].HeaderName + " | " + model.ListFields[0].TubeType + " | " + model.ListFields[0].ProductLine; model.DisplayMessage = model.ListFields[0].error_message; } else { if (model.ListFields[0].return_num == "0") { model.DisplayMessage = "Submitted"; } else { model.DisplayMessage = helper.checkErrors(model.ListFields[0].return_num, model.ListFields[0].error_message); } } } else if (buttontype == "Submit") { // Variables List <VTFieldObject> spc_options = new List <VTFieldObject>(); string header = model.ListFields[0].HeaderToken; string[] check; model.HeaderToken = model.ListFields[0].HeaderToken; // If the submission worked //SUBMIT HERE INTO DB then Clear List <string> values_to_submit = new List <string>(); // Creates a list to store the values to submit for (int i = 0; i < model.ListFields.Count; i++) { // Fills in the hidden values. if (model.ListFields[i].isHidden) { if (model.ListFields[i].Token == "SNT" || model.ListFields[i].Token == "SNC") { model.ListFields[i].Value = model.SerialNumber; } else if (model.ListFields[i].Token == "USR") { model.ListFields[i].Value = EmployeeID; } else if (model.ListFields[i].Token == "TMS") { model.ListFields[i].Value = "0"; } } // Have the radio list built if (model.ListFields[i].DataType == "DATA-RADIO") { string radiobuttons = model.ListFields[i].DetailOptionsString; model.ListFields[i].DetailOptions = helper.parseDetailOptions(radiobuttons); } // If it is a check box do the right conversion. if (model.ListFields[i].DataType == "DATA-CKBOX") { string convertedValue = helper.boolToInt(model.ListFields[i].BoolValue).ToString(); model.ListFields[i].Value = convertedValue; } // If the field has a spec value add it to the list of SPC graph options if (model.ListFields[i].ChildRelation == "R-VALUE") { if (model.ListFields[i].DataType == "DATA-DECIMAL") { spc_options.Add(model.ListFields[i]); // Add the option to the list } } values_to_submit.Add(model.ListFields[i].Token + model.ListFields[i].Value); } // Makes sure it passes the correctly filled form test string check_correct_form = helper.checkCorrectForm(model.ListFields); if (check_correct_form != "0") { // If it doesn't pass set display message to the error model.DisplayMessage = check_correct_form; // Set go to true so it will display the form model.Go = true; return(View(model)); } check = logic.helperSubmit(values_to_submit, 1, header); string error_number = check[0]; string error_message = check[1]; if (error_number == "0") { ModelState.Clear(); VTViewModel clear_model = new VTViewModel(); // Creates an empty model if (VT.Properties.Settings.Default.ShowSPC) { // Call the database to get SPC charts for (int i = 0; i < spc_options.Count; i++) { List <VTSPCObject> list = new List <VTSPCObject>(); list = logic.getSPCInfo(spc_options[i].FinalAssembly, spc_options[i].Token, spc_options[i].HeaderToken, "5"); string temp = helper.generateSPC(list).ToHtmlString(); // Change html so it will generate a unique graph per spec data string gen_spc_html = temp.Replace("chart_container", "chart_container_" + i); clear_model.ListSPCHTML.Add(gen_spc_html); } } clear_model.Success = true; clear_model.DisplayMessage = "Submitted\n" + model.SerialNumber + "\n" + DateTime.Now; return(View(clear_model)); } else { model.DisplayMessage = helper.checkErrors(error_number, error_message); // Sets the display message to the error. } } else if (buttontype == "Clear") { // Clears the screen and model ModelState.Clear(); VTViewModel clear_model = new VTViewModel(); // Creates an empty model clear_model.Submitted = true; return(View(clear_model)); } } return(View(model)); }