Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Core/Resgrid.Localization/Areas/User/Dispatch/Call.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@
<data name="AddImage" xml:space="preserve">
<value>Add Image</value>
</data>
<data name="AdditionalContactLabel" xml:space="preserve">
<value>Additional Contacts</value>
</data>
<data name="AddLinkedCall" xml:space="preserve">
<value>Add Linked Call</value>
</data>
Expand All @@ -153,12 +156,18 @@
<data name="AddNotePlaceholder" xml:space="preserve">
<value>Enter note here...</value>
</data>
<data name="AlertNotesHeader" xml:space="preserve">
<value>Alert Notes for Contact</value>
</data>
<data name="ArchivedCallsHeader" xml:space="preserve">
<value>Archived Calls</value>
</data>
<data name="AttachedImages" xml:space="preserve">
<value>Attached Images</value>
</data>
<data name="CallContactType" xml:space="preserve">
<value>Call Contact Type</value>
</data>
<data name="CallDocumentsHeader" xml:space="preserve">
<value>Call Documents</value>
</data>
Expand Down Expand Up @@ -237,6 +246,9 @@
<data name="CompletedTypeLabel" xml:space="preserve">
<value>Completed Type</value>
</data>
<data name="Contacts" xml:space="preserve">
<value>Contacts</value>
</data>
<data name="CreateCall" xml:space="preserve">
<value>Create and Dispatch Call</value>
</data>
Expand Down Expand Up @@ -334,7 +346,7 @@
<value>Name of the Call</value>
</data>
<data name="NewCallFormHeader" xml:space="preserve">
<value />
<value>New Call Form</value>
</data>
<data name="NewCallHeader" xml:space="preserve">
<value>New Call</value>
Expand Down Expand Up @@ -372,6 +384,9 @@
<data name="PersonnelEvents" xml:space="preserve">
<value>Personnel Events</value>
</data>
<data name="PrimaryContactLabel" xml:space="preserve">
<value>Primary Contact</value>
</data>
<data name="PrioirtyLabel" xml:space="preserve">
<value>Priority</value>
</data>
Expand Down
15 changes: 15 additions & 0 deletions Core/Resgrid.Localization/Areas/User/Dispatch/Call.es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@
<data name="AddImage" xml:space="preserve">
<value>Añadir imagen</value>
</data>
<data name="AdditionalContactLabel" xml:space="preserve">
<value />
</data>
<data name="AddLinkedCall" xml:space="preserve">
<value>Agregar llamada vinculada</value>
</data>
Expand All @@ -153,12 +156,18 @@
<data name="AddNotePlaceholder" xml:space="preserve">
<value>Introduzca la nota aquí...</value>
</data>
<data name="AlertNotesHeader" xml:space="preserve">
<value />
</data>
<data name="ArchivedCallsHeader" xml:space="preserve">
<value>Llamadas archivadas</value>
</data>
<data name="AttachedImages" xml:space="preserve">
<value>Imágenes adjuntas</value>
</data>
<data name="CallContactType" xml:space="preserve">
<value />
</data>
<data name="CallDocumentsHeader" xml:space="preserve">
<value>Documentos de llamadas</value>
</data>
Expand Down Expand Up @@ -237,6 +246,9 @@
<data name="CompletedTypeLabel" xml:space="preserve">
<value>Tipo completado</value>
</data>
<data name="Contacts" xml:space="preserve">
<value />
</data>
<data name="CreateCall" xml:space="preserve">
<value>Crear y enviar llamadas</value>
</data>
Expand Down Expand Up @@ -372,6 +384,9 @@
<data name="PersonnelEvents" xml:space="preserve">
<value>Eventos de personal</value>
</data>
<data name="PrimaryContactLabel" xml:space="preserve">
<value />
</data>
<data name="PrioirtyLabel" xml:space="preserve">
<value>Prioridad</value>
</data>
Expand Down
5 changes: 4 additions & 1 deletion Core/Resgrid.Model/Call.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ public class Call : IEntity
[ProtoMember(31)]
public virtual ICollection<CallReference> References { get; set; }

[ProtoMember(32)]
public virtual ICollection<CallContact> Contacts { get; set; }

public string ContactName { get; set; }

public string ContactNumber { get; set; }
Expand Down Expand Up @@ -190,7 +193,7 @@ public object IdValue
public int IdType => 0;

[NotMapped]
public IEnumerable<string> IgnoredProperties => new string[] { "IdValue", "IdType", "TableName", "IdName", "ReportingUser", "ClosedByUser", "Department", "Dispatches", "Attachments", "CallNotes", "GroupDispatches", "UnitDispatches", "RoleDispatches", "Protocols", "ShortenedAudioUrl", "ShortenedCallUrl", "CallPriority", "PreviousDispatchCount", "References" };
public IEnumerable<string> IgnoredProperties => new string[] { "IdValue", "IdType", "TableName", "IdName", "ReportingUser", "ClosedByUser", "Department", "Dispatches", "Attachments", "CallNotes", "GroupDispatches", "UnitDispatches", "RoleDispatches", "Protocols", "ShortenedAudioUrl", "ShortenedCallUrl", "CallPriority", "PreviousDispatchCount", "References", "Contacts" };

public string GetIdentifier()
{
Expand Down
8 changes: 8 additions & 0 deletions Core/Resgrid.Model/CallContact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ public class CallContact : IEntity
[ProtoMember(5)]
public int CallContactType { get; set; } // 0 = Primary

public string GetContactTypeName()
{
if (CallContactType == 0)
return "Primary";

return "Additional";
}

[NotMapped]
[JsonIgnore]
public object IdValue
Expand Down
18 changes: 17 additions & 1 deletion Core/Resgrid.Model/Contact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,22 @@ public class Contact : IEntity

public string EditedByUserId { get; set; }

[NotMapped]
public string Name
{
get
{
if (ContactType == 0)
{
return $"{FirstName} {LastName}";
}
else
{
return CompanyName;
}
}
}

public string GetName()
{
if (ContactType == 0)
Expand Down Expand Up @@ -143,6 +159,6 @@ public object IdValue
}

[NotMapped]
public IEnumerable<string> IgnoredProperties => new string[] { "IdValue", "IdType", "TableName", "IdName", "Category" };
public IEnumerable<string> IgnoredProperties => new string[] { "IdValue", "IdType", "TableName", "IdName", "Category", "Name" };
}
}
2 changes: 1 addition & 1 deletion Core/Resgrid.Model/Repositories/ICallContactsRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ namespace Resgrid.Model.Repositories
/// <seealso cref="Resgrid.Model.Repositories.IRepository{Resgrid.Model.CallContact}" />
public interface ICallContactsRepository : IRepository<CallContact>
{

Task<IEnumerable<CallContact>> GetCallContactsByCallIdAsync(int callId);
}
}
4 changes: 3 additions & 1 deletion Core/Resgrid.Model/Services/ICallsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ Task<bool> ClearGroupForDispatchesAsync(int departmentGroupId,
/// <param name="getProtocols">if set to <c>true</c> [get protocols].</param>
/// <param name="getReferences">if set to <c>true</c> [get references].</param>
/// <returns>Task&lt;Call&gt;.</returns>
Task<Call> PopulateCallData(Call call, bool getDispatches, bool getAttachments, bool getNotes, bool getGroupDispatches, bool getUnitDispatches, bool getRoleDispatches, bool getProtocols, bool getReferences);
Task<Call> PopulateCallData(Call call, bool getDispatches, bool getAttachments, bool getNotes, bool getGroupDispatches, bool getUnitDispatches, bool getRoleDispatches, bool getProtocols, bool getReferences, bool getContacts);

Task<List<Call>> GetAllNonDispatchedScheduledCallsWithinDateRange(DateTime startDate, DateTime endDate);

Expand All @@ -410,5 +410,7 @@ Task<bool> ClearGroupForDispatchesAsync(int departmentGroupId,
Task<bool> DeleteCallReferenceAsync(CallReference callReference, CancellationToken cancellationToken = default(CancellationToken));

Task<List<Call>> GetCallsByContactIdAsync(string contactId, int departmentId);

Task<bool> DeleteCallContactsAsync(int callId, CancellationToken cancellationToken = default(CancellationToken));
}
}
6 changes: 3 additions & 3 deletions Core/Resgrid.Services/AuthorizationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ public async Task<bool> CanUserDeleteCallAsync(string userId, int callId, int de
if (call == null || call.DepartmentId != departmentId)
return false;

call = await _callsService.PopulateCallData(call, false, false, false, true, false, false, false, false);
call = await _callsService.PopulateCallData(call, false, false, false, true, false, false, false, false, false);

if (group != null)
{
Expand Down Expand Up @@ -907,7 +907,7 @@ public async Task<bool> CanUserCloseCallAsync(string userId, int callId, int dep
if (call == null || call.DepartmentId != departmentId)
return false;

call = await _callsService.PopulateCallData(call, false, false, false, true, false, false, false, false);
call = await _callsService.PopulateCallData(call, false, false, false, true, false, false, false, false, false);

if (group != null)
{
Expand Down Expand Up @@ -946,7 +946,7 @@ public async Task<bool> CanUserAddCallDataAsync(string userId, int callId, int d
if (call == null || call.DepartmentId != departmentId)
return false;

call = await _callsService.PopulateCallData(call, false, false, false, true, false, false, false, false);
call = await _callsService.PopulateCallData(call, false, false, false, true, false, false, false, false, false);

if (group != null)
{
Expand Down
81 changes: 55 additions & 26 deletions Core/Resgrid.Services/CallsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public CallsService(ICallsRepository callsRepository, ICommunicationService comm
ICallDispatchUnitRepository callDispatchUnitRepository, ICallDispatchRoleRepository callDispatchRoleRepository,
IDepartmentCallPriorityRepository departmentCallPriorityRepository, IShortenUrlProvider shortenUrlProvider,
ICallProtocolsRepository callProtocolsRepository, IGeoLocationProvider geoLocationProvider, IDepartmentsService departmentsService,
ICallReferencesRepository callReferencesRepository, ICallContactsRepository callContactsRepository)
ICallReferencesRepository callReferencesRepository, ICallContactsRepository callContactsRepository)
{
_callsRepository = callsRepository;
_communicationService = communicationService;
Expand Down Expand Up @@ -83,41 +83,41 @@ public CallsService(ICallsRepository callsRepository, ICommunicationService comm
if (!String.IsNullOrWhiteSpace(call.GeoLocationData) && call.GeoLocationData.Length == 1)
call.GeoLocationData = "";

if (call.Dispatches != null && call.Dispatches.Any())
if (call.Dispatches != null && call.Dispatches.Any())
{
foreach (var dispatch in call.Dispatches)
{
foreach (var dispatch in call.Dispatches)
{
if (dispatch.CallDispatchId == 0)
dispatch.DispatchedOn = DateTime.UtcNow;
}
if (dispatch.CallDispatchId == 0)
dispatch.DispatchedOn = DateTime.UtcNow;
}
}

if (call.GroupDispatches != null && call.GroupDispatches.Any())
if (call.GroupDispatches != null && call.GroupDispatches.Any())
{
foreach (var dispatch in call.GroupDispatches)
{
foreach (var dispatch in call.GroupDispatches)
{
if (dispatch.CallDispatchGroupId == 0)
dispatch.DispatchedOn = DateTime.UtcNow;
}
if (dispatch.CallDispatchGroupId == 0)
dispatch.DispatchedOn = DateTime.UtcNow;
}
}

if (call.RoleDispatches != null && call.RoleDispatches.Any())
if (call.RoleDispatches != null && call.RoleDispatches.Any())
{
foreach (var dispatch in call.RoleDispatches)
{
foreach (var dispatch in call.RoleDispatches)
{
if (dispatch.CallDispatchRoleId == 0)
dispatch.DispatchedOn = DateTime.UtcNow;
}
if (dispatch.CallDispatchRoleId == 0)
dispatch.DispatchedOn = DateTime.UtcNow;
}
}

if (call.UnitDispatches != null && call.UnitDispatches.Any())
if (call.UnitDispatches != null && call.UnitDispatches.Any())
{
foreach (var dispatch in call.UnitDispatches)
{
foreach (var dispatch in call.UnitDispatches)
{
if (dispatch.CallDispatchUnitId == 0)
dispatch.DispatchedOn = DateTime.UtcNow;
}
if (dispatch.CallDispatchUnitId == 0)
dispatch.DispatchedOn = DateTime.UtcNow;
}
}

if (call.References != null && call.References.Any())
{
Expand Down Expand Up @@ -445,8 +445,11 @@ public async Task<List<DepartmentCallPriority>> GetActiveCallPrioritiesForDepart
return activePriorities;
}

public async Task<Call> PopulateCallData(Call call, bool getDispatches, bool getAttachments, bool getNotes, bool getGroupDispatches, bool getUnitDispatches, bool getRoleDispatches, bool getProtocols, bool getReferences)
public async Task<Call> PopulateCallData(Call call, bool getDispatches, bool getAttachments, bool getNotes, bool getGroupDispatches, bool getUnitDispatches, bool getRoleDispatches, bool getProtocols, bool getReferences, bool getContacts)
{
if (call == null)
return null;

if (getDispatches && call.Dispatches == null)
{
var items = await _callDispatchesRepository.GetCallDispatchesByCallIdAsync(call.CallId);
Expand Down Expand Up @@ -520,10 +523,36 @@ public async Task<Call> PopulateCallData(Call call, bool getDispatches, bool get
else
call.References = new List<CallReference>();
}
if (getContacts && call.Contacts == null)
{
var items = await _callContactsRepository.GetCallContactsByCallIdAsync(call.CallId);

if (items != null)
call.Contacts = items.ToList();
else
call.Contacts = new List<CallContact>();
}

return call;
}

public async Task<bool> DeleteCallContactsAsync(int callId, CancellationToken cancellationToken = default(CancellationToken))
{
var callContacts = await _callContactsRepository.GetCallContactsByCallIdAsync(callId);

if (callContacts != null || callContacts.Any())
{
foreach (var contact in callContacts)
{
await _callContactsRepository.DeleteAsync(contact, cancellationToken);
}

return true;
}

return false;
}

public List<DepartmentCallPriority> GetDefaultCallPriorities()
{
if (_callPriorities == null)
Expand Down
6 changes: 3 additions & 3 deletions Providers/Resgrid.Providers.Bus.Rabbit/RabbitConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,18 @@ await channel.QueueDeclareAsync(queue: SetQueueNameForEnv(ServiceBusConfig.Secur
return false;
}

public static IConnection CreateConnection(string clientName)
public static async Task<IConnection> CreateConnection(string clientName)
{
if (_connection == null)
VerifyAndCreateClients(clientName);
await VerifyAndCreateClients(clientName);

if (!_connection.IsOpen)
{
_connection.Dispose();
_connection = null;
_factory = null;

VerifyAndCreateClients(clientName);
await VerifyAndCreateClients(clientName);
}

return _connection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private async Task<bool> VerifyAndCreateClients(string clientName)
{
try
{
_connection = RabbitConnection.CreateConnection(clientName);
_connection = await RabbitConnection.CreateConnection(clientName);

if (_connection != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public RabbitInboundQueueProvider()
public async Task Start(string clientName)
{
_clientName = clientName;
var connection = RabbitConnection.CreateConnection(clientName);
var connection = await RabbitConnection.CreateConnection(clientName);

if (connection != null)
{
Expand Down Expand Up @@ -586,7 +586,7 @@ private async Task<bool> RetryQueueItem(BasicDeliverEventArgs ea, Exception mex)
//var factory = new ConnectionFactory() { HostName = ServiceBusConfig.RabbitHostname, UserName = ServiceBusConfig.RabbitUsername, Password = ServiceBusConfig.RabbbitPassword };
//using (var connection = RabbitConnection.CreateConnection())
//{
var connection = RabbitConnection.CreateConnection(_clientName);
var connection = await RabbitConnection.CreateConnection(_clientName);
if (connection != null)
{
using (var channel = await connection.CreateChannelAsync())
Expand Down
Loading
Loading