Skip to content

Commit 9f8338d

Browse files
committed
wip
1 parent 32adcf1 commit 9f8338d

8 files changed

Lines changed: 1106 additions & 18 deletions

File tree

ShiftSharp/NonWorkingPeriod.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
SOFTWARE.
2323
*/
2424

25-
26-
using System;
27-
using System.Collections.Generic;
28-
using System.Linq;
29-
using System.Text;
30-
using System.Threading.Tasks;
3125
using NodaTime;
26+
using System;
3227

3328
namespace Point85.ShiftSharp.Schedule
3429
{
@@ -51,7 +46,7 @@ public NonWorkingPeriod() : base()
5146
{
5247
}
5348

54-
NonWorkingPeriod(string name, string description, LocalDateTime startDateTime, Duration duration) : base(name, description)
49+
internal NonWorkingPeriod(string name, string description, LocalDateTime startDateTime, Duration duration) : base(name, description)
5550
{
5651
SetStartDateTime(startDateTime);
5752
SetDuration(duration);
@@ -153,7 +148,7 @@ public WorkSchedule GetWorkSchedule()
153148
return workSchedule;
154149
}
155150

156-
void SetWorkSchedule(WorkSchedule workSchedule)
151+
internal void SetWorkSchedule(WorkSchedule workSchedule)
157152
{
158153
this.workSchedule = workSchedule;
159154
}

ShiftSharp/Rotation.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2323
*/
2424

2525

26+
using NodaTime;
2627
using System;
2728
using System.Collections.Generic;
28-
using System.Linq;
29-
using System.Text;
30-
using System.Threading.Tasks;
31-
using NodaTime;
3229

3330
namespace Point85.ShiftSharp.Schedule
3431
{

ShiftSharp/RotationSegment.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
SOFTWARE.
2323
*/
2424

25-
2625
using System;
2726
using System.Collections.Generic;
2827
using System.Linq;

ShiftSharp/Shift.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public Shift() : base()
4646
{
4747
}
4848

49-
Shift(String name, String description, LocalTime start, Duration duration) : base(name, description, start, duration)
49+
internal Shift(String name, String description, LocalTime start, Duration duration) : base(name, description, start, duration)
5050
{
5151
}
5252

@@ -314,7 +314,7 @@ public WorkSchedule GetWorkSchedule()
314314
return workSchedule;
315315
}
316316

317-
void SetWorkSchedule(WorkSchedule workSchedule)
317+
internal void SetWorkSchedule(WorkSchedule workSchedule)
318318
{
319319
this.workSchedule = workSchedule;
320320
}

ShiftSharp/ShiftInstance.cs

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*
2+
MIT License
3+
4+
Copyright (c) 2016 Kent Randall
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
25+
using NodaTime;
26+
using System;
27+
28+
namespace Point85.ShiftSharp.Schedule
29+
{
30+
/// <summary>
31+
/// Class ShiftInstance is an instance of a {@link Shift}. A shift instance is worked by a Team.
32+
/// </summary>
33+
public class ShiftInstance : IComparable<ShiftInstance>
34+
{
35+
// definition of the shift
36+
private Shift shift;
37+
38+
// team working it
39+
private Team team;
40+
41+
// start date and time of day
42+
private LocalDateTime startDateTime;
43+
44+
internal ShiftInstance(Shift shift, LocalDateTime startDateTime, Team team)
45+
{
46+
this.shift = shift;
47+
this.startDateTime = startDateTime;
48+
this.team = team;
49+
}
50+
51+
/**
52+
* Get the shift for this instance
53+
*
54+
* @return {@link Shift}
55+
*/
56+
public Shift GetShift()
57+
{
58+
return shift;
59+
}
60+
61+
/**
62+
* Get the starting date and time of day
63+
*
64+
* @return LocalDateTime
65+
*/
66+
public LocalDateTime GetStartTime()
67+
{
68+
return startDateTime;
69+
}
70+
71+
/**
72+
* Get the end date and time of day
73+
*
74+
* @return LocalDateTime
75+
*/
76+
public LocalDateTime GetEndTime()
77+
{
78+
Duration duration = shift.GetDuration();
79+
return startDateTime.PlusSeconds((long)duration.TotalSeconds);
80+
}
81+
82+
/**
83+
* Get the team
84+
*
85+
* @return {@link Team}
86+
*/
87+
public Team GetTeam()
88+
{
89+
return team;
90+
}
91+
92+
/**
93+
* Compare this non-working period to another such period by start time of
94+
* day
95+
*
96+
* @return -1 if less than, 0 if equal and 1 if greater than
97+
*/
98+
public int CompareTo(ShiftInstance other)
99+
{
100+
throw new NotImplementedException();
101+
}
102+
103+
/**
104+
* Build a string representation of a shift instance
105+
*/
106+
public override string ToString()
107+
{
108+
string t = WorkSchedule.GetMessage("team");
109+
string s = WorkSchedule.GetMessage("shift");
110+
string ps = WorkSchedule.GetMessage("period.start");
111+
string pe = WorkSchedule.GetMessage("period.end");
112+
113+
string text = " " + t + ": " + GetTeam().GetName() + ", " + s + ": " + GetShift().GetName() + ", " + ps + ": "
114+
+ GetStartTime() + ", " + pe + ": " + GetEndTime();
115+
return text;
116+
}
117+
118+
}
119+
}

0 commit comments

Comments
 (0)