protected override void Initialize(System.Web.Routing.RequestContext requestContext)
 {
     if (this._emailsender == null || _context == null)
     {
         //     this._repository = new DBRepository();
         this._context = new SICIBD2Entities1();
         this._emailsender = new EmailSender();
     }
     base.Initialize(requestContext);
 }
        private SICIBD2Entities1 AddEnfermdadesToContext(SICIBD2Entities1 _context, CONDICIONFISICA_INTERNOENFERMEDADES cONDICIONFISICA_INTERNOENFERMEDADES, int count, int p1, bool p2)
        {
            _context.Set<CONDICIONFISICA_INTERNOENFERMEDADES>().Add(cONDICIONFISICA_INTERNOENFERMEDADES);

            if(count % p1 == 0)
            {
                _context.SaveChanges();
                if(p2)
                {
                    _context.Dispose();
                    _context = new SICIBD2Entities1();
                    _context.Configuration.AutoDetectChangesEnabled = false;                   

                }
            }
            return _context;
        }
        private SICIBD2Entities1 AddConsumoDrogasToContext(SICIBD2Entities1 _context, DATOSPROBLEMADROGAS_CONSUMODROGAS dATOSPROBLEMADROGAS_CONSUMODROGAS, int count, int p1, bool p2)
        {
            _context.Set<DATOSPROBLEMADROGAS_CONSUMODROGAS>().Add(dATOSPROBLEMADROGAS_CONSUMODROGAS);

            if(count %p1 == 0)
            {
                _context.SaveChanges();
                if (p2)
                {
                    _context.Dispose();
                    _context = new SICIBD2Entities1();
                    _context.Configuration.AutoDetectChangesEnabled = false;
                }
            }
            return _context;
        }
        private void GuardarEnfermedadesInterno(List<CONDICIONFISICA_INTERNOENFERMEDADES> internosEnfermedadesList)
        {
            _context = new SICIBD2Entities1();
            _context.Configuration.AutoDetectChangesEnabled = false;

            int count = 0;

            for (int i = 0; i < internosEnfermedadesList.Count; i++ )
            {
                ++count;
                _context = AddEnfermdadesToContext(
                    _context,
                    new CONDICIONFISICA_INTERNOENFERMEDADES {
                        IDINGRESO = internosEnfermedadesList[i].IDINGRESO,
                        IDENFERMEDAD = internosEnfermedadesList[i].IDENFERMEDAD
                    }, count, internosEnfermedadesList.Count, true
                    );
            }
        }
        // estrategia de dispose de _context
        private SICIBD2Entities1 AddToContext(SICIBD2Entities1 _context, INFORMACIONACADEMICA_ESTUDIOSOFICIO iNFORMACIONACADEMICA_ESTUDIOSOFICIO, int count, int p1, bool p2)
        {
            _context.Set<INFORMACIONACADEMICA_ESTUDIOSOFICIO>().Add(iNFORMACIONACADEMICA_ESTUDIOSOFICIO);

            if(count % p1 == 0)
            {
                _context.SaveChanges();
                if(p2)
                {
                    _context.Dispose();
                    _context = new SICIBD2Entities1();
                    _context.Configuration.AutoDetectChangesEnabled = false;
                }
            }

            return _context;
        }
        private void GuardarConsumoDrogas(List<DATOSPROBLEMADROGAS_CONSUMODROGAS> consumoDrogasList)
        {
            _context = new SICIBD2Entities1();
            _context.Configuration.AutoDetectChangesEnabled = false;

            int count = 0;

            for (int i = 0; i < consumoDrogasList.Count; i++ )
            {
                ++count;
                _context = AddConsumoDrogasToContext(_context, new DATOSPROBLEMADROGAS_CONSUMODROGAS
                {
                    IDDROGA = consumoDrogasList[i].IDDROGA,
                    IDINGRESO = consumoDrogasList[i].IDINGRESO
                },
                count, 
                consumoDrogasList.Count,                
                true);
            }

        }
        // add to context masivo
        private void GuardarOficiosIngreso(List<INFORMACIONACADEMICA_ESTUDIOSOFICIO> estudiosOficioList)
        {
            _context = new SICIBD2Entities1();
            _context.Configuration.AutoDetectChangesEnabled = false;

            int count = 0;

            for (int i = 0; i < estudiosOficioList.Count; i++ )
            {
                ++count;
                _context = AddToContext(_context,
                    new INFORMACIONACADEMICA_ESTUDIOSOFICIO {
                    IDESTUDIOS = estudiosOficioList[i].IDESTUDIOS,
                    IDOFICIOS = estudiosOficioList[i].IDOFICIOS},
                    count, estudiosOficioList.Count, true
                    );
            }
        }
        //actualización de datos sobre estudios y base de estudios
        public async Task<ActionResult> GuardarEstudiosEscolaridad(INFORMACIONACADEMICA_ESTUDIOSESCOLARIDAD _model, bool _sabeleer, string[] oficiosSeleccionados)
        {
            // conexión lenta
            Thread.Sleep(2000);

            try {

                // get entity
                var _entity = new INFORMACIONACADEMICA_ESTUDIOSESCOLARIDAD();

                // base de estudios
                var _entityBase = new INFORMACIONACADEMICA_ESTUDIOS();
                _entityBase = await _context.INFORMACIONACADEMICA_ESTUDIOS.FindAsync(_model.IDESTUDIOS);
                _entityBase.SABELEERYESCRIBIR = _sabeleer;                

                // set entity
                _entity.IDESTUDIOS = _model.IDESTUDIOS;
                _entity.IDESCOLARIDAD = _model.IDESCOLARIDAD;
                _entity.DESCRIPCION = _model.DESCRIPCION;

                

                _context = null;
               
                ////save data
                //_context.Entry(_entityBase).State = EntityState.Modified;
                //_context.INFORMACIONACADEMICA_ESTUDIOSESCOLARIDAD.Add(_entity);
                //await _context.SaveChangesAsync(); 
                IDBFactory _dbfactory = new DBFactory();

                var status = _dbfactory.GuardarInfoAcademica(_entityBase, _entity);

                if(status == GuardarInfoAcademicaIngreso.Exito)
                {
                    // guardar los oficios
                    var oficiosSelect = new HashSet<string>(oficiosSeleccionados);
                    List<INFORMACIONACADEMICA_ESTUDIOSOFICIO> estudiosOficioList = new List<INFORMACIONACADEMICA_ESTUDIOSOFICIO>();

                    foreach (var ofi in oficiosSeleccionados)
                    {
                        estudiosOficioList.Add(new INFORMACIONACADEMICA_ESTUDIOSOFICIO
                        {
                            IDESTUDIOS = _model.IDESTUDIOS,
                            IDOFICIOS = Int32.Parse(ofi)
                        });
                    }

                    //set data masiva
                    GuardarOficiosIngreso(estudiosOficioList);

                    // salida
                    return Json(new { success = true, message = "Se ha guardado el registro con éxito" }, JsonRequestBehavior.AllowGet);
                }


                return Json(new { success = false, message = MensajeDeErroInfoAcadem(status) }, JsonRequestBehavior.AllowGet);
            }
            catch(Exception ex)
            {
                return Json(new { success= false, message = ex.Message }, JsonRequestBehavior.AllowGet);

            }
        }
Example #9
0
 private void AddToContext(AppLog appLog)
 {
     _context = new SICIBD2Entities1();
     _context.spInsertNewAppLogItem(appLog.Tipo, appLog.PostTime, appLog.Componente, appLog.Metodo, appLog.TiempoTomado, appLog.Propiedades, appLog.Usuario);
 }
Example #10
0
        private SICIBD2Entities1 AddToContext(SICIBD2Entities1 _context, 
            CONT_CODOTALONARIO cONT_CODOTALONARIO, 
            int count, 
            int p1, 
            bool p2)
        {
            _context.Set<CONT_CODOTALONARIO>().Add(cONT_CODOTALONARIO);
            if(count % p1 == 0)
            {
                _context.SaveChanges();
                if(p2)
                {
                    _context.Dispose();
                    _context = new SICIBD2Entities1();
                    _context.Configuration.AutoDetectChangesEnabled = false;
                }
            }

            return _context;
        }
Example #11
0
        public GuardarCodosTalonariosMasivos GuardarCodosMasivos(List<CONT_CODOTALONARIO> CodosListToAdd)
        {
            // se incializa el _context
               SICIBD2Entities1 _context = new SICIBD2Entities1();
               _context.Configuration.AutoDetectChangesEnabled = false;

               try {
               //contador de registros
               int count = 0;

            //se recorre lista para hacer la inserción mediante el método add to context
               for (int i = 0; i < CodosListToAdd.Count; i++ )
               {
               ++count;
               _context = AddToContext(
                   _context,
                   new CONT_CODOTALONARIO {
                       FECHAAPAGAR = CodosListToAdd[i].FECHAAPAGAR,
                       FECHACREADO = CodosListToAdd[i].FECHACREADO,
                       DESCRIPCION = CodosListToAdd[i].DESCRIPCION,
                       IDMES = CodosListToAdd[i].IDMES,
                       IDTALONARIO = CodosListToAdd[i].IDTALONARIO,
                       IDTIPOCONCEPTO = CodosListToAdd[i].IDTIPOCONCEPTO,
                       IDTIPOESTADO = CodosListToAdd[i].IDTIPOESTADO,
                       VALORAPAGAR = CodosListToAdd[i].VALORAPAGAR
                   },
                   count,
                   CodosListToAdd.Count,
                   true
                   );
               }

               return GuardarCodosTalonariosMasivos.Exito;
               }catch(Exception ex)
               {
               Console.WriteLine(ex.Message);
               return GuardarCodosTalonariosMasivos.ErrorAlGuardarInfo;
               }
        }