void btnRefresh_Click(object sender, EventArgs e) { CaptureOrderIDs(); Entities.TrafficSheetFilter _filter = GetFilter(); _filter.FilterStartDate = dteStartDate.SelectedDate.Value; _filter.FilterEnddate = dteEndDate.SelectedDate.Value; _filter.BusinessTypes.Clear(); foreach (int businessTypeID in BusinessTypeIDs) { _filter.BusinessTypes.Add(businessTypeID); } _filter.TrafficAreaIDs.Clear(); foreach (ListItem li in cblTrafficAreas.Items) { if (li.Selected) { _filter.TrafficAreaIDs.Add(int.Parse(li.Value)); } } SetCookie(_filter); // Store the selected surcharge and service level ids. Session[C_SELECTED_SURCHARGES] = this.SurchargeIDs; Session[C_SELECTED_SERVICE_LEVELS] = this.ServiceLevelIDs; grdDeliveries.Rebind(); }
private Entities.TrafficSheetFilter GetDefaultFilter() { Facade.ITrafficSheetFilter facTrafficSheetFilter = new Facade.Traffic(); Entities.TrafficSheetFilter ts = facTrafficSheetFilter.GetDefault(((Entities.CustomPrincipal)Page.User).IdentityId); return(ts); }
public static Entities.TrafficSheetFilter GetFilterFromCookie(string sessionID, System.Web.HttpRequest Request) { Entities.TrafficSheetFilter f = null; try { string trafficSheetJSON = Request.Cookies[sessionID][C_TRAFFIC_SHEET_JSON]; if (Request.Cookies[sessionID] != null && trafficSheetJSON != null) { if (trafficSheetJSON.Length > 0) { f = JsonConvert.DeserializeObject <Entities.TrafficSheetFilter>(trafficSheetJSON); } } return(f); } catch (Exception ex) { } return(f); }
private void BindTrafficSheetFilter(Entities.TrafficSheetFilter filter) { txtFilterName.Text = filter.FilterName; SelectItem(cboFilters.Items, filter.FilterId); cboControlArea.ClearSelection(); SelectItem(cboControlArea.Items, filter.ControlAreaId); cboTrafficAreas.ClearSelection(); foreach (var taid in filter.TrafficAreaIDs) { SelectItem(cboTrafficAreas.Items, taid); } cboDepot.ClearSelection(); cboDepot.Items.FindByValue(filter.DepotId.ToString()).Selected = true; chkOnlyShowJobsWithDemurrage.Checked = filter.OnlyShowJobsWithDemurrage; chkOnlyShowJobsWithDemurrageAwaitingAcceptance.Checked = filter.OnlyShowJobsWithDemurrageAwaitingAcceptance; chkOnlyShowJobsWithPCVs.Checked = filter.OnlyShowJobsWithPCVs; for (int i = 0; i < filter.JobStates.Count; i++) { chkJobStates.Items.FindByValue(Utilities.UnCamelCase(Enum.Parse(typeof(eJobState), filter.JobStates[i].ToString()).ToString())).Selected = true; } cblBusinessType.ClearSelection(); foreach (int i in filter.BusinessTypes) { cblBusinessType.Items.FindByValue(i.ToString()).Selected = true; } }
private void ConfigureDefaultFilter() { Facade.ITrafficSheetFilter facFilters = new Facade.Traffic(); m_trafficSheetFilter = facFilters.GetDefault(((Entities.CustomPrincipal)Page.User).IdentityId); if (m_isJobSheet && m_jobSheetMode != eJobSheetMode.Normal) { switch (m_jobSheetMode) { case eJobSheetMode.Planning: m_trafficSheetFilter.JobStates.Add(eJobState.Booked); break; case eJobSheetMode.Completed: m_trafficSheetFilter.JobStates.Add(eJobState.Completed); m_trafficSheetFilter.JobStates.Add(eJobState.BookingInComplete); m_trafficSheetFilter.JobStates.Add(eJobState.BookingInIncomplete); m_trafficSheetFilter.JobStates.Add(eJobState.ReadyToInvoice); m_trafficSheetFilter.JobStates.Add(eJobState.Invoiced); break; } } else { m_trafficSheetFilter.JobStates.Add(eJobState.Booked); m_trafficSheetFilter.JobStates.Add(eJobState.Planned); m_trafficSheetFilter.JobStates.Add(eJobState.InProgress); } BindData(); }
private void UseDefaultFilter() { Facade.ITrafficSheetFilter facTrafficSheetFilter = new Facade.Traffic(); m_trafficSheetFilter = facTrafficSheetFilter.GetDefault(((Entities.CustomPrincipal)Page.User).IdentityId); // Configure the default dates. // Default dates are from the start of today until: // 1) On a Saturday, until the end of Monday. // 2) On any other day, until the end of tomorrow. DateTime startOfToday = DateTime.Now; startOfToday = startOfToday.Subtract(startOfToday.TimeOfDay); DateTime endOfTomorrow = startOfToday.Add(new TimeSpan(1, 23, 59, 59)); m_trafficSheetFilter.FilterStartDate = startOfToday; if (startOfToday.DayOfWeek == DayOfWeek.Saturday) { DateTime endOfMonday = startOfToday.Add(new TimeSpan(2, 23, 59, 59)); m_trafficSheetFilter.FilterEnddate = endOfMonday; } else { m_trafficSheetFilter.FilterEnddate = endOfTomorrow; } BindJobData(); }
void btnRefresh_Click(object sender, EventArgs e) { CaptureOrderIDs(); Entities.TrafficSheetFilter _filter = Utilities.GetFilterFromCookie(this.CookieSessionID, Request); _filter.FilterStartDate = dteStartDate.SelectedDate.Value.Subtract(dteStartDate.SelectedDate.Value.TimeOfDay); _filter.FilterEnddate = dteEndDate.SelectedDate.Value; _filter.BusinessTypes.Clear(); foreach (ListItem li in cblBusinessTypes.Items) { if (li.Selected) { _filter.BusinessTypes.Add(int.Parse(li.Value)); } } _filter.TrafficAreaIDs.Clear(); Facade.ITrafficArea facTrafficArea = new Facade.Traffic(); foreach (ListItem li in cblTrafficAreas.Items) { if (li.Selected) { _filter.TrafficAreaIDs.Add(int.Parse(li.Value)); } } SetCookie(_filter); // Persist the checkbox selection value to session. Session[C_ONLYSHOWNONCOLLECTED] = chkShowUnPlannedOnly.Checked; grdOrders.Rebind(); }
private void PopulateStaticControls() { if (Orchestrator.Globals.Configuration.UseControlAreaToFilterPCVsForReport) { Facade.ITrafficSheetFilter facTrafficSheetFilter = new Facade.Traffic(); Entities.TrafficSheetFilter defaultFilter = facTrafficSheetFilter.GetDefault(((Entities.CustomPrincipal)Page.User).IdentityId); Facade.IControlArea facControlArea = new Facade.Traffic(); cboControlAreas.DataSource = facControlArea.GetAll(); cboControlAreas.DataBind(); if (defaultFilter == null) { cboControlAreas.SelectedIndex = 0; } else { cboControlAreas.SelectedValue = defaultFilter.ControlAreaId.ToString(); } } //rdiSlotDate.SelectedDate = DateTime.Today; //rdiSlotTime.SelectedDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 23, 59, 0); rdiSlotDate.SelectedDate = null; rdiSlotTime.SelectedDate = null; }
private void BindDefaultFilter() { Entities.TrafficSheetFilter defaultFilter = GetDefaultFilter(); if (defaultFilter != null) { BindTrafficSheetFilter(defaultFilter); } }
Entities.TrafficSheetFilter GetFilter() { Entities.TrafficSheetFilter _filter = Utilities.GetFilterFromCookie(this.CookieSessionID, Request); if (_filter == null) { _filter = GetDefaultFilter(); } return(_filter); }
private void BindDefaultFilter() { m_trafficSheetFilter = GetDefaultFilter(); if (m_trafficSheetFilter != null) { BindTrafficSheetFilter(m_trafficSheetFilter); } }
private void GetDates() { Entities.TrafficSheetFilter _filter = Utilities.GetFilterFromCookie(this.CookieSessionID, Request); if (_filter != null) { if (_filter.FilterStartDate == DateTime.MinValue) { dteStartDate.SelectedDate = DateTime.Today.Subtract(DateTime.Now.TimeOfDay); dteEndDate.SelectedDate = DateTime.Today.AddDays(1); } else { dteStartDate.SelectedDate = _filter.FilterStartDate; dteEndDate.SelectedDate = _filter.FilterEnddate; } cblTrafficAreas.ClearSelection(); if (_filter.TrafficAreaIDs.Any()) { foreach (ListItem li in cblTrafficAreas.Items) { if (_filter.TrafficAreaIDs.Exists(i => i.ToString().Equals(li.Value))) { li.Selected = true; } } } cblBusinessTypes.ClearSelection(); if (_filter.BusinessTypes.Count > 0) { foreach (ListItem li in cblBusinessTypes.Items) { if (_filter.BusinessTypes.Contains(int.Parse(li.Value))) { li.Selected = true; } } } } else { _filter = GetDefaultFilter(); _filter.FilterStartDate = DateTime.Today.Subtract(DateTime.Today.TimeOfDay); _filter.FilterEnddate = DateTime.Today.AddDays(1); SetCookie(_filter); dteStartDate.SelectedDate = DateTime.Today; dteEndDate.SelectedDate = DateTime.Today.AddDays(1); if (!string.IsNullOrEmpty(Request.QueryString["BT"])) { cblBusinessTypes.Items.FindByValue(Request.QueryString["BT"]).Selected = true; } } }
private void SetCookie() { if (Filter == null) { Filter = new Entities.TrafficSheetFilter(); } Filter = this.PopulateFilter(Filter); Utilities.SetTrafficSheetCookie(this.CookieSessionID, Response, Filter); }
private void SetFilter() { m_trafficSheetFilter = Utilities.GetFilterFromCookie(this.CookieSessionID, this.Request); if (m_trafficSheetFilter == null) { Facade.ITrafficSheetFilter facFilter = new Facade.Traffic(); m_trafficSheetFilter = facFilter.GetDefault(((Entities.CustomPrincipal)Page.User).IdentityId); } // Configure the filter m_trafficSheetFilter.ControlAreaId = Convert.ToInt32(cboControlArea.SelectedValue); m_trafficSheetFilter.TrafficAreaIDs.Clear(); foreach (ListItem item in cboTrafficAreas.Items) { if (item.Selected) { m_trafficSheetFilter.TrafficAreaIDs.Add(Convert.ToInt32(item.Value)); } } m_trafficSheetFilter.FilterOutExcludedPoints = false; m_trafficSheetFilter.JobStates.Clear(); foreach (ListItem item in chkJobStates.Items) { if (item.Selected) { m_trafficSheetFilter.JobStates.Add(Enum.Parse(typeof(eJobState), item.Value.Replace(" ", ""))); } } m_trafficSheetFilter.OnlyShowMyJobs = false; m_trafficSheetFilter.OnlyShowJobsWithDemurrage = chkOnlyShowJobsWithDemurrage.Checked; m_trafficSheetFilter.OnlyShowJobsWithDemurrageAwaitingAcceptance = chkOnlyShowJobsWithDemurrageAwaitingAcceptance.Checked; m_trafficSheetFilter.FilterStartDate = (DateTime)dteStartDate.SelectedDate; m_trafficSheetFilter.FilterEnddate = ((DateTime)dteEndDate.SelectedDate).Add(new TimeSpan(23, 59, 59)); m_trafficSheetFilter.DepotId = int.Parse(cboDepot.SelectedValue); m_trafficSheetFilter.BusinessTypes.Clear(); foreach (ListItem li in cblBusinessType.Items) { if (li.Selected) { m_trafficSheetFilter.BusinessTypes.Add(int.Parse(li.Value)); } } SetCookie(m_trafficSheetFilter); }
/// <summary> /// The users wishes to save the filter. /// </summary> void btnSaveFilter_Click(object sender, EventArgs e) { btnSaveFilter.DisableServerSideValidation(); if (Page.IsValid) { Facade.ITrafficSheetFilter facTrafficSheetFilter = new Facade.Traffic(); var user = (Entities.CustomPrincipal)Page.User; Entities.TrafficSheetFilter filter = null; var isUpdate = false; if (cboFilters.SelectedValue != "0" && cboFilters.SelectedItem.Text == txtFilterName.Text) { // We are going to update the old version of the filter. isUpdate = true; filter = facTrafficSheetFilter.GetForTrafficSheetFilterId(Convert.ToInt32(cboFilters.SelectedValue)); } else { filter = new Entities.TrafficSheetFilter(user.IdentityId) { FilterName = txtFilterName.Text }; } filter.FilterOutExcludedPoints = false; filter.TrafficSheetGrouping = eTrafficSheetGrouping.None; filter.TrafficSheetSorting = eTrafficSheetSorting.EarliestLeg; this.PopulateFilter(filter); Facade.ITrafficArea facTrafficArea = new Facade.Traffic(); if (isUpdate) { ((Facade.ITrafficSheetFilter)facTrafficArea).Update(filter, user.UserName); } else { filter.FilterId = ((Facade.ITrafficSheetFilter)facTrafficArea).Create(filter, user.UserName); } PopulateFilterList(); cboFilters.ClearSelection(); SelectItem(cboFilters.Items, filter.FilterId); Filter = filter; SetCookie(); ReturnValue = "filterupdated"; } }
private bool GetValuesFromCookie() { try { Entities.TrafficSheetFilter filter = Utilities.GetFilterFromCookie(this.CookieSessionID, this.Request); if (filter != null) { m_controlAreaId = filter.ControlAreaId; } return(true); } catch { return(false); } }
private void LoadDefaultFilter() { int identityId = ((Entities.CustomPrincipal)Page.User).IdentityId; Facade.ITrafficSheetFilter facTrafficSheetFilter = new Facade.Traffic(); m_trafficSheetFilter = Utilities.GetFilterFromCookie(this.CookieSessionID, Request); if (m_trafficSheetFilter == null) { m_trafficSheetFilter = facTrafficSheetFilter.GetDefault(identityId); } if (m_trafficSheetFilter.LastUpdated == DateTime.MinValue || DateTime.Today.Subtract(m_trafficSheetFilter.LastUpdated).Days >= 1) { // Configure the default dates. // Default dates are from the start of today until: // 1) On a Saturday, until the end of Monday. // 2) On any other day, until the end of tomorrow. DateTime startOfToday = DateTime.Now; startOfToday = startOfToday.Subtract(startOfToday.TimeOfDay); DateTime endOfTomorrow = startOfToday.Add(new TimeSpan(1, 23, 59, 59)); m_trafficSheetFilter.FilterStartDate = startOfToday; if (startOfToday.DayOfWeek == DayOfWeek.Saturday) { DateTime endOfMonday = startOfToday.Add(new TimeSpan(2, 23, 59, 59)); m_trafficSheetFilter.FilterEnddate = endOfMonday; } else { m_trafficSheetFilter.FilterEnddate = endOfTomorrow; } m_trafficSheetFilter.LastUpdated = DateTime.Now; } if (m_jobSheetMode == eJobSheetMode.Completed || m_jobSheetMode == eJobSheetMode.Planning) { ConfigureDefaultFilter(); } BindData(m_trafficSheetFilter); }
/// <summary> /// The user has selected one of their previously saved filters. /// </summary> void cboFilters_SelectedIndexChanged(object sender, EventArgs e) { int trafficSheetFilterId = Convert.ToInt32(cboFilters.SelectedValue); if (trafficSheetFilterId == 0) { // This is the "blank filter" setting. cboControlArea.ClearSelection(); cboTrafficAreas.ClearSelection(); cboDepot.SelectedIndex = 0; txtFilterName.Text = string.Empty; } else { // Load the filter and configure the textbox to allow saving a new version Facade.ITrafficSheetFilter facTrafficSheetFilter = new Facade.Traffic(); Entities.TrafficSheetFilter selectedFilter = facTrafficSheetFilter.GetForTrafficSheetFilterId(trafficSheetFilterId); BindTrafficSheetFilter(selectedFilter); } }
private void GenerateCookie() { Facade.ITrafficSheetFilter facTrafficSheetFilter = new Facade.Traffic(); _filter = facTrafficSheetFilter.GetDefault(((Entities.CustomPrincipal)Page.User).IdentityId); // 02/05/08 : t.lunken : EH Nicols Additions _filter.OnlyShowDriversWithoutReloads = false; _filter.OnlyShowEmptyTrailers = false; _filter.SortTrailersByLastLocation = false; _filter.OnlyShowEmptyVehicles = false; #region // Configure the default dates. // Default dates are from the start of today until: // 1) On a Saturday, until the end of Monday. // 2) On any other day, until the end of tomorrow. DateTime startOfToday = DateTime.Now; startOfToday = startOfToday.Subtract(startOfToday.TimeOfDay); DateTime endOfTomorrow = startOfToday.Add(new TimeSpan(1, 23, 59, 59)); _filter.FilterStartDate = startOfToday; //ViewState["m_startDate"] = startOfToday; if (startOfToday.DayOfWeek == DayOfWeek.Saturday) { DateTime endOfMonday = startOfToday.Add(new TimeSpan(2, 23, 59, 59)); //ViewState["m_endDate"] = endOfMonday; _filter.FilterEnddate = endOfMonday; } else { _filter.FilterEnddate = endOfTomorrow; } //ViewState["m_endDate"] = endOfTomorrow; #endregion Utilities.SetTrafficSheetCookie(this.CookieSessionID, this.Response, _filter); cookieGenerated = true; }
private bool GetValuesFromCookie() { _filter = Utilities.GetFilterFromCookie(this.CookieSessionID, Request); // 01/05/08 : t.lunken - EH Nichols Addition CheckBox chkShowDriversWithoutReloads = ((CheckBox)this.RadPanelbar1.FindControl("chkShowDriversWithoutReloads")); CheckBox chkOnlyShowEmptyTrailers = ((CheckBox)this.RadPanelbar1.FindControl("chkOnlyShowEmptyTrailers")); CheckBox chkSortTrailersByLastLocation = ((CheckBox)this.RadPanelbar1.FindControl("chkSortTrailersByLastLocation")); CheckBox chkShowEmptyVehiclesOnly = ((CheckBox)this.RadPanelbar1.FindControl("chkShowEmptyVehiclesOnly")); if (_filter.OnlyShowDriversWithoutReloads != chkShowDriversWithoutReloads.Checked) { _filter.OnlyShowDriversWithoutReloads = chkShowDriversWithoutReloads.Checked; SetCookie(_filter); } if (_filter.OnlyShowEmptyTrailers != chkOnlyShowEmptyTrailers.Checked) { _filter.OnlyShowEmptyTrailers = chkOnlyShowEmptyTrailers.Checked; SetCookie(_filter); } if (_filter.SortTrailersByLastLocation != chkSortTrailersByLastLocation.Checked) { _filter.SortTrailersByLastLocation = chkSortTrailersByLastLocation.Checked; SetCookie(_filter); } if (_filter.OnlyShowEmptyVehicles != chkShowEmptyVehiclesOnly.Checked) { _filter.OnlyShowEmptyVehicles = chkShowEmptyVehiclesOnly.Checked; SetCookie(_filter); } chkShowDriversWithoutReloads.Checked = _filter.OnlyShowDriversWithoutReloads; chkOnlyShowEmptyTrailers.Checked = _filter.OnlyShowEmptyTrailers; chkSortTrailersByLastLocation.Checked = _filter.SortTrailersByLastLocation; chkShowEmptyVehiclesOnly.Checked = _filter.OnlyShowEmptyVehicles; return(true); }
private void UseDefaultFilter() { try { _filter = Utilities.GetFilterFromCookie(this.CookieSessionID, Request); // Set the Filters ((CheckBox)this.RadPanelbar1.FindControl("chkShowDriversWithoutReloads")).Checked = _filter.OnlyShowDriversWithoutReloads; ((CheckBox)this.RadPanelbar1.FindControl("chkOnlyShowEmptyTrailers")).Checked = _filter.OnlyShowEmptyTrailers; ((CheckBox)this.RadPanelbar1.FindControl("chkSortTrailersByLastLocation")).Checked = _filter.SortTrailersByLastLocation; ((CheckBox)this.RadPanelbar1.FindControl("chkShowEmptyVehiclesOnly")).Checked = _filter.OnlyShowEmptyVehicles; // To ensure that the dates are always valid check here if (_filter.FilterStartDate == DateTime.MinValue) { GenerateCookie(); } } catch { // invalid or old values stored in the cookie simply regenerate. GenerateCookie(); } }
private void SetCookie(Entities.TrafficSheetFilter ts) { Utilities.SetTrafficSheetCookie(this.CookieSessionID, this.Response, ts); }
/// <summary> /// The users wishes to save the filter. /// </summary> void btnSaveFilter_Click(object sender, EventArgs e) { btnSaveFilter.DisableServerSideValidation(); if (Page.IsValid) { Facade.ITrafficSheetFilter facTrafficSheetFilter = new Facade.Traffic(); Entities.CustomPrincipal user = (Entities.CustomPrincipal)Page.User; Entities.TrafficSheetFilter filter = null; bool isUpdate = false; if (dteStartDate.SelectedDate != null && dteEndDate.SelectedDate == null) { dteEndDate.SelectedDate = ((DateTime)dteStartDate.SelectedDate).AddDays(1).Add(new TimeSpan(23, 59, 59)); } if (cboFilters.SelectedValue != "0" && cboFilters.SelectedItem.Text == txtFilterName.Text) { // We are going to update the old version of the filter. isUpdate = true; filter = facTrafficSheetFilter.GetForTrafficSheetFilterId(Convert.ToInt32(cboFilters.SelectedValue)); } else { filter = new Entities.TrafficSheetFilter(user.IdentityId); filter.FilterName = txtFilterName.Text; } filter.FilterStartDate = (DateTime)dteStartDate.SelectedDate; filter.FilterEnddate = (DateTime)dteEndDate.SelectedDate; // Configure the filter filter.ControlAreaId = Convert.ToInt32(cboControlArea.SelectedValue); filter.TrafficAreaIDs.Clear(); foreach (ListItem item in cboTrafficAreas.Items) { if (item.Selected) { filter.TrafficAreaIDs.Add(Convert.ToInt32(item.Value)); } } filter.FilterOutExcludedPoints = false; filter.TrafficSheetGrouping = eTrafficSheetGrouping.None; filter.TrafficSheetSorting = eTrafficSheetSorting.EarliestLeg; filter.JobStates.Clear(); foreach (ListItem item in chkJobStates.Items) { if (item.Selected) { filter.JobStates.Add(Enum.Parse(typeof(eJobState), item.Value.Replace(" ", ""))); } } filter.BusinessTypes.Clear(); foreach (ListItem li in cblBusinessType.Items) { if (li.Selected) { filter.BusinessTypes.Add((int)int.Parse(li.Value)); } } filter.DepotId = int.Parse(cboDepot.SelectedValue); filter.OnlyShowJobsWithDemurrage = chkOnlyShowJobsWithDemurrage.Checked; filter.OnlyShowJobsWithDemurrageAwaitingAcceptance = chkOnlyShowJobsWithDemurrageAwaitingAcceptance.Checked; filter.OnlyShowJobsWithPCVs = chkOnlyShowJobsWithPCVs.Checked; filter.OnlyShowMyJobs = false; Facade.ITrafficArea facTrafficArea = new Facade.Traffic(); if (isUpdate) { ((Facade.ITrafficSheetFilter)facTrafficArea).Update(filter, user.UserName); } else { filter.FilterId = ((Facade.ITrafficSheetFilter)facTrafficArea).Create(filter, user.UserName); } SetFilter(); PopulateFilterList(); cboFilters.ClearSelection(); SelectItem(cboFilters.Items, filter.FilterId); this.ReturnValue = "refresh"; this.Close(); } }
private void BindTrafficSheetFilter(Entities.TrafficSheetFilter filter) { txtFilterName.Text = filter.FilterName; SelectItem(cboFilters.Items, filter.FilterId); cboControlArea.ClearSelection(); SelectItem(cboControlArea.Items, filter.ControlAreaId); cboTrafficAreas.ClearSelection(); foreach (var trafficAreaID in filter.TrafficAreaIDs) { SelectItem(cboTrafficAreas.Items, trafficAreaID); } cboDepot.ClearSelection(); cboDepot.Items.FindByValue(filter.DepotId.ToString()).Selected = true; chkShowStockMovementJobs.Checked = filter.ShowStockMovementJobs; chkShowPlanned.Checked = filter.ShowPlannedLegs; cblBusinessType.ClearSelection(); foreach (int i in filter.BusinessTypes) { cblBusinessType.Items.FindByValue(i.ToString()).Selected = true; } cblInstructionStates.ClearSelection(); foreach (int i in filter.InstructionStates) { cblInstructionStates.Items.FindByValue(((eInstructionState)i).ToString()).Selected = true; } cblInProgressSubStates.ClearSelection(); if (!filter.InProgressSubStates.Any()) { foreach (ListItem i in cblInProgressSubStates.Items) { i.Selected = true; } } else { foreach (int i in filter.InProgressSubStates) { cblInProgressSubStates.Items.FindByValue(((int)i).ToString()).Selected = true; } } chkSortbyEvent.Checked = filter.SortbyEvent; // MWF Comms States cblMWFCommsStates.ClearSelection(); var states = MWF_Instruction.GetTrafficSheetStatesFromCommunicationStatesFilter(filter.MWFCommsStates); foreach (int i in states) { cblMWFCommsStates.Items.FindByValue(i.ToString()).Selected = true; } // MWF Instruction States cblMWFInstructionStates.ClearSelection(); foreach (int i in filter.MWFInstructionStates) { cblMWFInstructionStates.Items.FindByValue(i.ToString()).Selected = true; } }
private Entities.TrafficSheetFilter PopulateFilter(Entities.TrafficSheetFilter _filter) { Entities.TrafficSheetFilter filter = null; if (_filter == null) { filter = new Entities.TrafficSheetFilter(); } else { filter = _filter; } filter.FilterStartDate = dteStartDate.SelectedDate.Value; filter.FilterEnddate = dteEndDate.SelectedDate.Value.Date.Add(new TimeSpan(23, 59, 59)); filter.ShowPlannedLegs = chkShowPlanned.Checked; filter.ShowStockMovementJobs = chkShowStockMovementJobs.Checked; filter.DepotId = int.Parse(cboDepot.SelectedValue); filter.ControlAreaId = int.Parse(cboControlArea.SelectedValue); filter.SortbyEvent = chkSortbyEvent.Checked; filter.CollapseRuns = chkCollapseRuns.Checked; filter.TrafficAreaIDs.Clear(); foreach (ListItem li in cboTrafficAreas.Items) { if (li.Selected) { filter.TrafficAreaIDs.Add(int.Parse(li.Value)); } } filter.BusinessTypes.Clear(); foreach (ListItem li in cblBusinessType.Items) { if (li.Selected) { filter.BusinessTypes.Add(int.Parse(li.Value)); } } filter.InstructionStates.Clear(); foreach (ListItem li in cblInstructionStates.Items) { if (li.Selected) { filter.InstructionStates.Add((int)Enum.Parse(typeof(eInstructionState), li.Value)); } } filter.InProgressSubStates.Clear(); foreach (ListItem li in cblInProgressSubStates.Items) { if (li.Selected) { filter.InProgressSubStates.Add((Entities.TrafficSheetFilter.eInProgressSubState) int.Parse(li.Value)); } } filter.PlanningCategories.Clear(); foreach (ListItem li in cblPlanningCategory.Items) { if (li.Selected) { filter.PlanningCategories.Add(int.Parse(li.Value)); } } if (chkSelectAllInstructionTypes.Checked) { filter.IncludeMWFInstructions = true; filter.IncludeNonMWFInstructions = true; } else { foreach (ListItem li in cblInstructionType.Items) { switch (li.Text) { case "MWF": filter.IncludeMWFInstructions = li.Selected; break; case "Non-MWF": filter.IncludeNonMWFInstructions = li.Selected; break; } } } filter.MWFCommsStates.Clear(); foreach (ListItem item in cblMWFCommsStates.Items.Cast <ListItem>().Where(item => item.Selected)) { filter.MWFCommsStates.Add(int.Parse(item.Value)); } filter.MWFInstructionStates.Clear(); foreach (ListItem item in cblMWFInstructionStates.Items.Cast <ListItem>().Where(item => item.Selected)) { filter.MWFInstructionStates.Add(int.Parse(item.Value)); } return(filter); }
public static void SetTrafficSheetCookie(string sessionID, System.Web.HttpResponse response, Entities.TrafficSheetFilter filter) { HttpCookie tSheetCookie = new HttpCookie(sessionID); string trafficSheetFilterJSON; trafficSheetFilterJSON = JsonConvert.SerializeObject(filter); tSheetCookie[C_TRAFFIC_SHEET_JSON] = trafficSheetFilterJSON; // Settings option to have the cookie expire daily or never if (Orchestrator.Globals.Configuration.ResetTrafficCookieDaily) { tSheetCookie.Expires = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 23, 59, 59); } else { tSheetCookie.Expires = new DateTime(2099, DateTime.Today.Month, DateTime.Today.Day, 23, 59, 59); } response.SetCookie(tSheetCookie); }
private void PopulateStaticControls() { #region // Configure the min and max dates. dteStartDate.MinDate = new DateTime(2000, 1, 1); dteEndDate.MaxDate = new DateTime(2036, 12, 31); #endregion #region // Populate Control Areas Facade.IControlArea facControlArea = new Facade.Traffic(); cboControlArea.DataSource = facControlArea.GetAll(); cboControlArea.DataBind(); cboControlArea.Items[0].Selected = true; #endregion #region // Populate Traffic Areas Facade.ITrafficArea facTrafficArea = (Facade.ITrafficArea)facControlArea; cboTrafficAreas.DataSource = facTrafficArea.GetAll(); cboTrafficAreas.DataBind(); if (cboTrafficAreas.Items.Count > 8) { divTrafficAreas.Attributes.Add("class", "overflowHandler"); divTrafficAreas.Attributes.Add("style", "height:100px;"); } #endregion #region // Populate Depots Facade.IOrganisationLocation facOrganisationLocation = new Facade.Organisation(); cboDepot.DataSource = facOrganisationLocation.GetAllDepots(Orchestrator.Globals.Configuration.IdentityId); cboDepot.DataBind(); cboDepot.Items.Insert(0, new ListItem("Use Control Area and Traffic Areas to determine resource pool", "0")); #endregion #region // Populate Filters for this user PopulateFilterList(); #endregion #region // Configure the default dates. // Default dates are from the start of today until: // 1) On a Saturday, until the end of Monday. // 2) On any other day, until the end of tomorrow. DateTime startOfToday = DateTime.Now; startOfToday = startOfToday.Subtract(startOfToday.TimeOfDay); DateTime endOfTomorrow = startOfToday.Add(new TimeSpan(1, 23, 59, 59)); DateTime startDate = startOfToday; DateTime endDate = endOfTomorrow; if (startOfToday.DayOfWeek == DayOfWeek.Saturday) { DateTime endOfMonday = startOfToday.Add(new TimeSpan(2, 23, 59, 59)); endDate = endOfMonday; } #endregion #region // Populate the Business Types Facade.IBusinessType facBusinessType = new Facade.BusinessType(); cblBusinessType.DataSource = facBusinessType.GetAll(); cblBusinessType.DataTextField = "Description"; cblBusinessType.DataValueField = "BusinessTypeID"; cblBusinessType.DataBind(); #endregion #region // Populate the Instruction States cblInstructionStates.DataSource = Enum.GetNames(typeof(eInstructionState)); cblInstructionStates.DataBind(); #endregion #region // Populate the In Progress Sub-States cblInProgressSubStates.DataSource = this.InProgressSubStateDescriptions.ToDictionary(kvp => (int)kvp.Key, kvp => kvp.Value); cblInProgressSubStates.DataBind(); #endregion #region // Populate the Planning Categories Types cblPlanningCategory.DataSource = DataContext.PlanningCategorySet.OrderBy(pc => pc.DisplayShort); cblPlanningCategory.DataBind(); var liAll = new ListItem("All", "-1") { Selected = true }; cblPlanningCategory.Items.Add(liAll); #endregion #region // Populate the Instruction Types cblInstructionType.Items.Clear(); var liMWF = new ListItem("MWF", "1"); liMWF.Attributes.Add("onclick", "onInstructionTypeChecked();"); var liNonMWF = new ListItem("Non-MWF", "2"); liNonMWF.Attributes.Add("onclick", "onInstructionTypeChecked();"); cblInstructionType.Items.Add(liMWF); cblInstructionType.Items.Add(liNonMWF); #endregion #region // Populate the MWF Comms Status var list = Enum.GetValues(typeof(MWFCommunicationStatusForTrafficSheetEnum)).Cast <object>().ToDictionary(v => (int)v, v => MWF_Instruction.GetCommunicationStatusForTrafficSheetDescription((int)v)); cblMWFCommsStates.DataSource = list; cblMWFCommsStates.DataBind(); #endregion #region // Populate the MWF Instruction States // Only adding the states that we use for now var list2 = new Dictionary <int, string> { { (int)MWFStatusEnum.Drive, "Drive" }, { (int)MWFStatusEnum.OnSite, "On Site" }, { (int)MWFStatusEnum.Suspend, "Suspend" }, { (int)MWFStatusEnum.Resume, "Resume" }, { (int)MWFStatusEnum.Complete, "Complete" } }; cblMWFInstructionStates.DataSource = list2; cblMWFInstructionStates.DataBind(); #endregion if (Filter == null) { Filter = Utilities.GetFilterFromCookie(this.CookieSessionID, Request); } if (Filter == null) { Filter = GetDefaultFilter(); // Configure the default dates. // Default dates are from the start of today until: // 1) On a Saturday, until the end of Monday. // 2) On any other day, until the end of tomorrow. Filter.FilterStartDate = startOfToday; if (startOfToday.DayOfWeek == DayOfWeek.Saturday) { DateTime endOfMonday = startOfToday.Add(new TimeSpan(2, 23, 59, 59)); Filter.FilterEnddate = endOfMonday; } else { Filter.FilterEnddate = endOfTomorrow; } } cboControlArea.ClearSelection(); SelectItem(cboControlArea.Items, Filter.ControlAreaId); foreach (var taid in Filter.TrafficAreaIDs) { SelectItem(cboTrafficAreas.Items, taid); } startDate = Filter.FilterStartDate; endDate = Filter.FilterEnddate; chkShowPlanned.Checked = Filter.ShowPlannedLegs; chkShowStockMovementJobs.Checked = Filter.ShowStockMovementJobs; cboDepot.ClearSelection(); cboDepot.Items.FindByValue(Filter.DepotId.ToString()).Selected = true; foreach (var i in Filter.BusinessTypes) { try { // P1 use if we try to work on different client's version of Orchestrator // the same cookie is used (domain). cblBusinessType.Items.FindByValue(i.ToString()).Selected = true; } catch { } } foreach (int i in this.Filter.InstructionStates) { cblInstructionStates.Items.FindByValue(((eInstructionState)i).ToString()).Selected = true; } foreach (var ipss in this.Filter.InProgressSubStates) { cblInProgressSubStates.Items.FindByValue(((int)ipss).ToString()).Selected = true; } if (this.Filter.PlanningCategories.Count > 0) { foreach (ListItem li in cblPlanningCategory.Items) { li.Selected = this.Filter.PlanningCategories.Contains(int.Parse(li.Value)); } } this.chkSortbyEvent.Checked = Filter.SortbyEvent; this.chkCollapseRuns.Checked = this.Filter.CollapseRuns; liMWF.Selected = Filter.IncludeMWFInstructions; liNonMWF.Selected = Filter.IncludeNonMWFInstructions; chkSelectAllInstructionTypes.Checked = (liMWF.Selected && liNonMWF.Selected); bool allSelected = false; if (Filter.MWFCommsStates.Count > 0) { allSelected = true; foreach (ListItem li in cblMWFCommsStates.Items) { li.Selected = Filter.MWFCommsStates.Contains(int.Parse(li.Value)); if (!li.Selected) { allSelected = false; } } } chkSelectAllMWFCommsStates.Checked = allSelected; var selected = false; if (Filter.MWFInstructionStates.Count > 0) { selected = true; foreach (ListItem li in cblMWFInstructionStates.Items) { li.Selected = Filter.MWFInstructionStates.Contains(int.Parse(li.Value)); if (!li.Selected) { selected = false; } } } chkSelectAllMWFInstructionStates.Checked = selected; #region // Apply the dates. dteStartDate.SelectedDate = startDate; dteEndDate.SelectedDate = endDate; #endregion }
private void BindData(Entities.TrafficSheetFilter filter) { BindJobData(filter.TrafficSheetGrouping); }
void dlgFilter_DialogCallBack(object sender, EventArgs e) { LoadDefaultFilter(); m_trafficSheetFilter = Utilities.GetFilterFromCookie(this.CookieSessionID, Request); BindData(m_trafficSheetFilter); }
private void PopulateStaticControls() { #region // Populate Control Areas Facade.IControlArea facControlArea = new Facade.Traffic(); cboControlArea.DataSource = facControlArea.GetAll(); cboControlArea.DataBind(); cboControlArea.Items[0].Selected = true; #endregion #region // Populate Traffic Areas Facade.ITrafficArea facTrafficArea = (Facade.ITrafficArea)facControlArea; cboTrafficAreas.DataSource = facTrafficArea.GetAll(); cboTrafficAreas.DataBind(); #endregion #region // Populate Depots Facade.IOrganisationLocation facOrganisationLocation = new Facade.Organisation(); cboDepot.DataSource = facOrganisationLocation.GetAllDepots(Orchestrator.Globals.Configuration.IdentityId); cboDepot.DataBind(); cboDepot.Items.Insert(0, new ListItem("Use Control Area and Traffic Areas to determine resource pool", "0")); #endregion #region // Populate Filters for this user PopulateFilterList(); #endregion #region // Configure the default dates. // Default dates are from the start of today until: // 1) On a Saturday, until the end of Monday. // 2) On any other day, until the end of tomorrow. DateTime startOfToday = DateTime.Now; startOfToday = startOfToday.Subtract(startOfToday.TimeOfDay); DateTime endOfTomorrow = startOfToday.Add(new TimeSpan(1, 23, 59, 59)); DateTime startDate = startOfToday; DateTime endDate = endOfTomorrow; if (startOfToday.DayOfWeek == DayOfWeek.Saturday) { DateTime endOfMonday = startOfToday.Add(new TimeSpan(2, 23, 59, 59)); endDate = endOfMonday; } #endregion #region // Cause the job states to be displayed chkJobStates.DataSource = Utilities.UnCamelCase(Enum.GetNames(typeof(eJobState))); chkJobStates.DataBind(); #endregion #region // Load the Job Types Facade.IBusinessType facBusinessType = new Facade.BusinessType(); cblBusinessType.DataSource = facBusinessType.GetAll(); cblBusinessType.DataTextField = "Description"; cblBusinessType.DataValueField = "BusinessTypeID"; cblBusinessType.DataBind(); #endregion #region React to supplied values bool haveReacted = false; try { Entities.TrafficSheetFilter m_trafficSheetFilter = Utilities.GetFilterFromCookie(this.CookieSessionID, Request); if (m_trafficSheetFilter == null) { m_trafficSheetFilter = GetDefaultFilter(); m_trafficSheetFilter.FilterStartDate = startDate; m_trafficSheetFilter.FilterEnddate = endDate; } cboControlArea.ClearSelection(); SelectItem(cboControlArea.Items, m_trafficSheetFilter.ControlAreaId); haveReacted = true; foreach (var taid in m_trafficSheetFilter.TrafficAreaIDs) { SelectItem(cboTrafficAreas.Items, taid); } for (int i = 0; i < m_trafficSheetFilter.JobStates.Count; i++) { chkJobStates.Items.FindByValue(Utilities.UnCamelCase(Enum.Parse(typeof(eJobState), m_trafficSheetFilter.JobStates[i].ToString()).ToString())).Selected = true; } cboDepot.ClearSelection(); cboDepot.Items.FindByValue(m_trafficSheetFilter.DepotId.ToString()).Selected = true; dteStartDate.SelectedDate = m_trafficSheetFilter.FilterStartDate; dteEndDate.SelectedDate = m_trafficSheetFilter.FilterEnddate; cblBusinessType.ClearSelection(); foreach (int i in m_trafficSheetFilter.BusinessTypes) { cblBusinessType.Items.FindByValue(i.ToString()).Selected = true; } } catch (Exception eX) { Entities.TrafficSheetFilter ts = GetDefaultFilter(); ts.FilterStartDate = startDate; dteStartDate.SelectedDate = startDate; ts.FilterEnddate = endDate; dteEndDate.SelectedDate = endDate; if (Request.Cookies[this.CookieSessionID] == null) { SetCookie(ts); } BindDefaultFilter(); } finally { // Apply the dates. } #endregion }