Vereinsmeisterschaften  22aa7800eae54b428d40e835886cefe1fdefdfdf
This is a software that can be used to manage the internal competition of the swimming club Illertissen called "Vereinsmeisterschaften".
Loading...
Searching...
No Matches
DocumentPlaceholderResolverRace.cs
5
7{
12 {
17 public DocumentPlaceholderResolverRace(IWorkspaceService workspaceService) : base(workspaceService)
18 {
19 }
20
27 {
28 ushort numSwimLanes = _workspaceService?.Settings?.GetSettingValue<ushort>(WorkspaceSettings.GROUP_RACE_CALCULATION, WorkspaceSettings.SETTING_RACE_CALCULATION_NUMBER_OF_SWIM_LANES) ?? 3;
29
30 List<string> personBirthYears = item.Starts.Select(s => s.PersonObj?.BirthYear.ToString()).ToList();
31 List<string> personCompetitionIDs = item.Starts.Select(s => s.CompetitionObj?.Id.ToString() ?? "?").ToList();
32 List<string> personCompleteNames = item.Starts.Select(s => s.PersonObj?.FirstName + " " + s.PersonObj?.Name).ToList();
33 List<string> personFirstNames = item.Starts.Select(s => s.PersonObj?.FirstName).ToList();
34 List<string> personLastNames = item.Starts.Select(s => s.PersonObj?.Name).ToList();
35 List<string> personGenders = item.Starts.Select(s => EnumCoreLocalizedStringHelper.Convert(s.PersonObj?.Gender)).ToList();
36 List<string> personGenderSymbols = item.Starts.Select(s => s.PersonObj?.Gender == Genders.Male ? "♂" : "♀").ToList();
37
38 DocXPlaceholderHelper.TextPlaceholders textPlaceholder = new DocXPlaceholderHelper.TextPlaceholders();
39 for (int i = 0; i < numSwimLanes; i++)
40 {
41 foreach (string placeholder in Placeholders.Placeholders_Name) { textPlaceholder.Add(placeholder + (i + 1), personCompleteNames.Count > i ? personCompleteNames[i] : ""); }
42 foreach (string placeholder in Placeholders.Placeholders_FirstName) { textPlaceholder.Add(placeholder + (i + 1), personFirstNames.Count > i ? personFirstNames[i] : ""); }
43 foreach (string placeholder in Placeholders.Placeholders_LastName) { textPlaceholder.Add(placeholder + (i + 1), personLastNames.Count > i ? personLastNames[i] : ""); }
44 foreach (string placeholder in Placeholders.Placeholders_Gender) { textPlaceholder.Add(placeholder + (i + 1), personGenders.Count > i ? personGenders[i] : ""); }
45 foreach (string placeholder in Placeholders.Placeholders_GenderSymbol) { textPlaceholder.Add(placeholder + (i + 1), personGenderSymbols.Count > i ? personGenderSymbols[i] : ""); }
46 foreach (string placeholder in Placeholders.Placeholders_BirthYear) { textPlaceholder.Add(placeholder + (i + 1), personBirthYears.Count > i ? personBirthYears[i] : ""); }
47 foreach (string placeholder in Placeholders.Placeholders_CompetitionID) { textPlaceholder.Add(placeholder + (i + 1), personCompetitionIDs.Count > i ? personCompetitionIDs[i] : ""); }
48 foreach (string placeholder in Placeholders.Placeholders_Distance) { textPlaceholder.Add(placeholder + (i + 1), item.Distance.ToString() + "m"); }
49 foreach (string placeholder in Placeholders.Placeholders_SwimmingStyle) { textPlaceholder.Add(placeholder + (i + 1), EnumCoreLocalizedStringHelper.Convert(item.Style)); }
50 }
51 foreach (string placeholder in Placeholders.Placeholders_Name) { textPlaceholder.Add(placeholder, string.Join(", ", personCompleteNames)); }
52 foreach (string placeholder in Placeholders.Placeholders_FirstName) { textPlaceholder.Add(placeholder, string.Join(", ", personFirstNames)); }
53 foreach (string placeholder in Placeholders.Placeholders_LastName) { textPlaceholder.Add(placeholder, string.Join(", ", personLastNames)); }
54 foreach (string placeholder in Placeholders.Placeholders_Gender) { textPlaceholder.Add(placeholder, string.Join(", ", personGenders)); }
55 foreach (string placeholder in Placeholders.Placeholders_GenderSymbol) { textPlaceholder.Add(placeholder, string.Join(", ", personGenderSymbols)); }
56 foreach (string placeholder in Placeholders.Placeholders_BirthYear) { textPlaceholder.Add(placeholder, string.Join(", ", personBirthYears)); }
57 foreach (string placeholder in Placeholders.Placeholders_CompetitionID) { textPlaceholder.Add(placeholder, string.Join(", ", personCompetitionIDs)); }
58 foreach (string placeholder in Placeholders.Placeholders_Distance) { textPlaceholder.Add(placeholder, item.Distance.ToString() + "m"); }
59 foreach (string placeholder in Placeholders.Placeholders_SwimmingStyle) { textPlaceholder.Add(placeholder, EnumCoreLocalizedStringHelper.Convert(item.Style)); }
60 foreach (string placeholder in Placeholders.Placeholders_RaceNumber) { textPlaceholder.Add(placeholder, item.RaceID.ToString()); }
61 return textPlaceholder;
62 }
63
65 public override List<string> SupportedPlaceholderKeys => new List<string>()
66 {
67 Placeholders.PLACEHOLDER_KEY_NAME,
68 Placeholders.PLACEHOLDER_KEY_FIRSTNAME,
69 Placeholders.PLACEHOLDER_KEY_LASTNAME,
70 Placeholders.PLACEHOLDER_KEY_GENDER,
71 Placeholders.PLACEHOLDER_KEY_GENDER_SYMBOL,
72 Placeholders.PLACEHOLDER_KEY_BIRTH_YEAR,
73 Placeholders.PLACEHOLDER_KEY_COMPETITION_ID,
74 Placeholders.PLACEHOLDER_KEY_DISTANCE,
75 Placeholders.PLACEHOLDER_KEY_SWIMMING_STYLE,
76 Placeholders.PLACEHOLDER_KEY_RACE_NUMBER
77 };
78
80 public override List<int> PostfixNumbersSupported
81 {
82 get
83 {
84 ushort numSwimLanes = _workspaceService?.Settings?.GetSettingValue<ushort>(WorkspaceSettings.GROUP_RACE_CALCULATION, WorkspaceSettings.SETTING_RACE_CALCULATION_NUMBER_OF_SWIM_LANES) ?? 3;
85 return Enumerable.Repeat((int)numSwimLanes, SupportedPlaceholderKeys.Count - 1).ToList(); // -1 because PLACEHOLDER_KEY_RACE_NUMBER doesn't support postfix numbers
86 }
87 }
88
89 }
90}
DocumentPlaceholderResolverBase(IWorkspaceService workspaceService)
Base constructor for a document placeholder resolver.
override DocXPlaceholderHelper.TextPlaceholders ResolveTextPlaceholders(Race item)
Take the Race item and create DocXPlaceholderHelper.TextPlaceholders.
override List< int > PostfixNumbersSupported
List of all postfix numbers that are supported by this resolver.
override List< string > SupportedPlaceholderKeys
List of all placeholder keys that are supported by this resolver.
DocumentPlaceholderResolverRace(IWorkspaceService workspaceService)
Constructor for a document placeholder resolver.
void Add(string placeholder, string value)
Add a placeholder to the dictionary.
Class that represents a single race.
Definition Race.cs:12
int Distance
Distance for this Race.
Definition Race.cs:82
ObservableCollection< PersonStart > Starts
List with all starts of this Race
Definition Race.cs:90
SwimmingStyles Style
for this .
Definition Race.cs:76
Interface for a service used to manage a workspace.
Genders
Available genders for a person.
Definition Genders.cs:7