Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit55313dc

Browse files
committed
CU-8687aj3gt Added logic for department code in Notification pushes
1 parentc376755 commit55313dc

File tree

10 files changed

+45
-30
lines changed

10 files changed

+45
-30
lines changed

‎Core/Resgrid.Model/Services/ICommunicationService.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Task<bool> SendUnitCallAsync(Call call, CallDispatchUnit dispatch, string depart
5555
/// <param name="title">The title.</param>
5656
/// <param name="profile">The profile.</param>
5757
/// <returns>Task&lt;System.Boolean&gt;.</returns>
58-
Task<bool>SendNotificationAsync(stringuserId,intdepartmentId,stringmessage,stringdepartmentNumber,
58+
Task<bool>SendNotificationAsync(stringuserId,intdepartmentId,stringmessage,stringdepartmentNumber,Departmentdepartment,
5959
stringtitle="Notification",UserProfileprofile=null);
6060

6161
/// <summary>

‎Core/Resgrid.Services/CalendarService.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,9 @@ public async Task<bool> NotifyNewCalendarItemAsync(CalendarItem calendarItem)
487487
foreach(varmemberingroup.Members)
488488
{
489489
if(profiles.ContainsKey(member.UserId))
490-
await_communicationService.SendNotificationAsync(member.UserId,calendarItem.DepartmentId,message,departmentNumber,title,profiles[member.UserId]);
490+
await_communicationService.SendNotificationAsync(member.UserId,calendarItem.DepartmentId,message,departmentNumber,department,title,profiles[member.UserId]);
491491
else
492-
await_communicationService.SendNotificationAsync(member.UserId,calendarItem.DepartmentId,message,departmentNumber,title,null);
492+
await_communicationService.SendNotificationAsync(member.UserId,calendarItem.DepartmentId,message,departmentNumber,department,title,null);
493493
}
494494
}
495495
}

‎Core/Resgrid.Services/CommunicationService.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public async Task<bool> SendUnitCallAsync(Call call, CallDispatchUnit dispatch,
290290
returntrue;
291291
}
292292

293-
publicasyncTask<bool>SendNotificationAsync(stringuserId,intdepartmentId,stringmessage,stringdepartmentNumber,stringtitle="Notification",UserProfileprofile=null)
293+
publicasyncTask<bool>SendNotificationAsync(stringuserId,intdepartmentId,stringmessage,stringdepartmentNumber,Departmentdepartment,stringtitle="Notification",UserProfileprofile=null)
294294
{
295295
if(Config.SystemBehaviorConfig.DoNotBroadcast&&!Config.SystemBehaviorConfig.BypassDoNotBroadcastDepartments.Contains(departmentId))
296296
returnfalse;
@@ -319,6 +319,7 @@ public async Task<bool> SendNotificationAsync(string userId, int departmentId, s
319319
varspm=newStandardPushMessage();
320320
spm.Title="Notification";
321321
spm.SubTitle=$"{title}{message}";
322+
spm.DepartmentCode=department?.Code;
322323

323324
try
324325
{

‎Core/Resgrid.Services/TrainingService.cs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ public async Task<bool> SendInitialTrainingNoticeAsync(Training training)
180180
else
181181
message=string.Format("Training ({0}) assigned to you",training.Name);
182182

183-
await_communicationService.SendNotificationAsync(user.UserId,training.DepartmentId,message,"New Training");
183+
vardepartment=await_departmentService.GetDepartmentByIdAsync(training.DepartmentId);
184+
185+
await_communicationService.SendNotificationAsync(user.UserId,training.DepartmentId,message,"New Training",department);
184186
}
185187

186188
returntrue;

‎Providers/Resgrid.Providers.Messaging/NovuProvider.cs‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ private async Task<bool> CreateSubscriber(string id, int departmentId, string em
2121
{
2222
varrequestUrl=$"{ChatConfig.NovuBackendUrl}/v2/subscribers";
2323
httpClient.DefaultRequestHeaders.Add("idempotency-key",Guid.NewGuid().ToString());
24-
httpClient.DefaultRequestHeaders.Add("Authorization",Config.ChatConfig.NovuSecretKey);
24+
httpClient.DefaultRequestHeaders.Add("Authorization",$"ApiKey{ChatConfig.NovuSecretKey}");
2525

2626
varpayload=new
2727
{
@@ -45,7 +45,8 @@ private async Task<bool> CreateSubscriber(string id, int departmentId, string em
4545
payload.data.Add(item.Key,item.Value);
4646
}
4747
}
48-
stringjsonContent=JsonConvert.SerializeObject(payload);
48+
49+
stringjsonContent=JsonConvert.SerializeObject(payload,newJsonSerializerSettings{NullValueHandling=NullValueHandling.Ignore});
4950

5051
varcontent=newStringContent(jsonContent,Encoding.UTF8,"application/json");
5152

@@ -115,7 +116,7 @@ private async Task<bool> UpdateSubscriberFcm(string id, string token, string fcm
115116
},
116117
integrationIdentifier=fcmId
117118
};
118-
stringjsonContent=JsonConvert.SerializeObject(payload);
119+
stringjsonContent=JsonConvert.SerializeObject(payload,newJsonSerializerSettings{NullValueHandling=NullValueHandling.Ignore});
119120

120121
request.Content=newStringContent(jsonContent,Encoding.UTF8,"application/json");
121122
HttpResponseMessageresponse=awaitclient.SendAsync(request);
@@ -151,7 +152,7 @@ private async Task<bool> UpdateSubscriberApns(string id, string token, string ap
151152
},
152153
integrationIdentifier=apnsId
153154
};
154-
stringjsonContent=JsonConvert.SerializeObject(payload);
155+
stringjsonContent=JsonConvert.SerializeObject(payload,newJsonSerializerSettings{NullValueHandling=NullValueHandling.Ignore});
155156

156157
request.Content=newStringContent(jsonContent,Encoding.UTF8,"application/json");
157158
HttpResponseMessageresponse=awaitclient.SendAsync(request);
@@ -272,10 +273,12 @@ private async Task<bool> SendNotification(string title, string body, string reci
272273
};
273274

274275
varcontent=newStringContent(
275-
JsonConvert.SerializeObject(payload),
276+
JsonConvert.SerializeObject(payload,newJsonSerializerSettings{NullValueHandling=NullValueHandling.Ignore}),
276277
Encoding.UTF8,
277278
"application/json");
278279

280+
281+
279282
varresult=awaithttpClient.PostAsync("v1/events/trigger",content);
280283

281284
returnresult.IsSuccessStatusCode;

‎Workers/Resgrid.Workers.Framework/Logic/CalendarNotifierLogic.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public async Task<Tuple<bool,string>> Process(CalendarNotifierQueueItem item)
5757
foreach(varpersoninitem.CalendarItem.Attendees)
5858
{
5959
varprofile=profiles.FirstOrDefault(x=>x.UserId==person.UserId);
60-
await_communicationService.SendNotificationAsync(person.UserId,item.CalendarItem.DepartmentId,message,departmentNumber,title,profile);
60+
await_communicationService.SendNotificationAsync(person.UserId,item.CalendarItem.DepartmentId,message,departmentNumber,department,title,profile);
6161
}
6262
}
6363
}
@@ -96,7 +96,7 @@ public async Task<Tuple<bool,string>> Process(CalendarNotifierQueueItem item)
9696
// Notify the entire department
9797
foreach(varprofileinprofiles)
9898
{
99-
await_communicationService.SendNotificationAsync(profile.Key,item.CalendarItem.DepartmentId,message,departmentNumber,title,profile.Value);
99+
await_communicationService.SendNotificationAsync(profile.Key,item.CalendarItem.DepartmentId,message,departmentNumber,department,title,profile.Value);
100100
}
101101
}
102102
else
@@ -114,9 +114,9 @@ public async Task<Tuple<bool,string>> Process(CalendarNotifierQueueItem item)
114114
foreach(varmemberingroup.Members)
115115
{
116116
if(profiles.ContainsKey(member.UserId))
117-
await_communicationService.SendNotificationAsync(member.UserId,item.CalendarItem.DepartmentId,message,departmentNumber,title,profiles[member.UserId]);
117+
await_communicationService.SendNotificationAsync(member.UserId,item.CalendarItem.DepartmentId,message,departmentNumber,department,title,profiles[member.UserId]);
118118
else
119-
await_communicationService.SendNotificationAsync(member.UserId,item.CalendarItem.DepartmentId,message,departmentNumber,title,null);
119+
await_communicationService.SendNotificationAsync(member.UserId,item.CalendarItem.DepartmentId,message,departmentNumber,department,title,null);
120120
}
121121
}
122122
}

‎Workers/Resgrid.Workers.Framework/Logic/NotificationBroadcastLogic.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static async Task<bool> ProcessNotificationItem(NotificationItem ni, stri
7070
if(!_notificationService.AllowToSendViaSms(notification.Type))
7171
profile.SendNotificationSms=false;
7272

73-
await_communicationService.SendNotificationAsync(user,notification.DepartmentId,text,queueItem.DepartmentTextNumber,"Notification",profile);
73+
await_communicationService.SendNotificationAsync(user,notification.DepartmentId,text,queueItem.DepartmentTextNumber,queueItem.Department,"Notification",profile);
7474
}
7575
}
7676
}

‎Workers/Resgrid.Workers.Framework/Logic/ShiftNotificationLogic.cs‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ public static async Task<bool> ProcessShiftQueueItem(ShiftQueueItem sqi)
1717
var_shiftsService=Bootstrapper.GetKernel().Resolve<IShiftsService>();
1818
var_communicationService=Bootstrapper.GetKernel().Resolve<ICommunicationService>();
1919
var_userProfileService=Bootstrapper.GetKernel().Resolve<IUserProfileService>();
20+
var_departmentService=Bootstrapper.GetKernel().Resolve<IDepartmentsService>();
21+
22+
vardepartment=await_departmentService.GetDepartmentByIdAsync(sqi.DepartmentId,false);
2023

2124
if(sqi.Type==(int)ShiftQueueTypes.TradeRequested)
2225
{
@@ -28,7 +31,7 @@ public static async Task<bool> ProcessShiftQueueItem(ShiftQueueItem sqi)
2831
foreach(varuserintradeRequest.Users)
2932
{
3033
UserProfileprofile=userProfiles.FirstOrDefault(x=>x.UserId==user.UserId);
31-
await_communicationService.SendNotificationAsync(user.UserId,tradeRequest.SourceShiftSignup.Shift.DepartmentId,text,sqi.DepartmentNumber,
34+
await_communicationService.SendNotificationAsync(user.UserId,tradeRequest.SourceShiftSignup.Shift.DepartmentId,text,sqi.DepartmentNumber,department,
3235
tradeRequest.SourceShiftSignup.Shift.Name,profile);
3336
}
3437
}
@@ -40,7 +43,7 @@ await _communicationService.SendNotificationAsync(user.UserId, tradeRequest.Sour
4043

4144
vartext=_shiftsService.GenerateShiftTradeRejectionText(targetUserProfile,tradeRequest);
4245

43-
await_communicationService.SendNotificationAsync(sourceUserProfile.UserId,tradeRequest.SourceShiftSignup.Shift.DepartmentId,text,sqi.DepartmentNumber,
46+
await_communicationService.SendNotificationAsync(sourceUserProfile.UserId,tradeRequest.SourceShiftSignup.Shift.DepartmentId,text,sqi.DepartmentNumber,department,
4447
tradeRequest.SourceShiftSignup.Shift.Name,sourceUserProfile);
4548
}
4649
elseif(sqi.Type==(int)ShiftQueueTypes.TradeProposed&&!String.IsNullOrWhiteSpace(sqi.SourceUserId))
@@ -51,7 +54,7 @@ await _communicationService.SendNotificationAsync(sourceUserProfile.UserId, trad
5154

5255
vartext=_shiftsService.GenerateShiftTradeProposedText(proposedUserProfile,tradeRequest);
5356

54-
await_communicationService.SendNotificationAsync(sourceUserProfile.UserId,tradeRequest.SourceShiftSignup.Shift.DepartmentId,text,sqi.DepartmentNumber,
57+
await_communicationService.SendNotificationAsync(sourceUserProfile.UserId,tradeRequest.SourceShiftSignup.Shift.DepartmentId,text,sqi.DepartmentNumber,department,
5558
tradeRequest.SourceShiftSignup.Shift.Name,sourceUserProfile);
5659
}
5760
elseif(sqi.Type==(int)ShiftQueueTypes.TradeFilled&&!String.IsNullOrWhiteSpace(sqi.SourceUserId))
@@ -62,7 +65,7 @@ await _communicationService.SendNotificationAsync(sourceUserProfile.UserId, trad
6265

6366
vartext=_shiftsService.GenerateShiftTradeFilledText(sourceUserProfile,tradeRequest);
6467

65-
await_communicationService.SendNotificationAsync(proposedUserProfile.UserId,tradeRequest.SourceShiftSignup.Shift.DepartmentId,text,sqi.DepartmentNumber,
68+
await_communicationService.SendNotificationAsync(proposedUserProfile.UserId,tradeRequest.SourceShiftSignup.Shift.DepartmentId,text,sqi.DepartmentNumber,department,
6669
tradeRequest.SourceShiftSignup.Shift.Name,proposedUserProfile);
6770
}
6871
elseif(sqi.Type==(int)ShiftQueueTypes.ShiftCreated)
@@ -74,7 +77,7 @@ await _communicationService.SendNotificationAsync(proposedUserProfile.UserId, tr
7477

7578
foreach(varprofileinprofiles.Select(x=>x.Value))
7679
{
77-
await_communicationService.SendNotificationAsync(profile.UserId,sqi.DepartmentId,text,sqi.DepartmentNumber,"New Shift",profile);
80+
await_communicationService.SendNotificationAsync(profile.UserId,sqi.DepartmentId,text,sqi.DepartmentNumber,department,"New Shift",profile);
7881
}
7982
}
8083
elseif(sqi.Type==(int)ShiftQueueTypes.ShiftUpdated)
@@ -87,9 +90,9 @@ await _communicationService.SendNotificationAsync(proposedUserProfile.UserId, tr
8790
foreach(varprofileinshift.Personnel)
8891
{
8992
if(profiles.ContainsKey(profile.UserId))
90-
await_communicationService.SendNotificationAsync(profile.UserId,sqi.DepartmentId,text,sqi.DepartmentNumber,shift.Name,profiles[profile.UserId]);
93+
await_communicationService.SendNotificationAsync(profile.UserId,sqi.DepartmentId,text,sqi.DepartmentNumber,department,shift.Name,profiles[profile.UserId]);
9194
else
92-
await_communicationService.SendNotificationAsync(profile.UserId,sqi.DepartmentId,text,sqi.DepartmentNumber,shift.Name);
95+
await_communicationService.SendNotificationAsync(profile.UserId,sqi.DepartmentId,text,sqi.DepartmentNumber,department,shift.Name);
9396
}
9497
}
9598
elseif(sqi.Type==(int)ShiftQueueTypes.ShiftDaysAdded)
@@ -104,9 +107,9 @@ await _communicationService.SendNotificationAsync(proposedUserProfile.UserId, tr
104107
foreach(varprofileinshift.Personnel)
105108
{
106109
if(profiles.ContainsKey(profile.UserId))
107-
await_communicationService.SendNotificationAsync(profile.UserId,sqi.DepartmentId,text,sqi.DepartmentNumber,shift.Name,profiles[profile.UserId]);
110+
await_communicationService.SendNotificationAsync(profile.UserId,sqi.DepartmentId,text,sqi.DepartmentNumber,department,shift.Name,profiles[profile.UserId]);
108111
else
109-
await_communicationService.SendNotificationAsync(profile.UserId,sqi.DepartmentId,text,sqi.DepartmentNumber,shift.Name);
112+
await_communicationService.SendNotificationAsync(profile.UserId,sqi.DepartmentId,text,sqi.DepartmentNumber,department,shift.Name);
110113
}
111114
}
112115
}

‎Workers/Resgrid.Workers.Framework/Logic/ShiftNotifierLogic.cs‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ public class ShiftNotifierLogic
1414
privateIShiftsService_shiftsService;
1515
privateICommunicationService_communicationService;
1616
privateIDepartmentSettingsService_departmentSettingsService;
17+
privateIDepartmentsService_departmentsService;
1718

1819
publicShiftNotifierLogic()
1920
{
2021
_shiftsService=Bootstrapper.GetKernel().Resolve<IShiftsService>();
2122
_communicationService=Bootstrapper.GetKernel().Resolve<ICommunicationService>();
2223
_departmentSettingsService=Bootstrapper.GetKernel().Resolve<IDepartmentSettingsService>();
24+
_departmentsService=Bootstrapper.GetKernel().Resolve<IDepartmentsService>();
2325
}
2426

2527
publicasyncTask<Tuple<bool,string>>Process(ShiftNotifierQueueItemitem)
@@ -31,6 +33,7 @@ public async Task<Tuple<bool, string>> Process(ShiftNotifierQueueItem item)
3133
{
3234
vartext=_shiftsService.GenerateShiftNotificationText(item.Shift);
3335
stringdepartmentNumber=await_departmentSettingsService.GetTextToCallNumberForDepartmentAsync(item.Shift.DepartmentId);
36+
vardepartment=await_departmentsService.GetDepartmentByIdAsync(item.Shift.DepartmentId,false);
3437

3538
if(ConfigHelper.CanTransmit(item.Shift.DepartmentId))
3639
{
@@ -39,7 +42,7 @@ public async Task<Tuple<bool, string>> Process(ShiftNotifierQueueItem item)
3942
foreach(varpersoninitem.Shift.Personnel)
4043
{
4144
UserProfileprofile=item.Profiles.FirstOrDefault(x=>x.UserId==person.UserId);
42-
await_communicationService.SendNotificationAsync(person.UserId,item.Shift.DepartmentId,text,departmentNumber,
45+
await_communicationService.SendNotificationAsync(person.UserId,item.Shift.DepartmentId,text,departmentNumber,department,
4346
item.Shift.Name,profile);
4447
}
4548
}
@@ -53,26 +56,26 @@ await _communicationService.SendNotificationAsync(person.UserId, item.Shift.Depa
5356
if(!String.IsNullOrWhiteSpace(signup.Trade.UserId))
5457
{
5558
UserProfileprofile=item.Profiles.FirstOrDefault(x=>x.UserId==signup.Trade.UserId);
56-
await_communicationService.SendNotificationAsync(signup.Trade.UserId,item.Shift.DepartmentId,text,departmentNumber,
59+
await_communicationService.SendNotificationAsync(signup.Trade.UserId,item.Shift.DepartmentId,text,departmentNumber,department,
5760
item.Shift.Name,profile);
5861
}
5962
elseif(signup.GetTradeType()==ShiftTradeTypes.Source)
6063
{
6164
UserProfileprofile=item.Profiles.FirstOrDefault(x=>x.UserId==signup.Trade.TargetShiftSignup.UserId);
62-
await_communicationService.SendNotificationAsync(signup.Trade.TargetShiftSignup.UserId,item.Shift.DepartmentId,text,departmentNumber,
65+
await_communicationService.SendNotificationAsync(signup.Trade.TargetShiftSignup.UserId,item.Shift.DepartmentId,text,departmentNumber,department,
6366
item.Shift.Name,profile);
6467
}
6568
elseif(signup.GetTradeType()==ShiftTradeTypes.Target)
6669
{
6770
UserProfileprofile=item.Profiles.FirstOrDefault(x=>x.UserId==signup.Trade.SourceShiftSignup.UserId);
68-
await_communicationService.SendNotificationAsync(signup.Trade.SourceShiftSignup.UserId,item.Shift.DepartmentId,text,departmentNumber,
71+
await_communicationService.SendNotificationAsync(signup.Trade.SourceShiftSignup.UserId,item.Shift.DepartmentId,text,departmentNumber,department,
6972
item.Shift.Name,profile);
7073
}
7174
}
7275
else
7376
{
7477
UserProfileprofile=item.Profiles.FirstOrDefault(x=>x.UserId==signup.UserId);
75-
await_communicationService.SendNotificationAsync(signup.UserId,item.Shift.DepartmentId,text,departmentNumber,
78+
await_communicationService.SendNotificationAsync(signup.UserId,item.Shift.DepartmentId,text,departmentNumber,department,
7679
item.Shift.Name,profile);
7780
}
7881
}

‎Workers/Resgrid.Workers.Framework/Logic/TrainingNotifierLogic.cs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ public class TrainingNotifierLogic
1414
privateICommunicationService_communicationService;
1515
privateIUserProfileService_userProfileService;
1616
privateIDepartmentSettingsService_departmentSettingsService;
17+
privateIDepartmentsService_departmentsService;
1718

1819
publicTrainingNotifierLogic()
1920
{
2021
_trainingService=Bootstrapper.GetKernel().Resolve<ITrainingService>();
2122
_communicationService=Bootstrapper.GetKernel().Resolve<ICommunicationService>();
2223
_userProfileService=Bootstrapper.GetKernel().Resolve<IUserProfileService>();
2324
_departmentSettingsService=Bootstrapper.GetKernel().Resolve<IDepartmentSettingsService>();
25+
_departmentsService=Bootstrapper.GetKernel().Resolve<IDepartmentsService>();
2426
}
2527

2628
publicasyncTask<Tuple<bool,string>>Process(TrainingNotifierQueueItemitem)
@@ -34,6 +36,7 @@ public async Task<Tuple<bool, string>> Process(TrainingNotifierQueueItem item)
3436
vartitle=String.Empty;
3537
varprofiles=await_userProfileService.GetSelectedUserProfilesAsync(item.Training.Users.Select(x=>x.UserId).ToList());
3638
vardepartmentNumber=await_departmentSettingsService.GetTextToCallNumberForDepartmentAsync(item.Training.DepartmentId);
39+
vardepartment=await_departmentsService.GetDepartmentByIdAsync(item.Training.DepartmentId,false);
3740

3841
if(ConfigHelper.CanTransmit(item.Training.DepartmentId))
3942
{
@@ -57,7 +60,7 @@ public async Task<Tuple<bool, string>> Process(TrainingNotifierQueueItem item)
5760
varprofile=profiles.FirstOrDefault(x=>x.UserId==person.UserId);
5861

5962
if(!item.Training.Notified.HasValue||!person.Complete)
60-
await_communicationService.SendNotificationAsync(person.UserId,item.Training.DepartmentId,message,departmentNumber,title,profile);
63+
await_communicationService.SendNotificationAsync(person.UserId,item.Training.DepartmentId,message,departmentNumber,department,title,profile);
6164

6265
title="Training Due Notice";
6366
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp