using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using GZTW.AyaNova.BLL; using Infragistics.Win; using DevExpress.XtraScheduler; using Infragistics.Win.UltraWinToolbars; using System.Threading; using CSLA.Security; using log4net; using System.Drawing.Drawing2D; using DevExpress.Utils; using System.Collections.Generic; using DevExpress.XtraScheduler.Printing; using System.Reflection; using DevExpress.XtraScheduler.Reporting; using DevExpress.XtraPrinting; namespace AyaNova { /// /// Summary description for ScheduleForm. /// public class ScheduleFormEx : 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.UltraWinToolbars.UltraToolbarsDockArea _ScheduleForm_Toolbars_Dock_Area_Left; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _ScheduleForm_Toolbars_Dock_Area_Right; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _ScheduleForm_Toolbars_Dock_Area_Top; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _ScheduleForm_Toolbars_Dock_Area_Bottom; private Infragistics.Win.UltraWinToolbars.UltraToolbarsManager ToolBarManager; private System.ComponentModel.IContainer components; private System.Windows.Forms.HelpProvider helpProvider1; private DevExpress.XtraScheduler.SchedulerControl sc; private DevExpress.XtraScheduler.SchedulerStorage ss; private System.Windows.Forms.Timer SchedRefreshTimer; private Infragistics.Win.UltraWinToolTip.UltraToolTipManager tt; public ScheduleFormEx() { // // Required for Windows Form Designer support // InitializeComponent(); // // // } /// /// Clean up any resources being used. /// protected override void Dispose(bool disposing) { if (disposing) { if (components != null) { try { components.Dispose(); } catch { }; } } base.Dispose(disposing); } #pragma warning disable 612, 618 #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(); DevExpress.XtraScheduler.TimeRuler timeRuler1 = new DevExpress.XtraScheduler.TimeRuler(); DevExpress.XtraScheduler.TimeScaleYear timeScaleYear1 = new DevExpress.XtraScheduler.TimeScaleYear(); DevExpress.XtraScheduler.TimeScaleQuarter timeScaleQuarter1 = new DevExpress.XtraScheduler.TimeScaleQuarter(); DevExpress.XtraScheduler.TimeScaleMonth timeScaleMonth1 = new DevExpress.XtraScheduler.TimeScaleMonth(); DevExpress.XtraScheduler.TimeScaleWeek timeScaleWeek1 = new DevExpress.XtraScheduler.TimeScaleWeek(); DevExpress.XtraScheduler.TimeScaleDay timeScaleDay1 = new DevExpress.XtraScheduler.TimeScaleDay(); DevExpress.XtraScheduler.TimeScaleHour timeScaleHour1 = new DevExpress.XtraScheduler.TimeScaleHour(); DevExpress.XtraScheduler.TimeScaleFixedInterval timeScaleFixedInterval1 = new DevExpress.XtraScheduler.TimeScaleFixedInterval(); DevExpress.XtraScheduler.TimeRuler timeRuler2 = new DevExpress.XtraScheduler.TimeRuler(); Infragistics.Win.UltraWinToolbars.UltraToolbar ultraToolbar1 = new Infragistics.Win.UltraWinToolbars.UltraToolbar("Schedule"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool1 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Schedule.EditScheduleableUserGroup"); Infragistics.Win.UltraWinToolbars.ComboBoxTool comboBoxTool1 = new Infragistics.Win.UltraWinToolbars.ComboBoxTool("LT:UI.Toolbar.Schedule.SelectScheduleableUserGroup"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool2 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Schedule.NewScheduleMarker"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool3 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Schedule.NewWorkorder"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool4 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Refresh"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool5 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Print"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool6 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Schedule.Today"); Infragistics.Win.UltraWinToolbars.StateButtonTool stateButtonTool6 = new Infragistics.Win.UltraWinToolbars.StateButtonTool("LT:UI.Toolbar.Schedule.TimeLineView", ""); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool11 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Schedule.EditScheduleMarker"); Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool1 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("LT:UI.Toolbar.Schedule.PrintWorkorders"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool12 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Schedule.EditWorkorder"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool13 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Schedule.AddToActiveWorkorderItem"); Infragistics.Win.UltraWinToolbars.StateButtonTool stateButtonTool1 = new Infragistics.Win.UltraWinToolbars.StateButtonTool("LT:UI.Toolbar.Schedule.MergeUsers", ""); Infragistics.Win.UltraWinToolbars.StateButtonTool stateButtonTool4 = new Infragistics.Win.UltraWinToolbars.StateButtonTool("LT:UI.Toolbar.Schedule.ShowClosed", ""); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool14 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Schedule.EditScheduleableUserGroup"); Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool19 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Schedule.EditWorkorder"); Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance4 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool20 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Schedule.EditScheduleMarker"); Infragistics.Win.Appearance appearance5 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance6 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool21 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Schedule.NewScheduleMarker"); Infragistics.Win.Appearance appearance7 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance8 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool22 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Schedule.NewWorkorder"); Infragistics.Win.Appearance appearance9 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance10 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool23 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Schedule.Today"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool24 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Refresh"); Infragistics.Win.Appearance appearance11 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance12 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool25 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Print"); Infragistics.Win.Appearance appearance13 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance14 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool26 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Schedule.AddToActiveWorkorderItem"); Infragistics.Win.Appearance appearance15 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance16 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ComboBoxTool comboBoxTool2 = new Infragistics.Win.UltraWinToolbars.ComboBoxTool("LT:UI.Toolbar.Schedule.SelectScheduleableUserGroup"); Infragistics.Win.ValueList valueList1 = new Infragistics.Win.ValueList(0); Infragistics.Win.UltraWinToolbars.StateButtonTool stateButtonTool2 = new Infragistics.Win.UltraWinToolbars.StateButtonTool("LT:UI.Toolbar.Schedule.MergeUsers", ""); Infragistics.Win.Appearance appearance17 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance18 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance19 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance20 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.StateButtonTool stateButtonTool3 = new Infragistics.Win.UltraWinToolbars.StateButtonTool("LT:UI.Toolbar.Schedule.ShowClosed", ""); Infragistics.Win.Appearance appearance21 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance22 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance23 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance24 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.StateButtonTool stateButtonTool5 = new Infragistics.Win.UltraWinToolbars.StateButtonTool("LT:UI.Toolbar.Schedule.TimeLineView", ""); Infragistics.Win.Appearance appearance25 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance26 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance27 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance28 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool2 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("LT:UI.Toolbar.Schedule.PrintWorkorders"); Infragistics.Win.Appearance appearance29 = new Infragistics.Win.Appearance(); Infragistics.Win.Appearance appearance30 = new Infragistics.Win.Appearance(); Infragistics.Win.UltraWinToolbars.ListTool listTool2 = new Infragistics.Win.UltraWinToolbars.ListTool("REPORTLIST"); Infragistics.Win.UltraWinToolbars.ListTool listTool1 = new Infragistics.Win.UltraWinToolbars.ListTool("REPORTLIST"); this.helpProvider1 = new System.Windows.Forms.HelpProvider(); this.tt = new Infragistics.Win.UltraWinToolTip.UltraToolTipManager(this.components); this.sc = new DevExpress.XtraScheduler.SchedulerControl(); this.ss = new DevExpress.XtraScheduler.SchedulerStorage(this.components); this.SchedRefreshTimer = new System.Windows.Forms.Timer(this.components); this._ScheduleForm_Toolbars_Dock_Area_Left = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this.ToolBarManager = new Infragistics.Win.UltraWinToolbars.UltraToolbarsManager(this.components); this._ScheduleForm_Toolbars_Dock_Area_Right = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._ScheduleForm_Toolbars_Dock_Area_Top = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._ScheduleForm_Toolbars_Dock_Area_Bottom = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); ((System.ComponentModel.ISupportInitialize)(this.sc)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.ss)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.ToolBarManager)).BeginInit(); this.SuspendLayout(); // // tt // this.tt.AutoPopDelay = 0; this.tt.ContainingControl = this; this.tt.DisplayStyle = Infragistics.Win.ToolTipDisplayStyle.BalloonTip; this.tt.InitialDelay = 0; // // sc // this.sc.Dock = System.Windows.Forms.DockStyle.Fill; this.sc.GroupType = DevExpress.XtraScheduler.SchedulerGroupType.Resource; this.sc.Location = new System.Drawing.Point(0, 43); this.sc.LookAndFeel.SkinName = "iMaginary"; this.sc.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.UltraFlat; this.sc.LookAndFeel.UseDefaultLookAndFeel = false; this.sc.LookAndFeel.UseWindowsXPTheme = true; this.sc.Name = "sc"; this.sc.OptionsBehavior.ShowRemindersForm = false; this.sc.OptionsCustomization.AllowAppointmentCopy = DevExpress.XtraScheduler.UsedAppointmentType.None; this.sc.OptionsCustomization.AllowAppointmentDelete = DevExpress.XtraScheduler.UsedAppointmentType.None; this.sc.OptionsCustomization.AllowInplaceEditor = DevExpress.XtraScheduler.UsedAppointmentType.None; this.sc.OptionsView.ShowOnlyResourceAppointments = true; this.sc.ResourceNavigator.Buttons.Append.Enabled = false; this.sc.ResourceNavigator.Buttons.Append.Visible = false; this.sc.ResourceNavigator.Buttons.Remove.Enabled = false; this.sc.ResourceNavigator.Buttons.Remove.Visible = false; this.sc.Size = new System.Drawing.Size(880, 661); this.sc.Start = new System.DateTime(2007, 10, 11, 0, 0, 0, 0); this.sc.Storage = this.ss; this.sc.TabIndex = 4; this.sc.Views.DayView.AppointmentDisplayOptions.SnapToCellsMode = DevExpress.XtraScheduler.AppointmentSnapToCellsMode.Never; this.sc.Views.DayView.AppointmentDisplayOptions.StatusDisplayType = DevExpress.XtraScheduler.AppointmentStatusDisplayType.Never; this.sc.Views.DayView.ResourcesPerPage = 9; this.sc.Views.DayView.TimeRulers.Add(timeRuler1); this.sc.Views.DayView.TimeScale = System.TimeSpan.Parse("00:15:00"); this.sc.Views.DayView.VisibleTime.End = System.TimeSpan.Parse("24.00:00:00"); this.sc.Views.DayView.WorkTime.End = System.TimeSpan.Parse("17:00:00"); this.sc.Views.DayView.WorkTime.Start = System.TimeSpan.Parse("08:00:00"); this.sc.Views.MonthView.ResourcesPerPage = 9; this.sc.Views.TimelineView.AppointmentDisplayOptions.SnapToCellsMode = DevExpress.XtraScheduler.AppointmentSnapToCellsMode.Never; timeScaleYear1.Enabled = false; timeScaleYear1.Visible = false; timeScaleQuarter1.Enabled = false; timeScaleQuarter1.Visible = false; timeScaleWeek1.Enabled = false; timeScaleWeek1.Visible = false; timeScaleFixedInterval1.Width = 16; this.sc.Views.TimelineView.Scales.Add(timeScaleYear1); this.sc.Views.TimelineView.Scales.Add(timeScaleQuarter1); this.sc.Views.TimelineView.Scales.Add(timeScaleMonth1); this.sc.Views.TimelineView.Scales.Add(timeScaleWeek1); this.sc.Views.TimelineView.Scales.Add(timeScaleDay1); this.sc.Views.TimelineView.Scales.Add(timeScaleHour1); this.sc.Views.TimelineView.Scales.Add(timeScaleFixedInterval1); this.sc.Views.TimelineView.SelectionBar.Visible = false; this.sc.Views.WeekView.ResourcesPerPage = 9; this.sc.Views.WorkWeekView.AppointmentDisplayOptions.StatusDisplayType = DevExpress.XtraScheduler.AppointmentStatusDisplayType.Never; this.sc.Views.WorkWeekView.ResourcesPerPage = 9; this.sc.Views.WorkWeekView.TimeRulers.Add(timeRuler2); this.sc.SelectionChanged += new System.EventHandler(this.sc_SelectionChanged); this.sc.VisibleIntervalChanged += new System.EventHandler(this.sc_VisibleIntervalChanged); this.sc.ActiveViewChanging += new DevExpress.XtraScheduler.ActiveViewChangingEventHandler(this.sc_ActiveViewChanging); this.sc.PreparePopupMenu += new DevExpress.XtraScheduler.PreparePopupMenuEventHandler(this.sc_PreparePopupMenu); this.sc.EditAppointmentFormShowing += new DevExpress.XtraScheduler.AppointmentFormEventHandler(this.sc_EditAppointmentFormShowing); this.sc.CustomDrawAppointment += new DevExpress.XtraScheduler.CustomDrawObjectEventHandler(this.sc_CustomDrawAppointment); this.sc.CustomDrawAppointmentBackground += new DevExpress.XtraScheduler.CustomDrawObjectEventHandler(this.sc_CustomDrawAppointmentBackground); // // ss // this.ss.EnableReminders = false; this.ss.AppointmentChanging += new DevExpress.XtraScheduler.PersistentObjectCancelEventHandler(this.ss_AppointmentChanging); // // SchedRefreshTimer // this.SchedRefreshTimer.Tick += new System.EventHandler(this.SchedRefreshTimer_Tick); // // _ScheduleForm_Toolbars_Dock_Area_Left // this._ScheduleForm_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._ScheduleForm_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control; this._ScheduleForm_Toolbars_Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Left; this._ScheduleForm_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText; this._ScheduleForm_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 43); this._ScheduleForm_Toolbars_Dock_Area_Left.Name = "_ScheduleForm_Toolbars_Dock_Area_Left"; this._ScheduleForm_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 661); this._ScheduleForm_Toolbars_Dock_Area_Left.ToolbarsManager = this.ToolBarManager; // // ToolBarManager // this.ToolBarManager.DesignerFlags = 1; this.ToolBarManager.DockWithinContainer = this; this.ToolBarManager.DockWithinContainerBaseType = typeof(System.Windows.Forms.Form); this.ToolBarManager.MdiMergeable = false; this.ToolBarManager.ShowFullMenusDelay = 500; ultraToolbar1.DockedColumn = 0; ultraToolbar1.DockedRow = 0; ultraToolbar1.NonInheritedTools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] { buttonTool1, comboBoxTool1, buttonTool2, buttonTool3, buttonTool4, buttonTool5, buttonTool6, stateButtonTool6, buttonTool11, popupMenuTool1, buttonTool12, buttonTool13, stateButtonTool1, stateButtonTool4}); ultraToolbar1.Text = "Schedule"; this.ToolBarManager.Toolbars.AddRange(new Infragistics.Win.UltraWinToolbars.UltraToolbar[] { ultraToolbar1}); this.ToolBarManager.ToolbarSettings.AllowCustomize = Infragistics.Win.DefaultableBoolean.False; this.ToolBarManager.ToolbarSettings.AllowFloating = Infragistics.Win.DefaultableBoolean.False; this.ToolBarManager.ToolbarSettings.AllowHiding = Infragistics.Win.DefaultableBoolean.False; appearance1.Image = global::AyaNova.Resource1.EditScheduledUserGroups32; buttonTool14.SharedPropsInternal.AppearancesLarge.Appearance = appearance1; appearance2.Image = global::AyaNova.Resource1.EditScheduledUserGroups16; buttonTool14.SharedPropsInternal.AppearancesSmall.Appearance = appearance2; buttonTool14.SharedPropsInternal.Caption = "LT:UI.Toolbar.Schedule.EditScheduleableUserGroup"; appearance3.Image = global::AyaNova.Resource1.ServiceWorkorder32; buttonTool19.SharedPropsInternal.AppearancesLarge.Appearance = appearance3; appearance4.Image = global::AyaNova.Resource1.ServiceWorkorder16; buttonTool19.SharedPropsInternal.AppearancesSmall.Appearance = appearance4; buttonTool19.SharedPropsInternal.Caption = "LT:UI.Toolbar.Schedule.EditWorkorder"; appearance5.Image = global::AyaNova.Resource1.ScheduleMarker32; buttonTool20.SharedPropsInternal.AppearancesLarge.Appearance = appearance5; appearance6.Image = global::AyaNova.Resource1.ScheduleMarker16; buttonTool20.SharedPropsInternal.AppearancesSmall.Appearance = appearance6; buttonTool20.SharedPropsInternal.Caption = "LT:UI.Toolbar.Schedule.EditScheduleMarker"; appearance7.Image = global::AyaNova.Resource1.ScheduleMarkerNew32; buttonTool21.SharedPropsInternal.AppearancesLarge.Appearance = appearance7; appearance8.Image = global::AyaNova.Resource1.ScheduleMarkerNew16; buttonTool21.SharedPropsInternal.AppearancesSmall.Appearance = appearance8; buttonTool21.SharedPropsInternal.Caption = "LT:UI.Toolbar.Schedule.NewScheduleMarker"; appearance9.Image = global::AyaNova.Resource1.ServiceWorkorderNew32; buttonTool22.SharedPropsInternal.AppearancesLarge.Appearance = appearance9; appearance10.Image = global::AyaNova.Resource1.ServiceWorkorderNew16; buttonTool22.SharedPropsInternal.AppearancesSmall.Appearance = appearance10; buttonTool22.SharedPropsInternal.Caption = "LT:UI.Toolbar.Schedule.NewWorkorder"; buttonTool23.SharedPropsInternal.Caption = "LT:UI.Toolbar.Schedule.Today"; buttonTool23.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.TextOnlyAlways; appearance11.Image = global::AyaNova.Resource1.Refresh32; buttonTool24.SharedPropsInternal.AppearancesLarge.Appearance = appearance11; appearance12.Image = global::AyaNova.Resource1.Refresh16; buttonTool24.SharedPropsInternal.AppearancesSmall.Appearance = appearance12; buttonTool24.SharedPropsInternal.Caption = "LT:UI.Toolbar.Refresh"; appearance13.Image = global::AyaNova.Resource1.PrintSchedule32; buttonTool25.SharedPropsInternal.AppearancesLarge.Appearance = appearance13; appearance14.Image = global::AyaNova.Resource1.PrintSchedule16; buttonTool25.SharedPropsInternal.AppearancesSmall.Appearance = appearance14; buttonTool25.SharedPropsInternal.Caption = "LT:UI.Toolbar.Print"; appearance15.Image = global::AyaNova.Resource1.AddSelectionToActiveWOItem32; buttonTool26.SharedPropsInternal.AppearancesLarge.Appearance = appearance15; appearance16.Image = global::AyaNova.Resource1.AddSelectionToActiveWOItem16; buttonTool26.SharedPropsInternal.AppearancesSmall.Appearance = appearance16; buttonTool26.SharedPropsInternal.Caption = "LT:UI.Toolbar.Schedule.AddToActiveWorkorderItem"; comboBoxTool2.AutoComplete = true; comboBoxTool2.SharedPropsInternal.Caption = "LT:UI.Toolbar.Schedule.SelectScheduleableUserGroup"; valueList1.MaxDropDownItems = 25; valueList1.SortStyle = Infragistics.Win.ValueListSortStyle.Ascending; comboBoxTool2.ValueList = valueList1; appearance17.Image = global::AyaNova.Resource1.ScheduleSeparate32; stateButtonTool2.SharedPropsInternal.AppearancesLarge.Appearance = appearance17; appearance18.Image = global::AyaNova.Resource1.ScheduleMerged32; stateButtonTool2.SharedPropsInternal.AppearancesLarge.PressedAppearance = appearance18; appearance19.Image = global::AyaNova.Resource1.ScheduleSeparate16; stateButtonTool2.SharedPropsInternal.AppearancesSmall.Appearance = appearance19; appearance20.Image = global::AyaNova.Resource1.ScheduleMerged16; stateButtonTool2.SharedPropsInternal.AppearancesSmall.PressedAppearance = appearance20; stateButtonTool2.SharedPropsInternal.Caption = "LT:UI.Toolbar.Schedule.MergeUsers"; appearance21.Image = global::AyaNova.Resource1.ShowOpenOnly32; stateButtonTool3.SharedPropsInternal.AppearancesLarge.Appearance = appearance21; appearance22.Image = global::AyaNova.Resource1.ShowOpenAndClosed32; stateButtonTool3.SharedPropsInternal.AppearancesLarge.PressedAppearance = appearance22; appearance23.Image = global::AyaNova.Resource1.ShowOpenOnly16; stateButtonTool3.SharedPropsInternal.AppearancesSmall.Appearance = appearance23; appearance24.Image = global::AyaNova.Resource1.ShowOpenAndClosed16; stateButtonTool3.SharedPropsInternal.AppearancesSmall.PressedAppearance = appearance24; stateButtonTool3.SharedPropsInternal.Caption = "LT:UI.Toolbar.Schedule.ShowClosed"; appearance25.Image = global::AyaNova.Resource1.DisplayRegular32; stateButtonTool5.SharedPropsInternal.AppearancesLarge.Appearance = appearance25; appearance26.Image = global::AyaNova.Resource1.DisplayTimeLine32; stateButtonTool5.SharedPropsInternal.AppearancesLarge.PressedAppearance = appearance26; appearance27.Image = global::AyaNova.Resource1.DisplayRegular16; stateButtonTool5.SharedPropsInternal.AppearancesSmall.Appearance = appearance27; appearance28.Image = global::AyaNova.Resource1.DisplayTimeLine16; stateButtonTool5.SharedPropsInternal.AppearancesSmall.PressedAppearance = appearance28; stateButtonTool5.SharedPropsInternal.Caption = "LT:UI.Toolbar.Schedule.TimeLineView"; appearance29.Image = global::AyaNova.Resource1.Print32; popupMenuTool2.SharedPropsInternal.AppearancesLarge.Appearance = appearance29; appearance30.Image = global::AyaNova.Resource1.Print16; popupMenuTool2.SharedPropsInternal.AppearancesSmall.Appearance = appearance30; popupMenuTool2.SharedPropsInternal.Caption = "LT:UI.Toolbar.Schedule.PrintWorkorders"; popupMenuTool2.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.ImageOnlyOnToolbars; popupMenuTool2.SharedPropsInternal.Shortcut = System.Windows.Forms.Shortcut.CtrlP; popupMenuTool2.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] { listTool2}); listTool1.DisplayCheckmark = false; listTool1.SharedPropsInternal.Caption = "REPORTLIST"; this.ToolBarManager.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] { buttonTool14, buttonTool19, buttonTool20, buttonTool21, buttonTool22, buttonTool23, buttonTool24, buttonTool25, buttonTool26, comboBoxTool2, stateButtonTool2, stateButtonTool3, stateButtonTool5, popupMenuTool2, listTool1}); this.ToolBarManager.UseLargeImagesOnToolbar = true; this.ToolBarManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.ToolBarManager_ToolClick); this.ToolBarManager.ToolValueChanged += new Infragistics.Win.UltraWinToolbars.ToolEventHandler(this.ToolBarManager_ToolValueChanged); // // _ScheduleForm_Toolbars_Dock_Area_Right // this._ScheduleForm_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._ScheduleForm_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control; this._ScheduleForm_Toolbars_Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Right; this._ScheduleForm_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText; this._ScheduleForm_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(880, 43); this._ScheduleForm_Toolbars_Dock_Area_Right.Name = "_ScheduleForm_Toolbars_Dock_Area_Right"; this._ScheduleForm_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 661); this._ScheduleForm_Toolbars_Dock_Area_Right.ToolbarsManager = this.ToolBarManager; // // _ScheduleForm_Toolbars_Dock_Area_Top // this._ScheduleForm_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._ScheduleForm_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control; this._ScheduleForm_Toolbars_Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Top; this._ScheduleForm_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText; this._ScheduleForm_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0); this._ScheduleForm_Toolbars_Dock_Area_Top.Name = "_ScheduleForm_Toolbars_Dock_Area_Top"; this._ScheduleForm_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(880, 43); this._ScheduleForm_Toolbars_Dock_Area_Top.ToolbarsManager = this.ToolBarManager; // // _ScheduleForm_Toolbars_Dock_Area_Bottom // this._ScheduleForm_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._ScheduleForm_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control; this._ScheduleForm_Toolbars_Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Bottom; this._ScheduleForm_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText; this._ScheduleForm_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 704); this._ScheduleForm_Toolbars_Dock_Area_Bottom.Name = "_ScheduleForm_Toolbars_Dock_Area_Bottom"; this._ScheduleForm_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(880, 0); this._ScheduleForm_Toolbars_Dock_Area_Bottom.ToolbarsManager = this.ToolBarManager; // // ScheduleFormEx // this.AutoScaleBaseSize = new System.Drawing.Size(6, 15); this.ClientSize = new System.Drawing.Size(880, 704); this.ControlBox = false; this.Controls.Add(this.sc); this.Controls.Add(this._ScheduleForm_Toolbars_Dock_Area_Left); this.Controls.Add(this._ScheduleForm_Toolbars_Dock_Area_Right); this.Controls.Add(this._ScheduleForm_Toolbars_Dock_Area_Bottom); this.Controls.Add(this._ScheduleForm_Toolbars_Dock_Area_Top); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.helpProvider1.SetHelpKeyword(this, ""); this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); this.Name = "ScheduleFormEx"; this.helpProvider1.SetShowHelp(this, true); this.Text = "ScheduleFormex"; this.Closing += new System.ComponentModel.CancelEventHandler(this.ScheduleForm_Closing); this.Load += new System.EventHandler(this.ScheduleForm_Load); ((System.ComponentModel.ISupportInitialize)(this.sc)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.ss)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.ToolBarManager)).EndInit(); this.ResumeLayout(false); } #endregion #pragma warning restore 612, 618 // __ _ _ ___ ____ __ __ __ __ __ ___ ___ // / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _) // ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _) // \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___) // #region global vars and props private Guid mSelectedUserGroupID = ScheduleableUserGroup.AllUsersGroupID; public Guid SelectedUserGroupID { get { return mSelectedUserGroupID; } set { mSelectedUserGroupID = value; } } public SchedulerControl ScheduleControl { get { return this.sc; } } //case 1242 //back again to facilitate saving last viewed date range MyDateNavigator mDateNav = null; public MyDateNavigator DateNav { set { if (mDateNav == null) { mDateNav = value; mDateNav.BoldAppointmentDates = true; } } } //Time window available to user private DateTime NextFetchStartWindow; private DateTime NextFetchEndWindow; private DateTime LastFetchStartWindow; private DateTime LastFetchEndWindow; //used to avoid unnecessary loading of data bool DoNotAllowFetchAndBind = true; #endregion #region Workorder changed event handler //case 702 /// /// This method is to refresh if a SERVICE work order is saved / deleted /// the workorder form adds this handler /// /// /// public void w_WorkorderUpdated(object sender, EventArgs e) { BindData(true); } #endregion #region Form Load / Close events private void ScheduleForm_Load(object sender, System.EventArgs e) { // // helpProvider1 // this.helpProvider1.HelpNamespace = Util.BaseHelpUrl + "what_do_i_use_the_schedule.htm"; Util.LoadFormCustomization("ScheduleFormEx", this, ToolBarManager, true); //case 812 Util.PluginInsertMenu(ToolBarManager, new Util.PluginMenuOptionData(false, RootObjectTypes.Schedule, this, null));//case 941 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); if (AyaBizUtils.Right("Object.Report") < (int)SecurityLevelTypes.ReadOnly) { ToolBarManager.Tools["LT:UI.Toolbar.Schedule.PrintWorkorders"].SharedProps.Visible = false; } else { ToolBarManager.Tools["LT:UI.Toolbar.Schedule.PrintWorkorders"].SharedProps.Visible = true; Util.ReportFillList(this.ToolBarManager.Tools["REPORTLIST"], WorkorderServiceList.ReportKey, WorkorderServiceDetailedReportData.ReportKey); } //case 1172 //ToolBarManager.Tools["LT:UI.Toolbar.Refresh"].SharedProps.Visible = !AyaBizUtils.Lite; ToolBarManager.Tools["LT:UI.Toolbar.Schedule.SelectScheduleableUserGroup"].SharedProps.Visible = !AyaBizUtils.Lite; ToolBarManager.Tools["LT:UI.Toolbar.Schedule.EditScheduleableUserGroup"].SharedProps.Visible = !AyaBizUtils.Lite; ToolBarManager.Tools["LT:UI.Toolbar.Schedule.MergeUsers"].SharedProps.Visible = !AyaBizUtils.Lite; //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.WorkorderItemScheduledUser") > (int)SecurityLevelTypes.ReadOnly); //case 1219 - need user for more stuff below User currentUser = User.GetItem(User.CurrentThreadUserID); mSelectedUserGroupID = currentUser.LastSchedGroupID; FillScheduleableUserGroupList(); bIgnoreSchedUserGroupChange = false; sc.Start = DBUtil.CurrentWorkingDateTime; //case 714 sc.DayView.TopRowTime = TimeSpan.FromHours(8); //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); //************************************** //case 1219 if (currentUser.LastSchedView > 4 || currentUser.LastSchedView < 0) currentUser.LastSchedView = 0; sc.ActiveViewType = (SchedulerViewType)currentUser.LastSchedView; if (currentUser.LastSchedStartDate.IsEmpty || currentUser.LastSchedStopDate.IsEmpty) { currentUser.LastSchedStartDate.Date = DateTime.Today; 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) { int nHalfWindow = (int)(nMaxWindow / 2) + 7; NextFetchStartWindow = currentUser.LastSchedStartDate.Date - TimeSpan.FromDays(nHalfWindow); NextFetchEndWindow = currentUser.LastSchedStopDate.Date + TimeSpan.FromDays(nHalfWindow); } else { //in theory this will be called when a user changes to selecting a year or something after only a month NextFetchStartWindow = currentUser.LastSchedStartDate.Date - TimeSpan.FromDays(7); NextFetchEndWindow = currentUser.LastSchedStopDate.Date + TimeSpan.FromDays(7); } //case 1553 StateButtonTool sbt = (StateButtonTool)ToolBarManager.Tools["LT:UI.Toolbar.Schedule.ShowClosed"]; sbt.Checked = !currentUser.ScheduleLastViewOpenOnly; //case 701 #if (DEBUG) //testing interval (5 minutes) this.SchedRefreshTimer.Interval = 300000; #else //5 minutes SchedRefreshTimer.Interval=300000; #endif SchedRefreshTimer.Enabled = true; SchedRefreshTimer.Start(); DoNotAllowFetchAndBind = false; BindData(true); } private void ScheduleForm_Closing(object sender, System.ComponentModel.CancelEventArgs e) { //case 701 SchedRefreshTimer.Stop(); SchedRefreshTimer.Enabled = false; DoNotAllowFetchAndBind = true; User u = User.GetItem(User.CurrentThreadUserID); u.LastSchedGroupID = mSelectedUserGroupID; //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 nstopdays = (u.LastSchedStopDate.Date - DateTime.Today).Days; if (nstartdays == 0 && nstopdays == 1) { u.LastSchedStartDate = new CSLA.SmartDate(); u.LastSchedStopDate = new CSLA.SmartDate(); } //case 1553 StateButtonTool sbt = (StateButtonTool)ToolBarManager.Tools["LT:UI.Toolbar.Schedule.ShowClosed"]; if (!sbt.Checked) u.ScheduleLastViewOpenOnly = true; else u.ScheduleLastViewOpenOnly = false; u.Save(); Util.SaveFormCustomization("ScheduleFormEx", this, ToolBarManager, true); } #endregion #region DataBinding private void BindData() { BindData(false); } private void BindData(bool ForceRefresh) { if (DoNotAllowFetchAndBind) { //System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString() + "BindData BAILING due to ignoredatechanges=true"); return; } //case 1644 workaround for devexpress bug //Avoid redrawing on first and only first time an appointment //is dragged to another tech, which dissappears appointments unnecessarily if (nAppointmentChangeCount == 1) { nAppointmentChangeCount++; return; } DoNotAllowFetchAndBind = true; NextFetchStartWindow = mDateNav.MyStartDate; NextFetchEndWindow = mDateNav.MyEndDate; //If the next window is inside of the current last fetch window then no need to fetch at all if (!ForceRefresh && !NextFetchOutsideLastFetchWindow()) { 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; //this is required otherwise the date navigator sometimes doesn't bold the dates properly mDateNav.BeginInit(); ss.BeginUpdate(); ss.Appointments.Clear(); ss.Resources.Clear(); #region ===== Fill owner list ===== //Owners UserListScheduleable uls = UserListScheduleable.GetList(); Resource r = new Resource(Guid.Empty.ToString(), Util.LocaleText.GetLocalizedText("Dashboard.Label.NotAssigned"));//case 1821 //Lite version has no unscheduled user if (!AyaBizUtils.Lite) ss.Resources.Add(r); foreach (UserListScheduleable.UserListScheduleableInfo ui in uls) { if (ui.Active) { r = new Resource(ui.ID.ToString(), ui.Name(AyaBizUtils.GlobalSettings.DefaultScheduleableUserNameDisplayFormat)); if (ui.ScheduleBackColor != 0) r.Color = Color.FromArgb(ui.ScheduleBackColor); ss.Resources.Add(r); } } #endregion #region ===== Show users selected ======= ///Show users in order of time consumption... //Show all users? if (mSelectedUserGroupID == ScheduleableUserGroup.AllUsersGroupID) goto OwnersDone;//all are visible already so no change required //Show current owner only? if (mSelectedUserGroupID == Guid.Empty) { string sCurrentUserID = (((BusinessPrincipal)Thread.CurrentPrincipal).ID).ToString(); for (int x = 0; x < ss.Resources.Count; x++) { r = ss.Resources[x]; if (r.Id.ToString() == sCurrentUserID) r.Visible = true; else r.Visible = false; } goto OwnersDone; } //Show selected groups users only ScheduleableUserGroupUsersList SelectedGroup = ScheduleableUserGroupUsersList.GetList(mSelectedUserGroupID); if (SelectedGroup.Count > 0) { for (int x = 0; x < ss.Resources.Count; x++) { r = ss.Resources[x]; if (SelectedGroup.Contains(r.Id.ToString()) || r.Id.ToString() == Guid.Empty.ToString())//Case 189 r.Visible = true; else r.Visible = false; } } //Done showing owners OwnersDone: #endregion #region ===== Fetch appointments ===== //Fetch appointments within a window on either side of the currently visible monthviewmulti calendar control AppointmentList apl; StateButtonTool sbt = (StateButtonTool)ToolBarManager.Tools["LT:UI.Toolbar.Schedule.ShowClosed"]; //System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString() + " BindData()-Fetching: " + NextFetchStartWindow.ToString() + " - " + NextFetchEndWindow.ToString()); if (!sbt.Checked) apl = AppointmentList.GetList(NextFetchStartWindow, NextFetchEndWindow, Guid.Empty); else apl = AppointmentList.GetListWithClosed(NextFetchStartWindow, NextFetchEndWindow, Guid.Empty); foreach (AppointmentList.AppointmentListInfo i in apl) { try { switch (i.SourceObjectType) { case RootObjectTypes.WorkorderItemScheduledUser: { AddAppointment(i, i.AppliesToObjectID); } break; case RootObjectTypes.ScheduleMarker: { #region schedmarkers ////Could be a bunch by region , global , dispatchzone, schedusergroup ////or could be a single by one user ID switch (i.AppliesToObjectType) { case RootObjectTypes.User: AddAppointment(i, i.AppliesToObjectID); break; case RootObjectTypes.Region: { //Loop through all active scheduleable users //if the region ID matches the marker region ID then //add a marker on the calendar for it foreach (UserListScheduleable.UserListScheduleableInfo ui in uls) { if (!ui.Active) continue; //case 58 if (i.AppliesToObjectID == GZTW.AyaNova.BLL.Region.DefaultRegionID)//SM is for default region? Then applies to everyone AddAppointment(i, ui.ID); else if (ui.RegionID == GZTW.AyaNova.BLL.Region.DefaultRegionID)//User is in default region? Then applies to them AddAppointment(i, ui.ID); else if (ui.RegionID == i.AppliesToObjectID)//SM and User in same non default region AddAppointment(i, ui.ID); else continue;//no match } } break; case RootObjectTypes.DispatchZone: { //Loop through all active scheduleable users //if the Dispatch zone ID matches the marker zone ID then //add a marker on the calendar for it foreach (UserListScheduleable.UserListScheduleableInfo ui in uls) if (ui.Active && ui.DispatchZoneID == i.AppliesToObjectID) AddAppointment(i, ui.ID); } break; case RootObjectTypes.ScheduleableUserGroup: { ScheduleableUserGroupUsersList ScheduleMarkerGroup = ScheduleableUserGroupUsersList.GetList(i.AppliesToObjectID); //Loop through all active scheduleable users //if they are in the ScheduleableUserGroup then //add a marker on the calendar for it foreach (UserListScheduleable.UserListScheduleableInfo ui in uls) if (ui.Active && ScheduleMarkerGroup.Contains(ui.ID)) AddAppointment(i, ui.ID); } break; case RootObjectTypes.Global: { //WARNING: this code makes the assumption that //all ACTIVE users are in the calendar owner collection //and does not check to see if they exist or not //Loop through all active scheduleable users //add a marker on the calendar for each one as this applies to everyone foreach (UserListScheduleable.UserListScheduleableInfo ui in uls) if (ui.Active) AddAppointment(i, ui.ID); } break; } #endregion schedmarkers } break; } } catch (Exception ex) { //log.Error("BindData:FetchAppointments", ex); string extra = ""; if (i.SourceObjectType == RootObjectTypes.WorkorderItemScheduledUser) extra = "(Service workorder " + i.ServiceNumber.ToString() + ")"; else extra = "(Schedulemarker: " + i.Subject + " - " + i.Details + ")"; Util.Error("ScheduleForm::BindData", ex.Message + "\r\nAttempting add of appointment for object:\r\nSourceType: " + i.SourceObjectType.ToString() + " - " + i.SourceObjectID.ToString() + "\r\nAppliesTo: " + i.AppliesToObjectType.ToString() + " - " + i.AppliesToObjectID.ToString() + "\r\n" + extra); } } #endregion ss.EndUpdate(); mDateNav.EndInit(); DoNotAllowFetchAndBind = false; Cursor.Current = Cursors.Default; } /// /// Add appointment to schedule /// /// /// private void AddAppointment(AppointmentList.AppointmentListInfo i, object ResourceID) { Appointment a = ss.CreateAppointment(AppointmentType.Normal); a.Start = i.StartDateTime; a.End = i.EndDateTime; a.Subject = i.Subject; a.CustomFields["AyaInfo"] = i; a.ResourceId = ResourceID.ToString(); ss.Appointments.Add(a); } #endregion #region MenuMerging public Infragistics.Win.UltraWinToolbars.UltraToolbarsManager ToolBar { get { Util.Localize(ToolBarManager); return ToolBarManager; } } #endregion #region ToolBar Events /// /// Handles the ToolBarManager_ToolClick's ToolClick event. /// private void ToolBarManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "LT:UI.Toolbar.Schedule.MergeUsers": // StateButtonTool StateButtonTool sbt = (StateButtonTool)ToolBarManager.Tools["LT:UI.Toolbar.Schedule.MergeUsers"]; if (sbt.Checked) sc.GroupType = SchedulerGroupType.None; else sc.GroupType = SchedulerGroupType.Resource; break; case "LT:UI.Toolbar.Schedule.EditScheduleableUserGroup": // ButtonTool ScheduleableUserGroupsForm suf = new ScheduleableUserGroupsForm(); ComboBoxTool cbt = (ComboBoxTool)ToolBarManager.Tools["LT:UI.Toolbar.Schedule.SelectScheduleableUserGroup"]; Guid SelectedGroup = (Guid)cbt.Value; if (SelectedGroup != Guid.Empty && SelectedGroup != ScheduleableUserGroup.AllUsersGroupID) suf.ScheduleableUserGroupToEdit = ScheduleableUserGroup.GetItem(SelectedGroup);// else { if (AyaBizUtils.Right("Object.ScheduleableUserGroup") < (int)SecurityLevelTypes.ReadWrite) { //case 1039 //log.Debug("No ScheduleableUserGroup selected to view and user has no rights to create a new one."); return; } suf.ScheduleableUserGroupToEdit = ScheduleableUserGroup.NewItem(); } suf.ShowDialog(); if (suf.ChangesMade) { FillScheduleableUserGroupList(); } //Added:2-Oct-2006 while looking into another matter //and spotting this suf.Dispose(); break; case "LT:UI.Toolbar.Print": // ButtonTool { ////case 1177 if (this.sc.ActivePrintStyle is DailyPrintStyle) { //Revised completely as per case 822 DailyPrintStyle pStyle = this.sc.ActivePrintStyle as DailyPrintStyle; // Set fonts for appointments and column headings. pStyle.AppointmentFont = new Font("Arial", 10, FontStyle.Regular); pStyle.HeadingsFont = new Font("Arial", 10, FontStyle.Regular); // Specify whether the Calendar header should be printed. pStyle.CalendarHeaderVisible = false; // Specify the intervals to print. pStyle.PrintTime = new TimeOfDayInterval(new TimeSpan(7, 0, 0), new TimeSpan(18, 0, 0)); pStyle.UseActiveViewTimeScale = true; pStyle.ResourceOptions.PrintAllResourcesOnOnePage = true; pStyle.ResourceOptions.PrintCustomCollection = false; pStyle.ResourceOptions.UseActiveViewGroupType = true; pStyle.ResourceOptions.ResourcesKind = ResourcesKind.Visible; pStyle.PrintAllAppointments = false; } //case 1397 testing //PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem()); //pcl.Component = sc; //pcl.Margins = new System.Drawing.Printing.Margins(30, 30, 30, 30); ////string leftColumn = "Pages: [Page # of Pages #]"; ////string middleColumn = "User: [User Name]"; ////string rightColumn = "Date: [Date Printed]"; ////// Create a PageHeaderFooter object and initializing it with ////// the link's PageHeaderFooter. ////PageHeaderFooter phf = printableComponentLink1.PageHeaderFooter as PageHeaderFooter; ////// Clear the PageHeaderFooter's contents. ////phf.Header.Content.Clear(); ////// Add custom information to the link's header. ////phf.Header.Content.AddRange(new string[] { leftColumn, middleColumn, rightColumn }); ////phf.Header.LineAlignment = BrickAlignment.Far; //pcl.CreateDocument(); //pcl.ShowPreviewDialog(); sc.ShowPrintOptionsForm(); #region some old shit that I don't know why I would care but don't want to delete //this turns out to not be necessary now but may be useful to have in future //DevExpress.XtraScheduler.Forms.PageSetupForm f = new DevExpress.XtraScheduler.Forms.PageSetupForm(sc); ////HideDateRangeControlsInPreviewDialog(f); //f.ShowDialog(); #endregion old stuff BindData(true); } break; case "LT:UI.Toolbar.Refresh": // ButtonTool case "LT:UI.Toolbar.Schedule.ShowClosed": BindData(true); break; case "LT:UI.Toolbar.Schedule.TimeLineView": ShowView(SchedulerViewType.Day); break; case "LT:UI.Toolbar.Schedule.AddToActiveWorkorderItem": AddUserToActiveWorkorder(); break; case "LT:UI.Toolbar.Schedule.EditWorkorder": // ButtonTool EditAppointment(); break; case "LT:UI.Toolbar.Schedule.EditScheduleMarker": // ButtonTool EditAppointment(); break; case "LT:UI.Toolbar.Schedule.NewScheduleMarker": // ButtonTool NewScheduleMarker(); break; case "LT:UI.Toolbar.Schedule.NewWorkorder": // ButtonTool NewWorkorder(); break; case "LT:UI.Toolbar.Schedule.Today": // ButtonTool sc.GoToToday(); break; case "REPORTLIST": { if (Util.ReportHandleToolClickIsSummary(e.Tool)) { Util.ReportHandleToolClick(e.Tool, WorkorderServiceList.ReportKey, WorkorderServiceList.GetListFromIDList(this.SelectedWorkOrderList)); } else { Util.ReportHandleToolClick(e.Tool, WorkorderServiceDetailedReportData.ReportKey, WorkorderServiceDetailedReportData.GetListFromIDList(this.SelectedWorkOrderList)); } Util.ReportFillList(this.ToolBarManager.Tools["REPORTLIST"], WorkorderServiceList.ReportKey, WorkorderServiceDetailedReportData.ReportKey); } break; } } private void HideDateRangeControlsInPreviewDialog(Control ctl) { switch (ctl.Name) { case "lblStart": case "lblEnd": case "edtStart": case "edtEnd": { ctl.Visible = false; return; } } 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(c.Name); if (c.Controls.Count > 0) { sb.Append("->"); sb.Append("\t"); sb.Append(GetAllControls(c)); } else sb.Append("\r\n"); } return sb.ToString(); } //New selection of ScheduleableUserGroup bool bIgnoreSchedUserGroupChange = true; private void ToolBarManager_ToolValueChanged(object sender, Infragistics.Win.UltraWinToolbars.ToolEventArgs e) { ////case 1039 //log.Debug("ToolBarManager_ToolValueChanged (New selection of ScheduleableUserGroup)"); if (bIgnoreSchedUserGroupChange) return; mSelectedUserGroupID = (Guid)((ComboBoxTool)e.Tool).Value; this.BindData(true); } #endregion #region Events #region Active view and date navigation events /// /// Event fired when active view is about to change /// /// /// private void sc_ActiveViewChanging(object sender, ActiveViewChangingEventArgs e) { if (ignoreActiveViewChanging) return; ShowView(e.NewView.Type); e.Cancel = true; } bool ignoreActiveViewChanging = false; /// /// Handles view changing the way we want it to happen /// /// private void ShowView(SchedulerViewType newView) { StateButtonTool sbt = (StateButtonTool)ToolBarManager.Tools["LT:UI.Toolbar.Schedule.TimeLineView"]; bool useTimeLineView = sbt.Checked; ignoreActiveViewChanging = true; if (newView == SchedulerViewType.Day) { if (useTimeLineView) newView = SchedulerViewType.Timeline; else//case 714 { sc.DayView.TopRowTime = TimeSpan.FromHours(8); } } sc.ActiveViewType = newView; ignoreActiveViewChanging = false; } #endregion active view and date navigation #region Appointment modification events /// /// User clicked on appointment to edit /// /// /// private void sc_EditAppointmentFormShowing(object sender, AppointmentFormEventArgs e) { EditAppointment(e.Appointment); e.Handled = true; } private AppointmentList.AppointmentListInfo iLastSelected; /// /// Selection logic /// /// /// private void sc_SelectionChanged(object sender, EventArgs e) { ToolBarManager.Tools["LT:UI.Toolbar.Schedule.EditWorkorder"].SharedProps.Visible = false; ToolBarManager.Tools["LT:UI.Toolbar.Schedule.EditScheduleMarker"].SharedProps.Visible = false; ToolBarManager.Tools["LT:UI.Toolbar.Schedule.PrintWorkorders"].SharedProps.Visible = false; if (sc.SelectedAppointments.Count < 1) return; if (sc.SelectedAppointments[0].CustomFields == null) return; if (sc.SelectedAppointments[0].CustomFields["AyaInfo"] == null) return; AppointmentList.AppointmentListInfo i = (AppointmentList.AppointmentListInfo)sc.SelectedAppointments[0].CustomFields["AyaInfo"]; //Ensure only one type of selection is in selection collection if (sc.SelectedAppointments.Count > 1) { //If the first selected appointment (0th) is a different type than the just selected //then deselect all the other selections prior to the current one AppointmentList.AppointmentListInfo ilast = (AppointmentList.AppointmentListInfo)sc.SelectedAppointments[sc.SelectedAppointments.Count - 1].CustomFields["AyaInfo"]; if (ilast.SourceObjectType != i.SourceObjectType) { //deselect int nSelectedCount = sc.SelectedAppointments.Count; nSelectedCount--; for (int x = 0; x < nSelectedCount; x++) { sc.SelectedAppointments.RemoveAt(0); } } i = ilast; } if (i.SourceObjectType == RootObjectTypes.ScheduleMarker) ToolBarManager.Tools["LT:UI.Toolbar.Schedule.EditScheduleMarker"].SharedProps.Visible = true; else { iLastSelected = i; ToolBarManager.Tools["LT:UI.Toolbar.Schedule.EditWorkorder"].SharedProps.Visible = true; if (!AyaBizUtils.Lite) { ToolBarManager.Tools["LT:UI.Toolbar.Schedule.AddToActiveWorkorderItem"].SharedProps.Visible = true; 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; } } //case 1644 int nAppointmentChangeCount = 0; private void ss_AppointmentChanging(object sender, PersistentObjectCancelEventArgs e) { if (e.Object == null || !(e.Object is Appointment)) return; Appointment apt = (Appointment)e.Object; object info = apt.CustomFields["AyaInfo"]; if (info == null) return; AppointmentList.AppointmentListInfo i = (AppointmentList.AppointmentListInfo)info; //flag for saving bool bChangesMade = false; Guid gNewResourceID = new Guid(apt.ResourceId.ToString()); switch (i.SourceObjectType) { #region CASE Schedule marker case RootObjectTypes.ScheduleMarker: { //TODO Checkrights here ScheduleMarker s = ScheduleMarker.GetItem(i.SourceObjectID); //************ SCHEDULE MARKER OWNER CHANGES *************************** //If it's a user item then it can be owner changed if (i.AppliesToObjectType == RootObjectTypes.User) { if (gNewResourceID == Guid.Empty) { //can't put a schedmarker for a user into the unassigned slot e.Cancel = true; return; } //New owner? if (gNewResourceID != s.SourceID) { s.SourceID = gNewResourceID; bChangesMade = true; } } //************ SCHEDULE MARKER DATE AND TIME CHANGES *************************** if (s.dtStartDate != apt.Start || s.dtStopDate != apt.End) { s.dtStartDate = apt.Start; s.dtStopDate = apt.End; if (s.IsSavable) { bChangesMade = true; } else { MessageBox.Show(s.BrokenRulesText); } } //************************************************************* if (bChangesMade && s.IsDirty) { if (s.IsSavable) { s.Save(); } else { MessageBox.Show(s.BrokenRulesText); } } break; } #endregion #region CASE Workorder case RootObjectTypes.WorkorderItemScheduledUser: { if (AyaBizUtils.Right("Object.WorkorderItemScheduledUser") < (int)SecurityLevelTypes.ReadWrite)//Less than read only instead of NoAccess to catch records where it's zero instead of 1 { //Inform them of their wicked ways and boot them out of here... MessageBox.Show(string.Format( Util.LocaleText.GetLocalizedText("Error.Security.NotAuthorizedToChange"), Util.LocaleText.GetLocalizedText("O.WorkorderItemScheduledUser"))); e.Cancel = true; return; } //New owner? if (gNewResourceID != i.AppliesToObjectID) { bChangesMade = true; } //new time? if (!bChangesMade && (i.StartDateTime != apt.Start || i.EndDateTime != apt.End)) { bChangesMade = true; } //Update if required. if (bChangesMade) { //Load up workorder and make the changes Workorder w = Workorder.GetItemNoMRU(i.WorkorderID); //Change: 13-July-2006 shouldn't allow changing a locked or read only workorder if (!w.IsEditable) { MessageBox.Show(string.Format( Util.LocaleText.GetLocalizedText("Error.Security.NotAuthorizedToChange"), Util.LocaleText.GetLocalizedText("O.Workorder"))); e.Cancel = true; return; } 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; if (w.IsDirty) { if (w.IsSavable) { w.Save(); } else { MessageBox.Show(w.BrokenRulesText); } } } break; } #endregion } nAppointmentChangeCount++; } #endregion appointment mod events #region custom draw datenavigator bold dates ////case 1548 indicate fetched window ////this is actually not required as it turns out that the start and end date are always outside the visible datenavigator range ////but I'm leaving it here in case it's ever required to draw custom values on certain dates for whatever reason //private void DateNav_CustomDrawDayNumberCell(object sender, DevExpress.XtraEditors.Calendar.CustomDrawDayNumberCellEventArgs e) //{ // if (e.Date.Date == dtStartWindow.Date || e.Date.Date == dtEndWindow.Date) // { // e.Graphics.FillRectangle(Brushes.Red, e.Bounds); // e.Graphics.DrawString(e.Date.Day.ToString(), e.Style.Font, Brushes.White, e.Bounds); // e.Handled = true; // } //} #endregion custom draw datenavigator #endregion #region object creation edit etc /// /// Iterate through selected items and build a list of unique work order id's /// private List SelectedWorkOrderList { get { List l = new List(); int nSelectedCount = sc.SelectedAppointments.Count; if (nSelectedCount == 0) return l; for (int x = 0; x < nSelectedCount; x++) { if (sc.SelectedAppointments[x].CustomFields["AyaInfo"] != null) { AppointmentList.AppointmentListInfo i = (AppointmentList.AppointmentListInfo)sc.SelectedAppointments[x].CustomFields["AyaInfo"]; if (i.SourceObjectType == RootObjectTypes.WorkorderItemScheduledUser) { if (!l.Contains(i.WorkorderID)) l.Add(i.WorkorderID); } } } return l; } } /// /// /// /// private bool AddUserToActiveWorkorder() { if (iLastSelected.SourceObjectType != RootObjectTypes.WorkorderItemScheduledUser) return false; Workorder w = Workorder.GetItemNoMRU(iLastSelected.WorkorderID); //Case 475 if (w.Closed || w.ServiceCompleted || AyaBizUtils.Right("Object.WorkorderService") < (int)SecurityLevelTypes.ReadWrite || AyaBizUtils.Right("Object.WorkorderItemScheduledUser") < (int)SecurityLevelTypes.ReadWrite) { MessageBox.Show(string.Format( Util.LocaleText.GetLocalizedText("Error.Security.NotAuthorizedToChange"), Util.LocaleText.GetLocalizedText("O.Workorder"))); BindData(true); return false; } WorkorderItem wi = w.WorkorderItems[iLastSelected.WorkorderItemID.ToString()]; WorkorderItemScheduledUser wisu = wi.ScheduledUsers.Add(wi); // Guid gUserID; //Day view always knows what day or time slot is selected //even when it's not visible so ... 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( (decimal)ts.TotalHours, 2, MidpointRounding.AwayFromZero); //case 1140 Util.ShowSchedTechOutsideRegionWarning(wisu.UserID, w.ClientID); if (w.IsDirty) { if (w.IsSavable) { w.Save(); BindData(true); return true; } else { MessageBox.Show(w.BrokenRulesText); return false; } } return false; } /// /// Edit whatever appointment is current selected /// private void EditAppointment() { if (sc.SelectedAppointments.Count > 0) EditAppointment(sc.SelectedAppointments[0]); } /// /// Edit passed in appointment /// /// private void EditAppointment(Appointment apt) { if (apt.CustomFields == null || apt.CustomFields["AyaInfo"] == null) return; AppointmentList.AppointmentListInfo i = (AppointmentList.AppointmentListInfo)apt.CustomFields["AyaInfo"]; switch (i.SourceObjectType) { case RootObjectTypes.ScheduleMarker: ScheduleMarker s = ScheduleMarker.GetItem(i.SourceObjectID); ScheduleMarkerForm f = new ScheduleMarkerForm(); f.ScheduleMarkerToEdit = s; f.ShowDialog(); if (f.ChangesMade) BindData(true); f.Dispose(); break; case RootObjectTypes.WorkorderItemScheduledUser: if (AyaBizUtils.Lite) { WorkorderFormLite wfl = new WorkorderFormLite(); Workorder w = Workorder.GetItem(i.WorkorderID); wfl.WorkorderToEdit = w; wfl.GoTo = RootObjectTypes.WorkorderItemScheduledUser; wfl.GoToWorkorderItemID = i.WorkorderItemID; wfl.GoToWorkorderItemSubItemID = i.SourceObjectID; wfl.ShowDialog(); wfl.Dispose(); } else { //Case 677 WorkorderForm wf = Util.GetWorkorderForm(i.WorkorderID); if (wf.WorkorderToEdit == null) { Workorder w = Workorder.GetItem(i.WorkorderID); wf.WorkorderToEdit = w; wf.GoTo = RootObjectTypes.WorkorderItemScheduledUser; wf.GoToWorkorderItemID = i.WorkorderItemID; wf.GoToWorkorderItemSubItemID = i.SourceObjectID; } wf.Show(); } //if (wf.ChangesMade) // BindData(); //wf.Dispose(); // SetActiveWorkorderItem(); break; } } /// /// Make new work order based on selected info /// private void NewWorkorder() { if (AyaBizUtils.Right("Object.WorkorderService") < (int)SecurityLevelTypes.ReadWrite || AyaBizUtils.Right("Object.WorkorderItemScheduledUser") < (int)SecurityLevelTypes.ReadWrite) { //case 1039 //log.Debug("Insufficient rights to create new workorder."); return; } //Get which client first... ClientSelector c = new ClientSelector(WorkorderTypes.TemplateService); DialogResult result = c.ShowDialog(); if (result == DialogResult.Cancel) return; Workorder w = null; try { if (c.SelectedTemplateID != Guid.Empty) w = Workorder.NewItem(c.SelectedTemplateID, c.SelectedClientID); else w = Workorder.NewItem(WorkorderTypes.Service); } catch (TrialException ex) { ex.ToString(); Util.PromptRestricted(); return; } w.ClientID = c.SelectedClientID; WorkorderItemScheduledUser wisu = w.WorkorderItems[0].ScheduledUsers.Add(w.WorkorderItems[0]); wisu.StartDate = sc.SelectedInterval.Start; wisu.StopDate = sc.SelectedInterval.End; //case 824: fill in estimated time automatically as in workorder form if (wisu.StartDate != wisu.StopDate) { DateTime dtStart = (DateTime)wisu.StartDate; DateTime dtStop = (DateTime)wisu.StopDate; TimeSpan ts = dtStop.Subtract(dtStart); wisu.EstimatedQuantity = decimal.Round( (decimal)ts.TotalHours, 2, MidpointRounding.AwayFromZero ); } //if created from merged view then the selected resource ID is actually a devexpress //object, not a guid string as is used for our stuff if (sc.SelectedResource.Id is string) wisu.UserID = new Guid(sc.SelectedResource.Id.ToString()); //case 1140 Util.ShowSchedTechOutsideRegionWarning(wisu.UserID, w.ClientID); if (AyaBizUtils.Lite)//case 1172 { WorkorderFormLite wfl = new WorkorderFormLite(); wfl.WorkorderToEdit = w; wfl.GoTo = RootObjectTypes.WorkorderItemScheduledUser; wfl.GoToWorkorderItemID = w.WorkorderItems[0].ID; wfl.GoToWorkorderItemSubItemID = wisu.ID; wfl.ShowDialog(); wfl.Dispose(); } else { WorkorderForm wf = new WorkorderForm(); wf.WorkorderToEdit = w; wf.GoTo = RootObjectTypes.WorkorderItemScheduledUser; wf.GoToWorkorderItemID = w.WorkorderItems[0].ID; wf.GoToWorkorderItemSubItemID = wisu.ID; //case 677 wf.Show(); } //if (wf.ChangesMade) //{ // BindData(); //} //wf.Dispose(); } /// /// Make new schedulemarker based on selected info /// private void NewScheduleMarker() { if (AyaBizUtils.Right("Object.ScheduleMarker") < (int)SecurityLevelTypes.ReadWrite) { //case 1039 //log.Debug("Insufficient rights to create new ScheduleMarker."); return; } ScheduleMarker s = ScheduleMarker.NewItem(); s.StartDate = sc.SelectedInterval.Start; s.StopDate = sc.SelectedInterval.End; //Case 788 //if created from merged view then the selected resource ID is actually a devexpress //object, not a guid string as is used for our stuff if (sc.SelectedResource.Id is string) { s.SourceID = new Guid(sc.SelectedResource.Id.ToString()); s.ScheduleMarkerSourceType = ScheduleMarkerSourceTypes.User; } ScheduleMarkerForm f = new ScheduleMarkerForm(); f.ScheduleMarkerToEdit = s; f.ShowDialog(); if (f.ChangesMade) BindData(true); } #endregion #region Fill ScheduleableUserGroup list combo private void FillScheduleableUserGroupList() { if (AyaBizUtils.Lite) return; //case 1039 //log.Debug("FillScheduleableUserGroupList"); ComboBoxTool cbt = (ComboBoxTool)ToolBarManager.Tools["LT:UI.Toolbar.Schedule.SelectScheduleableUserGroup"]; 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 if (User.GetItem(User.CurrentThreadUserID).IsScheduleable) { cbt.ValueList.ValueListItems.Add(Guid.Empty, "(" + Thread.CurrentPrincipal.Identity.Name + ")"); } //NVCHANGED GenericNVList l = GenericNVList.GetList("aScheduleableUserGroup", "aID", "aName", true, true, false); //Loop through the items in the list and put them //into the combo box for (int x = 0; x < l.Count; x++) { cbt.ValueList.ValueListItems.Add(new Guid(((DictionaryEntry)l.BindableList[x]).Key.ToString()), ((DictionaryEntry)l.BindableList[x]).Value.ToString()); } cbt.SelectedIndex = 0; bool bSelectedExists = false; foreach (ValueListItem vi in cbt.ValueList.ValueListItems) { if ((Guid)vi.DataValue == mSelectedUserGroupID) { cbt.SelectedItem = vi; bSelectedExists = true; break; } } if (!bSelectedExists) { //selected item no longer exists, might be one that was deleted //between user sessions, for safety set default to all mSelectedUserGroupID = ScheduleableUserGroup.AllUsersGroupID; } } #endregion #region Custom painting #pragma warning disable 618 /// /// Only way to turn off all popup menus /// /// /// private void sc_PreparePopupMenu(object sender, PreparePopupMenuEventArgs e) { e.Menu.Items.Clear(); } #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) { return; } 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) clAppointmentBackground = SystemColors.Highlight; Color clPriorityColour = SystemColors.Window; if (i.BackColorARGB != 0) clPriorityColour = Color.FromArgb(i.BackColorARGB); if (i.SourceObjectType == RootObjectTypes.WorkorderItemScheduledUser) { Rectangle rBack = e.Bounds; rBack.Width = nBackWidth; Rectangle rectPriorityArea = rBack; rectPriorityArea.Height = rectPriorityArea.Height / 2; Rectangle rectAppointmentBackground = new Rectangle(e.Bounds.X + nBackWidth, e.Bounds.Y, e.Bounds.Width - nBackWidth, e.Bounds.Height); 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); //case 852 separator footer at bottom of appointment Rectangle rectFooter = new Rectangle(e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 1, e.Bounds.Width, 1); e.Cache.FillRectangle(System.Drawing.Brushes.Gray, rectFooter); e.Handled = true; } else { 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 r.Inflate(-3, -3); e.Cache.FillRectangle(System.Drawing.Brushes.White, r); e.Handled = true; } } /// /// Draw Appointment face /// /// /// private void sc_CustomDrawAppointment(object sender, CustomDrawObjectEventArgs e) { DevExpress.XtraScheduler.Drawing.AppointmentViewInfo aptinfo = (DevExpress.XtraScheduler.Drawing.AppointmentViewInfo)e.ObjectInfo; if (aptinfo.Appointment.CustomFields == null) return; object info = aptinfo.Appointment.CustomFields["AyaInfo"]; if (info == null) return; AppointmentList.AppointmentListInfo i = (AppointmentList.AppointmentListInfo)info; bool bIsHorizontal = (aptinfo is DevExpress.XtraScheduler.Drawing.HorizontalAppointmentViewInfo); int nStatusWidth = 16;//16 for the status and 16 for the priority flag if (bIsHorizontal) nStatusWidth = 5;//status width //Create a text area to write text in which excludes the status and priority area Rectangle rTextArea = e.Bounds; rTextArea.X += nStatusWidth; rTextArea.Width -= nStatusWidth; //make it a tiny bit smaller to avoid text at the edges //and priority bar across top rTextArea.Y += 5; rTextArea.X += 2; rTextArea.Width -= 2; 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) { if (bIsHorizontal) { Rectangle ir = new Rectangle(rTextArea.X, e.Bounds.Y, e.Bounds.Width, 4); Brush brPriority = e.Cache.GetGradientBrush(ir, Color.White, Color.FromArgb(i.PriorityARGB), System.Drawing.Drawing2D.LinearGradientMode.Horizontal); //case 739 e.Cache.FillRectangle(brPriority, ir); } else { 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.Handled = true; } else { if (bIsHorizontal) { ; } else { 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.Handled = true; } } void FillRoundedRect(DevExpress.Utils.Paint.XPaint xp, Graphics gr, Brush br, Rectangle r, int roundRadius) { using (System.Drawing.Region rgn = new System.Drawing.Region(CreateRoundedRectPath(r, roundRadius))) { 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))) { gr.FillRegion(br, rgn); } } static public GraphicsPath CreateRoundedRectPath(Rectangle r, int radius) { GraphicsPath path = new GraphicsPath(); path.AddLine(r.Left + radius, r.Top, r.Left + r.Width - radius * 2, r.Top); path.AddArc(r.Left + r.Width - radius * 2, r.Top, radius * 2, radius * 2, 270, 90); path.AddLine(r.Left + r.Width, r.Top + radius, r.Left + r.Width, r.Top + r.Height - radius * 2); path.AddArc(r.Left + r.Width - radius * 2, r.Top + r.Height - radius * 2, radius * 2, radius * 2, 0, 90); path.AddLine(r.Left + r.Width - radius * 2, r.Top + r.Height, r.Left + radius, r.Top + r.Height); path.AddArc(r.Left, r.Top + r.Height - radius * 2, radius * 2, radius * 2, 90, 90); path.AddLine(r.Left, r.Top + r.Height - radius * 2, r.Left, r.Top + radius); path.AddArc(r.Left, r.Top, radius * 2, radius * 2, 180, 90); path.CloseFigure(); return path; } #endregion #region case 701 autorefresh schedule timer private void SchedRefreshTimer_Tick(object sender, EventArgs e) { SchedRefreshTimer.Stop(); if (MouseButtons == MouseButtons.None)// Case 731 BindData(true); SchedRefreshTimer.Start(); } #endregion #region Date range changed event double nMaxWindow = 0; // double nCurrentWindow = 0; private void sc_VisibleIntervalChanged(object sender, EventArgs e) { //System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString() + "sc_VisibleIntervalChanged fired"); BindData(); } /// /// Check if the next fetch window really needs to be fetched /// /// 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"); return false; } //case 3892 //void DayView_TopRowTimeChanged(object sender, DevExpress.XtraScheduler.Native.ChangeEventArgs e) //{ // System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString() + "DayView_TopRowTimeChanged fired"); // BindData(); //} #endregion date range change #region case 812 selected appointments public System.Collections.Generic.List SelectedAppointments { get { System.Collections.Generic.List apts = new List(); 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 VisibleUsers { get { System.Collections.Generic.List usrs = new List(); 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 }//EOC public class MyDateNavigator : DevExpress.XtraScheduler.DateNavigator { public DateTime MyStartDate { get { return this.StartDate; } } public DateTime MyEndDate { get { return this.EndDate; } } } }