protected override void ActivateView(string viewName, System.Collections.Generic.IDictionary <string, object> viewParameters) { try { IsNew = (bool)viewParameters["New"]; } catch (KeyNotFoundException) { } var planningGroup = (PlanningGroup)viewParameters["PlanningGroup"]; if (planningGroup != null) { PlanningGroup = planningGroup; } ReportControl = new ReportControlViewModel(); if (planningGroup != null) { ReportControl.CurrentPlanningGroupId = planningGroup.PlanningGroupId; } ReportControl.LoadReportsForView((int)ReportViews.PlanningGroup, ReportService); RaisePropertyChanged(() => ReportControl); try { var profitCenterOrganization = (Organization)viewParameters["Organization"]; if (profitCenterOrganization != null) { CurrentProfitCenter = new ProfitCenter() { Name = profitCenterOrganization.Name, ProfitCenterNumber = profitCenterOrganization.ExternalId }; } } catch (KeyNotFoundException) { } }
protected override void ActivateView(string viewName, System.Collections.Generic.IDictionary <string, object> viewParameters) { StartPerformanceTimer(); string view = ""; DateTime?period = null; Employee employee = null; DateTime?searchDate = null; object value = null; if (viewParameters.TryGetValue("New", out value)) { IsNew = (bool)value; } if (viewParameters.ContainsKey("NewProfitCenter")) { NewOrganizationCreated = (Organization)viewParameters["NewProfitCenter"]; } employee = (Employee)viewParameters["Employee"]; // Check if any specific view should be set as active if (viewParameters.ContainsKey("SelectedView")) { view = viewParameters["SelectedView"].ToString(); } // Check if a period should be loaded if (viewParameters.ContainsKey("Period") && viewParameters["Period"].ToString().Length > 0) { DateTime result; DateTime.TryParse(viewParameters["Period"].ToString(), out result); period = result; } if (viewParameters.ContainsKey("SearchDate") && viewParameters["SearchDate"] != null && viewParameters["SearchDate"].ToString().Length > 0) { DateTime result; DateTime.TryParse(viewParameters["SearchDate"].ToString(), out result); searchDate = result; } ReportControl = new ReportControlViewModel(); if (employee != null) { ReportControl.CurrentEmployeeNumber = employee.EmployeeNumberStr; ReportControl.CurrentEmployeeId = employee.EmployeeId; } ReportControl.LoadReportsForView((int)ReportViews.Employee, ReportService); RaisePropertyChanged(() => ReportControl); // Sanity check! if (employee == null) { return; } // Check if new or existing employee if (employee.EmployeeId > 0) { // Load employee from server LoadEmployee(employee.EmployeeId, searchDate, () => SetActiveView(view, period)); } else { // New employee Employee = employee; LoadChildViewmodels(); // Select first view if (_childVM != null && _childVM.Count > 0) { SelectedView = _childVM[0]; } } }