private int SubirArchivoInterno(string rutaConFichero) { var servidorDeArchivos = GestorDeVariables.LeerVariable(Contexto, Variable.CFG_Servidor_Archivos, true); if (!Directory.Exists(servidorDeArchivos.Valor)) { throw new Exception($"La ruta del servidor documental {servidorDeArchivos.Valor} asignada a la variable {Variable.CFG_Servidor_Archivos} no está definida"); } var fecha = DateTime.Now; var almacenarEn = $@"{servidorDeArchivos.Valor}\{fecha.Year}\{fecha.Month}\{fecha.Day}\{fecha.Hour}\{Contexto.DatosDeConexion.IdUsuario}"; Directory.CreateDirectory(almacenarEn); var fichero = Path.GetFileName(rutaConFichero); var archivo = new ArchivoDtm { Nombre = fichero, AlmacenadoEn = almacenarEn }; var parametros = new ParametrosDeNegocio(enumTipoOperacion.Insertar); var tran = Contexto.IniciarTransaccion(); try { PersistirRegistro(archivo, parametros); File.Move(rutaConFichero, $@"{archivo.AlmacenadoEn}\{archivo.Id}.se", true); Contexto.Commit(tran); } catch (Exception) { Contexto.Rollback(tran); throw; } return(archivo.Id); }
public VariablesController(GestorDeVariables gestorDeVariables, GestorDeErrores gestorDeErrores) : base ( gestorDeVariables, gestorDeErrores ) { }
private static string GenerarExcel <T>(ContextoSe contexto, List <T> elementos) { VariableDtm ruta = GestorDeVariables.VariableDeRutaDeExportaciones(contexto); var fichero = $"{elementos[0].GetType()}.xls"; var fecha = DateTime.Now; var rutaDeExportacion = $@"{ruta.Valor}\{fecha.Year}-{fecha.Month}-{fecha.Day}\{contexto.DatosDeConexion.Login}"; if (!Directory.Exists(rutaDeExportacion)) { Directory.CreateDirectory(rutaDeExportacion); } return(elementos.ToExcel(rutaDeExportacion, fichero)); }