133 lines
4.6 KiB
C#
133 lines
4.6 KiB
C#
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("<div><span class=\"tinytext\">");
|
|
s.Append("Licensed to: " + HttpUtility.HtmlEncode(AyaBizUtils.REGTO));//case 1171
|
|
s.Append("<br/>");
|
|
s.Append("AyaNova® MBI Service management software 7.6");//(patch XXX)
|
|
s.Append("<br/>");
|
|
s.Append("© 1999-2020 Ground Zero Tech-Works Inc. All rights reserved.");
|
|
s.Append("</span></div>");
|
|
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 ="<h2>The embedded firebird database can not be used with AyaNova MBI<br/>" +
|
|
"MBI requires a database server</h2>";
|
|
this.btnlogin.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
this.lit.Text ="<h2>MBI was unable to start, most likely this is due to a configuration error.</h2>" +
|
|
"<h3>Double check your settings in the config.txt file as outlined in the documentation.<br/>" +
|
|
"The error message is:</h3><div>" +
|
|
util.StringWebify(ex.Message) +
|
|
"</div><br/><br/><br/><br/>";
|
|
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!<br/><br/>This AyaNova MBI was built " +
|
|
AyaNovaMBI.Timestamp.BuildAt.ToString() + "<br/>" +
|
|
"but your license subscription for it ended " +
|
|
AyaBizUtils.PluginSubscriptionDate("MBI - Minimal browser interface").ToString() + "<br/>" +
|
|
"<br/>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";
|
|
|
|
}
|
|
}
|
|
|
|
|
|
//------------------
|
|
}
|
|
}
|