29 diciembre 2013

C# - Apps - MxPing - Download


Esta aplicación puede enviar hasta 100 procesos al mismo tiempo para testear el enlace de Internet o red local.
This application can send up to 100 processes simultaneously to test The Internet link or local network.


Donwload: MxPing
Donwload: Net Framework 2.0

12 febrero 2013

C# - Algoritmos - Conexión en Firebird (2005, 2008)

La clase Class_Connection.class
using FirebirdSql.Data.FirebirdClient;
using System;
using System.Data;
using System.IO;
using System.Configuration;
using System.Windows.Forms;
using System.Xml;

public class Class_Connection {
    private FbConnection Fb_Connection;

    public string Fb_ConnectionTXT() {
        StreamReader objReader = new StreamReader("\\FirebirdCN\\Firebird.txt");
        String ConnectionString;
        ConnectionString = "";
        ConnectionString = objReader.ReadLine();
        return ConnectionString;
    }

    public String Fb_ConnectionXML() {
        XmlDocument Xml;
        XmlNodeList NodeList;
        String ConnectionString = "";
        Xml = new XmlDocument();
        Xml.Load(Application.StartupPath + "\\FirebirdCN\\Firebird.xml");
        NodeList = Xml.SelectNodes("/FirebirCN");
        foreach (XmlNode Node in NodeList) {
            ConnectionString = ConnectionString + Node.ChildNodes.Item(0).Name + "=" + Node.ChildNodes.Item(0).InnerText + "; ";
            ConnectionString = ConnectionString + Node.ChildNodes.Item(1).Name + "=" + Node.ChildNodes.Item(1).InnerText + "; ";
            ConnectionString = ConnectionString + Node.ChildNodes.Item(2).Name + "=" + Node.ChildNodes.Item(2).InnerText + "; ";
            ConnectionString = ConnectionString + Node.ChildNodes.Item(3).Name + "=" + Node.ChildNodes.Item(3).InnerText + "; ";
            ConnectionString = ConnectionString + Node.ChildNodes.Item(4).Name + "=" + Node.ChildNodes.Item(4).InnerText + "; ";
            ConnectionString = ConnectionString + Node.ChildNodes.Item(5).Name + "=" + Node.ChildNodes.Item(5).InnerText + "; ";
            ConnectionString = ConnectionString + Node.ChildNodes.Item(6).Name + "=" + Node.ChildNodes.Item(6).InnerText + "; ";
            ConnectionString = ConnectionString + Node.ChildNodes.Item(7).Name + "=" + Node.ChildNodes.Item(7).InnerText;
        }
        return ConnectionString;
    }

    public void Fb_Open() {
        try {
            Fb_Connection = new FbConnection();
            Fb_Connection.ConnectionString = Fb_ConnectionXML();
            Fb_Connection.Open();
        } catch (InvalidCastException e) {
            MessageBox.Show("Unable to establish the Connection to the server");
        }
    }

    public void Fb_Close() {
        Fb_Connection.Close();
    }

    public void Fb_Execute(String SQL) {
        try {
            Fb_Open();
            FbCommand cmd = new FbCommand(SQL, Fb_Connection);
            cmd.ExecuteNonQuery();
            Fb_Close();
        } catch (InvalidCastException e) {
            MessageBox.Show("Unable to establish the Connection to the server");
        }
    }

    public DataTable Fb_DataTable(String SQL) {
        DataTable dt = new DataTable();
        try {
            Fb_Open();
            FbDataAdapter da = new FbDataAdapter(SQL, Fb_Connection);
            da.Fill(dt);
            Fb_Close();
        } catch (InvalidCastException e) {
            MessageBox.Show("Unable to establish the Connection to the server");
        }
        return dt;
    }

    public DataSet Fb_DataSet(String SQL) {
        DataSet dt = new DataSet();
        try {
            Fb_Open();
            FbDataAdapter da = new FbDataAdapter(SQL, Fb_Connection);
            da.Fill(dt, "Table");
            Fb_Close();
        } catch (InvalidCastException e) {
            MessageBox.Show("Unable to establish the Connection to the server");
        }
        return dt;
    }

}


El contenido del alchivo TXT
ServerType=0; User=SYSDBA; Password=masterkey; database=127.0.0.1:C:\LIMPIA.FDB; charset=UTF8
User=SYSDBA; Password=masterkey; DataSource=localhost; Database=C:\LIMPIA.FDB; Charset=UTF8; Port=; Pooling=true; ServerType=0


El Contenido del archivo XML
<?xml version="1.0" encoding="UTF-8"?>
<FirebirCN>
  <User>TheUser</User>
  <Password>ThePassword</Password>
  <Server>TheServer</Server>
  <Database>C:\Database.FDB</Database>
  <Charset>UTF8</Charset>
  <Port> </Port>
  <Pooling>false</Pooling>
  <ServerType>0</ServerType>
</FirebirCN>


Añadir referencias a las siguientes librerías

Download: FirebirdSql.Data.FirebirdClient.dll
Download: FirebirdDataAccess.Zhero.dll

11 febrero 2013

C# - Algoritmos - Convertir Bytes a Imagen (2005, 2008)

using System.Drawing;

private Image Get_IMAGE(Byte[] ImageB) {
    Image ImageR = null;
    if (ImageB != null)
        if (ImageB.Length > 0) {
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            ms.Write(ImageB, 0, ImageB.GetUpperBound(0) + 1);
            ImageR = System.Drawing.Image.FromStream(ms);
        }

    return ImageR;
}

10 febrero 2013

C# - Algoritmos - Convertir Imagen a Bytes (2005, 2008)

using System.Drawing;

private Byte[] Get_IMAGE(Image ImageR) {
    Byte[] ImageB = null;
    if (ImageR != null)
        try {
            using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) {
                ImageR.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                ImageB = ms.ToArray();
            }
        } catch (Exception) {
            throw;
        }
    return ImageB;
}

07 febrero 2013

Firebird - Procedimientos - Llenar un campo tipo BLOB con una imagen

SET TERM ^ ;
CREATE PROCEDURE UPDATE_IMAGE(
    CVE_REG VARCHAR(12) CHARACTER SET UTF8 COLLATE UTF8,
    IMAGE BLOB)
RETURNS( RETVAL SMALLINT )
AS
BEGIN
    UPDATE CAT_IMAGES 
        SET CAT_IMAGES.IMAGE = :IMAGE 
        WHERE CAT_IMAGES.CVE_REG = :CVE_REG;
    SUSPEND;
END^

SET TERM ; ^

06 febrero 2013

C# - Algoritmos - Llenar DataSet Manualmente (2005, 2008)

private void Fill_DataSet() {
    DataSet ds = new DataSet();

    ds.Tables.Add("0");
    ds.Tables["0"].Columns.Add("Campo_1", Type.GetType("System.String"));
    ds.Tables["0"].Columns.Add("Campo_2", Type.GetType("System.String"));
    ds.Tables["0"].Columns.Add("Campo_3", Type.GetType("System.String"));

    DataRow row = ds.Tables["0"].NewRow();

    row["Campo_1"] = "Rafael";
    row["Campo_2"] = "Méndez";
    row["Campo_3"] = "Mazariego";
    ds.Tables["0"].Rows.Add(row);

    ds.Tables["0"].AcceptChanges();
    DataGridView1.DataSource = ds.Tables["0"];
}

02 enero 2013

C# - Algoritmos - Cadenas Aleatorias (2005, 2008)

using System;
using System.Text;

public string RandomString(int size) {
    StringBuilder builder = new StringBuilder();
    Random random = new Random();
    char ch;
    for (int i = 0; i < size; i++) {
        ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
        builder.Append(ch);
    }
    return builder.ToString();
}