();
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)
{
//DBManager.FireBirdRecomputeStatistics();
#region Generate huge tracts o' data
//Random rand=new Random();
//Guid gTestSecurityGroupID = new Guid("{EA613C39-38F0-470E-9B76-ABB9B05C5F3A}");
//for (int x = 0; x < 999; x++)
//{
// User u = User.NewItem();
// u.EmployeeNumber = x.ToString();
// u.FirstName = "User";
// u.LastName = x.ToString();
// u.Initials = "xx";
// u.EmailAddress = x.ToString() + "@" + "test.com";
// u.UserType = UserTypes.Schedulable;
// u.MemberOfGroup = gTestSecurityGroupID;
// u.Login = x.ToString();
// u.Password = x.ToString();
// if (!u.IsSavable)
// System.Diagnostics.Debugger.Break();
// u.Save();
//}
//for (int x = 0; x < 20000; x++)
//{
// Client c = Client.NewItem();
// c.Name = "Client" + x.ToString("00000");
// c.Notes = "The quick brown fox jumped over the six lazy dogs";
// c.Phone1="555"+x.ToString("00000");
// c.Contact = "Client Contact";
// c.GoToAddress.City = "City";
// c.GoToAddress.Country = "Country";
// c.GoToAddress.Postal = rand.Next(90000, 99000).ToString();
// c.WebAddress = "http://www.client" + x.ToString("00000") + ".com";
// Address.Copy(c.GoToAddress, c.MailToAddress);
// c.AccountNumber = x.ToString();
// if (!c.IsSavable)
// System.Diagnostics.Debugger.Break();
// c.Save();
//}
//for (int x = 0; x < 20000; x++)
//{
// Vendor c = Vendor.NewItem();
// c.Name = "Test" + x.ToString("00000");
// c.Notes = "The quick brown fox jumped over the six lazy dogs";
// c.Phone1 = "555" + x.ToString("00000");
// c.Contact="Vendor Contact";
// c.GoToAddress.City = "City";
// c.GoToAddress.Country = "Country";
// c.GoToAddress.Postal = rand.Next(90000, 99000).ToString();
// c.WebAddress = "http://www.vendor" + x.ToString("00000") + ".com";
// Address.Copy(c.GoToAddress, c.MailToAddress);
// c.AccountNumber = x.ToString();
// if (!c.IsSavable)
// System.Diagnostics.Debugger.Break();
// c.Save();
//}
//VendorPickList vpl = VendorPickList.GetList();
//for (int x = 0; x < 20000; x++)
//{
// Part c = Part.NewItem();
// c.PartNumber = x.ToString();
// c.Cost = 5.00m;
// c.Retail = 15.00m;
// c.WholesalerID = vpl[rand.Next(vpl.Count)].ID;
// c.Name= "Part" + x.ToString("00000");
// c.Save();
//}
//Units
//manufacturers
//for (int x = 20001; x < 20050; x++)
//{
// Vendor c = Vendor.NewItem();
// c.VendorType = VendorTypes.Manufacturer;
// c.Name = "VendorMan" + x.ToString("00000");
// c.Notes = "The quick brown fox jumped over the six lazy dogs";
// c.Phone1 = "555" + x.ToString("00000");
// c.Contact = "VendorMan Contact";
// c.GoToAddress.City = "VendManCity";
// c.GoToAddress.Country = "VendManCountry";
// c.GoToAddress.Postal = rand.Next(90000, 99000).ToString();
// c.WebAddress = "http://www.vendor" + x.ToString("00000") + ".com";
// Address.Copy(c.GoToAddress, c.MailToAddress);
// c.AccountNumber = x.ToString();
// if (!c.IsSavable)
// System.Diagnostics.Debugger.Break();
// c.Save();
//}
//VendorPickList vendorMans = VendorPickList.GetList(VendorTypes.Manufacturer);
////Unitmodels
//for (int x = 0; x < 500; x++)
//{
// UnitModel c = UnitModel.NewItem();
// c.ModelNumber = x.ToString();
// c.VendorID = vendorMans[rand.Next(vendorMans.Count)].ID;
// c.LifeTimeWarranty = true;
// c.Name = "UnitModel" + x.ToString("00000");
// c.Save();
//}
//UnitModelPickList umpl= UnitModelPickList.GetList();
//ClientPickList cpl = ClientPickList.GetList();
//int nSerial=1;
//foreach (ClientPickList.ClientPickListInfo cp in cpl)
//{
// Unit u = Unit.NewItem();
// u.ClientID = cp.ID;
// u.UnitModelID = umpl[rand.Next(umpl.Count)].ID;
// u.Serial = nSerial.ToString();
// u.Description="Unit" + nSerial.ToString();
// nSerial++;
// u.Save();
//}
//Service Rates
// Rates rs = Rates.GetItems(false);
//for (int x = 0; x < 50; x++)
//{
// Rate r= rs.Add();
// r.AccountNumber = "svc" + x.ToString();
// r.Charge = 25.00m;
// r.Cost = 10.00m;
// r.Description = "Service Rate" + x.ToString();
// r.Name = "SVCRATE " + x.ToString();
// r.RateType = RateTypes.Service;
// rs.Save();
//}
//Travel Rates
//for (int x = 0; x < 50; x++)
//{
// Rate r = rs.Add();
// r.AccountNumber = "trv" + x.ToString();
// r.Charge = 25.00m;
// r.Cost = 10.00m;
// r.Description = "Travel Rate" + x.ToString();
// r.Name = "TRVRATE " + x.ToString();
// r.RateType = RateTypes.Travel;
// rs.Save();
//}
//UserPickList uplproj=UserPickList.GetList(false);
//DateTime dtStart;
//DateTime dtStop;
////Projects
//for (int x = 0; x < 500; x++)
//{
// dtStart = new DateTime(2000, 1, 1).AddDays(rand.Next(4380));//4380 days = 12 years
// Project c = Project.NewItem();
// c.AccountNumber = x.ToString();
// c.DateStarted = dtStart;
// c.Name = "Project" + x.ToString();
// c.ProjectOverseerID = uplproj[rand.Next(uplproj.Count)].ID;
// c.Save();
//}
//Workorders
// ClientPickList cpl = ClientPickList.GetList();
// UserPickList upl = UserPickList.GetList(false);
// WorkorderStatusPickList wspl = WorkorderStatusPickList.GetList();
// ProjectList projects = ProjectList.GetList("");
// WorkorderCategories wocats = WorkorderCategories.GetItems();
// PriorityPickList priors = PriorityPickList.GetList();
// WorkorderItemTypePickList woitypes = WorkorderItemTypePickList.GetList();
// RandomText text = new RandomText();
// RatePickList rl= RatePickList.GetListAllActiveRates();
// System.Collections.Generic.List serviceRates=new System.Collections.Generic.List();
// System.Collections.Generic.List travelRates=new System.Collections.Generic.List();
// PartPickList ppl=PartPickList.GetAllParts();
// foreach(RatePickList.RatePickListInfo i in rl)
// {
// if(i.RateType== RateTypes.Service)
// serviceRates.Add(i.ID);
// else
// travelRates.Add(i.ID);
// }
// TaxCodeList tcl = TaxCodeList.GetList();
// int nCount=1;
// for (int year = 2009; year < 2010; year++)
// for(int month=10;month < 13; month++)
// for (int day = 1; day < 29; day++)
// for(int hour=9;hour<18;hour++)
// {
// DateTime dtStart = new DateTime(year, month, day, hour, 0, 0);
// DateTime dtStop = dtStart.AddHours(1);
// Workorder w = Workorder.NewItem(WorkorderTypes.Service);
// w.ClientID = cpl[rand.Next(cpl.Count)].ID;
// w.WorkorderCategoryID = wocats[rand.Next(wocats.Count)].ID;
// w.WorkorderService.WorkorderStatusID = wspl[rand.Next(wspl.Count)].ID;
// w.ProjectID = projects[rand.Next(projects.Count)].LT_O_Project.Value;
// w.Summary = text.GetRandomSentence(5);
// w.WorkorderService.CloseByDate = dtStart.AddDays(1);
// w.WorkorderService.ServiceDate = dtStart;
// w.CustomerReferenceNumber = text.GetRandomSentence(1);
// w.InternalReferenceNumber = "Second run"+nCount.ToString();
// w.Onsite = true;
// WorkorderItem wi = w.WorkorderItems[0];
// wi.Summary = text.GetRandomText(1, 1, 2, 3, 8);
// wi.TechNotes = text.GetRandomText(1, 1, 1, 3, 8);
// wi.PriorityID = priors[rand.Next(priors.Count)].ID;
// wi.TypeID = woitypes[rand.Next(woitypes.Count)].ID;
// wi.WorkorderStatusID = wspl[rand.Next(wspl.Count)].ID;
// wi.WarrantyService = rand.Next(101) > 50 ? true : false;
// wi.RequestDate = dtStart;
// //Unit? 20percent chance
// if (rand.Next(101) > 80)
// {
// wi.UnitID = UnitPickList.GetListByClient(w.ClientID)[0].ID;
// }
// //sched users 1 or as many as 4
// int nMaxSchedUsers = rand.Next(1, 5);
// for (int nSchedUsers = 0; nSchedUsers < nMaxSchedUsers; nSchedUsers++)
// {
// WorkorderItemScheduledUser su = wi.ScheduledUsers.Add(wi);
// su.EstimatedQuantity = 1;
// su.UserID = upl[rand.Next(upl.Count)].ID;
// su.ServiceRateID = serviceRates[rand.Next(serviceRates.Count)];
// su.StartDate = dtStart;
// su.StopDate = dtStop;
// }
// //parts 0 to 5
// int nMaxParts = rand.Next(0, 6);
// for (int nParts = 0; nParts < nMaxParts; nParts++)
// {
// WorkorderItemPart p = wi.Parts.Add(wi);
// p.PartID = ppl[rand.Next(ppl.Count)].ID;
// p.Quantity = rand.Next(1, 11);
// p.TaxPartSaleID = tcl[0].ID;
// p.Used = true;
// }
// //Labor
// foreach (WorkorderItemScheduledUser scheduser in wi.ScheduledUsers)
// {
// w.CreateLaborFromScheduledUser(wi.ID, scheduser.ID);
// }
// foreach (WorkorderItemLabor labor in wi.Labors)
// {
// labor.ServiceDetails=text.GetRandomText(2, 1, 4, 5, 15);
// }
// //travel
// //travel 0 or as many as 4
// int nMaxTravel = rand.Next(0, 5);
// for (int nTravel = 0; nTravel < nMaxTravel; nTravel++)
// {
// WorkorderItemTravel su = wi.Travels.Add(wi);
// su.UserID = upl[rand.Next(upl.Count)].ID;
// su.TravelRateID = travelRates[rand.Next(travelRates.Count)];
// su.TravelStartDate = dtStart;
// su.TravelStopDate = dtStop;
// su.TravelDetails = text.GetRandomSentence(5);
// }
// //closed? 20percent chance
// if (rand.Next(101) > 80)
// {
// w.ServiceCompleted = true;
// w.Closed = true;
// }
//System.Diagnostics.Debug.Assert(w.IsSavable);
// w.Save();
// nCount++;
// }
////schedule markers
//RandomText text = new RandomText();
//UserListScheduleable schedUserList = UserListScheduleable.GetList();
//DateTime dt=new DateTime(2009,9,1);
//for (int x = 0; x < 1000; x++)
//{
// ScheduleMarker sm = ScheduleMarker.NewItem();
// sm.ARGB = rand.Next(0, 10000);
// sm.dtStartDate=dt.AddDays(rand.Next(120)).AddHours(rand.Next(8,18));
// sm.dtStopDate = sm.dtStartDate.AddHours(1);
// sm.Name = text.GetRandomSentence(5);
// sm.Notes = text.GetRandomText(1, 1, 5, 3, 8);
// sm.ScheduleMarkerSourceType = ScheduleMarkerSourceTypes.User;
// sm.SourceID = schedUserList[rand.Next(schedUserList.Count)].ID;
// sm.Save();
//}
#endregion generate huge tracts o' data
#region ayascript to update and close selected workorders
//System.Collections.Generic.List l= new System.Collections.Generic.List();
// l.Add(new Guid("c9d07183-89d6-4dc0-bacb-e46a6c7a1b9a"));
// l.Add(new Guid("d3eea5a5-6181-4484-afc6-20279aa9670d"));
// l.Add(new Guid("06afffc4-5d6c-4e0d-bc44-de996a69f69d"));
// l.Add(new Guid("7da89c49-c94e-4d57-94ef-d25507e5e512"));
// l.Add(new Guid("83e1ed3e-f831-445f-b3cd-5caac218d383"));
// //Reserve a place to store any errors during operation
// System.Text.StringBuilder sbErrors=new StringBuilder();
// foreach (Guid i in l)
// {
// //Fetch the workorder object from it's ID and do not place it in the most recently used object list (NoMRU)
// Workorder w = Workorder.GetItemNoMRU(i);
// //Already closed?
// if (w.Closed)
// continue;//It's already closed so move on to next one
// //If we're here it's not closed so let's close it..
// //SET WORKORDER STATUS
// //Note: There is no need to set the workorder status to the global settings automatical status on close
// //as that will be done automatically when you set it to closed=true below, however if for some reason you want to do it
// //anyway, it would be done here like this:
// w.WorkorderService.WorkorderStatusID = AyaBizUtils.GlobalSettings.WorkorderClosedStatus;
// //First set it to service completed as that is a prerequisite to close it
// w.ServiceCompleted = true;
// //Now close it. No need to set closed workorder status since it automatically will do it here
// w.Closed = true;
// //Make sure there are no broken rules and it can be saved
// if (w.IsSavable)
// w.Save();
// else
// {
// sbErrors.AppendLine("Workorder " + w.WorkorderService.ServiceNumber.ToString() + " is not saveable:");
// sbErrors.AppendLine(w.BrokenRulesText);
// sbErrors.AppendLine("****************************************");
// }
// }
// //display errors if necessary
// if (sbErrors.Length > 0)
// {
// MessageBox.Show(sbErrors.ToString());
// }
// MessageBox.Show("Done!");
#endregion
#region ayascript to updated selected workorders
////============== START OF SCRIPT =========================
//string WorkorderNumberMustBeLessThanThis = "3025";//<--Set your maximum work order number to set closed here
//WorkorderServiceList wsl = WorkorderServiceList.GetList(" \r\n" +
//" \r\n" +
//" \r\n" +
//" \r\n" +
//" \r\n" +
//" \r\n" +
//" \r\n" +
//" \r\n" +
//" \r\n" +
//" \r\n" +
//" \r\n" +
//" \r\n" +
//" \r\n" +
//" \r\n" +
//" \r\n" +
//" ");
////Reserve a place to store any errors during operation
//System.Text.StringBuilder sbErrors = new StringBuilder();
////WORKORDER STATUS TO SET ALL ITEMS AND WORKORDER
////"Closed" status Id
//Guid workorderStatusIdToSet = new Guid("9E818C52-074D-441E-AB12-825BF8C126DD");
//foreach (WorkorderServiceList.WorkorderServiceListInfo i in wsl)
//{
// //placeholder to keep track of current workorder in case an error ensues
// string currentWorkorder = string.Empty;
// try
// {
// //Fetch the workorder object from it's ID and do not place it in the most recently used object list (NoMRU)
// Workorder w = Workorder.GetItemNoMRU(i.LT_O_Workorder.Value);
// //get the workorder number in case we need to report an error with it
// currentWorkorder = w.WorkorderService.ServiceNumber.ToString();
// //Already closed or service completed?
// if (w.Closed || w.ServiceCompleted)
// {
// //Scan the workorder and all items to see if it's already set correctly...
// bool alreadySetCorrectly = true;
// //check the workorder header status
// if (w.WorkorderService.WorkorderStatusID == workorderStatusIdToSet)
// {
// //header matched so check all workorder item's status
// foreach (WorkorderItem wi in w.WorkorderItems)
// {
// if (wi.WorkorderStatusID != workorderStatusIdToSet)
// {
// //Status is not set correctly so no need to continue checking
// alreadySetCorrectly = false;
// break;
// }
// }
// }
// else
// alreadySetCorrectly = false;
// //Respond to the results of the workorder scan..
// if (alreadySetCorrectly)
// continue; //We got through the entire workorder and it's all correct so we can skip this one
// else
// {
// //something doesn't match so reopen the workorder and allow it to be set below
// w.Closed = false;
// w.ServiceCompleted = false;
// }
// }
// //If we're here it needs status set and closed...
// //SET WORKORDER AND ITEMS STATUS
// w.WorkorderService.WorkorderStatusID = workorderStatusIdToSet;
// foreach (WorkorderItem wi in w.WorkorderItems)
// wi.WorkorderStatusID = workorderStatusIdToSet;
// //Set it to service completed as that is a prerequisite to close it
// w.ServiceCompleted = true;
// //Now close it and save it
// w.Closed = true;
// w.Save();
// }
// catch (Exception ex)
// {
// sbErrors.AppendLine("Error processing workorder " + currentWorkorder);
// sbErrors.AppendLine(ex.Message);
// while (ex.InnerException != null)
// {
// ex = ex.InnerException;
// if (!string.IsNullOrWhiteSpace(ex.InnerException.Message))
// sbErrors.AppendLine(ex.Message);
// }
// sbErrors.AppendLine("****************************************");
// }
//}
////display errors if necessary
//if (sbErrors.Length > 0)
//{
// MessageBox.Show(sbErrors.ToString());
//}
//MessageBox.Show("Done!");
////=============END OF SCRIPT ===============
#endregion
User u = User.GetItem(new Guid("619AAD67-B95E-4674-844B-5057EBE8AF05"));
string srch = "" +
"" +
"";
var v = WorkorderQuoteScheduledUserList.GetList(srch);
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
StringBuilder sb = new StringBuilder();
foreach (WorkorderQuoteScheduledUserList.WorkorderQuoteScheduledUserListInfo i in v)
{
Workorder w = Workorder.GetItemNoMRU(i.LT_Workorder_Label_ID);
w.WorkorderItems[i.LT_WorkorderItem_Label_ID].ScheduledUsers[i.LT_WorkorderItemScheduledUser_Label_ID].UserID = Guid.Empty;
w.Save();
}
}
if (keyData == Keys.F11)
{
// ____ ___ ___ ____ __ _ _ __
//(_ _)( _)/ __)(_ _)( )( \( )/ _)
// )( ) _)\__ \ )( )( ) (( (/\
// (__) (___)(___/ (__) (__)(_)\_)\__/
//ctrl-alt-g for GRID FILTER CRITERIA
#region gen workorders COMMENTED OUT
//==============================================================================
//Workorders
//Random rand=new Random();
//ClientPickList cpl = ClientPickList.GetList();
//UserPickList upl = UserPickList.GetList(false);
//WorkorderStatusPickList wspl = WorkorderStatusPickList.GetList();
//ProjectList projects = ProjectList.GetList("");
//WorkorderCategories wocats = WorkorderCategories.GetItems();
//PriorityPickList priors = PriorityPickList.GetList();
//WorkorderItemTypePickList woitypes = WorkorderItemTypePickList.GetList();
//RandomText text = new RandomText();
//RatePickList rl = RatePickList.GetListAllActiveRates();
//System.Collections.Generic.List serviceRates = new System.Collections.Generic.List();
//System.Collections.Generic.List travelRates = new System.Collections.Generic.List();
//PartPickList ppl = PartPickList.GetAllParts();
//foreach(RatePickList.RatePickListInfo i in rl)
//{
// if(i.RateType == RateTypes.Service)
// serviceRates.Add(i.ID);
// else
// travelRates.Add(i.ID);
//}
//TaxCodeList tcl = TaxCodeList.GetList();
//int nCount = 1;
////for(int year = 2012; year < 2013; year++)
//// for(int month = 1; month < 13; month++)
//// for(int day = 1; day < 29; day++)
//// for(int hour = 9; hour < 18; hour++)
// for(int n=0;n<10001;n++)
// {
// int year = 2012;
// int month = rand.Next(1, 13);
// int day = rand.Next(1, 29);
// int hour = rand.Next(9, 18);
// DateTime dtStart = new DateTime(year, month, day, hour, 0, 0);
// DateTime dtStop = dtStart.AddHours(1);
// Workorder w = Workorder.NewItem(WorkorderTypes.Service);
// w.ClientID = cpl[rand.Next(cpl.Count)].ID;
// w.WorkorderCategoryID = wocats[rand.Next(wocats.Count)].ID;
// w.WorkorderService.WorkorderStatusID = wspl[rand.Next(wspl.Count)].ID;
// w.ProjectID = projects[rand.Next(projects.Count)].LT_O_Project.Value;
// w.Summary = text.GetRandomSentence(5);
// w.WorkorderService.CloseByDate = dtStart.AddDays(1);
// w.WorkorderService.ServiceDate = dtStart;
// w.CustomerReferenceNumber = text.GetRandomSentence(1);
// w.InternalReferenceNumber = "Generated data " + nCount.ToString();
// w.Onsite = true;
// WorkorderItem wi = w.WorkorderItems[0];
// wi.Summary = text.GetRandomText(1, 1, 2, 3, 8);
// wi.TechNotes = text.GetRandomText(1, 1, 1, 3, 8);
// wi.PriorityID = priors[rand.Next(priors.Count)].ID;
// wi.TypeID = woitypes[rand.Next(woitypes.Count)].ID;
// wi.WorkorderStatusID = wspl[rand.Next(wspl.Count)].ID;
// wi.WarrantyService = rand.Next(101) > 50 ? true : false;
// wi.RequestDate = dtStart;
// //Unit? 20percent chance
// //If the client has any units
// {
// UnitPickList clientUnitList = UnitPickList.GetListByClient(w.ClientID);
// if(clientUnitList.Count > 0 && rand.Next(101) > 80)
// {
// wi.UnitID = clientUnitList[0].ID;
// }
// }
// //sched users 1 or as many as 4
// int nMaxSchedUsers = rand.Next(1, 5);
// for(int nSchedUsers = 0; nSchedUsers < nMaxSchedUsers; nSchedUsers++)
// {
// WorkorderItemScheduledUser su = wi.ScheduledUsers.Add(wi);
// su.EstimatedQuantity = 1;
// UserPickList.UserPickListInfo upi = upl[rand.Next(upl.Count)];
// //ensure it's a scheduleable user
// while(upi.Type != UserTypes.Schedulable)
// upi = upl[rand.Next(upl.Count)];
// su.UserID = upi.ID;
// su.ServiceRateID = serviceRates[rand.Next(serviceRates.Count)];
// su.StartDate = dtStart;
// su.StopDate = dtStop;
// }
// //parts 0 to 5
// //int nMaxParts = rand.Next(0, 6);
// //for(int nParts = 0; nParts < nMaxParts; nParts++)
// //{
// // WorkorderItemPart p = wi.Parts.Add(wi);
// // //get non serialized parts only for this action
// // p.PartID = ppl[rand.Next(ppl.Count)].ID;
// // p.Quantity = rand.Next(1, 11);
// // p.TaxPartSaleID = tcl[0].ID;
// // p.Used = true;
// //}
// //Labor
// foreach(WorkorderItemScheduledUser scheduser in wi.ScheduledUsers)
// {
// w.CreateLaborFromScheduledUser(wi.ID, scheduser.ID);
// }
// foreach(WorkorderItemLabor labor in wi.Labors)
// {
// labor.ServiceDetails = text.GetRandomText(2, 1, 4, 5, 15);
// }
// //travel
// //travel 0 or as many as 4
// int nMaxTravel = rand.Next(0, 5);
// for(int nTravel = 0; nTravel < nMaxTravel; nTravel++)
// {
// WorkorderItemTravel su = wi.Travels.Add(wi);
// su.UserID = upl[rand.Next(upl.Count)].ID;
// su.TravelRateID = travelRates[rand.Next(travelRates.Count)];
// su.TravelStartDate = dtStart;
// su.TravelStopDate = dtStop;
// su.TravelDetails = text.GetRandomSentence(5);
// }
// //closed? 80percent chance
// if(rand.Next(101) > 20)
// {
// w.ServiceCompleted = true;
// w.Closed = true;
// }
// if(!w.IsSavable)
// {
// CopyableMessageBox cm = new CopyableMessageBox(w.WhatsBroken);
// System.Diagnostics.Debugger.Break();
// }
// w.Save();
// nCount++;
// }
//===============================================================================
#endregion
#region Import utility COMMENTED OUT
////==============================================================================
////Lists to contain item Id's to compare to and ensure no duplicates imported
//System.Collections.Generic.Dictionary allUnits = new System.Collections.Generic.Dictionary();
//System.Collections.Generic.Dictionary allUnitModels = new System.Collections.Generic.Dictionary();
//System.Collections.Generic.Dictionary allClients = new System.Collections.Generic.Dictionary();
//{
// //Get lists of items that are already pre-entered in AyaNova and need to be matched by name
// ClientPickList clientList = ClientPickList.GetList();
// UnitPickList unitList = UnitPickList.GetListOfAll();
// UnitModelPickList unitModelList = UnitModelPickList.GetList();
// //Populate the lists from items already in the AyaNova database
// foreach(ClientPickList.ClientPickListInfo i in clientList)
// allClients.Add(i.Name.Trim(), i.ID);
// foreach(UnitModelPickList.UnitModelPickListInfo i in unitModelList)
// allUnitModels.Add(i.Name.Trim(), i.ID);
// foreach(UnitPickList.UnitPickListInfo i in unitList)
// allUnits.Add(i.Serial.Trim(), i.ID);
// //free up the temporary list objects fetched
// clientList = null;
// unitList = null;
// unitModelList = null;
//}
////Read the data from the csv file "units.csv" located in c:\temp, change below to your file name and path as required
//string[] rawLines = System.IO.File.ReadAllLines(@"c:\temp\units.csv");
////warning
//if(MessageBox.Show("Warning: There is no Undo, your AyaNova database will be changed permanently!\r\nBe *certain* you have a backup of your database before proceeding.\r\n\r\nAre you sure you want to continue?", "Import", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
// return false;
////hourglass cursor
//Cursor.Current = Cursors.WaitCursor;
////Iterate through the raw data, break it into fields and try to match with existing data and generate pm's accordingly
//long recordsImported = 0;
//bool firstRow = true;
//foreach(string rawItem in rawLines)
//{
// //skip first row that has column names not actual data
// if(firstRow)
// {
// firstRow = false;
// continue;
// }
// //split current row into fields
// string[] row = rawItem.Split(',');
// if(row.GetLength(0) != 10)
// throw new System.ApplicationException("Import failed (restore DB, fix problem and try again): Current import row doesn't have expected 10 fields. Row data:\r\n" + rawItem);
// //##### Field 0 Unit Serial number #####
// string sn = row[0].Trim();
// if(string.IsNullOrWhiteSpace(sn))
// throw new System.ApplicationException("Import failed (restore DB, fix problem and try again): Current import row doesn't have a serial number. Row data:\r\n" + rawItem);
// //Has it already been imported?
// if(allUnits.ContainsKey(sn))
// continue;//skip to the next record
// //Not there already so import unit but first get a client id...
// //##### Field 1 Client #####
// string ClientName = row[1].Trim();
// if(string.IsNullOrWhiteSpace(ClientName))
// throw new System.ApplicationException("Import failed (restore DB, fix problem and try again): Current import row doesn't have a client. Row data:\r\n" + rawItem);
// Guid ClientId = Guid.Empty;
// if(allClients.ContainsKey(ClientName))
// ClientId = allClients[ClientName];
// if(ClientId == Guid.Empty)
// {
// //Create a new client
// Client c = Client.NewItem();
// c.Name = ClientName;
// ClientId = c.ID;
// if(!c.IsSavable)
// throw new System.ApplicationException("Import failed (restore DB, fix problem and try again): Current import row Client record can not be saved. Row data:\r\n" + rawItem);
// c.Save();
// //add to list so it won't try to import client again next time
// allClients.Add(ClientName, ClientId);
// }
// //##### Field 2 UnitModel #####
// Guid UnitModelId = Guid.Empty;
// string UnitModelName = row[2].Trim();
// //If unit model name is not empty then deal with it (Unitmodel is optional for a unit)
// if(!string.IsNullOrWhiteSpace(UnitModelName))
// {
// //see if we already have it
// if(allUnitModels.ContainsKey(UnitModelName))
// UnitModelId = allUnitModels[UnitModelName];
// if(UnitModelId == Guid.Empty)
// {
// //Create a new UnitModel
// UnitModel c = UnitModel.NewItem();
// c.Name = UnitModelName;
// UnitModelId = c.ID;
// if(!c.IsSavable)
// throw new System.ApplicationException("Import failed (restore DB, fix problem and try again): Current import row UnitModel record can not be saved. Row data:\r\n" + rawItem);
// c.Save();
// allUnitModels.Add(UnitModelName, UnitModelId);
// }
// }
// //##### Field 3 Text1 #####
// string text1 = row[3].Trim();
// //##### Field 4 PurchaseDate #####
// string purchaseDate = row[4].Trim();
// DateTime dtPurchaseDate = DateTime.MinValue;//MinValue means no date
// if(!string.IsNullOrWhiteSpace(purchaseDate))
// {
// DateTime.TryParse(purchaseDate, out dtPurchaseDate);
// }
// //##### Field 5 Description #####
// string description = row[5].Trim();
// //##### Field 6 Receipt number #####
// string receipt = row[6].Trim();
// //##### Field 7 Text2 #####
// string text2 = row[7].Trim();
// //##### Field 8 Text3 #####
// string text3 = row[8].Trim();
// //##### Field 9 Text4 #####
// string text4 = row[9].Trim();
// //Import the unit now that we have all the info required
// Unit u = Unit.NewItem();
// u.ClientID = ClientId;
// u.UnitModelID = UnitModelId;
// u.Serial = sn;
// u.Text1 = text1;
// if(dtPurchaseDate != DateTime.MinValue)
// u.PurchasedDate = dtPurchaseDate;
// u.Text2 = text2;
// u.Description = description;
// u.Receipt = receipt;
// u.Text2 = text2;
// u.Text3 = text3;
// u.Text4 = text4;
// Guid unitId = u.ID;
// u.Save();
// allUnits.Add(sn, unitId);
// recordsImported++;
//}
//Cursor.Current = Cursors.Default;
//MessageBox.Show("Finished importing " + recordsImported.ToString() + " records");
////Done.
////===============================================================================
#endregion import util
#region Close selected workorders by criteria COMMENTED OUT
////**** CLOSE SELECTED WORKORDERS THAT MATCH THE FOLLOWING ******
////Change these values as required
//string WorkorderStatusName = "Service is Completed";
//string ClientName = "ABC Accounting";
////**************************************************************
////No need to change anything below here if different status or client in future
////Reserve a place to store any errors during operation
//System.Text.StringBuilder sbErrors = new StringBuilder();
////GET THE STATUS ID
////placeholder for status once it's found
//Guid workorderStatusId = Guid.Empty;
//WorkorderStatusPickList wospl = WorkorderStatusPickList.GetList();
//try
//{
// //try to fetch the status by name and get the Id from it
// workorderStatusId = wospl[WorkorderStatusName].ID;
//}
//catch
//{
// sbErrors.AppendLine("Status of \"" + WorkorderStatusName + "\" was not found in the database, can't proceed!");
//}
////GET THE CLIENT ID
////placeholder for client Id once it's found
//Guid clientId = Guid.Empty;
//ClientPickList cpl = ClientPickList.GetList();
//foreach (ClientPickList.ClientPickListInfo i in cpl)
//{
// if (i.Name.Equals(ClientName))
// {
// clientId = i.ID;
// break;
// }
//}
//if (clientId == Guid.Empty)
// sbErrors.AppendLine("Client called \"" + ClientName + "\" was not found in the database, can't proceed!");
////counter of successfully closed and saved workorders
//long workordersClosed = 0;
////do we have a status and client Id?
//if (workorderStatusId != Guid.Empty && clientId != Guid.Empty)
//{
// //Yup, so continue...
// //GET APPLICABLE WORKORDERS VIA WORKORDER SERVICE LIST AND CRITERIA
// WorkorderServiceList wsl = WorkorderServiceList.GetList(" \r\n" +
// " \r\n" +
// " \r\n" +
// " \r\n" +
// " \r\n" +
// " \r\n" +
// " \r\n" +
// " \r\n" +
// " \r\n" + //belongs to client specified
// " \r\n" +
// " \r\n" +
// " \r\n" + //has status specified
// " \r\n" +
// " \r\n" +
// " \r\n" + //is service completed
// " \r\n" +
// " \r\n" +
// " \r\n" + //is not closed
// " \r\n" +
// " " );
// //Iterate the resulting list and close accordingly
// foreach (WorkorderServiceList.WorkorderServiceListInfo i in wsl)
// {
// //placeholder to keep track of current workorder number
// //in case an error ensues and we have to report it later
// string currentWorkorderNumber = string.Empty;
// try
// {
// //Fetch the workorder object from it's ID and do not place it in the most recently used object list (NoMRU)
// Workorder w = Workorder.GetItemNoMRU(i.LT_O_Workorder.Value);
// //get the workorder number in case we need to report an error with it
// currentWorkorderNumber = w.WorkorderService.ServiceNumber.ToString();
// //try to close it
// if (w.IsCloseAllowed)
// {
// w.Closed = true;
// if (w.IsSavable)
// {
// w.Save();
// workordersClosed++;
// }
// else
// sbErrors.AppendLine("Error processing workorder " + currentWorkorderNumber + " not saveable for some reason.");
// }
// else
// {
// sbErrors.AppendLine("Error processing workorder " + currentWorkorderNumber + " not closeable for some reason.");
// }
// }
// catch (Exception ex)
// {
// //Save failed for some reason so report it...
// sbErrors.AppendLine("Error processing workorder " + currentWorkorderNumber);
// sbErrors.AppendLine(ex.Message);
// while (ex.InnerException != null)
// {
// ex = ex.InnerException;
// if (!string.IsNullOrWhiteSpace(ex.InnerException.Message))
// sbErrors.AppendLine(ex.Message);
// }
// sbErrors.AppendLine("****************************************");
// }
// }
//}
////display errors if necessary
//if (sbErrors.Length > 0)
//{
// MessageBox.Show(sbErrors.ToString());
//}
//MessageBox.Show("Finished, " + workordersClosed.ToString() + " workorders were closed and saved");
#endregion
#region Generator on demand COMMENTED OUT
//try
//{
// AyaBizUtils.TG = true;
// Cursor.Current = Cursors.WaitCursor;
// Status("Processing PM workorders...");
// GenProcessPM.GeneratePMWorkorders();
//}
//catch
//{
// throw;
//}
//finally
//{
// AyaBizUtils.TG = false;
//}
#endregion generator on demand
#region Generate serialized inventory for a single part COMMENTED OUT
//Random rand = new Random();
//int snCount = 0;
////get all active warehouses without exception
//PartWarehousePickList whsList = PartWarehousePickList.GetActiveOnlyListWithExceptions(new System.Collections.Generic.List());
//for (int x = 0; x < 500; x++)
//{
// PartInventoryAdjustment p = PartInventoryAdjustment.NewItem();
// p.DateAdjusted = DateTime.Now;
// p.ReasonForAdjustment = "coding test";
// PartInventoryAdjustmentItem i = p.Items.Add(p);
// //HUB
// i.PartID = new Guid("A54B1C5D-8EF7-43AB-A35C-C9FE2A875A46");
// i.PartWarehouseID = whsList[rand.Next(whsList.Count)].ID;
// i.QuantityAdjustment = 1;
// snCount++;
// PartSerial ps = i.SerialNumbers[0];
// ps.PartID = i.PartID;
// ps.PartWarehouseID = i.PartWarehouseID;
// ps.SerialNumber = "TESTSN_" + snCount.ToString();
// if (p.IsSavable)
// p.Save();
// else
// {
// MessageBox.Show("Error with item " + snCount.ToString() + "\r\n" + p.BrokenRulesText);
// System.Diagnostics.Debugger.Break();
// break;
// }
//}
#endregion generate serialized inventory
#region delete a bunch of clients
//StringBuilder sbRet = new StringBuilder();
//ClientPickList cpl = ClientPickList.GetList();
//foreach (ClientPickList.ClientPickListInfo theClient in cpl)
//{
// try
// {
// sbRet.AppendLine("Attempting to delete client " + theClient.Name);
// sbRet.AppendLine("WORKORDERS");
// sbRet.AppendLine(Client.DeleteAllClientWorkorders(theClient.ID));
// sbRet.AppendLine("UNITS");
// Client.DeleteAllClientUnits(theClient.ID);
// sbRet.AppendLine("CLIENT RECORD");
// Client.DeleteItem(theClient.ID);
// }
// catch { }
//}
//CopyableMessageBox d = new CopyableMessageBox(sbRet.ToString());
//d.ShowDialog();
#endregion
//============== START OF SCRIPT =========================
//a2a2632b-8945-4d93-8513-2ee65c91adc3
/*
*/
//Workorder.GetDescendant(
//try
//{
// //*********** This is the only block you really need *******
// PartList pl = PartList.GetListForSingleItem(new Guid("a2a2632b-8945-4d93-8513-2ee65c91adc3"));//my test part id
// PartList.PartListInfo pli = pl[0];
// string sTheManufaturerName = pli.LT_Part_Label_ManufacturerID.Display;
// string sTheManufacturerNumber = pli.LT_Part_Label_ManufacturerNumber;
// string sTheWholeSalerName = pli.LT_Part_Label_WholesalerID.Display;
// string sTheWholeSalerNumber = pli.LT_Part_Label_WholesalerNumber;
// //*************** But the outer try catch will give you the actual error if you need it ****
//}
//catch (Exception ex) {
// Exception ActualException = null;
// while (ActualException.InnerException != null)
// ActualException = ActualException.InnerException;
// string ActualErrorMessage = ActualException.Message;
//}
//var vvvv = "blah";
////etc
//=============END OF SCRIPT ===============
//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