public void SubscribeToDepartmentLink(int linkId) { var link = _departmentLinksService.GetLinkById(linkId); if (link != null && link.LinkEnabled) { Groups.Add(Context.ConnectionId, link.DepartmentId.ToString()); } }
public IActionResult EnableLink(int linkId) { var link = _departmentLinksService.GetLinkById(linkId); if (link.LinkedDepartmentId != DepartmentId) { Unauthorized(); } link.LinkEnabled = true; link.LinkAccepted = DateTime.UtcNow; _departmentLinksService.Save(link); return(RedirectToAction("Index")); }
public List <LinkedCallResult> GetActiveCallsForLink(int linkId) { var result = new List <LinkedCallResult>(); var link = _departmentLinksService.GetLinkById(linkId); if (link.DepartmentId != DepartmentId && link.LinkedDepartmentId != DepartmentId) { return(new List <LinkedCallResult>()); } var calls = _callsService.GetActiveCallsByDepartment(link.DepartmentId).OrderByDescending(x => x.LoggedOn); var department = _departmentsService.GetDepartmentById(link.DepartmentId, false); foreach (var c in calls) { var call = new LinkedCallResult(); call.Cid = c.CallId; call.Pri = c.Priority; call.Ctl = c.IsCritical; call.Nme = StringHelpers.SanitizeHtmlInString(c.Name); if (!String.IsNullOrWhiteSpace(c.NatureOfCall)) { call.Noc = StringHelpers.SanitizeHtmlInString(c.NatureOfCall); } call.Map = c.MapPage; if (!String.IsNullOrWhiteSpace(c.Notes)) { call.Not = StringHelpers.SanitizeHtmlInString(c.Notes); } if (c.CallNotes != null) { call.Nts = c.CallNotes.Count(); } else { call.Nts = 0; } if (c.Attachments != null) { call.Aud = c.Attachments.Count(x => x.CallAttachmentType == (int)CallAttachmentTypes.DispatchAudio); call.Img = c.Attachments.Count(x => x.CallAttachmentType == (int)CallAttachmentTypes.Image); call.Fls = c.Attachments.Count(x => x.CallAttachmentType == (int)CallAttachmentTypes.File); } else { call.Aud = 0; call.Img = 0; call.Fls = 0; } if (String.IsNullOrWhiteSpace(c.Address) && !String.IsNullOrWhiteSpace(c.GeoLocationData)) { var geo = c.GeoLocationData.Split(char.Parse(",")); if (geo.Length == 2) { call.Add = _geoLocationProvider.GetAddressFromLatLong(double.Parse(geo[0]), double.Parse(geo[1])); } } else { call.Add = c.Address; } call.Geo = c.GeoLocationData; call.Lon = c.LoggedOn.TimeConverter(department); call.Ste = c.State; call.Num = c.Number; call.Priority = c.ToCallPriorityDisplayText(); call.PriorityCss = c.ToCallPriorityCss(); call.State = c.ToCallStateDisplayText(); call.StateCss = c.ToCallStateCss(); result.Add(call); } return(result); }