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();
}