• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

HicServices / RDMP / 6245535001

20 Sep 2023 07:44AM UTC coverage: 57.013%. First build
6245535001

push

github

web-flow
8.1.0 Release (#1628)

* Bump Newtonsoft.Json from 13.0.1 to 13.0.2

Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 13.0.1 to 13.0.2.
- [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/13.0.1...13.0.2)

---
updated-dependencies:
- dependency-name: Newtonsoft.Json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump NLog from 5.0.5 to 5.1.0

Bumps [NLog](https://github.com/NLog/NLog) from 5.0.5 to 5.1.0.
- [Release notes](https://github.com/NLog/NLog/releases)
- [Changelog](https://github.com/NLog/NLog/blob/dev/CHANGELOG.md)
- [Commits](https://github.com/NLog/NLog/compare/v5.0.5...v5.1.0)

---
updated-dependencies:
- dependency-name: NLog
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump NLog from 5.0.5 to 5.1.0

* Fix -r flag - should have been --results-directory all along

* Bump Newtonsoft.Json from 13.0.1 to 13.0.2

* Bump YamlDotNet from 12.0.2 to 12.1.0

Bumps [YamlDotNet](https://github.com/aaubry/YamlDotNet) from 12.0.2 to 12.1.0.
- [Release notes](https://github.com/aaubry/YamlDotNet/releases)
- [Commits](https://github.com/aaubry/YamlDotNet/compare/v12.0.2...v12.1.0)

---
updated-dependencies:
- dependency-name: YamlDotNet
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump Moq from 4.18.2 to 4.18.3

Bumps [Moq](https://github.com/moq/moq4) from 4.18.2 to 4.18.3.
- [Release notes](https://github.com/moq/moq4/releases)
- [Changelog](https://github.com/moq/moq4/blob/main/CHANGELOG.md)
- [Commits](https://github.com/moq/moq4/compare/v4.18.2...v4.18.3)

---
updated-dependencies:
- dependency-name: Moq
... (continued)

10732 of 20257 branches covered (0.0%)

Branch coverage included in aggregate %.

48141 of 48141 new or added lines in 1086 files covered. (100.0%)

30685 of 52388 relevant lines covered (58.57%)

7387.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

38.46
/Rdmp.Core/ReusableLibraryCode/Settings/UserSettings.cs
1
// Copyright (c) The University of Dundee 2018-2019
2
// This file is part of the Research Data Management Platform (RDMP).
3
// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5
// You should have received a copy of the GNU General Public License along with RDMP. If not, see <https://www.gnu.org/licenses/>.
6

7
using System;
8
using System.Collections.Generic;
9
using System.Linq;
10
using FAnsi.Discovery;
11
using Rdmp.Core.ReusableLibraryCode.Checks;
12

13
namespace Rdmp.Core.ReusableLibraryCode.Settings;
14

15
/// <summary>
16
/// This is the Settings static class that can be used in your Core solution or in any
17
/// of your client applications. All settings are laid out the same exact way with getters
18
/// and setters.
19
/// </summary>
20
public static class UserSettings
21
{
22
    private static readonly Lazy<RDMPApplicationSettings> Implementation =
4✔
23
        new(static () => new RDMPApplicationSettings(), System.Threading.LazyThreadSafetyMode.ExecutionAndPublication);
8✔
24

25
    private static RDMPApplicationSettings AppSettings => Implementation.Value ??
37,042!
26
                                                          throw new NotImplementedException(
37,042✔
27
                                                              "Isolated Storage does not work in this environment...");
37,042✔
28

29

30
    /// <summary>
31
    /// Show a Yes/No confirmation dialog box when closing RDMP
32
    /// </summary>
33
    public static bool ConfirmApplicationExiting
34
    {
35
        get => AppSettings.GetValueOrDefault("ConfirmExit", true);
×
36
        set => AppSettings.AddOrUpdateValue("ConfirmExit", value);
×
37
    }
38

39
    /// <summary>
40
    /// True if the user has accepted the open source license agreements for RDMP and
41
    /// dependencies used in the software (i.e. MIT and GNU licenses).
42
    /// </summary>
43
    public static string LicenseAccepted
44
    {
45
        get => AppSettings.GetValueOrDefault("LicenseAccepted", null);
×
46
        set => AppSettings.AddOrUpdateValue("LicenseAccepted", value);
×
47
    }
48

49
    /// <summary>
50
    /// Automatically launch the RDMP Home Screen on launch of the RDMP application, regardless of the last window you viewed.
51
    /// </summary>
52
    public static bool ShowHomeOnStartup
53
    {
54
        get => AppSettings.GetValueOrDefault("ShowHomeOnStartup", false);
×
55
        set => AppSettings.AddOrUpdateValue("ShowHomeOnStartup", value);
×
56
    }
57

58
    /// <summary>
59
    /// If checked series included in graphs that have no values will not be displayed
60
    /// </summary>
61
    public static bool IncludeZeroSeriesInGraphs
62
    {
63
        get => AppSettings.GetValueOrDefault("IncludeZeroSeriesInGraphs", true);
4✔
64
        set => AppSettings.AddOrUpdateValue("IncludeZeroSeriesInGraphs", value);
6✔
65
    }
66

67
    /// <summary>
68
    /// Adds an additional behaviour when changing tabs that highlights the tree view
69
    /// collection that has that object visible in it.
70
    /// </summary>
71
    public static bool EmphasiseOnTabChanged
72
    {
73
        get => AppSettings.GetValueOrDefault("EmphasiseOnTabChanged", false);
×
74
        set => AppSettings.AddOrUpdateValue("EmphasiseOnTabChanged", value);
×
75
    }
76

77
    /// <summary>
78
    /// True to disable any auto starting tutorials
79
    /// </summary>
80
    public static bool DisableTutorials
81
    {
82
        get => AppSettings.GetValueOrDefault("DisableTutorials", false);
×
83
        set => AppSettings.AddOrUpdateValue("DisableTutorials", value);
×
84
    }
85

86
    /// <summary>
87
    /// The connection string to the main RDMP platform database
88
    /// </summary>
89
    public static string CatalogueConnectionString
90
    {
91
        get => AppSettings.GetValueOrDefault("CatalogueConnectionString", "");
×
92
        set => AppSettings.AddOrUpdateValue("CatalogueConnectionString", value);
×
93
    }
94

95
    /// <summary>
96
    /// The connection string to the data export RDMP platform database.  This database will contain
97
    /// refrerences to objects in the <see cref="CatalogueConnectionString"/> database
98
    /// </summary>
99
    public static string DataExportConnectionString
100
    {
101
        get => AppSettings.GetValueOrDefault("DataExportConnectionString", "");
×
102
        set => AppSettings.AddOrUpdateValue("DataExportConnectionString", value);
×
103
    }
104

105
    /// <summary>
106
    /// The colour scheme and format for the RDMP gui client application
107
    /// </summary>
108
    public static string Theme
109
    {
110
        get => AppSettings.GetValueOrDefault("Theme", "ResearchDataManagementPlatform.Theme.MyVS2015BlueTheme");
×
111
        set => AppSettings.AddOrUpdateValue("Theme", value);
×
112
    }
113

114
    /// <summary>
115
    /// When selecting a result from the Find dialog the selected item is pinned in the corresponding view.
116
    /// </summary>
117
    public static bool FindShouldPin
118
    {
119
        get => AppSettings.GetValueOrDefault("FindShouldPin", true);
×
120
        set => AppSettings.AddOrUpdateValue("FindShouldPin", value);
×
121
    }
122

123
    /// <summary>
124
    /// Set the amount of time (in seconds) that the Create Database processes should wait before timing out.
125
    /// </summary>
126
    public static int CreateDatabaseTimeout
127
    {
128
        get => AppSettings.GetValueOrDefault("CreateDatabaseTimeout", 30);
16✔
129
        set => AppSettings.AddOrUpdateValue("CreateDatabaseTimeout",
×
130
            DiscoveredServerHelper.CreateDatabaseTimeoutInSeconds = Math.Max(value, 30));
×
131
    }
132

133
    /// <summary>
134
    /// Set the amount of time (in milliseconds) that tooltips should take to appear in the tree collection views (e.g. list of Catalogues etc)
135
    /// </summary>
136
    public static int TooltipAppearDelay
137
    {
138
        get => AppSettings.GetValueOrDefault("TooltipAppearDelay", 750);
20✔
139
        set => AppSettings.AddOrUpdateValue("TooltipAppearDelay", Math.Max(10, value));
×
140
    }
141

142
    /// <summary>
143
    /// When using the Find feature this option will automatically filter out any cohort set containers (i.e. UNION / INTERSECT / EXCEPT containers)
144
    /// </summary>
145
    public static bool ScoreZeroForCohortAggregateContainers
146
    {
147
        get => AppSettings.GetValueOrDefault("ScoreZeroForCohortAggregateContainers", false);
50✔
148
        set => AppSettings.AddOrUpdateValue("ScoreZeroForCohortAggregateContainers", value);
8✔
149
    }
150

151
    /// <summary>
152
    /// Create audit objects for specific objects/changes (e.g. changes to Catalogue Deprecated status).
153
    /// </summary>
154
    public static bool EnableCommits
155
    {
156
        get => AppSettings.GetValueOrDefault("EnableCommits", true);
22✔
157
        set => AppSettings.AddOrUpdateValue("EnableCommits", value);
×
158
    }
159

160

161
    #region Catalogue flag visibility settings
162

163
    public static bool ShowInternalCatalogues
164
    {
165
        get => AppSettings.GetValueOrDefault("ShowInternalCatalogues", true);
40✔
166
        set => AppSettings.AddOrUpdateValue("ShowInternalCatalogues", value);
48✔
167
    }
168

169
    public static bool ShowDeprecatedCatalogues
170
    {
171
        get => AppSettings.GetValueOrDefault("ShowDeprecatedCatalogues", true);
40✔
172
        set => AppSettings.AddOrUpdateValue("ShowDeprecatedCatalogues", value);
48✔
173
    }
174

175
    public static bool ShowColdStorageCatalogues
176
    {
177
        get => AppSettings.GetValueOrDefault("ShowColdStorageCatalogues", true);
40✔
178
        set => AppSettings.AddOrUpdateValue("ShowColdStorageCatalogues", value);
48✔
179
    }
180

181
    public static bool ShowProjectSpecificCatalogues
182
    {
183
        get => AppSettings.GetValueOrDefault("ShowProjectSpecificCatalogues", true);
40✔
184
        set => AppSettings.AddOrUpdateValue("ShowProjectSpecificCatalogues", value);
48✔
185
    }
186

187
    public static bool ShowNonExtractableCatalogues
188
    {
189
        get => AppSettings.GetValueOrDefault("ShowNonExtractableCatalogues", true);
40✔
190
        set => AppSettings.AddOrUpdateValue("ShowNonExtractableCatalogues", value);
48✔
191
    }
192

193
    /// <summary>
194
    /// True to apply theme changes to context menus and tool strips.
195
    /// </summary>
196
    public static bool ApplyThemeToMenus
197
    {
198
        get => AppSettings.GetValueOrDefault("ApplyThemeToMenus", true);
×
199
        set => AppSettings.AddOrUpdateValue("ApplyThemeToMenus", value);
×
200
    }
201

202
    /// <summary>
203
    /// Determines line wrapping in multi line editor controls when lines stretch off the control client area
204
    /// </summary>
205
    public static int WrapMode
206
    {
207
        get => AppSettings.GetValueOrDefault("WrapMode", 0);
40✔
208
        set => AppSettings.AddOrUpdateValue("WrapMode", value);
×
209
    }
210

211
    /// <summary>
212
    /// <para>Base colours used for generating heatmaps in HEX format.  Colour intensity will vary
213
    /// from the first color to the second.</para>
214
    /// 
215
    /// <para>The first colour represents the lowest values and should
216
    /// typically be darker than the second which represents high values.</para>
217
    /// </summary>
218
    public static string HeatMapColours
219
    {
220
        get => AppSettings.GetValueOrDefault("HeatMapColours", null);
×
221
        set => AppSettings.AddOrUpdateValue("HeatMapColours", value);
×
222
    }
223

224
    /// <summary>
225
    /// <para>Adds a 5 second delay after startup</para>
226
    /// <para>Use this option to add a delay that can be helpful for troubleshooting issues on RDMP startup. </para>
227
    /// </summary>
228
    public static bool Wait5SecondsAfterStartupUI
229
    {
230
        get => AppSettings.GetValueOrDefault("Wait5SecondsAfterStartupUI", true);
10✔
231
        set => AppSettings.AddOrUpdateValue("Wait5SecondsAfterStartupUI", value);
12✔
232
    }
233

234
    /// <summary>
235
    /// True to show the cohort creation wizard when creating new cohorts.  False to create
236
    /// a default empty configuration.
237
    /// </summary>
238
    public static bool ShowCohortWizard
239
    {
240
        get => AppSettings.GetValueOrDefault("ShowCohortWizard", false);
×
241
        set => AppSettings.AddOrUpdateValue("ShowCohortWizard", value);
×
242
    }
243

244
    /// <summary>
245
    /// <para>True to enable "stirct validation" for containers in Cohort Builder Queries.</para>
246
    ///
247
    /// <para>Will not allow empty sets, or sets that only have one item.</para>
248
    /// </summary>
249
    public static bool StrictValidationForCohortBuilderContainers
250
    {
251
        get => AppSettings.GetValueOrDefault("StrictValidationForCohortBuilderContainers", true);
38✔
252
        set => AppSettings.AddOrUpdateValue("StrictValidationForCohortBuilderContainers", value);
×
253
    }
254

255
    /// <summary>
256
    /// Changes the behaviour of mouse double clicks in tree views.  When enabled double
257
    /// click expands nodes instead of opening the double clicked object (the default behaviour).
258
    /// </summary>
259
    public static bool DoubleClickToExpand
260
    {
261
        get => AppSettings.GetValueOrDefault("DoubleClickToExpand", false);
×
262
        set => AppSettings.AddOrUpdateValue("DoubleClickToExpand", value);
×
263
    }
264

265
    public static string RecentHistory
266
    {
267
        get => AppSettings.GetValueOrDefault("RecentHistory", "");
60✔
268
        set => AppSettings.AddOrUpdateValue("RecentHistory", value);
18✔
269
    }
270

271
    /// <summary>
272
    /// <para>When enabled RDMP will record certain performance related metrics (how long refresh takes etc).</para>
273
    /// <para>These figures are completely internal to the application and are not transmitted anywhere.You can view the results in the toolbar.</para>
274
    /// </summary>
275
    public static bool DebugPerformance
276
    {
277
        get => AppSettings.GetValueOrDefault("DebugPerformance", false);
30,308✔
278
        set => AppSettings.AddOrUpdateValue("DebugPerformance", value);
×
279
    }
280

281
    /// <summary>
282
    /// <para>Automatically resize columns in the RDMP user interface with fit contents.</para>
283
    /// <para>Can be disabled if problems arrise with column content or header visibility</para>
284
    /// </summary>
285
    public static bool AutoResizeColumns
286
    {
287
        get => AppSettings.GetValueOrDefault("AutoResizeColumns", true);
30✔
288
        set => AppSettings.AddOrUpdateValue("AutoResizeColumns", value);
×
289
    }
290

291

292
    /// <summary>
293
    /// Show a popup confirmation dialog at the end of a pipeline completing execution
294
    /// </summary>
295
    public static bool ShowPipelineCompletedPopup
296
    {
297
        get => AppSettings.GetValueOrDefault("ShowPipelineCompletedPopup", true);
×
298
        set => AppSettings.AddOrUpdateValue("ShowPipelineCompletedPopup", value);
×
299
    }
300

301
    /// <summary>
302
    /// <para>Enable to skip the checking stage of pipeline source component CohortIdentificationConfigurationSource.</para>
303
    /// <para>In slow computer, or contesest databases this can take a while to compile. This option lets you disable it.</para>
304
    /// </summary>
305
    public static bool SkipCohortBuilderValidationOnCommit
306
    {
307
        get => AppSettings.GetValueOrDefault("SkipCohortBuilderValidationOnCommit", false);
×
308
        set => AppSettings.AddOrUpdateValue("SkipCohortBuilderValidationOnCommit", value);
×
309
    }
310

311
    public static string ConsoleColorScheme
312
    {
313
        get => AppSettings.GetValueOrDefault("ConsoleColorScheme", "default");
×
314
        set => AppSettings.AddOrUpdateValue("ConsoleColorScheme", value);
×
315
    }
316

317
    /// <summary>
318
    /// <para>When true RDMP log viewer will hide table load audits where no inserts/updates/deletes were applied.</para>
319
    /// <para>This is helpful if a load targets many tables not all of which will be updated in a given run</para>
320
    /// </summary>
321
    public static bool HideEmptyTableLoadRunAudits
322
    {
323
        get => AppSettings.GetValueOrDefault("HideEmptyTableLoadRunAudits", false);
×
324
        set => AppSettings.AddOrUpdateValue("HideEmptyTableLoadRunAudits", value);
×
325
    }
326

327
    /// <summary>
328
    /// <para>Enables additional Find filters for objects that are in:</para>
329
    /// <para>Cold Storage, Internal, Deprecated, Project Specific and Non Extractable</para>
330
    /// </summary>
331
    public static bool AdvancedFindFilters
332
    {
333
        get => AppSettings.GetValueOrDefault("AdvancedFindFilters", false);
×
334
        set => AppSettings.AddOrUpdateValue("AdvancedFindFilters", value);
×
335
    }
336

337
    /// <summary>
338
    /// Timeout in seconds to allow for creating archive trigger, index etc
339
    /// </summary>
340
    public static int ArchiveTriggerTimeout
341
    {
342
        get => AppSettings.GetValueOrDefault("ArchiveTriggerTimeout", 30);
1,198✔
343
        set => AppSettings.AddOrUpdateValue("ArchiveTriggerTimeout", value);
×
344
    }
345

346
    public static int FindWindowWidth
347
    {
348
        get => AppSettings.GetValueOrDefault("FindWindowWidth", 730);
×
349
        set => AppSettings.AddOrUpdateValue("FindWindowWidth", value);
×
350
    }
351

352
    public static int FindWindowHeight
353
    {
354
        get => AppSettings.GetValueOrDefault("FindWindowHeight", 400);
×
355
        set => AppSettings.AddOrUpdateValue("FindWindowHeight", value);
×
356
    }
357

358
    /// <summary>
359
    /// Enable to refresh only objects which you make changes to instead of
360
    /// fetching all database changes since your last edit.  This improves
361
    /// performance in large RDMP deployments with thousands of Projects configured.
362
    /// </summary>
363
    public static bool SelectiveRefresh
364
    {
365
        get => AppSettings.GetValueOrDefault("SelectiveRefresh", false);
150✔
366
        set => AppSettings.AddOrUpdateValue("SelectiveRefresh", value);
×
367
    }
368

369
    /// <summary>
370
    /// Set to true to always attempt to force joins on all tables under a Catalogue
371
    /// when building queries (in Cohort Builder).  This makes it impossible to untick
372
    /// force joins.
373
    /// </summary>
374
    public static bool AlwaysJoinEverything
375
    {
376
        get => AppSettings.GetValueOrDefault("AlwaysJoinEverything", false);
648✔
377
        set => AppSettings.AddOrUpdateValue("AlwaysJoinEverything", value);
×
378
    }
379

380
    /// <summary>
381
    /// <para>
382
    /// Determines whether queries are automatically sent and results displayed in
383
    /// data tabs in RDMP (e.g. View top 100 etc).  Enable to automatically send the
384
    /// queries.  Disable to show the SQL but require the user to press F5 or click Run
385
    /// to execute.
386
    /// </para>
387
    /// </summary>
388
    public static bool AutoRunSqlQueries
389
    {
390
        get => AppSettings.GetValueOrDefault("AutoRunSqlQueries", false);
×
391
        set => AppSettings.AddOrUpdateValue("AutoRunSqlQueries", value);
×
392
    }
393

394
    /// <summary>
395
    /// Enable to automatically expand the tree when opening or creating cohorts in
396
    /// Cohort Builder
397
    /// </summary>
398
    public static bool ExpandAllInCohortBuilder
399
    {
400
        get => AppSettings.GetValueOrDefault("ExpandAllInCohortBuilder", true);
2✔
401
        set => AppSettings.AddOrUpdateValue("ExpandAllInCohortBuilder", value);
×
402
    }
403

404
    /// <summary>
405
    /// True to show ProjectSpecific Catalogues' columns in extraction configuration user interface
406
    /// </summary>
407
    public static bool ShowProjectSpecificColumns
408
    {
409
        get => AppSettings.GetValueOrDefault("ShowProjectSpecificColumns", true);
18✔
410
        set => AppSettings.AddOrUpdateValue("ShowProjectSpecificColumns", value);
×
411
    }
412

413
    /// <summary>
414
    /// <para>When generating an aggregate graph, use the column alias instead of the select sql.  For example
415
    /// when you have the select column 'SELECT YEAR(dt) as myYear' then the GROUP BY will default to
416
    /// 'GROUP BY YEAR(dt)'.  Setting this property to true will instead use 'GROUP BY myYear'.  Typically
417
    /// this only works in MySql but it is not universally supported by all MySql versions and server settings
418
    /// </para>
419
    /// <para>Defaults to false.</para>
420
    /// </summary>
421
    public static bool UseAliasInsteadOfTransformInGroupByAggregateGraphs
422
    {
423
        get => AppSettings.GetValueOrDefault("ShowProjectSpecificColumns", false);
268✔
424
        set => AppSettings.AddOrUpdateValue("ShowProjectSpecificColumns", value);
8✔
425
    }
426

427
    #endregion
428

429
    /// <summary>
430
    /// Returns the error level the user wants for <paramref name="errorCode"/> or <see cref="ErrorCode.DefaultTreatment"/> (if no custom
431
    /// reporting level has been set up for this error code).
432
    /// </summary>
433
    /// <param name="errorCode"></param>
434
    /// <returns></returns>
435
    public static CheckResult GetErrorReportingLevelFor(ErrorCode errorCode)
436
    {
437
        var result = AppSettings.GetValueOrDefault($"EC_{errorCode.Code}", errorCode.DefaultTreatment.ToString());
32✔
438

439
        return Enum.Parse<CheckResult>(result);
32✔
440
    }
441

442
    /// <summary>
443
    /// Changes the reporting level of the given error to <paramref name="value"/> instead of its <see cref="ErrorCode.DefaultTreatment"/>
444
    /// </summary>
445
    /// <param name="errorCode"></param>
446
    /// <param name="value"></param>
447
    public static void SetErrorReportingLevelFor(ErrorCode errorCode, CheckResult value)
448
    {
449
        AppSettings.AddOrUpdateValue($"EC_{errorCode.Code}", value.ToString());
16✔
450
    }
16✔
451

452
    public static bool GetTutorialDone(Guid tutorialGuid) =>
453
        tutorialGuid != Guid.Empty && AppSettings.GetValueOrDefault($"T_{tutorialGuid:N}", false);
×
454

455
    public static void SetTutorialDone(Guid tutorialGuid, bool value)
456
    {
457
        if (tutorialGuid == Guid.Empty)
×
458
            return;
×
459

460
        AppSettings.AddOrUpdateValue($"T_{tutorialGuid:N}", value);
×
461
    }
×
462

463
    public static void SetColumnWidth(Guid columnGuid, int width)
464
    {
465
        if (columnGuid == Guid.Empty)
3,132!
466
            return;
×
467
        SetColumnWidth(columnGuid.ToString("N"), width);
3,132✔
468
    }
3,132✔
469

470
    public static void SetColumnWidth(string colIdentifier, int width)
471
    {
472
        AppSettings.AddOrUpdateValue($"ColW_{colIdentifier}", width);
3,132✔
473
    }
3,132✔
474

475
    public static void SetColumnVisible(Guid columnGuid, bool visible)
476
    {
477
        if (columnGuid == Guid.Empty)
×
478
            return;
×
479

480
        SetColumnVisible(columnGuid.ToString("N"), visible);
×
481
    }
×
482

483
    public static void SetColumnVisible(string colIdentifier, bool visible)
484
    {
485
        AppSettings.AddOrUpdateValue($"ColV_{colIdentifier}", visible);
×
486
    }
×
487

488
    public static int GetColumnWidth(Guid columnGuid) =>
489
        columnGuid == Guid.Empty ? 100 : GetColumnWidth(columnGuid.ToString("N"));
128!
490

491
    public static int GetColumnWidth(string colIdentifier) =>
492
        AppSettings.GetValueOrDefault($"ColW_{colIdentifier}", 100);
128✔
493

494
    public static bool GetColumnVisible(Guid columnGuid) =>
495
        columnGuid == Guid.Empty || GetColumnVisible(columnGuid.ToString("N"));
128!
496

497
    public static bool GetColumnVisible(string colIdentifier) =>
498
        AppSettings.GetValueOrDefault($"ColV_{colIdentifier}", true);
128✔
499

500
    public static string[] GetHistoryForControl(Guid controlGuid)
501
    {
502
        return AppSettings.GetValueOrDefault($"A_{controlGuid:N}", "").Split(new[] { "#!#" }, StringSplitOptions.None);
22✔
503
    }
504

505
    public static void SetHistoryForControl(Guid controlGuid, IEnumerable<string> history)
506
    {
507
        AppSettings.AddOrUpdateValue($"A_{controlGuid:N}", string.Join("#!#", history));
204✔
508
    }
204✔
509

510
    public static void AddHistoryForControl(Guid guid, string v)
511
    {
512
        if (string.IsNullOrWhiteSpace(v))
×
513
            return;
×
514

515
        var l = GetHistoryForControl(guid).ToList();
×
516

517
        if (l.Contains(v))
×
518
            return;
×
519

520
        l.Add(v);
×
521

522
        SetHistoryForControl(guid, l.Distinct().ToList());
×
523
    }
×
524

525
    public static Tuple<string, bool> GetLastColumnSortForCollection(Guid controlGuid)
526
    {
527
        lock (_oLockUserSettings)
2✔
528
        {
529
            var value = AppSettings.GetValueOrDefault($"LastColumnSort_{controlGuid:N}", null);
2✔
530

531
            //if we don't have a value
532
            if (string.IsNullOrWhiteSpace(value))
2!
533
                return null;
2✔
534

535
            var args = value.Split(new[] { "#!#" }, StringSplitOptions.RemoveEmptyEntries);
×
536

537
            //or it doesn't split properly
538
            if (args.Length != 2)
×
539
                return null;
×
540

541
            //or either element is null
542
            if (string.IsNullOrWhiteSpace(args[0]) || string.IsNullOrWhiteSpace(args[1]))
×
543
                return null;
×
544

545
            if (bool.TryParse(args[1], out var ascending))
×
546
                return Tuple.Create(args[0], ascending);
×
547
        }
×
548

549
        return null;
×
550
    }
2✔
551

552
    private static object _oLockUserSettings = new();
4✔
553

554
    public static void SetLastColumnSortForCollection(Guid controlGuid, string columnName, bool ascending)
555
    {
556
        lock (_oLockUserSettings)
2✔
557
        {
558
            AppSettings.AddOrUpdateValue($"LastColumnSort_{controlGuid:N}", $"{columnName}#!#{ascending}");
2✔
559
        }
2✔
560
    }
2✔
561

562

563
    /// <summary>
564
    /// Returns the last known manually set splitter distance for the Control who is
565
    /// identified by <paramref name="controlGuid"/> or -1 if none set yet
566
    /// </summary>
567
    /// <param name="controlGuid"></param>
568
    /// <returns></returns>
569
    public static int GetSplitterDistance(Guid controlGuid) =>
570
        AppSettings.GetValueOrDefault($"SplitterDistance_{controlGuid:N}", -1);
×
571

572
    /// <summary>
573
    /// Records that the user has manaully changed the splitter distance of the Control
574
    /// who is identified by <paramref name="controlGuid"/>
575
    /// </summary>
576
    /// <param name="controlGuid"></param>
577
    /// <param name="splitterDistance"></param>
578
    public static void SetSplitterDistance(Guid controlGuid, int splitterDistance)
579
    {
580
        lock (_oLockUserSettings)
×
581
        {
582
            AppSettings.AddOrUpdateValue($"SplitterDistance_{controlGuid:N}", splitterDistance);
×
583
        }
×
584
    }
×
585

586
    public static void ClearUserSettings()
587
    {
588
        AppSettings.Clear();
2✔
589
    }
2✔
590
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc