using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using GZTW.AyaNova.BLL;
using log4net;
namespace AyaNova
{
///
/// Summary description for GlobalxForm.
///
public class GlobalxForm : System.Windows.Forms.Form
{
// Create a logger for use in this class
//case 1039 private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private Infragistics.Win.UltraWinEditors.UltraTextEditor edNotes;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _GlobalxForm_Toolbars_Dock_Area_Left;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _GlobalxForm_Toolbars_Dock_Area_Right;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _GlobalxForm_Toolbars_Dock_Area_Top;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _GlobalxForm_Toolbars_Dock_Area_Bottom;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsManager tbManager;
private System.ComponentModel.IContainer components;
private bool LicenseOnlyMode = false;
public GlobalxForm(bool licenseonlymode = false)
{
//case 2094
LicenseOnlyMode = licenseonlymode;
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
//
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
Infragistics.Win.UltraWinToolbars.UltraToolbar ultraToolbar1 = new Infragistics.Win.UltraWinToolbars.UltraToolbar("GlobalxMenuBar");
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool5 = new Infragistics.Win.UltraWinToolbars.ButtonTool("fetch");
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool1 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:Admin.Label.PasteLicense");
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool2 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:Admin.Label.EraseDatabase");
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool3 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:Admin.Label.PasteLicense");
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool4 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:Admin.Label.EraseDatabase");
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool6 = new Infragistics.Win.UltraWinToolbars.ButtonTool("fetch");
this.edNotes = new Infragistics.Win.UltraWinEditors.UltraTextEditor();
this.tbManager = new Infragistics.Win.UltraWinToolbars.UltraToolbarsManager(this.components);
this._GlobalxForm_Toolbars_Dock_Area_Left = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
this._GlobalxForm_Toolbars_Dock_Area_Right = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
this._GlobalxForm_Toolbars_Dock_Area_Top = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
this._GlobalxForm_Toolbars_Dock_Area_Bottom = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
((System.ComponentModel.ISupportInitialize)(this.edNotes)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tbManager)).BeginInit();
this.SuspendLayout();
//
// edNotes
//
this.edNotes.AcceptsReturn = true;
this.edNotes.Dock = System.Windows.Forms.DockStyle.Fill;
this.edNotes.Location = new System.Drawing.Point(0, 26);
this.edNotes.Multiline = true;
this.edNotes.Name = "edNotes";
this.edNotes.ReadOnly = true;
this.edNotes.Size = new System.Drawing.Size(628, 417);
this.edNotes.TabIndex = 128;
//
// tbManager
//
this.tbManager.DesignerFlags = 1;
this.tbManager.DockWithinContainer = this;
this.tbManager.DockWithinContainerBaseType = typeof(System.Windows.Forms.Form);
this.tbManager.ShowFullMenusDelay = 500;
ultraToolbar1.DockedColumn = 0;
ultraToolbar1.DockedRow = 0;
ultraToolbar1.NonInheritedTools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
buttonTool5,
buttonTool1,
buttonTool2});
ultraToolbar1.Text = "GlobalxMenuBar";
this.tbManager.Toolbars.AddRange(new Infragistics.Win.UltraWinToolbars.UltraToolbar[] {
ultraToolbar1});
this.tbManager.ToolbarSettings.AllowCustomize = Infragistics.Win.DefaultableBoolean.False;
this.tbManager.ToolbarSettings.AllowFloating = Infragistics.Win.DefaultableBoolean.False;
this.tbManager.ToolbarSettings.AllowHiding = Infragistics.Win.DefaultableBoolean.False;
buttonTool3.SharedPropsInternal.Caption = "LT:Admin.Label.PasteLicense";
buttonTool3.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.TextOnlyAlways;
buttonTool4.SharedPropsInternal.Caption = "LT:Admin.Label.EraseDatabase";
buttonTool4.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.TextOnlyAlways;
buttonTool6.SharedPropsInternal.Caption = "Fetch license";
buttonTool6.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.TextOnlyAlways;
this.tbManager.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
buttonTool3,
buttonTool4,
buttonTool6});
this.tbManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.tbManager_ToolClick);
//
// _GlobalxForm_Toolbars_Dock_Area_Left
//
this._GlobalxForm_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._GlobalxForm_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control;
this._GlobalxForm_Toolbars_Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Left;
this._GlobalxForm_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText;
this._GlobalxForm_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 26);
this._GlobalxForm_Toolbars_Dock_Area_Left.Name = "_GlobalxForm_Toolbars_Dock_Area_Left";
this._GlobalxForm_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 417);
this._GlobalxForm_Toolbars_Dock_Area_Left.ToolbarsManager = this.tbManager;
//
// _GlobalxForm_Toolbars_Dock_Area_Right
//
this._GlobalxForm_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._GlobalxForm_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control;
this._GlobalxForm_Toolbars_Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Right;
this._GlobalxForm_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText;
this._GlobalxForm_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(628, 26);
this._GlobalxForm_Toolbars_Dock_Area_Right.Name = "_GlobalxForm_Toolbars_Dock_Area_Right";
this._GlobalxForm_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 417);
this._GlobalxForm_Toolbars_Dock_Area_Right.ToolbarsManager = this.tbManager;
//
// _GlobalxForm_Toolbars_Dock_Area_Top
//
this._GlobalxForm_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._GlobalxForm_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control;
this._GlobalxForm_Toolbars_Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Top;
this._GlobalxForm_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText;
this._GlobalxForm_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0);
this._GlobalxForm_Toolbars_Dock_Area_Top.Name = "_GlobalxForm_Toolbars_Dock_Area_Top";
this._GlobalxForm_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(628, 26);
this._GlobalxForm_Toolbars_Dock_Area_Top.ToolbarsManager = this.tbManager;
//
// _GlobalxForm_Toolbars_Dock_Area_Bottom
//
this._GlobalxForm_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._GlobalxForm_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control;
this._GlobalxForm_Toolbars_Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Bottom;
this._GlobalxForm_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText;
this._GlobalxForm_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 443);
this._GlobalxForm_Toolbars_Dock_Area_Bottom.Name = "_GlobalxForm_Toolbars_Dock_Area_Bottom";
this._GlobalxForm_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(628, 0);
this._GlobalxForm_Toolbars_Dock_Area_Bottom.ToolbarsManager = this.tbManager;
//
// GlobalxForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
this.ClientSize = new System.Drawing.Size(628, 443);
this.Controls.Add(this.edNotes);
this.Controls.Add(this._GlobalxForm_Toolbars_Dock_Area_Left);
this.Controls.Add(this._GlobalxForm_Toolbars_Dock_Area_Right);
this.Controls.Add(this._GlobalxForm_Toolbars_Dock_Area_Bottom);
this.Controls.Add(this._GlobalxForm_Toolbars_Dock_Area_Top);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "GlobalxForm";
this.Load += new System.EventHandler(this.GlobalxForm_Load);
((System.ComponentModel.ISupportInitialize)(this.edNotes)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.tbManager)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private void GlobalxForm_Load(object sender, System.EventArgs e)
{
Icon = Resource1.AyaNova5;
//case 1039 //log.Debug("GlobalxForm_Load");
Util.Localize(this);
edNotes.Text = AyaBizUtils.View();
if (LicenseOnlyMode)
{
//hide the erase database option
tbManager.Tools["LT:Admin.Label.EraseDatabase"].SharedProps.Visible = false;
}
}
private void tbManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
{
switch (e.Tool.Key)
{
case "LT:Admin.Label.EraseDatabase": // ButtonTool
if (AyaBizUtils.Trial)
{
MessageBox.Show("This feature requires a license.\r\nTrial databases can not be erased.");
return;
}
if (!AyaBizUtils.Lite && !User.IsAdmin)
{
Util.PromptAdministratorOnly();
return;
}
// Place code here
if (Util.PromptYesNoFromLocaleKey("Admin.Label.EraseDatabaseWarning") != DialogResult.Yes)
return;
if (Util.PromptYesNoFromLocaleKey("Admin.Label.EraseDatabaseLastWarning") != DialogResult.Yes)
return;
Cursor.Current = Cursors.WaitCursor;
DBManager.EraseDatabase("I_UNDERSTAND_ALL_DATA_WILL_BE_ERASED_AND_I_ACCEPT_RESPONSIBILITY");
Application.Exit();
break;
case "LT:Admin.Label.PasteLicense": // ButtonTool
if (!AyaBizUtils.Lite && !User.IsAdmin)
{
Util.PromptAdministratorOnly();
return;
}
if (Clipboard.GetDataObject().GetDataPresent(typeof(string)))
{
string s = (string)Clipboard.GetDataObject().GetData(typeof(string));
//case 1172
string sKeyType = "AyaNovaLiteLicenseKey";
if (s.Contains("AyaNovaLicenseKey"))//modified to take out <> for case 3122
{
sKeyType = "AyaNovaLicenseKey";
}
bool containsXML = s.Contains("");
bool containsJSON = s.Contains("[KEY");
if (!containsXML && !containsJSON)
{
Util.PromptWithIconOKOnlyFromLocaleKey("Key.Error.NotFound", MessageBoxIcon.Error);
return;
}
//Key sanity checks
bool isRequestedTrial = false;
int newScheduleableUsers = 0;
if (containsJSON)
{
string keyNoWS = System.Text.RegularExpressions.Regex.Replace(AyaBizUtils.ExtractString(s, "[KEY", "KEY]").Trim(), "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1").ToLowerInvariant();
if (keyNoWS.Contains("\"RequestedTrial\":\"True\"".ToLowerInvariant()))
{
isRequestedTrial = true;
}
newScheduleableUsers = int.Parse(AyaBizUtils.ExtractString(keyNoWS, ",\"TotalScheduleableUsers\":\"".ToLowerInvariant(), "\","));
}
else
{
//xml key
isRequestedTrial = s.Contains("RequestedTrial>true");
newScheduleableUsers = int.Parse(AyaBizUtils.ExtractString(s, "", ""));
}
if (AyaBizUtils.RequestedTrial && isRequestedTrial)
{
MessageBox.Show(
"This requested trial license can not be used because this database already contains a requested trial license\r\n"
, "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
return;
}
//Don't allow them to enter a lite key into a db that is currently not a standalone firebird
//otherwise they could permanently lock themselves out of the db (until we fixed it of course)
if (sKeyType == "AyaNovaLiteLicenseKey" && !AyaBizUtils.AyaNovaConnectionSetting.SingleUserConnection)
{
MessageBox.Show(
"This AyaNova Lite license can not be used because the current database is not a single user stand alone FireBird database.\r\n" +
"AyaNova Lite can not be used with a Firebird server or Microsoft SQL server.\r\n", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
return;
}
//case 2084
//warn if less users in new key than in current license
if (!AyaBizUtils.Trial)
{
if (AyaBizUtils.ScheduleableUsers > newScheduleableUsers)
{
//case 3199
if (MessageBox.Show("WARNING: The Key you are about to apply is for less scheduleable resource licenses than your database is presently licensed for.\r\n\r\nPlease cancel and resolve; or select OK to apply", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) != DialogResult.OK)
{
return;
}
}
}
if (!AyaBizUtils.Insert(s))
{
Util.PromptWithIconOKOnlyFromLocaleKey("Key.Error.NotValid", MessageBoxIcon.Error);
Application.Exit();
}
else
{
edNotes.Text = AyaBizUtils.View();
Util.PromptWithIconOKOnlyFromLocaleKey("Key.Label.Saved", MessageBoxIcon.Information);
Application.Exit();
}
}
else
Util.PromptWithIconOKOnlyFromLocaleKey("Key.Error.NotFound", MessageBoxIcon.Error);
break;
//case 3233
case "fetch":
{
if (!AyaBizUtils.Lite && !User.IsAdmin)
{
Util.PromptAdministratorOnly();
return;
}
GlobalFetchKey d = new GlobalFetchKey();
d.ShowDialog();
}
break;
}
}
}
}