public IActionResult NewUnit() { var model = new NewUnitView(); model.Unit = new Unit(); model.Types = _unitsService.GetUnitTypesForDepartment(DepartmentId); var states = new List <CustomState>(); states.Add(new CustomState { Name = "Standard Actions" }); states.AddRange(_customStateService.GetAllActiveUnitStatesForDepartment(DepartmentId)); model.States = states; var groups = new List <DepartmentGroup>(); groups.Add(new DepartmentGroup { Name = "No Station" }); groups.AddRange(_departmentGroupsService.GetAllStationGroupsForDepartment(DepartmentId)); model.Stations = groups; return(View(model)); }
public IActionResult Adjust() { var model = new AdjustView(); model.Inventory = new Inventory(); model.Types = _inventoryService.GetAllTypesForDepartment(DepartmentId); model.Stations = _departmentGroupsService.GetAllStationGroupsForDepartment(DepartmentId); return(View(model)); }
public List <RespondingOptionResult> GetRespondingOptions() { var result = new List <RespondingOptionResult>(); var stations = _departmentGroupsService.GetAllStationGroupsForDepartment(DepartmentId); var calls = _callsService.GetActiveCallsByDepartment(DepartmentId); /* Removed the Parallel.ForEach statement here as this data needs to be sorted * and there isn't enough sort data (at least for calls) for the client to do it. * Also during JMeter testing the perf gains wernt there (10ms average for both). */ foreach (var s in stations.OrderBy(x => x.Name)) { var respondingTo = new RespondingOptionResult(); respondingTo.Id = s.DepartmentGroupId; respondingTo.Typ = 1; respondingTo.Nme = ""; result.Add(respondingTo); } foreach (var c in calls.OrderByDescending(x => x.LoggedOn)) { var respondingTo = new RespondingOptionResult(); respondingTo.Id = c.CallId; respondingTo.Typ = 2; respondingTo.Nme = c.Name; result.Add(respondingTo); } return(result); }
private void PopulateLogViewModel(NewLogView model) { model.Department = _departmentsService.GetDepartmentByUserId(UserId); model.User = _usersService.GetUserById(UserId); model.Types = model.LogType.ToSelectList(); model.CallPriorities = model.CallPriority.ToSelectList(); model.Users.Add(String.Empty, "Not Applicable"); model.SetUsers(_departmentsService.GetAllUsersForDepartment(DepartmentId)); var groups = new List <DepartmentGroup>(); groups.Add(new DepartmentGroup { Name = "Not Applicable" }); groups.AddRange(_departmentGroupsService.GetAllStationGroupsForDepartment(DepartmentId)); model.Stations = groups; List <CallType> types = new List <CallType>(); types.Add(new CallType { CallTypeId = 0, Type = "No Type" }); types.AddRange(_callsService.GetCallTypesForDepartment(DepartmentId)); model.CallTypes = new SelectList(types, "Type", "Type"); }
public HttpResponseMessage VoiceCall(string userId, int callId) { var response = new TwilioResponse(); var call = _callsService.GetCallById(callId); if (call == null) { response.Say("This call has been closed. Goodbye.").Hangup(); return(Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter())); } if (call.State == (int)CallStates.Cancelled || call.State == (int)CallStates.Closed || call.IsDeleted) { response.Say(string.Format("This call, Id {0} has been closed. Goodbye.", call.Number)).Hangup(); return(Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter())); } var stations = _departmentGroupsService.GetAllStationGroupsForDepartment(call.DepartmentId); string address = call.Address; if (String.IsNullOrWhiteSpace(address) && !string.IsNullOrWhiteSpace(call.GeoLocationData)) { try { string[] points = call.GeoLocationData.Split(char.Parse(",")); if (points != null && points.Length == 2) { address = _geoLocationProvider.GetAproxAddressFromLatLong(double.Parse(points[0]), double.Parse(points[1])); } } catch { } } if (String.IsNullOrWhiteSpace(address) && !String.IsNullOrWhiteSpace(call.Address)) { address = call.Address; } StringBuilder sb = new StringBuilder(); if (!String.IsNullOrWhiteSpace(address)) { sb.Append(string.Format("{0}, Priority {1} Address {2} Nature {3}", call.Name, call.GetPriorityText(), call.Address, call.NatureOfCall)); } else { sb.Append(string.Format("{0}, Priority {1} Nature {2}", call.Name, call.GetPriorityText(), call.NatureOfCall)); } sb.Append(", Press 0 to repeat, Press 1 to respond to the scene"); for (int i = 0; i < stations.Count; i++) { if (i >= 8) { break; } sb.Append(string.Format(", press {0} to respond to {1}", i + 2, stations[i].Name)); } response.BeginGather(new { numDigits = 1, timeout = 10, method = "GET", action = string.Format("{0}/Twilio/VoiceCallAction/{1}/{2}", Config.SystemBehaviorConfig.ResgridApiBaseUrl, userId, callId) }).Say(sb.ToString()).EndGather().Pause(10).Hangup(); return(Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter())); }
public IActionResult GetMapData(MapSettingsInput input) { MapDataJson dataJson = new MapDataJson(); var calls = _callsService.GetActiveCallsByDepartment(DepartmentId); var department = _departmentsService.GetDepartmentById(DepartmentId, false); var stations = _departmentGroupsService.GetAllStationGroupsForDepartment(DepartmentId); var lastUserActionlogs = _actionLogsService.GetActionLogsForDepartment(DepartmentId); var personnelNames = _departmentsService.GetAllPersonnelNamesForDepartment(DepartmentId); var unitStates = _unitsService.GetAllLatestStatusForUnitsByDepartmentId(DepartmentId); var userLocationPermission = _permissionsService.GetPermisionByDepartmentType(DepartmentId, PermissionTypes.CanSeePersonnelLocations); if (userLocationPermission != null) { var userGroup = _departmentGroupsService.GetGroupForUser(UserId, DepartmentId); int?groupId = null; if (userGroup != null) { groupId = userGroup.DepartmentGroupId; } var roles = _personnelRolesService.GetRolesForUser(UserId, DepartmentId); var allowedUsers = _permissionsService.GetAllowedUsers(userLocationPermission, DepartmentId, groupId, ClaimsAuthorizationHelper.IsUserDepartmentAdmin(), ClaimsAuthorizationHelper.IsUserDepartmentAdmin(), roles); lastUserActionlogs.RemoveAll(x => !allowedUsers.Contains(x.UserId)); } if (input.ShowDistricts) { foreach (var station in stations) { if (!String.IsNullOrWhiteSpace(station.Geofence)) { GeofenceJson geofence = new GeofenceJson(); geofence.Name = station.Name; geofence.Color = station.GeofenceColor; geofence.Fence = station.Geofence; dataJson.Geofences.Add(geofence); } } } if (input.ShowStations) { foreach (var station in stations) { MapMakerInfo info = new MapMakerInfo(); info.ImagePath = "Station"; info.Title = station.Name; info.InfoWindowContent = station.Name; if (station.Address != null) { string coordinates = _geoLocationProvider.GetLatLonFromAddress(string.Format("{0} {1} {2} {3}", station.Address.Address1, station.Address.City, station.Address.State, station.Address.PostalCode)); if (!String.IsNullOrEmpty(coordinates)) { info.Latitude = double.Parse(coordinates.Split(char.Parse(","))[0]); info.Longitude = double.Parse(coordinates.Split(char.Parse(","))[1]); dataJson.Markers.Add(info); } } else if (!String.IsNullOrWhiteSpace(station.Latitude) && !String.IsNullOrWhiteSpace(station.Longitude)) { info.Latitude = double.Parse(station.Latitude); info.Longitude = double.Parse(station.Longitude); dataJson.Markers.Add(info); } } } if (input.ShowCalls) { foreach (var call in calls) { MapMakerInfo info = new MapMakerInfo(); info.ImagePath = "Call"; info.Title = call.Name; info.InfoWindowContent = call.NatureOfCall; if (!String.IsNullOrEmpty(call.GeoLocationData)) { try { info.Latitude = double.Parse(call.GeoLocationData.Split(char.Parse(","))[0]); info.Longitude = double.Parse(call.GeoLocationData.Split(char.Parse(","))[1]); dataJson.Markers.Add(info); } catch { } } else if (!String.IsNullOrEmpty(call.Address)) { string coordinates = _geoLocationProvider.GetLatLonFromAddress(call.Address); if (!String.IsNullOrEmpty(coordinates)) { info.Latitude = double.Parse(coordinates.Split(char.Parse(","))[0]); info.Longitude = double.Parse(coordinates.Split(char.Parse(","))[1]); } dataJson.Markers.Add(info); } } } if (input.ShowUnits) { foreach (var unit in unitStates) { if (unit.Latitude.HasValue && unit.Latitude.Value != 0 && unit.Longitude.HasValue && unit.Longitude.Value != 0) { MapMakerInfo info = new MapMakerInfo(); info.ImagePath = "Engine_Responding"; info.Title = unit.Unit.Name; info.InfoWindowContent = ""; info.Latitude = double.Parse(unit.Latitude.Value.ToString()); info.Longitude = double.Parse(unit.Longitude.Value.ToString()); dataJson.Markers.Add(info); } } } if (input.ShowPersonnel) { foreach (var person in lastUserActionlogs) { if (!String.IsNullOrWhiteSpace(person.GeoLocationData)) { MapMakerInfo info = new MapMakerInfo(); info.ImagePath = "Person"; var name = personnelNames.FirstOrDefault(x => x.UserId == person.UserId); if (name != null) { info.Title = name.Name; info.InfoWindowContent = ""; } else { info.Title = ""; info.InfoWindowContent = ""; } var infos = person.GeoLocationData.Split(char.Parse(",")); if (infos != null && infos.Length == 2) { info.Latitude = double.Parse(infos[0]); info.Longitude = double.Parse(infos[1]); dataJson.Markers.Add(info); } } } } if (input.ShowPOIs) { var poiTypes = _mappingService.GetPOITypesForDepartment(DepartmentId); foreach (var poiType in poiTypes) { foreach (var poi in poiType.Pois) { MapMakerInfo info = new MapMakerInfo(); info.ImagePath = poiType.Image; info.Marker = poiType.Marker; info.Title = poiType.Name; info.InfoWindowContent = ""; info.Latitude = poi.Latitude; info.Longitude = poi.Longitude; info.Color = poiType.Color; dataJson.Pois.Add(info); } } } return(Json(dataJson)); }
public List <PersonnelViewModel> GetPersonnelStatuses() { var department = _departmentsService.GetDepartmentById(DepartmentId, false); var stations = _departmentGroupsService.GetAllStationGroupsForDepartment(DepartmentId); var calls = _callsService.GetActiveCallsByDepartment(DepartmentId); var allUsers = _departmentsService.GetAllUsersForDepartment(DepartmentId); var hideUnavailable = _departmentSettingsService.GetBigBoardHideUnavailableDepartment(DepartmentId); var lastUserActionlogs = _actionLogsService.GetActionLogsForDepartment(DepartmentId); //var departmentGroups = _departmentGroupsService.GetAllGroupsForDepartment(DepartmentId); var lastUserStates = _userStateService.GetLatestStatesForDepartment(DepartmentId); var personnelNames = _departmentsService.GetAllPersonnelNamesForDepartment(DepartmentId); var names = new Dictionary <string, string>(); var userStates = new List <UserState>(); foreach (var u in allUsers) { var state = lastUserStates.FirstOrDefault(x => x.UserId == u.UserId); if (state != null) { userStates.Add(state); } else { userStates.Add(_userStateService.GetLastUserStateByUserId(u.UserId)); } var name = personnelNames.FirstOrDefault(x => x.UserId == u.UserId); if (name != null) { names.Add(u.UserId, name.Name); } } var personnelViewModels = new List <PersonnelViewModel>(); var sortedUngroupedUsers = from u in allUsers // let mu = Membership.GetUser(u.UserId) let userGroup = _departmentGroupsService.GetGroupForUser(u.UserId, DepartmentId) let groupName = userGroup == null ? "" : userGroup.Name let roles = _personnelRolesService.GetRolesForUser(u.UserId, DepartmentId) //let name = (ProfileBase.Create(mu.UserName, true)).GetPropertyValue("Name").ToString() let name = names[u.UserId] let weight = lastUserActionlogs.Where(x => x.UserId == u.UserId).FirstOrDefault().GetWeightForAction() orderby groupName, weight, name ascending select new { Name = name, User = u, Group = userGroup, Roles = roles }; foreach (var u in sortedUngroupedUsers) { //var mu = Membership.GetUser(u.User.UserId); var al = lastUserActionlogs.Where(x => x.UserId == u.User.UserId).FirstOrDefault(); var us = userStates.Where(x => x.UserId == u.User.UserId).FirstOrDefault(); // if setting is such, ignore unavailable users. if (hideUnavailable.HasValue && hideUnavailable.Value && us.State != (int)UserStateTypes.Unavailable) { continue; } string callNumber = ""; if (al != null && al.ActionTypeId == (int)ActionTypes.RespondingToScene || (al != null && al.DestinationType.HasValue && al.DestinationType.Value == 2)) { if (al.DestinationId.HasValue) { var call = calls.FirstOrDefault(x => x.CallId == al.DestinationId.Value); if (call != null) { callNumber = call.Number; } } } var respondingToDepartment = stations.Where(s => al != null && s.DepartmentGroupId == al.DestinationId).FirstOrDefault(); var personnelViewModel = PersonnelViewModel.Create(u.Name, al, us, department, respondingToDepartment, u.Group, u.Roles, callNumber); personnelViewModels.Add(personnelViewModel); } return(personnelViewModels); }
public IActionResult GetPersonnelList(int linkId) { var link = _departmentLinksService.GetLinkById(linkId); if (link.DepartmentId != DepartmentId && link.LinkedDepartmentId != DepartmentId) { Unauthorized(); } var department = _departmentsService.GetDepartmentById(link.DepartmentId); var allUsers = _departmentsService.GetAllUsersForDepartment(link.DepartmentId); var lastUserActionlogs = _actionLogsService.GetActionLogsForDepartment(link.DepartmentId); var departmentGroups = _departmentGroupsService.GetAllGroupsForDepartment(link.DepartmentId); var lastUserStates = _userStateService.GetLatestStatesForDepartment(link.DepartmentId); var personnelNames = _departmentsService.GetAllPersonnelNamesForDepartment(link.DepartmentId); var calls = _callsService.GetActiveCallsByDepartment(link.DepartmentId); var stations = _departmentGroupsService.GetAllStationGroupsForDepartment(link.DepartmentId); var names = new Dictionary <string, string>(); var userStates = new List <UserState>(); foreach (var u in allUsers) { var state = lastUserStates.FirstOrDefault(x => x.UserId == u.UserId); if (state != null) { userStates.Add(state); } else { userStates.Add(_userStateService.GetLastUserStateByUserId(u.UserId)); } var name = personnelNames.FirstOrDefault(x => x.UserId == u.UserId); if (name != null) { names.Add(u.UserId, name.Name); } else { names.Add(u.UserId, UserHelper.GetFullNameForUser(u.UserId)); } } var personnelViewModels = new List <Models.BigBoardX.PersonnelViewModel>(); var sortedUngroupedUsers = from u in allUsers // let mu = Membership.GetUser(u.UserId) let userGroup = _departmentGroupsService.GetGroupForUser(u.UserId, DepartmentId) let groupName = userGroup == null ? "" : userGroup.Name let roles = _personnelRolesService.GetRolesForUser(u.UserId, DepartmentId) //let name = (ProfileBase.Create(mu.UserName, true)).GetPropertyValue("Name").ToString() let name = names[u.UserId] let weight = lastUserActionlogs.Where(x => x.UserId == u.UserId).FirstOrDefault().GetWeightForAction() orderby groupName, weight, name ascending select new { Name = name, User = u, Group = userGroup, Roles = roles }; foreach (var u in sortedUngroupedUsers) { //var mu = Membership.GetUser(u.User.UserId); var al = lastUserActionlogs.Where(x => x.UserId == u.User.UserId).FirstOrDefault(); var us = userStates.Where(x => x.UserId == u.User.UserId).FirstOrDefault(); string callNumber = ""; if (al != null && al.ActionTypeId == (int)ActionTypes.RespondingToScene || (al != null && al.DestinationType.HasValue && al.DestinationType.Value == 2)) { if (al.DestinationId.HasValue) { var call = calls.FirstOrDefault(x => x.CallId == al.DestinationId.Value); if (call != null) { callNumber = call.Number; } } } var respondingToDepartment = stations.Where(s => al != null && s.DepartmentGroupId == al.DestinationId).FirstOrDefault(); var personnelViewModel = Models.BigBoardX.PersonnelViewModel.Create(u.Name, al, us, department, respondingToDepartment, u.Group, u.Roles, callNumber); personnelViewModels.Add(personnelViewModel); } return(Json(personnelViewModels)); }