public List <OpcionLogic> Usuario_x_Sistema(string usuario, int codigo_sistema) { List <OpcionLogic> litaOpciones = new List <OpcionLogic>(); try { SQLServer.OpenConection(); SQLServer.CreateCommand("SEG.USP_USUARIO_X_SISTEMA", CommandType.StoredProcedure, SQLServer.CreateParameter("USUARIO", SqlDbType.VarChar, usuario), SQLServer.CreateParameter("CODIGO_SISTEMA", SqlDbType.Int, codigo_sistema)); using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection)) { litaOpciones = new GenericInstance <OpcionLogic>().readDataReaderList(oReader); } } catch (Exception ex) { throw ex; } finally { SQLServer.CloseConection(); } return(litaOpciones); }
public SistemaLogic Sistema_x_Token(string token, int codigo_usuario) { SistemaLogic sistema = new SistemaLogic(); try { SQLServer.OpenConection(); SQLServer.CreateCommand("SEG.USP_SISTEMA_X_TOKEN", CommandType.StoredProcedure, SQLServer.CreateParameter("TOKEN", SqlDbType.VarChar, token), SQLServer.CreateParameter("CODIGO_USUARIO", SqlDbType.Int, codigo_usuario)); using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection)) { sistema = new GenericInstance <SistemaLogic>().readDataReader(oReader); } } catch (Exception ex) { throw ex; } finally { SQLServer.CloseConection(); } return(sistema); }
public List <PerfilLogic> Paginacion(PaginateParams paginateParams) { List <PerfilLogic> listEntidadLogic = new List <PerfilLogic>(); try { SQLServer.OpenConection(); SQLServer.CreateCommand("SEG.USP_SEL_PERFIL_PAG", CommandType.StoredProcedure, SQLServer.CreateParameter("SORTDIRECTION", SqlDbType.VarChar, paginateParams.SortDirection), SQLServer.CreateParameter("SORTCOLUMN", SqlDbType.VarChar, paginateParams.SortColumn), SQLServer.CreateParameter("PAGEINDEX", SqlDbType.Int, paginateParams.PageIndex), SQLServer.CreateParameter("ROWSPERPAGE", SqlDbType.Int, paginateParams.RowsPerPage), SQLServer.CreateParameter("PAGINATE", SqlDbType.Bit, paginateParams.IsPaginate), SQLServer.CreateParameter("FILTERS", SqlDbType.Structured, paginateParams.Filters)); using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection)) { listEntidadLogic = new GenericInstance <PerfilLogic>().readDataReaderList(oReader); } paginateParams.TotalRows = listEntidadLogic.Count > 0 ? listEntidadLogic[0].CantidadTotalRegistros : 0; } catch (Exception ex) { throw ex; } finally { SQLServer.CloseConection(); } return(listEntidadLogic); }
public List <DashboardLogic> Listar(int CodigoTipoGuia, int CodigoIndicador, int CodigoTipoRegistro, int TipoPeriodicidad, int SubTipoPeriodicidad, string Anio, string Fecha, int tipoPlan) { List <DashboardLogic> lista = new List <DashboardLogic>(); try { SQLServer.OpenConection(); SQLServer.CreateCommand("MAN.USP_DASHBOARD_SEL", CommandType.StoredProcedure, SQLServer.CreateParameter("CODIGO_TIPO_GUIA_EMPRESARIAL", SqlDbType.Int, CodigoTipoGuia), SQLServer.CreateParameter("CODIGO_INDICADOR", SqlDbType.Int, CodigoIndicador), SQLServer.CreateParameter("CODIGO_TIPO_REGISTRO", SqlDbType.Int, CodigoTipoRegistro), SQLServer.CreateParameter("TIPO_PERIODICIDAD", SqlDbType.Int, TipoPeriodicidad), SQLServer.CreateParameter("CODIGO_TIPO_PERIODICIDAD", SqlDbType.Int, SubTipoPeriodicidad), SQLServer.CreateParameter("ANIO", SqlDbType.VarChar, Anio), SQLServer.CreateParameter("FECHA", SqlDbType.VarChar, Fecha), SQLServer.CreateParameter("TIPO_PLAN", SqlDbType.VarChar, tipoPlan)); using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection)) { lista = new GenericInstance <DashboardLogic>().readDataReaderList(oReader); } } catch (Exception ex) { throw ex; } finally { SQLServer.CloseConection(); } return(lista); }
public List <PerfilLogic> Listar() { List <PerfilLogic> listEntidadLogic = new List <PerfilLogic>(); Database oDatabase = DataBaseManager.GetDefaultDataBase(); DbCommand oDbCommand = oDatabase.GetStoredProcCommand("SEG.USP_SEL_PERFIL_LISTAR"); try { using (IDataReader oReader = oDatabase.ExecuteReader(oDbCommand)) { listEntidadLogic = new GenericInstance <PerfilLogic>().readDataReaderList(oReader); } } catch (Exception ex) { throw ex; } finally { if (oDbCommand.Connection != null && oDbCommand.Connection.State != ConnectionState.Closed) { oDbCommand.Dispose(); } } return(listEntidadLogic); }
public List <IndicadorDetalleLogic> Listar(int CodigoAlineamientoEstrategico, int codigoTipoRegistro, int codigoTipoPlan, string fechaPeriodo) { List <IndicadorDetalleLogic> listEntidadLogic = new List <IndicadorDetalleLogic>(); try { SQLServer.OpenConection(); SQLServer.CreateCommand("MOV.USP_SEL_INDICADOR_DETALLE_LISTAR", CommandType.StoredProcedure, SQLServer.CreateParameter("CODIGO_ALINEAMIENTO_ESTRATEGICO", SqlDbType.Int, CodigoAlineamientoEstrategico), SQLServer.CreateParameter("CODIGO_TIPO_REGISTRO", SqlDbType.Int, codigoTipoRegistro), SQLServer.CreateParameter("CODIGO_TIPO_PLAN", SqlDbType.Int, codigoTipoPlan), SQLServer.CreateParameter("FECHA_PERIODO", SqlDbType.VarChar, fechaPeriodo)); using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection)) { listEntidadLogic = new GenericInstance <IndicadorDetalleLogic>().readDataReaderList(oReader); } } catch (Exception ex) { throw ex; } finally { SQLServer.CloseConection(); } return(listEntidadLogic); }
public MaterialLogicalEntity Guardar(MaterialLogicalEntity _LogicalEntity) { MaterialLogicalEntity _ResponseLogicalEntity = new MaterialLogicalEntity(); try { SQLServerConnect.OpenConection(); SQLServerConnect.CreateCommand("SP_Material_guardar", CommandType.StoredProcedure, SQLServerConnect.CreateParameter("Id_Material", SqlDbType.Int, _LogicalEntity.Id_Material), SQLServerConnect.CreateParameter("Descripcion", SqlDbType.VarChar, _LogicalEntity.Descripcion), SQLServerConnect.CreateParameter("Estado", SqlDbType.Char, _LogicalEntity.Estado), SQLServerConnect.CreateParameter("ACCION", SqlDbType.Char, _LogicalEntity.ACCION) ); using (IDataReader oReader = SQLServerConnect.GetDataReader(CommandBehavior.CloseConnection)) { _ResponseLogicalEntity = new GenericInstance <MaterialLogicalEntity>().readDataReader(oReader); } } catch (Exception ex) { string SYSTEM_MESSAGE = ex.Message; } finally { SQLServerConnect.CloseConection(); } return(_ResponseLogicalEntity); }
public List <ParametroDetalleLogic> Listar(long codParametro) { List <ParametroDetalleLogic> listParametroDetalle = new List <ParametroDetalleLogic>(); Database oDatabase = DataBaseManager.GetDefaultDataBase(); DbCommand oDbCommand = oDatabase.GetStoredProcCommand("PAR.USP_SEL_PARAMETRO_DETALLE_LISTAR"); try { oDatabase.AddInParameter(oDbCommand, "@CODIGO_PARAMETRO", DbType.Int16, codParametro); using (IDataReader oReader = oDatabase.ExecuteReader(oDbCommand)) { listParametroDetalle = new GenericInstance <ParametroDetalleLogic>().readDataReaderList(oReader); } } catch (Exception ex) { throw ex; } finally { if (oDbCommand.Connection != null && oDbCommand.Connection.State != ConnectionState.Closed) { oDbCommand.Dispose(); } } return(listParametroDetalle); }
public ParametroDetalleLogic Obtener(long codParametro, string codElemento) { ParametroDetalleLogic parametroDetalle = new ParametroDetalleLogic(); try { SQLServer.OpenConection(); SQLServer.CreateCommand("PAR.USP_SEL_PARAMETRO_DETALLE_OBTENER", CommandType.StoredProcedure, SQLServer.CreateParameter("CODIGO_PARAMETRO", SqlDbType.BigInt, codParametro), SQLServer.CreateParameter("CODIGO_ELEMENTO", SqlDbType.VarChar, codElemento)); using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection)) { parametroDetalle = new GenericInstance <ParametroDetalleLogic>().readDataReader(oReader); } } catch (Exception ex) { throw ex; } finally { SQLServer.CloseConection(); } return(parametroDetalle); }
private void Initialize(Function template, GenericInstance genericInstance) { // Store the template and the generic instance. this.template = template; this.genericInstance = genericInstance; // Store a name and the flags. this.name = template.GetName(); this.flags = template.GetFlags(); // Instance the function type. SetFunctionType((FunctionType)template.GetFunctionType().InstanceGeneric(genericInstance, GetModule())); // Copy the prototype if this is not the final instance. if (genericInstance.GetPrototype() != template.GetGenericPrototype()) { SetGenericPrototype(template.GetGenericPrototype()); } // Use the template parent scope. this.parentScope = template.GetParentScope(); // Register myself. GetModule().RegisterGenericInstance(this); }
public List <ParametroResponse> GetFiltered(int codigoSistemaPadre, string activo) { List <ParametroResponse> listEntidadLogic = new List <ParametroResponse>(); try { SQLServer.OpenConection(); SQLServer.CreateCommand("MAN.SP_SEL_PARAMETRO", CommandType.StoredProcedure, SQLServer.CreateParameter("CODIGO_PADRE", SqlDbType.Int, codigoSistemaPadre), SQLServer.CreateParameter("ESTADO_REGISTRO", SqlDbType.Char, activo), SQLServer.CreateParameter("TIPO", SqlDbType.Char, "1") ); using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection)) { listEntidadLogic = new GenericInstance <ParametroResponse>().readDataReaderList(oReader); } } catch (Exception ex) { throw ex; } finally { SQLServer.CloseConection(); } return(listEntidadLogic); }
public UsuariosLogic Login(string usuario, string contrasena) { UsuariosLogic usuarios = new UsuariosLogic(); try { SQLServer.OpenConection(); SQLServer.CreateCommand("SEG.USP_LOGIN", CommandType.StoredProcedure, SQLServer.CreateParameter("USUARIO", SqlDbType.VarChar, usuario), SQLServer.CreateParameter("CONTRASENA", SqlDbType.VarChar, contrasena)); using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection)) { usuarios = new GenericInstance <UsuariosLogic>().readDataReader(oReader); } } catch (Exception ex) { throw ex; } finally { SQLServer.CloseConection(); } return(usuarios); }
internal PropertyInstance(ScopeMember factory, GenericInstance instance, PropertyVariable template) : base(factory.GetModule()) { this.type = template.GetVariableType().InstanceGeneric(instance, GetModule()); this.flags = template.flags; this.SetName(template.GetName()); this.parentScope = (Scope)factory; if (template.getAccessor != null) { this.getAccessor = (Function)template.getAccessor.InstanceMember(factory, instance); } if (template.setAccessor != null) { this.setAccessor = (Function)template.setAccessor.InstanceMember(factory, instance); } // Instance the indexers. if (template.indices != null) { int numindices = template.indices.Length; this.indices = new IChelaType[numindices]; for (int i = 0; i < numindices; ++i) { this.indices[i] = template.indices[i].InstanceGeneric(instance, GetModule()); } } }
public List <VariableDetalleLogic> Paginacion(PaginateParams paginateParams, float codigoGuiaEmpresarial, float tipoRegistro) { List <VariableDetalleLogic> listEntidadLogic = new List <VariableDetalleLogic>(); try { SQLServer.OpenConection(); SQLServer.CreateCommand("MOV.USP_SEL_VARIABLE_DETALLE_PAG", CommandType.StoredProcedure, SQLServer.CreateParameter("CODIGO_TIPO_REGISTRO", SqlDbType.Int, tipoRegistro), SQLServer.CreateParameter("CODIGO_GUIA_EMPRESARIAL", SqlDbType.Int, codigoGuiaEmpresarial), SQLServer.CreateParameter("SORTDIRECTION", SqlDbType.VarChar, paginateParams.SortDirection), SQLServer.CreateParameter("SORTCOLUMN", SqlDbType.VarChar, paginateParams.SortColumn), SQLServer.CreateParameter("PAGEINDEX", SqlDbType.Int, paginateParams.PageIndex), SQLServer.CreateParameter("ROWSPERPAGE", SqlDbType.Int, paginateParams.RowsPerPage), SQLServer.CreateParameter("PAGINATE", SqlDbType.Bit, paginateParams.IsPaginate), SQLServer.CreateParameter("FILTERS", SqlDbType.Structured, paginateParams.Filters)); using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection)) { listEntidadLogic = new GenericInstance <VariableDetalleLogic>().readDataReaderList(oReader); } paginateParams.TotalRows = listEntidadLogic.Count > 0 ? listEntidadLogic[0].CantidadTotalRegistros : 0; } catch (Exception ex) { throw ex; } finally { SQLServer.CloseConection(); } return(listEntidadLogic); }
public List <ReporteLogic> ObtenerDetalleIndicador(long codigoGuiaEmpresarial, long codigoTipoRegistro, long codigoTipoPeriodicidad, int tipoPlan) { List <ReporteLogic> reporte = new List <ReporteLogic>(); try { SQLServer.OpenConection(); SQLServer.CreateCommand("REP.USP_SEL_REPORTE_DETALLE_INDICADOR_LISTAR", CommandType.StoredProcedure, SQLServer.CreateParameter("TIPO_DOCUMENTO_EMPRESARIAL", SqlDbType.Int, codigoGuiaEmpresarial), SQLServer.CreateParameter("TIPO_REGISTRO", SqlDbType.Int, codigoTipoRegistro), SQLServer.CreateParameter("TIPO_PERIODICIDAD", SqlDbType.Int, codigoTipoPeriodicidad), SQLServer.CreateParameter("TIPO_PLAN", SqlDbType.Int, tipoPlan)); using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection)) { reporte = new GenericInstance <ReporteLogic>().readDataReaderList(oReader); } } catch (Exception ex) { throw ex; } finally { SQLServer.CloseConection(); } return(reporte); }
//public String ParametrosRuta(Int64 codigoParametro) //{ // SqlParameter[] parametros = new SqlParameter[] // { // new SqlParameter("CODIGO_PARAMETRO", SqlDbType.Int) { Value = codigoParametro }, // }; // var resultado = this.dataBaseProvider.ExecuteStoreProcedure<String>(DatosConstantes.EsquemasBd.Man + ".USP_SEL_PARAMETROS_RUTA", parametros).ToList(); // var Texto = ""; // if (resultado.Count > 0) // { // Texto = resultado[0]; // } // return Texto; // //try // //{ // // SQLServer.OpenConection(); // // SQLServer.CreateCommand(DatosConstantes.EsquemasBd.Man+".USP_SEL_PARAMETROS_RUTA", CommandType.StoredProcedure, // // SQLServer.CreateParameter("CODIGO_PARAMETRO", SqlDbType.Int, codigoParametro) // // ); // // using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection)) // // { // // String texto = ""; // // while (oReader.Read()) // // { // // texto =oReader["ruta"].ToString(); // // } // // return texto; // // } // //} // //catch (Exception ex) // //{ // // throw ex; // //} // //finally // //{ // // SQLServer.CloseConection(); // //} //} //public List<ParametroLogic> listarParametros(ParametroRequest oPublicacionRequest) //{ // List<ParametroLogic> listEntidadLogic = new List<ParametroLogic>(); // try // { // SQLServer.OpenConection(); // SQLServer.CreateCommand(DatosConstantes.EsquemasBd.Man + ".USP_SEL_PARAMETRO_DETALLE_LISTAR", CommandType.StoredProcedure, // SQLServer.CreateParameter("CODIGO_PARAMETRO", SqlDbType.Int, oPublicacionRequest.CodigoParametro) // ); // using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection)) // { // listEntidadLogic = new GenericInstance<ParametroLogic>().readDataReaderList(oReader); // } // } // catch (Exception ex) // { // throw ex; // } // finally // { // SQLServer.CloseConection(); // } // return listEntidadLogic; //} public List <ParametroResponse> ListarParametrosGrilla(ParametroRequest oParametroRequest) { List <ParametroResponse> listEntidadLogic = new List <ParametroResponse>(); try { SQLServer.OpenConection(); SQLServer.CreateCommand("MAN.USP_SEL_PARAMETRO_PAG", CommandType.StoredProcedure, SQLServer.CreateParameter("SORTDIRECTION", SqlDbType.VarChar, oParametroRequest.SortDirection), SQLServer.CreateParameter("SORTCOLUMN", SqlDbType.VarChar, oParametroRequest.SortColumn), SQLServer.CreateParameter("ROWSPERPAGE", SqlDbType.VarChar, oParametroRequest.RowsPerPage), SQLServer.CreateParameter("PAGEINDEX", SqlDbType.Int, oParametroRequest.PageIndex), SQLServer.CreateParameter("PAGINATE", SqlDbType.Bit, oParametroRequest.IsPaginate), SQLServer.CreateParameter("FILTERS", SqlDbType.Structured, oParametroRequest.Filters)); using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection)) { listEntidadLogic = new GenericInstance <ParametroResponse>().readDataReaderList(oReader); } oParametroRequest.TotalRows = listEntidadLogic.Count > 0 ? listEntidadLogic[0].TotalRegistro : 0; } catch (Exception ex) { throw ex; } finally { SQLServer.CloseConection(); } return(listEntidadLogic); }
public StructureInstance(Structure template, GenericInstance instance, ScopeMember factory, ChelaModule module) : base(module) { this.factory = factory; Initialize(template, instance); }
public List <MaterialLogicalEntity> Buscar(MaterialLogicalEntity _LogicalEntity) { List <MaterialLogicalEntity> _ListLogicalEntity = new List <MaterialLogicalEntity>(); try { SQLServerConnect.OpenConection(); SQLServerConnect.CreateCommand("sp_Material_buscar", CommandType.StoredProcedure, SQLServerConnect.CreateParameter("REPORTE", SqlDbType.VarChar, _LogicalEntity.REPORTE), SQLServerConnect.CreateParameter("Id_Material", SqlDbType.Int, _LogicalEntity.Id_Material) ); using (IDataReader oReader = SQLServerConnect.GetDataReader(CommandBehavior.CloseConnection)) { _ListLogicalEntity = new GenericInstance <MaterialLogicalEntity>().readDataReaderList(oReader); } } catch (Exception ex) { string SYSTEM_MESSAGE = ex.Message; } finally { SQLServerConnect.CloseConection(); } return(_ListLogicalEntity); }
public List <AlineamientoConfiguracionLogic> Listar() { List <AlineamientoConfiguracionLogic> listEntidadLogic = new List <AlineamientoConfiguracionLogic>(); Database oDatabase = DataBaseManager.GetDefaultDataBase(); DbCommand oDbCommand = oDatabase.GetStoredProcCommand("MOV.USP_SEL_ALINEAMIENTO_CONFIGURACION_LISTAR"); try { using (IDataReader oReader = oDatabase.ExecuteReader(oDbCommand)) { listEntidadLogic = new GenericInstance <AlineamientoConfiguracionLogic>().readDataReaderList(oReader); } } catch (Exception ex) { throw ex; } finally { if (oDbCommand.Connection != null && oDbCommand.Connection.State != ConnectionState.Closed) { oDbCommand.Dispose(); } } return(listEntidadLogic); }
public HttpResponseMessage GetContactList() { GenericInstance genericInstance = new GenericInstance(); List <ContactInformation> contactList = this._instance.GetContactList(); return(Request.CreateResponse(HttpStatusCode.OK, contactList)); }
public FunctionInstance(Function template, GenericInstance genericInstance, ScopeMember factory) : base(factory.GetModule()) { this.factory = factory; Initialize(template, genericInstance); // Use the factory as a scope. this.UpdateParent((Scope)factory); }
public FunctionInstance(Function template, GenericInstance genericInstance, ScopeMember factory) : base(factory.GetModule()) { this.factory = factory; Initialize(template, genericInstance); // Use the factory as a scope. this.UpdateParent((Scope)factory); }
public HttpResponseMessage AddContact(ContactInformation contactInformation) { GenericInstance genericInstance = new GenericInstance(); string errorMessage = genericInstance.RequiredFieldsValidation(contactInformation); if (!string.IsNullOrEmpty(errorMessage)) { return(Request.CreateResponse(HttpStatusCode.PreconditionFailed, errorMessage)); } this._instance.AddContact(contactInformation); return(Request.CreateResponse(HttpStatusCode.OK, "Contact Added Successfully!"));; }
public HttpResponseMessage DeleteContact([FromBody] int contactID) { GenericInstance genericInstance = new GenericInstance(); if (!genericInstance.isValidContact(contactID)) { return(Request.CreateResponse(HttpStatusCode.PreconditionFailed, "Contact is not valid.")); } this._instance.DeleteContact(contactID); return(Request.CreateResponse(HttpStatusCode.OK, "Contact Deleted Successfully!")); }
public void Generic_Member_Instance_With_MemoryStream() { using (var stream = new MemoryStream()) { { var genericInstance = new GenericInstance <PrimitiveTestClass>(); var writer = new ObjectWriter(stream); writer.Write(genericInstance); } var reader = new ObjectReader(stream); var readValue = reader.Read() as GenericInstance <PrimitiveTestClass>; Assert.AreSame(readValue.GetType(), typeof(GenericInstance <PrimitiveTestClass>)); } }
public FunctionGroupInstance(FunctionGroup template, GenericInstance instance, ScopeMember factory) : base(template.GetName(), (Scope)factory) { // Instance all of the functions. foreach(FunctionGroupName gname in template.GetFunctions()) { // Instance the function. Function tmplFunction = gname.GetFunction(); Function function = (Function)tmplFunction.InstanceMember(factory, instance); // Create the new group name. FunctionGroupName groupName = new FunctionGroupName(function.GetFunctionType(), gname.IsStatic()); groupName.SetFunction(function); // Store the group name. functions.Add(groupName); } }
public FunctionGroupInstance(FunctionGroup template, GenericInstance instance, ScopeMember factory) : base(template.GetName(), (Scope)factory) { // Instance all of the functions. foreach (FunctionGroupName gname in template.GetFunctions()) { // Instance the function. Function tmplFunction = gname.GetFunction(); Function function = (Function)tmplFunction.InstanceMember(factory, instance); // Create the new group name. FunctionGroupName groupName = new FunctionGroupName(function.GetFunctionType(), gname.IsStatic()); groupName.SetFunction(function); // Store the group name. functions.Add(groupName); } }
internal PropertyInstance(ScopeMember factory, GenericInstance instance, PropertyVariable template) : base(factory.GetModule()) { this.type = template.GetVariableType().InstanceGeneric(instance, GetModule()); this.flags = template.flags; this.SetName(template.GetName()); this.parentScope = (Scope)factory; if(template.getAccessor != null) this.getAccessor = (Function)template.getAccessor.InstanceMember(factory, instance); if(template.setAccessor != null) this.setAccessor = (Function)template.setAccessor.InstanceMember(factory, instance); // Instance the indexers. if(template.indices != null) { int numindices = template.indices.Length; this.indices = new IChelaType[numindices]; for(int i = 0; i < numindices; ++i) this.indices[i] = template.indices[i].InstanceGeneric(instance, GetModule()); } }
internal FieldInstance(ScopeMember factory, GenericInstance instance, FieldVariable template) : base(factory.GetModule()) { // Store the factory and the template. this.factory = factory; this.template = template; // Use the factory as the parent scope. this.parentScope = (Scope)factory; // Copy the name and the flags. this.SetName(template.GetName()); this.flags = template.flags; // Copy the slot. this.slot = template.slot; // Instance the type. this.type = template.GetVariableType().InstanceGeneric(instance, GetModule()); // Use the factory as parent scope. this.parentScope = (Scope)factory; }
internal FieldInstance(ScopeMember factory, GenericInstance instance, FieldVariable template) : base(factory.GetModule()) { // Store the factory and the template. this.factory = factory; this.template = template; // Use the factory as the parent scope. this.parentScope = (Scope)factory; // Copy the name and the flags. this.SetName(template.GetName()); this.flags = template.flags; // Copy the slot. this.slot = template.slot; // Instance the type. this.type = template.GetVariableType().InstanceGeneric(instance, GetModule()); // Use the factory as parent scope. this.parentScope = (Scope)factory; }
public List <ReporteLogic> ObtenerDetalle(long codigoGuiaEmpresarial) { List <ReporteLogic> reporte = new List <ReporteLogic>(); try { SQLServer.OpenConection(); SQLServer.CreateCommand("REP.USP_SEL_REPORTE_DETALLE_LISTAR", CommandType.StoredProcedure, SQLServer.CreateParameter("TIPO_DOCUMENTO_EMPRESARIAL", SqlDbType.BigInt, codigoGuiaEmpresarial)); using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection)) { reporte = new GenericInstance <ReporteLogic>().readDataReaderList(oReader); } } catch (Exception ex) { throw ex; } finally { SQLServer.CloseConection(); } return(reporte); }
public AlineamientoConfiguracionLogic Obtener(float codigo) { AlineamientoConfiguracionLogic entidadLogic = new AlineamientoConfiguracionLogic(); try { SQLServer.OpenConection(); SQLServer.CreateCommand("MOV.USP_SEL_ALINEAMIENTO_CONFIGURACION_OBTENER", CommandType.StoredProcedure, SQLServer.CreateParameter("CODIGO_ALINEAMIENTO_CONFIGURACION", SqlDbType.BigInt, codigo)); using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection)) { entidadLogic = new GenericInstance <AlineamientoConfiguracionLogic>().readDataReader(oReader); } } catch (Exception ex) { throw ex; } finally { SQLServer.CloseConection(); } return(entidadLogic); }
public VariableDetalleLogic Obtener(float codigo) { VariableDetalleLogic entidadLogic = new VariableDetalleLogic(); try { SQLServer.OpenConection(); SQLServer.CreateCommand("MOV.USP_SEL_VARIABLE_DETALLE_OBTENER", CommandType.StoredProcedure, SQLServer.CreateParameter("CODIGO_VARIABLE_DETALLE", SqlDbType.BigInt, codigo)); using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection)) { entidadLogic = new GenericInstance <VariableDetalleLogic>().readDataReader(oReader); } } catch (Exception ex) { throw ex; } finally { SQLServer.CloseConection(); } return(entidadLogic); }
public PerfilLogic Obtener(float codigo) { PerfilLogic entidadLogic = new PerfilLogic(); try { SQLServer.OpenConection(); SQLServer.CreateCommand("SEG.USP_SEL_PERFIL_OBTENER", CommandType.StoredProcedure, SQLServer.CreateParameter("CODIGO_PERFIL", SqlDbType.BigInt, codigo)); using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection)) { entidadLogic = new GenericInstance <PerfilLogic>().readDataReader(oReader); } } catch (Exception ex) { throw ex; } finally { SQLServer.CloseConection(); } return(entidadLogic); }
public VariableLogic ObtenerByNombre(string nombreCodigo) { VariableLogic entidadLogic = new VariableLogic(); try { SQLServer.OpenConection(); SQLServer.CreateCommand("MAN.USP_SEL_VARIABLE_OBTENER_BY_NOMBRE", CommandType.StoredProcedure, SQLServer.CreateParameter("NOMBRE_VARIABLE", SqlDbType.VarChar, nombreCodigo)); using (IDataReader oReader = SQLServer.GetDataReader(CommandBehavior.CloseConnection)) { entidadLogic = new GenericInstance <VariableLogic>().readDataReader(oReader); } } catch (Exception ex) { throw ex; } finally { SQLServer.CloseConection(); } return(entidadLogic); }
private void Initialize(Function template, GenericInstance genericInstance) { // Store the template and the generic instance. this.template = template; this.genericInstance = genericInstance; // Store a name and the flags. this.name = template.GetName(); this.flags = template.GetFlags(); // Instance the function type. SetFunctionType((FunctionType)template.GetFunctionType().InstanceGeneric(genericInstance, GetModule())); // Copy the prototype if this is not the final instance. if(genericInstance.GetPrototype() != template.GetGenericPrototype()) SetGenericPrototype(template.GetGenericPrototype()); // Use the template parent scope. this.parentScope = template.GetParentScope(); // Register myself. GetModule().RegisterGenericInstance(this); }
public virtual ScopeMember InstanceMember(ScopeMember factory, GenericInstance instance) { return this; }
public FunctionInstance(Function template, GenericInstance genericInstance, ChelaModule instanceModule) : base(instanceModule) { Initialize(template, genericInstance); }
private void ReadData() { // Only read once the data. if(readedData) return; readedData = true; ModuleReader reader = new ModuleReader(new MemoryStream(rawData)); // Get the module. ChelaModule module = GetModule(); // Read the template. template = (Structure)module.GetMember(reader.ReadUInt()); // Read the factory. factory = (Scope)module.GetMember(reader.ReadUInt()); // Read the generic instance. genericInstance = GenericInstance.Read(template.GetGenericPrototype(), reader, module); // Initialize. Initialize(template, genericInstance); rawData = null; }
public virtual IChelaType InstanceGeneric(GenericInstance args, ChelaModule instModule) { return this; }
public FunctionInstance InstanceGeneric(GenericInstance genericInstance, ChelaModule instanceModule) { return new FunctionInstance(this, genericInstance, instanceModule); }
public override ScopeMember InstanceMember(ScopeMember factory, GenericInstance genericInstance) { return new FunctionInstance(this, genericInstance, factory); }
public override ScopeMember InstanceMember(ScopeMember factory, GenericInstance instance) { return null;//new FunctionGroupInstance (this, instance, factory); }
public override ScopeMember InstanceMember(ScopeMember factory, GenericInstance instance) { return new FieldInstance(factory, instance, this); }
public override IChelaType InstanceGeneric(GenericInstance instance, ChelaModule instanceModule) { // Instance the instance. GenericInstance newInstance = genericInstance.InstanceFrom(instance, instanceModule); // Instance the structure. return template.InstanceGeneric(newInstance, instanceModule); }
public override ScopeMember InstanceMember(ScopeMember factory, GenericInstance instance) { // Instance the instance. ChelaModule module = factory.GetModule(); GenericInstance newInstance = genericInstance.InstanceFrom(instance, module); // Instance the structure. return template.InstanceMember(factory, newInstance); }
private void DefineGeneratorBody(FunctionDefinition node) { // Get entry function. Function entryFunction = node.GetFunction(); // Rebase his locals. entryFunction.RebaseLocals(); // Create the generator class. Scope spaceScope = entryFunction.GetParentScope(); Class generatorClass = new Class(GenSym(), MemberFlags.Internal, spaceScope); node.GeneratorClass = generatorClass; // Use the same generic prototype as the entry point function. generatorClass.SetGenericPrototype(entryFunction.GetGenericPrototype()); // Add the generator class to the same scope as the function. if(spaceScope.IsClass() || spaceScope.IsStructure()) { Structure parentClass = (Structure)spaceScope; parentClass.AddType(generatorClass); } else if(spaceScope.IsNamespace()) { Namespace parentSpace = (Namespace)spaceScope; parentSpace.AddMember(generatorClass); } else { Error(node, "Cannot create generator class in {0}", spaceScope.GetFullName()); } // Add the enumerable interface. Structure enumerableIface = null; if(node.IsEnumerable) { enumerableIface = currentModule.GetEnumerableIface(); if(node.IsGenericIterator) { enumerableIface = currentModule.GetEnumerableGIface(); GenericInstance gargs = new GenericInstance(enumerableIface.GetGenericPrototype(), new IChelaType[]{node.YieldType}); enumerableIface = (Structure)enumerableIface.InstanceGeneric(gargs, currentModule); } generatorClass.AddInterface(enumerableIface); } // Add the enumerator interface. Structure enumeratorIface = currentModule.GetEnumeratorIface(); if(node.IsGenericIterator) { enumeratorIface = currentModule.GetEnumeratorGIface(); GenericInstance gargs = new GenericInstance(enumeratorIface.GetGenericPrototype(), new IChelaType[]{node.YieldType}); enumeratorIface = (Structure)enumeratorIface.InstanceGeneric(gargs, currentModule); } generatorClass.AddInterface(enumeratorIface); // Create the yielded field. FieldVariable yieldedValue = new FieldVariable("yielded", MemberFlags.Private, node.YieldType, generatorClass); generatorClass.AddField(yieldedValue); node.YieldedValue = yieldedValue; // Create the generator state variable. FieldVariable generatorState = new FieldVariable("state", MemberFlags.Private, ChelaType.GetIntType(), generatorClass); generatorClass.AddField(generatorState); node.GeneratorState = generatorState; // Encapsulate the locals in fields. foreach(LocalVariable local in entryFunction.GetLocals()) { if(!local.IsPseudoLocal) continue; // Variables containing arguments must be public. MemberFlags access = MemberFlags.Private; if(local.ArgumentIndex >= 0) access = MemberFlags.Public; // Create the field to hold the state. FieldVariable localField = new FieldVariable(GenSym(), access, local.GetVariableType(), generatorClass); generatorClass.AddField(localField); local.ActualVariable = localField; } // Create an instance of the generator class. Structure generatorClassInstance = generatorClass.GetClassInstance(); if(generatorClass.GetGenericPrototype().GetPlaceHolderCount() != 0) { // Create an instance using the same placeholders. GenericPrototype proto = generatorClass.GetGenericPrototype(); int numargs = proto.GetPlaceHolderCount(); IChelaType[] protoInstance = new IChelaType[numargs]; for(int i = 0; i < numargs; ++i) protoInstance[i] = proto.GetPlaceHolder(i); // Instance the generic class. GenericInstance instance = new GenericInstance(proto, protoInstance); generatorClassInstance = (Structure)generatorClassInstance.InstanceGeneric(instance, currentModule); } node.GeneratorClassInstance = generatorClassInstance; // Create the trivial constructor. Function ctor = CreateTrivialConstructor(generatorClass, generatorClassInstance); if(generatorClass.IsGeneric()) ctor = FindFirstConstructor(generatorClassInstance); // Create a local to hold the created closure. LexicalScope topScope = (LexicalScope)node.GetScope(); LocalVariable closureLocal = new LocalVariable("closure", topScope, ReferenceType.Create(generatorClassInstance)); // Create the entry point content. BasicBlock entryBlock = CreateBasicBlock(); entryBlock.SetName("entry"); builder.SetBlock(entryBlock); // Create the closure and store it in his local. builder.CreateNewObject(generatorClassInstance, ctor, 0); builder.CreateStoreLocal(closureLocal); // Load the closure. builder.CreateLoadLocal(closureLocal); // Store the arguments into the closure. FunctionPrototype prototype = node.GetPrototype(); AstNode argument = prototype.GetArguments(); byte index = 0; while(argument != null) { FunctionArgument argNode = (FunctionArgument) argument; // TODO: Forbid ref, out, stream arguments here. // Store the argument in the closure. LocalVariable argVar = argNode.GetVariable(); if(argVar != null) { // Load the closure builder.CreateDup1(); // Load the argument. builder.CreateLoadArg(index); // Store it into the field. builder.CreateStoreField((FieldVariable)argVar.ActualVariable); } // Process the next argument. argument = argument.GetNext(); index++; } // Encapsulate the argument variables. foreach(ArgumentVariable argVar in node.ArgumentVariables) { if(!argVar.IsPseudoArgument) continue; // Create the argument field. FieldVariable argField = new FieldVariable(GenSym(), MemberFlags.Public, argVar.GetVariableType(), generatorClass); generatorClass.AddField(argField); argVar.ActualVariable = argField; // Store the self field. if(!currentFunction.IsStatic() && argVar.GetArgumentIndex() == 0) node.GeneratorSelf = argField; // Load the closure. builder.CreateDup1(); // Load the argument. builder.CreateLoadArg((byte)argVar.GetArgumentIndex()); // Store it into the closure. builder.CreateStoreField(argField); } // Return the generator. builder.CreateRet(); // Notify the yields about their states. int stateIndex = 2; foreach(ReturnStatement yieldStmtn in node.Yields) { yieldStmtn.YieldState = stateIndex; stateIndex += 2; } // Implement IEnumerator. if(node.IsEnumerable) { // Create the object GetEnumerator method. CreateGenerator_GetEnumerator(node, currentModule.GetEnumeratorIface(), false); // Create the generic GetEnumerator method if(node.IsGenericIterator) CreateGenerator_GetEnumerator(node, enumeratorIface, true); } // Create the Current property. CreateGenerator_Current(node, false); if(node.IsGenericIterator) CreateGenerator_Current(node, true); // Create the Reset method. CreateGenerator_Reset(node); // Create the MoveNext method. Function moveNext = CreateGenerator_MoveNext(node); // Create the Dispose method. CreateGenerator_Dispose(node, moveNext); // Fix the inheritance. generatorClass.FixInheritance(); }
private void CreateKernelEntryPoint(AstNode where, Function function) { // Only create once if(function.EntryPoint != null) return; // Get the function type. FunctionType functionType = function.GetFunctionType(); // The return type must be void. if(functionType.GetReturnType() != ChelaType.GetVoidType()) return; // Check the parameters for input and output streams, and not references. bool inputStream = false; bool outputStream = false; for(int i = 0; i < functionType.GetArgumentCount(); ++i) { IChelaType argType = functionType.GetArgument(i); // Streams are references. if(!argType.IsReference()) continue; // Cast the argument. ReferenceType argRef = (ReferenceType)argType; // Only stream and array references are supported in kernel entry points. if(!argRef.IsStreamReference()) { argType = argRef.GetReferencedType(); if(argType.IsArray()) continue; return; } // Check the stream flow. ReferenceFlow flow = argRef.GetReferenceFlow(); if(flow == ReferenceFlow.In || flow == ReferenceFlow.InOut) inputStream = true; if(flow == ReferenceFlow.Out || flow == ReferenceFlow.InOut) outputStream = true; // Don't stop the loop to check for the non-stream references. } // Both types of streams must be present. if(!inputStream || !outputStream) return; // Now create the entry point function type. List<IChelaType> arguments = new List<IChelaType> (); for(int i = 0; i < functionType.GetArgumentCount(); ++i) { IChelaType argType = functionType.GetArgument(i); // Select the adecuate holder. Class holder = null; if(!argType.IsReference()) { // Use uniform holder for non-stream and non-array arguments. holder = currentModule.GetUniformHolderClass(); } else { // De-Reference the argument type. ReferenceType refType = (ReferenceType)argType; argType = refType.GetReferencedType(); // Get the array dimensions. int dimensions = 0; if(argType.IsArray()) { ArrayType arrayType = (ArrayType)argType; argType = arrayType.GetValueType(); dimensions = arrayType.GetDimensions(); } else { // TODO: Read the dimensions from the reference type. } // Select the stream holder according to the dimensions. switch(dimensions) { case 0: holder = currentModule.GetStreamHolderClass(); break; case 1: holder = currentModule.GetStreamHolder1DClass(); break; case 2: holder = currentModule.GetStreamHolder2DClass(); break; case 3: holder = currentModule.GetStreamHolder3DClass(); break; default: Error(where, "unsupported array with more than 3 dimensions in kernels."); break; } } // Create an stream holder instance. GenericInstance instanceData = new GenericInstance(holder.GetGenericPrototype(), new IChelaType[]{argType}); IChelaType holderType = holder.InstanceGeneric(instanceData, currentModule); // Store the stream holder type. if(holderType.IsPassedByReference()) holderType = ReferenceType.Create(holderType); arguments.Add(holderType); } // Create the kernel binder type. IChelaType computeBindingType = ReferenceType.Create(currentModule.GetComputeBindingDelegate()); FunctionType kernelBinderType = FunctionType.Create(computeBindingType, arguments); // Create the kernel entry point. function.EntryPoint = new KernelEntryPoint(function, kernelBinderType); }
public override AstNode Visit(GenericInstanceExpr node) { // Visit the generic expression. Expression genericExpr = node.GetGenericExpression(); genericExpr.Accept(this); // Visit the parameters. List<IChelaType> parameters = new List<IChelaType> (); AstNode currentParam = node.GetParameters(); while(currentParam != null) { // Visit the parameter. currentParam.Accept(this); // Get the parameter type. IChelaType paramType = currentParam.GetNodeType(); paramType = ExtractActualType(currentParam, paramType); parameters.Add(FilterGenericParameter(paramType)); // Visit the next parameter. currentParam = currentParam.GetNext(); } // Create the parameter array. IChelaType[] typeArgs = parameters.ToArray(); // Get the generic member. IChelaType genericExprType = genericExpr.GetNodeType(); if(genericExprType.IsMetaType()) { // Extract the actual type. MetaType metaType = (MetaType)genericExprType; genericExprType = metaType.GetActualType(); // Handle type groups. Structure building = null; if(genericExprType.IsTypeGroup()) { // Check each member of the group, until find a match. TypeGroup group = (TypeGroup)genericExprType; foreach(TypeGroupName gname in group.GetBuildings()) { // Use the first match // TODO: Use the best match. if(CheckGenericArguments(null, gname.GetGenericPrototype(), typeArgs)) { building = gname.GetBuilding(); break; } } // Make sure a match was found. if(building == null) { if(@group.GetBuildingCount() == 1) { foreach(TypeGroupName gname in group.GetBuildings()) CheckGenericArguments(node, gname.GetGenericPrototype(), typeArgs); } else { // TODO: Give a more descriptive error. Error(node, "couldn't find a matching generic type."); } } // Prevent ambiguity. building.CheckAmbiguity(node.GetPosition()); } else { // This must be a class/struct/interface. if(!genericExprType.IsClass() && !genericExprType.IsStructure() && !genericExprType.IsInterface()) Error(node, "only class/structure/interface/delegate types can be generic."); building = (Structure)genericExprType; building.CheckAmbiguity(node.GetPosition()); } // Check the generic member. GenericPrototype genProto = building.GetGenericPrototype(); CheckGenericArguments(node, genProto, typeArgs); // Use a generic structure instance type. GenericInstance args = new GenericInstance(genProto, typeArgs); IChelaType instancedType = building.InstanceGeneric(args, currentModule); node.SetNodeType(MetaType.Create(instancedType)); } else if(genericExprType.IsFunctionGroup()) { // This is a function group, so delay generic member selection. FunctionGroupSelector selector = (FunctionGroupSelector)genericExpr.GetNodeValue(); selector.GenericParameters = typeArgs; node.SetNodeType(genericExpr.GetNodeType()); node.SetNodeValue(selector); } else { // Unexpected member. Error(node, "expected class/struct/interface/delegate/function group."); } return node; }
public GenericInstance GetFullGenericInstance() { // Return the cached instance. if(fullGenericInstance != null) return fullGenericInstance; // Get the full prototype. GenericPrototype fullProto = GetFullGenericPrototype(); if(fullProto == null) return null; // Get the parent full generic instance. GenericInstance parentFull = null; Scope parent = GetParentScope(); if(parent != null) parentFull = parent.GetFullGenericInstance(); // Get my generic instance. GenericInstance myInstance = GetGenericInstance(); if(myInstance == null || myInstance.GetParameterCount() == 0) { fullGenericInstance = parentFull; } else if(parentFull == null || parentFull.GetParameterCount() == 0) { fullGenericInstance = myInstance; } else { // Merge both instances int parentSize = parentFull.GetParameterCount(); int mySize = myInstance.GetParameterCount(); IChelaType[] newInstance = new IChelaType[parentSize + mySize]; // Add the parent prototype components. for(int i = 0; i < parentSize; ++i) newInstance[i] = parentFull.GetParameter(i); // Add my prototype components. for(int i = 0; i < mySize; ++i) newInstance[i + parentSize] = myInstance.GetParameter(i); // Store the new complete generic instance. fullGenericInstance = new GenericInstance(fullProto, newInstance); } return fullGenericInstance; }
private void Initialize(Structure template, GenericInstance instance) { // Copy the template name and flags. this.name = template.GetName(); this.flags = template.flags; // Store the template and the generic instance. this.template = template; this.genericInstance = instance; // Copy the prototype if this is not the final instance. SetGenericPrototype(template.GetGenericPrototype()); // Use the factory this.parentScope = (Scope)factory; template.genericInstanceList.Add(this); // Register myself in the module. GetModule().RegisterGenericInstance(this); // Get the complete instance. GetFullGenericInstance(); }