Refactor quick action output handling and extend case note support
This commit is contained in:
@@ -1,18 +1,11 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace FasdDesktopUi.Basics.Helper
|
||||
{
|
||||
@@ -20,7 +13,7 @@ namespace FasdDesktopUi.Basics.Helper
|
||||
{
|
||||
#region Unicode
|
||||
|
||||
public static void TraverseBlockAsUnicode(BlockCollection blocks, StringBuilder stringBuilder, bool isBlockFromList = false)
|
||||
public static void TraverseBlockAsUnicode(BlockCollection blocks, StringBuilder stringBuilder)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -54,15 +47,11 @@ namespace FasdDesktopUi.Basics.Helper
|
||||
|
||||
private static void TraverseParagraphAsUnicode(Paragraph paragraph, StringBuilder stringBuilder)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var inline in paragraph.Inlines)
|
||||
foreach (Run run in paragraph.Inlines.OfType<Run>())
|
||||
{
|
||||
if (inline is Run run)
|
||||
{
|
||||
stringBuilder.Append(run.Text);
|
||||
}
|
||||
stringBuilder.Append(run.Text);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
@@ -73,32 +62,24 @@ namespace FasdDesktopUi.Basics.Helper
|
||||
|
||||
private static void TraverseListAsUnicode(List list, StringBuilder stringBuilder)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if (list.MarkerStyle == TextMarkerStyle.Decimal)
|
||||
{
|
||||
|
||||
for (int i = 0; i < list.ListItems.Count; i++)
|
||||
{
|
||||
|
||||
stringBuilder.Append(i + 1 + ". ");
|
||||
TraverseBlockAsUnicode(list.ListItems.ElementAt(i).Blocks, stringBuilder, true);
|
||||
|
||||
TraverseBlockAsUnicode(list.ListItems.ElementAt(i).Blocks, stringBuilder);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var item in list.ListItems)
|
||||
{
|
||||
|
||||
stringBuilder.Append("- ");
|
||||
TraverseBlockAsUnicode(item.Blocks, stringBuilder, true);
|
||||
|
||||
TraverseBlockAsUnicode(item.Blocks, stringBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
@@ -108,18 +89,14 @@ namespace FasdDesktopUi.Basics.Helper
|
||||
|
||||
private static void TraverseImageAsUnicode(System.Windows.Controls.Image image, StringBuilder stringBuilder)
|
||||
{
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
stringBuilder.Append("[Image]");
|
||||
stringBuilder.Append($"[Image:\"{image.Name}\"]");
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -151,12 +128,7 @@ namespace FasdDesktopUi.Basics.Helper
|
||||
else if (block is BlockUIContainer container)
|
||||
{
|
||||
if (container.Child is System.Windows.Controls.Image image)
|
||||
{
|
||||
|
||||
TraverseImageAsHtml(image, stringBuilder);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -223,7 +195,6 @@ namespace FasdDesktopUi.Basics.Helper
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
byte[] arr;
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
@@ -242,7 +213,6 @@ namespace FasdDesktopUi.Basics.Helper
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void TraverseRunAsHtml(Run run, StringBuilder stringBuilder)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,11 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using C4IT.F4SD.DisplayFormatting;
|
||||
using C4IT.FASD.Base;
|
||||
using C4IT.MultiLanguage;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.UserControls;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using static FasdDesktopUi.Basics.UserControls.QuickActionStatusMonitor;
|
||||
using FasdDesktopUi.Basics.Models.QuickActionOutput;
|
||||
|
||||
namespace FasdDesktopUi.Basics.Services.ProtocollService
|
||||
{
|
||||
@@ -155,7 +153,7 @@ namespace FasdDesktopUi.Basics.Services.ProtocollService
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
private static string GetQuickActionAsciiOutput(cFasdQuickAction quickActionDefinition, QuickActionStatusMonitor.cQuickActionOutput quickActionOutput)
|
||||
private static string GetQuickActionAsciiOutput(cFasdQuickAction quickActionDefinition, cQuickActionOutput quickActionOutput)
|
||||
{
|
||||
string output = string.Empty;
|
||||
|
||||
@@ -166,7 +164,7 @@ namespace FasdDesktopUi.Basics.Services.ProtocollService
|
||||
|
||||
switch (quickActionOutput)
|
||||
{
|
||||
case QuickActionStatusMonitor.cQuickActionOutputSingle singleOutput:
|
||||
case cQuickActionOutputSingle singleOutput:
|
||||
{
|
||||
if (singleOutput.Value is null)
|
||||
return output;
|
||||
@@ -177,7 +175,7 @@ namespace FasdDesktopUi.Basics.Services.ProtocollService
|
||||
|
||||
break;
|
||||
}
|
||||
case QuickActionStatusMonitor.cQuickActionOutputList listOutput:
|
||||
case cQuickActionOutputList listOutput:
|
||||
{
|
||||
output += AsciiSeperator;
|
||||
output += cMultiLanguageSupport.GetItem("QuickAction.Copy.Output") + "\n";
|
||||
@@ -219,7 +217,7 @@ namespace FasdDesktopUi.Basics.Services.ProtocollService
|
||||
|
||||
break;
|
||||
}
|
||||
case QuickActionStatusMonitor.cQuickActionOutputObject objectOutput:
|
||||
case cQuickActionOutputObject objectOutput:
|
||||
{
|
||||
output += AsciiSeperator;
|
||||
output += cMultiLanguageSupport.GetItem("QuickAction.Copy.Output") + "\n";
|
||||
@@ -259,7 +257,7 @@ namespace FasdDesktopUi.Basics.Services.ProtocollService
|
||||
return output;
|
||||
}
|
||||
|
||||
private static string GetQuickActionAsciiValueComparisonString(List<QuickActionStatusMonitor.cQuickActionMeasureValue> measureValues)
|
||||
private static string GetQuickActionAsciiValueComparisonString(List<cQuickActionMeasureValue> measureValues)
|
||||
{
|
||||
string output = string.Empty;
|
||||
|
||||
@@ -365,7 +363,7 @@ namespace FasdDesktopUi.Basics.Services.ProtocollService
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
private static string GetQuickActionHtmlOutput(cFasdQuickAction quickActionDefinition, QuickActionStatusMonitor.cQuickActionOutput quickActionOutput)
|
||||
private static string GetQuickActionHtmlOutput(cFasdQuickAction quickActionDefinition, cQuickActionOutput quickActionOutput)
|
||||
{
|
||||
string output = string.Empty;
|
||||
|
||||
@@ -378,7 +376,7 @@ namespace FasdDesktopUi.Basics.Services.ProtocollService
|
||||
|
||||
switch (quickActionOutput)
|
||||
{
|
||||
case QuickActionStatusMonitor.cQuickActionOutputSingle singleOutput:
|
||||
case cQuickActionOutputSingle singleOutput:
|
||||
{
|
||||
if (singleOutput.Value is null)
|
||||
return output;
|
||||
@@ -387,7 +385,7 @@ namespace FasdDesktopUi.Basics.Services.ProtocollService
|
||||
output += "<p>" + cMultiLanguageSupport.GetItem("QuickAction.Copy.Output.Html") + " " + displayValue + "</p>";
|
||||
break;
|
||||
}
|
||||
case QuickActionStatusMonitor.cQuickActionOutputList listOutput:
|
||||
case cQuickActionOutputList listOutput:
|
||||
{
|
||||
output += "<p>" + cMultiLanguageSupport.GetItem("QuickAction.Copy.Output.Html") + "</p>";
|
||||
|
||||
@@ -436,7 +434,7 @@ namespace FasdDesktopUi.Basics.Services.ProtocollService
|
||||
output += "</table>";
|
||||
break;
|
||||
}
|
||||
case QuickActionStatusMonitor.cQuickActionOutputObject objectOutput:
|
||||
case cQuickActionOutputObject objectOutput:
|
||||
{
|
||||
output += "<p>" + cMultiLanguageSupport.GetItem("QuickAction.Copy.Output.Html") + "</p>";
|
||||
|
||||
@@ -479,7 +477,7 @@ namespace FasdDesktopUi.Basics.Services.ProtocollService
|
||||
return output;
|
||||
}
|
||||
|
||||
private static string GetQuickActionHtmlValueComparison(List<QuickActionStatusMonitor.cQuickActionMeasureValue> measureValues)
|
||||
private static string GetQuickActionHtmlValueComparison(List<cQuickActionMeasureValue> measureValues)
|
||||
{
|
||||
string output = string.Empty;
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace FasdDesktopUi.Basics.Services.RemoteDesktop
|
||||
{
|
||||
ProcessStartInfo info = new ProcessStartInfo(GetViewerPath())
|
||||
{
|
||||
Arguments = $"-connectionId {connectionDetails.ConnectionId} -phoenixServiceUrl {connectionDetails.PhoenixServiceUrl} -secret {connectionDetails.Secret}"
|
||||
Arguments = $"-connectionId {connectionDetails.ConnectionId} -phoenixServiceUrl {connectionDetails.PhoenixServiceUrl} -secret {connectionDetails.Secret} -hideAi {!cFasdCockpitConfig.Instance.Global.UseAiAnalyzer}"
|
||||
};
|
||||
|
||||
Process process = Process.Start(info);
|
||||
|
||||
@@ -3,6 +3,7 @@ using C4IT.FASD.Cockpit.Communication;
|
||||
using C4IT.Logging;
|
||||
using FasdDesktopUi.Basics.CustomEvents;
|
||||
using FasdDesktopUi.Basics.Enums;
|
||||
using FasdDesktopUi.Basics.Helper;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.Services.Models;
|
||||
using FasdDesktopUi.Basics.Services.SupportCase.Controllers;
|
||||
@@ -11,6 +12,7 @@ using FasdDesktopUi.Pages.DetailsPage.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
@@ -24,6 +26,11 @@ namespace FasdDesktopUi.Basics.Services.SupportCase.Processors
|
||||
internal const string AgentDeviceIdNamedParameterName = "F4SD_Agent_DeviceId";
|
||||
internal const string AgentUserIdNamedParameterName = "F4SD_Agent_UserId";
|
||||
internal const string AgentOrganisationCodeNamedParameterName = "F4SD_Agent_OrganisationId";
|
||||
internal const string CaseNotesNamedParameterName = "F4SD_CaseNotes";
|
||||
internal const string CaseNotesHtmlNamedParameterName = "F4SD_CaseNotesHtml";
|
||||
internal const string QuickActionProtocolNamedParameterName = "F4SD_QuickActionProtocol";
|
||||
internal const string QuickActionProtocolLastNamedParameterName = "F4SD_QuickActionProtocolLast";
|
||||
|
||||
|
||||
private ISupportCase _supportCase;
|
||||
public cSupportCaseDataProvider SupportCaseDataProviderArtifact { get => _supportCase?.SupportCaseDataProviderArtifact; }
|
||||
@@ -134,6 +141,16 @@ namespace FasdDesktopUi.Basics.Services.SupportCase.Processors
|
||||
}
|
||||
|
||||
_namedParameterCache[relation][AgentOrganisationCodeNamedParameterName] = cCockpitConfiguration.Instance.agentApiConfiguration.OrganizationCode;
|
||||
|
||||
// todo insert quick action protocoll
|
||||
|
||||
StringBuilder caseNotesStringBuilder = new StringBuilder();
|
||||
cRichTextBoxHelper.TraverseBlockAsUnicode(SupportCaseDataProviderArtifact.CaseNotes.Blocks, caseNotesStringBuilder);
|
||||
_namedParameterCache[relation][CaseNotesNamedParameterName] = caseNotesStringBuilder.ToString();
|
||||
|
||||
StringBuilder caseNotesHtmlStringBuilder = new StringBuilder();
|
||||
cRichTextBoxHelper.TraverseBlockAsHtml(SupportCaseDataProviderArtifact.CaseNotes.Blocks, caseNotesHtmlStringBuilder);
|
||||
_namedParameterCache[relation][CaseNotesHtmlNamedParameterName] = caseNotesHtmlStringBuilder.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using C4IT.F4SD.DisplayFormatting;
|
||||
using C4IT.F4SD.SupportCaseProtocoll.Models;
|
||||
using C4IT.FASD.Base;
|
||||
using C4IT.Logging;
|
||||
using C4IT.MultiLanguage;
|
||||
|
||||
using FasdCockpitBase.Models;
|
||||
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.Models.QuickActionOutput;
|
||||
using FasdDesktopUi.Basics.Services.ProtocollService;
|
||||
using FasdDesktopUi.Basics.UserControls;
|
||||
|
||||
using static FasdDesktopUi.Basics.UserControls.QuickActionStatusMonitor;
|
||||
|
||||
namespace FasdDesktopUi.Basics.UiActions
|
||||
{
|
||||
@@ -139,7 +132,7 @@ namespace FasdDesktopUi.Basics.UiActions
|
||||
catch { }
|
||||
|
||||
StatusMonitor.QuickActionOutputs.Add(_ref.Output);
|
||||
quickActionOutput = QuickActionStatusMonitor.cQuickActionOutput.GetQuickActionOutput(_ref.Output, DataProvider);
|
||||
quickActionOutput = cQuickActionOutput.GetQuickActionOutput(_ref.Output, DataProvider);
|
||||
|
||||
cQuickActionCopyData copyData = QuickActionProtocollEntryOutput.GetCopyData(quickActionDemo, DataProvider, true, quickActionOutput, StatusMonitor.MeasureValues);
|
||||
QuickActionProtocollEntry protocollEntry = QuickActionProtocollEntryOutput.GetQuickActionProtocollEntry(quickActionDemo, copyData);
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
using C4IT.F4SD.DisplayFormatting;
|
||||
using C4IT.FASD.Base;
|
||||
using C4IT.Logging;
|
||||
using C4IT.MultiLanguage;
|
||||
using FasdCockpitBase.Models;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.UserControls;
|
||||
using FasdDesktopUi.Basics.Models.QuickActionOutput;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Tracing;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
namespace FasdDesktopUi.Basics.UiActions
|
||||
{
|
||||
@@ -39,7 +32,7 @@ namespace FasdDesktopUi.Basics.UiActions
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<QuickActionStatusMonitor.cQuickActionMeasureValue> GetStatusMonitorMeasureValues(List<cF4sdQuickActionRevision.cMeasure> measures)
|
||||
private List<cQuickActionMeasureValue> GetStatusMonitorMeasureValues(List<cF4sdQuickActionRevision.cMeasure> measures)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using C4IT.F4SD.DisplayFormatting;
|
||||
@@ -11,12 +9,11 @@ using C4IT.FASD.Base;
|
||||
using C4IT.FASD.Cockpit.Communication;
|
||||
using C4IT.Logging;
|
||||
using C4IT.MultiLanguage;
|
||||
using FasdCockpitBase.Models;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.Models.QuickActionOutput;
|
||||
using FasdDesktopUi.Basics.Services.ProtocollService;
|
||||
using Newtonsoft.Json;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using static FasdDesktopUi.Basics.UserControls.QuickActionStatusMonitor;
|
||||
|
||||
namespace FasdDesktopUi.Basics.UiActions
|
||||
{
|
||||
|
||||
@@ -1,21 +1,15 @@
|
||||
using C4IT.F4SD.DisplayFormatting;
|
||||
using C4IT.F4SD.SupportCaseProtocoll.Models;
|
||||
using C4IT.FASD.Base;
|
||||
using C4IT.Logging;
|
||||
using C4IT.MultiLanguage;
|
||||
using FasdCockpitBase.Models;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.Models.QuickActionOutput;
|
||||
using FasdDesktopUi.Basics.Services.ProtocollService;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using static FasdDesktopUi.Basics.UserControls.QuickActionStatusMonitor;
|
||||
|
||||
namespace FasdDesktopUi.Basics.UiActions
|
||||
{
|
||||
|
||||
@@ -85,6 +85,9 @@ namespace FasdDesktopUi.Basics.UiActions
|
||||
|
||||
cF4sdStagedSearchResultRelationTaskId gatherRelationTask = await _searchUiProvider.SearchService.LoadRelationsAsync(_searchResults, token);
|
||||
|
||||
if (gatherRelationTask == null)
|
||||
return false;
|
||||
|
||||
HashSet<enumFasdInformationClass> orderedPendingInfoClasses
|
||||
= GetInformationClassOrderedByPriority(gatherRelationTask.PendingInformationClasses, cF4sdIdentityEntry.GetFromSearchResult(_searchResults.FirstOrDefault()?.Type ?? enumF4sdSearchResultClass.Unknown));
|
||||
_searchUiProvider.SetPendingInformationClasses(orderedPendingInfoClasses);
|
||||
|
||||
@@ -6,6 +6,7 @@ using C4IT.Logging;
|
||||
using C4IT.MultiLanguage;
|
||||
using FasdCockpitBase.Models;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.Models.QuickActionOutput;
|
||||
using FasdDesktopUi.Basics.Services.ProtocollService;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
@@ -6,6 +6,7 @@ using C4IT.Logging;
|
||||
using C4IT.MultiLanguage;
|
||||
using FasdCockpitBase.Models;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.Models.QuickActionOutput;
|
||||
using FasdDesktopUi.Basics.Services.ProtocollService;
|
||||
using FasdDesktopUi.Basics.UserControls;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
using C4IT.F4SD.DisplayFormatting;
|
||||
using C4IT.F4SD.SupportCaseProtocoll.Models;
|
||||
using C4IT.FASD.Base;
|
||||
using C4IT.MultiLanguage;
|
||||
using F4SD_AdaptableIcon.Enums;
|
||||
using F4SD.Gamification;
|
||||
using FasdDesktopUi.Basics.Converter;
|
||||
using FasdDesktopUi.Basics.Models;
|
||||
using FasdDesktopUi.Basics.Services.ProtocollService;
|
||||
using FasdDesktopUi.Basics.UiActions;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -23,12 +20,12 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using F4SD.Gamification.Services;
|
||||
using FasdDesktopUi.Basics.Models.QuickActionOutput;
|
||||
|
||||
namespace FasdDesktopUi.Basics.UserControls
|
||||
{
|
||||
public partial class QuickActionStatusMonitor : UserControl, IBlurInvoker
|
||||
{
|
||||
private const string veiledText = "********";
|
||||
private bool secretsAreShown = false;
|
||||
private readonly IRawValueFormatter _rawValueFormatter = new RawValueFormatter();
|
||||
|
||||
@@ -42,503 +39,6 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
set { lock (_currentQuickActionLock) { _currentRunningQuickActionId = value; } }
|
||||
}
|
||||
|
||||
#region Helperclasses QuickAction Output
|
||||
|
||||
public abstract class cQuickActionOutput
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
private CancellationTokenSource tokenSource;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using C4IT.FASD.Base;
|
||||
|
||||
using FasdDesktopUi.Basics.Models.QuickActionOutput;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
MinHeight="225"
|
||||
MinWidth="255"
|
||||
x:Name="NotepadUc">
|
||||
|
||||
|
||||
<UserControl.Resources>
|
||||
<Style TargetType="ico:AdaptableIcon"
|
||||
BasedOn="{StaticResource Menu.MenuBar.PinnedIcon }">
|
||||
@@ -38,52 +38,26 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<DockPanel>
|
||||
|
||||
<!--<DockPanel.Resources>
|
||||
<Style TargetType="ico:AdaptableIcon">
|
||||
<Setter Property="IconWidth"
|
||||
Value="20" />
|
||||
<Setter Property="IconHeight"
|
||||
Value="20" />
|
||||
<Setter Property="BorderPadding"
|
||||
Value="5" />
|
||||
<Setter Property="IconBackgroundColor"
|
||||
Value="Transparent" />
|
||||
<Setter Property="Margin"
|
||||
Value="0, 0, 10, 0" />
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource Color.Menu.Icon}" />
|
||||
<Setter Property="Cursor"
|
||||
Value="Hand" />
|
||||
<Setter Property="WindowChrome.IsHitTestVisibleInChrome"
|
||||
Value="True" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="PrimaryIconColor"
|
||||
Value="{DynamicResource Color.Menu.Icon.Hover}" />
|
||||
<Setter Property="IconBackgroundColor"
|
||||
Value="{DynamicResource Background.Menu.Icon.Hover}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
|
||||
</Style>
|
||||
</DockPanel.Resources>-->
|
||||
|
||||
<ico:AdaptableIcon x:Name="CloseNotepadIcon" x:FieldModifier="private"
|
||||
<ico:AdaptableIcon x:Name="CloseNotepadIcon"
|
||||
x:FieldModifier="private"
|
||||
DockPanel.Dock="Right"
|
||||
SelectedInternIcon="window_minimize"
|
||||
Style="{DynamicResource SettingsPage.Close.Icon}"
|
||||
WindowChrome.IsHitTestVisibleInChrome ="True"
|
||||
WindowChrome.IsHitTestVisibleInChrome="True"
|
||||
Margin="0 8 0 0"
|
||||
Tag="close" MouseUp="CloseNotepadIcon_MouseUp" TouchDown="CloseNotepadIcon_TouchDown"/>
|
||||
Tag="close"
|
||||
MouseLeftButtonUp="CloseNotepadIcon_Click"
|
||||
TouchDown="CloseNotepadIcon_Click" />
|
||||
|
||||
<ico:AdaptableIcon x:Name="LockNotepadIcon" x:FieldModifier="private"
|
||||
<ico:AdaptableIcon x:Name="LockNotepadIcon"
|
||||
x:FieldModifier="private"
|
||||
DockPanel.Dock="Right"
|
||||
Style="{DynamicResource Menu.Notepad.Icon.Lock}"
|
||||
MouseLeave="LockNotepadIcon_MouseLeave"
|
||||
WindowChrome.IsHitTestVisibleInChrome ="True"
|
||||
Tag="lock" MouseUp="LockNotepadIcon_MouseUp" TouchDown="LockNotepadIcon_TouchDown"/>
|
||||
WindowChrome.IsHitTestVisibleInChrome="True"
|
||||
Tag="lock"
|
||||
MouseLeftButtonUp="LockNotepadIcon_Click"
|
||||
TouchDown="LockNotepadIcon_Click" />
|
||||
|
||||
<ico:AdaptableIcon DockPanel.Dock="Left"
|
||||
VerticalAlignment="Center"
|
||||
@@ -93,16 +67,16 @@
|
||||
IconHeight="15"
|
||||
IconWidth="15"
|
||||
Style="{x:Null}">
|
||||
|
||||
|
||||
</ico:AdaptableIcon>
|
||||
|
||||
<TextBlock DockPanel.Dock="Left"
|
||||
Style="{DynamicResource DetailsPage.DataHistory.TitleColumn.OverviewTitle}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10"
|
||||
Margin="10"
|
||||
Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Notepad.Heading.Notes}">
|
||||
|
||||
|
||||
</TextBlock>
|
||||
|
||||
</DockPanel>
|
||||
@@ -110,48 +84,56 @@
|
||||
<DockPanel Grid.Row="2">
|
||||
|
||||
<Border DockPanel.Dock="Top"
|
||||
Margin="0 0 0 10"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.Widget.Title}"
|
||||
Padding="5"
|
||||
CornerRadius="7.5">
|
||||
Margin="0 0 0 10"
|
||||
Background="{DynamicResource BackgroundColor.DetailsPage.Widget.Title}"
|
||||
Padding="5"
|
||||
CornerRadius="7.5">
|
||||
<DockPanel>
|
||||
|
||||
<ico:AdaptableIcon x:Name="ToggleDockButton" x:FieldModifier="private"
|
||||
<ico:AdaptableIcon x:Name="ToggleDockButton"
|
||||
x:FieldModifier="private"
|
||||
DockPanel.Dock="Right"
|
||||
SelectedMaterialIcon="ic_zoom_out_map"
|
||||
MouseLeftButtonUp="ToggleDockButton_MouseLeftButtonUp"
|
||||
TouchDown="ToggleDockButton_TouchDown" />
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ico:AdaptableIcon x:Name="UndoIcon" x:FieldModifier="private"
|
||||
<ico:AdaptableIcon x:Name="UndoIcon"
|
||||
x:FieldModifier="private"
|
||||
SelectedMaterialIcon="ic_undo"
|
||||
Command="ApplicationCommands.Undo"
|
||||
Style="{DynamicResource Menu.MenuBar.PinnedIcon.Disabled}"/>
|
||||
<ico:AdaptableIcon x:Name="RedoIcon" x:FieldModifier="private"
|
||||
Command="ApplicationCommands.Undo"
|
||||
Style="{DynamicResource Menu.MenuBar.PinnedIcon.Disabled}" />
|
||||
<ico:AdaptableIcon x:Name="RedoIcon"
|
||||
x:FieldModifier="private"
|
||||
SelectedMaterialIcon="ic_redo"
|
||||
Command="ApplicationCommands.Redo"
|
||||
Style="{DynamicResource Menu.MenuBar.PinnedIcon.Disabled}"/>
|
||||
Style="{DynamicResource Menu.MenuBar.PinnedIcon.Disabled}" />
|
||||
<ico:AdaptableIcon x:Name="CopyIcon"
|
||||
SelectedInternIcon="menuBar_copy"
|
||||
TouchDown="CopyIcon_TouchDown"
|
||||
MouseLeftButtonUp="CopyIcon_MouseLeftButtonUp" />
|
||||
<ico:AdaptableIcon x:Name="BoldIcon" x:FieldModifier="private"
|
||||
TouchDown="CopyIcon_Click"
|
||||
MouseLeftButtonUp="CopyIcon_Click" />
|
||||
<ico:AdaptableIcon x:Name="BoldIcon"
|
||||
x:FieldModifier="private"
|
||||
SelectedMaterialIcon="ic_format_bold"
|
||||
Command="EditingCommands.ToggleBold"
|
||||
MouseLeftButtonUp="TextBoxIcon_MouseLeftButtonUp" />
|
||||
<ico:AdaptableIcon x:Name="ItalicIcon" x:FieldModifier="private"
|
||||
<ico:AdaptableIcon x:Name="ItalicIcon"
|
||||
x:FieldModifier="private"
|
||||
SelectedMaterialIcon="ic_format_italic"
|
||||
Command="EditingCommands.ToggleItalic"
|
||||
MouseLeftButtonUp="TextBoxIcon_MouseLeftButtonUp" />
|
||||
<ico:AdaptableIcon x:Name="UnderlineIcon" x:FieldModifier="private"
|
||||
<ico:AdaptableIcon x:Name="UnderlineIcon"
|
||||
x:FieldModifier="private"
|
||||
SelectedMaterialIcon="ic_format_underlined"
|
||||
Command="EditingCommands.ToggleUnderline"
|
||||
MouseLeftButtonUp="TextBoxIcon_MouseLeftButtonUp" />
|
||||
<ico:AdaptableIcon x:Name="BulletsIcon" x:FieldModifier="private"
|
||||
<ico:AdaptableIcon x:Name="BulletsIcon"
|
||||
x:FieldModifier="private"
|
||||
SelectedMaterialIcon="ic_format_list_bulleted"
|
||||
Command="EditingCommands.ToggleBullets"
|
||||
MouseLeftButtonUp="TextBoxIcon_MouseLeftButtonUp" />
|
||||
<ico:AdaptableIcon x:Name="NumberingIcon" x:FieldModifier="private"
|
||||
<ico:AdaptableIcon x:Name="NumberingIcon"
|
||||
x:FieldModifier="private"
|
||||
SelectedMaterialIcon="ic_format_list_numbered"
|
||||
Command="EditingCommands.ToggleNumbering"
|
||||
MouseLeftButtonUp="TextBoxIcon_MouseLeftButtonUp" />
|
||||
@@ -161,7 +143,8 @@
|
||||
</Border>
|
||||
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<RichTextBox x:Name="NotepadRichTextBox" x:FieldModifier="private"
|
||||
<RichTextBox x:Name="NotepadRichTextBox"
|
||||
x:FieldModifier="private"
|
||||
VerticalAlignment="Stretch"
|
||||
Padding="2.5 5"
|
||||
TextChanged="NotepadRichTextBox_TextChanged"
|
||||
|
||||
@@ -42,21 +42,7 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
|
||||
#region DataProvider
|
||||
|
||||
private cSupportCaseDataProvider DataProvider;
|
||||
|
||||
/*
|
||||
{
|
||||
get { return (cDataProviderBase)GetValue(DataProviderProperty); }
|
||||
set {
|
||||
SetValue(DataProviderProperty, value);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
private static readonly DependencyProperty DataProviderProperty =
|
||||
DependencyProperty.Register("DataProvider", typeof(cDataProviderBase), typeof(Notepad), new PropertyMetadata(null));
|
||||
*/
|
||||
private readonly cSupportCaseDataProvider _dataProvider;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -102,24 +88,18 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
|
||||
private static void HandleLockedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
if (!(d is Notepad _me))
|
||||
{
|
||||
if (!(d is Notepad notepad))
|
||||
return;
|
||||
}
|
||||
|
||||
_me.LockNotepadIcon.SelectedInternIcon = _me.IsLocked ? F4SD_AdaptableIcon.Enums.enumInternIcons.lock_closed : F4SD_AdaptableIcon.Enums.enumInternIcons.lock_open;
|
||||
|
||||
_me.CloseNotepadIcon.IsEnabled = _me.IsLocked ? false : true;
|
||||
|
||||
notepad.LockNotepadIcon.SelectedInternIcon = notepad.IsLocked ? enumInternIcons.lock_closed : enumInternIcons.lock_open;
|
||||
notepad.CloseNotepadIcon.IsEnabled = !notepad.IsLocked;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -165,7 +145,7 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
|
||||
public Notepad(cSupportCaseDataProvider dataProvider)
|
||||
{
|
||||
DataProvider = dataProvider;
|
||||
_dataProvider = dataProvider;
|
||||
InitializeComponent();
|
||||
saveTimer = new DispatcherTimer(TimeSpan.FromSeconds(0.75), DispatcherPriority.Render, SaveNotes, Dispatcher.CurrentDispatcher);
|
||||
IsLocked = cFasdCockpitConfig.Instance.IsNotepadVisibleDocked;
|
||||
@@ -180,16 +160,16 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DataProvider is null)
|
||||
if (_dataProvider is null)
|
||||
return;
|
||||
|
||||
if (DataProvider?.CaseNotes?.Parent is RichTextBox parentBox)
|
||||
if (_dataProvider?.CaseNotes?.Parent is RichTextBox parentBox)
|
||||
parentBox.Document = new FlowDocument();
|
||||
|
||||
if (!(sender is RichTextBox senderElement))
|
||||
return;
|
||||
|
||||
senderElement.Document = DataProvider.CaseNotes;
|
||||
senderElement.Document = _dataProvider.CaseNotes;
|
||||
senderElement.CaretPosition = senderElement.CaretPosition.DocumentEnd;
|
||||
}
|
||||
catch (Exception E)
|
||||
@@ -221,7 +201,7 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
|
||||
#region CopyIcon Click
|
||||
|
||||
private async void CopyIcon_Click(object sender)
|
||||
private async void CopyIcon_Click(object sender, InputEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -254,16 +234,6 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyIcon_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
CopyIcon_Click(sender);
|
||||
}
|
||||
|
||||
private void CopyIcon_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
CopyIcon_Click(sender);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Popout
|
||||
@@ -308,13 +278,13 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
{
|
||||
saveTimer?.Stop();
|
||||
|
||||
if (DataProvider is null)
|
||||
if (_dataProvider is null)
|
||||
return;
|
||||
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
SetLanguageOfDocument();
|
||||
DataProvider.SaveCaseNotes();
|
||||
_dataProvider.SaveCaseNotes();
|
||||
});
|
||||
}
|
||||
catch (Exception E)
|
||||
@@ -642,7 +612,7 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
{
|
||||
ToggleDockButton.Visibility = IsUndocked ? Visibility.Collapsed : Visibility.Visible;
|
||||
LockNotepadIcon.Visibility = IsUndocked ? Visibility.Collapsed : Visibility.Visible;
|
||||
CloseNotepadIcon.IsEnabled = IsUndocked ? true : !IsLocked;
|
||||
CloseNotepadIcon.IsEnabled = IsUndocked || !IsLocked;
|
||||
|
||||
}
|
||||
catch (Exception E)
|
||||
@@ -680,23 +650,12 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseNotepadIcon_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.ChangedButton == MouseButton.Left)
|
||||
CloseNotepad();
|
||||
}
|
||||
|
||||
private void CloseNotepadIcon_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
CloseNotepad();
|
||||
}
|
||||
private void CloseNotepadIcon_Click(object sender, InputEventArgs e) => CloseNotepad();
|
||||
|
||||
private void LockNotepad()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if (IsLocked)
|
||||
{
|
||||
LockNotepadIcon.SetResourceReference(AdaptableIcon.AdaptableIcon.PrimaryIconColorProperty, "Color.SoftContrast");
|
||||
@@ -717,19 +676,9 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void LockNotepadIcon_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.ChangedButton == MouseButton.Left)
|
||||
LockNotepad();
|
||||
}
|
||||
|
||||
private void LockNotepadIcon_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
LockNotepad();
|
||||
}
|
||||
private void LockNotepadIcon_Click(object sender, InputEventArgs e) => LockNotepad();
|
||||
|
||||
private void LockNotepadIcon_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
|
||||
@@ -78,14 +78,15 @@
|
||||
<local:SearchBar x:Name="Search"
|
||||
DockPanel.Dock="Top"
|
||||
PlaceholderText="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Searchbar.Placeholder}"
|
||||
ShowCloseButton="False"
|
||||
ShowCloseButton="True"
|
||||
SearchButtonSize="26"
|
||||
DebounceInterval="0"
|
||||
SearchBackground="{DynamicResource BackgroundColor.DetailsPage.Widget.Title}"
|
||||
SearchValueChanged="SearchBar_SearchValueChanged"
|
||||
Margin="0 0 0 10"
|
||||
Focusable="True"
|
||||
Height="26" />
|
||||
Height="26"
|
||||
CancelledSearch="Search_CancelledSearch" />
|
||||
|
||||
<local:CustomMenu x:Name="SubMenuUc"
|
||||
DockPanel.Dock="Top"
|
||||
|
||||
@@ -238,5 +238,12 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
|
||||
private void SearchBar_SearchValueChanged(object sender, string e)
|
||||
=> SearchValueChanged?.Invoke(this, e);
|
||||
|
||||
#region ClearSearch
|
||||
private void Search_CancelledSearch(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Search.Clear();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
@@ -9,7 +10,7 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
{
|
||||
public partial class SearchBar : UserControl
|
||||
{
|
||||
private readonly DispatcherTimer _searchTimer = new DispatcherTimer();
|
||||
private readonly Timer _searchTimer = new Timer();
|
||||
|
||||
#region Dependency Properties
|
||||
|
||||
@@ -70,7 +71,8 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
|
||||
private static void OnDebounceIntervalChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
((SearchBar)d)._searchTimer.Interval = (TimeSpan)e.NewValue;
|
||||
TimeSpan interval = (TimeSpan)e.NewValue;
|
||||
((SearchBar)d)._searchTimer.Interval = Math.Max(interval.TotalMilliseconds, 10);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IsInputEnabledProperty =
|
||||
@@ -158,7 +160,7 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
|
||||
private void HandleSearchValueChanged()
|
||||
{
|
||||
if (_searchTimer.IsEnabled)
|
||||
if (_searchTimer.Enabled)
|
||||
_searchTimer.Stop();
|
||||
|
||||
_searchTimer.Start();
|
||||
@@ -183,8 +185,8 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
private void SearchBar_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_searchTimer.Stop();
|
||||
_searchTimer.Interval = DebounceInterval;
|
||||
_searchTimer.Tick += SearchTimerTick;
|
||||
_searchTimer.Interval = Math.Max(DebounceInterval.TotalMilliseconds, 10);
|
||||
_searchTimer.Elapsed += SearchTimerTick;
|
||||
BackgroundBorder.CornerRadius = new CornerRadius(BackgroundBorder.ActualHeight / 2.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -422,9 +422,28 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
|
||||
foreach (var informationClass in informationClasses.Reverse())
|
||||
{
|
||||
string _title = string.Empty;
|
||||
switch (informationClass)
|
||||
{
|
||||
case enumFasdInformationClass.Computer:
|
||||
_title = "Searchbar.Relations.SearchFor.Computer";
|
||||
break;
|
||||
case enumFasdInformationClass.User:
|
||||
_title = "Searchbar.Relations.SearchFor.User";
|
||||
break;
|
||||
case enumFasdInformationClass.Ticket:
|
||||
_title = "Searchbar.Relations.SearchFor.Ticket";
|
||||
break;
|
||||
case enumFasdInformationClass.VirtualSession:
|
||||
_title = "Searchbar.Relations.SearchFor.VirtualSession";
|
||||
break;
|
||||
}
|
||||
if (string.IsNullOrEmpty(_title))
|
||||
continue;
|
||||
|
||||
var searchResultCategory = new SearchResultCategory()
|
||||
{
|
||||
Title = string.Format(cMultiLanguageSupport.GetItem("Searchbar.Relations.SearchFor"), informationClass),
|
||||
Title = cMultiLanguageSupport.GetItem(_title),
|
||||
IsPending = true,
|
||||
TitleIcon = GetIconFrom(informationClass),
|
||||
Margin = new Thickness(0, 7.5, 0, 0)
|
||||
|
||||
Reference in New Issue
Block a user