/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] asArguments)
{
Hashtable rArguments = null;
try
{
rArguments = CUtility.rParseCommandLineArguments(asArguments,frmMain.c_sArgumentSeparator_Prefix,frmMain.c_sArgumentSeparator_Suffix);
string sCulture = (string)rArguments[frmMain.c_sArgumentKey_Culture];
if((sCulture != null)&&(sCulture != string.Empty))
{
try
{
System.Globalization.CultureInfo rCulture = new System.Globalization.CultureInfo(sCulture);
System.Threading.Thread.CurrentThread.CurrentCulture = rCulture;
System.Threading.Thread.CurrentThread.CurrentUICulture = rCulture;
}
catch(Exception)
{
}
}
string sUserName = (string)rArguments[frmMain.c_sArgumentKey_UserName];
string sPassword = (string)rArguments[frmMain.c_sArgumentKey_Password];
System.Collections.Hashtable rConfigurationSection = (System.Collections.Hashtable)System.Configuration.ConfigurationSettings.GetConfig(frmMain.c_sConfigurationSection_Authorization);
byte byLimit_LoginAttempts = byte.Parse((string)rConfigurationSection[frmMain.c_sKey_Limit_LoginAttempt]);
AuthenticationService.TaskVisionII_Authentication rAuthenticationService = new AuthenticationService.TaskVisionII_Authentication();
rAuthenticationService.Url = (string)rConfigurationSection[frmMain.c_sKey_Location_Service];
ICredentials rCredentials = null;
AuthenticationService.CUser rUser = null;
frmLogin rLogin = null;
byte cAttempts = 0;
while(cAttempts < byLimit_LoginAttempts)
{
try
{
if((sUserName != null)&&(sPassword != null))
{
rCredentials = new System.Net.NetworkCredential(sUserName,sPassword);
}
else
{
rCredentials = System.Net.CredentialCache.DefaultCredentials;
}
rAuthenticationService.Credentials = rCredentials;
rUser = rAuthenticationService.rAuthenticate();
break;
}
catch(WebException rException)
{
if(rLogin == null)
{
rLogin = new frmLogin();
}
rLogin.Show();
while(rLogin.Visible)
{
Application.DoEvents();
}
if(rLogin.DialogResult != DialogResult.OK)
{
break;
}
sUserName = rLogin.UserName;
sPassword = rLogin.Password;
}
cAttempts++;
}
if(rUser == null)
{
throw new Exception();
}
Thread.CurrentPrincipal = new CUser(rUser.sName,rUser.sLanguage_Preferred,rUser.afPermissions,rCredentials,rUser.asRoles);
}
catch(Exception rException)
{
return;
}
fRestart = true;
while(fRestart)
{
fRestart = false;
try
{
frmMain.SetCulture();
}
catch(Exception)
{
}
Application.Run(new frmMain(rArguments));
}
}