public IActionResult Main() { ViewBag.LogErrors = new List <string>(); string email = HttpContext.Session.GetString("userpass"); if (email == null) { ViewBag.LogErrors.Add("You need to log in first"); TempData["LogErrors"] = ViewBag.LogErrors; return(RedirectToAction("Index")); } else { ViewBag.MessageErrors = TempData["MessageErrors"]; ViewBag.CommentErrors = TempData["CommentErrors"]; if (ViewBag.MessageErrors == null) { ViewBag.MessageErrors = new List <string>(); } if (ViewBag.CommentErrors == null) { ViewBag.CommentErrors = new List <string>(); } string selectQuery = $"SELECT id FROM users WHERE email = '{email}'"; var younow = MySqlConnector.Query(selectQuery); string selectMessages = $"SELECT users.firstName AS firstName,users.LastName AS lastName,messages.id AS id,messages.message AS message, messages.user_id AS message_user_id, messages.created_at AS created_at,messages.updated_at AS updated_at FROM users JOIN messages ON users.id = messages.user_id"; string selectComments = $"SELECT users.firstName AS user_firstName,users.LastName AS user_lastName,messages.id AS message_id,messages.message AS message, messages.user_id AS message_user_id,messages.created_at AS message_created_at,messages.updated_at AS message_updated_at,comments.id AS comment_id,comments.comment AS comment, comments.message_id AS comment_message_id,comments.user_id AS comment_user_id, comments.created_at AS comment_created_at,comments.updated_at AS comment_updated_at FROM users JOIN comments ON users.id = comments.user_id JOIN messages ON comments.message_id = messages.id"; var messages = MySqlConnector.Query(selectMessages); var comments = MySqlConnector.Query(selectComments); ViewBag.userid = (int)younow[0]["id"]; ViewBag.MessageList = messages; ViewBag.CommentList = comments; return(View("Main")); } }
public IActionResult Index() { var allNotes = MySqlConnector.Query("SELECT * FROM notes"); ViewBag.allNotes = allNotes; return(View()); }
public IActionResult quotes() { var allQuotes = MySqlConnector.Query("SELECT * FROM comments"); ViewBag.quotes = allQuotes; return(View("quotes")); }
public IActionResult addUser(string firstName, string lastName, int?age, string email, string password, string pw_confirm) { ViewBag.Errors = new List <string>(); if (firstName == null || firstName.Length < 4) { ViewBag.Errors.Add("First name field has to have at least 4 characters."); } if (lastName == null || lastName.Length < 4) { ViewBag.Errors.Add("Last name field has to have at least 4 characters."); } if (age == null) { ViewBag.Errors.Add("You have to provide your age."); } if (email == null) { ViewBag.Errors.Add("You have to provide an e-mail address"); } else { if (isValidEmail(email) == false) { ViewBag.Errors.Add("The email format provided is not correct"); } } if (password == null || password.Length < 8) { ViewBag.Errors.Add("You have to provide a password"); } if (pw_confirm == null || pw_confirm != password) { ViewBag.Errors.Add("Password and password confirmation do not match"); } if (ViewBag.Errors.Count > 0) { TempData["Errors"] = ViewBag.Errors; return(RedirectToAction("Index")); } else { string selectQuery = $"SELECT * FROM users WHERE email = '{email}'"; var emailVal = MySqlConnector.Query(selectQuery); if (emailVal.Count > 0) { ViewBag.Errors.Add("This e-mail already belongs to a registered user"); TempData["Errors"] = ViewBag.Errors; return(RedirectToAction("Index")); } else { string rightNow = DateTime.Now.ToString("yyyyMMddHHmmss"); string query = $"INSERT INTO users (firstName,lastName,age,email,password,created_at,updated_at) VALUES ('{firstName}','{lastName}','{age}','{email}','{password}',{rightNow},{rightNow})"; MySqlConnector.Execute(query); HttpContext.Session.SetString("userpass", (string)email); return(RedirectToAction("Index")); } } }
public IActionResult quote() { string query = "SELECT * FROM quotes"; var quotes = MySqlConnector.Query(query); ViewBag.quotes = quotes; return(View("quotes")); }
public void Ping() { MySqlConnector sql = new MySqlConnector(); sql.LoadConfig("IASERVER"); string query = @"UPDATE `aoidata`.`maquina` SET `ping` = NOW() WHERE `id` = " + mysql_id + " LIMIT 1;"; DataTable sp = sql.Query(query); }
public IActionResult quotes() { string query = "SELECT * FROM QuotesTable"; var result = ctx.Query(query); ViewBag.allQuotes = result; return(View()); }
public IActionResult Quotes() { string query = "SELECT * FROM quotes"; var quotes = MySqlConnector.Query(query); ViewBag.Quotes = quotes; Console.WriteLine("test"); Console.WriteLine(ViewBag.Quotes); return(View()); }
public IActionResult submit(string name, string content) { string query = $"INSERT INTO quotes (name, content, created_at, updated_at) VALUES ('{name}', '{content}', NOW(), NOW())"; MySqlConnector.Execute(query); string str = "SELECT * FROM quotes"; var quotes = MySqlConnector.Query(str); ViewBag.quotes = quotes; return(View("quotes")); }
private void SaveBlocks(string path) { foreach (Bloque bloque in bloqueList) { Stopwatch sw = Stopwatch.StartNew(); if (Config.debugMode) { machine.LogBroadcast("warning", string.Format("Debug mode: ON, no se guarda el bloque") ); } else { machine.LogBroadcast("debug", string.Format("Ejecutando sp_addInspectionBlock({0}) ", bloque.barcode) ); string query = @"CALL sp_addInspectionBlock('" + panelId + "', '" + bloque.barcode + "', '" + bloque.tipoBarcode + "', '" + bloque.revisionAoi + "', '" + bloque.revisionIns + "', '" + bloque.totalErrores + "', '" + bloque.totalErroresFalsos + "', '" + bloque.totalErroresReales + "', '" + bloque.bloqueId + "' );"; #region GUARDA EN DB MySqlConnector sql = new MySqlConnector(); sql.LoadConfig("IASERVER"); DataTable sp = sql.Query(query); if (sql.rows) { int id_inspeccion_bloque = 0; id_inspeccion_bloque = int.Parse(sp.Rows[0]["id"].ToString()); if (id_inspeccion_bloque > 0) { history.SaveBloque(id_inspeccion_bloque); } if (bloque.totalErrores > 0) { // EXISTEN ERRORES REALES O FALSOS SaveDetail(id_inspeccion_bloque, bloque); } } #endregion } sw.Stop(); machine.LogBroadcast("success", string.Format("Bloque guardado: {0} (ms) {1} ", bloque.barcode, (long)sw.ElapsedMilliseconds) ); } }
private void SaveDetail(int id_inspeccion_bloque, Bloque bloque) { foreach (Detail detail in bloque.detailList) { string query = @"CALL sp_addInspectionDetail('" + id_inspeccion_bloque + "', '" + detail.referencia + "', '" + detail.faultcode + "', '" + detail.estado + "');"; MySqlConnector sql = new MySqlConnector(); sql.LoadConfig("IASERVER"); DataTable sp = sql.Query(query); } // Una vez insertados los detalles de inspeccion del bloque, genero un historial history.SaveDetalle(id_inspeccion_bloque); }
public IActionResult login(string emailLog, string passwordLog) { var user = MySqlConnector.Query($"SELECT * FROM consoledb.logregusers WHERE email='{emailLog}' AND password='******'"); if (user.Count == 1) { return(View("success")); } else { ViewBag.error = "User doesn't exist or password is incorrect."; return(View("index")); } }
public static void UpdateInspectionDate(int id) { MySqlConnector sql = new MySqlConnector(); sql.LoadConfig("IASERVER"); string query = @"CALL sp_updateInspeccionMaquina(" + id + ", NOW());"; DataTable sp = sql.Query(query); if (sql.rows) { string ultima_inspeccion = sp.Rows[0]["ultima_inspeccion"].ToString(); Machine update = list.Find(obj => obj.mysql_id == id); update.ultima_inspeccion = ultima_inspeccion; } }
public static bool UpdatePing(string nombreSensor, DateTime fecha_medicion) { try { string fecha = fecha_medicion.ToString("yyyy-MM-dd H:mm:ss"); string query = "CALL temp_hum.sp_updatePing('" + nombreSensor + "','" + fecha + "')"; MySqlConnector mysql = new MySqlConnector(); mysql.LoadConfig("IASERVER"); mysql.Query(query); } catch (Exception ex) { return(false); } return(true); }
public static List <Pendiente> Download(string machineNameKey) { List <Pendiente> pendlist = new List <Pendiente>(); string query = @" SELECT p.id, p.barcode, CAST(p.fecha_maquina as CHAR) as fecha_maquina, p.id_maquina, p.programa, p.vtwin_program_name_id, p.vtwin_test_machine_id from aoidata.procesar_pendiente p, aoidata.maquina m where m.id = p.id_maquina and m.active = 1 and m.tipo = '" + machineNameKey + "' "; MySqlConnector sql = new MySqlConnector(); sql.LoadConfig("IASERVER"); DataTable dt = sql.Query(query); if (sql.rows) { foreach (DataRow r in dt.Rows) { Pendiente ipen = new Pendiente(); ipen.idPendiente = int.Parse(r["id"].ToString()); ipen.barcode = r["barcode"].ToString(); ipen.fechaMaquina = r["fecha_maquina"].ToString(); ipen.idMaquina = int.Parse(r["id_maquina"].ToString()); ipen.programa = r["programa"].ToString(); ipen.vtwinTestMachineId = int.Parse(r["vtwin_test_machine_id"].ToString()); ipen.vtwinProgramNameId = r["vtwin_program_name_id"].ToString(); pendlist.Add(ipen); } } return(pendlist); }
public static int Insert(PcbInfo pcb) { string nombre = pcb.programa.Split('.').FirstOrDefault(); MySqlConnector sql = new MySqlConnector(); sql.LoadConfig("IASERVER"); string query = @"CALL sp_addPcbData('" + nombre + "', '" + pcb.programa + "', '" + pcb.bloques + "','" + pcb.segmentos + "', '" + pcb.tipoMaquina + "', '" + pcb.hash + "', '" + pcb.fechaModificacion + "');"; DataTable sp = sql.Query(query); if (sql.rows) { pcb.id = int.Parse(sp.Rows[0]["id"].ToString()); } // Retorno ID, 0 si no pudo insertar. return(pcb.id); }
/// <summary> /// Envia al historial los detalles de el ultimo bloque insertado /// </summary> /// <param name="save_id_bloque"></param> public void SaveDetalle(int save_id_bloque) { try { if (idPanel > 0 && idBloque > 0) { string query = "CALL aoidata.sp_insertHistoryDetail(" + save_id_bloque + ")"; MySqlConnector sql = new MySqlConnector(); sql.LoadConfig("IASERVER"); DataTable dt = sql.Query(query); } } catch (Exception ex) { isStackError = true; Log.Stack("HustorySaveDetalle()", this, ex); } }
public static void Download() { list = new List <Machine>(); string query = @" SELECT m.id, p.barcode, m.maquina, m.linea, m.tipo, m.ultima_inspeccion, m.ultima_inspeccion_iaserver, m.active, m.ping from aoidata.maquina as m left join aoidata.produccion p ON m.id = p.id_maquina "; MySqlConnector sql = new MySqlConnector(); sql.LoadConfig("IASERVER"); DataTable dt = sql.Query(query); if (sql.rows) { foreach (DataRow r in dt.Rows) { Machine mac = new Machine(); mac.mysql_id = int.Parse(r["id"].ToString()); mac.maquina = r["maquina"].ToString(); mac.nroLinea = int.Parse(r["linea"].ToString()); mac.smd = "SMD-" + mac.nroLinea; mac.tipo = r["tipo"].ToString(); mac.ultima_inspeccion = r["ultima_inspeccion"].ToString(); mac.line_barcode = r["barcode"].ToString(); mac.active = bool.Parse(r["active"].ToString()); mac.ping = r["ping"].ToString(); list.Add(mac); } } }
public static bool createMeasure(int id_sensor, string temperatura, string humedad, DateTime fecha_medicion) { bool creado = true; string fecha = fecha_medicion.ToString("yyyy-MM-dd H:mm:ss"); string query = "CALL temp_hum.sp_createMeasurePoint('" + id_sensor + "','" + humedad + "','" + temperatura + "','" + fecha + "')"; MySqlConnector mysql = new MySqlConnector(); mysql.LoadConfig("IASERVER"); mysql.Query(query); if (mysql.rows) { creado = true; } else { creado = false; } return(creado); }
public IActionResult login(string email, string password) { ViewBag.LogErrors = new List <string>(); if (email == null) { ViewBag.LogErrors.Add("You have to provide an username"); } if (password == null) { ViewBag.LogErrors.Add("You have to provide a password"); } if (ViewBag.LogErrors.Count > 0) { TempData["LogErrors"] = ViewBag.LogErrors; return(RedirectToAction("Index")); } else { string selectQuery = $"SELECT * FROM users WHERE email = '{email}'"; var emailVal = MySqlConnector.Query(selectQuery); if (emailVal.Count < 1) { ViewBag.LogErrors.Add("We cannot find your username in our records"); TempData["LogErrors"] = ViewBag.LogErrors; return(RedirectToAction("Index")); } else { if ((string)emailVal[0]["password"] != password) { ViewBag.LogErrors.Add("Wrong password"); TempData["LogErrors"] = ViewBag.LogErrors; return(RedirectToAction("Index")); } else { HttpContext.Session.SetString("userpass", (string)email); return(RedirectToAction("Success")); } } } }
/// <summary> /// Envia al historial la inspeccion realizada del panel /// </summary> /// <param name="save_id_panel"></param> public void SavePanel(int save_id_panel, string mode) { try { string query = "CALL aoidata.sp_insertHistoryPanel(" + save_id_panel + ", '" + mode + "')"; MySqlConnector sql = new MySqlConnector(); sql.LoadConfig("IASERVER"); DataTable dt = sql.Query(query); if (sql.rows) { DataRow r = dt.Rows[0]; idPanel = int.Parse(r["id"].ToString()); } } catch (Exception ex) { isStackError = true; Log.Stack("HistorySavePanel()", this, ex); } }
public IActionResult addComment(string comment, int?messageid) { ViewBag.CommentErrors = new List <string>(); if (comment == null || comment.Length < 4) { ViewBag.commentErrors.Add("The comment has to have at least 4 characters."); TempData["CommentErrors"] = ViewBag.commentErrors; return(RedirectToAction("Main")); } else { comment = comment.Replace("'", @"\'"); string email = HttpContext.Session.GetString("userpass"); string selectQuery = $"SELECT * FROM users WHERE email = '{email}'"; var younow = MySqlConnector.Query(selectQuery); int? yourid = (int)younow[0]["id"]; string rightNow = DateTime.Now.ToString("yyyyMMddHHmmss"); string commentQuery = $"INSERT INTO comments (comment,user_id,message_id,created_at,updated_at) VALUES ('{comment}',{yourid},{messageid},{rightNow},{rightNow})"; MySqlConnector.Execute(commentQuery); return(RedirectToAction("Main")); } }
/// <summary> /// Descarga la lista de faultcodes del servidor /// </summary> public static void Download() { list = new List <Faultcode>(); string query = @"SELECT id,faultcode,descripcion FROM aoidata.rns_faultcode "; MySqlConnector sql = new MySqlConnector(); sql.LoadConfig("IASERVER"); DataTable dt = sql.Query(query); if (sql.rows) { foreach (DataRow r in dt.Rows) { Faultcode fault = new Faultcode(); fault.id = int.Parse(r["id"].ToString()); fault.faultcode = r["faultcode"].ToString(); fault.descripcion = r["descripcion"].ToString(); list.Add(fault); } } }
/// <summary> /// Descarga los sensores Activos /// </summary> public static void Actives() { list = new List <Sensores>(); string query = "CALL temp_hum.getActiveSensors()"; MySqlConnector mysql = new MySqlConnector(); mysql.LoadConfig("IASERVER"); DataTable dt = mysql.Query(query); if (mysql.rows) { foreach (DataRow r in dt.Rows) { Sensores sensor = new Sensores(); sensor.id_sensor = int.Parse(r["id_sensor"].ToString()); sensor.nombre = r["nombre"].ToString(); sensor.ip_sensor = r["ip_sensor"].ToString(); sensor.last_date_saved = r["last_date_saved"].ToString(); list.Add(sensor); } } }
/// <summary> /// Envia al historial la inspeccion realizada del bloque /// </summary> /// <param name="save_id_bloque"></param> public void SaveBloque(int save_id_bloque) { try { if (idPanel > 0) { string query = "CALL aoidata.sp_insertHistoryBlock(" + idPanel + "," + save_id_bloque + ")"; MySqlConnector sql = new MySqlConnector(); sql.LoadConfig("IASERVER"); DataTable dt = sql.Query(query); if (sql.rows) { DataRow r = dt.Rows[0]; idBloque = int.Parse(r["id"].ToString()); } } } catch (Exception ex) { isStackError = true; Log.Stack("HistorySaveBloque()", this, ex); } }
public List <Dictionary <string, object> > getMovies() { return(MySqlConnector.Query("SELECT * FROM movies ORDER BY created_at DESC")); }
public IActionResult Quotes(){ var allQuotes = MySqlConnector.Query("SELECT * FROM quotes ORDER BY created_at DESC"); ViewBag.allQuotes = allQuotes; return View(); }
private PanelService SavePanel(PanelService panelService) { Stopwatch sw = Stopwatch.StartNew(); if (Config.debugMode) { machine.LogBroadcast("warning", "Debug mode ON, no ejecuta StoreProcedure para guardar panel"); } else { #region SAVE PANELS ON DB string query = @"CALL sp_setInspectionPanel_optimizando('" + panelId + "','" + machine.mysql_id + "', '" + barcode + "', '" + programa + "', '" + fecha + "', '" + hora + "', '', '" + revisionAoi + "', '" + revisionIns + "', '" + totalErrores + "', '" + totalErroresFalsos + "', '" + totalErroresReales + "', '" + pcbInfo.bloques + "', '" + tipoBarcode + "', '" + Convert.ToInt32(pendiente) + "' , '" + machine.oracle_id + "' , '" + vtwinProgramNameId + "' , '" + spMode + "' );"; machine.LogBroadcast("debug", string.Format("Ejecutando StoreProcedure: sp_setInspectionPanel_optimizando({0}) =>", barcode) ); MySqlConnector sql = new MySqlConnector(); sql.LoadConfig("IASERVER"); DataTable sp = sql.Query(query); if (sql.rows) { // En caso de insert, informo el id_panel creado, si fue un update, seria el mismo id_panel... panelId = int.Parse(sp.Rows[0]["id_panel"].ToString()); //if (pendiente) //{ // Pendiente.Save(this); //} if (pendienteDelete) { Pendiente.Delete(this); } if (panelId > 0) { try { history.SavePanel(panelId, spMode); } catch (Exception ex) { machine.log.stack( string.Format("+ Error al ejecutar history.SavePanel({0}, {1}) ", panelId, spMode ), this, ex); } } } #endregion } // Es necesario volver a ejecutar el service, para obtener la OP asignada al panel if (spMode == "insert") { machine.LogBroadcast("debug", "Actualizando datos de panel insertado"); panelService = GetBarcodeInfoFromIAServer(); } sw.Stop(); machine.LogBroadcast("success", string.Format("Panel guardado: {0} (ms) {1} ", barcode, (long)sw.ElapsedMilliseconds) ); // Retorno ID, 0 si no pudo insertar, o actualizar return(panelService); }
public static void Download(string _tipoMaquina = "ALL") { string filtroMaquina = ""; switch (_tipoMaquina) { case "W": // Reseteo solo programas VTWIN. list.RemoveAll(o => o.tipoMaquina == "W"); filtroMaquina = " where tipo_maquina = 'W' "; break; case "Z": // Reseteo solo programas ZENITH. list.RemoveAll(o => o.tipoMaquina == "Z"); filtroMaquina = " where tipo_maquina = 'Z' "; break; case "R": // Reseteo solo programas RNS. list.RemoveAll(o => o.tipoMaquina == "R"); filtroMaquina = " where tipo_maquina = 'R' "; break; case "ALL": // Reseteo resultados SQL anteriores. list = new List <PcbInfo>(); break; } MySqlConnector sql = new MySqlConnector(); sql.LoadConfig("IASERVER"); DataTable query = sql.Query("select id,nombre,programa,bloques,segmentos,tipo_maquina,hash,DATE_FORMAT(fecha_modificacion,'%Y-%m-%d %H:%i:%s') as fecha_modificacion,libreria,etiquetas,secundaria from aoidata.pcb_data " + filtroMaquina); if (sql.rows) { foreach (DataRow r in query.Rows) { PcbInfo n = new PcbInfo(); n.id = int.Parse(r["id"].ToString()); n.programa = r["programa"].ToString(); n.nombre = r["nombre"].ToString(); n.bloques = int.Parse(r["bloques"].ToString()); n.segmentos = r["segmentos"].ToString(); n.tipoMaquina = r["tipo_maquina"].ToString(); n.hash = r["hash"].ToString(); n.fechaModificacion = r["fecha_modificacion"].ToString(); string _etiquetas = r["etiquetas"].ToString(); try { n.etiquetas = int.Parse(_etiquetas); } catch (Exception ex) { n.etiquetas = 0; } string sec = r["secundaria"].ToString(); if (sec.ToLower().Equals("false")) { n.secundaria = 0; } if (sec.ToLower().Equals("true")) { n.secundaria = 1; } n.libreria = r["secundaria"].ToString(); list.Add(n); } } }