public static T_CoefArea InsertarCoefArea(int i) { var _worksheet = ImportarExcel.GetWorkSheetByName("BaseDatos"); var _value = _worksheet.GetSingleCellValue(i, 7); using (var db = new DB_PLANTILLA()) { T_CoefArea _coef = new T_CoefArea() { Value = _value }; var _record = db.GetSingleRecord <T_CoefArea>(x => x.Value == _coef.Value); if (_record == null) { db.AddElemento(_coef.GetType(), _coef); } else { _coef = _record; } return(_coef); } }
public static void InsertarAireFresco() { var _worksheet = ImportarExcel.GetWorkSheetByName("BaseDatos"); T_Aire_Fresco _af = null; for (int i = 2; i < _worksheet.Dimension.Rows + 1; i++) { var _aireFrescoM = _worksheet.GetSingleCellValue(i, 26); var _aireFrescoP = _worksheet.GetSingleCellValue(i, 27); using (var db = new DB_PLANTILLA()) { var _afM = db.GetSingleRecord <T_AF_Metro_Cuadrado>(x => x.Value == _aireFrescoM); var _afP = db.GetSingleRecord <T_AF_Persona>(x => x.Value == _aireFrescoP); var _afRecord = db.GetSingleRecord <T_Aire_Fresco>(x => x.Persona == _afP.Id && x.Metro_Cuadrado == _afM.Id); if (_afRecord == null) { _af = new T_Aire_Fresco() { Metro_Cuadrado = db.GetSingleRecord <T_AF_Metro_Cuadrado>(x => x.Value == _aireFrescoM).Id, Persona = db.GetSingleRecord <T_AF_Persona>(x => x.Value == _aireFrescoP).Id }; db.AddElemento(_af.GetType(), _af); } _af = _afRecord; } } }
public static void InsertarSubsistemas <T>() where T : class { string _pageName = ""; switch (typeof(T).Name) { case "T_Subsistema_Area": _pageName = "SubsistemaArea"; break; case "T_Subsistema_Tipo": _pageName = "SubsistemaTipo"; break; } var _subAreas = ImportarExcel.GetSubsistema <T>(_pageName); using (var db = new DB_PLANTILLA()) { foreach (var item in _subAreas) { IList <PropertyInfo> _properties = new List <PropertyInfo>(item.GetType().GetProperties()); dynamic _subsistema = Activator.CreateInstance <T>(); _subsistema.Value = _properties.FirstOrDefault(p => p.Name == "Value").GetValue(item).ToString(); DataBaseController.AddElemento(db, typeof(T), _subsistema); } } }
public static void InsertarLocalesTipo() { var _allLocalesTipo = ImportarExcel.GetAllLocalesTipo(); foreach (var keys in _allLocalesTipo) { var _grupoLocalesId = new DB_PLANTILLA().GetSingleRecord <T_Grupo_Locales>(x => x.Cod1 == keys.Key).Id; foreach (var value in keys.Value) { T_LocalTipo _localTipo = new T_LocalTipo() { Value = value, Grupo_Locales = _grupoLocalesId }; new DB_PLANTILLA().AddElemento(_localTipo.GetType(), _localTipo); } } //using (var db = new DB_PLANTILLA()) //{ //foreach (var item in _allLocalesTipo) //{ // var _grupoLocalesId = DataBaseController.GetSingleRecord<T_Grupo_Locales>(new DB_PLANTILLA(), x => x.Cod1 == item.Value).Id; // T_LocalTipo _localTipo = new T_LocalTipo() // { // Value = item.Key, // Grupo_Locales = _grupoLocalesId // }; // DataBaseController.AddElemento(new DB_PLANTILLA(), _localTipo.GetType(), _localTipo); //} //} }
public static void InsertarLocales() { var _worksheet = ImportarExcel.GetWorkSheetByName("BaseDatos"); using (var db = new DB_PLANTILLA()) { for (int i = 2; i < _worksheet.Dimension.Rows + 1; i++) { var _temp = ""; if (_worksheet.GetSingleCellValue(i, 1) == null || _worksheet.GetSingleCellValue(i, 1) == "-") { break; } var _roomID = int.Parse(_worksheet.GetSingleCellValue(i, 1)); var _keyName = _worksheet.GetSingleCellValue(i, 5); var _name = _worksheet.GetSingleCellValue(i, 6); var _habitacion = _worksheet.GetSingleCellValue(i, 10) != "0"; _temp = _worksheet.GetSingleCellValue(i, 13); var _subTipo = db.GetSingleRecord <T_Subsistema_Tipo>(x => x.Value == _temp).Id; _temp = _worksheet.GetSingleCellValue(i, 14); var _subArea = db.GetSingleRecord <T_Subsistema_Area>(x => x.Value == _temp).Id; _temp = _worksheet.GetSingleCellValue(i, 3); var _grupoLocales = db.GetSingleRecord <T_Grupo_Locales>(x => x.Cod1 == _temp).Id; var _climatizacion = InsertarClimatizaciones(i).Id; var _comunicaciones = InsertarComunicacionesTV(i).Id; _temp = _worksheet.GetSingleCellValue(i, 16); var _ambiente = db.GetSingleRecord <T_Ambiente>(x => x.Nombre == _temp).Id; var _coefArea = InsertarCoefArea(i).Id; var _tempInt = int.Parse(_worksheet.GetSingleCellValue(i, 11)); var _mod = db.GetSingleRecord <T_Mod>(x => x.Value == _tempInt).Id; var _tempFloat = float.Parse(_worksheet.GetSingleCellValue(i, 9)); var _porcientoBD = db.GetSingleRecord <T_Porciento_BD>(x => x.Value == _tempFloat).Id; _temp = _worksheet.GetSingleCellValue(i, 15); var _localTipo = db.GetSingleRecord <T_LocalTipo>(x => x.Value == _temp).Id; _temp = _worksheet.GetSingleCellValue(i, 12); var _tipoEdificio = db.GetSingleRecord <T_Tipo_Edificio>(x => x.Value == _temp).Id; T_Local _local = new T_Local() { RoomId = _roomID, Key_Name = _keyName, Name = _name, Habitacion = _habitacion, SubsistemaTipo = _subTipo, SubsistemaArea = _subArea, Climatizacion = _climatizacion, Comunicaciones_TV = _comunicaciones, Ambiente = _ambiente, Coef_Area = _coefArea, Mod = _mod, Porciento_BD = _porcientoBD, LocalTipo = _localTipo, Grupo_Local = _grupoLocales, Tipo_Edificio = _tipoEdificio }; db.AddElemento(_local.GetType(), _local); } } }
public static void InsertarGrupoLocales() { var _allGrupoLocales = ImportarExcel.GetAllGrupoLocales(); foreach (var item in _allGrupoLocales) { new DB_PLANTILLA().AddElemento(item.GetType(), item); } }
public static void AdicionarAmbientes() { //ImportarExcel.Singleton(); var _allAmbientes = ImportarExcel.GetAllAmbientes(); foreach (var item in _allAmbientes) { new DB_PLANTILLA().AddElemento(item.GetType(), item); } }
public static void InsertarAlojamiento() { var _alojamientos = ImportarExcel.GetAlojamientos(); using (var db = new DB_PLANTILLA()) { foreach (var item in _alojamientos) { db.AddElemento(item.GetType(), item); } } }
public static void AdicionarAll <T>() where T : class { //ImportarExcel.Singleton(); string _pageName = ""; switch (typeof(T).Name) { case "T_Catalogo_Techo": _pageName = "Techos"; break; case "T_Catalogo_Pared": _pageName = "Paredes"; break; case "T_Catalogo_Rodapie": _pageName = "Rodapie"; break; case "T_Catalogo_Suelo": _pageName = "Suelos"; break; case "T_Catalogo_Impermeable": _pageName = "Impermeable"; break; } var _workSheet = ImportarExcel.GetWorkSheetByName(_pageName); var _acabadosName = ImportarExcel.GetAcabadosName(_workSheet); using (var dbp = new DB_PLANTILLA()) { foreach (var item in _acabadosName) { var _record = ImportarExcel.GetCatalogoRow(item); IList <PropertyInfo> _properties = new List <PropertyInfo>(_record.GetType().GetProperties()); dynamic _acabado = Activator.CreateInstance(typeof(T)); _acabado.Cod = _properties.FirstOrDefault(p => p.Name == "Cod").GetValue(_record).ToString(); _acabado.CapituloID = _properties.FirstOrDefault(p => p.Name == "Capitulo_ID").GetValue(_record).ToString(); _acabado.Capitulo = _properties.FirstOrDefault(p => p.Name == "Capitulo").GetValue(_record).ToString(); _acabado.Grupo = _properties.FirstOrDefault(p => p.Name == "Grupo").GetValue(_record).ToString(); DataBaseController.AddElemento(dbp, typeof(T), _acabado); } } }
public static T_Climatizacion InsertarClimatizaciones(int i) { var _worksheet = ImportarExcel.GetWorkSheetByName("BaseDatos"); var _tratamiento = _worksheet.GetSingleCellValue(i, 22); var _equipamiento = _worksheet.GetSingleCellValue(i, 23); var _criterioM = _worksheet.GetSingleCellValue(i, 24); var _aireFrescoM = _worksheet.GetSingleCellValue(i, 26); var _aireFrescoP = _worksheet.GetSingleCellValue(i, 27); var _renovaciones = _worksheet.GetSingleCellValue(i, 28); var _wAire = _worksheet.GetSingleCellValue(i, 29); using (var db = new DB_PLANTILLA()) { var _afM = db.GetSingleRecord <T_AF_Metro_Cuadrado>(x => x.Value == _aireFrescoM).Id; var _afP = db.GetSingleRecord <T_AF_Persona>(x => x.Value == _aireFrescoP).Id; var _af = db.GetSingleRecord <T_Aire_Fresco>(x => x.Metro_Cuadrado == _afM && x.Persona == _afP).Id; T_Climatizacion _clima = new T_Climatizacion() { Tratamiento = db.GetSingleRecord <T_Tratamiento>(x => x.Value == _tratamiento).Id, Equipamiento = db.GetSingleRecord <T_Equipamiento>(x => x.Value == _equipamiento).Id, Criterio = db.GetSingleRecord <T_Criterio>(x => x.Value == _criterioM).Id, Aire_Fresco = _af, Renovaciones = db.GetSingleRecord <T_Renovaciones>(x => x.Value == _renovaciones).Id, W_Aire = db.GetSingleRecord <T_W_Aire>(x => x.Value == _wAire).Id }; var _record = db.GetSingleRecord <T_Climatizacion>(x => x.Tratamiento == _clima.Tratamiento && x.Equipamiento == _clima.Equipamiento && x.Criterio == _clima.Criterio && x.Aire_Fresco == _clima.Aire_Fresco && x.Renovaciones == _clima.Renovaciones && x.W_Aire == _clima.W_Aire); if (_record == null) { db.AddElemento(_clima.GetType(), _clima); } else { _clima = _record; } return(_clima); } }
public static void InsertarParametroFloat <T>(int column) where T : class { var _records = ImportarExcel.GetColumnValues(column); var _uniqueRecords = _records.Distinct(); foreach (var item in _uniqueRecords) { dynamic _parameter = Activator.CreateInstance(typeof(T)); _parameter.Value = item == "-" ? 0.0f : float.Parse(item); DataBaseController.AddElemento(new DB_PLANTILLA(), typeof(T), _parameter); } }
public static T_Comunicaciones_Tv InsertarComunicacionesTV(int i) { var _worksheet = ImportarExcel.GetWorkSheetByName("BaseDatos"); var _tf = _worksheet.GetSingleCellValue(i, 30); var _td = _worksheet.GetSingleCellValue(i, 31); var _tdPos = _worksheet.GetSingleCellValue(i, 32); var _upsc = _worksheet.GetSingleCellValue(i, 33); var _upsi = _worksheet.GetSingleCellValue(i, 34); var _tttv = _worksheet.GetSingleCellValue(i, 35); var _di = _worksheet.GetSingleCellValue(i, 36); var _altv = _worksheet.GetSingleCellValue(i, 37); using (var db = new DB_PLANTILLA()) { T_Comunicaciones_Tv _comm = new T_Comunicaciones_Tv() { Tf = db.GetSingleRecord <T_TF>(x => x.Value == _tf).Id, Td = db.GetSingleRecord <T_TD>(x => x.Value == _td).Id, TD_Pos = db.GetSingleRecord <T_TD_Pos>(x => x.Value == _tdPos).Id, UPSC = db.GetSingleRecord <T_UPSC>(x => x.Value == _upsc).Id, UPSI = db.GetSingleRecord <T_UPSI>(x => x.Value == _upsi).Id, TT_TV = db.GetSingleRecord <T_TT_TV>(x => x.Value == _tttv).Id, Di = db.GetSingleRecord <T_DI>(x => x.Value == _di).Id, Altv = db.GetSingleRecord <T_ALTV>(x => x.Value == _altv).Id }; var _record = db.GetSingleRecord <T_Comunicaciones_Tv>(x => x.Tf == _comm.Tf && x.Td == _comm.Td && x.TD_Pos == _comm.TD_Pos && x.UPSC == _comm.UPSC && x.UPSI == _comm.UPSI && x.TT_TV == _comm.TT_TV && x.Di == _comm.Di && x.Altv == _comm.Altv); if (_record == null) { db.AddElemento(_comm.GetType(), _comm); } else { _comm = _record; } return(_comm); } }
public static void CleanAllTemplates() { using (var dbp = new DB_PLANTILLA()) { try { dbp.DeleteAllRecords <T_Local>(); //Acabados dbp.DeleteAllRecords <T_Ambiente>(); dbp.DeleteAllRecords <T_Catalogo_Techo>(); dbp.DeleteAllRecords <T_Catalogo_Pared>(); dbp.DeleteAllRecords <T_Catalogo_Rodapie>(); dbp.DeleteAllRecords <T_Catalogo_Suelo>(); dbp.DeleteAllRecords <T_Catalogo_Impermeable>(); //Climatizacion dbp.DeleteAllRecords <T_Climatizacion>(); dbp.DeleteAllRecords <T_Aire_Fresco>(); dbp.DeleteAllRecords <T_AF_Persona>(); dbp.DeleteAllRecords <T_AF_Metro_Cuadrado>(); dbp.DeleteAllRecords <T_Tratamiento>(); dbp.DeleteAllRecords <T_Equipamiento>(); dbp.DeleteAllRecords <T_Criterio>(); dbp.DeleteAllRecords <T_Renovaciones>(); dbp.DeleteAllRecords <T_W_Aire>(); //TT_TV dbp.DeleteAllRecords <T_Comunicaciones_Tv>(); dbp.DeleteAllRecords <T_TF>(); dbp.DeleteAllRecords <T_TD>(); dbp.DeleteAllRecords <T_TD_Pos>(); dbp.DeleteAllRecords <T_UPSC>(); dbp.DeleteAllRecords <T_TT_TV>(); dbp.DeleteAllRecords <T_DI>(); dbp.DeleteAllRecords <T_ALTV>(); dbp.DeleteAllRecords <T_UPSI>(); //Alojamiento dbp.DeleteAllRecords <T_Alojamiento_Tipo>(); dbp.DeleteAllRecords <T_Alojamiento>(); //Otros dbp.DeleteAllRecords <T_CoefArea>(); dbp.DeleteAllRecords <T_Mod>(); dbp.DeleteAllRecords <T_Tipo_Edificio>(); dbp.DeleteAllRecords <T_Porciento_BD>(); dbp.DeleteAllRecords <T_LocalTipo>(); dbp.DeleteAllRecords <T_Grupo_Locales>(); dbp.DeleteAllRecords <T_Subsistema_Area>(); dbp.DeleteAllRecords <T_Subsistema_Tipo>(); //Reiniciar los contadores de todas las tablas (local y ambiente no tienen autoincremento por lo que no se incluyen) dbp.ReseedTable(typeof(T_Catalogo_Techo)); dbp.ReseedTable(typeof(T_Catalogo_Pared)); dbp.ReseedTable(typeof(T_Catalogo_Rodapie)); dbp.ReseedTable(typeof(T_Catalogo_Suelo)); dbp.ReseedTable(typeof(T_Catalogo_Impermeable)); dbp.ReseedTable(typeof(T_Climatizacion)); dbp.ReseedTable(typeof(T_Aire_Fresco)); dbp.ReseedTable(typeof(T_AF_Persona)); dbp.ReseedTable(typeof(T_AF_Metro_Cuadrado)); dbp.ReseedTable(typeof(T_Tratamiento)); dbp.ReseedTable(typeof(T_Equipamiento)); dbp.ReseedTable(typeof(T_Criterio)); dbp.ReseedTable(typeof(T_Renovaciones)); dbp.ReseedTable(typeof(T_W_Aire)); dbp.ReseedTable(typeof(T_Comunicaciones_Tv)); dbp.ReseedTable(typeof(T_TF)); dbp.ReseedTable(typeof(T_TD)); dbp.ReseedTable(typeof(T_TD_Pos)); dbp.ReseedTable(typeof(T_UPSC)); dbp.ReseedTable(typeof(T_TT_TV)); dbp.ReseedTable(typeof(T_DI)); dbp.ReseedTable(typeof(T_ALTV)); dbp.ReseedTable(typeof(T_UPSI)); dbp.ReseedTable(typeof(T_CoefArea)); dbp.ReseedTable(typeof(T_Alojamiento_Tipo)); dbp.ReseedTable(typeof(T_Alojamiento)); dbp.ReseedTable(typeof(T_Mod)); dbp.ReseedTable(typeof(T_Tipo_Edificio)); dbp.ReseedTable(typeof(T_Porciento_BD)); dbp.ReseedTable(typeof(T_Grupo_Locales)); dbp.ReseedTable(typeof(T_LocalTipo)); dbp.ReseedTable(typeof(T_Subsistema_Area)); dbp.ReseedTable(typeof(T_Subsistema_Tipo)); } catch (Exception ex) { throw; } } //Reimportando todo ImportarExcel.Singleton(); ReinsertarAcabados.AdicionarAll <T_Catalogo_Suelo>(); ReinsertarAcabados.AdicionarAll <T_Catalogo_Pared>(); ReinsertarAcabados.AdicionarAll <T_Catalogo_Techo>(); ReinsertarAcabados.AdicionarAll <T_Catalogo_Impermeable>(); ReinsertarAcabados.AdicionarAll <T_Catalogo_Rodapie>(); ReinsertarAcabados.AdicionarAmbientes(); ReinsertarSubsistemas.InsertarSubsistemas <T_Subsistema_Tipo>(); ReinsertarSubsistemas.InsertarSubsistemas <T_Subsistema_Area>(); ReinsertarAlojamientos.InsertarAlojamiento(); ReinsertarLocal.InsertarParametros <T_Tratamiento>(22); ReinsertarLocal.InsertarParametros <T_Equipamiento>(23); ReinsertarLocal.InsertarParametros <T_Criterio>(24); ReinsertarLocal.InsertarParametros <T_AF_Metro_Cuadrado>(26); ReinsertarLocal.InsertarParametros <T_AF_Persona>(27); ReinsertarLocal.InsertarParametros <T_Renovaciones>(28); ReinsertarLocal.InsertarParametros <T_W_Aire>(29); ReinsertarLocal.InsertarAireFresco(); ReinsertarLocal.InsertarParametros <T_TF>(30); ReinsertarLocal.InsertarParametros <T_TD>(31); ReinsertarLocal.InsertarParametros <T_TD_Pos>(32); ReinsertarLocal.InsertarParametros <T_UPSC>(33); ReinsertarLocal.InsertarParametros <T_UPSI>(34); ReinsertarLocal.InsertarParametros <T_TT_TV>(35); ReinsertarLocal.InsertarParametros <T_DI>(36); ReinsertarLocal.InsertarParametros <T_ALTV>(37); ReinsertarGrupoLocales.InsertarGrupoLocales(); ReinsertarGrupoLocales.InsertarLocalesTipo(); ReinsertarLocal.InsertarParametroInt <T_Mod>(11); ReinsertarLocal.InsertarParametroFloat <T_Porciento_BD>(9); ReinsertarLocal.InsertarParametros <T_Tipo_Edificio>(12); ReinsertarLocal.InsertarLocales(); MessageBox.Show("Completado!"); }