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;
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
img_service_management.AlternateText = "AyaNova service management work order software login";
try
{
GZTW.AyaNova.BLL.AyaBizUtils.Initialize();
}
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"))
{
Response.Write("
The embedded firebird database can not be used with AyaNova WBI
" +
"WBI requires a database server
");
Response.End();
}
else
{
Response.Write("WBI was unable to start, most likely this is due to a configuration error.
");
Response.Write("Double check your settings in the config.txt file as outlined in the documentation.
");
Response.Write("The error message is:
");
Response.Write("");
Response.Write(Util.StringWebify(ex.Message));
Response.Write("");
Response.End();
}
}
string ls = AyaBizUtils.PluginSubscriptionStatus("WBI - Web browser interface", WBI.Timestamp.BuildAt);
if (ls == "OK")
{
if (AyaBizUtils.REGTO != "CH Technologies, Inc.")//Case 844 exception for guy who doesn't want "advertising" or a "security risk" that his customers can see
litcomp.Text = "AyaNova® WBI Service management software
" +
"Licensed to: " + HttpUtility.HtmlEncode(AyaBizUtils.REGTO) + "
" + //case 1188
"© 1999-2022 Ground Zero Tech-Works Inc. All rights reserved.";
else
litcomp.Text = "";
}
else
{
//litcomp.Text = "Licensed to: NOT LICENSED";
string slm = "";
if (ls == "NOTALLOWED")
{
slm = "NOT LICENSED!
This AyaNova WBI was built " +
WBI.Timestamp.BuildAt.ToString() + "
" +
"but your license subscription for it ended " +
AyaBizUtils.PluginSubscriptionDate("WBI - Web browser interface").ToString() + "
" +
"
Downgrade back to your previous version or purchase a subscription to use AyaNova WBI.";
}
else
slm = "An WBI license is required to use AyaNova WBI";
Response.Write(""+slm+"
");
Response.End();
}
//Case 300
// this.HyperLink1.Text = this.HyperLink1.Text + " (v" + Util.Version + ")";
//case 1435 / case 1111
if(Request.QueryString["cl"]!=null)
Util.PageAddCustomContent(this.Page,true);
//case 2094
//case 1638
if (AyaBizUtils.TrialExpired || AyaBizUtils.LockedOut)
{
this.lit.Text = "Read only mode: License has expired";
}
}
protected void btnLogin_Click1(object sender, ImageClickEventArgs e)
{
string ls = AyaBizUtils.PluginSubscriptionStatus("WBI - Web browser interface", WBI.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)
{
Session["AyaNova-Principle"] = Thread.CurrentPrincipal;
HttpContext.Current.User = (System.Security.Principal.IPrincipal)Session["AyaNova-Principle"];
// The user has been authenticated.
// 1. Create the ticket.
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
Util.CurrentUserID.ToString(),
false,
999999);
// 2. Create the cookie using the ticket.
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName,
FormsAuthentication.Encrypt(ticket));
// 3. Attach the cookie to the outbound response.
Response.Cookies.Add(cookie);
// 4. Do the redirect.
if (Util.CurrentUser.IsClientOrHeadOfficeAccount)
{
if (AyaBizUtils.Right("Object.ClientServiceRequest") > (int)SecurityLevelTypes.NoAccess)
Response.Redirect("ClientClientServiceRequests.aspx");
else if(AyaBizUtils.Right("Object.WorkorderService") > (int)SecurityLevelTypes.NoAccess)
Response.Redirect("ClientWorkorders.aspx");
else
{
Response.Redirect("Limbo.aspx");
}
}
else
{
//remove grid last views data from cache in case it hasn't been
//expired already (this is to prevent user from seeing stale grid
//view set in AyaNova, generally only applicable when testing
//but here it is anyway)
Cache.Remove(Util.CurrentUserID.ToString() + "GridLastViews");
//Remove user grid filters list when logging in
Cache.Remove("UserGridFilters" + Util.CurrentUserID.ToString());
Response.Redirect("Service.aspx");
//FormsAuthentication.RedirectFromLoginPage(sUser, true);
}
}
}
else
{
this.lit.Text="A license is required to use AyaNova WBI";
}
}
}