Refactor quick action output handling and extend case note support
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
|
||||
using C4IT.F4SD.DisplayFormatting;
|
||||
using C4IT.F4SD.DisplayFormatting;
|
||||
using C4IT.F4SD.SupportCaseProtocoll.Models;
|
||||
using C4IT.FASD.Base;
|
||||
|
||||
using FasdCockpitBase;
|
||||
using FasdDesktopUi.Basics.Helper;
|
||||
using FasdDesktopUi.Basics.Services.ProtocollService;
|
||||
using FasdDesktopUi.Basics.Services.SupportCase.Processors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Imaging;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Basics.Models
|
||||
@@ -193,6 +195,33 @@ namespace FasdDesktopUi.Basics.Models
|
||||
}
|
||||
}
|
||||
|
||||
public class cNamedParameterEntryCaseNotes : cNamedParameterEntryBase
|
||||
{
|
||||
private readonly bool _getHtmlAsDefaultValue;
|
||||
|
||||
public cNamedParameterEntryCaseNotes(cSupportCaseDataProvider dataProvider, bool getHtmlAsDefaultValue) : base(dataProvider)
|
||||
{
|
||||
_getHtmlAsDefaultValue = getHtmlAsDefaultValue;
|
||||
}
|
||||
|
||||
public override string GetValue()
|
||||
{
|
||||
if (_getHtmlAsDefaultValue)
|
||||
return GetHtmlValue();
|
||||
|
||||
StringBuilder caseNotesStringBuilder = new StringBuilder();
|
||||
cRichTextBoxHelper.TraverseBlockAsUnicode(dataProvider.CaseNotes.Blocks, caseNotesStringBuilder);
|
||||
return caseNotesStringBuilder.ToString();
|
||||
}
|
||||
|
||||
public override string GetHtmlValue()
|
||||
{
|
||||
StringBuilder caseNotesHtmlStringBuilder = new StringBuilder();
|
||||
cRichTextBoxHelper.TraverseBlockAsHtml(dataProvider.CaseNotes.Blocks, caseNotesHtmlStringBuilder);
|
||||
return caseNotesHtmlStringBuilder.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public class cNamedParameterList : Dictionary<string, cNamedParameterEntryBase>
|
||||
{
|
||||
public cNamedParameterList()
|
||||
@@ -204,8 +233,11 @@ namespace FasdDesktopUi.Basics.Models
|
||||
{
|
||||
try
|
||||
{
|
||||
Add("F4SD_QuickActionProtocolLast", new cNamedParameterEntryQuickActionResult(dataProvider));
|
||||
Add("F4SD_QuickActionProtocol", new cNamedParameterEntryQuickActionResultProtocol(dataProvider));
|
||||
Add(SupportCaseProcessor.QuickActionProtocolLastNamedParameterName, new cNamedParameterEntryQuickActionResult(dataProvider));
|
||||
Add(SupportCaseProcessor.QuickActionProtocolNamedParameterName, new cNamedParameterEntryQuickActionResultProtocol(dataProvider));
|
||||
|
||||
Add(SupportCaseProcessor.CaseNotesNamedParameterName, new cNamedParameterEntryCaseNotes(dataProvider, false));
|
||||
Add(SupportCaseProcessor.CaseNotesHtmlNamedParameterName, new cNamedParameterEntryCaseNotes(dataProvider, true));
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using FasdDesktopUi.Basics.UserControls;
|
||||
using FasdDesktopUi.Basics.Models.QuickActionOutput;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FasdDesktopUi.Basics.Models
|
||||
{
|
||||
@@ -13,7 +10,7 @@ namespace FasdDesktopUi.Basics.Models
|
||||
public string Name { get; set; }
|
||||
public string AffectedDeviceName { get; set; }
|
||||
public bool WasRunningOnAffectedDevice { get; set; }
|
||||
public QuickActionStatusMonitor.cQuickActionOutput QuickActionOutput { get; set; }
|
||||
public List<QuickActionStatusMonitor.cQuickActionMeasureValue> MeasureValues { get; set; }
|
||||
public cQuickActionOutput QuickActionOutput { get; set; }
|
||||
public List<cQuickActionMeasureValue> MeasureValues { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
using C4IT.F4SD.DisplayFormatting;
|
||||
using C4IT.FASD.Base;
|
||||
using C4IT.MultiLanguage;
|
||||
|
||||
namespace FasdDesktopUi.Basics.Models.QuickActionOutput
|
||||
{
|
||||
|
||||
public class cQuickActionMeasureValue
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public cMultiLanguageDictionary Names { get; set; }
|
||||
public object Value { get; set; }
|
||||
public object PostValue { get; set; }
|
||||
|
||||
public object Difference
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (Display)
|
||||
{
|
||||
case RawValueType.INTEGER:
|
||||
case RawValueType.PERCENT:
|
||||
case RawValueType.PERCENT100:
|
||||
case RawValueType.PERCENT1000:
|
||||
case RawValueType.BYTES:
|
||||
var valueDouble = cF4SDHealthCardRawData.GetDouble(Value);
|
||||
var postValueDouble = cF4SDHealthCardRawData.GetDouble(PostValue);
|
||||
|
||||
if (valueDouble != null && postValueDouble != null)
|
||||
return postValueDouble - valueDouble;
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public RawValueType Display { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
using C4IT.F4SD.DisplayFormatting;
|
||||
using C4IT.FASD.Base;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Basics.Models.QuickActionOutput
|
||||
{
|
||||
public abstract class cQuickActionOutput
|
||||
{
|
||||
protected const string veiledText = "********";
|
||||
|
||||
protected readonly IRawValueFormatter _rawValueFormatter = new RawValueFormatter();
|
||||
|
||||
public cQuickActionOutput(cF4sdQuickActionRevision.cOutput scriptOutput)
|
||||
{
|
||||
_rawValueFormatter.SetDefaultCulture(cFasdCockpitConfig.Instance.SelectedCulture);
|
||||
_rawValueFormatter.SetDefaultTimeZone(TimeZoneInfo.Local);
|
||||
ErrorCode = scriptOutput.ErrorCode;
|
||||
ErrorDescription = scriptOutput.ErrorDescription;
|
||||
ResultCode = scriptOutput.ResultCode.GetValueOrDefault();
|
||||
IsError = HasError(scriptOutput);
|
||||
}
|
||||
|
||||
public cSupportCaseDataProvider DataProvider { get; private set; }
|
||||
public enumQuickActionSuccess? ResultCode { get; set; }
|
||||
public int? ErrorCode { get; set; }
|
||||
public string ErrorDescription { get; set; }
|
||||
|
||||
public bool IsError { get; private set; }
|
||||
|
||||
internal static KeyValuePair<string, RawValueType> GetDisplayType(dynamic columnTypeObject)
|
||||
{
|
||||
var output = new KeyValuePair<string, RawValueType>();
|
||||
|
||||
try
|
||||
{
|
||||
var columnType = columnTypeObject.ToObject<dynamic>();
|
||||
string name = string.Empty;
|
||||
RawValueType type = RawValueType.STRING;
|
||||
|
||||
|
||||
if (columnType.Name != null)
|
||||
if (columnType.Name is Newtonsoft.Json.Linq.JValue nameJValue)
|
||||
name = nameJValue.Value.ToString();
|
||||
|
||||
if (columnType.Type != null)
|
||||
if (columnType.Type is Newtonsoft.Json.Linq.JValue typeJValue)
|
||||
if (Enum.TryParse(typeJValue.Value.ToString(), out RawValueType typeJValueType))
|
||||
type = typeJValueType;
|
||||
|
||||
output = new KeyValuePair<string, RawValueType>(name, type);
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public static cQuickActionOutput GetQuickActionOutput(cF4sdQuickActionRevision.cOutput scriptOutput, cSupportCaseDataProvider dataProvider)
|
||||
{
|
||||
if (scriptOutput == null)
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
if (scriptOutput?.Values == null)
|
||||
{
|
||||
var output = new cQuickActionOutputSingle(scriptOutput) { DataProvider = dataProvider };
|
||||
return output;
|
||||
}
|
||||
else if (scriptOutput.Values is JArray scriptValueJArray)
|
||||
{
|
||||
var scriptValues = scriptValueJArray.ToObject<List<dynamic>>();
|
||||
if (scriptValues != null && scriptValues.Count > 0)
|
||||
{
|
||||
var output = new cQuickActionOutputList(scriptOutput) { DataProvider = dataProvider };
|
||||
|
||||
foreach (var scriptValue in scriptValues)
|
||||
{
|
||||
if (scriptValue is JObject scriptValueJObject)
|
||||
{
|
||||
try
|
||||
{
|
||||
var scriptValueHelperDictionary = scriptValueJObject.ToObject<Dictionary<string, object>>();
|
||||
output.Values.Add(scriptValueHelperDictionary.ToList());
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
else if (scriptOutput.Values is JObject scriptValueJObject)
|
||||
{
|
||||
try
|
||||
{
|
||||
var output = new cQuickActionOutputObject(scriptOutput) { DataProvider = dataProvider };
|
||||
return output;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return new cQuickActionOutputSingle(scriptOutput) { DataProvider = dataProvider };
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static bool HasError(cF4sdQuickActionRevision.cOutput quickActionOutput)
|
||||
{
|
||||
if ((quickActionOutput?.ResultCode == null || quickActionOutput?.ResultCode == enumQuickActionSuccess.finished || quickActionOutput?.ResultCode == enumQuickActionSuccess.successfull)
|
||||
&& (quickActionOutput?.ErrorCode == null || quickActionOutput?.ErrorCode == 0)
|
||||
&& string.IsNullOrEmpty(quickActionOutput?.ErrorDescription))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
using C4IT.F4SD.DisplayFormatting;
|
||||
using C4IT.FASD.Base;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Basics.Models.QuickActionOutput
|
||||
{
|
||||
public class cQuickActionOutputList : cQuickActionOutput
|
||||
{
|
||||
public cQuickActionOutputList(cF4sdQuickActionRevision.cOutput scriptOutput) : base(scriptOutput)
|
||||
{
|
||||
InstantiateDisplayTypes(scriptOutput);
|
||||
}
|
||||
|
||||
public Dictionary<string, RawValueType> DisplayTypes { get; set; } = new Dictionary<string, RawValueType>();
|
||||
public List<List<KeyValuePair<string, object>>> Values { get; set; } = new List<List<KeyValuePair<string, object>>>();
|
||||
|
||||
private void InstantiateDisplayTypes(cF4sdQuickActionRevision.cOutput scriptOutput)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (scriptOutput.ColumnTypes is Newtonsoft.Json.Linq.JArray columnTypeJArray)
|
||||
{
|
||||
var columnTypes = columnTypeJArray.ToObject<List<dynamic>>();
|
||||
if (columnTypes != null && columnTypes.Count > 0)
|
||||
{
|
||||
foreach (var columnTypeObject in columnTypes)
|
||||
{
|
||||
var displayType = GetDisplayType(columnTypeObject);
|
||||
DisplayTypes[displayType.Key] = displayType.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (scriptOutput.ColumnTypes is Newtonsoft.Json.Linq.JObject columnTypeJObject)
|
||||
{
|
||||
try
|
||||
{
|
||||
var displayType = GetDisplayType(columnTypeJObject);
|
||||
|
||||
DisplayTypes[displayType.Key] = displayType.Value;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetDisplayValue(int row, int column, Dictionary<string, cColumnOutputFormatting> columnOutputFormattings, bool getSecretValue = false)
|
||||
{
|
||||
string output = null;
|
||||
|
||||
try
|
||||
{
|
||||
RawValueType displayType = RawValueType.STRING;
|
||||
DisplayTypes.TryGetValue(Values[row][column].Key, out displayType);
|
||||
output = _rawValueFormatter.GetDisplayValue(Values[row][column].Value, displayType);
|
||||
|
||||
if (columnOutputFormattings != null && columnOutputFormattings.TryGetValue(Values[row][column].Key, out var outputFormatting))
|
||||
{
|
||||
if (outputFormatting.Hidden)
|
||||
return string.Empty;
|
||||
|
||||
if (outputFormatting.IsSecret && !getSecretValue)
|
||||
return veiledText;
|
||||
|
||||
if (outputFormatting.DisplayType != null)
|
||||
output = _rawValueFormatter.GetDisplayValue(Values[row][column].Value, outputFormatting.DisplayType.Value);
|
||||
|
||||
if (outputFormatting.Translation != null)
|
||||
{
|
||||
var abstractTranslation = cF4SDHealthCardConfig.GetTranslationsWithName(DataProvider?.HealthCardDataHelper?.SelectedHealthCard, outputFormatting.Translation);
|
||||
if (abstractTranslation != null && abstractTranslation is cHealthCardTranslator translator)
|
||||
{
|
||||
output = translator.DefaultTranslation?.Translation.GetValue() ?? Values[row].ToList()[column].Value.ToString();
|
||||
|
||||
foreach (var translation in translator.Translations)
|
||||
{
|
||||
if (translation.Values.Any(value => value.Equals(Values[row].ToList()[column].Value.ToString(), StringComparison.InvariantCultureIgnoreCase)))
|
||||
output = translation.Translation.GetValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
using C4IT.F4SD.DisplayFormatting;
|
||||
using C4IT.FASD.Base;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Basics.Models.QuickActionOutput
|
||||
{
|
||||
public class cQuickActionOutputObject : cQuickActionOutput
|
||||
{
|
||||
public Dictionary<string, RawValueType> DisplayTypes { get; set; } = new Dictionary<string, RawValueType>();
|
||||
public List<KeyValuePair<string, object>> Values { get; set; } = new List<KeyValuePair<string, object>>();
|
||||
|
||||
public cQuickActionOutputObject(cF4sdQuickActionRevision.cOutput scriptOutput) : base(scriptOutput)
|
||||
{
|
||||
try
|
||||
{
|
||||
InstantiateDisplayTypes(scriptOutput);
|
||||
InstantiateValues(scriptOutput);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void InstantiateDisplayTypes(cF4sdQuickActionRevision.cOutput scriptOutput)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (scriptOutput.ColumnTypes is Newtonsoft.Json.Linq.JArray columnTypeJArray)
|
||||
{
|
||||
var columnTypes = columnTypeJArray.ToObject<List<dynamic>>();
|
||||
if (columnTypes != null && columnTypes.Count > 0)
|
||||
{
|
||||
foreach (var columnTypeObject in columnTypes)
|
||||
{
|
||||
var displayType = GetDisplayType(columnTypeObject);
|
||||
DisplayTypes[displayType.Key] = displayType.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (scriptOutput.ColumnTypes is Newtonsoft.Json.Linq.JObject columnTypeJObject)
|
||||
{
|
||||
try
|
||||
{
|
||||
var displayType = GetDisplayType(columnTypeJObject);
|
||||
|
||||
DisplayTypes[displayType.Key] = displayType.Value;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
private void InstantiateValues(cF4sdQuickActionRevision.cOutput scriptOutput)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(scriptOutput.Values is JObject valuesJObject))
|
||||
return;
|
||||
|
||||
if (valuesJObject.Properties() == null)
|
||||
return;
|
||||
|
||||
foreach (var property in valuesJObject.Properties())
|
||||
{
|
||||
Values.Add(new KeyValuePair<string, object>(property.Name, property.Value));
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetDisplayValue(int index, Dictionary<string, cColumnOutputFormatting> columnOutputFormattings, bool getSecretValue = false)
|
||||
{
|
||||
string output = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (Values.Count <= index)
|
||||
return null;
|
||||
|
||||
var selectedItem = Values[index];
|
||||
|
||||
RawValueType displayType = RawValueType.STRING;
|
||||
DisplayTypes.TryGetValue(selectedItem.Key, out displayType);
|
||||
output = _rawValueFormatter.GetDisplayValue(selectedItem.Value, displayType);
|
||||
|
||||
if (columnOutputFormattings != null && columnOutputFormattings.TryGetValue(selectedItem.Key, out var outputFormatting))
|
||||
{
|
||||
if (outputFormatting.Hidden)
|
||||
return string.Empty;
|
||||
|
||||
if (outputFormatting.IsSecret && !getSecretValue)
|
||||
return veiledText;
|
||||
|
||||
if (outputFormatting.DisplayType != null)
|
||||
output = _rawValueFormatter.GetDisplayValue(selectedItem.Value, outputFormatting.DisplayType.Value);
|
||||
|
||||
if (outputFormatting.Translation != null)
|
||||
{
|
||||
var abstractTranslation = cF4SDHealthCardConfig.GetTranslationsWithName(DataProvider?.HealthCardDataHelper?.SelectedHealthCard, outputFormatting.Translation);
|
||||
if (abstractTranslation != null && abstractTranslation is cHealthCardTranslator translator)
|
||||
{
|
||||
output = translator.DefaultTranslation?.Translation.GetValue() ?? selectedItem.Value.ToString();
|
||||
|
||||
foreach (var translation in translator.Translations)
|
||||
{
|
||||
if (translation.Values.Any(value => value.Equals(selectedItem.Value.ToString(), StringComparison.InvariantCultureIgnoreCase)))
|
||||
output = translation.Translation.GetValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
using C4IT.F4SD.DisplayFormatting;
|
||||
using C4IT.FASD.Base;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Basics.Models.QuickActionOutput
|
||||
{
|
||||
public class cQuickActionOutputSingle : cQuickActionOutput
|
||||
{
|
||||
public cQuickActionOutputSingle(cF4sdQuickActionRevision.cOutput scriptOutput) : base(scriptOutput)
|
||||
{
|
||||
Instantiate(scriptOutput);
|
||||
}
|
||||
|
||||
|
||||
public RawValueType DisplayType { get; set; }
|
||||
public string Key { get; set; }
|
||||
public object Value { get; set; }
|
||||
|
||||
private void Instantiate(cF4sdQuickActionRevision.cOutput scriptOutput)
|
||||
{
|
||||
try
|
||||
{
|
||||
Value = scriptOutput.Values;
|
||||
|
||||
if (scriptOutput.Values is JObject scriptValueJObject)
|
||||
{
|
||||
string scriptValueKey = null;
|
||||
|
||||
try
|
||||
{
|
||||
var scriptValueHelperDictionary = scriptValueJObject.ToObject<Dictionary<string, object>>();
|
||||
scriptValueKey = scriptValueHelperDictionary.Keys.ToList()[0];
|
||||
|
||||
Key = scriptValueKey;
|
||||
Value = scriptValueHelperDictionary[scriptValueKey];
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
if (scriptOutput.ColumnTypes is JArray columnTypeJArray)
|
||||
{
|
||||
var columnTypes = columnTypeJArray.ToObject<List<dynamic>>();
|
||||
if (columnTypes != null && columnTypes.Count > 0)
|
||||
{
|
||||
foreach (var columnTypeObject in columnTypes)
|
||||
{
|
||||
var displayType = cQuickActionOutput.GetDisplayType(columnTypeObject);
|
||||
|
||||
if (displayType.Key == scriptValueKey)
|
||||
DisplayType = displayType.Value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (scriptOutput.ColumnTypes is JObject columnTypeJObject)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dispayType = cQuickActionOutput.GetDisplayType(columnTypeJObject);
|
||||
DisplayType = dispayType.Value;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetDisplayValue(Dictionary<string, cColumnOutputFormatting> columnOutputFormattings, bool getSecretValue = false)
|
||||
{
|
||||
string output = null;
|
||||
|
||||
try
|
||||
{
|
||||
output = _rawValueFormatter.GetDisplayValue(Value, DisplayType);
|
||||
|
||||
cColumnOutputFormatting outputFormatting = null;
|
||||
|
||||
if (string.IsNullOrEmpty(Key))
|
||||
outputFormatting = columnOutputFormattings?.Values.FirstOrDefault();
|
||||
else
|
||||
columnOutputFormattings?.TryGetValue(Key, out outputFormatting);
|
||||
|
||||
if (outputFormatting != null)
|
||||
{
|
||||
if (outputFormatting.IsSecret && !getSecretValue)
|
||||
return veiledText;
|
||||
|
||||
if (outputFormatting.DisplayType != null)
|
||||
output = _rawValueFormatter.GetDisplayValue(Value, outputFormatting.DisplayType.Value);
|
||||
|
||||
if (outputFormatting.Translation != null)
|
||||
{
|
||||
var abstractTranslation = cF4SDHealthCardConfig.GetTranslationsWithName(DataProvider?.HealthCardDataHelper?.SelectedHealthCard, outputFormatting.Translation);
|
||||
if (abstractTranslation != null && abstractTranslation is cHealthCardTranslator translator)
|
||||
{
|
||||
output = translator.DefaultTranslation?.Translation.GetValue() ?? Value.ToString();
|
||||
|
||||
foreach (var translation in translator.Translations)
|
||||
{
|
||||
if (translation.Values.Any(value => value.Equals(Value.ToString(), StringComparison.InvariantCultureIgnoreCase)))
|
||||
output = translation.Translation.GetValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user