public void LoadDocument() { PATH = GetPath(); try { lock (lockThis) { _log.Info("Inicio DocumentManager " + System.Reflection.MethodBase.GetCurrentMethod().Name); if (!File.Exists(PATH)) { File.CreateText(PATH); } } } catch (ArgumentNullException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (PathTooLongException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (DirectoryNotFoundException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (UnauthorizedAccessException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (NotSupportedException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (SecurityException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (IOException ex) { _log.Fatal("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (Exception ex) { _log.Fatal("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } finally { _log.Info("Fin de DocumentManager " + System.Reflection.MethodBase.GetCurrentMethod().Name); } }
public Alumno Add(Alumno alumno) { try { _log.Fatal("Inicio AlumnoBl " + System.Reflection.MethodBase.GetCurrentMethod().Name + " -> " + alumno.ToString()); //Calcular Campos alumno.Edad = CalcularEdad(alumno.FechaNacimiento); alumno.FechaRegistro = CalcularFechaRegistro(); IDAO <Alumno> doc = DAOFactory <Alumno> .getFormat(); return(doc.Insert(alumno)); } catch (ArgumentNullException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (PathTooLongException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (DirectoryNotFoundException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (UnauthorizedAccessException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (NotSupportedException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (SecurityException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (IOException ex) { _log.Fatal("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (Exception ex) { _log.Fatal("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } finally { _log.Info("Fin de AlumnoBl " + System.Reflection.MethodBase.GetCurrentMethod().Name); } }
public T Insert(T entity) { try { IDAO <T> daof = DAOFactory <T> .getFormat(); daof. _log.Info("Inicio AlumnoDao " + System.Reflection.MethodBase.GetCurrentMethod().Name + " Alumno ->" + entity.ToString()); return(iDoc.Insert(entity)); } catch (ArgumentNullException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (PathTooLongException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (DirectoryNotFoundException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (UnauthorizedAccessException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (NotSupportedException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (System.Security.SecurityException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (IOException ex) { _log.Fatal("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (Exception ex) { _log.Fatal("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } finally { _log.Info("Fin de AlumnoDao " + System.Reflection.MethodBase.GetCurrentMethod().Name); } }
//Mindundi2017 public void email_send(string error) { MailMessage mail = new MailMessage(); mail.From = new MailAddress(myMail); mail.To.Add("*****@*****.**"); mail.Subject = "ERROR:"; mail.Body = error; /* System.Net.Mail.Attachment attachment; * attachment = new System.Net.Mail.Attachment("c:/textfile.txt"); * mail.Attachments.Add(attachment); */ var SmtpServer = new SmtpClient { Host = smtp, Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(myMail, "Mindundi2017") }; try { _log.Info("Inicio Envio Correo " + System.Reflection.MethodBase.GetCurrentMethod().Name); SmtpServer.Send(mail); } catch (SmtpFailedRecipientsException ex) { _log.Fatal("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); } catch (Exception ex) { _log.Fatal("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); } finally { _log.Info("Final Envio Correo " + System.Reflection.MethodBase.GetCurrentMethod().Name); } }
public T Insert(T entity) { try { _log.Info("Inicio TXT " + System.Reflection.MethodBase.GetCurrentMethod().Name); using (var tw = new StreamWriter(DocumentsManager.PATH, true)) { tw.WriteLine(entity.ToString()); } //throw new IOException(); return Select(entity.Guid); } catch (ArgumentNullException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (PathTooLongException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (DirectoryNotFoundException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (UnauthorizedAccessException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (NotSupportedException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (SecurityException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (IOException ex) { _log.Fatal("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (Exception ex) { _log.Fatal("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } finally { _log.Info("Fin de TXT " + System.Reflection.MethodBase.GetCurrentMethod().Name); } }
public void TestInit() { _log.Info("Inicialiazamos Tests"); _log.Debug("Limpiamos de ficheros existentes"); DocumentsManager docMan = new DocumentsManager(TipoFichero.JSON); String filename = docMan.GetPath(); if (File.Exists(filename)) { File.Delete(filename); } _log.Debug("Obtenemos el alumno DAO con el formato actual."); iAlumnoDao = new AlumnoDao <Alumno>(DAOFactory <Alumno> .getFormat()); }
public void Formater(TipoFichero tipoFichero) { try { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); _log.Info("Inicio AlumnoBl " + System.Reflection.MethodBase.GetCurrentMethod().Name); var value = (int)tipoFichero; config.AppSettings.Settings["tipoFichero"].Value = value.ToString(); config.Save(ConfigurationSaveMode.Modified); } catch (ConfigurationErrorsException ex) { _log.Fatal("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + " Error al Escribir en AppSettings--> " + ex.Message); throw; } catch (Exception ex) { _log.Fatal("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } finally { _log.Info("Fin de AlumnoBl " + System.Reflection.MethodBase.GetCurrentMethod().Name); } }
public T Insert(T entity) { try { _log.Info("Inicio JSON " + System.Reflection.MethodBase.GetCurrentMethod().Name); List <T> entityList = SelectAll(); if (entityList == null) { entityList = new List <T>(); } using (StreamWriter file = new StreamWriter(@PATH)) { JsonSerializer serializer = new JsonSerializer { Formatting = Formatting.Indented }; entityList.Add(entity); serializer.Serialize(file, entityList); } return(Select(entity.Guid)); } catch (ArgumentNullException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (PathTooLongException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (DirectoryNotFoundException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (UnauthorizedAccessException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (NotSupportedException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (SecurityException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (IOException ex) { _log.Fatal("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (Exception ex) { _log.Fatal("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } finally { _log.Info("Fin de JSON " + System.Reflection.MethodBase.GetCurrentMethod().Name); } }
public T Insert(T entity) { try { Log.Info("Inicio XML " + System.Reflection.MethodBase.GetCurrentMethod().Name); _log.Info("Inicio XML " + System.Reflection.MethodBase.GetCurrentMethod().Name); List <T> entityList = SelectAll(); XmlSerializer xSeriz = new XmlSerializer(typeof(List <Alumno>)); if (entityList == null) { entityList = new List <T>(); } using (FileStream fs1 = new FileStream(docManager.GetPath(), FileMode.Create)) { entityList.Add(entity); xSeriz.Serialize(fs1, entityList); } return(Select(entity.Guid)); } catch (ArgumentNullException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (PathTooLongException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (DirectoryNotFoundException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (UnauthorizedAccessException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (NotSupportedException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (SecurityException ex) { _log.Error("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (IOException ex) { _log.Fatal("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } catch (Exception ex) { _log.Fatal("Error en " + System.Reflection.MethodBase.GetCurrentMethod().Name + "--> " + ex.Message); throw; } finally { _log.Info("Fin de XML " + System.Reflection.MethodBase.GetCurrentMethod().Name); } }