();
mNotifyPopUpList = NotifyPopUpList.GetList();
if (mNotifyPopUpList.Count > 0)
{
//enable popup menu option
ShowNotifyPopMenuOption(true);
//See if there is a newer notification than previous
bool bNewNotifications = false;
System.Text.StringBuilder sbPopupText = new StringBuilder();
sbPopupText.Append("
");
//case 3467
//we want to display a maximum of 5 items and then just say +xx more...
int addedPopupItemCount = 0;
foreach (NotifyPopUpList.NotifyPopUpListInfo i in mNotifyPopUpList)
{
if (!lsShownPopUpNotifications.Contains(i.ID))
{
lsShownPopUpNotifications.Add(i.ID);
bNewNotifications = true;
sbPopupText.Append("");
sbPopupText.Append(i.LT_Notify_Label_NotificationMessage);
sbPopupText.Append("
");
//case 3467
addedPopupItemCount++;
if (addedPopupItemCount > 5)
{
sbPopupText.Append("
+ ");
sbPopupText.Append((mNotifyPopUpList.Count - 5).ToString());
sbPopupText.Append(" MORE....
");
break;
}
}
}
//if so then show the windesktop notification bubble
if (bNewNotifications)
{
Infragistics.Win.Misc.UltraDesktopAlertShowWindowInfo wi =
new Infragistics.Win.Misc.UltraDesktopAlertShowWindowInfo();
//Infragistics.Win.Misc.UltraDesktopAlertWindowInfo i = new Infragistics.Win.Misc.UltraDesktopAlertWindowInfo();
wi.Caption = Thread.CurrentPrincipal.Identity.Name;
wi.FooterText = "AyaNova";
wi.Image = Resource1.NotificationSubscription32;
wi.PinButtonVisible = false;
wi.Pinned = false;
wi.Text = sbPopupText.ToString();
wi.Key = "NOTIFYBUBBLE";
// Disallow moving the desktop alert window, and prevent
// multiple alerts from appearing.
this.ultraDesktopAlert1.AllowMove = Infragistics.Win.DefaultableBoolean.False;
this.ultraDesktopAlert1.MultipleWindowDisplayStyle = Infragistics.Win.Misc.MultipleWindowDisplayStyle.None;
// Set AutoClose to true, and set AutoCloseDelay to a relatively
// high value so that the end user has enough time to notice the alert.
this.ultraDesktopAlert1.AutoClose = Infragistics.Win.DefaultableBoolean.True;
this.ultraDesktopAlert1.AutoCloseDelay = 5000;
this.ultraDesktopAlert1.AnimationStyleShow = Infragistics.Win.Misc.AnimationStyle.Fade;
this.ultraDesktopAlert1.AnimationStyleAutoClose = Infragistics.Win.Misc.AnimationStyle.Fade;
this.ultraDesktopAlert1.TreatCaptionAsLink = Infragistics.Win.DefaultableBoolean.False;
this.ultraDesktopAlert1.TreatFooterTextAsLink = Infragistics.Win.DefaultableBoolean.False;
// this.ultraDesktopAlert1.TreatTextAsLink = Infragistics.Win.DefaultableBoolean.False;
//this.ultraDesktopAlert1.AnimationScrollDirectionShow = Infragistics.Win.Misc.AnimationScrollDirection.BottomRightToTopLeft;
// this.ultraDesktopAlert1.AnimationScrollDirectionAutoClose = Infragistics.Win.Misc.AnimationScrollDirection.TopLeftToBottomRight;
// this.ultraDesktopAlert1.FixedSize =
//new Size(Screen.PrimaryScreen.WorkingArea.Width / 8,
//Screen.PrimaryScreen.WorkingArea.Height / 8);
//this.ultraDesktopAlert1.TextAppearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True;
this.ultraDesktopAlert1.Show(wi);
}
}
else
{
//disable popup menu option
ShowNotifyPopMenuOption(false);
//reset
lsShownPopUpNotifications.Clear();
}
}
#endregion
Cursor.Current = Cursors.Default;//was bugging me that wait cursor didn't clear on gen process while testing case 1163
timer1.Start();
}
private void ultraDesktopAlert1_DesktopAlertLinkClicked(object sender, Infragistics.Win.Misc.DesktopAlertLinkClickedEventArgs e)
{
ShowPopupNotificationForm();
}
private void ShowNotifyPopMenuOption(bool Show)
{
this.ultraToolbarsManager1.Tools["NotifyPop"].SharedProps.Enabled = Show;
this.ultraToolbarsManager1.Tools["NotifyPop"].SharedProps.Visible = Show;
}
private void ShowPopupNotificationForm()
{
if (this.ultraDesktopAlert1.IsOpen("NOTIFYBUBBLE"))
ultraDesktopAlert1.GetWindowInfo("NOTIFYBUBBLE").Close();
PopUp p = new PopUp(mNotifyPopUpList);
p.ShowDialog();
}
#endregion
#region Open workorder toolbar events
///
/// Direct open workorder by number click event
///
///
///
private void edOpenWorkorder_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
Guid g = Guid.Empty;
string sObject = Util.LocaleText.GetLocalizedText("O.WorkorderService");
WorkorderTypes wotype = WorkorderTypes.Service;
switch (e.Button.Key)
{
case "QUOTE":
wotype = WorkorderTypes.Quote;
sObject = Util.LocaleText.GetLocalizedText("O.WorkorderQuote");
break;
case "PM":
wotype = WorkorderTypes.PreventiveMaintenance;
sObject = Util.LocaleText.GetLocalizedText("O.WorkorderPreventiveMaintenance");
break;
}
g = WorkorderInternalIDFetcher.GetItem(edOpenWorkorder.Text, wotype);
if (g != Guid.Empty && (AyaBizUtils.InYourRegion(ObjectRegionIDFetcher.ObjectRegion(new TypeAndID(RootObjectTypes.Workorder, g)))))//case 58
Util.EditRecord(RootObjectTypes.Workorder, g);
else
MessageBox.Show(
string.Format(Util.LocaleText.GetLocalizedText("Error.Object.FieldValueNotValid"), edOpenWorkorder.Text),
sObject,
MessageBoxButtons.OK,
MessageBoxIcon.Information
);
}
///
/// Case 226
/// Open service workorder if enter key is used since
/// it's the most common workorder type
///
///
///
private void edOpenWorkorder_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
Cursor.Current = Cursors.WaitCursor;
Guid g = Guid.Empty;
string sObject = Util.LocaleText.GetLocalizedText("O.WorkorderService");
WorkorderTypes wotype = WorkorderTypes.Service;
g = WorkorderInternalIDFetcher.GetItem(edOpenWorkorder.Text, wotype);
if (g != Guid.Empty && (AyaBizUtils.InYourRegion(ObjectRegionIDFetcher.ObjectRegion(new TypeAndID(RootObjectTypes.Workorder, g)))))//case 58
Util.EditRecord(RootObjectTypes.Workorder, g);
else
{
MessageBox.Show(
string.Format(Util.LocaleText.GetLocalizedText("Error.Object.FieldValueNotValid"), edOpenWorkorder.Text),
sObject,
MessageBoxButtons.OK,
MessageBoxIcon.Information
);
}
}
}
#endregion
#region Docking events
private void dm_AfterSplitterDrag(object sender, PanesEventArgs e)
{
DockableControlPane pane = dm.ControlPanes[0];
int newwidth = e.Panes[0].ActualSize.Width;
if (newwidth < 60) newwidth = 60;//sanity check
pane.FlyoutSize = new Size(newwidth, pane.FlyoutSize.Height);
}
private void dm_AfterHideFlyout(object sender, ControlPaneEventArgs e)
{
e.Pane.TextTab = GetExplorerBarSelectionString();
}
#endregion
private void Form1_Deactivate(object sender, EventArgs e)
{
}
private void Form1_Shown(object sender, EventArgs e)
{
////case 1389 TEST
//throw new System.InvalidOperationException("TEST case 1389");
//case 2049
//all this expires stuff previously was about trial versions only.
if (AyaBizUtils.Trial || AyaBizUtils.WillLockout || AyaBizUtils.RequestedTrial)
{
//case 1172 moved here for lite version because
//this messagebox is hidden behind splash in autologin
if (AyaBizUtils.TrialExpired || AyaBizUtils.LockedOut)
{//case 1424
TrialExpired tedlg = new TrialExpired();
tedlg.ShowDialog();
//Util.PromptWithIconOKOnlyFromLocaleKey("Error.License.Expired", MessageBoxIcon.Warning);
}
else if (AyaBizUtils.WillExpire || AyaBizUtils.WillLockout)
{//case 1306
TrialExpire tedlg = new TrialExpire();
tedlg.ShowDialog();
}
}
else
{
//case 2094
//warning if trial is within 10 days of expiry
//warning if expired
if (AyaBizUtils.SubscriptionExpirationImminent || AyaBizUtils.SubscriptionExpired)
{
SubStatus ssdlg = new SubStatus();
ssdlg.ShowDialog();
}
}
//case 1389
MainFormLoadingComplete = true;
}
//case 1163
private void timerClock_Tick(object sender, EventArgs e)
{
toolStripClock.Text = DBUtil.CurrentWorkingDateTime.ToString();
}
#region Accelerator keys
///
/// Case 37
///
///
///
///
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
#if(DEBUG)
// ____ ___ ___ ____ __ _ _ __
//(_ _)( _)/ __)(_ _)( )( \( )/ _)
// )( ) _)\__ \ )( )( ) (( (/\
// (__) (___)(___/ (__) (__)(_)\_)\__/
//Case 515 testing
if (keyData == Keys.F12)
{
}
if (keyData == Keys.F11)
{
//ctrl-alt-g for GRID FILTER CRITERIA
//END OF TESTING
}
#endif
//Short circuit:
//Only process modified keystrokes (i.e. when a modifier like ctrl-alt-or shift is also
//being held down
if (ModifierKeys == Keys.None) return base.ProcessCmdKey(ref msg, keyData);
switch (Util.HotKeys(keyData))
{
//Close form
case HotKeyAction.CloseForm:
this.Close();
return true;
//case 776
case HotKeyAction.GridFilterCriteria://ctrl-alt-g
CopyableMessageBox cp = new CopyableMessageBox(frmMainGrid.CurrentGridFilterCriteria);
cp.ShowDialog();
return true;
case HotKeyAction.NewWorkorder:
case HotKeyAction.NewQuote:
case HotKeyAction.NewPreventiveMaintenance:
{
//Get which client first...
WorkorderTypes wotype = WorkorderTypes.Unknown;
if (Util.HotKeys(keyData) == HotKeyAction.NewWorkorder)
wotype = WorkorderTypes.Service;
if (Util.HotKeys(keyData) == HotKeyAction.NewPreventiveMaintenance)
wotype = WorkorderTypes.PreventiveMaintenance;
if (Util.HotKeys(keyData) == HotKeyAction.NewQuote)
wotype = WorkorderTypes.Quote;
if (AyaBizUtils.Lite && wotype != WorkorderTypes.Service) return true;//case 1206
ClientSelector c = new ClientSelector(wotype);
DialogResult result = c.ShowDialog();
if (result == DialogResult.Cancel) return true;
Workorder w = null;
try
{
if (c.SelectedTemplateID != Guid.Empty)
w = Workorder.NewItem(c.SelectedTemplateID, c.SelectedClientID);
else
{
switch (Util.HotKeys(keyData))
{
case HotKeyAction.NewWorkorder:
w = Workorder.NewItem(WorkorderTypes.Service);
break;
case HotKeyAction.NewQuote:
w = Workorder.NewItem(WorkorderTypes.Quote);
break;
case HotKeyAction.NewPreventiveMaintenance:
w = Workorder.NewItem(WorkorderTypes.PreventiveMaintenance);
break;
}
}
}
catch (TrialException ex)
{
ex.ToString();
Util.PromptRestricted();
return true;
}
w.ClientID = c.SelectedClientID;
c.Dispose();
if (AyaBizUtils.Lite)//case 1172
{
WorkorderFormLite wfl = new WorkorderFormLite();
wfl.WorkorderToEdit = w;
wfl.ShowDialog();
wfl.Dispose();
}
else
{
WorkorderForm wf = new WorkorderForm();
wf.WorkorderToEdit = w;
//Case 677
wf.Show();
}
//wf.Dispose();
}
return true;
case HotKeyAction.NewClient:
{
Util.EditRecord(RootObjectTypes.Client, AyaBizUtils.NewObjectGuid);
}
return true;
case HotKeyAction.NewUnit:
{
if (AyaBizUtils.Lite) return true;//case 1206
Util.EditRecord(RootObjectTypes.Unit, AyaBizUtils.NewObjectGuid);
}
return true;
case HotKeyAction.NewPart:
{
Util.EditRecord(RootObjectTypes.Part, AyaBizUtils.NewObjectGuid);
}
return true;
case HotKeyAction.EmptyWorkingSet:
{
Util.EmptyWorkingSet();
MessageBox.Show(
"Note: doing this slows AyaNova down temporarily.\r\n" +
"Only use this option for diagnostic purposes.\r\n" +
"(If Windows gets low on memory it will automatically \r\n" +
"take back what it requires from .net applications like AyaNova if required)", "All cached memory freed to operating system");
}
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
#endregion
//************************************************************
}
#region main and application class
public class clsMain
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public clsMain()
{
//
// TODO: Add constructor logic here
//
}
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//Application.DoEvents();
//case 2094 related
try
{
new MyApp().Run(args);
}
catch (System.NullReferenceException)
{
;//no operation, this was found to be happening when an old db is updated to a new db, maybe
//an attempt to show something that doesn't exist yet in db or...?
//it's so obscure I'm just going to swallow it here (but only that specific one)
}
catch (System.ObjectDisposedException)
{
;//no operation, this was found to be happening when an old db is updated to a new db, maybe
//an attempt to show something that doesn't exist yet in db or...?
//it's so obscure I'm just going to swallow it here (but only that specific one)
}
}
//These changes added for case 1157
public class MyApp : Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase
{
protected override void OnCreateSplashScreen()
{
//case 1389
this.MinimumSplashScreenDisplayTime = 3000;
this.SplashScreen = new Splish();
}
protected override void OnCreateMainForm()
{
//bugbug begininvoke error could it be because something is happening in this event
//handler that shouldn't such as a dialog box or something, need to research OnCreatemainForm for more
//possibilities...
// Do your time consuming stuff here...
#region .net 4 full profile check
//case 1571
if (Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full") == null)
{
MessageBox.Show("AyaNova was unable to start\r\n\r\n" +
"This release of AyaNova requires the .net 4.0 Full profile not the lesser Client profile\r\n\r\n" +
"Normally the installer ensures it's present, did you copy the AyaNova program files without running setup?\r\n",
"Fatal Error",
MessageBoxButtons.OK,
MessageBoxIcon.Stop);
return;
}
#endregion
#region Log environment
//OK, we can start logging now and continue initialization...
if (log.IsDebugEnabled)
{
log.Info("AyaNova start - full environment:\r\n" +
Util.FullSupportInfo());
}
else
{
log.Info("AyaNova start - brief environment:\r\n" +
Util.BriefSupportInfo());
}
#endregion log environment
#region Initialization and integrity checks...
try
{
GZTW.AyaNova.BLL.AyaBizUtils.Initialize();
string s = AyaBizUtils.View();
log.Info("\r\n" + s);
log.Info(s.GetHashCode().ToString());
}
catch (Exception ex)
{
//splash.CloseForm();
string path;
path = System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
string errorMessage = "";
if (ex.InnerException == null)
{
//log the exception
log.Fatal("First initialization and connect attempt", ex);
if (ex is LiteDBTypeInvalidException)
errorMessage = "Error: AyaNova Lite can only be used with a standalone single user Firebird database";
else if (ex is AyNotSubscribedForThisVersionException)
{
//Give user further options to enter a new license or to quit
//after login
this.MainForm = new Form1();
((Form1)this.MainForm).LicenseRequired = true;
return;
}
else
errorMessage = "Unhandled exception:\r\n" + ex.Message + "\r\n" +
ex.GetType() +
"\r\n\r\n\r\nStack Trace:\r\n" +
ex.StackTrace;
}
else
{
//log the exception
log.Fatal("First initialization and connect attempt", ex.InnerException);
//Display a plain exception in case of a license violation
//without the stack trace
if (ex.InnerException.Message.IndexOf("LICENSE") != -1)
{
ExceptionDialog dl = new ExceptionDialog(ex.InnerException.Message, true);
dl.ShowDialog();
Application.Exit();
return;
}
//case 1466
if (ex.InnerException != null && ex.InnerException is FirebirdSql.Data.FirebirdClient.FbException)//] {"I/O error for file \"C:\\data\\AyaNova\\database\\AYANOVA.FDB\"\r\nError while trying to open file"} FirebirdSql.Data.FirebirdClient.FbException
{
if (ex.InnerException.Message.Contains("I/O"))
{
if (AyaBizUtils.AyaNovaConnectionSetting.SingleUserConnection)
{
errorMessage =
ex.InnerException.Message + "\r\n\r\n" +
"You are seeing this error for one of two possible reasons:\r\n\r\n" +
"1) AyaNova couldn't open the database file specified in the config.txt file. Check the setting.\r\n" +
"2) You are attempting to open the AyaNova database file more than once at the same time.\r\n" +
"This is a single user installation of AyaNova and can only be opened once at a time.\r\n" +
"If you need to open more than one copy of AyaNova simultaneously switch to a database server installation.";
}
else
{//Multi user so only one reason to see this
errorMessage =
ex.InnerException.Message + "\r\n\r\n" +
"AyaNova couldn't open the database file specified in the config.txt file. Check the setting.\r\n";
}
}
else
{//inner exception doesn't contain the string IO meaning it's a firebird error probably
//related to network firebird server problem
errorMessage =
"Unhandled Exception:\r\n" +
ex.Message + "\r\n" +
"Inner exception type: " +
ex.InnerException.GetType() +
"\r\nInner exception message: " + ex.InnerException.Message;
}
}
else//Inner exception is null or it's not a firebird exception
{
//We get here in the case of being unable to connect.
if (ex.InnerException != null)
{
errorMessage =
"Unhandled Exception:\r\n" +
ex.Message + "\r\n" +
"Inner exception type: " +
ex.InnerException.GetType() +
"\r\nInner exception message: " + ex.InnerException.Message;
}
else
{
errorMessage =
"Unhandled Exception:\r\n" +
ex.Message + "\r\nException type:" +
ex.GetType();
}
}
}
ExceptionDialog d = new ExceptionDialog(
"AyaNova was unable to start\r\n\r\n" +
"Depending on how early in startup the problem occurred,\r\n" +
"a detailed log of the problem with suggestions *may* have\r\n" +
"been saved to the file AyaLog.txt \r\n" +
"located at: " + path +
"\r\n\r\nError details:\r\n" + errorMessage, true);
d.TopMost = true;
d.BringToFront();
d.ShowDialog();
//splash.CloseForm();
// Splash2.Fadeout();
//rethrow it
throw (ex);
}//end catch block
//NOTE: SCHEMA CHECK NOW MOVED TO JUST AFTER LOGIN IS DONE BY USER
#endregion init and integrity check
// Create the main form, the splash screen will close automatically
this.MainForm = new Form1();
//this.MainForm.Visible = true;
//this.MainForm.Visible = false;
}
} //end of class
#endregion mainclass
}
}//end namespace