Skip to content

Commit 32b7f0d

Browse files
renemadsenclaude
andcommitted
Add gRPC server support for TimePlanning settings service
Adds proto definitions matching the Flutter client, gRPC service implementation for GetAssignedSite and GetRegistrationSites endpoints, and registers gRPC in the plugin's ConfigureServices/Configure methods. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent be9ab75 commit 32b7f0d

5 files changed

Lines changed: 555 additions & 0 deletions

File tree

eFormAPI/Plugins/TimePlanning.Pn/TimePlanning.Pn/EformTimePlanningPlugin.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ namespace TimePlanning.Pn;
7171
using Services.TimePlanningLocalizationService;
7272
using Services.TimePlanningPlanningService;
7373
using Services.TimePlanningWorkingHoursService;
74+
using Services.GrpcServices;
7475

7576
public class EformTimePlanningPlugin : IEformPlugin
7677
{
@@ -88,6 +89,7 @@ public Assembly PluginAssembly()
8889

8990
public void ConfigureServices(IServiceCollection services)
9091
{
92+
services.AddGrpc();
9193
services.AddTransient<ITimePlanningLocalizationService, TimePlanningLocalizationService>();
9294
services.AddTransient<ITimePlanningPlanningService, TimePlanningPlanningService>();
9395
services.AddTransient<ITimePlanningWorkingHoursService, TimePlanningWorkingHoursService>();
@@ -203,6 +205,11 @@ public void ConfigureDbContext(IServiceCollection services, string connectionStr
203205

204206
public void Configure(IApplicationBuilder appBuilder)
205207
{
208+
appBuilder.UseRouting();
209+
appBuilder.UseEndpoints(endpoints =>
210+
{
211+
endpoints.MapGrpcService<TimePlanningSettingsGrpcService>();
212+
});
206213
}
207214

208215
public List<PluginMenuItemModel> GetNavigationMenu(IServiceProvider serviceProvider)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
syntax = "proto3";
2+
3+
package timeplanning;
4+
5+
option csharp_namespace = "TimePlanning.Pn.Grpc";
6+
7+
// Matches C# OperationResult
8+
message OperationResult {
9+
bool success = 1;
10+
string message = 2;
11+
}
12+
13+
// Matches C# OperationDataResult<T> — generic payloads use oneof
14+
message Empty {}
Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
syntax = "proto3";
2+
3+
package timeplanning;
4+
5+
import "common.proto";
6+
import "google/protobuf/wrappers.proto";
7+
import "google/protobuf/timestamp.proto";
8+
9+
option csharp_namespace = "TimePlanning.Pn.Grpc";
10+
11+
// Matches C# AutoBreakSettings.Day
12+
message BreakDaySettings {
13+
int32 break_minutes_divider = 1;
14+
int32 break_minutes_pr_divider = 2;
15+
int32 break_minutes_upper_limit = 3;
16+
}
17+
18+
// Matches C# AutoBreakSettings
19+
message AutoBreakSettings {
20+
BreakDaySettings monday = 1;
21+
BreakDaySettings tuesday = 2;
22+
BreakDaySettings wednesday = 3;
23+
BreakDaySettings thursday = 4;
24+
BreakDaySettings friday = 5;
25+
BreakDaySettings saturday = 6;
26+
BreakDaySettings sunday = 7;
27+
}
28+
29+
// Matches C# AssignedSite (143 properties)
30+
// Field numbers are stable — never reuse a number
31+
message AssignedSite {
32+
int32 id = 1;
33+
string site_name = 2;
34+
int32 site_id = 3;
35+
google.protobuf.Int32Value case_microting_uid = 4;
36+
37+
// Shift 1 schedule (Monday-Sunday)
38+
google.protobuf.Int32Value start_monday = 5;
39+
google.protobuf.Int32Value end_monday = 6;
40+
google.protobuf.Int32Value break_monday = 7;
41+
google.protobuf.Int32Value start_tuesday = 8;
42+
google.protobuf.Int32Value end_tuesday = 9;
43+
google.protobuf.Int32Value break_tuesday = 10;
44+
google.protobuf.Int32Value start_wednesday = 11;
45+
google.protobuf.Int32Value end_wednesday = 12;
46+
google.protobuf.Int32Value break_wednesday = 13;
47+
google.protobuf.Int32Value start_thursday = 14;
48+
google.protobuf.Int32Value end_thursday = 15;
49+
google.protobuf.Int32Value break_thursday = 16;
50+
google.protobuf.Int32Value start_friday = 17;
51+
google.protobuf.Int32Value end_friday = 18;
52+
google.protobuf.Int32Value break_friday = 19;
53+
google.protobuf.Int32Value start_saturday = 20;
54+
google.protobuf.Int32Value end_saturday = 21;
55+
google.protobuf.Int32Value break_saturday = 22;
56+
google.protobuf.Int32Value start_sunday = 23;
57+
google.protobuf.Int32Value end_sunday = 24;
58+
google.protobuf.Int32Value break_sunday = 25;
59+
60+
bool resigned = 26;
61+
google.protobuf.Timestamp resigned_at_date = 27;
62+
63+
// Break calculation settings per day
64+
int32 monday_break_minutes_divider = 28;
65+
int32 monday_break_minutes_pr_divider = 29;
66+
int32 tuesday_break_minutes_divider = 30;
67+
int32 tuesday_break_minutes_pr_divider = 31;
68+
int32 wednesday_break_minutes_divider = 32;
69+
int32 wednesday_break_minutes_pr_divider = 33;
70+
int32 thursday_break_minutes_divider = 34;
71+
int32 thursday_break_minutes_pr_divider = 35;
72+
int32 friday_break_minutes_divider = 36;
73+
int32 friday_break_minutes_pr_divider = 37;
74+
int32 saturday_break_minutes_divider = 38;
75+
int32 saturday_break_minutes_pr_divider = 39;
76+
int32 sunday_break_minutes_divider = 40;
77+
int32 sunday_break_minutes_pr_divider = 41;
78+
79+
bool global_auto_break_calculation_active = 42;
80+
bool auto_break_calculation_active = 43;
81+
82+
int32 monday_break_minutes_upper_limit = 44;
83+
int32 tuesday_break_minutes_upper_limit = 45;
84+
int32 wednesday_break_minutes_upper_limit = 46;
85+
int32 thursday_break_minutes_upper_limit = 47;
86+
int32 friday_break_minutes_upper_limit = 48;
87+
int32 saturday_break_minutes_upper_limit = 49;
88+
int32 sunday_break_minutes_upper_limit = 50;
89+
90+
bool use_one_minute_intervals = 51;
91+
bool allow_accept_of_planned_hours = 52;
92+
bool allow_edit_of_registrations = 53;
93+
bool allow_personal_time_registration = 54;
94+
95+
// Shift 2 schedule (Monday-Sunday)
96+
google.protobuf.Int32Value start_monday_2nd_shift = 55;
97+
google.protobuf.Int32Value end_monday_2nd_shift = 56;
98+
google.protobuf.Int32Value break_monday_2nd_shift = 57;
99+
google.protobuf.Int32Value start_tuesday_2nd_shift = 58;
100+
google.protobuf.Int32Value end_tuesday_2nd_shift = 59;
101+
google.protobuf.Int32Value break_tuesday_2nd_shift = 60;
102+
google.protobuf.Int32Value start_wednesday_2nd_shift = 61;
103+
google.protobuf.Int32Value end_wednesday_2nd_shift = 62;
104+
google.protobuf.Int32Value break_wednesday_2nd_shift = 63;
105+
google.protobuf.Int32Value start_thursday_2nd_shift = 64;
106+
google.protobuf.Int32Value end_thursday_2nd_shift = 65;
107+
google.protobuf.Int32Value break_thursday_2nd_shift = 66;
108+
google.protobuf.Int32Value start_friday_2nd_shift = 67;
109+
google.protobuf.Int32Value end_friday_2nd_shift = 68;
110+
google.protobuf.Int32Value break_friday_2nd_shift = 69;
111+
google.protobuf.Int32Value start_saturday_2nd_shift = 70;
112+
google.protobuf.Int32Value end_saturday_2nd_shift = 71;
113+
google.protobuf.Int32Value break_saturday_2nd_shift = 72;
114+
google.protobuf.Int32Value start_sunday_2nd_shift = 73;
115+
google.protobuf.Int32Value end_sunday_2nd_shift = 74;
116+
google.protobuf.Int32Value break_sunday_2nd_shift = 75;
117+
118+
// Shift 3 schedule (Monday-Sunday)
119+
google.protobuf.Int32Value start_monday_3rd_shift = 76;
120+
google.protobuf.Int32Value end_monday_3rd_shift = 77;
121+
google.protobuf.Int32Value break_monday_3rd_shift = 78;
122+
google.protobuf.Int32Value start_tuesday_3rd_shift = 79;
123+
google.protobuf.Int32Value end_tuesday_3rd_shift = 80;
124+
google.protobuf.Int32Value break_tuesday_3rd_shift = 81;
125+
google.protobuf.Int32Value start_wednesday_3rd_shift = 82;
126+
google.protobuf.Int32Value end_wednesday_3rd_shift = 83;
127+
google.protobuf.Int32Value break_wednesday_3rd_shift = 84;
128+
google.protobuf.Int32Value start_thursday_3rd_shift = 85;
129+
google.protobuf.Int32Value end_thursday_3rd_shift = 86;
130+
google.protobuf.Int32Value break_thursday_3rd_shift = 87;
131+
google.protobuf.Int32Value start_friday_3rd_shift = 88;
132+
google.protobuf.Int32Value end_friday_3rd_shift = 89;
133+
google.protobuf.Int32Value break_friday_3rd_shift = 90;
134+
google.protobuf.Int32Value start_saturday_3rd_shift = 91;
135+
google.protobuf.Int32Value end_saturday_3rd_shift = 92;
136+
google.protobuf.Int32Value break_saturday_3rd_shift = 93;
137+
google.protobuf.Int32Value start_sunday_3rd_shift = 94;
138+
google.protobuf.Int32Value end_sunday_3rd_shift = 95;
139+
google.protobuf.Int32Value break_sunday_3rd_shift = 96;
140+
141+
// Shift 4 schedule (Monday-Sunday)
142+
google.protobuf.Int32Value start_monday_4th_shift = 97;
143+
google.protobuf.Int32Value end_monday_4th_shift = 98;
144+
google.protobuf.Int32Value break_monday_4th_shift = 99;
145+
google.protobuf.Int32Value start_tuesday_4th_shift = 100;
146+
google.protobuf.Int32Value end_tuesday_4th_shift = 101;
147+
google.protobuf.Int32Value break_tuesday_4th_shift = 102;
148+
google.protobuf.Int32Value start_wednesday_4th_shift = 103;
149+
google.protobuf.Int32Value end_wednesday_4th_shift = 104;
150+
google.protobuf.Int32Value break_wednesday_4th_shift = 105;
151+
google.protobuf.Int32Value start_thursday_4th_shift = 106;
152+
google.protobuf.Int32Value end_thursday_4th_shift = 107;
153+
google.protobuf.Int32Value break_thursday_4th_shift = 108;
154+
google.protobuf.Int32Value start_friday_4th_shift = 109;
155+
google.protobuf.Int32Value end_friday_4th_shift = 110;
156+
google.protobuf.Int32Value break_friday_4th_shift = 111;
157+
google.protobuf.Int32Value start_saturday_4th_shift = 112;
158+
google.protobuf.Int32Value end_saturday_4th_shift = 113;
159+
google.protobuf.Int32Value break_saturday_4th_shift = 114;
160+
google.protobuf.Int32Value start_sunday_4th_shift = 115;
161+
google.protobuf.Int32Value end_sunday_4th_shift = 116;
162+
google.protobuf.Int32Value break_sunday_4th_shift = 117;
163+
164+
// Shift 5 schedule (Monday-Sunday)
165+
google.protobuf.Int32Value start_monday_5th_shift = 118;
166+
google.protobuf.Int32Value end_monday_5th_shift = 119;
167+
google.protobuf.Int32Value break_monday_5th_shift = 120;
168+
google.protobuf.Int32Value start_tuesday_5th_shift = 121;
169+
google.protobuf.Int32Value end_tuesday_5th_shift = 122;
170+
google.protobuf.Int32Value break_tuesday_5th_shift = 123;
171+
google.protobuf.Int32Value start_wednesday_5th_shift = 124;
172+
google.protobuf.Int32Value end_wednesday_5th_shift = 125;
173+
google.protobuf.Int32Value break_wednesday_5th_shift = 126;
174+
google.protobuf.Int32Value start_thursday_5th_shift = 127;
175+
google.protobuf.Int32Value end_thursday_5th_shift = 128;
176+
google.protobuf.Int32Value break_thursday_5th_shift = 129;
177+
google.protobuf.Int32Value start_friday_5th_shift = 130;
178+
google.protobuf.Int32Value end_friday_5th_shift = 131;
179+
google.protobuf.Int32Value break_friday_5th_shift = 132;
180+
google.protobuf.Int32Value start_saturday_5th_shift = 133;
181+
google.protobuf.Int32Value end_saturday_5th_shift = 134;
182+
google.protobuf.Int32Value break_saturday_5th_shift = 135;
183+
google.protobuf.Int32Value start_sunday_5th_shift = 136;
184+
google.protobuf.Int32Value end_sunday_5th_shift = 137;
185+
google.protobuf.Int32Value break_sunday_5th_shift = 138;
186+
187+
bool use_google_sheet_as_default = 139;
188+
bool use_only_plan_hours = 140;
189+
int32 monday_plan_hours = 141;
190+
int32 tuesday_plan_hours = 142;
191+
int32 wednesday_plan_hours = 143;
192+
int32 thursday_plan_hours = 144;
193+
int32 friday_plan_hours = 145;
194+
int32 saturday_plan_hours = 146;
195+
int32 sunday_plan_hours = 147;
196+
197+
bool use_punch_clock = 148;
198+
bool use_detailed_pause_editing = 149;
199+
bool use_punch_clock_with_allow_registering_in_history = 150;
200+
int32 day_of_payment = 151;
201+
bool third_shift_active = 152;
202+
bool fourth_shift_active = 153;
203+
bool fifth_shift_active = 154;
204+
bool days_back_in_time_allowed_editing_enabled = 155;
205+
int32 days_back_in_time_allowed_editing = 156;
206+
bool gps_enabled = 157;
207+
bool snapshot_enabled = 158;
208+
bool is_manager = 159;
209+
repeated int32 managing_tag_ids = 160;
210+
AutoBreakSettings auto_break_settings = 161;
211+
212+
bool enforce_end_of_shift_before_allow_registration = 162;
213+
}
214+
215+
// Matches C# Site model
216+
message Site {
217+
int32 site_id = 1;
218+
string site_name = 2;
219+
string first_name = 3;
220+
string last_name = 4;
221+
int32 customer_no = 5;
222+
int32 otp_code = 6;
223+
int32 unit_id = 7;
224+
int32 worker_uid = 8;
225+
string email = 9;
226+
string pin_code = 10;
227+
string default_language = 11;
228+
bool hours_started = 12;
229+
bool pause_started = 13;
230+
bool auto_break_calculation_active = 14;
231+
string avatar_url = 15;
232+
bool third_shift_active = 16;
233+
bool fourth_shift_active = 17;
234+
bool fifth_shift_active = 18;
235+
bool snapshot_enabled = 19;
236+
bool resigned = 20;
237+
google.protobuf.Timestamp resigned_at_date = 21;
238+
}
239+
240+
// Response wrappers matching C# OperationDataResult<T>
241+
message GetAssignedSiteResponse {
242+
bool success = 1;
243+
string message = 2;
244+
AssignedSite model = 3;
245+
}
246+
247+
message GetRegistrationSitesResponse {
248+
bool success = 1;
249+
string message = 2;
250+
repeated Site model = 3;
251+
}
252+
253+
// Request messages
254+
message GetAssignedSiteRequest {}
255+
256+
message GetRegistrationSitesRequest {
257+
string token = 1;
258+
}
259+
260+
// gRPC service definition
261+
service TimePlanningSettingsService {
262+
// Maps to GET /api/time-planning-pn/settings/assigned-site
263+
rpc GetAssignedSite(GetAssignedSiteRequest) returns (GetAssignedSiteResponse);
264+
265+
// Maps to GET /api/time-planning-pn/settings/registration-sites
266+
rpc GetRegistrationSites(GetRegistrationSitesRequest) returns (GetRegistrationSitesResponse);
267+
}

0 commit comments

Comments
 (0)