Ej, si se quieren obtener todas las inner classes de LibX.dll:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using LibX;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static StreamWriter sw;
static void Main(string[] args)
{
if (File.Exists(@"c:\temp\out.txt"))
File.Delete(@"c:\temp\out.txt");
sw = File.AppendText(@"c:\temp\out.txt");
var theList = Assembly.GetExecutingAssembly().GetTypes()
.Where(t => t.Namespace == "X")
.ToList();
var asm = Assembly.LoadFile(@"C:\crusso\X\fuentes\Desarrollo\_DLL\LibX\bin\debug\LibX.dll");
foreach (var t in asm.ExportedTypes)
{
Type[] typelist = GetTypesInNamespace(asm, t.Namespace);
for (int i = 0; i < typelist.Length; i++)
{
var jj = ListarInner(typelist[i]);
if (jj != "")
{
sw.WriteLine(jj);
}
}
}
var namespaces = asm.GetTypes()
.Select(t => t.Namespace)
.Distinct();
sw.Close();
Console.ReadLine();
}
private static Type[] GetTypesInNamespace(Assembly assembly, string nameSpace)
{
return assembly.GetTypes().Where(t => String.Equals(t.Namespace, nameSpace, StringComparison.Ordinal)).ToArray();
}
public static string ListarInner(Type t)
{
Type myType = (t);
Type[] myArrayType = myType.GetNestedTypes(BindingFlags.Public);
foreach (var tt in myArrayType)
{
bool isStruct = tt.IsValueType && !tt.IsEnum;
if (!tt.IsEnum && !isStruct)
{
return tt + Environment.NewLine + ListarInner(tt);
}
}
return "";
}
}
}
JqueryUI autocomplete con JSON
Código html:
<style>
.ui-autocomplete { height: 400px; overflow-y: scroll; overflow-x: hidden;}
</style>
<input id="id_mantis" type="text" size="6" style="" />
<script>
$(document).ready(function() {
CargarAutocompletar("nombre_del_campo_de_texto", 2);
});
</script>
Código JS:
function CargarAutocompletar(id_input, modo)
{
$.ui.autocomplete.prototype._renderItem = function (ul, item) {
item.label = item.label.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(this.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<span style='font-weight:bold;color:Blue;'>$1</span>");
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.label + "</a>")
.appendTo(ul);
};
jQuery.support.cors = true;
$.ajaxSetup({ cache: false });
var urlServicio = "http://" + window.self.location.hostname + "/wsX/Parametros.asmx/ObtenerChoiceListItemsJSON";
$("#" + id_input).autocomplete({
source: function( request, response ) {
$.ajax({
url: urlServicio,
dataType: "json",
data: {term: request.term,
dcnFiltro: $("#" + id_input).val(),
random: Math.floor(Math.random()*9999999999)},
success: function(data) {
response($.map(data, function(item) {
return {
label: item.dcn_cod,
id: item.dcn_dsc
};
}));
}
});
},
minLength: 2,
select: function(event, ui) {
//quito tags html
var dcn = ui.item.label.replace(/<(?:.|\n)*?>/gm, '');
alert(dcn);
}
});
}
<style>
.ui-autocomplete { height: 400px; overflow-y: scroll; overflow-x: hidden;}
</style>
<script>
$(document).ready(function() {
CargarAutocompletar("nombre_del_campo_de_texto", 2);
});
</script>
Código JS:
function CargarAutocompletar(id_input, modo)
{
$.ui.autocomplete.prototype._renderItem = function (ul, item) {
item.label = item.label.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(this.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<span style='font-weight:bold;color:Blue;'>$1</span>");
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.label + "</a>")
.appendTo(ul);
};
jQuery.support.cors = true;
$.ajaxSetup({ cache: false });
var urlServicio = "http://" + window.self.location.hostname + "/wsX/Parametros.asmx/ObtenerChoiceListItemsJSON";
$("#" + id_input).autocomplete({
source: function( request, response ) {
$.ajax({
url: urlServicio,
dataType: "json",
data: {term: request.term,
dcnFiltro: $("#" + id_input).val(),
random: Math.floor(Math.random()*9999999999)},
success: function(data) {
response($.map(data, function(item) {
return {
label: item.dcn_cod,
id: item.dcn_dsc
};
}));
}
});
},
minLength: 2,
select: function(event, ui) {
//quito tags html
var dcn = ui.item.label.replace(/<(?:.|\n)*?>/gm, '');
alert(dcn);
}
});
}
Internal Server Error 500 al intentar ejecutar un web service
descomentar la siguiente línea del web service:
<System.Web.Script.Services.ScriptService()> _
<System.Web.Script.Services.ScriptService()> _
Llamado a un webservice asmx con AJAX
Código .NET
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports LibX.X
Imports System.Web.Script.Services
Imports System.Web.Script.Serialization
<WebMethod> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
Sub ObtenerChoiceListItems2(ByVal cobnamtab As String, ByVal filtro As String)
Dim js As New JavaScriptSerializer()
Context.Response.Clear()
Context.Response.ContentType = "application/json"
Dim d As String = "{ " +
"'datos': { " +
"'items': [{ " +
" 'coddestab': '5', " +
" 'deslartab': 'DESC ITEM 5' " +
" }, { " +
" 'coddestab': '10', " +
" 'deslartab': 'DESC ITEM 10' " +
" }, { " +
" 'coddestab': '15', " +
" 'deslartab': 'DESC ITEM 15' " +
"}]" +
"}" +
"}"
Context.Response.Write(js.Serialize(d))
End Sub
function getJSON(data_obj)
{
if (data_obj.d)
data_ok = data_obj.d;
else
data_ok = data_obj;
evalJson = eval("var varJSON = " + data_ok + ";");
return varJSON;
}
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports LibX.X
Imports System.Web.Script.Services
Imports System.Web.Script.Serialization
<WebMethod> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
Sub ObtenerChoiceListItems2(ByVal cobnamtab As String, ByVal filtro As String)
Dim js As New JavaScriptSerializer()
Context.Response.Clear()
Context.Response.ContentType = "application/json"
Dim d As String = "{ " +
"'datos': { " +
"'items': [{ " +
" 'coddestab': '5', " +
" 'deslartab': 'DESC ITEM 5' " +
" }, { " +
" 'coddestab': '10', " +
" 'deslartab': 'DESC ITEM 10' " +
" }, { " +
" 'coddestab': '15', " +
" 'deslartab': 'DESC ITEM 15' " +
"}]" +
"}" +
"}"
Context.Response.Write(js.Serialize(d))
End Sub
Código javascript:
function cargarChoiceList(vNombreCombo, vCobnamtab)
{
jQuery.support.cors = true;
rndAux = '&random=' + Math.floor(Math.random()*9999999999);
jqxhr2 = jQuery.ajax({
type:"GET",
data:{ cobnamtab: vCobnamtab,
filtro:"",
rnd: rndAux},
dataType:"json",
url:"http://" + window.self.location.hostname + "/wsX/Parametros.asmx/ObtenerChoiceListItems2",
beforeSend:function(){
}
}).fail(function(jqXHR, textStatus){
alert("Error: " + "Status: "+
jqXHR.status +" detalle: "+ textStatus +
" detalle: "+ jqXHR.responseText);
}).success(function(data){
var v = getJSON(data);
$("[name=" + vNombreCombo + "]").empty();
for (i=0; i<v.datos.items.length; i++)
{
$("[name=" + vNombreCombo + "]").append($('<option>', {
value: v.datos.items[i]["coddestab"],
text : v.datos.items[i]["deslartab"]
}));
}
});
}
function getJSON(data_obj)
{
if (data_obj.d)
data_ok = data_obj.d;
else
data_ok = data_obj;
evalJson = eval("var varJSON = " + data_ok + ";");
return varJSON;
}
Ejemplo de llamado:
cargarChoiceList('WFF-SINO3', 'BANCOS');
Thermistor NTC3950 de 100K con Arduino
Codigo:
#include <math.h>
double Thermistor(int RawADC) {
double Temp;
Temp = log(10000.0*((1024.0/RawADC-1)));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15;
Temp = (Temp * 9.0)/ 5.0 + 32.0;
return Temp;
}
void setup() {
Serial.begin(9600);
}
void loop() {
int val;
double tempFahrenheith;
val=analogRead(2);
tempFahrenheith=Thermistor(val);
double tempCelcius = (tempFahrenheith - 32) * 5/9;
Serial.print("Temperature = ");
Serial.print(tempCelcius);
Serial.println(" C");
delay(1000);
}
Breakpoint aparece en amarillo y muestra el error "No se pueden cargar los simbolos"
Primero ejecutar la aplicacion.
Luego ir a Debug / Windows / Modules
Luego ir a Debug / Windows / Modules
elegir el assembly que corresponda al sitio (ej, RetWeb.dll)
Click derecho, y seleccionar "Symbol Load Information"
Start debugging, as soon as you've arrived at a breakpoint or used Debug > Break All, use Debug > Windows > Modules. You'll see a list of all the assemblies that are loaded into the process. Locate the one you want to get debug info for. Right-click it and select Symbol Load Information. You'll get a dialog that lists all the directories where it looked for the .pdb file for the assembly. Verify that list against the actual .pdb location. Make sure it doesn't find an old one.
In normal projects, the assembly and its .pdb file should always have been copied by the IDE into the same folder as your .exe. The bin\Debug folder of your project. Make sure you remove one from the GAC if you've been playing with itExportar datos a un archivo de texto con MySql
*** Tener en cuenta que el archivo se genera en el servidor de MySql ***
SELECT *
INTO OUTFILE '/mantis/out.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM mantis_custom_field_string_table
SELECT *
INTO OUTFILE '/mantis/out.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM mantis_custom_field_string_table
Formato de fechas al exportar un dataset a XML
Cuando se exporta un dataset a XML, las fechas se formatean según la timezone del equipo donde se está ejecutando la exportación.
Ej, si la fecha es
2003-04-06T00:00:00
cuando se exporta a XML puede quedar así
2003-04-06T00:00:00-03:00
En este caso le agregó el GMT -3
Una solución posible es cambiar el DateTimeMode del dataset a Unspecified.
De esta forma, no se incluirá el offset (el -3) en el archivo XML.
Fuente: http://blog.scosby.com/post/2013/03/01/Serializing-A-DataSet-With-DateTime-Columns.aspx
Ej, si la fecha es
2003-04-06T00:00:00
cuando se exporta a XML puede quedar así
2003-04-06T00:00:00-03:00
En este caso le agregó el GMT -3
Una solución posible es cambiar el DateTimeMode del dataset a Unspecified.
De esta forma, no se incluirá el offset (el -3) en el archivo XML.
System.Data.DataSet data = new DataSet();
// ...
// Iterate the columns and set DataColumn.DateTimeMode
// to DataSetDateTime.Unspecified to remove offset
// when serialized.
foreach (DataTable table in data.Tables)
{
foreach (DataColumn item in table.Columns)
{
// Switching from UnspecifiedLocal to Unspecified
// is allowed even after the DataSet has rows.
if (item.DataType == typeof(DateTime) &&
item.DateTimeMode == DataSetDateTime.UnspecifiedLocal)
{
item.DateTimeMode = DataSetDateTime.Unspecified;
}
}
}
Crear un componente con PCB Wizard
http://www.new-wave-concepts.com/files/PWtutor5.pdf
1. Agregar los pads que se necesiten (insert / pad)
2. Ir a Edit / Symbol / Insert Pin y hacer click en el centro de cada pad (esto es lo que permite luego conectar componentes entre si)
3. Ir a View / Coordinates / Origin / Change Origin, y hacer click en la esquina inferior izquierda del componente.
4. Crear con recuadros, circulos, etc, el formato del componente.
5. Seleccionar todo, click derecho, Arrange / Group
6. Hacer click derecho en el componente, ir a Edit / Symbol / Make Symbol, elegir Circuit Symbol, definirle una key (con la que se identificara en el pcb wizard, un nombre y una descripcion)
7. Click derecho en el componente, Symbol / Add to Library, y elegir la libreria en la que se quiere agregar.
1. Agregar los pads que se necesiten (insert / pad)
2. Ir a Edit / Symbol / Insert Pin y hacer click en el centro de cada pad (esto es lo que permite luego conectar componentes entre si)
3. Ir a View / Coordinates / Origin / Change Origin, y hacer click en la esquina inferior izquierda del componente.
4. Crear con recuadros, circulos, etc, el formato del componente.
5. Seleccionar todo, click derecho, Arrange / Group
6. Hacer click derecho en el componente, ir a Edit / Symbol / Make Symbol, elegir Circuit Symbol, definirle una key (con la que se identificara en el pcb wizard, un nombre y una descripcion)
7. Click derecho en el componente, Symbol / Add to Library, y elegir la libreria en la que se quiere agregar.
CS0103: The name 'Json' does not exist in the current context
Dentro del tag <compilation> agregar lo siguiente:
<assemblies>
<add assembly="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
<assemblies>
<add assembly="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
Invocar un método por su nombre en C# con Invoke
Type thisType = this.GetType();
En el caso en que sea un método privado, agregar estos parametros:
MethodInfo theMethod = thisType.GetMethod("nombre-del-metodo", BindingFlags.NonPublic | BindingFlags.Instance);
Si el método es público:
MethodInfo theMethod = thisType.GetMethod("nombre-del-metodo");
var msg = (TipoDeDatoQueDevuelveElMetodo)theMethod.Invoke(this, new[] { param });
Ej, si se llama a un actionresult:
var msg = (TipoDeDatoQueDevuelveElMetodo)theMethod.Invoke(this, new[] { param });
En el caso en que sea un método privado, agregar estos parametros:
MethodInfo theMethod = thisType.GetMethod("nombre-del-metodo", BindingFlags.NonPublic | BindingFlags.Instance);
Si el método es público:
MethodInfo theMethod = thisType.GetMethod("nombre-del-metodo");
Para ejecutarlo: (observar que param es el parametro que se le pasa al metodo:
var msg = (TipoDeDatoQueDevuelveElMetodo)theMethod.Invoke(this, new[] { param });
Ej, si se llama a un actionresult:
var msg = (TipoDeDatoQueDevuelveElMetodo)theMethod.Invoke(this, new[] { param });
Suscribirse a:
Entradas (Atom)
