COmmitting test of async methods for page 3 on init page

This commit is contained in:
Rick Falkvinge
2012-11-12 11:12:54 +00:00
parent 016414cc9b
commit 87c62036f3
2 changed files with 54 additions and 6 deletions
+25 -6
View File
@@ -33,7 +33,7 @@
</head>
<body>
<form id="form2" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnablePageMethods="True" />
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
<script type="text/javascript">
@@ -75,14 +75,33 @@
$('#<%=this.TextServerName.ClientID %>').css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
$('#<%=this.TextServerAddress.ClientID %>').css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
} else {
$('#<%=this.TextServerName.ClientID %>').css('background-image', "none").disabled = true;
$('#<%=this.TextServerAddress.ClientID %>').css('background-image', "none").disabled = true;
$('#<%=this.TextServerName.ClientID %>').css('background-image', "none");
$('#<%=this.TextServerAddress.ClientID %>').css('background-image', "none");
}
}
else if (stepNumber == 2) {
// Press invisible button to have server initialize database accounts
isValid = true; // assume true, make false as we go
var textBoxes = ["<%=this.TextCredentialsReadDatabase.ClientID %>", "<%=this.TextCredentialsReadServer.ClientID %>", "<%=this.TextCredentialsReadUser.ClientID %>", "<%=this.TextCredentialsReadPassword.ClientID %>",
"<%=this.TextCredentialsWriteDatabase.ClientID %>", "<%=this.TextCredentialsWriteServer.ClientID %>", "<%=this.TextCredentialsWriteUser.ClientID %>", "<%=this.TextCredentialsWritePassword.ClientID %>",
"<%=this.TextCredentialsAdminDatabase.ClientID %>", "<%=this.TextCredentialsAdminServer.ClientID %>", "<%=this.TextCredentialsAdminUser.ClientID %>", "<%=this.TextCredentialsAdminPassword.ClientID %>"];
for (var loop = 0; loop < textBoxes.length; loop++) {
var fieldContents = $('#' + textBoxes[loop]).val();
if (fieldContents && fieldContents.length > 0) {
$('#' + textBoxes[loop]).css('background-image', "none");
} else {
$('#' + textBoxes[loop]).css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
isValid = false;
}
}
if (isValid) {
$('#<%=this.ButtonInitDatabase.ClientID %>').click();
}
// TODO: If isValid, press invisible button that starts import
}
return isValid;
@@ -316,7 +335,7 @@
<asp:TextBox CssClass="textinput" ID="TextCredentialsAdminUser" runat="server" />&nbsp;<br />
<asp:TextBox CssClass="textinput" ID="TextCredentialsAdminPassword" runat="server" />&nbsp;<br />
</div>
<div style="display:none"><asp:Button runat="server" ID="ButtonInitDatabase" Text="You should not see this button"/></div>
<div style="display:none"><asp:Button runat="server" ID="ButtonInitDatabase" Text="You should not see this button" OnClick="ButtonInitDatabase_Click"/></div>
</div>
<div id="step-3">
<h2 class="StepTitle">Step 3 Content</h2>
+29
View File
@@ -77,6 +77,10 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
preferredCulture = browserPreference;
}
if (preferredCulture == "en-US")
{
preferredCulture = "en-GB"; // Hack because of malfunctioning Telerik popup
}
/*
string[] languages = (string[])Application["Cultures"];
@@ -242,6 +246,31 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
return _buildIdentity;
}
protected void ButtonInitDatabase_Click (object sender, EventArgs args)
{
// Initialize database. For now, fake it.
for (int loop = 0; loop < 100; loop++)
{
Thread.Sleep(1000);
Session["PercentInitComplete"] = loop;
}
}
[WebMethod(true)] // "true" causes session to be loaded
public static int GetInitProgress()
{
try
{
return (int) HttpContext.Current.Session["PercentInitComplete"];
}
catch (Exception)
{
return 0; // session variable not set yet, so parsing error of a null object
}
}
[WebMethod]
public static bool VerifyHostName(string input)
{