case 3892

This commit is contained in:
2021-06-22 19:13:05 +00:00
parent bc0e4dacc3
commit 86eea2e5fc

View File

@@ -479,7 +479,7 @@ namespace AyaNova
//back again to facilitate saving last viewed date range
MyDateNavigator mDateNav = null;
public MyDateNavigator DateNav
{
{
set
{
if (mDateNav == null)
@@ -531,7 +531,7 @@ namespace AyaNova
ToolBarManager.Tools["LT:UI.Toolbar.Schedule.AddToActiveWorkorderItem"].SharedProps.Visible = false;
ss.Appointments.CustomFieldMappings.Add(new AppointmentCustomFieldMapping("AyaInfo", ""));
Util.LocalizeHelperInsertMenu(ToolBarManager, this); //case 1810
Util.Localize(this);
@@ -554,26 +554,30 @@ namespace AyaNova
//case 3172
ToolBarManager.Tools["LT:UI.Toolbar.Schedule.NewScheduleMarker"].SharedProps.Visible = (AyaBizUtils.Right("Object.ScheduleMarker") > (int)SecurityLevelTypes.ReadOnly);
ToolBarManager.Tools["LT:UI.Toolbar.Schedule.NewWorkorder"].SharedProps.Visible =
(AyaBizUtils.Right("Object.WorkorderService") > (int)SecurityLevelTypes.ReadOnly &&
(AyaBizUtils.Right("Object.WorkorderService") > (int)SecurityLevelTypes.ReadOnly &&
AyaBizUtils.Right("Object.WorkorderItemScheduledUser") > (int)SecurityLevelTypes.ReadOnly);
//case 1219 - need user for more stuff below
User currentUser=User.GetItem(User.CurrentThreadUserID);
User currentUser = User.GetItem(User.CurrentThreadUserID);
mSelectedUserGroupID = currentUser.LastSchedGroupID;
FillScheduleableUserGroupList();
bIgnoreSchedUserGroupChange = false;
sc.Start = DBUtil.CurrentWorkingDateTime;
//case 714
sc.DayView.TopRowTime = TimeSpan.FromHours(8);
//NewDateRange();
//case 3892 restrict scrollable day view day to that day only as it's not working outside of the current day
sc.DayView.VisibleTime.Start = TimeSpan.FromHours(0);
sc.DayView.VisibleTime.End = TimeSpan.FromHours(24);
//**************************************
@@ -587,24 +591,24 @@ namespace AyaNova
currentUser.LastSchedStopDate.Date = DateTime.Today;
}
TimeIntervalCollection coll = new TimeIntervalCollection();
coll.Add(new TimeInterval(currentUser.LastSchedStartDate.Date, currentUser.LastSchedStopDate.Date));
sc.ActiveView.SetVisibleIntervals(coll);
if (AyaBizUtils.OverrideTimeZone)
{
TimeRuler trOffset = sc.Views.DayView.TimeRulers[0];
trOffset.ShowCurrentTime = false;
}
//**************************************
//case 1219 - make initial start window same as users saved
//test test
//MessageBox.Show("MaxWindow at form load is:" + nMaxWindow.ToString());
//case 1548
TimeSpan ts = currentUser.LastSchedStopDate.Date - currentUser.LastSchedStartDate.Date;
if (ts.TotalDays < nMaxWindow)
@@ -624,25 +628,25 @@ namespace AyaNova
StateButtonTool sbt = (StateButtonTool)ToolBarManager.Tools["LT:UI.Toolbar.Schedule.ShowClosed"];
sbt.Checked = !currentUser.ScheduleLastViewOpenOnly;
//case 701
//case 701
#if (DEBUG)
//testing interval (5 minutes)
//testing interval (5 minutes)
this.SchedRefreshTimer.Interval = 300000;
#else
//5 minutes
SchedRefreshTimer.Interval=300000;
#endif
SchedRefreshTimer.Enabled = true;
SchedRefreshTimer.Start();
SchedRefreshTimer.Enabled = true;
SchedRefreshTimer.Start();
DoNotAllowFetchAndBind = false;
BindData(true);
DoNotAllowFetchAndBind = false;
BindData(true);
}
private void ScheduleForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
@@ -657,11 +661,11 @@ namespace AyaNova
//case 1219
u.LastSchedView = (int)sc.ActiveViewType;
u.LastSchedStartDate = new CSLA.SmartDate(sc.ActiveView.GetVisibleIntervals().Start);
u.LastSchedStopDate = new CSLA.SmartDate(sc.ActiveView.GetVisibleIntervals().End);
//case 1390
int nstartdays=(u.LastSchedStartDate.Date - DateTime.Today).Days;
int nstartdays = (u.LastSchedStartDate.Date - DateTime.Today).Days;
int nstopdays = (u.LastSchedStopDate.Date - DateTime.Today).Days;
if (nstartdays == 0 && nstopdays == 1)
{
@@ -672,10 +676,10 @@ namespace AyaNova
//case 1553
StateButtonTool sbt = (StateButtonTool)ToolBarManager.Tools["LT:UI.Toolbar.Schedule.ShowClosed"];
if (!sbt.Checked)
u.ScheduleLastViewOpenOnly=true;
u.ScheduleLastViewOpenOnly = true;
else
u.ScheduleLastViewOpenOnly=false;
u.ScheduleLastViewOpenOnly = false;
u.Save();
Util.SaveFormCustomization("ScheduleFormEx", this, ToolBarManager, true);
@@ -718,15 +722,15 @@ namespace AyaNova
DoNotAllowFetchAndBind = false;
return;
}
LastFetchEndWindow = NextFetchEndWindow;
LastFetchStartWindow = NextFetchStartWindow;
//Add a day on either side to ensure date range is inclusive to the very start and end date of the range
NextFetchStartWindow = NextFetchStartWindow.AddDays(-10);
NextFetchEndWindow = NextFetchEndWindow.AddDays(10);
Cursor.Current = Cursors.WaitCursor;
Cursor.Current = Cursors.WaitCursor;
//this is required otherwise the date navigator sometimes doesn't bold the dates properly
mDateNav.BeginInit();
ss.BeginUpdate();
@@ -741,9 +745,9 @@ namespace AyaNova
Resource r = new Resource(Guid.Empty.ToString(), Util.LocaleText.GetLocalizedText("Dashboard.Label.NotAssigned"));//case 1821
//Lite version has no unscheduled user
if(!AyaBizUtils.Lite)
if (!AyaBizUtils.Lite)
ss.Resources.Add(r);
foreach (UserListScheduleable.UserListScheduleableInfo ui in uls)
@@ -926,15 +930,15 @@ namespace AyaNova
#endregion
ss.EndUpdate();
mDateNav.EndInit();
DoNotAllowFetchAndBind = false;
Cursor.Current = Cursors.Default;
}
/// <summary>
@@ -1016,7 +1020,7 @@ namespace AyaNova
case "LT:UI.Toolbar.Print": // ButtonTool
{
////case 1177
if (this.sc.ActivePrintStyle is DailyPrintStyle)
{
@@ -1039,8 +1043,8 @@ namespace AyaNova
pStyle.ResourceOptions.UseActiveViewGroupType = true;
pStyle.ResourceOptions.ResourcesKind = ResourcesKind.Visible;
pStyle.PrintAllAppointments = false;
}
@@ -1076,8 +1080,8 @@ namespace AyaNova
#endregion old stuff
BindData(true);
}
break;
@@ -1141,7 +1145,7 @@ namespace AyaNova
}
private void HideDateRangeControlsInPreviewDialog(Control ctl)
private void HideDateRangeControlsInPreviewDialog(Control ctl)
{
switch (ctl.Name)
{
@@ -1153,21 +1157,21 @@ namespace AyaNova
ctl.Visible = false;
return;
}
}
foreach(Control c in ctl.Controls)
HideDateRangeControlsInPreviewDialog(c);
foreach (Control c in ctl.Controls)
HideDateRangeControlsInPreviewDialog(c);
}
private string GetAllControls(Control ctl)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
foreach (Control c in ctl.Controls)
{
sb.Append(c.ToString());
sb.Append(" - ");
sb.Append(" - ");
sb.Append(c.Name);
if (c.Controls.Count > 0)
@@ -1201,6 +1205,9 @@ namespace AyaNova
#region Events
#region Active view and date navigation events
/// <summary>
/// Event fired when active view is about to change
/// </summary>
@@ -1210,6 +1217,7 @@ namespace AyaNova
{
if (ignoreActiveViewChanging)
return;
ShowView(e.NewView.Type);
e.Cancel = true;
}
@@ -1221,6 +1229,8 @@ namespace AyaNova
/// <param name="newView"></param>
private void ShowView(SchedulerViewType newView)
{
StateButtonTool sbt = (StateButtonTool)ToolBarManager.Tools["LT:UI.Toolbar.Schedule.TimeLineView"];
bool useTimeLineView = sbt.Checked;
ignoreActiveViewChanging = true;
@@ -1230,7 +1240,10 @@ namespace AyaNova
if (useTimeLineView)
newView = SchedulerViewType.Timeline;
else//case 714
{
sc.DayView.TopRowTime = TimeSpan.FromHours(8);
}
}
sc.ActiveViewType = newView;
@@ -1240,7 +1253,7 @@ namespace AyaNova
}
#endregion active view and date navigation
@@ -1309,7 +1322,7 @@ namespace AyaNova
ToolBarManager.Tools["LT:UI.Toolbar.Schedule.AddToActiveWorkorderItem"].SharedProps.ToolTipText =
Util.LocaleText.GetLocalizedText("UI.Toolbar.Schedule.AddToActiveWorkorderItem") + " (" + i.ServiceNumber + ")";
}
ToolBarManager.Tools["LT:UI.Toolbar.Schedule.PrintWorkorders"].SharedProps.Visible = true;
ToolBarManager.Tools["LT:UI.Toolbar.Schedule.PrintWorkorders"].SharedProps.Visible = true;
}
}
@@ -1448,19 +1461,19 @@ namespace AyaNova
WorkorderItem wi = w.WorkorderItems[i.WorkorderItemID.ToString()];
WorkorderItemScheduledUser su = wi.ScheduledUsers[i.SourceObjectID.ToString()];
su.StartDate = apt.Start;
su.StopDate = apt.End;
//case 1051
TimeSpan ts = apt.End.Subtract(apt.Start);
su.EstimatedQuantity = decimal.Round(
(decimal)ts.TotalHours,
2, MidpointRounding.AwayFromZero);
su.UserID = gNewResourceID;
su.UserID = gNewResourceID;
if (w.IsDirty)
{
@@ -1559,13 +1572,13 @@ namespace AyaNova
}
WorkorderItem wi = w.WorkorderItems[iLastSelected.WorkorderItemID.ToString()];
WorkorderItemScheduledUser wisu = wi.ScheduledUsers.Add(wi);
// Guid gUserID;
// Guid gUserID;
@@ -1577,7 +1590,7 @@ namespace AyaNova
wisu.StartDate = sc.SelectedInterval.Start;
wisu.StopDate = sc.SelectedInterval.End;
wisu.UserID = new Guid(sc.SelectedResource.Id.ToString());
//case 1161
TimeSpan ts = sc.SelectedInterval.End.Subtract(sc.SelectedInterval.Start);
wisu.EstimatedQuantity = decimal.Round(
@@ -1624,7 +1637,7 @@ namespace AyaNova
private void EditAppointment(Appointment apt)
{
if (apt.CustomFields==null || apt.CustomFields["AyaInfo"] == null) return;
if (apt.CustomFields == null || apt.CustomFields["AyaInfo"] == null) return;
AppointmentList.AppointmentListInfo i = (AppointmentList.AppointmentListInfo)apt.CustomFields["AyaInfo"];
switch (i.SourceObjectType)
@@ -1714,9 +1727,9 @@ namespace AyaNova
w.ClientID = c.SelectedClientID;
WorkorderItemScheduledUser wisu = w.WorkorderItems[0].ScheduledUsers.Add(w.WorkorderItems[0]);
wisu.StartDate = sc.SelectedInterval.Start;
wisu.StopDate = sc.SelectedInterval.End;
@@ -1817,9 +1830,9 @@ namespace AyaNova
//case 1039 //log.Debug("FillScheduleableUserGroupList");
ComboBoxTool cbt = (ComboBoxTool)ToolBarManager.Tools["LT:UI.Toolbar.Schedule.SelectScheduleableUserGroup"];
cbt.AutoComplete=true;
cbt.AutoComplete = true;
cbt.ValueList.ValueListItems.Clear();
cbt.ValueList.ValueListItems.Add(ScheduleableUserGroup.AllUsersGroupID, Util.LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownAllItem"));
//Case 303 - check if current user is scheduleable before adding to drop combo
@@ -1829,9 +1842,9 @@ namespace AyaNova
}
//NVCHANGED
GenericNVList l = GenericNVList.GetList("aScheduleableUserGroup", "aID", "aName", true, true,false);
GenericNVList l = GenericNVList.GetList("aScheduleableUserGroup", "aID", "aName", true, true, false);
//Loop through the items in the list and put them
//into the combo box
@@ -1863,7 +1876,7 @@ namespace AyaNova
}
#endregion
#region Custom painting
#region Custom painting
#pragma warning disable 618
/// <summary>
/// Only way to turn off all popup menus
@@ -1877,7 +1890,7 @@ namespace AyaNova
#pragma warning restore 618
private void sc_CustomDrawAppointmentBackground(object sender, CustomDrawObjectEventArgs e)
{
DevExpress.XtraScheduler.Drawing.AppointmentViewInfo aptinfo = (DevExpress.XtraScheduler.Drawing.AppointmentViewInfo)e.ObjectInfo;
if (aptinfo.Appointment.CustomFields == null)
{
@@ -1886,15 +1899,15 @@ namespace AyaNova
object info = aptinfo.Appointment.CustomFields["AyaInfo"];
if (info == null) return;
AppointmentList.AppointmentListInfo i = (AppointmentList.AppointmentListInfo)info;
int nBackWidth = 16;
if (aptinfo is DevExpress.XtraScheduler.Drawing.HorizontalAppointmentViewInfo)
nBackWidth = 5;
Color clAppointmentBackground = SystemColors.Window;
if (aptinfo.Selected)
if (aptinfo.Selected)
clAppointmentBackground = SystemColors.Highlight;
Color clPriorityColour = SystemColors.Window;
@@ -1913,7 +1926,7 @@ namespace AyaNova
Brush brAppointmentBackground = e.Cache.GetGradientBrush(rBack, clPriorityColour, Color.White,
System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
e.Cache.FillRectangle(brAppointmentBackground, rBack);
e.Cache.FillRectangle(e.Cache.GetSolidBrush(clAppointmentBackground), rectAppointmentBackground);
@@ -1926,15 +1939,15 @@ namespace AyaNova
}
else
{
Rectangle r = e.Bounds;
Rectangle r = e.Bounds;
FillRoundedRect(e.Cache.Paint, e.Graphics, e.Cache.GetSolidBrush(clPriorityColour), r, 5);
r.Inflate(-1, -1);
FillRoundedRect(e.Cache.Paint, e.Graphics, e.Cache.GetSolidBrush(clAppointmentBackground), r, 5);
//case 1228
//case 1228
r.Inflate(-3, -3);
e.Cache.FillRectangle(System.Drawing.Brushes.White, r);
e.Handled = true;
}
@@ -1972,7 +1985,7 @@ namespace AyaNova
rTextArea.Height -= 5;
//write the text
aptinfo.Appearance.DrawString(e.Cache, i.Subject, rTextArea, aptinfo.Appearance.TextOptions.GetStringFormat(TextOptions.DefaultOptionsMultiLine));
if (i.SourceObjectType == RootObjectTypes.WorkorderItemScheduledUser)
{
if (i.PriorityARGB != 0)
@@ -1990,7 +2003,7 @@ namespace AyaNova
Rectangle ir = new Rectangle(e.Bounds.X, e.Bounds.Y, 16, 16);
Brush br = e.Cache.GetSolidBrush(Color.WhiteSmoke);
//case 739
e.Cache.Paint.DrawImage(e.Graphics,Util.Flag(i.PriorityARGB), ir);
e.Cache.Paint.DrawImage(e.Graphics, Util.Flag(i.PriorityARGB), ir);
}
}
@@ -2009,8 +2022,8 @@ namespace AyaNova
{
Rectangle ir = new Rectangle(e.Bounds.X, e.Bounds.Y, 16, 16);
Brush br = e.Cache.GetSolidBrush(Color.WhiteSmoke);
e.Cache.Paint.DrawImage(e.Graphics,Resource1.ScheduleMarker16, ir);
e.Cache.Paint.DrawImage(e.Graphics, Resource1.ScheduleMarker16, ir);
}
e.Handled = true;
}
@@ -2023,7 +2036,7 @@ namespace AyaNova
xp.FillRegion(gr, br, rgn);
}
}
void FillRoundedRect(Graphics gr, Brush br, Rectangle r, int roundRadius)
{
using (System.Drawing.Region rgn = new System.Drawing.Region(CreateRoundedRectPath(r, roundRadius)))
@@ -2032,7 +2045,7 @@ namespace AyaNova
}
}
static public GraphicsPath CreateRoundedRectPath(Rectangle r, int radius)
{
@@ -2057,7 +2070,7 @@ namespace AyaNova
SchedRefreshTimer.Stop();
if (MouseButtons == MouseButtons.None)// Case 731
BindData(true);
SchedRefreshTimer.Start();
}
@@ -2065,70 +2078,79 @@ namespace AyaNova
#region Date range changed event
double nMaxWindow = 0;
// double nCurrentWindow = 0;
// double nCurrentWindow = 0;
private void sc_VisibleIntervalChanged(object sender, EventArgs e)
{
//System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString() + "sc_VisibleIntervalChanged fired");
BindData();
}
}
/// <summary>
/// Check if the next fetch window really needs to be fetched
/// </summary>
/// <returns></returns>
private bool NextFetchOutsideLastFetchWindow()
{
{
if (NextFetchStartWindow < LastFetchStartWindow || NextFetchEndWindow > LastFetchEndWindow)
{
//System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString() + " *New date range should fetch*");
return true;
}
// System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString() + " Not a new date range no fetch");
// System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString() + " Not a new date range no fetch");
return false;
}
#endregion date range change
//case 3892
//void DayView_TopRowTimeChanged(object sender, DevExpress.XtraScheduler.Native.ChangeEventArgs e)
//{
// System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString() + "DayView_TopRowTimeChanged fired");
// BindData();
//}
#region case 812 selected appointments
public System.Collections.Generic.List<AppointmentList.AppointmentListInfo> SelectedAppointments
{
get
{
System.Collections.Generic.List<AppointmentList.AppointmentListInfo> apts = new List<AppointmentList.AppointmentListInfo>();
if (sc.SelectedAppointments.Count == 0) return apts;
foreach (Appointment a in sc.SelectedAppointments)
{
apts.Add((AppointmentList.AppointmentListInfo)a.CustomFields["AyaInfo"]);
}
return apts;
}
}
public System.Collections.Generic.List<Guid> VisibleUsers
{
get
{
System.Collections.Generic.List<Guid> usrs = new List<Guid>();
for (int x = 0; x < ss.Resources.Count; x++)
{
Resource r = ss.Resources[x];
if (r.Id == null || string.IsNullOrEmpty(r.Id.ToString())) continue;
Guid id = new Guid(r.Id.ToString());
if (id == Guid.Empty) continue;
if(r.Visible)
usrs.Add(id);
#endregion date range change
#region case 812 selected appointments
public System.Collections.Generic.List<AppointmentList.AppointmentListInfo> SelectedAppointments
{
get
{
System.Collections.Generic.List<AppointmentList.AppointmentListInfo> apts = new List<AppointmentList.AppointmentListInfo>();
if (sc.SelectedAppointments.Count == 0) return apts;
foreach (Appointment a in sc.SelectedAppointments)
{
apts.Add((AppointmentList.AppointmentListInfo)a.CustomFields["AyaInfo"]);
}
return apts;
}
}
public System.Collections.Generic.List<Guid> VisibleUsers
{
get
{
System.Collections.Generic.List<Guid> usrs = new List<Guid>();
for (int x = 0; x < ss.Resources.Count; x++)
{
Resource r = ss.Resources[x];
if (r.Id == null || string.IsNullOrEmpty(r.Id.ToString())) continue;
Guid id = new Guid(r.Id.ToString());
if (id == Guid.Empty) continue;
if (r.Visible)
usrs.Add(id);
}
return usrs;
}
}
#endregion
}
return usrs;
}
}
#endregion
@@ -2147,5 +2169,5 @@ namespace AyaNova
get { return this.EndDate; }
}
}
}