miércoles, 4 de diciembre de 2013

Creation & verification from demo software license file

CREATION FOR DEMO SOFTWARE LICENSE FILE

        static void Main(string[] args)
        {
            Console.Write("login:");

            ConsoleKeyInfo pw;
            StringBuilder input = new StringBuilder();
            pw = Console.ReadKey(true);
         
            while (pw.Key != ConsoleKey.Enter)
            {
                input.Append(pw.KeyChar);
                pw = Console.ReadKey(true);
            }

            string pwd = Encode64(input.ToString());

            if (pwd == "cHcuMy54eHg=")
            {
                string path = Directory.GetCurrentDirectory() + "\\licence";

                if (!Directory.Exists(path))
                    Directory.CreateDirectory(path);

                if (File.Exists(path + "\\licence.xaf"))
                    File.Delete(path + "\\licence.xaf");

                using (StreamWriter sw = File.CreateText(path + "\\licence.xaf"))
                {
                    sw.WriteLine(
                        (DateTime.Now.AddDays(30)).Month.ToString() + "/" +
                        (DateTime.Now.AddDays(30)).Day.ToString() + "/" +
                        (DateTime.Now.AddDays(30)).Year.ToString() +
                        "|100");
                }

                System.Diagnostics.Process.Start("explorer.exe", path);
            }
        }

VERIFICATION FOR LICENCE FILE

            string apppath = Directory.GetCurrentDirectory();

            try
            {
                if (File.Exists(apppath + "\\license.xaf"))
                {
                    using (StreamReader f = File.OpenText(apppath + "\\license.xaf"))
                    {
                        string s = f.ReadLine();
                        //s = Encode64("31/01/2013|100");
                        s = Decode64(s);
                        string[] ss = s.Split('|');

                        if (DateTime.Parse(
                            ss[0].Substring(3, 2) + "/" +
                            ss[0].Substring(0, 2) + "/" +
                            ss[0].Substring(6, 4)) < DateTime.Now)
                         
                            throw new Exception();
                    }

                    Factory.CanConnect = false;
                    Factory.LoadConfiguration(tbProject, tbSqlSrv, tbDatabase, tbUser, tbPwd, btConnect, btDir);
                }
                else
                {
                    throw new Exception();
                }
            }
            catch
            {
                MessageBox.Show("La aplicación requiere de una licencia válida.", "Información");
                Close();
            }

Encode & Decode 64 bits in C#

        public static string Encode64(string toEncode)
        {
            byte[] toEncodeAsBytes
                  = System.Text.ASCIIEncoding.ASCII.GetBytes(toEncode);
            string returnValue
                  = System.Convert.ToBase64String(toEncodeAsBytes);
            return returnValue;
        }

        public static string Decode64(string encodedData)
        {
            byte[] encodedDataAsBytes
                = System.Convert.FromBase64String(encodedData);
            string returnValue =
               System.Text.ASCIIEncoding.ASCII.GetString(encodedDataAsBytes);
            return returnValue;
        }

miércoles, 13 de noviembre de 2013

Control codes

ASCII
Hex
Símbolo
Tipo
Descripción
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
10
11
12
13
14
15
16
17
18
19
1A
1B
1C
1D
1E
1F
NUL
SOH
STX
ETX
EOT
ENQ
ACK
BEL
BS
TAB
LF
VT
FF
CR
SO
SI
DLE
DC1
DC2
DC3
DC4
NAK
SYN
ETB
CAN
EM
SUB
ESC
FS
GS
RS
US

CC
CC
CC
CC
CC
CC

FE
FE
FE
FE
FE
FE


CC




CC
CC
CC




IS
IS
IS
IS
Null - nulo
Start of Heading - inicio de cabecera
Start of Text - inicio de texto
End of Text - fin de texto
End of Transmission - fin de transmissión
Enquiry - solicitud de información
Acknowledge - confirmación
Bell - señal audible / tono de atención
Backspace - retroceso
Horizontal Tabulation - tabulado horizontal
Line Feed - avance de linea
Vertical Tabulation - tabulado vertical
Form Feed - avance de página
Carriage Return - Retorno de carro, iniciar nueva linea
Shift Out - terminar modo mayúsculas
Shift In - iniciar modo mayúsculas
Data Link Escape - escape del enlace de datos
Device Control 1 - control de dispositivo 1
Device Control 2 - control de dispositivo 2
Device Control 3 - control de dispositivo 3 
Device Control 4 - control de dispositivo 4
Negative Acknowledge - confirmación negativa
Synchronous Idle - sincronización de la comunicación 
End of Transmission Block - fin de bloque de transmissión
Cancel - cancelar
End of Medium - fin del medio (cinta/disco/papel)
Substitute - reemplazar
Escape
File Separator - separador de archivos
Group Separator - separador de grupo
Record Separator - separador de registro
Unit Separator - separador de unidad

CC - Communication Control - control de comunicación
FE - Format Effector - manipulador de formato
IS - Information Separator - separador de información

source: http://ascii.cl/es/codigos-de-control.htm

HTML codes

Standard ASCII set, HTML Entity names, ISO 10646, ISO 8879, ISO 8859-1 Latin alphabet No. 1
Browser support: All browsers


ASCII
HTML
HTML
Dec
Hex
Symbol
Number
Name
Description
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
20
21
22
23
24
25
26
27
28
29
2A
2B
2C
2D
2E
2F

!
"
#
$
%
&
'
(
)
*
+
,
-
.
/
&#32;
&#33;
&#34;
&#35;
&#36;
&#37;
&#38;
&#39;
&#40;
&#41;
&#42;
&#43;
&#44;
&#45;
&#46;
&#47;


&quot;



&amp;








space
exclamation point
double quotes
number sign
dollar sign
percent sign
ampersand
single quote
opening parenthesis
closing parenthesis
asterisk
plus sign
comma
minus sign - hyphen
period
slash
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
30
31
32
33
34
35
36
37
38
39
3A
3B
3C
3D
3E
3F
0
1
2
3
4
5
6
7
8
9
:
;
<
=
>
?
&#48;
&#49;
&#50;
&#51;
&#52;
&#53;
&#54;
&#55;
&#56;
&#57;
&#58;
&#59;
&#60;
&#61;
&#62;
&#63;












&lt;

&gt;
zero
one
two
three
four
five
six
seven
eight
nine
colon
semicolon
less than sign
equal sign
greater than sign
question mark
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
40
41
42
43
44
45
46
47
48
49
4A
4B
4C
4D
4E
4F
@
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
&#64;
&#65;
&#66;
&#67;
&#68;
&#69;
&#70;
&#71;
&#72;
&#73;
&#74;
&#75;
&#76;
&#77;
&#78;
&#79;

at symbol
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
50
51
52
53
54
55
56
57
58
59
5A
5B
5C
5D
5E
5F
P
Q
R
S
T
U
V
W
X
Y
Z
[
\
]
^
_
&#80;
&#81;
&#82;
&#83;
&#84;
&#85;
&#86;
&#87;
&#88;
&#89;
&#90;
&#91;
&#92;
&#93;
&#94;
&#95;












opening bracket
backslash
closing bracket
caret - circumflex
underscore
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
60
61
62
63
64
65
66
67
68
69
6A
6B
6C
6D
6E
6F
`
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
&#96;
&#97;
&#98;
&#99;
&#100;
&#101;
&#102;
&#103;
&#104;
&#105;
&#106;
&#107;
&#108;
&#109;
&#110;
&#111;

grave accent
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
70
71
72
73
74
75
76
77
78
79
7A
7B
7C
7D
7E
7F
p
q
r
s
t
u
v
w
x
y
z
{
|
}
~
&#112;
&#113;
&#114;
&#115;
&#116;
&#117;
&#118;
&#119;
&#120;
&#121;
&#122;
&#123;
&#124;
&#125;
&#126;












opening brace
vertical bar
closing brace
equivalency sign - tilde
(not defined in HTML 4 standard)
159
9F
(not defined in HTML 4 standard)
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
A0
A1
A2
A3
A4
A5
A6
A7
A8
A9
AA
AB
AC
AD
AE
AF

¡
¢
£
¤
¥
¦
§
¨
©
ª
«
¬

®
¯
&#160;
&#161;
&#162;
&#163;
&#164;
&#165;
&#166;
&#167;
&#168;
&#169;
&#170;
&#171;
&#172;
&#173;
&#174;
&#175;
&nbsp;
&iexcl;
&cent;
&pound;
&curren;
&yen;
&brvbar;
&sect;
&uml;
&copy;
&ordf;
&laquo;
&not;
&shy;
&reg;
&macr;
non-breaking space
inverted exclamation mark
cent sign
pound sign
currency sign
yen sign
broken vertical bar
section sign
spacing diaeresis - umlaut
copyright sign
feminine ordinal indicator
left double angle quotes
not sign
soft hyphen
registered trade mark sign
spacing macron - overline
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
B0
B1
B2
B3
B4
B5
B6
B7
B8
B9
BA
BB
BC
BD
BE
BF
°
±
²
³
´
µ

·
¸
¹
º
»
¼
½
¾
¿
&#176;
&#177;
&#178;
&#179;
&#180;
&#181;
&#182;
&#183;
&#184;
&#185;
&#186;
&#187;
&#188;
&#189;
&#190;
&#191;
&deg;
&plusmn;
&sup2;
&sup3;
&acute;
&micro;
&para;
&middot;
&cedil;
&sup1;
&ordm;
&raquo;
&frac14;
&frac12;
&frac34;
&iquest;
degree sign
plus-or-minus sign
superscript two - squared
superscript three - cubed
acute accent - spacing acute
micro sign
pilcrow sign - paragraph sign
middle dot - Georgian comma
spacing cedilla
superscript one
masculine ordinal indicator
right double angle quotes
fraction one quarter
fraction one half
fraction three quarters
inverted question mark
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
C0
C1
C2
C3
C4
C5
C6
C7
C8
C9
CA
CB
CC
CD
CE
CF
À
Á
Â
Ã
Ä
Å
Æ
Ç
È
É
Ê
Ë
Ì
Í
Î
Ï
&#192;
&#193;
&#194;
&#195;
&#196;
&#197;
&#198;
&#199;
&#200;
&#201;
&#202;
&#203;
&#204;
&#205;
&#206;
&#207;
&Agrave;
&Aacute;
&Acirc;
&Atilde;
&Auml;
&Aring;
&AElig;
&Ccedil;
&Egrave;
&Eacute;
&Ecirc;
&Euml;
&Igrave;
&Iacute;
&Icirc;
&Iuml;
latin capital letter A with grave
latin capital letter A with acute
latin capital letter A with circumflex
latin capital letter A with tilde
latin capital letter A with diaeresis
latin capital letter A with ring above
latin capital letter AE
latin capital letter C with cedilla
latin capital letter E with grave
latin capital letter E with acute
latin capital letter E with circumflex
latin capital letter E with diaeresis
latin capital letter I with grave
latin capital letter I with acute
latin capital letter I with circumflex
latin capital letter I with diaeresis
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
D0
D1
D2
D3
D4
D5
D6
D7
D8
D9
DA
DB
DC
DD
DE
DF
Ð
Ñ
Ò
Ó
Ô
Õ
Ö
×
Ø
Ù
Ú
Û
Ü
Ý
Þ
ß
&#208;
&#209;
&#210;
&#211;
&#212;
&#213;
&#214;
&#215;
&#216;
&#217;
&#218;
&#219;
&#220;
&#221;
&#222;
&#223;
&ETH;
&Ntilde;
&Ograve;
&Oacute;
&Ocirc;
&Otilde;
&Ouml;
&times;
&Oslash;
&Ugrave;
&Uacute;
&Ucirc;
&Uuml;
&Yacute;
&THORN;
&szlig;
latin capital letter ETH
latin capital letter N with tilde
latin capital letter O with grave
latin capital letter O with acute
latin capital letter O with circumflex
latin capital letter O with tilde
latin capital letter O with diaeresis
multiplication sign
latin capital letter O with slash
latin capital letter U with grave
latin capital letter U with acute
latin capital letter U with circumflex
latin capital letter U with diaeresis
latin capital letter Y with acute
latin capital letter THORN
latin small letter sharp s - ess-zed
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
E0
E1
E2
E3
E4
E5
E6
E7
E8
E9
EA
EB
EC
ED
EE
EF
à
á
â
ã
ä
å
æ
ç
è
é
ê
ë
ì
í
î
ï
&#224;
&#225;
&#226;
&#227;
&#228;
&#229;
&#230;
&#231;
&#232;
&#233;
&#234;
&#235;
&#236;
&#237;
&#238;
&#239;
agrave;
&aacute;
&acirc;
&atilde;
&auml;
&aring;
&aelig;
&ccedil;
&egrave;
&eacute;
&ecirc;
&euml;
&igrave;
&iacute;
&icirc;
&iuml;
latin small letter a with grave
latin small letter a with acute
latin small letter a with circumflex
latin small letter a with tilde
latin small letter a with diaeresis
latin small letter a with ring above
latin small letter ae
latin small letter c with cedilla
latin small letter e with grave
latin small letter e with acute
latin small letter e with circumflex
latin small letter e with diaeresis
latin small letter i with grave
latin small letter i with acute
latin small letter i with circumflex
latin small letter i with diaeresis
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
F0
F1
F2
F3
F4
F5
F6
F7
F8
F9
FA
FB
FC
FD
FE
FF
ð
ñ
ò
ó
ô
õ
ö
÷
ø
ù
ú
û
ü
ý
þ
ÿ
&#240;
&#241;
&#242;
&#243;
&#244;
&#245;
&#246;
&#247;
&#248;
&#249;
&#250;
&#251;
&#252;
&#253;
&#254;
&#255;
&eth;
&ntilde;
&ograve;
&oacute;
&ocirc;
&otilde;
&ouml;
&divide;
&oslash;
&ugrave;
&uacute;
&ucirc;
&uuml;
&yacute;
&thorn;
&yuml;
latin small letter eth
latin small letter n with tilde
latin small letter o with grave
latin small letter o with acute
latin small letter o with circumflex
latin small letter o with tilde
latin small letter o with diaeresis
division sign
latin small letter o with slash
latin small letter u with grave
latin small letter u with acute
latin small letter u with circumflex
latin small letter u with diaeresis
latin small letter y with acute
latin small letter thorn
latin small letter y with diaeresis

jueves, 12 de septiembre de 2013

Compressing MDB

procedure TDM.CompactAndRepairDataBase;
var
  JetEng: Variant;
  Src, Dst: WideString;
  SrcMDB, DstMDB: String;
  Provider: String;
begin
  DM.ConnectionScholl.Close;

  JetEng := CreateOleObject('JRO.JetEngine');

  try
    Provider := 'Provider=Microsoft.Jet.OLEDB.4.0;';
    SrcMDB := GetPathApp + 'Schollc.dat';
    DstMDB := GetPathApp + 'Scholl.dat';
    Src := Provider + 'Data Source=' + SrcMDB;
    Dst := Provider + 'Data Source=' + DstMDB;
    if RenameFile(DstMDB, SrcMDB) then
    begin
      JetEng.CompactDatabase(Src, Dst);
      DeleteFile(PChar(SrcMDB));
    end;
  finally
    JetEng := Unassigned;
  end;
end;

miércoles, 4 de septiembre de 2013

Merge GridView Cells Or Columns In Row ASP.NET C# VB.NET

Article

Using delegates

Article

DB2 Express for Windows

Here

TIFF - JPG, Image converter

Article

Oracle client data provider using C# & ODP.NET

Acticle for Microsoft OracleClient to ODP.NET Application

Resources

Web responsive

Article

Mootools, compact JS framework

Oficial Website Demos

Robotizando el IE

C# using WebBrowser control and need to access DOM elements
Sending text from my program to an existing program textbox
Sending text to specific textbox in IE

Graphic math functions demo

Go to

Jquery example

Go to

Products and Extensions for Visual Studio

Ver

Grafos, camino hamiltoniano

Wikipedia

AppFactory, how to...

Como obtener el código de descuento
Registro individual
Cómo subir tu aplicación
Tutorial AppFactory
Repositorio de tips de diseño

Game makers tools

#WebDevelopers repository
SMASH AND CATCH THOSE BUGS
Game Studios

Updating news

News

Why metro?

Articulo

Secure MVC app on Windows Azure

Articulo

Microsoft developer portal

Go... Go... Go.

Microsoft dynamics does metro style

Article

HTML5 movil

Part 1
Part 2
Part 3
Part 4
Part 5
Part 6
Part 7

Windows store

Promociona y distribuye. Elegir tus mercados
Ofrecer versiones gratuitas para despertar el interés.
Llevar tus aplicaciones al mercado
Seguimiento de las ventas de aplicaciones

Antes de enviar
Distribuir
Promover
Analizar y mejorar

How your app appears in the Windows Store

Beginning Windows Azure

Article

Kinect programing for Windows

Articulo
Recursos
Ejemplos

viernes, 23 de agosto de 2013

Exporting unknown table format to excel & exclude selected fields

    protected void Button1_Click(object senderEventArgs e)
    {
        string fichpath = ConfigurationManager.AppSettings["ruta"].ToString();
        string fich = "errores.xls";
        string cols = "";
        string colstype = "";
        bool flg = false;
        string nombretabla = "HS_IZ_CLIENTES";
        string fecha = "20130820";
        DataTable tabla = new DataTable("errores");
 
        try
        {
            SqlConnection cnx = new SqlConnection();
            cnx.ConnectionString = ConfigurationManager.ConnectionStrings["HSSIAAF"].ToString();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = cnx;
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "SELECT COLUMN_NAME,DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" + nombretabla + "' AND COLUMN_NAME NOT IN ('LINEA','ERROR','CHECKS','ERRORS','LINEAC')";
            cnx.Open();
            SqlDataReader dr = cmd.ExecuteReader();
 
            if (File.Exists(fichpath + fich))
                File.Delete(fichpath + fich);
 
            using (System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection(
                "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + fichpath + fich + "';Extended Properties='Excel 8.0;HDR=Yes'"))
            {
                using (System.Data.OleDb.OleDbCommand ocmd = new System.Data.OleDb.OleDbCommand(""con))
                {
                    ocmd.Connection = con;
                    con.Open();
 
                    string sql = "CREATE TABLE [Errores] ( ";
                    bool flgcomma = true;
 
                    try
                    {
                        while (dr.Read())
                        {
                            switch (dr.GetString(1))
                            {
                                case "char":
                                    {
                                        sql += (flgcomma ? "" : ","+ dr.GetString(0+ " CHAR(1) ";
                                        flg = true;
                                        break;
                                    }
                                case "varchar":
                                    {
                                        sql += (flgcomma ? "" : ","+ dr.GetString(0+ " VARCHAR(250) ";
                                        flg = true;
                                        break;
                                    }
                                case "int":
                                    {
                                        sql += (flgcomma ? "" : ","+ dr.GetString(0+ " INT ";
                                        flg = true;
                                        break;
                                    }
                                case "datetime":
                                    {
                                        sql += (flgcomma ? "" : ","+ dr.GetDateTime(0+ " DATETIME ";
                                        flg = true;
                                        break;
                                    }
                            }
 
                            if (flg)
                            {
                                cols += (flgcomma ? "" : ","+ dr.GetString(0);
                                colstype += (flgcomma ? "" : ","+ dr.GetString(1);
                                flgcomma = false;
                            }
                            flg = false;
                        }
                    }
                    catch
                    { }
 
                    sql += ")";
                    ocmd.CommandText = sql;
                    ocmd.CommandType = CommandType.Text;
                    ocmd.ExecuteNonQuery();
                    con.Close();
                    cnx.Close();
 
                    cmd.CommandText = "SELECT " + cols + " FROM " + nombretabla + " WHERE FECHA_CARGA='" + fecha + "'";
                    cnx.Open();
                    SqlDataReader dr2 = cmd.ExecuteReader();
                    string[] s = cols.Split(',');
                    string[] st = colstype.Split(',');
                    int cant = s.Length;
                    con.Open();
 
                    while (dr2.Read())
                    { 
                        sql = "INSERT INTO [Errores] (" + cols + ") VALUES(";
                        flgcomma = true;
                        
                        for (int i = 0i <= cant - 1i++)
                        {
                            switch (st[i])
                            {
                                case "char":
                                    {
                                        try
                                        {
                                            string sv = dr2.GetString(i);
                                            sv = sv.Replace('\''' ').Replace('\"'' ');
 
                                            sql += (flgcomma ? "'" : ",'"+ dr2.GetString(i+ "'";
                                        }
                                        catch
                                        {
                                            sql += (flgcomma ? "'" : ",'"+ "'";
                                        }
 
                                        flgcomma = false;
                                        break;
                                    }
                                case "varchar":
                                    {
                                        try
                                        {
                                            string sv = dr2.GetString(i);
                                            int y = 0;
                                            sv = sv.Replace('\''' ').Replace('\"'' ');
 
                                            if (sv.Length > 250)
                                                sv = sv.Substring(1247+ "...";
 
                                            sql += (flgcomma ? "'" : ",'"+ sv + "'";
                                        }
                                        catch
                                        {
                                            sql += (flgcomma ? "'" : ",'"+ "'";
                                        }
 
                                        flgcomma = false;
                                        break;
                                    }
                                case "int":
                                    {
                                        try
                                        {
                                            sql += (flgcomma ? "" : ","+ dr2.GetInt32(i);
                                        }
                                        catch
                                        {
                                            sql += (flgcomma ? "" : ","+ "0";
                                        }
 
                                        flgcomma = false;
                                        break;
                                    }
                                case "datetime":
                                    {
                                        DateTime d = dr2.GetDateTime(i);
 
                                        try
                                        {
                                            sql += (flgcomma ? "'" : ",'"+ d.Year.ToString() + (d.Month < 10 ? "0" : ""+ d.Month.ToString() + (d.Day < 10 ? "0" : ""+ d.Day.ToString() + "'";
                                        }
                                        catch
                                        {
                                            sql += (flgcomma ? "'" : ",'"+ "'";
                                        }
 
                                        flgcomma = false;
                                        break;
                                    }
                            }
                        }
                        
                        sql += ")";
                        ocmd.CommandText = sql.Replace('\t',' ').Replace('\n',' ');
 
                        try
                        {
                            ocmd.ExecuteNonQuery();
                        }
                        catch
                        {
                            if (con.State == ConnectionState.Open)
                            {
                                ocmd.CommandText = "INSERT INTO [Errores] (" + cols.Substring(0cols.IndexOf(',')) + ") VALUES('ERROR')";
                                ocmd.ExecuteNonQuery();
                            }
                        }
                    }
 
                    con.Close();
                    cnx.Close();
                }
            }
 
            //Insert Terminado
        }
        catch //(Exception ex)
        {
            //ex.ToString();
        }
 
        Response.Clear();
        Response.AddHeader("Content-Disposition""attachment; filename=" + fich);
        Response.Charset = "";
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.ContentType = "application/excel";
        Response.TransmitFile(fichpath + fich);
        Response.End();
    }