using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CSLA.Security;
using System.Threading;
using GZTW.AyaNova.BLL;
namespace AyaNovaMBI
{
public partial class _default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
GZTW.AyaNova.BLL.AyaBizUtils.Initialize();
System.Text.StringBuilder s=new System.Text.StringBuilder();
s.Append("
");
s.Append("Licensed to: " + HttpUtility.HtmlEncode(AyaBizUtils.REGTO));//case 1171
s.Append("
");
s.Append("AyaNova® MBI Service management software 7.6");//(patch XXX)
s.Append("
");
s.Append("© 1999-2022 Ground Zero Tech-Works Inc. All rights reserved.");
s.Append("
");
this.litnfo.Text = s.ToString();
this.btnlogin.Visible = true;
}
catch (Exception ex)
{
//Case 352 - discovered that this was all using the inner exception blindly assuming
//there was one which caused any exception without an inner exception to throw a null reference
//exception here instead of showing the correct message (i.e. license or schema invalid etc etc).
//crack the exception
while (ex.InnerException != null)
ex = ex.InnerException;
if (ex.Message.Contains("fbembed"))
{
this.lit.Text ="The embedded firebird database can not be used with AyaNova MBI
" +
"MBI requires a database server
";
this.btnlogin.Visible = false;
}
else
{
this.lit.Text ="MBI was unable to start, most likely this is due to a configuration error.
" +
"Double check your settings in the config.txt file as outlined in the documentation.
" +
"The error message is:
" +
util.StringWebify(ex.Message) +
"
";
this.btnlogin.Visible = false;
}
}
}
protected void btnlogin_Click(object sender, EventArgs e)
{
string ls = AyaBizUtils.PluginSubscriptionStatus("MBI - Minimal browser interface", AyaNovaMBI.Timestamp.BuildAt);
if (ls=="OK")
{
string sUser = edUserName.Text;
string sPass = edPassword.Text;
if (sUser == "manager" && sPass == "letmein")
{
this.lit.Text = "Access denied: The default Administrator account password must be changed.";
return;
}
Session.Clear();
AyaBizUtils.Login(sUser, sPass);
if (Thread.CurrentPrincipal.Identity.IsAuthenticated && (!util.CurrentUser.IsClientOrHeadOfficeAccount)
&& (util.CurrentUser.IsScheduleable))
{
Session["AyaNova-Principle"] = Thread.CurrentPrincipal;
HttpContext.Current.User = (System.Security.Principal.IPrincipal)Session["AyaNova-Principle"];
FormsAuthentication.SetAuthCookie(sUser, false);
Response.Redirect("schedule.aspx");
}
}
else
{
if (ls == "NOTALLOWED")
{
this.lit.Text =
"NOT LICENSED!
This AyaNova MBI was built " +
AyaNovaMBI.Timestamp.BuildAt.ToString() + "
" +
"but your license subscription for it ended " +
AyaBizUtils.PluginSubscriptionDate("MBI - Minimal browser interface").ToString() + "
" +
"
Downgrade back to your previous version or purchase a subscription to use AyaNova MBI.";
}
else
this.lit.Text = "An MBI license is required to use AyaNova MBI";
}
}
//------------------
}
}