// Delete. public void DeleteCondPro(IEnumerable<Model.CondProModel> condpros) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { foreach (Model.CondProModel p in condpros) { CAT_CONDPRO result = null; try { result = (from o in entity.CAT_CONDPRO where o.IdCondicion == p.IdCondicion select o).First(); } catch (Exception) { throw; } if (result != null) { result.IsActive = false; result.IsModified = true; result.LastModifiedDate = new UNID().getNewUNID(); } } entity.SaveChanges(); _SyncRepository.UpdateSyn(entity); } }
// Delete. public void DeleteEstPuntoMed(IEnumerable<Model.EstPuntoMedModel> estpuntomeds) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { foreach (Model.EstPuntoMedModel p in estpuntomeds) { REL_EST_PUNTOMED result = null; try { result = (from o in entity.REL_EST_PUNTOMED where o.IdEstPuntoMed == p.IdEstPuntoMed select o).First(); } catch (Exception) { throw; } if (result != null) { result.IsActive = false; result.IsModified = true; result.LastModifiedDate = new UNID().getNewUNID(); } } entity.SaveChanges(); _SyncRepository.UpdateSyn(entity); } }
// Delete. public void DeleteSistema(IEnumerable<Model.SistemaModel> sistemas) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { foreach (Model.SistemaModel p in sistemas) { CAT_SISTEMA result = null; try { result = (from o in entity.CAT_SISTEMA where o.IdSistema == p.IdSistema select o).First(); } catch (Exception) { throw; } if (result != null) { result.IsActive = false; result.IsModified = true; result.LastModifiedDate = new UNID().getNewUNID(); } } entity.SaveChanges(); _SyncRepository.UpdateSyn(entity); } }
// Delete. public void DeleteEstructuraDependencia(IEnumerable<Model.EstructuraDependenciaModel> estructuradependencias) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { foreach (Model.EstructuraDependenciaModel p in estructuradependencias) { REL_ESTRUCTURA_DEPENDENCIA result = null; try { result = (from o in entity.REL_ESTRUCTURA_DEPENDENCIA where o.IdEstructuraDependencia == p.IdEstructuraDependencia select o).First(); } catch (Exception) { throw; } if (result != null) { result.IsActive = false; result.IsModified = true; result.LastModifiedDate = new UNID().getNewUNID(); } } entity.SaveChanges(); _SyncRepository.UpdateSyn(entity); } }
public bool ConfirmationUpload(List<CiTrackingUploadConfirmationModel> items) { bool x = false; using (var entity=new db_SeguimientoProtocolo_r2Entities()) { foreach (var row in items) { try { CI_TRACKING result = null; result = (from i in entity.CI_TRACKING where i.IdTracking == row.IdTracking select i).First(); if (result != null) { result.IsModified = false; result.ServerLastModifiedDate = row.SLMD; } } catch (Exception ex) { AppBitacoraRepository.Insert(new AppBitacoraModel() { Fecha = DateTime.Now, Metodo = ex.StackTrace, Mensaje = ex.Message }); } } entity.SaveChanges(); } return x; }
// Delete. public void DeletePuntoMedicion(IEnumerable<Model.PuntoMedicionModel> puntomedicions) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { foreach (Model.PuntoMedicionModel p in puntomedicions) { CAT_PUNTO_MEDICION result = null; try { result = (from o in entity.CAT_PUNTO_MEDICION where o.IdPuntoMedicion == p.IdPuntoMedicion select o).First(); } catch (Exception) { throw; } if (result != null) { result.IsActive = false; result.IsModified = true; result.LastModifiedDate = new UNID().getNewUNID(); } } entity.SaveChanges(); _SyncRepository.UpdateSyn(entity); } }
// Delete. public void DeleteAccionProtocolo(IEnumerable<Model.AccionProtocoloModel> accionprotocolos) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { foreach (Model.AccionProtocoloModel p in accionprotocolos) { REL_ACCION_PROTOCOLO result = null; try { result = (from o in entity.REL_ACCION_PROTOCOLO where o.IdAccionProtocolo == p.IdAccionProtocolo select o).First(); } catch (Exception) { throw; } if (result != null) { result.IsActive = false; result.IsModified = true; result.LastModifiedDate = new UNID().getNewUNID(); } } entity.SaveChanges(); _SyncRepository.UpdateSyn(entity); } }
public void InsertSyncLog(SyncLogModel syncModel) { try { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { if (syncModel != null) { entity.CAT_SYNC_LOG.AddObject(new CAT_SYNC_LOG() { IdSyncLog = syncModel.IdSyncLog, FechaSinc = syncModel.Fecha, Hora = syncModel.Hora, Menssage = syncModel.Menssage, Exception=syncModel.Exception }); entity.SaveChanges(); } } } catch (Exception) { ; } }
public void InsertAppUsuario(Model.AppUsuarioModel usuario) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { if (usuario != null) { //Validar si el elemento ya existe APP_USUARIO result = null; try { result = (from o in entity.APP_USUARIO where o.IdUsuario == usuario.IdUsuario select o).First(); } catch (Exception ex) { ; } if (result == null) { entity.APP_USUARIO.AddObject( new APP_USUARIO() { IdUsuario = usuario.IdUsuario, Nombre = usuario.Nombre, IsActive = usuario.IsActive } ); entity.SaveChanges(); } } } }
public void UpdateServerLastDataLocal(long serverFecha) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { var modified = entity.CAT_SERVER_LASTDATA.First(p => p.IdServerLastData == 20120101000000000); modified.ActualDate = serverFecha; entity.SaveChanges(); } }
public static void Insert(AppBitacoraModel model) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { entity.APP_BITACORA.AddObject(new APP_BITACORA() { Fecha=model.Fecha, Metodo=model.Metodo, Mensaje=model.Mensaje }); entity.SaveChanges(); } }
public void Upsert(ObservableCollection<AppSettingsModel> items) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { try { foreach (AppSettingsModel row in items) { APP_SETTINGS result = null; try { result = (from s in entity.APP_SETTINGS where s.IdSettings == row.IdSettings select s).First(); } catch (Exception) { ; } if (result == null) { entity.APP_SETTINGS.AddObject( new APP_SETTINGS() { IdSettings = row.IdSettings, SettingName = row.SettingName, Value = row.Value, LastModifiedDate =(long)row.LastModifiedDate, ServerLastModifiedDate = row.ServerLastModifiedDate }); } if (result != null && result.LastModifiedDate < row.LastModifiedDate) { result.IdSettings = row.IdSettings; result.SettingName = row.SettingName; result.Value = row.Value; result.LastModifiedDate =(long)row.LastModifiedDate; result.ServerLastModifiedDate = row.ServerLastModifiedDate; } } entity.SaveChanges(); } catch (Exception ex) { AppBitacoraRepository.Insert(new AppBitacoraModel() { Fecha = DateTime.Now, Metodo = ex.StackTrace, Mensaje = ex.Message }); } } }
public void Upsert(ObservableCollection<ProtocoloModel> items) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { try { foreach (ProtocoloModel row in items) { CAT_PROTOCOLO result = null; try { result = (from s in entity.CAT_PROTOCOLO where s.IdPuntoMedicion == row.IdPuntoMedicion select s).First(); } catch (Exception) { ; } if (result == null) { entity.CAT_PROTOCOLO.AddObject( new CAT_PROTOCOLO() { IdProtocolo = row.IdProtocolo, IdPuntoMedicion = row.IdPuntoMedicion, LastModifiedDate = row.LastModifiedDate, ServerLastModifiedDate = row.ServerLastModifiedDate, }); } if (result != null && result.LastModifiedDate < row.LastModifiedDate) { result.IdProtocolo = row.IdProtocolo; result.IdPuntoMedicion = row.IdPuntoMedicion; result.LastModifiedDate = row.LastModifiedDate; result.ServerLastModifiedDate = row.ServerLastModifiedDate; } } entity.SaveChanges(); } catch (Exception ex) { AppBitacoraRepository.Insert(new AppBitacoraModel() { Fecha = DateTime.Now, Metodo = ex.StackTrace, Mensaje = ex.Message }); } } }
public void ResetSyncDummy() { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { try { var modified = entity.CAT_SYNC.First(p => p.IdSycn == 20120101000000000); modified.ActualDate = 0; entity.SaveChanges(); } catch (Exception) { ; } } }
public void InsertUploadLogLocal(Model.UploadLogModel uploadLog) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { entity.CAT_UPLOAD_LOG.AddObject( new CAT_UPLOAD_LOG() { IdUploadLog = uploadLog.IdUploadLog, IdUsuario = uploadLog.IdUsuario, IpDir = uploadLog.IpDir, Msg = uploadLog.Msg, PcName = uploadLog.PcName } ); entity.SaveChanges(); } }
public bool CloseSession() { bool x = false; try { using (var entity=new db_SeguimientoProtocolo_r2Entities()) { var item = (from res in entity.APP_USUARIO select res).FirstOrDefault(); entity.APP_USUARIO.DeleteObject(item); entity.SaveChanges(); } } catch (Exception ex) { AppBitacoraRepository.Insert(new AppBitacoraModel() { Fecha = DateTime.Now, Metodo = ex.StackTrace, Mensaje = ex.Message }); } return x; }
public void DeleteAppRoles(IEnumerable<Model.AppRolModel> roles) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { foreach (Model.AppRolModel p in roles) { try { var res = (from o in entity.APP_ROL where o.IdRol == p.IdRol select o).First().IsActive = false; } catch (Exception) { throw; } } entity.INF_INFODOC.AddObject( new INF_INFODOC() { IdInfoDoc = new UNID().getNewUNID(), IdRol = 2, IdUsuario = 3, IdForm = 4, IdAccion = 2, Fecha = 6, IdRef = 7, IpAddress = "a", MacAdress = "a", PcName = "a", IsActive = true, IsModified = false, LastModifiedDate = 1 } ); entity.SaveChanges(); } }
// Create. public void InsertPuntoMedicion(Model.PuntoMedicionModel puntomedicion) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { if (puntomedicion != null) { //Validar si el elemento ya existe CAT_PUNTO_MEDICION result = null; try { result = (from o in entity.CAT_PUNTO_MEDICION where o.IdPuntoMedicion == puntomedicion.IdPuntoMedicion select o).First(); } catch (Exception ex) { ; } if (result == null) { entity.CAT_PUNTO_MEDICION.AddObject( new CAT_PUNTO_MEDICION() { IdPuntoMedicion = puntomedicion.IdPuntoMedicion, PuntoMedicionName = puntomedicion.PuntoMedicionName.Trim(), IdUnidadMedida = puntomedicion.UNIDADMEDIDA.IdUnidadMedida, IdTipoPuntoMedicion = puntomedicion.TIPOPUNTOMEDICION.IdTipoPuntoMedicion, ValorReferencia = puntomedicion.ValorReferencia, ParametroReferencia = puntomedicion.ParametroReferencia.Trim(), IsActive = puntomedicion.IsActive, IsModified = true, LastModifiedDate = new UNID().getNewUNID() } ); entity.SaveChanges(); _SyncRepository.UpdateSyn(entity); } } } }
// Update. public void UpdateCondPro(Model.CondProModel condpro) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { CAT_CONDPRO result = null; try { result = (from o in entity.CAT_CONDPRO where o.IdCondicion == condpro.IdCondicion select o).First(); } catch (Exception ex) { ; } if (result != null) { result.IdCondicion = condpro.IdCondicion; result.CondicionName = condpro.CondicionName; result.IsModified = true; result.LastModifiedDate = new UNID().getNewUNID(); entity.SaveChanges(); _SyncRepository.UpdateSyn(entity); } } }
public void LoadSyncLocal(ObservableCollection<Model.PuntoMedicionModel> puntoMedicion) { if (puntoMedicion != null) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { foreach (Model.PuntoMedicionModel item in puntoMedicion) { var query = (from cust in entity.CAT_PUNTO_MEDICION where item.IdPuntoMedicion == cust.IdPuntoMedicion select cust).ToList(); //Actualización if (query.Count > 0) { // compara la fecha mas actual si es mayor la local que la servidor actualiza var local = query.First(); if (local.LastModifiedDate < item.LastModifiedDate) UpdatePuntoMedicionSyncLocal(item, entity); } //Inserción else InsertPuntoMedicionSyncLocal(item, entity); } entity.SaveChanges(); } } }
public void LoadSyncLocal(ObservableCollection<Model.CondProModel> condpro) { if (condpro != null) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { foreach (Model.CondProModel item in condpro) { var query = (from cust in entity.CAT_CONDPRO where item.IdCondicion == cust.IdCondicion select cust).ToList(); //Actualización if (query.Count > 0) { // compara la fecha mas actual si es mayor la local que la servidor actualiza var local = query.First(); if (local.LastModifiedDate < item.LastModifiedDate) UpdateCondProSyncLocal(item, entity); } //Inserción else InsertCondProSyncLocal(item, entity); //resetea la bandera en le servidor de IsModified a false var modified = entity.CAT_CONDPRO.First(p => p.IdCondicion == item.IdCondicion); modified.IsModified = false; } entity.SaveChanges(); } } }
// Create. public void InsertCondPro(Model.CondProModel condpro) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { if (condpro != null) { //Validar si el elemento ya exist CAT_CONDPRO result = null; try { result = (from o in entity.CAT_CONDPRO where o.IdCondicion == condpro.IdCondicion select o).First(); } catch (Exception ex) { ; } if (result == null) { entity.CAT_CONDPRO.AddObject( new CAT_CONDPRO() { IdCondicion = condpro.IdCondicion, CondicionName = condpro.CondicionName.Trim(), IsActive = condpro.IsActive, IsModified = true, LastModifiedDate = new UNID().getNewUNID() } ); entity.SaveChanges(); _SyncRepository.UpdateSyn(entity); } } } }
// Update. public void UpdateEstPuntoMed(Model.EstPuntoMedModel estpuntomed) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { REL_EST_PUNTOMED result = null; try { result = (from o in entity.REL_EST_PUNTOMED where o.IdEstPuntoMed == estpuntomed.IdEstPuntoMed select o).First(); } catch (Exception ex) { ; } if (result != null) { result.IdEstPuntoMed = estpuntomed.IdEstPuntoMed; result.IdEstructura = estpuntomed.ESTRUCTURA.IdEstructura; result.IdPuntoMedicion = estpuntomed.PUNTOMEDICION.IdPuntoMedicion; result.IsModified = true; result.LastModifiedDate = new UNID().getNewUNID(); entity.SaveChanges(); _SyncRepository.UpdateSyn(entity); } } }
// Create varios. public void InsertEstPuntoMeds(IEnumerable<Model.EstructuraModel> observableCollection, Model.PuntoMedicionModel puntoMedicionModel) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { foreach (Model.EstructuraModel p in observableCollection) { REL_EST_PUNTOMED result = null; try { result = (from o in entity.REL_EST_PUNTOMED where o.IdPuntoMedicion == puntoMedicionModel.IdPuntoMedicion && o.IdEstructura == p.IdEstructura select o).First(); } catch (Exception ex) { ; } if (result == null) { entity.REL_EST_PUNTOMED.AddObject( new REL_EST_PUNTOMED() { IdEstPuntoMed = new UNID().getNewUNID(), IdEstructura = p.IdEstructura, IdPuntoMedicion = puntoMedicionModel.IdPuntoMedicion, IsActive = true, IsModified = true, LastModifiedDate = new UNID().getNewUNID() } ); entity.SaveChanges(); _SyncRepository.UpdateSyn(entity); } } } }
// Create. public void InsertEstPuntoMed(Model.EstPuntoMedModel estpuntomed) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { if (estpuntomed != null) { //Validar si el elemento ya existe REL_EST_PUNTOMED result = null; try { result = (from o in entity.REL_EST_PUNTOMED where o.IdEstPuntoMed == estpuntomed.IdEstPuntoMed select o).First(); } catch (Exception ex) { ; } if (result == null) { entity.REL_EST_PUNTOMED.AddObject( new REL_EST_PUNTOMED() { IdEstPuntoMed = estpuntomed.IdEstPuntoMed, IdEstructura = estpuntomed.ESTRUCTURA.IdEstructura, IdPuntoMedicion = estpuntomed.PUNTOMEDICION.IdPuntoMedicion, IsActive = estpuntomed.IsActive, IsModified = true, LastModifiedDate = new UNID().getNewUNID() } ); entity.SaveChanges(); _SyncRepository.UpdateSyn(entity); } } } }
// Update. public void UpdatePuntoMedicion(Model.PuntoMedicionModel puntomedicion) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { CAT_PUNTO_MEDICION result = null; try { result = (from o in entity.CAT_PUNTO_MEDICION where o.IdPuntoMedicion == puntomedicion.IdPuntoMedicion select o).First(); } catch (Exception ex) { ; } if (result != null) { result.PuntoMedicionName = puntomedicion.PuntoMedicionName; result.IdUnidadMedida = puntomedicion.UNIDADMEDIDA.IdUnidadMedida; result.IdTipoPuntoMedicion = puntomedicion.TIPOPUNTOMEDICION.IdTipoPuntoMedicion; result.ValorReferencia = puntomedicion.ValorReferencia; result.ParametroReferencia = puntomedicion.ParametroReferencia; result.IsModified = true; result.LastModifiedDate = new UNID().getNewUNID(); entity.SaveChanges(); _SyncRepository.UpdateSyn(entity); } } }
public void ResetPuntoMedicion(List<Model.ListUnidsModel> listUnids) { if (listUnids != null) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { try { foreach (var item in listUnids) { var local = entity.CAT_PUNTO_MEDICION.First(p => p.IdPuntoMedicion == item.IdTypeTable); if (local.IdPuntoMedicion == item.IdTypeTable && local.LastModifiedDate <= item.LastModifiedDate) { local.IsModified = false; } } entity.SaveChanges(); } catch (Exception) { ; } } } }
// Create. public void InsertTipoPuntoMedicion(Model.TipoPuntoMedicionModel tipopuntomedicion) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { if (tipopuntomedicion != null) { //Validar si el elemento ya existe CAT_TIPO_PUNTO_MEDICION result = null; try { result = (from o in entity.CAT_TIPO_PUNTO_MEDICION where o.IdTipoPuntoMedicion == tipopuntomedicion.IdTipoPuntoMedicion select o).First(); } catch (Exception ex) { ; } if (result == null) { entity.CAT_TIPO_PUNTO_MEDICION.AddObject( new CAT_TIPO_PUNTO_MEDICION() { IdTipoPuntoMedicion = tipopuntomedicion.IdTipoPuntoMedicion, TipoPuntoMedicionName = tipopuntomedicion.TipoPuntoMedicionName.Trim(), IsActive = tipopuntomedicion.IsActive, IsModified = true, LastModifiedDate = new UNID().getNewUNID() } ); entity.SaveChanges(); _SyncRepository.UpdateSyn(entity); } } } }
public void Upsert(ObservableCollection<EstructuraDependenciaModel> items) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { try { foreach (EstructuraDependenciaModel row in items) { REL_ESTRUCTURA_DEPENDENCIA result = null; try { result = (from s in entity.REL_ESTRUCTURA_DEPENDENCIA where s.IdEstructuraDependencia == row.IdEstructuraDependencia select s).First(); } catch (Exception) { ; } if (result == null) { entity.REL_ESTRUCTURA_DEPENDENCIA.AddObject( new REL_ESTRUCTURA_DEPENDENCIA() { IdEstructuraDependencia = row.IdEstructuraDependencia, IdDependencia = row.IdDependencia, IdEstructura = row.IdEstructura, IsActive = row.IsActive, IsModified = row.IsModified, LastModifiedDate = row.LastModifiedDate, ServerLastModifiedDate = row.ServerLastModifiedDate, }); } if (result != null && result.LastModifiedDate < row.LastModifiedDate) { result.IdDependencia = row.IdDependencia; result.IdEstructura = row.IdEstructura; result.IsActive = row.IsActive; result.IsModified = row.IsModified; result.LastModifiedDate = row.LastModifiedDate; result.ServerLastModifiedDate = row.ServerLastModifiedDate; } } entity.SaveChanges(); } catch (Exception ex) { AppBitacoraRepository.Insert(new AppBitacoraModel() { Fecha = DateTime.Now, Metodo = ex.StackTrace, Mensaje = ex.Message }); } } }
// Update. public void UpdateTipoPuntoMedicion(Model.TipoPuntoMedicionModel tipopuntomedicion) { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { CAT_TIPO_PUNTO_MEDICION result = null; try { result = (from o in entity.CAT_TIPO_PUNTO_MEDICION where o.IdTipoPuntoMedicion == tipopuntomedicion.IdTipoPuntoMedicion select o).First(); } catch (Exception ex) { ; } if (result != null) { result.TipoPuntoMedicionName = tipopuntomedicion.TipoPuntoMedicionName; result.IsModified = true; result.LastModifiedDate = new UNID().getNewUNID(); entity.SaveChanges(); _SyncRepository.UpdateSyn(entity); } } }