This commit is contained in:
Meik
2025-11-11 11:03:42 +01:00
commit dc3e8a2e4c
582 changed files with 191465 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.1.0" newVersion="6.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.4.0" newVersion="4.2.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -0,0 +1,10 @@
<Application x:Class="FasdExcelToJsonConverter.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FasdExcelToJsonConverter"
StartupUri="MainWindow.xaml"
Startup="Application_Startup">
<Application.Resources>
</Application.Resources>
</Application>

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using C4IT.Logging;
namespace FasdExcelToJsonConverter
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
private void Application_Startup(object sender, StartupEventArgs e)
{
cLogManagerFile.CreateInstance(false, SubFolder: "Logs");
cLogManager.DefaultLogger.LogAssemblyInfo();
}
}
}

View File

@@ -0,0 +1,345 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using C4IT.FASD.Base;
using FasdCockpitCommunicationDemo;
using static C4IT.Logging.cLogManager;
using Microsoft.Office.Interop.Excel;
using Excel = Microsoft.Office.Interop.Excel;
using System.Windows.Shapes;
using System.Text.RegularExpressions;
using FasdCockpitBase.Models;
namespace FasdExcelToJsonConverter
{
public class cExcelHealthcardParser
{
private Dictionary<string, Worksheet> workSheets;
public cExcelHealthcardParser(Workbook selectedWorkBook)
{
if (LoadWorkSheets(selectedWorkBook, out var workSheets))
this.workSheets = workSheets;
}
private bool LoadWorkSheets(Workbook selectedWorkBook, out Dictionary<string, Worksheet> workSheets)
{
var CM = MethodBase.GetCurrentMethod();
LogMethodBegin(CM);
workSheets = new Dictionary<string, Worksheet>();
if (selectedWorkBook == null)
return false;
try
{
foreach (Worksheet workSheet in selectedWorkBook.Worksheets)
{
workSheets.Add(workSheet.Name, workSheet);
}
return true;
}
catch (Exception E)
{
LogException(E);
}
finally
{
LogMethodEnd(CM);
}
return false;
}
public bool GetHealthcardDataFromExcel(string WorkSheetName, out cF4SDHealthCardJsonRawData HealthcardJsonData)
{
var CM = MethodBase.GetCurrentMethod();
LogMethodBegin(CM);
HealthcardJsonData = new cF4SDHealthCardJsonRawData();
if (string.IsNullOrEmpty(WorkSheetName))
return false;
try
{
if (!workSheets.TryGetValue(WorkSheetName, out var selectedWorkSheet))
return false;
var range = selectedWorkSheet.UsedRange;
var healthCardData = new cF4SDHealthCardRawData();
for (int excelRow = 2; excelRow <= range.Rows.Count; excelRow++) // start from 2 because not zero based and 1st row contains header
{
//Get values of excel row
var values = new List<object>();
for (int excelColumn = 3; excelColumn <= range.Columns.Count; excelColumn++) // start from 2 because not zero based and 1st and 2nd column contains ValueTable & ValueColumn
{
var cellValue = range.Cells[excelRow, excelColumn].Value as object;
values.Add(cellValue);
}
//Get Table of Dictionary
var valueTable = range.Cells[excelRow, 1].Value?.ToString();
if (!healthCardData.Tables.ContainsKey(valueTable))
healthCardData.Tables.Add(valueTable, new cF4SDHealthCardRawData.cHealthCardTable() { Name = valueTable });
//Add Columns
if (healthCardData.Tables.TryGetValue(valueTable, out cF4SDHealthCardRawData.cHealthCardTable tableDictionaryEntry))
{
var columnName = range.Cells[excelRow, 2].Value?.ToString();
if (tableDictionaryEntry.Columns.ContainsKey(columnName))
continue;
tableDictionaryEntry.Columns.Add(columnName, new cF4SDHealthCardRawData.cHealthCardTableColumn() { ColumnName = columnName, Values = values.ToList() });
if (tableDictionaryEntry.TimeFrames == null)
tableDictionaryEntry.TimeFrames = new DateTime[1, 2];
if (tableDictionaryEntry.TimeFrames.GetLength(0) < values.Count)
tableDictionaryEntry.TimeFrames = new DateTime[values.Count, 2];
}
}
foreach (var table in healthCardData.Tables)
{
table.Value.TimeFrames[0, 0] = DateTime.Now;
table.Value.TimeFrames[0, 1] = DateTime.Today;
for (int i = 1; i < table.Value.TimeFrames.GetLength(0) - 1; i++)
{
table.Value.TimeFrames[i, 0] = DateTime.Today.AddDays(-i);
table.Value.TimeFrames[i, 1] = DateTime.Today.AddDays(-i - 1);
}
}
HealthcardJsonData = cF4SDHealthCardJsonRawData.GetHealthCardJsonRawData(healthCardData);
HealthcardJsonData.DetailsTables = GetDetailsTablesFromExcel();
HealthcardJsonData.Tickets = GetTicketsFromExcel();
return true;
}
catch (Exception E)
{
LogException(E);
}
finally
{
LogMethodEnd(CM);
}
return false;
}
private List<cF4SDHealthCardRawData.cHealthCardDetailsTable> GetDetailsTablesFromExcel()
{
var CM = MethodBase.GetCurrentMethod();
LogMethodBegin(CM);
var output = new List<cF4SDHealthCardRawData.cHealthCardDetailsTable>();
try
{
foreach (var workSheet in workSheets)
{
if (!workSheet.Key.StartsWith("details-"))
continue;
var selectedWorkSheet = workSheet.Value;
var range = selectedWorkSheet.UsedRange;
var tableName = workSheet.Key.Replace("details-", "agnt-computer-event-details-");
var tableColumns = new List<string>();
for (int i = 2; i <= range.Columns.Count; i++)
{
tableColumns.Add(range.Cells[1, i].Value?.ToString());
}
var tableValues = new Dictionary<int, List<object[]>>();
for (int excelRow = 2; excelRow <= range.Rows.Count; excelRow++)
{
var dayValue = range.Cells[excelRow, 1].Value?.ToString();
int dayIndex = int.MinValue;
if (DateTime.TryParse(dayValue, out DateTime dayDate))
dayIndex = (DateTime.Today - dayDate).Days;
List<object> rowValues = new List<object>();
for (int excelColumn = 2; excelColumn <= range.Columns.Count; excelColumn++)
{
rowValues.Add(range.Cells[excelRow, excelColumn].Value);
}
if (tableValues.TryGetValue(dayIndex, out var dayValues))
dayValues.Add(rowValues.ToArray());
else
tableValues.Add(dayIndex, new List<object[]>() { rowValues.ToArray() });
}
var tableToAdd = new cF4SDHealthCardRawData.cHealthCardDetailsTable() { Name = tableName, Columns = tableColumns, Values = tableValues };
output.Add(tableToAdd);
}
}
catch (Exception E)
{
LogException(E);
}
finally
{
LogMethodEnd(CM);
}
return output;
}
private List<cF4SDTicket> GetTicketsFromExcel()
{
var CM = MethodBase.GetCurrentMethod();
LogMethodBegin(CM);
List<cF4SDTicket> output = new List<cF4SDTicket>();
try
{
if (!workSheets.TryGetValue("%TicketData%", out var TicketWorksheet))
return output;
Dictionary<double, cF4SDTicket> tempTickets = new Dictionary<double, cF4SDTicket>();
var ticketRange = TicketWorksheet.UsedRange;
for (int row = 2; row <= ticketRange.Rows.Count; row++)
{
double ticketId = ticketRange.Cells[row, 1].Value;
string affectedUser = ticketRange.Cells[row, 2].Value;
double creationDaysSinceNow = ticketRange.Cells[row, 3].Value;
DateTime creationDate = DateTime.Now.AddDays(-creationDaysSinceNow);
double? closingDaysSinceNow = ticketRange.Cells[row, 4].Value;
DateTime? closingDate = null;
if (closingDaysSinceNow.HasValue)
closingDate = DateTime.Now.AddDays(closingDaysSinceNow.Value);
enumTicketStatus ticketStatus = enumTicketStatus.Unknown;
Enum.TryParse<enumTicketStatus>(ticketRange.Cells[row, 5].Value?.ToString(), out ticketStatus);
cF4SDTicket.enumTicketCreationSource creationSource = cF4SDTicket.enumTicketCreationSource.Unknown;
Enum.TryParse<cF4SDTicket.enumTicketCreationSource>(ticketRange.Cells[row, 6].Value, out creationSource);
// classification = ticketRange.Cells[row, 7].Value;
string asset = ticketRange.Cells[row, 8].Value;
string ticketName = ticketRange.Cells[row, 9].Value;
string summary = ticketRange.Cells[row, 10].Value;
string category = ticketRange.Cells[row, 11].Value;
double priority = ticketRange.Cells[row, 12].Value;
string description = ticketRange.Cells[row, 13].Value;
string htmlDescription = ticketRange.Cells[row, 14].Value;
string solution = ticketRange.Cells[row, 15].Value;
string directLinkPreview = ticketRange.Cells[row, 16].Value;
string directLinkEdit = ticketRange.Cells[row, 17].Value;
string directLinkClose = ticketRange.Cells[row, 18].Value;
if (tempTickets.ContainsKey(ticketId))
{
LogEntry($"Ticket with id {ticketId} allready exists.");
continue;
}
cF4SDTicket tempTicket = new cF4SDTicket()
{
Id = Guid.NewGuid(),
AffectedUser = affectedUser,
CreationDaysSinceNow = creationDaysSinceNow,
CreationDate = creationDate,
ClosingDaysSinceNow = closingDaysSinceNow,
ClosingDate = closingDate,
Status = ticketStatus,
CreationSource = creationSource,
Asset = asset,
Name = ticketName,
Summary = summary,
Category = category,
Priority = (int)priority,
Description = description,
DescriptionHtml = htmlDescription,
Solution = solution,
JournalItems = new List<cF4SDTicket.cTicketJournalItem>(),
DirectLinks = new Dictionary<string, string>()
};
if (!(string.IsNullOrWhiteSpace(directLinkPreview)))
{
tempTicket.DirectLinks.Add("DirectLinkPreview", directLinkPreview);
var ticketIdString = Regex.Match(directLinkPreview, @"[0-9A-Fa-f]{8}-?([0-9A-Fa-f]{4}-?){3}[0-9A-Fa-f]{12}");
if (ticketIdString.Success && Guid.TryParse(ticketIdString.Value, out var tempTicketId))
tempTicket.Id = tempTicketId;
}
if (!(string.IsNullOrWhiteSpace(directLinkEdit)))
tempTicket.DirectLinks.Add("DirectLinkEdit", directLinkEdit);
if (!(string.IsNullOrWhiteSpace(directLinkClose)))
tempTicket.DirectLinks.Add("DirectLinkClose", directLinkClose);
tempTickets.Add(ticketId, tempTicket);
}
output = tempTickets.Values.ToList();
if (!workSheets.TryGetValue("%TicketDetails%", out var DetailsWorksheet))
return output;
var detailRange = DetailsWorksheet.UsedRange;
for (int row = 2; row <= detailRange.Rows.Count; row++)
{
double ticketId = detailRange.Cells[row, 1].Value;
double creationDaysSinceNow = detailRange.Cells[row, 2].Value;
DateTime creationDate = DateTime.Now.AddDays(-creationDaysSinceNow);
bool isVisibleForUser = bool.Parse(detailRange.Cells[row, 3].Value);
string header = detailRange.Cells[row, 4].Value;
string createdBy = detailRange.Cells[row, 5].Value;
string description = detailRange.Cells[row, 6].Value;
var tempJournalItem = new cF4SDTicket.cTicketJournalItem()
{
CreationDaysSinceNow = creationDaysSinceNow,
CreationDate = creationDate,
IsVisibleForUser = isVisibleForUser,
Header = header,
CreatedBy = createdBy,
Description = description
};
if (tempTickets.ContainsKey(ticketId))
{
var tempJournalItems = tempTickets[ticketId].JournalItems;
if (tempJournalItems is null)
tempJournalItems = new List<cF4SDTicket.cTicketJournalItem>();
tempJournalItems.Add(tempJournalItem);
}
}
output = tempTickets.Values.ToList();
}
catch (Exception E)
{
LogException(E);
}
finally
{
LogMethodEnd(CM);
}
return output;
}
}
}

View File

@@ -0,0 +1,209 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E6E1E6DA-A230-4EB8-807C-76DC84D43AD0}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>FasdExcelToJsonConverter</RootNamespace>
<AssemblyName>F4SD-ExcelToJson-Converter</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>false</Deterministic>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'BuildToTeams|AnyCPU'">
<OutputPath>bin\BuildToTeams\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Demo%28Debug%29|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Demo%28Debug%29\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NewFeatures%28Debug%29|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\NewFeatures%28Debug%29\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="..\Shared\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="ExcelHealthcardParser.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Resource Include="Resources\Roboto-Regular.ttf" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<COMReference Include="Microsoft.Office.Core">
<Guid>{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}</Guid>
<VersionMajor>2</VersionMajor>
<VersionMinor>8</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="Microsoft.Office.Interop.Excel">
<Guid>{00020813-0000-0000-C000-000000000046}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>9</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="VBIDE">
<Guid>{0002E157-0000-0000-C000-000000000046}</Guid>
<VersionMajor>5</VersionMajor>
<VersionMinor>3</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\F4SD-Logging\F4SD-Logging.csproj">
<Project>{7793f281-b226-4e20-b6f6-5d53d70f1dc1}</Project>
<Name>F4SD-Logging</Name>
</ProjectReference>
<ProjectReference Include="..\FasdCockpitBase\F4SD-Cockpit-Client-Base.csproj">
<Project>{6dced162-2229-4483-ba70-4471bcdd29cf}</Project>
<Name>F4SD-Cockpit-Client-Base</Name>
</ProjectReference>
<ProjectReference Include="..\FasdCockpitCommunicationDemo\F4SD-Cockpit-Client-Demo.csproj">
<Project>{6efd86ac-d73e-47ac-aafc-d8ea3f8ade93}</Project>
<Name>F4SD-Cockpit-Client-Demo</Name>
</ProjectReference>
<ProjectReference Include="..\FasdDesktopUi\F4SD-Cockpit-Client.csproj">
<Project>{3f1d99e4-b884-4383-867f-b9e746ffa30d}</Project>
<Name>F4SD-Cockpit-Client</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
}

View File

@@ -0,0 +1,52 @@
<Window x:Class="FasdExcelToJsonConverter.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:FasdExcelToJsonConverter"
mc:Ignorable="d"
Title="F4SD Excel-JSON Converter"
Height="130"
Width="400"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
WindowStyle="ToolWindow"
ResizeMode="NoResize">
<Window.Resources>
<FontFamily x:Key="robotoRegularFont">./resources/Roboto-Regular.ttf#Roboto</FontFamily>
</Window.Resources>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox Grid.Row="0"
Grid.Column="0"
Padding="3"
Text="{Binding SelectedFile}"
FontFamily="{StaticResource robotoRegularFont}"/>
<Button x:Name="SearchFileButton"
Grid.Column="1"
Click="SearchFileButton_Click"
ToolTip="Select File"
Margin="5,0,0,0"
Padding="5,0"
FontFamily="{StaticResource robotoRegularFont}">...</Button>
<Button x:Name="ConvertButton"
Margin="0, 10"
Padding="5"
Grid.ColumnSpan="2"
Grid.Row="1"
FontSize="20"
FontFamily="{StaticResource robotoRegularFont}"
FontWeight="Black"
Cursor="Hand"
Click="ConvertButton_Click">Convert to JSON!</Button>
</Grid>
</Window>

View File

@@ -0,0 +1,114 @@
using System;
using System.IO;
using System.Windows;
using Microsoft.Win32;
using Excel = Microsoft.Office.Interop.Excel;
using Newtonsoft.Json;
using System.Reflection;
using C4IT.Logging;
using static C4IT.Logging.cLogManager;
namespace FasdExcelToJsonConverter
{
public partial class MainWindow : Window
{
#region Properties
#region SelectedFile
public static readonly DependencyProperty SelectedFileProperty =
DependencyProperty.Register("SelectedFile", typeof(string), typeof(MainWindow), new PropertyMetadata(""));
public string SelectedFile
{
get { return (string)GetValue(SelectedFileProperty); }
set { SetValue(SelectedFileProperty, value); }
}
#endregion
private readonly Excel.Application excelApp = new Excel.Application();
private Excel.Workbook excelWorkBook;
#endregion
public MainWindow()
{
InitializeComponent();
}
private void SaveSelectedFileAsJson()
{
var CM = MethodBase.GetCurrentMethod();
LogMethodBegin(CM);
try
{
excelWorkBook = excelApp.Workbooks.Open(SelectedFile);
cExcelHealthcardParser healthCardParser = new cExcelHealthcardParser(excelWorkBook);
if (!healthCardParser.GetHealthcardDataFromExcel("%RawData%", out var healthCardData))
return;
SaveFileDialog saveFileDialog = new SaveFileDialog
{
Filter = "Json files (*.json)|*.json"
};
if (saveFileDialog.ShowDialog() == true)
{
healthCardData.SampleDataName = Path.GetFileNameWithoutExtension(saveFileDialog.FileName);
healthCardData.SampleDataId = Guid.NewGuid();
if (healthCardData.SampleDataName == "Kohl, Carlos")
healthCardData.SampleDataId = new Guid("6180aa17-ba2d-455a-bf2f-ec4a075c2d64");
else if (healthCardData.SampleDataName == "Anwender, Peter")
healthCardData.SampleDataId = new Guid("436e8d67-1b9b-4b1a-83e9-0b1e8fa0173b");
else if(healthCardData.SampleDataName == "Ticket, Timo")
healthCardData.SampleDataId = new Guid("42c760d6-90e8-469f-b2fe-ac7d4cc6cb0a");
else if (healthCardData.SampleDataName == "Nichtanwender, Frauke")
healthCardData.SampleDataId = new Guid("2183284f-ba95-4eb8-ac13-6c2f70857e98");
using (StreamWriter streamWriter = File.CreateText(saveFileDialog.FileName))
{
streamWriter.WriteLine(JsonConvert.SerializeObject(healthCardData, Formatting.Indented));
}
MessageBox.Show("Sample Json was created.");
}
}
catch (Exception E)
{
LogException(E);
}
finally
{
excelWorkBook.Close();
excelApp.Quit();
LogMethodEnd(CM);
}
}
private void SearchFileButton_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog
{
Filter = "Excel Files|*.xls;*.xlsx;*.xlsm"
};
if (openFileDialog.ShowDialog() == true)
SelectedFile = openFileDialog.FileName;
}
private void ConvertButton_Click(object sender, RoutedEventArgs e)
{
ConvertButton.IsEnabled = false;
ConvertButton.Content = "Converting...";
SaveSelectedFileAsJson();
ConvertButton.IsEnabled = true;
ConvertButton.Content = "Convert to JSON!";
}
}
}

View File

@@ -0,0 +1,12 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;
[assembly: AssemblyTitle("F4SD ExcelToJson converter")]
[assembly: AssemblyDescription("Creation of demo data.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]

View File

@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace FasdExcelToJsonConverter.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FasdExcelToJsonConverter.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,29 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace FasdExcelToJsonConverter.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

Binary file not shown.

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
</packages>