Skip to content

Commit 59d5f84

Browse files
committed
RE1-T112 PR#322 fixes
1 parent f933b5f commit 59d5f84

5 files changed

Lines changed: 33 additions & 9 deletions

File tree

Providers/Resgrid.Providers.Bus.Rabbit/RabbitConnection.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static async Task<bool> VerifyAndCreateClients(string clientName)
2525
_connection.Dispose();
2626
_connection = null;
2727
_factory = null;
28-
ConnectionReset?.Invoke();
28+
RaiseConnectionReset();
2929
}
3030

3131
if (_connection == null)
@@ -185,14 +185,33 @@ public static async Task<IConnection> CreateConnection(string clientName)
185185
_connection.Dispose();
186186
_connection = null;
187187
_factory = null;
188-
ConnectionReset?.Invoke();
188+
RaiseConnectionReset();
189189

190190
await VerifyAndCreateClients(clientName);
191191
}
192192

193193
return _connection;
194194
}
195195

196+
private static void RaiseConnectionReset()
197+
{
198+
var handler = ConnectionReset;
199+
if (handler == null)
200+
return;
201+
202+
foreach (var subscriber in handler.GetInvocationList())
203+
{
204+
try
205+
{
206+
((Action)subscriber).Invoke();
207+
}
208+
catch (Exception ex)
209+
{
210+
Logging.LogException(ex);
211+
}
212+
}
213+
}
214+
196215
public static string SetQueueNameForEnv(string cacheKey)
197216
{
198217
if (Config.SystemBehaviorConfig.Environment == SystemEnvironment.Dev)

Providers/Resgrid.Providers.Bus.Rabbit/RabbitTopicProvider.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,14 @@ public async Task<bool> UnitLocationUpdatedChanged(UnitLocationUpdatedEvent mess
121121

122122
private static async Task<bool> VerifyAndCreateClients(string clientName)
123123
{
124-
if (_exchangeDeclared)
125-
return true;
126-
127124
try
128125
{
126+
// Validate/create connection first so a reconnect clears _exchangeDeclared
129127
var connection = await RabbitConnection.CreateConnection(clientName);
130128

129+
if (_exchangeDeclared)
130+
return true;
131+
131132
if (connection != null)
132133
{
133134
using (var channel = await connection.CreateChannelAsync())

Web/Resgrid.Web.Services/Controllers/TwilioController.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,12 +591,12 @@ public async Task<ActionResult> VoiceCallAction(string userId, int callId, [From
591591

592592
response.Say("You have been marked responding to the scene, goodbye.").Hangup();
593593
}
594-
else
594+
else if (int.TryParse(twilioRequest.Digits, out var digit))
595595
{
596596
var call = await _callsService.GetCallByIdAsync(callId);
597597
var stations = await _departmentGroupsService.GetAllStationGroupsForDepartmentAsync(call.DepartmentId);
598598

599-
int index = int.Parse(twilioRequest.Digits) - 2;
599+
int index = digit - 2;
600600

601601
if (index >= 0 && index < stations.Count)
602602
{
@@ -611,6 +611,10 @@ await _actionLogsService.SetUserActionAsync(userId, call.DepartmentId, (int)Acti
611611
}
612612
}
613613
}
614+
else
615+
{
616+
response.Say("Sorry, that was not a valid selection.").Redirect(new Uri(string.Format("{0}/api/Twilio/VoiceCall?userId={1}&callId={2}", Config.SystemBehaviorConfig.ResgridApiBaseUrl, userId, callId)), "GET");
617+
}
614618

615619
return new ContentResult
616620
{

Web/Resgrid.Web/wwwroot/js/app/internal/statuses/resgrid.statuses.editstatus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ var resgrid;
8585
var baseTypeVal = $('#baseType').length ? $('#baseType').val() : '-1';
8686
var detailTypeVal = $('#detailType').length ? $('#detailType').val() : '0';
8787
var noteTypeVal = $('#noteType').length ? $('#noteType').val() : '0';
88-
var requireGpsVal = $('#requireGps').length ? $('#requireGps').val() : 'false';
88+
var requireGpsVal = $('#requireGps').length && $('#requireGps').is(':checked') ? 'on' : 'false';
8989
$('#options tbody').first().append("<tr><td><input type='number' min='0' id='order_" + editstatus.optionsCount + "' name='order_" + editstatus.optionsCount + "' value='0' class='numberEntry'></td><td>" + $('#buttonText').val() + "<input type='hidden' id='buttonText_" + editstatus.optionsCount + "' name='buttonText_" + editstatus.optionsCount + "' value='" + $('#buttonText').val() + "'></input><input type='hidden' id='baseType_" + editstatus.optionsCount + "' name='baseType_" + editstatus.optionsCount + "' value='" + baseTypeVal + "'></input></td><td><a class='btn btn-default' role='button' style='color:" + $('#textColor').val() + ";background:" + $('#buttonColor').val() + ";'>" + $('#buttonText').val() + "</a><input type='hidden' id='buttonColor_" + editstatus.optionsCount + "' name='buttonColor_" + editstatus.optionsCount + "' value='" + $('#buttonColor').val() + "'><input type='hidden' id='textColor_" + editstatus.optionsCount + "' name='textColor_" + editstatus.optionsCount + "' value='" + $('#textColor').val() + "'><input type='hidden' id='detailType_" + editstatus.optionsCount + "' name='detailType_" + editstatus.optionsCount + "' value='" + detailTypeVal + "'></input><input type='hidden' id='noteType_" + editstatus.optionsCount + "' name='noteType_" + editstatus.optionsCount + "' value='" + noteTypeVal + "'></input><input type='hidden' id='requireGps_" + editstatus.optionsCount + "' name='requireGps_" + editstatus.optionsCount + "' value='" + requireGpsVal + "'></input></td><td style='text-align:center;'><a onclick='$(this).parent().parent().remove();' class='btn btn-xs btn-danger' data-original-title='Remove this option'>Remove</a></td></tr>");
9090
}
9191
editstatus.addOption = addOption;

Web/Resgrid.Web/wwwroot/js/app/internal/statuses/resgrid.statuses.newstatus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ var resgrid;
9393
var baseTypeVal = $('#baseType').length ? $('#baseType').val() : '-1';
9494
var detailTypeVal = $('#detailType').length ? $('#detailType').val() : '0';
9595
var noteTypeVal = $('#noteType').length ? $('#noteType').val() : '0';
96-
var requireGpsVal = $('#requireGps').length ? $('#requireGps').val() : 'false';
96+
var requireGpsVal = $('#requireGps').length && $('#requireGps').is(':checked') ? 'on' : 'false';
9797
$('#options tbody').first().append("<tr><td><input type='number' min='0' id='order_" + newstatus.optionsCount + "' name='order_" + newstatus.optionsCount + "' value='0' onkeypress='return resgrid.statuses.newstatus.isNumber(event)'></td><td>" + $('#buttonText').val() + "<input type='hidden' id='buttonText_" + newstatus.optionsCount + "' name='buttonText_" + newstatus.optionsCount + "' value='" + $('#buttonText').val() + "'></input><input type='hidden' id='baseType_" + newstatus.optionsCount + "' name='baseType_" + newstatus.optionsCount + "' value='" + baseTypeVal + "'></input></td><td><a class='btn btn-default' role='button' style='color:" + $('#textColor').val() + ";background:" + $('#buttonColor').val() + ";'>" + $('#buttonText').val() + "</a><input type='hidden' id='buttonColor_" + newstatus.optionsCount + "' name='buttonColor_" + newstatus.optionsCount + "' value='" + $('#buttonColor').val() + "'><input type='hidden' id='textColor_" + newstatus.optionsCount + "' name='textColor_" + newstatus.optionsCount + "' value='" + $('#textColor').val() + "'><input type='hidden' id='detailType_" + newstatus.optionsCount + "' name='detailType_" + newstatus.optionsCount + "' value='" + detailTypeVal + "'></input><input type='hidden' id='noteType_" + newstatus.optionsCount + "' name='noteType_" + newstatus.optionsCount + "' value='" + noteTypeVal + "'></input><input type='hidden' id='requireGps_" + newstatus.optionsCount + "' name='requireGps_" + newstatus.optionsCount + "' value='" + requireGpsVal + "'></input></td><td style='text-align:center;'><a onclick='$(this).parent().parent().remove();' class='btn btn-xs btn-danger' data-original-title='Remove this option'>Remove</a></td></tr>");
9898
}
9999
}

0 commit comments

Comments
 (0)