This commit is contained in:
2024-03-13 00:33:46 +01:00
commit e124a47765
19374 changed files with 9806149 additions and 0 deletions

View File

@@ -0,0 +1,114 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sda.Modeling", "Sda.Modeling\Sda.Modeling.csproj", "{43E28CCF-4918-4CCD-B1BF-9BBFCF43C4CC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sda.Modeling.Provider", "Sda.Modeling.Provider\Sda.Modeling.Provider.csproj", "{CCAC367F-DBE4-4484-9AC1-9A83671AA5FC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sda.Modeling.Runtime", "Sda.Modeling.Runtime\Sda.Modeling.Runtime.csproj", "{7FBE4601-CDB1-4081-AB35-7CF1E43099D8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sda.Modeling.TextTemplating", "Sda.Modeling.TextTemplating\Sda.Modeling.TextTemplating.csproj", "{056CD3AA-F544-41E7-81D3-5D30D664A193}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sda.DictionaryItemEnumGenerator", "Sda.DictionaryItemEnumGenerator\Sda.DictionaryItemEnumGenerator.csproj", "{7D3D2200-9954-4CAD-BEF6-04F4BB129FE6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sda.Build", "Sda.Build\Sda.Build.csproj", "{98EC024C-6439-44B1-8B1E-29E457B2201F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sda.ModelIdUpdater", "Sda.ModelIdUpdater\Sda.ModelIdUpdater.csproj", "{BBAD0E6B-8C66-4746-83AB-F3807C8E1A8E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Build|Any CPU = Build|Any CPU
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{43E28CCF-4918-4CCD-B1BF-9BBFCF43C4CC}.Build|Any CPU.ActiveCfg = Build|Any CPU
{43E28CCF-4918-4CCD-B1BF-9BBFCF43C4CC}.Build|Any CPU.Build.0 = Build|Any CPU
{43E28CCF-4918-4CCD-B1BF-9BBFCF43C4CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43E28CCF-4918-4CCD-B1BF-9BBFCF43C4CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43E28CCF-4918-4CCD-B1BF-9BBFCF43C4CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43E28CCF-4918-4CCD-B1BF-9BBFCF43C4CC}.Release|Any CPU.Build.0 = Release|Any CPU
{CCAC367F-DBE4-4484-9AC1-9A83671AA5FC}.Build|Any CPU.ActiveCfg = Build|Any CPU
{CCAC367F-DBE4-4484-9AC1-9A83671AA5FC}.Build|Any CPU.Build.0 = Build|Any CPU
{CCAC367F-DBE4-4484-9AC1-9A83671AA5FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CCAC367F-DBE4-4484-9AC1-9A83671AA5FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CCAC367F-DBE4-4484-9AC1-9A83671AA5FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CCAC367F-DBE4-4484-9AC1-9A83671AA5FC}.Release|Any CPU.Build.0 = Release|Any CPU
{7FBE4601-CDB1-4081-AB35-7CF1E43099D8}.Build|Any CPU.ActiveCfg = Build|Any CPU
{7FBE4601-CDB1-4081-AB35-7CF1E43099D8}.Build|Any CPU.Build.0 = Build|Any CPU
{7FBE4601-CDB1-4081-AB35-7CF1E43099D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7FBE4601-CDB1-4081-AB35-7CF1E43099D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7FBE4601-CDB1-4081-AB35-7CF1E43099D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FBE4601-CDB1-4081-AB35-7CF1E43099D8}.Release|Any CPU.Build.0 = Release|Any CPU
{056CD3AA-F544-41E7-81D3-5D30D664A193}.Build|Any CPU.ActiveCfg = Build|Any CPU
{056CD3AA-F544-41E7-81D3-5D30D664A193}.Build|Any CPU.Build.0 = Build|Any CPU
{056CD3AA-F544-41E7-81D3-5D30D664A193}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{056CD3AA-F544-41E7-81D3-5D30D664A193}.Debug|Any CPU.Build.0 = Debug|Any CPU
{056CD3AA-F544-41E7-81D3-5D30D664A193}.Release|Any CPU.ActiveCfg = Release|Any CPU
{056CD3AA-F544-41E7-81D3-5D30D664A193}.Release|Any CPU.Build.0 = Release|Any CPU
{7D3D2200-9954-4CAD-BEF6-04F4BB129FE6}.Build|Any CPU.ActiveCfg = Build|Any CPU
{7D3D2200-9954-4CAD-BEF6-04F4BB129FE6}.Build|Any CPU.Build.0 = Build|Any CPU
{7D3D2200-9954-4CAD-BEF6-04F4BB129FE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7D3D2200-9954-4CAD-BEF6-04F4BB129FE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7D3D2200-9954-4CAD-BEF6-04F4BB129FE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7D3D2200-9954-4CAD-BEF6-04F4BB129FE6}.Release|Any CPU.Build.0 = Release|Any CPU
{98EC024C-6439-44B1-8B1E-29E457B2201F}.Build|Any CPU.ActiveCfg = Build|Any CPU
{98EC024C-6439-44B1-8B1E-29E457B2201F}.Build|Any CPU.Build.0 = Build|Any CPU
{98EC024C-6439-44B1-8B1E-29E457B2201F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{98EC024C-6439-44B1-8B1E-29E457B2201F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98EC024C-6439-44B1-8B1E-29E457B2201F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98EC024C-6439-44B1-8B1E-29E457B2201F}.Release|Any CPU.Build.0 = Release|Any CPU
{BBAD0E6B-8C66-4746-83AB-F3807C8E1A8E}.Build|Any CPU.ActiveCfg = Build|Any CPU
{BBAD0E6B-8C66-4746-83AB-F3807C8E1A8E}.Build|Any CPU.Build.0 = Build|Any CPU
{BBAD0E6B-8C66-4746-83AB-F3807C8E1A8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BBAD0E6B-8C66-4746-83AB-F3807C8E1A8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BBAD0E6B-8C66-4746-83AB-F3807C8E1A8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BBAD0E6B-8C66-4746-83AB-F3807C8E1A8E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 7
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = http://sdatfs.hu:8080/tfs/sda
SccProjectUniqueName0 = Sda.Modeling\\Sda.Modeling.csproj
SccProjectName0 = Sda.Modeling
SccAuxPath0 = http://sdatfs.hu:8080/tfs/sda
SccLocalPath0 = Sda.Modeling
SccProvider0 = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccProjectUniqueName1 = Sda.Modeling.Provider\\Sda.Modeling.Provider.csproj
SccProjectName1 = Sda.Modeling.Provider
SccAuxPath1 = http://sdatfs.hu:8080/tfs/sda
SccLocalPath1 = Sda.Modeling.Provider
SccProvider1 = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccProjectUniqueName2 = Sda.Modeling.Runtime\\Sda.Modeling.Runtime.csproj
SccProjectName2 = Sda.Modeling.Runtime
SccAuxPath2 = http://sdatfs.hu:8080/tfs/sda
SccLocalPath2 = Sda.Modeling.Runtime
SccProvider2 = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccProjectUniqueName3 = Sda.Modeling.TextTemplating\\Sda.Modeling.TextTemplating.csproj
SccProjectName3 = Sda.Modeling.TextTemplating
SccAuxPath3 = http://sdatfs.hu:8080/tfs/sda
SccLocalPath3 = Sda.Modeling.TextTemplating
SccProvider3 = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccProjectUniqueName4 = Sda.DictionaryItemEnumGenerator\\Sda.DictionaryItemEnumGenerator.csproj
SccProjectName4 = .
SccAuxPath4 = http://sdatfs.hu:8080/tfs/sda
SccLocalPath4 = .
SccProvider4 = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccProjectFilePathRelativizedFromConnection4 = Sda.DictionaryItemEnumGenerator\\
SccProjectUniqueName5 = Sda.Build\\Sda.Build.csproj
SccProjectName5 = Sda.Build
SccAuxPath5 = http://sdatfs.hu:8080/tfs/sda
SccLocalPath5 = Sda.Build
SccProvider5 = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccProjectUniqueName6 = Sda.ModelIdUpdater\\Sda.ModelIdUpdater.csproj
SccProjectName6 = Sda.ModelIdUpdater
SccAuxPath6 = http://sdatfs.hu:8080/tfs/sda
SccLocalPath6 = Sda.ModelIdUpdater
SccProvider6 = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,11 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
//
// To add a suppression to this file, right-click the message in the
// Code Analysis results, point to "Suppress Message", and click
// "In Suppression File".
// You do not need to add suppressions to this file manually.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", Scope = "namespace", Target = "Sda.Build.Activities")]

View File

@@ -0,0 +1,34 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.Build.Utilities;
using Sda.Build.Tasks;
namespace Sda.Build
{
static class Program
{
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static void Main()
{
//Task kretaDb = new MssqlDBCreate
//{
// DbName = "kreta",
// MssqlScriptDir = @"g:\Kreta\Main\DBScripts\Mssql",
// Password = "Porcica1.",
// UserName = "kreta",
// ServerName = "10.201.199.114",
// //DbConnection = "Data Source=40.127.174.54;Initial Catalog=master;Persist Security Info=False;User ID=kreta;Password=Porcica1.;Pooling=False;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;",
//};
//kretaDb.Execute();
var SolutionRoot = @"c:\Git";
Task t = new DictionaryItem
{
InputFile = $@"{SolutionRoot}\Kreta.DataAccess.Migrations\DBScripts\DictionaryItems.txt",
InputDictionaryXMLFile = $@"{SolutionRoot}\GeneratedDictionaryItems.kres",
ScriptOutputDir = $@"{SolutionRoot}\Kreta.DataAccess.Migrations\DBScripts\Database\dev\",
CSharpOutputDir = $@"{SolutionRoot}\Kreta.Enums\"
};
t.Execute();
}
}
}

View File

@@ -0,0 +1 @@


View File

@@ -0,0 +1,150 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{98EC024C-6439-44B1-8B1E-29E457B2201F}</ProjectGuid>
<ProjectTypeGuids>{32f31d43-81cc-4c15-9de6-3fc5453562b6};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sda.Build</RootNamespace>
<AssemblyName>Sda.Build</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>0</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\Assemblies\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
<DebugSymbols>true</DebugSymbols>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>sn.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<StartupObject>
</StartupObject>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Build|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Build\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="JetBrains.Annotations">
<HintPath>..\packages\JetBrains.Annotations.9.1.1\lib\net20\JetBrains.Annotations.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Build.Framework.16.3.0\lib\net472\Microsoft.Build.Framework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Build.Utilities.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Build.Utilities.Core.16.3.0\lib\net472\Microsoft.Build.Utilities.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.SqlServer.ConnectionInfo, Version=14.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Microsoft.SqlServer.ConnectionInfo.dll</HintPath>
</Reference>
<Reference Include="Microsoft.SqlServer.Management.Sdk.Sfc, Version=14.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Microsoft.SqlServer.Management.Sdk.Sfc.dll</HintPath>
</Reference>
<Reference Include="Microsoft.SqlServer.Smo, Version=14.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Microsoft.SqlServer.Smo.dll</HintPath>
</Reference>
<Reference Include="Microsoft.SqlServer.SmoExtended, Version=14.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Microsoft.SqlServer.SmoExtended.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Setup.Configuration.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Setup.Configuration.Interop.1.16.30\lib\net35\Microsoft.VisualStudio.Setup.Configuration.Interop.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="System" />
<Reference Include="System.Collections.Immutable, Version=1.2.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Program.cs" />
<Compile Include="..\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tasks\MssqlDBCreate.cs" />
<Compile Include="Tasks\DictionaryItem.cs" />
<Compile Include="Tasks\GenerateImf.cs" />
<Compile Include="Tasks\SetEnvVar.cs" />
<Compile Include="Tasks\TaskExtensions.cs" />
<Compile Include="Tasks\UnixLineEnding.cs" />
<Compile Include="Tasks\UpdateIds.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<EmbeddedResource Include="sda.pfx" />
<None Include="sn.snk" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Sda.DictionaryItemEnumGenerator\Sda.DictionaryItemEnumGenerator.csproj">
<Project>{7d3d2200-9954-4cad-bef6-04f4bb129fe6}</Project>
<Name>Sda.DictionaryItemEnumGenerator</Name>
</ProjectReference>
<ProjectReference Include="..\Sda.ModelIdUpdater\Sda.ModelIdUpdater.csproj">
<Project>{bbad0e6b-8c66-4746-83ab-f3807c8e1a8e}</Project>
<Name>Sda.ModelIdUpdater</Name>
</ProjectReference>
<ProjectReference Include="..\Sda.Modeling.Runtime\Sda.Modeling.Runtime.csproj">
<Project>{7fbe4601-cdb1-4081-ab35-7cf1e43099d8}</Project>
<Name>Sda.Modeling.Runtime</Name>
</ProjectReference>
<ProjectReference Include="..\Sda.Modeling.TextTemplating\Sda.Modeling.TextTemplating.csproj">
<Project>{056cd3aa-f544-41e7-81d3-5d30d664a193}</Project>
<Name>Sda.Modeling.TextTemplating</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,68 @@
using System;
using System.IO;
using JetBrains.Annotations;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Sda.DictionaryItemEnumGenerator;
namespace Sda.Build.Tasks
{
/// <summary>
/// Kódtételek generálása.
/// </summary>
/// <remarks>
/// Oracle kliens binárisok legyenek a <c>PATH</c>-ban!
/// </remarks>
public sealed class DictionaryItem : Task
{
/// <summary>
/// Kréta adatbázis script - szótár elemeket felvevő script
/// </summary>
[CanBeNull, Required]
public string ScriptOutputDir { get; set; }
/// <summary>
/// Kódtétel osztályokat listázó fájl.
/// </summary>
[CanBeNull, Required]
public string InputFile { get; set; }
/// <summary>
/// C# alkalmazás-kiszolgáló kimeneti könyvtár.
/// </summary>
[CanBeNull, Required]
public string CSharpOutputDir { get; set; }
/// <summary>
/// A Solutation alatt a GeneratedDictionaryItems.XML fájl.
/// </summary>
[CanBeNull, Required]
public string InputDictionaryXMLFile { get; set; }
public override bool Execute()
{
if (string.IsNullOrEmpty(ScriptOutputDir))
{
return false;
}
if (string.IsNullOrEmpty(InputFile)
||
!File.Exists(InputFile))
{
return false;
}
if (string.IsNullOrEmpty(InputDictionaryXMLFile)
||
!File.Exists(InputDictionaryXMLFile))
{
return false;
}
Generator.Generate(
InputFile,
InputDictionaryXMLFile,
ScriptOutputDir,
Path.Combine(CSharpOutputDir ?? ".", "GeneratedEnums.cs"));
return true;
}
}
}

View File

@@ -0,0 +1,57 @@
using System.Diagnostics;
using System.Linq;
using JetBrains.Annotations;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Sda.Modeling.Runtime;
namespace Sda.Build.Tasks
{
/// <summary>
/// <c>IMF</c> model generálás <c>XMI</c> alapján.
/// </summary>
public sealed class GenerateImf : Task
{
/// <summary>
/// A bemeneti <c>XMI</c> állományok nevei, első legyen a gyökér projekt.
/// </summary>
[CanBeNull, Required]
public ITaskItem[] Inputs { get; set; }
/// <summary>
/// A kimeneti <c>IMF</c> állomány neve.
/// </summary>
[CanBeNull, Required]
public string Output { get; set; }
public override bool Execute()
{
if (string.IsNullOrEmpty(Output))
{
return false;
}
if (Inputs == null)
{
return false;
}
Generator generator = new Generator();
generator.LogMessageHandler += (sender, args) =>
{
switch (args.Type)
{
case TraceEventType.Error:
this.LogError("GenerateImf: {0}", args.Message);
break;
case TraceEventType.Warning:
this.LogWarning("GenerateImf: {0}", args.Message);
break;
default:
this.LogInfo("GenerateImf: {0}", args.Message);
break;
}
};
generator.Run(Output, Inputs.Select(i => i.ItemSpec).ToArray());
return true;
}
}
}

View File

@@ -0,0 +1,426 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
namespace Sda.Build.Tasks
{
//<UsingTask AssemblyFile="$(SolutionRoot)\BuildTools\Sda.Build.dll" TaskName="Sda.Build.Tasks.MssqlDBCreate" />
//<MssqlDBCreate ServerName="fittest" DbName="Kreta" UserName="kreta" Password="kreta" MssqlScriptDir="$(SolutionRoot)\DBScripts\Mssql"/>
public class MssqlDBCreate : Task
{
[Required]
public string ServerName { get; set; }
[Required]
public string DbName { get; set; }
[Required]
public string UserName { get; set; }
[Required]
public string Password { get; set; }
[Required]
public string MssqlScriptDir { get; set; }
public string DbConnection { get; set; }
public string ManualDbName { get; set; }
const string FunctionsDirectoryName = "dbo\\Functions";
const string StoredProceduresDirectoryName = "dbo\\Stored procedures";
const string DevStoredProceduresDirectoryName = "dev";
const string MigrationDirectoryName = "..\\..\\Migrations";
private Server dbServer;
public Server DbServer
{
get
{
if (dbServer == null)
{
if (string.IsNullOrEmpty(DbConnection))
{
var connectionStringBuilder = new SqlConnectionStringBuilder
{
IntegratedSecurity = false,
UserID = UserName,
Password = Password,
DataSource = ServerName
};
DbConnection = connectionStringBuilder.ToString();
}
var connection = new SqlConnection(DbConnection);
LogMessage("ConnectionString: " + DbConnection);
connection.Open();
dbServer = new Server(new ServerConnection(connection));
}
return dbServer;
}
}
private string CreatedDbName { get; set; }
public override bool Execute()
{
try
{
// ha létezik, régi adatbázis eldobása és új létrehozása
bool isNewDb = CreateDatabase();
// ha létezik a DB (vagyis nem változott a verziószám), akkor nem fog új DB-t generálni.
if (isNewDb)
{
// adatbázis séma kialakítása (táblák, indexek, constraintek, tárolt eljárások...)
CreatingDatabaseSchema();
}
}
catch (Exception ex)
{
if (BuildEngine != null)
{
Log.LogErrorFromException(ex);
}
}
return !Log.HasLoggedErrors;
}
/// <summary>
/// Csak akkor dobja el és hozza újra létre a Db-t, ha változott a verziószám.
/// </summary>
/// <returns></returns>
private bool CreateDatabase()
{
if (!string.IsNullOrEmpty(DbConnection))
{
CreatedDbName = DbName;
if (DbServer.Databases[CreatedDbName] != null)
{
LogMessage($"{CreatedDbName} database exists!");
return false;
}
}
else if (string.IsNullOrEmpty(ManualDbName))
{
CreatedDbName = DbName;
if (DbServer.Databases[CreatedDbName] != null)
{
LogMessage($"{CreatedDbName} database exists!");
return false;
}
}
else
{
CreatedDbName = $"{DbName}_{ManualDbName}";
if (DbServer.Databases[CreatedDbName] != null)
{
LogMessage($"Dropping existing {CreatedDbName} on {ServerName} ...");
DbServer.KillAllProcesses(CreatedDbName);
DbServer.Databases[CreatedDbName].Drop();
}
}
LogMessage($"Creating {CreatedDbName} on {ServerName} ...");
var newDb = new Database(DbServer, CreatedDbName)
{
Collation = "Hungarian_CI_AI"
};
newDb.Create();
LogMessage("Done.");
return true;
}
private void CreatingDatabaseSchema()
{
var scriptList = new List<string>();
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "create.schemas.sql", SearchOption.TopDirectoryOnly).ToList());
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "create.schemas.*.sql", SearchOption.TopDirectoryOnly).ToList()); // schémák létrehozása
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "create.tables.sql", SearchOption.TopDirectoryOnly).ToList());
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "create.tables.*.sql", SearchOption.TopDirectoryOnly).ToList()); // táblák létrehozása
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "alter.tables.sql", SearchOption.TopDirectoryOnly).ToList());
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "alter.tables.*.sql", SearchOption.TopDirectoryOnly).ToList()); // táblák módosítása
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "create.comments.sql", SearchOption.TopDirectoryOnly).ToList());
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "create.comments.*.sql", SearchOption.TopDirectoryOnly).ToList()); // táblák, oszlopok descriptionjei
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "create.indexes.sql", SearchOption.TopDirectoryOnly).ToList());
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "create.indexes.*.sql", SearchOption.TopDirectoryOnly).ToList()); // indexek létrehozása
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "create.triggers.sql", SearchOption.TopDirectoryOnly).ToList());
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "create.triggers.*.sql", SearchOption.TopDirectoryOnly).ToList()); // triggerek létrehozása
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "create.data.sql", SearchOption.TopDirectoryOnly).ToList());
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "create.data.*.sql", SearchOption.TopDirectoryOnly).ToList()); // alapadatok beszúrása (insert)
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "create.testdata.sql", SearchOption.TopDirectoryOnly).ToList());
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "create.testdata.*.sql", SearchOption.TopDirectoryOnly).ToList()); // alap tesztadatok beszúrása (insert)
ExecureSqlScripts(scriptList);
CreateDevStoredProcedures();
CreateGlobalStoredProcedures();
scriptList = new List<string>();
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "create.views.sql", SearchOption.TopDirectoryOnly).ToList());
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "create.views.*.sql", SearchOption.TopDirectoryOnly).ToList()); // dbo-s view-k létrehozása
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "create.auditlog.sql", SearchOption.TopDirectoryOnly).ToList());
scriptList.AddRange(Directory.GetFiles(MssqlScriptDir, "create.auditlog.*.sql", SearchOption.TopDirectoryOnly).ToList()); // auditlog létrehozása
ExecureSqlScripts(scriptList);
CreateFunctions();
CreateStoredProcedures();
VersionInfoInsert();
}
private void VersionInfoInsert()
{
string script = "";
LogMessage($"Populate VersionInfo");
var dirs = Directory.GetFiles(Path.Combine(MssqlScriptDir, MigrationDirectoryName, "Archive"), "20*.cs", SearchOption.TopDirectoryOnly).Select(d => Path.GetFileNameWithoutExtension(d)).ToList();
dirs.AddRange(Directory.GetFiles(Path.Combine(MssqlScriptDir, MigrationDirectoryName), "20*.cs", SearchOption.TopDirectoryOnly).Select(d => Path.GetFileNameWithoutExtension(d)).ToList());
int i = 0;
foreach (var dir in dirs)
{
if (i++ == 0)
{
script = "INSERT INTO VersionInfo (Version, AppliedOn, Description) VALUES\n";
script += " (" + dir.Substring(0, 14) + ", GETDATE(), '" + dir.Substring(15) + "')\n";
}
else
{
script += " ,(" + dir.Substring(0, 14) + ", GETDATE(), '" + dir.Substring(15) + "')\n";
}
if (i == 500)
{
i = 0;
try
{
Database db = DbServer.Databases[CreatedDbName];
db.ExecuteNonQuery(script);
}
catch (Exception ex)
{
LogMessage($"Hiba az SQL script futtatása közben: Populate VersionInfo, hibaüzenet: {ex.Message}");
throw new Exception($"Hiba az SQL script futtatása közben: Populate VersionInfo, hibaüzenet: {ex.Message}");
}
}
}
}
private void ExecureSqlScripts(List<String> scriptList)
{
var hasError = false;
foreach (var scriptName in scriptList)
{
try
{
var flieName = Path.GetFileName(scriptName);
LogMessage($"Executing script {flieName} ...");
ExecuteScript(scriptName);
}
catch (Exception ex)
{
LogMessage($"Hiba az SQL script futtatása közben: {scriptName}, hibaüzenet: {ex.Message}");
throw new Exception($"Hiba az SQL script futtatása közben: {scriptName}, hibaüzenet: {ex.Message}");
}
}
if (hasError)
{
throw new Exception("Hibás SQL script!");
}
}
private void CreateGlobalStoredProcedures()
{
LogMessage("Creating global stored procedures ...");
var hasError = false;
var storedProcedureFiles = Directory.GetFiles(MssqlScriptDir, "sp_Global_*.sql", SearchOption.TopDirectoryOnly);
foreach (var storedProcedureFile in storedProcedureFiles)
{
try
{
ExecuteScript(storedProcedureFile);
}
catch (Exception ex)
{
LogMessage($"Hibás tárolt eljárás: {storedProcedureFile}, hibaüzenet: {ex.Message}");
hasError = true;
}
}
if (hasError)
{
throw new Exception("Hibás tárolt eljárások!");
}
LogMessage("Done.");
}
private void CreateStoredProcedures()
{
LogMessage("Creating stored procedures ...");
var hasError = false;
var storedProcedureFiles = Directory.GetFiles(Path.Combine(MssqlScriptDir, StoredProceduresDirectoryName), "*.sql", SearchOption.AllDirectories);
foreach (var storedProcedureFile in storedProcedureFiles)
{
try
{
ExecuteScript(storedProcedureFile);
}
catch (Exception ex)
{
LogMessage($"Hibás tárolt eljárás: {storedProcedureFile}, hibaüzenet: {ex.Message}");
hasError = true;
}
}
if (hasError)
{
throw new Exception("Hibás tárolt eljárások!");
}
LogMessage("Done.");
}
private void CreateDevStoredProcedures()
{
LogMessage("Creating dev schema stored procedures and functions ...");
var hasError = false;
var storedProcedureFiles = Directory.GetFiles(Path.Combine(MssqlScriptDir, DevStoredProceduresDirectoryName), "*.sql", SearchOption.AllDirectories);
foreach (var storedProcedureFile in storedProcedureFiles)
{
try
{
ExecuteScript(storedProcedureFile);
}
catch (Exception ex)
{
LogMessage($"Hibás tárolt eljárás: {storedProcedureFile}, hibaüzenet: {ex.Message}");
hasError = true;
}
}
if (hasError)
{
throw new Exception("Hibás tárolt eljárások!");
}
LogMessage("Done.");
}
private void CreateFunctions()
{
LogMessage("Creating functions ...");
var hasError = false;
string functionPath;
string line;
functionPath = Path.Combine(MssqlScriptDir, FunctionsDirectoryName);
using (var reader = new StreamReader(Path.Combine(functionPath, "FunctionOrder.txt"), Encoding.UTF8))
{
while ((line = reader.ReadLine()) != null)
{
try
{
LogMessage($"Creating sorted functions ... {line}");
ExecuteScript(Path.Combine(functionPath, line));
}
catch (Exception ex)
{
LogMessage($"Hibás függvény: {line}, hibaüzenet: {ex.Message}");
hasError = true;
}
}
}
var functionFiles = Directory.GetFiles(functionPath, "*.sql", SearchOption.AllDirectories);
foreach (var functionFile in functionFiles)
{
try
{
ExecuteScript(functionFile);
}
catch (Exception ex)
{
LogMessage($"Hibás függvény: {functionFile}, hibaüzenet: {ex.Message}");
hasError = true;
}
}
if (hasError)
{
throw new Exception("Hibás függvények!");
}
LogMessage("Done.");
}
private void ExecuteScript(string scriptPath)
{
string script;
using (var reader = new StreamReader(scriptPath, Encoding.UTF8))
{
script = reader.ReadToEnd();
}
Database db = DbServer.Databases[CreatedDbName];
db.ExecuteNonQuery(script);
}
private void LogMessage(string message)
{
LogMessage(MessageImportance.High, message);
}
private void LogMessage(MessageImportance importance, string message)
{
if (BuildEngine != null)
{
Log.LogMessage(importance, message);
}
}
}
}

View File

@@ -0,0 +1,52 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using JetBrains.Annotations;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Sda.Build.Tasks
{
/// <summary>
/// <c>DOS</c> környezeti változó deklarálás.
/// </summary>
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Env")]
public sealed class SetEnvVar : Task
{
/// <summary>
/// A környezeti változó neve.
/// </summary>
[CanBeNull, Required]
public string Variable { get; set; }
/// <summary>
/// A korábbi értékhez karakteres hozzáfűzés történjen, pl. <c>%PATH%</c> esetén hasznos.
/// </summary>
public bool Append { get; set; }
/// <summary>
/// Környezeti változó értéke.
/// </summary>
[CanBeNull, Required]
public string Value { get; set; }
public override bool Execute()
{
if (Variable == null)
{
return false;
}
if (Append)
{
StringBuilder sb = new StringBuilder(Environment.GetEnvironmentVariable(Variable) ?? "");
sb.Append(Value);
Environment.SetEnvironmentVariable(Variable, sb.ToString());
}
else
{
Environment.SetEnvironmentVariable(Variable, Value);
}
return true;
}
}
}

View File

@@ -0,0 +1,116 @@
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using JetBrains.Annotations;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Sda.Build.Tasks
{
static class TaskExtensions
{
static readonly TraceSource _trace = new TraceSource("TaskLog", SourceLevels.Off);
static bool CheckLog([NotNull] Task task)
{
// ReSharper disable once InvocationIsSkipped
Contract.Requires(task != null);
return
task.HostObject != null
||
task.BuildEngine != null
||
task.BuildEngine2 != null
||
task.BuildEngine3 != null
||
task.BuildEngine4 != null;
}
[StringFormatMethod("message")]
public static void LogHigh([NotNull] this Task task, [NotNull] string message, [CanBeNull] params object[] args)
{
if (task == null)
throw new ArgumentNullException("task");
if (message == null)
throw new ArgumentNullException("message");
if (CheckLog(task))
{
task.Log.LogMessage(MessageImportance.High, message.Replace("\r", ""), args);
}
else
{
_trace.TraceEvent(TraceEventType.Warning, 0, message, args ?? new object[0]);
}
}
[StringFormatMethod("message")]
public static void LogInfo([NotNull] this Task task, [NotNull] string message, [CanBeNull] params object[] args)
{
if (task == null)
throw new ArgumentNullException("task");
if (message == null)
throw new ArgumentNullException("message");
if (CheckLog(task))
{
task.Log.LogMessage(MessageImportance.Normal, message.Replace("\r", ""), args);
}
else
{
_trace.TraceEvent(TraceEventType.Information, 0, message, args ?? new object[0]);
}
}
[StringFormatMethod("message")]
public static void LogWarning([NotNull] this Task task, [NotNull] string message, [CanBeNull] params object[] args)
{
if (task == null)
throw new ArgumentNullException("task");
if (message == null)
throw new ArgumentNullException("message");
if (CheckLog(task))
{
task.Log.LogWarning(message.Replace("\r", ""), args);
}
else
{
_trace.TraceEvent(TraceEventType.Warning, 0, message, args ?? new object[0]);
}
}
[StringFormatMethod("message")]
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static void LogError([NotNull] this Task task, [NotNull] string message, [CanBeNull] params object[] args)
{
if (task == null)
throw new ArgumentNullException("task");
if (message == null)
throw new ArgumentNullException("message");
if (CheckLog(task))
{
task.Log.LogError(message.Replace("\r", ""), args);
}
else
{
_trace.TraceEvent(TraceEventType.Error, 0, message, args ?? new object[0]);
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static void LogError([NotNull] this Task task, [NotNull] Exception exception)
{
if (task == null)
throw new ArgumentNullException("task");
if (exception == null)
throw new ArgumentNullException("exception");
LogError(task, exception.ToString());
}
}
}

View File

@@ -0,0 +1,52 @@
using System;
using System.IO;
using System.Linq;
using JetBrains.Annotations;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Sda.Build.Tasks
{
public sealed class UnixLineEnding : Task
{
/// <summary>
/// Kréta adatbázis script - szótár elemeket felvevő script
/// </summary>
[CanBeNull, Required]
public string DataAccessorsPath { get; set; }
/// <summary>
/// Kódtétel osztályokat listázó fájl.
/// </summary>
[CanBeNull, Required]
public string EntitiesPath { get; set; }
/// <summary>
/// C# alkalmazás-kiszolgáló kimeneti könyvtár.
/// </summary>
[CanBeNull, Required]
public string InterfacesPath { get; set; }
public override bool Execute()
{
if (string.IsNullOrEmpty(DataAccessorsPath) || string.IsNullOrEmpty(EntitiesPath) || string.IsNullOrEmpty(InterfacesPath))
{
return false;
}
if (!Directory.Exists(DataAccessorsPath) || !Directory.Exists(EntitiesPath) || !Directory.Exists(InterfacesPath))
{
return false;
}
var files = Directory.GetFiles(DataAccessorsPath, "*.cs").ToList();
files.AddRange(Directory.GetFiles(EntitiesPath, "*.cs"));
files.AddRange(Directory.GetFiles(InterfacesPath, "*.cs"));
foreach (var file in files)
{
var content = File.ReadAllBytes(file);
var newContent = Array.FindAll(content, c => c != 0x0d);
File.WriteAllBytes(file, newContent);
}
return true;
}
}
}

View File

@@ -0,0 +1,63 @@
using System;
using System.Diagnostics;
using System.Linq;
using JetBrains.Annotations;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Sda.ModelIdUpdater;
namespace Sda.Build.Tasks
{
/// <summary>
/// Kiegészít egy <c>XMI</c> modellt úgy, hogy minden elemnek egyedi <c>ID</c>-ja legyen.
/// </summary>
public sealed class UpdateIds : Task
{
/// <summary>
/// A módosítandó <c>XML</c> modell állomány neve.
/// </summary>
[CanBeNull, Required]
public string Input { get; set; }
[CanBeNull]
public ITaskItem[] Packages { get; set; }
public override bool Execute()
{
Updater updater = new Updater();
updater.LogMessageHandler += (sender, e) =>
{
if (e == null
||
string.IsNullOrWhiteSpace(e.Message))
{
return;
}
if (Packages != null
&&
Packages.Length > 0
&&
!string.IsNullOrWhiteSpace(e.Package)
&&
!Packages.Any(p => string.Equals(p.ItemSpec, e.Package, StringComparison.OrdinalIgnoreCase)))
{
return;
}
switch (e.EventType)
{
case TraceEventType.Error:
this.LogError(e.Message);
break;
case TraceEventType.Warning:
this.LogWarning(e.Message);
break;
default:
this.LogInfo(e.Message);
break;
}
};
updater.UpdateIds(Input);
return true;
}
}
}

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="JetBrains.Annotations" version="9.1.1" targetFramework="net45" />
<package id="Microsoft.Build.Framework" version="16.3.0" targetFramework="net48" />
<package id="Microsoft.Build.Utilities.Core" version="16.3.0" targetFramework="net48" />
<package id="Microsoft.VisualStudio.Setup.Configuration.Interop" version="1.16.30" targetFramework="net48" developmentDependency="true" />
<package id="System.Collections.Immutable" version="1.5.0" targetFramework="net48" />
</packages>

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,766 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using JetBrains.Annotations;
namespace Sda.DictionaryItemEnumGenerator
{
public class DictionaryItemGroup
{
public DictionaryItemGroup()
{
Items = new List<DictionaryItem>();
}
public int Id { get; set; }
public string TableName { get; set; }
public string Code { get; set; }
//public int ResourceId { get; set; }
public bool CustomItemAllowed { get; set; }
public bool ColorEditable { get; set; }
public string Name { get; set; }
public string Name1 { get; set; }
public string Name2 { get; set; }
public string Name3 { get; set; }
public string Name4 { get; set; }
public List<DictionaryItem> Items { get; set; }
}
public class DictionaryItem
{
public int Id { get; set; }
public string EnumName { get; set; }
public List<DictionaryItemValue> DictionaryItemValues { get; set; } = new List<DictionaryItemValue>();
}
public class DictionaryItemValue
{
public string EnvironmentName { get; set; }
//public int StringResourcesId { get; set; }
/// <summary>
/// Magyar
/// </summary>
public string Name { get; set; }
/// <summary>
/// Angol
/// </summary>
public string Name1 { get; set; }
public string Name2 { get; set; }
public string Name3 { get; set; }
public string Name4 { get; set; }
public bool Protected { get; set; }
public bool Visible { get; set; }
public int? Order { get; set; }
public string Code { get; set; }
public int? Value { get; set; }
public string Color { get; set; }
}
public class DictionaryItemGroupUtils
{
public List<DictionaryItemGroup> itemGroups { get; set; }
#region Load
/// <summary>
/// A TXT és XML fájl adatok összefésülése.
/// </summary>
/// <param name="idc"></param>
public void Load(InputDataCollection idc, List<DictionaryItemGroup> xmlData)
{
itemGroups = new List<DictionaryItemGroup>();
for (int index = 0; index < idc.Count; index++)
{
var umlDictionaryItem = idc[index];
// megkeresem hozzá az XML adatokat
var xmlDataItem = xmlData.Where(d => d.Code == umlDictionaryItem.DictionaryItemGroupName).SingleOrDefault();
if (xmlDataItem != null)
{
xmlDataItem.TableName = umlDictionaryItem.TableName;
itemGroups.Add(xmlDataItem);
}
//else
// throw new ArgumentNullException(string.Format("{0} "));
}
}
#endregion
#region Save
public void SaveCSharp([NotNull] string outputFile)
{
if (string.IsNullOrEmpty(outputFile))
throw new ArgumentNullException(nameof(outputFile));
if (itemGroups == null || itemGroups.Count == 0)
throw new ArgumentNullException(nameof(itemGroups));
string adatszotarTipusEnumOutputFile = outputFile.Replace("GeneratedEnums.cs", @"GeneratedAdatszotarTipusEnum.cs");
var file = new StringBuilder().AppendFormat(
@"//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
{0}",
GenerateEnums());
using (StreamWriter writer = new StreamWriter(Path.Combine(Path.GetDirectoryName(outputFile), "GeneratedEnums.cs"), false, Encoding.UTF8))
{
writer.Write(Regex.Replace(file.ToString(), "((?<!\r)\n|\r(?!\n))", "\r\n"));
}
file = new StringBuilder().AppendFormat(
@"//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
{0}",
GenerateAdatszotarEnum());
using (StreamWriter writer = new StreamWriter(Path.Combine(Path.GetDirectoryName(adatszotarTipusEnumOutputFile), "GeneratedAdatszotarTipusEnum.cs"), false, Encoding.UTF8))
{
writer.Write(Regex.Replace(file.ToString(), "((?<!\r)\n|\r(?!\n))", "\r\n"));
}
}
#endregion
#region Generate
[NotNull]
string GenerateEnums()
{
StringBuilder builder = new StringBuilder();
string nsp = "";
foreach (DictionaryItemGroup group in this.itemGroups)
{
builder.Append(GenerateEnumWithNameSpace(group, ref nsp));
}
if (builder.Length > 0)
{
builder.Append(@"
}
");
}
return builder.ToString();
}
[NotNull]
string GenerateAdatszotarEnum()
{
string nsp = "Kreta.Enums";
string header = "public enum GeneratedAdatszotarTipusEnum";
var body = new StringBuilder();
int valueIndex = 1;
foreach (DictionaryItemGroup group in this.itemGroups.OrderBy(x => x.Id))
{
var lastLine = valueIndex == this.itemGroups.Count;
body.AppendFormat(
"{0}\r\n", GenerateAdatszotarEnumLine(group, valueIndex, lastLine));
valueIndex++;
}
return string.Format(@"
namespace {0}
{{
{1}
{{{2}
}}
}}
",
nsp,
header,
body);
}
[NotNull]
string GenerateEnumWithNameSpace([NotNull] DictionaryItemGroup group, [CanBeNull] ref string nsp)
{
string str = GenerateEnum(group);
string ns = "Kreta.Enums";
if (string.IsNullOrEmpty(nsp))
{
nsp = ns;
return string.Format(@"
namespace {0}
{{{1}",
ns,
str);
}
if (ns == nsp)
{
return string.Format(@"
{0}",
str);
}
nsp = ns;
return string.Format(@"
}}
namespace {0}
{{{1}",
ns,
str);
}
[NotNull]
string GenerateEnum([NotNull] DictionaryItemGroup group)
{
string comment = string.Format(@"
/// <summary>
/// <entity>{0}</entity>
/// <description>{1}</description>
/// <tablename>{2}</tablename>
/// <protected>{3}</protected>
/// </summary>",
(group.Code ?? "").Trim(),
string.IsNullOrWhiteSpace(group.Name) ? "Nincs leírás." : (group.Name ?? "").Trim(),
(group.TableName ?? "").Trim(), !group.CustomItemAllowed ? "Igen" : "Nem");
string header = string.Format(
"\tpublic enum {0}Enum",
group.Code.ToBase26String());
var body = new StringBuilder();
int valueIndex = 1;
foreach (var itemValue in group.Items)
{
var lastLine = valueIndex == group.Items.Count;
body.AppendFormat(
"{0}\r\n", GenerateEnumLine(itemValue, valueIndex, lastLine));
valueIndex++;
}
return string.Format(
"{0}\r\n\t{1}\r\n\t{{{2}\t}}",
comment,
header,
body);
}
#endregion
#region Generate line
[NotNull]
string GenerateEnumLine(DictionaryItem item, int valueIndex, bool LastItem)
{
string comment = string.Format(
"Name: {0}",
item.DictionaryItemValues.First(x => x.EnvironmentName == "Default").Name);
string comma = "";
if (!LastItem)
{
comma = ",";
}
return string.Format(@"
/// <summary>
/// {0}
/// </summary>
{1} = {2}{3}",
comment,
item.EnumName.ToBase26String(),
item.Id,
comma);
}
[NotNull]
string GenerateAdatszotarEnumLine(DictionaryItemGroup group, int valueIndex, bool LastItem)
{
string comma = "";
if (!LastItem)
{
comma = ",";
}
return string.Format(@"
{0} = {1}{2}",
group.Code.ToBase26String(),
group.Id,
comma);
}
#endregion
#region Generate Scripts
public void GenerateDBScripts([NotNull] string outputScriptPath)
{
if (string.IsNullOrEmpty(outputScriptPath))
throw new ArgumentNullException(nameof(outputScriptPath));
if (itemGroups == null || itemGroups.Count == 0)
throw new ArgumentNullException(nameof(itemGroups));
var file = GetDBScripts();
using (StreamWriter writer = new StreamWriter(Path.Combine(Path.GetDirectoryName(outputScriptPath), "uspCreateDictionaryItems.sql"), false, Encoding.UTF8))
{
writer.Write(Regex.Replace(file.ToString(), "((?<!\r)\n|\r(?!\n))", "\r\n"));
}
}
private string GetDBScripts()
{
string KK_EnvironmentName = "KK";
string NSZFH_EnvironmentName = "NSZFH";
string HOI_EnvironmentName = "HOI";
string AZURE_EnvironmentName = "AZURE";
string Default_EnvironmentName = "Default";
StringBuilder script = new StringBuilder(@"
-- =============================================
-- Description: Szótár elemeket létrehozó script
-- =============================================
DROP PROCEDURE IF EXISTS [dev].uspCreateDictionaryItems
GO
CREATE PROCEDURE [dev].uspCreateDictionaryItems
@IntezmenyId int = NULL,
@pTanevNev nvarchar(10) = NULL
AS
BEGIN
SET NOCOUNT ON;
DECLARE @EnvironmentName nvarchar(1000), @LastTanevSorszam int
SET @EnvironmentName = (SELECT [Value] FROM dev.EnvironmentInfo WHERE [Key] = 'Dictionary')
IF (@EnvironmentName IS NULL OR @EnvironmentName NOT IN ('KK','NSZFH','HOI','AZURE'))
BEGIN INSERT INTO T_DICTIONARYITEMBASE (C_VALUE) VALUES ('Nincs Dictionary ertek a dev.EnvironmentInfo tablaban') END -- elszall a migracio ha nincs
SET @LastTanevSorszam = (SELECT MAX(C_SORSZAM) FROM T_TANEV WHERE TOROLT = 'F' AND (C_KOVETKEZO = 'T' OR C_AKTIV = 'T') AND @IntezmenyId IS NULL OR C_INTEZMENYID = @IntezmenyId)
DROP TABLE IF EXISTS #Tanevek
CREATE TABLE #Tanevek (IntezmenyId int, TanevId int)
IF @IntezmenyId IS NULL BEGIN
INSERT INTO #Tanevek (IntezmenyId, TanevId)
SELECT
i.ID
,t.ID
FROM T_INTEZMENY i
INNER JOIN T_TANEV t ON t.C_INTEZMENYID = i.ID
AND C_SORSZAM <= @LastTanevSorszam
AND (@pTanevNev IS NULL OR t.C_NEV = @pTanevNev)
WHERE i.C_ISARCHIV = 'F'
END
ELSE BEGIN
INSERT INTO #Tanevek (IntezmenyId, TanevId)
SELECT
i.ID
,t.ID
FROM T_INTEZMENY i
INNER JOIN T_TANEV t ON t.C_INTEZMENYID = i.ID
AND t.C_INTEZMENYID = i.ID
AND C_SORSZAM <= @LastTanevSorszam
AND (@pTanevNev IS NULL OR t.C_NEV = @pTanevNev)
WHERE i.ID = @IntezmenyId
AND i.C_ISARCHIV = 'F'
END
DROP TABLE IF EXISTS #DICTIONARYTYPE
CREATE TABLE #DICTIONARYTYPE(
ID INT PRIMARY KEY
,C_CODENAME NVARCHAR(255) INDEX IX_CODENAME NONCLUSTERED
,C_NAME NVARCHAR(255)
,C_ISCUSTOMITEMALLOWED NVARCHAR(1)
,C_ISCOLOREDITABLE NVARCHAR(1)
,C_DESCRIPTION NVARCHAR(255)
)
DROP TABLE IF EXISTS #DICTIONARYITEMBASE
CREATE TABLE #DICTIONARYITEMBASE (
ID INT not null PRIMARY KEY
,C_NAME NVARCHAR(250) not null
,C_NAME_1 NVARCHAR(250) null
,C_NAME_2 NVARCHAR(250) null
,C_NAME_3 NVARCHAR(250) null
,C_NAME_4 NVARCHAR(250) null
,C_TYPE NVARCHAR(32) not null INDEX IX_TYPE NONCLUSTERED
,C_DICTIONARYTYPEID INT not null
,C_PROTECTED CHAR(1) null
,C_VISIBLE CHAR(1) not null
,C_ORDER INT null
,C_CODE NVARCHAR(20) null
,C_VALUE INT null
,C_COLOR NVARCHAR(6) null
)
-- DictionaryType elemek
INSERT INTO #DICTIONARYTYPE (ID, C_CODENAME, C_NAME, C_ISCUSTOMITEMALLOWED, C_ISCOLOREDITABLE, C_DESCRIPTION)
VALUES");
foreach (var itemGroup in itemGroups)
{
script.AppendFormat(@"
({0}, N'{1}', N'{2}', '{3}', '{4}', N'{5}'),",
itemGroup.Id,
itemGroup.Code,
itemGroup.Name,
itemGroup.CustomItemAllowed ? "T" : "F",
itemGroup.ColorEditable ? "T" : "F",
"NULL");
}
script.Remove(script.Length - 1, 1);
script.Append(@"
SET IDENTITY_INSERT T_DICTIONARYTYPE ON
INSERT INTO T_DICTIONARYTYPE (ID, C_CODENAME, C_NAME, C_ISCUSTOMITEMALLOWED, C_ISCOLOREDITABLE, C_DESCRIPTION, C_INTEZMENYID, C_TANEVID)
SELECT
ID
,C_CODENAME
,C_NAME
,C_ISCUSTOMITEMALLOWED
,C_ISCOLOREDITABLE
,C_DESCRIPTION
,tn.IntezmenyId AS C_INTEZMENYID
,tn.TanevId AS C_TANEVID
FROM #DICTIONARYTYPE tdt
CROSS JOIN #Tanevek tn
WHERE NOT EXISTS (SELECT 1 FROM dbo.T_DICTIONARYTYPE dt WHERE dt.ID = tdt.ID AND dt.C_INTEZMENYID = tn.IntezmenyId AND dt.C_TANEVID = tn.TanevId)
SET IDENTITY_INSERT T_DICTIONARYTYPE OFF
-- DictionaryItemBase elemek
");
if (itemGroups.Exists(x => x.Items.Exists(y => y.DictionaryItemValues.Exists(z => z.EnvironmentName == KK_EnvironmentName))))
{
script.Append(@"
-- A '" + KK_EnvironmentName + @"' sajatos elemek kezdete
IF (@EnvironmentName IS NOT NULL AND @EnvironmentName = '" + KK_EnvironmentName + @"')
BEGIN
");
int index = 0;
foreach (var itemGroup in itemGroups)
{
var order = 1;
foreach (var item in itemGroup.Items)
{
foreach (var value in item.DictionaryItemValues.Where(x => x.EnvironmentName == KK_EnvironmentName))
{
if ((index % 900) == 0)
{
script.Remove(script.Length - 1, 1);
script.Append(@"
INSERT INTO #DICTIONARYITEMBASE (ID, C_NAME, C_NAME_1, C_NAME_2, C_NAME_3, C_NAME_4, C_TYPE, C_DICTIONARYTYPEID, C_PROTECTED, C_VISIBLE, C_ORDER, C_CODE, C_VALUE, C_COLOR)
VALUES");
}
script.AppendFormat(@"
({0}, N'{1}', {2}, {3}, {4}, {5}, N'{6}', {7}, N'{8}', N'{9}', {10}, {11}, {12}, {13}),",
item.Id,
value.Name,
string.IsNullOrEmpty(value.Name1) == false ? "N'" + value.Name1 + "'" : "NULL",
string.IsNullOrEmpty(value.Name2) == false ? "N'" + value.Name2 + "'" : "NULL",
string.IsNullOrEmpty(value.Name3) == false ? "N'" + value.Name3 + "'" : "NULL",
string.IsNullOrEmpty(value.Name4) == false ? "N'" + value.Name4 + "'" : "NULL",
itemGroup.Code,
itemGroup.Id,
value.Protected ? "T" : "F",
value.Visible ? "T" : "F",
value.Order ?? order,
string.IsNullOrEmpty(value.Code) == false ? "N'" + value.Code + "'" : "NULL",
value.Value ?? order,
string.IsNullOrEmpty(value.Color) == false ? "N'" + value.Color + "'" : "NULL");
order++;
index++;
}
}
}
script.Remove(script.Length - 1, 1);
script.AppendLine(@"
END
-- A '" + KK_EnvironmentName + @"' sajatos elemek vege");
}
if (itemGroups.Exists(x => x.Items.Exists(y => y.DictionaryItemValues.Exists(z => z.EnvironmentName == NSZFH_EnvironmentName))))
{
script.Append(@"
-- A '" + NSZFH_EnvironmentName + @"' sajatos elemek kezdete
IF (@EnvironmentName IS NOT NULL AND @EnvironmentName = '" + NSZFH_EnvironmentName + @"')
BEGIN
");
int index = 0;
foreach (var itemGroup in itemGroups)
{
var order = 1;
foreach (var item in itemGroup.Items)
{
foreach (var value in item.DictionaryItemValues.Where(x => x.EnvironmentName == NSZFH_EnvironmentName))
{
if ((index % 900) == 0)
{
script.Remove(script.Length - 1, 1);
script.Append(@"
INSERT INTO #DICTIONARYITEMBASE (ID, C_NAME, C_NAME_1, C_NAME_2, C_NAME_3, C_NAME_4, C_TYPE, C_DICTIONARYTYPEID, C_PROTECTED, C_VISIBLE, C_ORDER, C_CODE, C_VALUE, C_COLOR)
VALUES");
}
script.AppendFormat(@"
({0}, N'{1}', {2}, {3}, {4}, {5}, N'{6}', {7}, N'{8}', N'{9}', {10}, {11}, {12}, {13}),",
item.Id,
value.Name,
string.IsNullOrEmpty(value.Name1) == false ? "N'" + value.Name1 + "'" : "NULL",
string.IsNullOrEmpty(value.Name2) == false ? "N'" + value.Name2 + "'" : "NULL",
string.IsNullOrEmpty(value.Name3) == false ? "N'" + value.Name3 + "'" : "NULL",
string.IsNullOrEmpty(value.Name4) == false ? "N'" + value.Name4 + "'" : "NULL",
itemGroup.Code,
itemGroup.Id,
value.Protected ? "T" : "F",
value.Visible ? "T" : "F",
value.Order ?? order,
string.IsNullOrEmpty(value.Code) == false ? "N'" + value.Code + "'" : "NULL",
value.Value ?? order,
string.IsNullOrEmpty(value.Color) == false ? "N'" + value.Color + "'" : "NULL");
order++;
index++;
}
}
}
script.Remove(script.Length - 1, 1);
script.AppendLine(@"
END
-- A '" + NSZFH_EnvironmentName + @"' sajatos elemek vege");
}
if (itemGroups.Exists(x => x.Items.Exists(y => y.DictionaryItemValues.Exists(z => z.EnvironmentName == HOI_EnvironmentName))))
{
script.Append(@"
-- A '" + HOI_EnvironmentName + @"' sajatos elemek kezdete
IF (@EnvironmentName IS NOT NULL AND @EnvironmentName = '" + HOI_EnvironmentName + @"')
BEGIN
");
int index = 0;
foreach (var itemGroup in itemGroups)
{
var order = 1;
foreach (var item in itemGroup.Items)
{
foreach (var value in item.DictionaryItemValues.Where(x => x.EnvironmentName == HOI_EnvironmentName))
{
if ((index % 900) == 0)
{
script.Remove(script.Length - 1, 1);
script.Append(@"
INSERT INTO #DICTIONARYITEMBASE (ID, C_NAME, C_NAME_1, C_NAME_2, C_NAME_3, C_NAME_4, C_TYPE, C_DICTIONARYTYPEID, C_PROTECTED, C_VISIBLE, C_ORDER, C_CODE, C_VALUE, C_COLOR)
VALUES");
}
script.AppendFormat(@"
({0}, N'{1}', {2}, {3}, {4}, {5}, N'{6}', {7}, N'{8}', N'{9}', {10}, {11}, {12}, {13}),",
item.Id,
value.Name,
string.IsNullOrEmpty(value.Name1) == false ? "N'" + value.Name1 + "'" : "NULL",
string.IsNullOrEmpty(value.Name2) == false ? "N'" + value.Name2 + "'" : "NULL",
string.IsNullOrEmpty(value.Name3) == false ? "N'" + value.Name3 + "'" : "NULL",
string.IsNullOrEmpty(value.Name4) == false ? "N'" + value.Name4 + "'" : "NULL",
itemGroup.Code,
itemGroup.Id,
value.Protected ? "T" : "F",
value.Visible ? "T" : "F",
value.Order ?? order,
string.IsNullOrEmpty(value.Code) == false ? "N'" + value.Code + "'" : "NULL",
value.Value ?? order,
string.IsNullOrEmpty(value.Color) == false ? "N'" + value.Color + "'" : "NULL");
order++;
index++;
}
}
}
script.Remove(script.Length - 1, 1);
script.AppendLine(@"
END
-- A '" + HOI_EnvironmentName + @"' sajatos elemek vege");
}
if (itemGroups.Exists(x => x.Items.Exists(y => y.DictionaryItemValues.Exists(z => z.EnvironmentName == AZURE_EnvironmentName))))
{
script.Append(@"
-- A '" + AZURE_EnvironmentName + @"' sajatos elemek kezdete
IF (@EnvironmentName IS NOT NULL AND @EnvironmentName = 'AZURE')
BEGIN
");
int index = 0;
foreach (var itemGroup in itemGroups)
{
var order = 1;
foreach (var item in itemGroup.Items)
{
foreach (var value in item.DictionaryItemValues.Where(x => x.EnvironmentName == AZURE_EnvironmentName))
{
if ((index % 900) == 0)
{
script.Remove(script.Length - 1, 1);
script.Append(@"
INSERT INTO #DICTIONARYITEMBASE (ID, C_NAME, C_NAME_1, C_NAME_2, C_NAME_3, C_NAME_4, C_TYPE, C_DICTIONARYTYPEID, C_PROTECTED, C_VISIBLE, C_ORDER, C_CODE, C_VALUE, C_COLOR)
VALUES");
}
script.AppendFormat(@"
({0}, N'{1}', {2}, {3}, {4}, {5}, N'{6}', {7}, N'{8}', N'{9}', {10}, {11}, {12}, {13}),",
item.Id,
value.Name,
string.IsNullOrEmpty(value.Name1) == false ? "N'" + value.Name1 + "'" : "NULL",
string.IsNullOrEmpty(value.Name2) == false ? "N'" + value.Name2 + "'" : "NULL",
string.IsNullOrEmpty(value.Name3) == false ? "N'" + value.Name3 + "'" : "NULL",
string.IsNullOrEmpty(value.Name4) == false ? "N'" + value.Name4 + "'" : "NULL",
itemGroup.Code,
itemGroup.Id,
value.Protected ? "T" : "F",
value.Visible ? "T" : "F",
value.Order ?? order,
string.IsNullOrEmpty(value.Code) == false ? "N'" + value.Code + "'" : "NULL",
value.Value ?? order,
string.IsNullOrEmpty(value.Color) == false ? "N'" + value.Color + "'" : "NULL");
order++;
index++;
}
}
}
script.Remove(script.Length - 1, 1);
script.AppendLine(@"
END
-- A '" + AZURE_EnvironmentName + @"' sajatos elemek vege");
}
script.Append(@"
-- A '" + Default_EnvironmentName + @"' elemek kezdete ");
int indexdefault = 0;
foreach (var itemGroup in itemGroups)
{
var order = 1;
foreach (var item in itemGroup.Items)
{
foreach (var value in item.DictionaryItemValues.Where(x => x.EnvironmentName == Default_EnvironmentName))
{
if ((indexdefault % 900) == 0)
{
script.Remove(script.Length - 1, 1);
script.Append(@"
INSERT INTO #DICTIONARYITEMBASE (ID, C_NAME, C_NAME_1, C_NAME_2, C_NAME_3, C_NAME_4, C_TYPE, C_DICTIONARYTYPEID, C_PROTECTED, C_VISIBLE, C_ORDER, C_CODE, C_VALUE, C_COLOR)
SELECT * FROM ( VALUES");
}
script.AppendFormat(@"
({0}, N'{1}', {2}, {3}, {4}, {5}, N'{6}', {7}, N'{8}', N'{9}', {10}, {11}, {12}, {13}),",
item.Id,
value.Name,
string.IsNullOrEmpty(value.Name1) == false ? "N'" + value.Name1 + "'" : "NULL",
string.IsNullOrEmpty(value.Name2) == false ? "N'" + value.Name2 + "'" : "NULL",
string.IsNullOrEmpty(value.Name3) == false ? "N'" + value.Name3 + "'" : "NULL",
string.IsNullOrEmpty(value.Name4) == false ? "N'" + value.Name4 + "'" : "NULL",
itemGroup.Code,
itemGroup.Id,
value.Protected ? "T" : "F",
value.Visible ? "T" : "F",
value.Order ?? order,
string.IsNullOrEmpty(value.Code) == false ? "N'" + value.Code + "'" : "NULL",
value.Value ?? order,
string.IsNullOrEmpty(value.Color) == false ? "N'" + value.Color + "'" : "NULL");
if ((((indexdefault + 1) % 900) == 0) || (indexdefault + 1) == itemGroups.SelectMany(x => x.Items).SelectMany(x => x.DictionaryItemValues).Count(z => z.EnvironmentName == Default_EnvironmentName))
{
script.Remove(script.Length - 1, 1);
script.AppendLine(@"
) x (ID, C_NAME, C_NAME_1, C_NAME_2, C_NAME_3, C_NAME_4, C_TYPE, C_DICTIONARYTYPEID, C_PROTECTED, C_VISIBLE, C_ORDER, C_CODE, C_VALUE, C_COLOR)
WHERE NOT EXISTS (SELECT 1 FROM #DICTIONARYITEMBASE d WHERE x.ID = d.ID)
");
}
order++;
indexdefault++;
}
}
}
script.AppendLine(@"
-- A '" + Default_EnvironmentName + @"' elemek vege
");
script.AppendLine(@"
SET IDENTITY_INSERT [dbo].[T_DICTIONARYITEMBASE] ON
INSERT INTO dbo.T_DICTIONARYITEMBASE (ID, C_NAME, C_NAME_1, C_NAME_2, C_NAME_3, C_NAME_4, C_TYPE, C_DICTIONARYTYPEID, C_PROTECTED, C_VISIBLE, C_ORDER, C_CODE, C_VALUE, C_COLOR, C_INTEZMENYID, C_TANEVID, TOROLT, SERIAL, LASTCHANGED, CREATED, MODIFIER, CREATOR, ELOZOTANEVIREKORDID)
SELECT tdib.ID, tdib.C_NAME, tdib.C_NAME_1, tdib.C_NAME_2, tdib.C_NAME_3, tdib.C_NAME_4, tdib.C_TYPE, tdib.C_DICTIONARYTYPEID, tdib.C_PROTECTED, tdib.C_VISIBLE, tdib.C_ORDER, tdib.C_CODE, tdib.C_VALUE, tdib.C_COLOR, tn.IntezmenyId, tn.TanevId, 'F', 0, GETDATE(), GETDATE(), NULL, NULL,tdib.ID
FROM #DICTIONARYITEMBASE tdib
CROSS JOIN #Tanevek tn
WHERE NOT EXISTS (SELECT 1 FROM dbo.T_DICTIONARYITEMBASE dib WHERE dib.ID = tdib.ID AND dib.C_INTEZMENYID = tn.IntezmenyId AND dib.C_TANEVID = tn.TanevId)");
script.AppendLine(@"
SET IDENTITY_INSERT [dbo].[T_DICTIONARYITEMBASE] OFF");
script.Append(@"
-- DictionaryItem elemek ");
foreach (var itemGroup in itemGroups)
{
if (itemGroup.Items.Any())
{
script.AppendFormat(@"
INSERT INTO [dbo].[{0}] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID])
SELECT tdib.ID, tn.IntezmenyId, tn.TanevId
FROM #DICTIONARYITEMBASE tdib
CROSS JOIN #Tanevek tn
WHERE NOT EXISTS (SELECT 1 FROM dbo.[{0}] di WHERE di.ID = tdib.ID AND di.C_ALINTEZMENYID = tn.IntezmenyId AND di.C_ALTANEVID = tn.TanevId)
AND tdib.C_DICTIONARYTYPEID = {1} ", itemGroup.TableName, itemGroup.Id);
}
}
script.Append(@" DROP TABLE IF EXISTS #DICTIONARYITEMBASE
END");
return script.ToString();
}
#endregion
}
}

View File

@@ -0,0 +1,36 @@
SCCardBevonasOka;T_SCCARDBEVONASOKA;False;Kreta
Megye;T_MEGYE;False;Kreta
TelepulesTipus;T_TELEPULESTIPUS;True;Kreta
DH2Statusz;T_DH2STATUSZ;True;Kreta
DiakigazolvanyIgenyStatusz;T_DIAKIGAZOLVANYIGENYSTATUSZ;True;Kreta
DiakigazolvanyIgenyTipus;T_DIAKIGAZOLVANYIGENYTIPUS;True;Kreta
OTPJelentesStatus;T_OTPJELENTESSTATUS;False;Kreta
OTPJelentesTipus;T_OTPJELENTESTIPUS;False;Kreta
KozteruletJelleg;T_KOZTERULETJELLEG;False;Kreta
SCApplicationFormStatus;T_SCAPPLICATIONFORMSTATUS;False;Kreta
SCStickerStatus;T_SCSTICKERSTATUS;True;Kreta
DHKStatus;T_DHKSTATUS;True;Kreta
SMSMessageStatus;T_SMSMESSAGESTATUS;True;Kreta
TransactionAnalysisFileStatus;T_TRANSACTIONANALYSISFILESTATU;False;Kreta
Country;T_COUNTRY;True;Kreta
FinancialStatus2;T_FINANCIALSTATUS2;True;Kreta
EventType;T_EVENTTYPE;False;Kreta
EventStatus;T_EVENTSTATUS;True;Kreta
MessageType;T_MESSAGETYPE;True;Kreta
TransactionStatus;T_TRANSACTIONSTATUS;True;Kreta
MessageStatus;T_MESSAGESTATUS;True;Kreta
FeeType;T_FEETYPE;False;Kreta
PaymentTitleType;T_PAYMENTTITLETYPE;False;Kreta
EmailType;T_EMAILTYPE;True;Kreta
TelephoneType;T_TELEPHONETYPE;True;Kreta
PayingType;T_PAYINGTYPE;True;Kreta
Citizenship;T_CITIZENSHIP;True;Kreta
StudentCardStatus;T_STUDENTCARDSTATUS;True;Kreta
Nationality;T_NATIONALITY;False;Kreta
MaritalStatus;T_MARITALSTATUS;True;Kreta
ImpositionStatus;T_IMPOSITIONSTATUS;True;Kreta
Language;T_LANGUAGE;True;Kreta
AddressType;T_ADDRESSTYPE;True;Kreta
Sex;T_SEX;True;Kreta
FotoType;T_FOTOTYPE;False;Kreta
FormType;T_FORMTYPE;True;Kreta

View File

@@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Linq;
using JetBrains.Annotations;
namespace Sda.DictionaryItemEnumGenerator
{
public class GeneratedDictionaryInputDataCollection
{
public GeneratedDictionaryInputDataCollection()
{
DictionaryItemGroups = new List<DictionaryItemGroup>();
}
public List<DictionaryItemGroup> DictionaryItemGroups { get; set; }
/// <summary>
/// DictionaryItemek beolvasasa
/// </summary>
/// <param name="fileName"></param>
public void Load([NotNull] string fileName)
{
if (fileName == null)
throw new ArgumentNullException(nameof(fileName));
if (File.Exists(fileName))
{
// XML fájl beolvasása
XElement root = XElement.Load(fileName);
// dict.itemek feltöltése
foreach (XElement dictionaryType in root.Elements())
{
var dictionaryGroup = new DictionaryItemGroup
{
Id = Convert.ToInt32(dictionaryType.Attribute("Id").Value),
Code = dictionaryType.Attribute("Code").Value,
CustomItemAllowed = Convert.ToBoolean(dictionaryType.Attribute("CustomItemAllowed").Value),
ColorEditable = Convert.ToBoolean(dictionaryType.Attribute("ColorEditable").Value),
Name = dictionaryType.Attribute("Name").Value,
Name1 = dictionaryType.Attribute("Name1").Value,
Name2 = dictionaryType.Attribute("Name2").Value,
Name3 = dictionaryType.Attribute("Name3").Value,
Name4 = dictionaryType.Attribute("Name4").Value
};
foreach (XElement dictionaryItem in dictionaryType.Elements())
{
DictionaryItem newDictionaryItem = new DictionaryItem();
var Id = dictionaryItem.Attribute("Id").Value;
var enumName = dictionaryItem.Attribute("EnumName").Value;
newDictionaryItem.DictionaryItemValues = new List<DictionaryItemValue>();
foreach (XElement dictionaryItemValue in dictionaryItem.Elements())
{
var Protected = Convert.ToBoolean(dictionaryItemValue.Attribute("Protected").Value);
var Visible = dictionaryItemValue.Attribute("Visible") != null && !string.IsNullOrEmpty(dictionaryItemValue.Attribute("Visible").Value) ? Convert.ToBoolean(dictionaryItemValue.Attribute("Visible").Value) : true;
var Order = dictionaryItemValue.Attribute("Order") != null && !string.IsNullOrEmpty(dictionaryItemValue.Attribute("Order").Value) ? Convert.ToInt32(dictionaryItemValue.Attribute("Order").Value) : (int?)null;
var Code = dictionaryItemValue.Attribute("Code") != null && !string.IsNullOrEmpty(dictionaryItemValue.Attribute("Code").Value) ? dictionaryItemValue.Attribute("Code").Value : null;
var Value = dictionaryItemValue.Attribute("Value") != null && !string.IsNullOrEmpty(dictionaryItemValue.Attribute("Value").Value) ? Convert.ToInt32(dictionaryItemValue.Attribute("Value").Value) : (int?)null;
var Color = dictionaryItemValue.Attribute("Color") != null && !string.IsNullOrEmpty(dictionaryItemValue.Attribute("Color").Value) ? dictionaryItemValue.Attribute("Color").Value : null;
var Environment = dictionaryItemValue.Attribute("Environment") != null && !string.IsNullOrEmpty(dictionaryItemValue.Attribute("Environment").Value) ? dictionaryItemValue.Attribute("Environment").Value : null;
var Name = dictionaryItemValue.Attribute("Name") != null && !string.IsNullOrEmpty(dictionaryItemValue.Attribute("Name").Value) ? dictionaryItemValue.Attribute("Name").Value : null;
var Name1 = dictionaryItemValue.Attribute("Name1") != null && !string.IsNullOrEmpty(dictionaryItemValue.Attribute("Name1").Value) ? dictionaryItemValue.Attribute("Name1").Value : null;
var Name2 = dictionaryItemValue.Attribute("Name2") != null && !string.IsNullOrEmpty(dictionaryItemValue.Attribute("Name2").Value) ? dictionaryItemValue.Attribute("Name2").Value : null;
var Name3 = dictionaryItemValue.Attribute("Name3") != null && !string.IsNullOrEmpty(dictionaryItemValue.Attribute("Name3").Value) ? dictionaryItemValue.Attribute("Name3").Value : null;
var Name4 = dictionaryItemValue.Attribute("Name4") != null && !string.IsNullOrEmpty(dictionaryItemValue.Attribute("Name4").Value) ? dictionaryItemValue.Attribute("Name4").Value : null;
if (string.IsNullOrEmpty(Name))
throw new ArgumentNullException(string.Format("{0}: hiányzik a Name", dictionaryGroup.Code));
newDictionaryItem.DictionaryItemValues.Add(new DictionaryItemValue
{
Name = Name,
Name1 = Name1,
Name2 = Name2,
Name3 = Name3,
Name4 = Name4,
EnvironmentName = Environment,
Protected = Protected,
Visible = Visible,
Order = Order,
Code = Code,
Value = Value,
Color = Color
});
}
if (string.IsNullOrEmpty(enumName))
throw new ArgumentNullException(string.Format("{0}: hiányzik a Name", dictionaryGroup.Code));
if (string.IsNullOrEmpty(Id))
throw new ArgumentNullException(string.Format("{0}_{1}: hiányzik az Id", dictionaryGroup.Code, enumName));
newDictionaryItem.Id = Convert.ToInt32(Id);
newDictionaryItem.EnumName = enumName;
dictionaryGroup.Items.Add(newDictionaryItem);
}
DictionaryItemGroups.Add(dictionaryGroup);
}
}
else
{
throw new FileNotFoundException(fileName);
}
}
}
}

View File

@@ -0,0 +1,104 @@
using System;
using System.IO;
using JetBrains.Annotations;
namespace Sda.DictionaryItemEnumGenerator
{
public static class Generator
{
public static void Generate(
[NotNull] string inputFileName,
[NotNull] string InputDictionaryXMLFile,
[NotNull] string ScriptOutputDir,
[NotNull] string csharpOutput)
{
if (string.IsNullOrEmpty(ScriptOutputDir))
throw new ArgumentNullException("ScriptOutputDir");
if (string.IsNullOrEmpty(inputFileName))
throw new ArgumentNullException("inputFileName");
if (string.IsNullOrEmpty(csharpOutput))
throw new ArgumentNullException("csharpOutput");
if (string.IsNullOrEmpty(InputDictionaryXMLFile))
throw new ArgumentNullException("InputDictionaryXMLFile");
try
{
// 1. UML-ből generált DictionaryItems.txt fájl feldolgozása
InputDataCollection idc = new InputDataCollection();
idc.Load(inputFileName);
// 2. GeneratedDictionaryItems.kres XML fájl betöltése + stringresources betöltése és feldolgozása
GeneratedDictionaryInputDataCollection dictInputDatas = new GeneratedDictionaryInputDataCollection();
dictInputDatas.Load(InputDictionaryXMLFile);
// 3. az XML és TXT fájlok összefésülése
DictionaryItemGroupUtils dictionaryitemGroupUtils = new DictionaryItemGroupUtils();
dictionaryitemGroupUtils.Load(idc, dictInputDatas.DictionaryItemGroups);
// 4. Kréta DB Scriptek generálása
dictionaryitemGroupUtils.GenerateDBScripts(ScriptOutputDir);
// 5. GeneratedEnums.cs fájl generálása
dictionaryitemGroupUtils.SaveCSharp(csharpOutput);
}
catch (Exception ex)
{
throw new ArgumentException(ex.Message);
}
}
internal static void GenerateConsole(
[NotNull] string inputFileName,
[NotNull] string InputDictionaryXMLFile,
[NotNull] string ScriptOutputDir,
[NotNull] string csharpOutput)
{
if (string.IsNullOrEmpty(inputFileName))
inputFileName = @"g:\Kreta\Main\DBScripts\DictionaryItems.txt";
if (string.IsNullOrEmpty(InputDictionaryXMLFile))
InputDictionaryXMLFile = @"g:\Kreta\Main\GeneratedDictionaryItems.kres";
if (string.IsNullOrEmpty(ScriptOutputDir))
ScriptOutputDir = @"g:\Kreta\Main\DBScripts\Mssql\";
if (string.IsNullOrEmpty(csharpOutput))
csharpOutput = @"g:\Kreta\Main\Kreta.Enums\";
FileInfo fi = new FileInfo(inputFileName);
Console.WriteLine("InputFileName: " + fi.FullName);
Console.WriteLine("Exists: " + fi.Exists);
Console.WriteLine();
//FileInfo fi2 = new FileInfo( outputFilename );
//Console.WriteLine( "OutputDirectory: " + fi2.FullName );
//Console.WriteLine( "Exists: " + fi2.Exists );
if (!fi.Exists)
{
Console.WriteLine("Input File does Not Exists");
Console.WriteLine("Exit Code is 1");
Environment.ExitCode = 1;
Environment.Exit(Environment.ExitCode);
}
try
{
// 1. UML-ből generált DictionaryItems.txt fájl feldolgozása
InputDataCollection idc = new InputDataCollection();
idc.Load(inputFileName);
// 2. GeneratedDictionaryItems.kres XML fájl betöltése + stringresources betöltése és feldolgozása
GeneratedDictionaryInputDataCollection dictInputDatas = new GeneratedDictionaryInputDataCollection();
dictInputDatas.Load(InputDictionaryXMLFile);
// 3. az XML és TXT fájlok összefésülése
DictionaryItemGroupUtils dictionaryitemGroupUtils = new DictionaryItemGroupUtils();
dictionaryitemGroupUtils.Load(idc, dictInputDatas.DictionaryItemGroups);
dictionaryitemGroupUtils.GenerateDBScripts(ScriptOutputDir);
dictionaryitemGroupUtils.SaveCSharp(csharpOutput);
}
catch (Exception ex)
{
throw new ArgumentException(ex.Message);
}
}
}
}

View File

@@ -0,0 +1,106 @@
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using JetBrains.Annotations;
namespace Sda.DictionaryItemEnumGenerator
{
public class InputData
{
[CanBeNull]
public string DictionaryItemGroupName { get; set; }
[CanBeNull]
public string TableName { get; set; }
public bool Protected { get; set; }
/// <summary>
/// Csomag neve az UML-ben.
/// </summary>
[CanBeNull]
public string Package { get; set; }
}
public class InputDataCollection : IEnumerable
{
readonly ArrayList _set = new ArrayList();
public int Count
{
get
{
return _set.Count;
}
}
public void Add([NotNull] InputData value)
{
if (value == null)
throw new ArgumentNullException("value");
_set.Add(value);
}
public void Clear()
{
_set.Clear();
}
public InputData this[int index]
{
get
{
return (InputData)_set[index];
}
}
[NotNull]
public IEnumerator GetEnumerator()
{
return _set.GetEnumerator();
}
public void Load([NotNull] string filename)
{
if (filename == null)
throw new ArgumentNullException("filename");
if (File.Exists(filename))
{
Clear();
FileStream stream = File.OpenRead(filename);
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
string filecontent = Encoding.UTF8.GetString(buffer);
string[] rows = filecontent.Split(new[] { '\n' });
foreach (InputData data in
from row in rows
let row2 = row.TrimEnd(new[] { '\r', '\n' })
where row.IndexOf(";", StringComparison.Ordinal) > -1
select row2.Split(new[] { ';' }) into values
select new InputData
{
DictionaryItemGroupName = values[0],
TableName = values[1],
Protected = Convert.ToBoolean(values[2]),
Package = values[3]
})
{
Add(data);
}
}
else
{
throw new FileNotFoundException(filename);
}
}
}
}

View File

@@ -0,0 +1,40 @@
using System;
using JetBrains.Annotations;
namespace Sda.DictionaryItemEnumGenerator
{
static class Program
{
[UsedImplicitly]
static void Main([CanBeNull] string[] args)
{
try
{
if (args == null || args.Length < 3)
{
Usage();
}
else
{
Generator.GenerateConsole(args[0], args[1], args[2], args[3]);
Console.WriteLine("Done.");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Environment.ExitCode = 1;
}
}
static void Usage()
{
Console.WriteLine("Usage:");
Console.WriteLine("DictionaryItemGenerator.exe DBConnectionString OutputFileName InputFileName");
Console.WriteLine();
Console.WriteLine("Parameter DBConnectionstring");
Console.WriteLine("Parameter OutputFileName");
Console.WriteLine("Parameter InputFileName");
}
}
}

View File

@@ -0,0 +1,172 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>7.10.3077</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7D3D2200-9954-4CAD-BEF6-04F4BB129FE6}</ProjectGuid>
<SccProjectName>%24/Kreta/Main/Tools/CodeGeneration/src</SccProjectName>
<SccLocalPath>..</SccLocalPath>
<SccProvider>{4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}</SccProvider>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon>
</ApplicationIcon>
<AssemblyKeyContainerName />
<AssemblyName>Sda.DictionaryItemEnumGenerator</AssemblyName>
<AssemblyOriginatorKeyFile>sn.snk</AssemblyOriginatorKeyFile>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<RootNamespace>Sda.DictionaryItemEnumGenerator</RootNamespace>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<StartupObject>
</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>0.0</OldToolsVersion>
<SccAuxPath>http://sdatfs.hu:8080/tfs/sda</SccAuxPath>
<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>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile />
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DocumentationFile />
<DebugSymbols>true</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn />
<Optimize>false</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile />
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile />
<DebugSymbols>true</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn />
<Optimize>true</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<DebugType>pdbonly</DebugType>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Build|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Build\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<BaseAddress>285212672</BaseAddress>
<Optimize>true</Optimize>
<FileAlignment>4096</FileAlignment>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="JetBrains.Annotations">
<HintPath>..\packages\JetBrains.Annotations.9.1.1\lib\net20\JetBrains.Annotations.dll</HintPath>
</Reference>
<Reference Include="System">
<Name>System</Name>
<Private>False</Private>
</Reference>
<Reference Include="System.Data">
<Name>System.Data</Name>
</Reference>
<Reference Include="System.XML" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="GeneratedDictionaryInputData.cs" />
<Compile Include="DictionaryItemGroup.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Generator.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="InputData.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Utils.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="sn.snk" />
</ItemGroup>
<ItemGroup>
<None Include="DictionaryItems.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent />
<PostBuildEvent />
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using JetBrains.Annotations;
namespace Sda.DictionaryItemEnumGenerator
{
public class StringResourcesData
{
public string StringValue { get; set; }
public string StringValue_1 { get; set; }
public string StringValue_2 { get; set; }
public string StringValue_3 { get; set; }
public string StringValue_4 { get; set; }
}
public class StringResourcesInputData
{
private XElement _stringresources = null;
public void Load([NotNull] string filename)
{
if (filename == null)
throw new ArgumentNullException(nameof(filename));
if (File.Exists(filename))
{
// XML fájl beolvasása
_stringresources = XElement.Load(filename);
}
else
{
throw new FileNotFoundException(filename);
}
}
}
}

View File

@@ -0,0 +1,71 @@
using System;
using System.IO;
using System.Text;
using JetBrains.Annotations;
namespace Sda.DictionaryItemEnumGenerator
{
public static class Utils
{
#region Utils
/// <summary>
/// Angolosítja a magyar ékezetes betűket.
/// Ez az összehasonlításnál kell, angol karakterláncokat nagyobb
/// biztonsággal lehet összehasonlítani, plusz az ékezetes betűket megeszi a VSS
/// ezért a kódban ilyet írni plusz összehasonlítani hibaforrás!
/// </summary>
[NotNull]
public static string ToBase26String([CanBeNull] this string str)
{
if (str == null)
return "";
str = str
.Replace('É', 'E').Replace('Á', 'A').Replace('Ű', 'U')
.Replace('Ö', 'O').Replace('Ü', 'U').Replace('Ó', 'O')
.Replace('Ő', 'O').Replace('Ú', 'U').Replace('Í', 'I')
.Replace('é', 'e').Replace('á', 'a').Replace('ű', 'u')
.Replace('ö', 'o').Replace('ü', 'u').Replace('ó', 'o')
.Replace('ő', 'o').Replace('ú', 'u').Replace('í', 'i')
.Replace((char)0xC1, 'A').Replace((char)0xE1, 'a') // á
.Replace((char)0xC9, 'E').Replace((char)0xE9, 'e') // é
.Replace((char)0xCD, 'I').Replace((char)0xED, 'i') // í
.Replace((char)0xD3, 'O').Replace((char)0xF3, 'o') // ó
.Replace((char)0xD6, 'O').Replace((char)0xF6, 'o') // ö
.Replace((char)0xD5, 'O').Replace((char)0xF5, 'o') // ő
.Replace((char)0xDA, 'U').Replace((char)0xFA, 'u') // ú
.Replace((char)0xDC, 'U').Replace((char)0xFC, 'u') // ü
.Replace((char)0xDB, 'U').Replace((char)0xFB, 'u') // ű
.Replace((char)0x150, 'O').Replace((char)0x151, 'o') // unicode
.Replace((char)0x170, 'U').Replace((char)0x171, 'u');
char[] array = str.ToCharArray();
for (int i = 0; i < array.Length; i++)
{
if (char.IsLetterOrDigit(array[i]) == false)
{
array[i] = '_';
}
}
string result = new string(array);
while (result.IndexOf("__", StringComparison.Ordinal) > -1)
{
result = result.Replace("__", "_");
}
if (result.Length > 0 && char.IsDigit(result[0]))
{
return "_" + result;
}
return result;
// unicode 0x150 nagy hosszú ö
// unicode 0x151 kicsi hosszú ö
// unicode 0x170 nagy hosszú ü
// unicode 0x171 kicsi hosszú ü
}
#endregion
}
}

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="JetBrains.Annotations" version="9.1.1" targetFramework="net45" />
</packages>

View File

@@ -0,0 +1,11 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
//
// To add a suppression to this file, right-click the message in the
// Code Analysis results, point to "Suppress Message", and click
// "In Suppression File".
// You do not need to add suppressions to this file manually.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Sda.ModelIdUpdater")]

View File

@@ -0,0 +1,19 @@
using System;
using System.Diagnostics;
namespace Sda.ModelIdUpdater
{
public class LogEventArgs : EventArgs
{
public TraceEventType EventType { get; set; }
public string Message { get; set; }
public string Package { get; set; }
public LogEventArgs()
{
EventType = TraceEventType.Warning;
}
}
}

View File

@@ -0,0 +1,38 @@
using System;
using System.Diagnostics;
namespace Sda.ModelIdUpdater
{
static class Program
{
public static void Main(string[] args)
{
if (args == null)
throw new ArgumentNullException("args");
Updater updater = new Updater();
updater.LogMessageHandler += (sender, e) =>
{
if (e == null
||
string.IsNullOrWhiteSpace(e.Message))
{
return;
}
switch (e.EventType)
{
case TraceEventType.Error:
Trace.TraceError(e.Message);
break;
case TraceEventType.Warning:
Trace.TraceWarning(e.Message);
break;
default:
Trace.TraceInformation(e.Message);
break;
}
};
updater.UpdateIds(args.Length > 0 ? args[0] : "Model.xml");
}
}
}

View File

@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" 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>{BBAD0E6B-8C66-4746-83AB-F3807C8E1A8E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sda.ModelIdUpdater</RootNamespace>
<AssemblyName>Sda.ModelIdUpdater</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>sn.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>
</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject>
</StartupObject>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Build|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Build\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="JetBrains.Annotations">
<HintPath>..\packages\JetBrains.Annotations.9.1.1\lib\net20\JetBrains.Annotations.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="LogEventArgs.cs" />
<Compile Include="Program.cs" />
<Compile Include="Updater.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="sn.snk" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="JetBrains.Annotations" version="9.1.1" targetFramework="net45" />
</packages>

Binary file not shown.

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling.Provider.Classes
{
internal class AssociationElement : Extendable, IAssociation
{
public IStartRole StartRole
{
get;
set;
}
public IEndRole EndRole
{
get;
set;
}
public string Name
{
get;
set;
}
public IModel Model
{
get;
set;
}
public IClass AssociationClass
{
get;
set;
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling.Provider.Classes
{
internal class AttributeElement : Extendable, IAttribute
{
public string Name
{
get;
set;
}
public string Type
{
get;
set;
}
public string DefaultValue
{
get;
set;
}
public IClass Class
{
get;
set;
}
}
}

View File

@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling.Provider.Classes
{
internal class ClassElement : Extendable, IClass
{
public string Name
{
get;
set;
}
public ICollection<IOperation> Operations
{
get;
set;
}
public ICollection<IAttribute> Attributes
{
get;
set;
}
public ICollection<IClass> SubClasses
{
get;
set;
}
public IClass SuperClass
{
get;
set;
}
public ICollection<IRole> Roles
{
get;
set;
}
public IPackage Package
{
get;
set;
}
public IIdentified Generalization
{
get;
set;
}
}
}

View File

@@ -0,0 +1,9 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling.Provider.Classes
{
internal class EndRoleElement : Role, IEndRole
{
}
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling.Provider.Classes
{
internal abstract class Extendable : Versionable, IExtendable
{
public ICollection<IStereotype> Stereotypes
{
get;
set;
}
public ICollection<ITagValuePair> TagValues
{
get;
set;
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling.Provider.Classes
{
sealed class Identified : IIdentified
{
public long LocalId { get; set; }
public Identified(long localId)
{
LocalId = localId;
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling.Provider.Classes
{
internal class ModelElement : IModel
{
public string Name
{
get;
set;
}
public ICollection<IPackage> Packages
{
get;
set;
}
public ICollection<IAssociation> Associations
{
get;
set;
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling.Provider.Classes
{
internal class OperationElement : Extendable, IOperation
{
public string Name
{
get;
set;
}
public ICollection<IParameter> Parameters
{
get;
set;
}
public IClass Class
{
get;
set;
}
}
}

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling.Provider.Classes
{
internal class PackageElement : Extendable, IPackage
{
public string Name
{
get;
set;
}
public ICollection<IClass> Classes
{
get;
set;
}
public IModel Model
{
get;
set;
}
public IPackage Parent
{
get;
set;
}
public ICollection<IPackage> Children
{
get;
set;
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling.Provider.Classes
{
internal class ParameterElement : Extendable, IParameter
{
public string Name
{
get;
set;
}
public string Type
{
get;
set;
}
public string Direction
{
get;
set;
}
public IOperation Operation
{
get;
set;
}
}
}

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling.Provider.Classes
{
internal abstract class Role : Versionable, IRole
{
public string Name
{
get;
set;
}
public string Multiplicity
{
get;
set;
}
public bool IsNavigable
{
get;
set;
}
public IClass Class
{
get;
set;
}
public IAssociation Association
{
get;
set;
}
}
}

View File

@@ -0,0 +1,9 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling.Provider.Classes
{
internal class StartRoleElement : Role, IStartRole
{
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling.Provider.Classes
{
internal class Stereotype : IStereotype
{
public string Name
{
get;
set;
}
}
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling.Provider.Classes
{
internal class TagValuePair : ITagValuePair
{
public string Name
{
get;
set;
}
public string Value
{
get;
set;
}
}
}

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling.Provider.Classes
{
internal abstract class Versionable : IVersionable
{
public string Author
{
get;
set;
}
public string Documentation
{
get;
set;
}
public string GlobalId
{
get;
set;
}
public long LocalId
{
get;
set;
}
public string Version
{
get;
set;
}
}
}

View File

@@ -0,0 +1,9 @@
using System;
namespace Sda.Modeling.Provider
{
public interface IModelProvider
{
IModel Model(params string[] packages);
}
}

View File

@@ -0,0 +1,614 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using Sda.Modeling.Provider.Classes;
namespace Sda.Modeling.Provider.Providers.Xmi
{
// ReSharper disable PossibleNullReferenceException
public sealed class XmiModelProvider : IModelProvider
{
static readonly XNamespace _umlNs = "omg.org/UML1.3";
static readonly Regex _alias = new Regex("alias=(?<alias>\\d+);", RegexOptions.Singleline | RegexOptions.Compiled);
readonly ModelElement _model;
public XmiModelProvider(XDocument modelDocument, params XDocument[] packageDocuments)
{
XElement modelElement =
modelDocument.Root
.Element("XMI.content")
.Element(_umlNs + "Model");
_model = new ModelElement
{
Name = modelElement.Attribute("name").Value,
Associations = new List<IAssociation>(),
Packages = new List<IPackage>(),
};
XElement owned;
if ((owned = modelElement.Element(_umlNs + "Namespace.ownedElement")) == null)
{
return;
}
ResolveMainModelElements(owned);
foreach (var subOwned in
packageDocuments
.Select(pd =>
pd.Root
.Element("XMI.content")
.Element(_umlNs + "Model")
.Element(_umlNs + "Namespace.ownedElement"))
.Where(o => o != null))
{
ResolveMainModelElements(subOwned);
}
ResolveModelElements(owned);
foreach (var subOwned in
packageDocuments
.Select(pd =>
pd.Root
.Element("XMI.content")
.Element(_umlNs + "Model")
.Element(_umlNs + "Namespace.ownedElement"))
.Where(o => o != null))
{
ResolveModelElements(subOwned);
}
foreach (var generalizationElement in
packageDocuments
.Select(pd =>
pd.Root
.Element("XMI.content")
.Element(_umlNs + "Model")
.Element(_umlNs + "Namespace.ownedElement"))
.Where(oe => oe != null)
.SelectMany(oe =>
oe
.Elements(_umlNs + "Package")
.SelectMany(pe =>
pe
.Element(_umlNs + "Namespace.ownedElement")
.Elements(_umlNs + "Generalization"))))
{
var superTypeId = FormatGuid(generalizationElement.Attribute("supertype").Value);
var subTypeId = FormatGuid(generalizationElement.Attribute("subtype").Value);
var superType = _model.Packages.SelectMany(p => p.Classes).Single(c => c.GlobalId == superTypeId);
var subType = _model.Packages.SelectMany(p => p.Classes).Single(c => c.GlobalId == subTypeId);
if (subType.SuperClass != null)
{
continue;
}
subType.SuperClass = superType;
superType.SubClasses.Add(subType);
}
foreach (var associationElement in
packageDocuments
.Select(pd =>
pd.Root
.Element("XMI.content")
.Element(_umlNs + "Model")
.Element(_umlNs + "Namespace.ownedElement"))
.Where(oe => oe != null)
.SelectMany(oe =>
oe
.Elements(_umlNs + "Package")
.SelectMany(pe =>
pe
.Element(_umlNs + "Namespace.ownedElement")
.Elements(_umlNs + "Association"))))
{
if (GetDescriptor(associationElement, "associationclass") == null)
{
string globalId = associationElement.Attribute("xmi.id").Value;
ResolveAssociation(associationElement);
ResolveRoles(_model.Associations.Single(a => a.GlobalId == globalId), associationElement);
}
else
{
string globalId = FormatGuid(GetDescriptor(associationElement, "associationclass"));
var association = _model.Associations.Single(a => a.AssociationClass != null && a.AssociationClass.GlobalId == globalId);
GetAssocElement(associationElement, association);
ResolveRoles(association, associationElement);
}
}
foreach (var tag in
packageDocuments
.SelectMany(pd =>
pd.Root
.Element("XMI.content")
.Elements(_umlNs + "TaggedValue")))
{
var globalId = tag.Attribute("modelElement").Value;
var classes = _model.Packages.SelectMany(p => p.Classes).Where(c => c.GlobalId == globalId);
foreach (var @class in classes)
{
@class.TagValues.Add(new TagValuePair { Value = tag.Attribute("value").Value, Name = tag.Attribute("tag").Value });
}
}
foreach (XElement tagElement in
packageDocuments
.Concat(new[] { modelDocument })
.Select(pd => pd.Root.Element("XMI.content"))
.SelectMany(e => e.Elements(_umlNs + "TaggedValue")))
{
string classId = FormatGuid(tagElement.Attribute("modelElement").Value);
IClass @class = _model.Packages.SelectMany(p => p.Classes).SingleOrDefault(c => c.GlobalId == classId);
if (@class != null)
{
@class.TagValues.Add(new TagValuePair
{
Name = tagElement.Attribute("tag").Value,
Value = tagElement.Attribute("value").Value
});
}
}
}
void ResolveRoles(IAssociation association, XContainer associationElement)
{
foreach (var end in associationElement.Element(_umlNs + "Association.connection").Elements())
{
var classId = FormatGuid(end.Attribute("type").Value);
var @class = _model.Packages.SelectMany(p => p.Classes).SingleOrDefault(c => c.GlobalId == classId);
if (@class == null)
{
continue;
}
var endName = end.Attribute("name");
var roleName = endName == null ? "" : endName.Value;
var multiplicityAttribute = end.Attribute("multiplicity");
if (multiplicityAttribute == null)
{
continue;
}
var multiplicity = multiplicityAttribute.Value;
var isNavigable = bool.Parse(end.Attribute("isNavigable").Value);
Role role;
long localId;
var eaEnd = GetDescriptor(end, "ea_end");
if (eaEnd == "source")
{
var style = GetDescriptor(end, @"sourcestyle");
if (string.IsNullOrEmpty(style)
||
!_alias.IsMatch(style)
||
!long.TryParse(_alias.Match(style).Result("${alias}"), out localId))
{
continue;
}
role = new StartRoleElement
{
Association = association,
Class = @class,
IsNavigable = isNavigable,
Multiplicity = multiplicity,
Name = roleName,
LocalId = localId,
GlobalId = "EA_" + localId,
};
association.StartRole = (StartRoleElement)role;
}
else
{
var style = GetDescriptor(end, @"deststyle");
if (string.IsNullOrEmpty(style)
||
!_alias.IsMatch(style)
||
!long.TryParse(_alias.Match(style).Result("${alias}"), out localId))
{
continue;
}
role = new EndRoleElement
{
Association = association,
Class = @class,
IsNavigable = isNavigable,
Multiplicity = multiplicity,
Name = roleName,
LocalId = localId,
GlobalId = "EA_" + localId,
};
association.EndRole = (EndRoleElement)role;
}
@class.Roles.Add(role);
}
}
void ResolvePackageGeneralizationElements(XContainer packageElements)
{
var elements = packageElements.Elements().ToList();
foreach (var childPackageElement in elements.Where(e => e.Name == _umlNs + "Package"))
{
ResolvePackageGeneralization(childPackageElement);
}
foreach (var generalizationElement in elements.Where(e => e.Name == _umlNs + "Generalization"))
{
var superTypeId = FormatGuid(generalizationElement.Attribute("supertype").Value);
var subTypeId = FormatGuid(generalizationElement.Attribute("subtype").Value);
var superType = _model.Packages.SelectMany(p => p.Classes).Single(c => c.GlobalId == superTypeId);
var subType = _model.Packages.SelectMany(p => p.Classes).Single(c => c.GlobalId == subTypeId);
// ReSharper disable once InvertIf
if (subType.SuperClass == null)
{
var styleex = GetDescriptor(generalizationElement, "styleex");
long localId;
if (!string.IsNullOrEmpty(styleex)
&&
_alias.IsMatch(styleex)
&&
long.TryParse(_alias.Match(styleex).Result("${alias}"), out localId))
{
subType.Generalization = new Identified(localId);
}
subType.SuperClass = superType;
superType.SubClasses.Add(subType);
}
}
}
void ResolvePackageGeneralization(XContainer element)
{
var owned = element.Element(_umlNs + "Namespace.ownedElement");
if (owned != null)
{
ResolvePackageGeneralizationElements(owned);
}
}
void ResolvePackageAssociationElements(XContainer packageElements)
{
var elements = packageElements.Elements().ToList();
foreach (var childPackageElement in elements.Where(e => e.Name == _umlNs + "Package"))
{
ResolvePackageAssoc(childPackageElement);
}
foreach (var associationElement in elements.Where(e => e.Name == _umlNs + "Association"))
{
string globalId = associationElement.Attribute("xmi.id").Value;
ResolveAssociation(associationElement);
// ReSharper disable once AccessToModifiedClosure
var association = _model.Associations.Single(a => a.GlobalId == globalId);
ResolveRoles(association, associationElement);
// ReSharper disable once InvertIf
if (GetDescriptor(associationElement, "associationclass") != null)
{
globalId = FormatGuid(GetDescriptor(associationElement, "associationclass"));
// ReSharper disable once AccessToModifiedClosure
var @class = _model.Packages.SelectMany(p => p.Classes).Single(c => c.GlobalId == globalId);
association.AssociationClass = @class;
}
}
}
void ResolvePackageAssoc(XContainer element)
{
var owned = element.Element(_umlNs + "Namespace.ownedElement");
if (owned != null)
{
ResolvePackageAssociationElements(owned);
}
}
void ResolveMainModelElements(XContainer modelElements)
{
foreach (var packageElement in modelElements.Elements().Where(e => e.Name == _umlNs + "Package"))
{
ResolvePackage(packageElement, null);
}
}
void ResolvePackageElements(XContainer packageElements, IPackage parent)
{
var elements = packageElements.Elements().ToList();
foreach (var childPackageElement in elements.Where(e => e.Name == _umlNs + "Package"))
{
ResolvePackage(childPackageElement, parent);
}
foreach (var classElement in elements.Where(e => e.Name == _umlNs + "Class"))
{
ResolveClass(classElement, parent);
}
}
void ResolveModelElements(XContainer modelElements)
{
foreach (var packageElement in modelElements.Elements().Where(e => e.Name == _umlNs + "Package"))
{
ResolvePackageAssoc(packageElement);
}
foreach (var packageElement in modelElements.Elements().Where(e => e.Name == _umlNs + "Package"))
{
ResolvePackageGeneralization(packageElement);
}
}
void ResolveAssociation(XElement associationElement)
{
var association = new AssociationElement();
GetAssocElement(associationElement, association);
if (_model.Associations.Any(a => a.GlobalId == association.GlobalId))
{
return;
}
_model.Associations.Add(association);
}
void GetAssocElement(XElement associationElement, IAssociation association)
{
var globalId = associationElement.Attribute("xmi.id").Value;
var styleex = GetDescriptor(associationElement, "styleex");
long localId;
if (string.IsNullOrEmpty(styleex)
||
!_alias.IsMatch(styleex)
||
!long.TryParse(_alias.Match(styleex).Result("${alias}"), out localId))
{
localId = -Int64.Parse(GetDescriptor(associationElement, "ea_localid"));
}
association.Author = GetDescriptor(associationElement, "author");
association.Documentation = GetDescriptor(associationElement, "documentation");
association.GlobalId = globalId;
association.LocalId = localId;
association.Name = associationElement.Attribute("name") != null ?
associationElement.Attribute("name").Value :
"";
association.Model = _model;
association.Stereotypes = GetStereoTypes(associationElement);
association.TagValues = GetTagValues(associationElement);
association.Version = GetDescriptor(associationElement, "version");
}
void ResolvePackage(XElement element, IPackage parent)
{
var name = element.Attribute("name").Value;
var package = _model.Packages.SingleOrDefault(p => p.Name == name);
if (package == null)
{
var globalId = element.Attribute("xmi.id").Value;
string alias = GetDescriptor(element, "alias");
long localId;
if (string.IsNullOrEmpty(alias) || !long.TryParse(alias, out localId))
{
localId = Math.Abs(name.GetHashCode());
}
package = new PackageElement
{
Author = GetDescriptor(element, "author"),
Documentation = GetDescriptor(element, "documentation"),
GlobalId = globalId,
Children = new List<IPackage>(),
Classes = new List<IClass>(),
LocalId = localId,
Model = _model,
Name = name,
Parent = parent,
Stereotypes = GetStereoTypes(element),
TagValues = GetTagValues(element),
Version = GetDescriptor(element, "version"),
};
_model.Packages.Add(package);
if (parent != null)
{
parent.Children.Add(package);
}
}
var owned = element.Element(_umlNs + "Namespace.ownedElement");
if (owned != null)
{
ResolvePackageElements(owned, package);
}
}
public IModel Model(params string[] packages)
{
return _model;
}
static string FormatGuid(string guid)
{
return FormatGuid(Guid.Parse(guid.Substring(5).Replace('_', '-')));
}
static string FormatGuid(Guid guid)
{
string s = guid.ToString("D");
return
s.Substring(0, 14).ToUpperInvariant() +
s.Substring(14, 4).ToLowerInvariant() +
s.Substring(18).ToUpperInvariant();
}
static string MapType(string type)
{
switch (type ?? "")
{
case "XmlString":
return "Object";
default:
return type;
}
}
static void ResolveClass(XElement element, IPackage parent)
{
if (element.Attribute("name") == null)
{
return;
}
var name = element.Attribute("name").Value;
var globalId = FormatGuid(element.Attribute("xmi.id").Value);
if (parent.Classes.Any(c => c.Name == name))
{
throw new XmiProviderException(string.Format(CultureInfo.InvariantCulture, "Duplicate class by name {0}!", name));
}
string alias = GetDescriptor(element, "alias");
long localId;
if (string.IsNullOrEmpty(alias) || !long.TryParse(alias, out localId))
{
return;
}
var @class = new ClassElement
{
Attributes = new List<IAttribute>(),
Author = GetDescriptor(element, "author"),
Documentation = GetDescriptor(element, "documentation"),
GlobalId = globalId,
LocalId = localId,
Name = name,
Operations = new List<IOperation>(),
Package = parent,
Roles = new List<IRole>(),
Stereotypes = GetStereoTypes(element),
SubClasses = new List<IClass>(),
SuperClass = null,
TagValues = GetTagValues(element),
Version = GetDescriptor(element, "version"),
};
ResolveAttributes(element, @class);
ResolveOperations(element, @class);
parent.Classes.Add(@class);
}
static void ResolveAttributes(XContainer element, IClass parent)
{
var classifier = element.Element(_umlNs + "Classifier.feature");
if (classifier == null)
return;
foreach (var attributeElement in classifier.Elements(_umlNs + "Attribute"))
{
var defaultDescriptor =
attributeElement
.Element(_umlNs + "Attribute.initialValue")
.Element(_umlNs + "Expression")
.Attribute("body");
string alias = GetDescriptor(attributeElement, "style");
long localId;
if (string.IsNullOrEmpty(alias) || !long.TryParse(alias, out localId))
{
continue;
}
parent.Attributes.Add(new AttributeElement
{
Author = GetDescriptor(attributeElement, "author"),
Class = parent,
DefaultValue = defaultDescriptor == null ? null : defaultDescriptor.Value,
Documentation = GetDescriptor(attributeElement, "description"),
GlobalId = GetDescriptor(attributeElement, "ea_guid"),
LocalId = localId,
Name = attributeElement.Attribute("name").Value,
Stereotypes = GetStereoTypes(attributeElement),
TagValues = GetTagValues(attributeElement),
Type = GetDescriptor(attributeElement, "type"),
Version = GetDescriptor(attributeElement, "version"),
});
}
}
static void ResolveOperations(XContainer element, IClass parent)
{
var classifier = element.Element(_umlNs + "Classifier.feature");
if (classifier == null)
return;
foreach (var operationElement in classifier.Elements(_umlNs + "Operation"))
{
string alias = GetDescriptor(operationElement, "style");
long localId;
if (string.IsNullOrEmpty(alias) || !long.TryParse(alias, out localId))
{
continue;
}
var operation = new OperationElement
{
Author = GetDescriptor(operationElement, "author"),
Class = parent,
Documentation = GetDescriptor(operationElement, "documentation"),
GlobalId = FormatGuid(Guid.Parse(GetDescriptor(operationElement, "ea_guid"))),
LocalId = localId,
Name = operationElement.Attribute("name").Value,
Parameters = new List<IParameter>(),
Stereotypes = GetStereoTypes(operationElement),
TagValues = GetTagValues(operationElement),
Version = GetDescriptor(operationElement, "version"),
};
parent.Operations.Add(operation);
foreach (var parameterElement in operationElement.Element(_umlNs + "BehavioralFeature.parameter").Elements())
{
operation.Parameters.Add(new ParameterElement
{
Author = GetDescriptor(parameterElement, "author"),
Direction = parameterElement.Attribute("kind").Value,
Documentation = GetDescriptor(parameterElement, "documentation"),
GlobalId = GetDescriptor(parameterElement, "ea_guid"),
LocalId = 0,
Name = parameterElement.Attribute("name") == null ? null : parameterElement.Attribute("name").Value,
Operation = operation,
Stereotypes = GetStereoTypes(parameterElement),
TagValues = GetTagValues(parameterElement),
Type = MapType(GetDescriptor(parameterElement, "type")),
Version = GetDescriptor(parameterElement, "version"),
});
}
}
}
static ICollection<ITagValuePair> GetTagValues(XContainer element)
{
return
element.Element(_umlNs + "ModelElement.taggedValue")
.Elements()
.Where(e =>
e.Attribute("xmi.id") != null
||
e.Attribute("tag").Value == @"alias"
||
e.Attribute("tag").Value == @"type"
||
e.Attribute("tag").Value == @"version"
||
e.Attribute("tag").Value == @"style"
||
e.Attribute("tag").Value == @"styleex"
||
e.Attribute("tag").Value == @"deststyle"
||
e.Attribute("tag").Value == @"sourcestyle"
||
e.Attribute("tag").Value == @"ea_end"
||
e.Attribute("tag").Value == @"ea_localid"
||
e.Attribute("tag").Value == @"ea_guid"
||
e.Attribute("tag").Value == @"stereotype"
||
e.Attribute("tag").Value == @"associationclass"
||
e.Attribute("tag").Value == @"author"
||
e.Attribute("tag").Value == @"documentation"
||
e.Attribute("tag").Value == @"description")
.Select(e => new TagValuePair { Name = e.Attribute("tag").Value, Value = e.Attribute("value").Value, })
.Cast<ITagValuePair>()
.ToList();
}
static ICollection<IStereotype> GetStereoTypes(XContainer element)
{
return GetTagValues(element).Where(t => t.Name == "stereotype").Select(t => new Stereotype { Name = t.Value }).Cast<IStereotype>().ToList();
}
static string GetDescriptor(XContainer element, string name)
{
return GetTagValues(element).Where(t => t.Name == name).Select(t => t.Value).FirstOrDefault();
}
}
// ReSharper restore PossibleNullReferenceException
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Runtime.Serialization;
namespace Sda.Modeling.Provider.Providers.Xmi
{
[Serializable]
public sealed class XmiProviderException : Exception
{
public XmiProviderException() { }
public XmiProviderException(string message) : base(message) { }
public XmiProviderException(string message, Exception inner) : base(message, inner) { }
XmiProviderException(SerializationInfo info, StreamingContext context) : base(info, context) { }
}
}

View File

@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{CCAC367F-DBE4-4484-9AC1-9A83671AA5FC}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sda.Modeling.Provider</RootNamespace>
<AssemblyName>Sda.Modeling.Provider</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<UseVSHostingProcess>false</UseVSHostingProcess>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>sn.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Build|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Build\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Classes\AttributeElement.cs" />
<Compile Include="Classes\AssociationElement.cs" />
<Compile Include="Classes\ClassElement.cs" />
<Compile Include="Classes\Extendable.cs" />
<Compile Include="Classes\EndRoleElement.cs" />
<Compile Include="Classes\Identified.cs" />
<Compile Include="Classes\ParameterElement.cs" />
<Compile Include="Classes\Versionable.cs" />
<Compile Include="Classes\ModelElement.cs" />
<Compile Include="Classes\OperationElement.cs" />
<Compile Include="Classes\PackageElement.cs" />
<Compile Include="Classes\Role.cs" />
<Compile Include="Classes\StartRoleElement.cs" />
<Compile Include="Classes\Stereotype.cs" />
<Compile Include="Classes\TagValuePair.cs" />
<Compile Include="Providers\Xmi\XmiModelProvider.cs" />
<Compile Include="IModelProvider.cs" />
<Compile Include="Providers\Xmi\XmiProviderException.cs" />
</ItemGroup>
<ItemGroup>
<None Include="sn.snk" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SDA.Modeling\SDA.Modeling.csproj">
<Project>{43e28ccf-4918-4ccd-b1bf-9bbfcf43c4cc}</Project>
<Name>SDA.Modeling</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Binary file not shown.

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>

View File

@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using Microsoft.VisualStudio.TextTemplating;
using Sda.Modeling.TextTemplating;
namespace Sda.Modeling.Runtime
{
public class Generator
{
public event EventHandler<LogEventArgs> LogMessageHandler;
public void Run(string output, string[] inputs)
{
StringBuilder templateContent;
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Sda.Modeling.Runtime.Model.t4"))
{
Debug.Assert(stream != null, "stream != null");
using (var reader = new StreamReader(stream))
{
templateContent = new StringBuilder(reader.ReadToEnd());
}
}
var files = new List<string>();
Debug.Assert(inputs != null, "inputs != null");
foreach (var input in inputs.Where(input => !string.IsNullOrEmpty(input)))
{
if (!File.Exists(input))
{
throw new ArgumentException("One of the files was not found (" + input + ")!", "inputs");
}
files.Add(Path.GetFullPath(input));
}
var engine = new Engine();
var host =
#if DEBUG
new TextTemplatingEngineHost { TemplateFile = @"..\..\Model.t4", SourceFiles = files };
#else
new TextTemplatingEngineHost { TemplateFile = ".", SourceFiles = files };
#endif
if (LogMessageHandler != null)
{
host.LogMessageHandler += LogMessageHandler;
}
Debug.Assert(output != null, "output != null");
try
{
File.WriteAllText(
output,
engine.ProcessTemplate(
templateContent.ToString(),
host),
Encoding.UTF8);
}
catch (Exception exp)
{
if (LogMessageHandler != null)
{
LogMessageHandler(
this,
new LogEventArgs
{
Type = TraceEventType.Error,
Message = exp.ToString()
});
}
throw;
}
}
}
}

View File

@@ -0,0 +1,925 @@
<#@ template debug="true" #>
<#@ output extension=".imf" #>
<#@ assembly name="System" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="Sda.Modeling" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="Sda.Modeling" #>
<#@ sdamodel Processor="SdaModelDirectiveProcessor" #>
{ Package
Id 48279
GUID UID_92C5E298-1C0F-4b77-92CB-76F29030058B
Name DataTypesAndBaseClasses
Desc Adattípusokat definiáló csomag.
{ MDataType
Id 13084
GUID UID_7F0E0880-EB4F-458b-A3F9-4DED1B74C884
Name LongString
Desc Adattípus a végtelen karakterlánc típusú attribútumok kezeléséhez.
}
{ MDataType
Id 28586
GUID UID_3A4356E9-5100-4a6f-91A6-13E1EB703D83
Name Char
Desc Adattípus a karakter típusú attribútumok kezeléséhez.
}
{ MDataType
Id 28570
GUID UID_13E4BB36-06B2-44e6-B293-7C919E222713
Name DictionaryItem
Desc Adattípus a kódtétel típusú attribútumok kezeléséhez.
}
{ MDataType
Id 28562
GUID UID_14D0E5C3-60DB-4227-BF92-8C42E614FEAA
Name DateTime
Desc Adattípus a dátum típusú attribútumok kezeléséhez.
}
{ MDataType
Id 28554
GUID UID_697EB0CA-2F19-42e9-8042-55629DD962BE
Name Boolean
Desc Adattípus a logikai típusú attribútumok kezeléséhez.
}
{ MDataType
Id 28534
GUID UID_51A4E386-EB71-408b-8C7C-95DF7F71E9FF
Name ID
Desc Adattípus az azonosító típusú attribútumok kezeléséhez.
}
{ MDataType
Id 28544
GUID UID_90CCFC09-537D-4169-A7A8-F2A50D94CE6D
Name Float
Desc Adattípus a lebegőpontos szám típusú attribútumok kezeléséhez.
}
{ MDataType
Id 28526
GUID UID_BE7EB910-472C-4dfa-A546-09BB64B3D8DE
Name Integer
Desc Adattípus a egész szám típusú attribútumok kezeléséhez.
}
{ MDataType
Id 28518
GUID UID_A616844D-1E15-4294-9851-EBA8FF9DB18D
Name Binary
Desc Adattípus a Binary típusú attribútumok kezeléséhez.
}
{ MDataType
Id 28509
GUID UID_F81333D0-376C-4879-8939-01BCCA0FCCF6
Name String
Desc Adattípus a karakterlánc típusú attribútumok kezeléséhez.
}
}
<#
string intezmenyId = ""; // Intézmény Class Local ID
string tanevId = ""; // Tanév Class Local ID
foreach( var package in
from p in Model.Packages
where ValidPackage( p.Name )
orderby p.LocalId
select p )
{
#>
{ Package
Id <#= package.LocalId #>
GUID UID_<#= CreateGuid() #>
Name <#= package.Name #>
<#
if( !string.IsNullOrWhiteSpace( package.Documentation ) )
{
#>
Desc <#= package.Documentation #>
<#
}
foreach( var entity in
from c in package.Classes
orderby c.LocalId
select c )
{
if(entity.Name == "Intezmeny")
{
intezmenyId = entity.LocalId.ToString();
}
if(entity.Name == "Tanev")
{
tanevId = entity.LocalId.ToString();
}
#>
{ NormalClass
Id <#= entity.LocalId #>
GUID UID_<#= entity.GlobalId #>
Name <#= entity.Name #>
<#
if( !string.IsNullOrWhiteSpace( entity.Documentation ) )
{
#>
Desc <#= entity.Documentation #>
<#
}
if (entity.TagValues.Any(t => t.Name.ToLowerInvariant() == "dkt" && t.Value == "true") && !(entity.SuperClass == null && entity.TagValues.Any(t => t.Name.ToLowerInvariant() == "inheritance" && t.Value == "tpc")))
{
#>
{ MAttribute
Id <#= entity.LocalId #>_101
GUID UID_<#= CreateGuid() #>
Name IsAktiv
Type Boolean
Access private
DefaultValue True
Key False
Binding normal
Derived False
}
{ MAttribute
Id <#= entity.LocalId #>_102
GUID UID_<#= CreateGuid() #>
Name IsModosithato
Type Boolean
Access private
<#
if (entity.TagValues.Any(t => t.Name.ToLowerInvariant() == "saveddi" && t.Value == "true"))
{
#>
DefaultValue False
<#
}
else
{
#>
DefaultValue True
<#
}
#>
Key False
Binding normal
Derived False
}
{ MAttribute
Id <#= entity.LocalId #>_103
GUID UID_<#= CreateGuid() #>
Name IsTorolheto
Type Boolean
Access private
<#
if (entity.TagValues.Any(t => t.Name.ToLowerInvariant() == "saveddi" && t.Value == "true"))
{
#>
DefaultValue False
<#
}
else
{
#>
DefaultValue True
<#
}
#>
Key False
Binding normal
Derived False
}
{ MAttribute
Id <#= entity.LocalId #>_104
GUID UID_<#= CreateGuid() #>
Name IsLathato
Type Boolean
Access private
DefaultValue True
Key False
Binding normal
Derived False
}
<#
}
if (!(entity.SuperClass == null && entity.TagValues.Any(t => t.Name.ToLowerInvariant() == "inheritance" && t.Value == "tpc")) && (entity.TagValues.Any(t => t.Name.ToLowerInvariant() == "dktnameset" && t.Value == "true") || (entity.SuperClass != null && entity.SuperClass.TagValues.Any(t => t.Name.ToLowerInvariant() == "dktnameset" && t.Value == "true"))))
{
#>
{ MAttribute
Id <#= entity.LocalId #>_111
GUID UID_<#= CreateGuid() #>
Name Nev
Type String
Access private
Key False
Binding normal
Derived False
}
{ MAttribute
Id <#= entity.LocalId #>_112
GUID UID_<#= CreateGuid() #>
Name RovidNev
Type String
Access private
Key False
Binding normal
Derived False
}
{ MAttribute
Id <#= entity.LocalId #>_113
GUID UID_<#= CreateGuid() #>
Name AliasNev
Type String
Access private
Key False
Binding normal
Derived False
}
{ MAttribute
Id <#= entity.LocalId #>_114
GUID UID_<#= CreateGuid() #>
Name Leiras
Type String
Access private
Key False
Binding normal
Derived False
}
{ MAttribute
Id <#= entity.LocalId #>_115
GUID UID_<#= CreateGuid() #>
Name Megjegyzes
Type String
Access private
Key False
Binding normal
Derived False
}
<#
}
foreach( var attribute in
from a in entity.Attributes
orderby a.LocalId
select a )
{
if (!(entity.SuperClass == null && entity.TagValues.Any(t => t.Name.ToLowerInvariant() == "inheritance" && t.Value == "tpc")))
{
#>
{ MAttribute
Id <#= attribute.LocalId #>
GUID UID_<#= CreateGuid() #>
Name <#= attribute.Name #>
Type <#= attribute.Type #>
Access private
<#
if( !string.IsNullOrWhiteSpace( attribute.DefaultValue ) )
{
#>
DefaultValue <#= attribute.DefaultValue#>
<#
}
#>
Key False
Binding normal
Derived False
<#
if( !string.IsNullOrWhiteSpace( attribute.Documentation ) )
{
#>
Desc <#= attribute.Documentation #>
<#
}
#>
}
<#
}
}
//SuperClass oszlopai
if (entity.SuperClass != null && entity.SuperClass.TagValues.Any(t => t.Name.ToLowerInvariant() == "inheritance" && t.Value == "tpc"))
{
int i = 1;
foreach( var attribute in
from a in entity.SuperClass.Attributes
orderby a.LocalId
select a )
{
#>
{ MAttribute
Id <#= entity.LocalId #>_<#= attribute.LocalId #>
GUID UID_<#= CreateGuid() #>
Name <#= attribute.Name #>
Type <#= attribute.Type #>
Access private
<#
if( !string.IsNullOrWhiteSpace( attribute.DefaultValue ) )
{
#>
DefaultValue <#= attribute.DefaultValue#>
<#
}
#>
Key False
Binding normal
Derived False
<#
if( !string.IsNullOrWhiteSpace( attribute.Documentation ) )
{
#>
Desc <#= attribute.Documentation #>
<#
}
#>
}
<#
i++;
}
}
foreach( var operation in
from o in entity.Operations
orderby o.LocalId
select o )
{
#>
{ MOperation
Id <#= operation.LocalId #>
GUID UID_<#= operation.GlobalId #>
Name <#= operation.Name #>
Access public
Binding normal
<#
if( !string.IsNullOrWhiteSpace( operation.Documentation ) )
{
#>
Desc <#= operation.Documentation #>
<#
}
int i = 0;
foreach( var parameter in
from p in operation.Parameters
where p.Direction != "return"
select p )
{
#>
{ OpPara
Id <#= operation.LocalId #>_Para_<#= i #>
GUID UID_<#= operation.GlobalId #>_Para_<#= i #>
Name <#= parameter.Name #>
Type <#= parameter.Type #>
}
<#
++i;
}
#>
}
<#
}
#>
}
<#
}
#>
}
<#
}
foreach( var package in
from p in Model.Packages
where ValidPackage( p.Name ) && ValidExtendedPackage( p.Name )
orderby p.LocalId
select p )
{
#>
{ NormalClass
Id <#= package.LocalId #>_0
GUID UID_<#= CreateGuid() #>
Name <#= package.Name.ToUpperInvariant() #>_VERSION
Desc <#= package.Name #> verzió tárolására szolgáló entitás
}
<#
}
foreach( var association in
from a in Model.Associations
where a.StartRole != null && a.EndRole != null
orderby a.LocalId
select a )
{
#>
{ MAssociation
Id <#= association.LocalId #>
GUID UID_<#= CreateGuid() #>
<#
if( !string.IsNullOrWhiteSpace( association.Name ) )
{
#>
Name <#= association.Name #>
<#
}
if( !string.IsNullOrWhiteSpace( association.Documentation ) )
{
#>
Desc <#= association.Documentation #>
<#
}
if( association.AssociationClass != null )
{
#>
AssocClassId <#= association.AssociationClass.LocalId #>
<#
}
#>
{ MAssociationEnd
Id <#= association.StartRole.LocalId #>
GUID UID_<#= CreateGuid() #>
MClassId <#= association.StartRole.Class.LocalId #>
<#
if( !string.IsNullOrWhiteSpace( association.StartRole.Name ) )
{
#>
Name <#= association.StartRole.Name #>
<#
}
#>
isNavigable <#= association.StartRole.IsNavigable ? "TRUE" : "FALSE" #>
Aggregation None
Multiplicity <#= association.StartRole.Multiplicity #>
Ordering False
}
{ MAssociationEnd
Id <#= association.EndRole.LocalId #>
GUID UID_<#= CreateGuid() #>
MClassId <#= association.EndRole.Class.LocalId #>
<#
if( !string.IsNullOrWhiteSpace( association.EndRole.Name ) )
{
#>
Name <#= association.EndRole.Name #>
<#
}
#>
isNavigable <#= association.EndRole.IsNavigable ? "TRUE" : "FALSE" #>
Aggregation None
Multiplicity <#= association.EndRole.Multiplicity #>
Ordering False
}
}
<#
}
foreach( var entity in
from p in Model.Packages
where ValidPackage( p.Name )
from c in p.Classes
where c.SubClasses.Any()
orderby c.LocalId
select c )
{
foreach( var subClass in entity.SubClasses )
{
#>
{ MInheritance
Id <#= subClass.Generalization.LocalId #>
GUID UID_<#= CreateGuid() #>
subClassId <#= subClass.LocalId #>
superClassId <#= entity.LocalId #>
}
<#
}
}
// Intézményi adatok és Tanévi asszociáció //&& c.Generalization == null
foreach( var entity in
from p in Model.Packages
where ValidPackage( p.Name ) && ValidExtendedPackage( p.Name )
from c in p.Classes
where ValidClass( c.Name )
orderby c.LocalId
select c )
{
if (!entity.TagValues.Any(t => t.Name.ToLowerInvariant() == "inheritance" && t.Value == "tpc"))
{
#>
{ MAssociation
Id <#= entity.LocalId*100 #>
GUID UID_<#= CreateGuid() #>
Name <#= entity.Name #>_Intezmeny
{ MAssociationEnd
Id <#= entity.LocalId*100+1 #>
GUID UID_<#= CreateGuid() #>
MClassId <#= entity.LocalId #>
isNavigable TRUE
Aggregation None
Multiplicity *
Ordering False
}
{ MAssociationEnd
Id <#= entity.LocalId*100+2 #>
GUID UID_<#= CreateGuid() #>
<# if(entity.Generalization != null && !entity.SuperClass.TagValues.Any(t => t.Name.ToLowerInvariant() == "inheritance" && t.Value == "tpc"))
{
#>
Name AlIntezmeny
<# } #>
MClassId <#= intezmenyId #>
isNavigable TRUE
Aggregation None
<# if(NullableClass(entity.Name) == true)
{ #>
Multiplicity 0..1
<#}
else
{ #>
Multiplicity 1
<# } #>
Ordering False
}
}
{ MAssociation
Id <#= entity.LocalId*100+3 #>
GUID UID_<#= CreateGuid() #>
Name <#= entity.Name #>_Tanev
{ MAssociationEnd
Id <#= entity.LocalId*100+4 #>
GUID UID_<#= CreateGuid() #>
MClassId <#= entity.LocalId #>
isNavigable TRUE
Aggregation None
Multiplicity *
Ordering False
}
{ MAssociationEnd
Id <#= entity.LocalId*100+5 #>
GUID UID_<#= CreateGuid() #>
<# if(entity.Generalization != null && !entity.SuperClass.TagValues.Any(t => t.Name.ToLowerInvariant() == "inheritance" && t.Value == "tpc"))
{
#>
Name AlTanev
<# } #>
MClassId <#= tanevId #>
isNavigable TRUE
Aggregation None
<# if(NullableClass(entity.Name) == true)
{ #>
Multiplicity 0..1
<#}
else
{ #>
Multiplicity 1
<# } #>
Ordering False
}
}
<#
}
}
// Intézményi asszociáció vége
#>
{ MStereotype
Id 28467
Name DataType
SemElementId 13084
SemElementId 28509
SemElementId 28518
SemElementId 28526
SemElementId 28534
SemElementId 28544
SemElementId 28554
SemElementId 28562
SemElementId 28570
SemElementId 28586
}
{ MStereotype
Id 17013
Name Entity
<#
foreach( var entity in
from p in Model.Packages
where ValidPackage( p.Name )
from c in p.Classes
where c.Stereotypes.Any( s => s.Name == "SDAEntity" )
orderby c.LocalId
select c )
{
#>
SemElementId <#= entity.LocalId #>
<#
}
#>
}
{ MStereotype
Id 84408
Name DisplayName
<#
foreach( var attribute in
from p in Model.Packages
where ValidPackage( p.Name )
from c in p.Classes
from a in c.Attributes
where a.Stereotypes.Any( s => s.Name == "DisplayName" )
group a by a.LocalId into g
orderby g.Key
select g.First() )
{
#>
SemElementId <#= attribute.LocalId #>
<#
}
#>
}
{ MTaggedValue
Id 1__0
MElementId 28509
Tag length
Value 20
}
{ MTaggedValue
Id 2__0
MElementId 28534
Tag length
Value 15
}
{ MTaggedValue
Id 3__0
MElementId 28534
Tag default
Value 0
}
{ MTaggedValue
Id 4__0
MElementId 28544
Tag length
Value 10
}
{ MTaggedValue
Id 5__0
MElementId 28544
Tag precision
Value 2
}
{ MTaggedValue
Id 6__0
MElementId 28586
Tag length
Value 1
}
<#
int tagid = 7;
foreach( var package in
from p in Model.Packages
where ValidPackage( p.Name )
orderby p.LocalId
select p )
{
#>
{ MTaggedValue
Id <#= tagid++ #>__0
MElementId <#= package.LocalId #>_0
Tag version
Value <#= package.Version #>
}
<#
foreach( var tag in
from c in package.Classes
from t in c.TagValues
where ValidTagValue( t )
orderby c.LocalId, t.Name
select new { t.Name, t.Value, c.LocalId } )
{
#>
{ MTaggedValue
Id <#= tagid++ #>__0
MElementId <#= tag.LocalId #>
Tag <#= tag.Name #>
Value <#= tag.Value #>
}
<#
}
foreach( var entity in
from c in package.Classes
orderby c.LocalId
select c )
{
#>
{ MTaggedValue
Tag <#= entity.Name #>
}
<#
if (entity.TagValues.Any(t => t.Name.ToLowerInvariant() == "dkt" && t.Value == "true") && !(entity.SuperClass == null && entity.TagValues.Any(t => t.Name.ToLowerInvariant() == "inheritance" && t.Value == "tpc")))
{
#>
{ MTaggedValue
Id <#= tagid++ #>__0
MElementId <#= entity.LocalId #>_101
Tag required
Value true
}
{ MTaggedValue
Id <#= tagid++ #>__0
MElementId <#= entity.LocalId #>_102
Tag required
Value true
}
{ MTaggedValue
Id <#= tagid++ #>__0
MElementId <#= entity.LocalId #>_103
Tag required
Value true
}
{ MTaggedValue
Id <#= tagid++ #>__0
MElementId <#= entity.LocalId #>_104
Tag required
Value true
}
<#
}
if (!(entity.SuperClass == null && entity.TagValues.Any(t => t.Name.ToLowerInvariant() == "inheritance" && t.Value == "tpc")) && (entity.TagValues.Any(t => t.Name.ToLowerInvariant() == "dktnameset" && t.Value == "true") || (entity.SuperClass != null && entity.SuperClass.TagValues.Any(t => t.Name.ToLowerInvariant() == "dktnameset" && t.Value == "true"))))
{
#>
{ MTaggedValue
Id <#= tagid++ #>__0
MElementId <#= entity.LocalId #>_111
Tag length
Value 1000
}
{ MTaggedValue
Id <#= tagid++ #>__0
MElementId <#= entity.LocalId #>_112
Tag length
Value 255
}
{ MTaggedValue
Id <#= tagid++ #>__0
MElementId <#= entity.LocalId #>_113
Tag length
Value 1000
}
{ MTaggedValue
Id <#= tagid++ #>__0
MElementId <#= entity.LocalId #>_114
Tag length
Value 1000
}
{ MTaggedValue
Id <#= tagid++ #>__0
MElementId <#= entity.LocalId #>_115
Tag length
Value 1000
}
<#
}
foreach( var tag in
from a in entity.Attributes
from t in a.TagValues
where ValidTagValue( t )
orderby entity.LocalId, a.LocalId, t.Name
select new { t.Name, t.Value, a.LocalId} )
{
#>
{ MTaggedValue
Id <#= tagid++ #>__0
MElementId <#= tag.LocalId #>
Tag <#= tag.Name #>
Value <#= tag.Value #>
}
<#
}
//SuperClass tagValue-i
if (entity.SuperClass != null && entity.SuperClass.TagValues.Any(t => t.Name.ToLowerInvariant() == "inheritance" && t.Value == "tpc"))
{
#>
{ MTaggedValue
Tag <#= entity.SuperClass.Name #>
}
<#
foreach( var tag in
from a in entity.SuperClass.Attributes
from t in a.TagValues
where ValidTagValue( t )
orderby entity.LocalId, a.LocalId, t.Name
select new { t.Name, t.Value, a.LocalId } )
{
#>
{ MTaggedValue
Id <#= tagid++ #>__0
MElementId <#= entity.LocalId #>_<#= tag.LocalId #>
Tag <#= tag.Name #>
Value <#= tag.Value #>
}
<#
}
}
}
foreach( var tag in
from c in package.Classes
from o in c.Operations
from t in o.TagValues
where ValidTagValue( t )
orderby c.LocalId, o.LocalId, t.Name
select new { t.Name, t.Value, o.LocalId } )
{
#>
{ MTaggedValue
Id <#= tagid++ #>__0
MElementId <#= tag.LocalId #>
Tag <#= tag.Name #>
Value <#= tag.Value #>
}
<#
}
}
foreach( var tag in
from a in Model.Associations
from t in a.TagValues
where ValidTagValue( t )
orderby a.LocalId, t.Name
select new { t.Name, t.Value, a.LocalId } )
{
#>
{ MTaggedValue
Id <#= tagid++ #>__0
MElementId <#= tag.LocalId #>
Tag <#= tag.Name #>
Value <#= tag.Value #>
}
<#
}
#>
<#+
static string[] _knownTags =
{
"saveddi", "length", "required", "languageindex", "allread",
"version", "multilang", "readonly", "precision", "default", "index",
"progress", "historymode", "disabledsecuritymode", "anonymous",
"poszeidondeleter", "trim", "defaultonly", "history", "minvalue",
"maxvalue", "minlength", "maxlength", "truncateable", "value",
"index_function", "unique", "unique1", "unique2", "index1", "index2",
"cascadedelete", "displayname", "private", "unicode", "dictdefault",
"computed", "persisted", "dkt", "inheritance", "dktnameset"
};
static string[] _notvalidClasses =
{
"dbversion", "logeventtype", "logleveltype", "globallock",
"tanev", "intezmeny", "intezmenyadatok", "intezmenyadatszolgaltatas", "fenntarto",
"serverstatistics", "telepules", "tantargynevhezkategoria", "globalisbeallitasok",
"mobildbinfo", "dashboarduzenet", "dashboarduzenetkategoria", "amittfsablon", "amitantargysablon", "adattisztitasindikator",
"dashboarduzenetintezmeny", "configtipus", "intezmenyconfig", "szirstatkonyvtarkategoria"
};
static string[] _nullableClasses =
{
"log", "entityhistory", "entityattributehistory", "felhasznalobelepestortenet"
};
static bool ValidTagValue( ITagValuePair tag )
{
return _knownTags.Any( t => t == tag.Name.ToLowerInvariant() );
}
static bool ValidPackage( string name )
{
return name != "Model" && name != "STP" && name != "SDA";
}
static bool ValidExtendedPackage( string name )
{
return name != "stage";
}
static bool ValidClass(string name)
{
return _notvalidClasses.Contains(name.ToLowerInvariant()) == false;
}
static bool NullableClass(string name)
{
return _nullableClasses.Contains(name.ToLowerInvariant());
}
static string CreateGuid()
{
string id = Guid.NewGuid().ToString( "D" );
return
id.Substring( 0, 14 ).ToUpperInvariant() +
id.Substring( 14, 4 ).ToLowerInvariant() +
id.Substring( 18 ).ToUpperInvariant();
}
static readonly Random getrandom = new Random();
static readonly object syncLock = new object();
static string CreateID()
{
lock(syncLock) { // synchronize
return getrandom .Next(1000000, 9999999).ToString();
}
}
#>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace Sda.Modeling.Runtime
{
static class Program
{
readonly static TraceSource _trace = new TraceSource("Generator", SourceLevels.Error);
public static void Main(string[] args)
{
if (args == null)
throw new ArgumentNullException("args");
List<string> files = (
from arg in args
where File.Exists(arg)
select Path.GetFullPath(arg))
.ToList();
if (files.Count == 0)
{
files.Add("Model.xml");
}
Console.WriteLine("Started.");
Generator generator = new Generator();
generator.LogMessageHandler += (sender, eventArgs) => _trace.TraceEvent(eventArgs.Type, 0, eventArgs.Message);
generator.Run(
Path.Combine(Path.GetDirectoryName(files[0]) ?? "", "Model.deb.imf"),
files.ToArray());
Console.WriteLine("Finished.");
}
}
}

View File

@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" 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>{7FBE4601-CDB1-4081-AB35-7CF1E43099D8}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sda.Modeling.Runtime</RootNamespace>
<AssemblyName>Sda.Modeling.Runtime</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>sn.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>
</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject>
</StartupObject>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Build|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Build\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.TextTemplating.12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\libs\Microsoft.VisualStudio.TextTemplating.12.0.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TextTemplating.Interfaces.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\libs\Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TextTemplating.Interfaces.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\libs\Microsoft.VisualStudio.TextTemplating.Interfaces.11.0.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Generator.cs" />
<Compile Include="Program.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Model.t4" />
<None Include="App.config" />
<None Include="sn.snk" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Sda.Modeling.Provider\Sda.Modeling.Provider.csproj">
<Project>{ccac367f-dbe4-4484-9ac1-9a83671aa5fc}</Project>
<Name>Sda.Modeling.Provider</Name>
</ProjectReference>
<ProjectReference Include="..\Sda.Modeling.TextTemplating\Sda.Modeling.TextTemplating.csproj">
<Project>{056cd3aa-f544-41e7-81d3-5d30d664a193}</Project>
<Name>Sda.Modeling.TextTemplating</Name>
</ProjectReference>
<ProjectReference Include="..\Sda.Modeling\Sda.Modeling.csproj">
<Project>{43e28ccf-4918-4ccd-b1bf-9bbfcf43c4cc}</Project>
<Name>Sda.Modeling</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Binary file not shown.

View File

@@ -0,0 +1,11 @@
using System;
using System.Diagnostics;
namespace Sda.Modeling.TextTemplating
{
public sealed class LogEventArgs : EventArgs
{
public TraceEventType Type { get; set; }
public string Message { get; set; }
}
}

View File

@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{056CD3AA-F544-41E7-81D3-5D30D664A193}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sda.Modeling.TextTemplating</RootNamespace>
<AssemblyName>Sda.Modeling.TextTemplating</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<UseVSHostingProcess>false</UseVSHostingProcess>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>sn.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Build|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Build\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.TextTemplating.12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\libs\Microsoft.VisualStudio.TextTemplating.12.0.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TextTemplating.Interfaces.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\libs\Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TextTemplating.Interfaces.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\libs\Microsoft.VisualStudio.TextTemplating.Interfaces.11.0.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="LogEventArgs.cs" />
<Compile Include="SdaModelDirectiveProcessor.cs" />
<Compile Include="TextTemplatingEngineHost.cs" />
</ItemGroup>
<ItemGroup>
<None Include="sn.snk" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SDA.Modeling.Provider\SDA.Modeling.Provider.csproj">
<Project>{ccac367f-dbe4-4484-9ac1-9a83671aa5fc}</Project>
<Name>SDA.Modeling.Provider</Name>
</ProjectReference>
<ProjectReference Include="..\SDA.Modeling\SDA.Modeling.csproj">
<Project>{43e28ccf-4918-4ccd-b1bf-9bbfcf43c4cc}</Project>
<Name>SDA.Modeling</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,162 @@
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using Microsoft.VisualStudio.TextTemplating;
using Sda.Modeling.Provider;
using Sda.Modeling.Provider.Providers.Xmi;
namespace Sda.Modeling.TextTemplating
{
public sealed class SdaModelDirectiveProcessor : DirectiveProcessor
{
static readonly CodeGeneratorOptions _options = new CodeGeneratorOptions
{
BlankLinesBetweenMembers = true,
IndentString = " ",
VerbatimOrder = true,
BracingStyle = "C"
};
readonly StringWriter _classCodeWriter = new StringWriter();
readonly StringWriter _initializationCodeWriter = new StringWriter();
string[] _files = new string[0];
CodeDomProvider _languageProvider;
public override void Initialize(ITextTemplatingEngineHost host)
{
base.Initialize(host);
TextTemplatingEngineHost textTemplatingEngineHost = host as TextTemplatingEngineHost;
if (textTemplatingEngineHost != null
&&
textTemplatingEngineHost.SourceFiles != null)
{
_files = textTemplatingEngineHost.SourceFiles.ToArray();
}
}
public override void StartProcessingRun(CodeDomProvider languageProvider, string templateContents, CompilerErrorCollection errors)
{
base.StartProcessingRun(languageProvider, templateContents, errors);
_languageProvider = languageProvider;
}
public override void FinishProcessingRun()
{
_languageProvider = null;
}
public override string GetClassCodeForProcessingRun()
{
return _classCodeWriter.ToString();
}
public override string[] GetImportsForProcessingRun()
{
return new[]
{
"System",
"System.Xml",
"System.Xml.Linq",
typeof( IModel ).Namespace,
typeof( IModelProvider ).Namespace
};
}
public override string GetPostInitializationCodeForProcessingRun()
{
return _initializationCodeWriter.ToString();
}
public override string GetPreInitializationCodeForProcessingRun()
{
return "";
}
public override string[] GetReferencesForProcessingRun()
{
return new[]
{
"System.Xml",
"System.Xml.Linq",
"System.Core",
typeof( IModel ).Assembly.Location,
typeof( IModelProvider ).Assembly.Location
};
}
public override bool IsDirectiveSupported(string directiveName)
{
return string.Equals(directiveName, @"sdamodel", StringComparison.OrdinalIgnoreCase);
}
public override void ProcessDirective(string directiveName, IDictionary<string, string> arguments)
{
string xmiArgument;
if (_files.Length == 0
&&
arguments.TryGetValue("Xmi", out xmiArgument))
{
_files = xmiArgument.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
}
string value;
var project = arguments.TryGetValue("Project", out value) ? value : "";
var modelField = new CodeMemberField(typeof(IModel), "model")
{
Attributes = MemberAttributes.Private,
};
_languageProvider.GenerateCodeFromMember(modelField, _classCodeWriter, _options);
var modelProperty = new CodeMemberProperty
{
Name = "Model",
Type = new CodeTypeReference(typeof(IModel)),
Attributes = MemberAttributes.Public,
HasGet = true,
HasSet = false,
};
modelProperty.GetStatements.Add(
new CodeMethodReturnStatement(
new CodeFieldReferenceExpression(
new CodeThisReferenceExpression(),
"model")));
var projectNameProperty = new CodeMemberProperty
{
Name = "ProjectName",
Type = new CodeTypeReference(typeof(string)),
Attributes = MemberAttributes.Public,
HasGet = true,
HasSet = false,
};
projectNameProperty.GetStatements.Add(
new CodeMethodReturnStatement(
new CodePrimitiveExpression(project)));
_languageProvider.GenerateCodeFromMember(projectNameProperty, _classCodeWriter, _options);
_languageProvider.GenerateCodeFromMember(modelProperty, _classCodeWriter, _options);
var docs = _files
.Select(f =>
new CodeMethodInvokeExpression(
new CodeTypeReferenceExpression(typeof(XDocument)),
"Load",
new CodePrimitiveExpression(f)))
.OfType<CodeExpression>()
.ToArray();
var assignment = new CodeAssignStatement(
new CodeFieldReferenceExpression(
new CodeThisReferenceExpression(), "model"),
new CodeCastExpression(
new CodeTypeReference(typeof(IModel)),
new CodeMethodInvokeExpression(
new CodeObjectCreateExpression(
new CodeTypeReference(
typeof(XmiModelProvider)),
docs
),
"Model",
new CodePrimitiveExpression(project))));
_languageProvider.GenerateCodeFromStatement(assignment, _initializationCodeWriter, _options);
}
}
}

View File

@@ -0,0 +1,138 @@
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using Microsoft.VisualStudio.TextTemplating;
namespace Sda.Modeling.TextTemplating
{
public sealed class TextTemplatingEngineHost : ITextTemplatingEngineHost
{
public event EventHandler<LogEventArgs> LogMessageHandler;
public object GetHostOption(string optionName)
{
switch (optionName)
{
case "CacheAssemblies":
return true;
default:
return null;
}
}
public bool LoadIncludeText(string requestFileName, out string content, out string location)
{
content = "";
location = "";
if (!File.Exists(requestFileName))
{
return false;
}
content = File.ReadAllText(requestFileName);
return true;
}
public void LogErrors(CompilerErrorCollection errors)
{
if (LogMessageHandler == null)
{
return;
}
foreach (CompilerError error in errors)
{
LogMessageHandler(this, new LogEventArgs { Type = TraceEventType.Error, Message = error.ErrorText });
}
}
public AppDomain ProvideTemplatingAppDomain(string content)
{
return AppDomain.CurrentDomain;
}
public string ResolveAssemblyReference(string assemblyReference)
{
if (File.Exists(assemblyReference))
{
return assemblyReference;
}
string candidate = Path.Combine(Path.GetDirectoryName(TemplateFile ?? ".") ?? ".", assemblyReference);
return File.Exists(candidate) ? candidate : "";
}
public Type ResolveDirectiveProcessor(string processorName)
{
if (string.Equals(processorName, "SdaModelDirectiveProcessor", StringComparison.OrdinalIgnoreCase))
{
return typeof(SdaModelDirectiveProcessor);
}
throw new ArgumentOutOfRangeException(processorName);
}
public string ResolveParameterValue(string directiveId, string processorName, string parameterName)
{
return String.Empty;
}
public string ResolvePath(string path)
{
if (path == null)
{
throw new ArgumentNullException("path");
}
if (File.Exists(path))
{
return path;
}
string candidate = Path.Combine(Path.GetDirectoryName(TemplateFile ?? ".") ?? ".", path);
return File.Exists(candidate) ? candidate : path;
}
public void SetFileExtension(string extension)
{
}
public void SetOutputEncoding(Encoding encoding, bool fromOutputDirective)
{
}
public IList<string> StandardAssemblyReferences
{
get
{
return new[]
{
typeof( String ).Assembly.Location,
typeof( CodeGenerator ).Assembly.Location,
typeof( Enumerable ).Assembly.Location,
typeof( XmlDocument ).Assembly.Location,
typeof( XDocument ).Assembly.Location
};
}
}
public IList<string> StandardImports
{
get
{
return new[]
{
"System",
"System.Collections.Generic",
"System.Linq",
"System.Xml",
"System.Xml.Linq"
};
}
}
public IList<string> SourceFiles { get; set; }
public string TemplateFile { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling
{
public interface IAssociation : IExtendable
{
string Name { get; set; }
IStartRole StartRole { get; set; }
IEndRole EndRole { get; set; }
IModel Model { get; set; }
IClass AssociationClass { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling
{
public interface IAttribute : IExtendable
{
string Name { get; set; }
string Type { get; set; }
string DefaultValue { get; set; }
IClass Class { get; set; }
}
}

View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling
{
public interface IClass : IExtendable
{
string Name { get; set; }
ICollection<IOperation> Operations { get; set; }
ICollection<IAttribute> Attributes { get; set; }
ICollection<IClass> SubClasses { get; set; }
IClass SuperClass { get; set; }
ICollection<IRole> Roles { get; set; }
IPackage Package { get; set; }
IIdentified Generalization { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling
{
public interface IEndRole : IRole
{
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling
{
public interface IExtendable : IVersionable
{
ICollection<IStereotype> Stereotypes { get; set; }
ICollection<ITagValuePair> TagValues { get; set; }
}
}

View File

@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling
{
public interface IIdentified
{
long LocalId { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling
{
public interface IModel
{
string Name { get; set; }
ICollection<IPackage> Packages { get; set; }
ICollection<IAssociation> Associations { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling
{
public interface IOperation : IExtendable
{
string Name { get; set; }
ICollection<IParameter> Parameters { get; set; }
IClass Class { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling
{
public interface IPackage : IExtendable
{
string Name { get; set; }
ICollection<IClass> Classes { get; set; }
IPackage Parent { get; set; }
ICollection<IPackage> Children { get; set; }
IModel Model { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling
{
public interface IParameter
{
string Name { get; set; }
string Type { get; set; }
string Direction { get; set; }
IOperation Operation { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling
{
public interface IRole : IVersionable
{
string Name { get; set; }
string Multiplicity { get; set; }
bool IsNavigable { get; set; }
IClass Class { get; set; }
IAssociation Association { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling
{
public interface IStartRole : IRole
{
}
}

View File

@@ -0,0 +1,10 @@
using System;
namespace Sda.Modeling
{
public interface IStereotype
{
string Name { get; set; }
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
namespace Sda.Modeling
{
public interface ITagValuePair
{
string Name { get; set; }
string Value { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
namespace Sda.Modeling
{
public interface IVersionable : IIdentified
{
string Author { get; set; }
string Documentation { get; set; }
string GlobalId { get; set; }
string Version { get; set; }
}
}

View File

@@ -0,0 +1 @@


View File

@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{43E28CCF-4918-4CCD-B1BF-9BBFCF43C4CC}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sda.Modeling</RootNamespace>
<AssemblyName>Sda.Modeling</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<UseVSHostingProcess>false</UseVSHostingProcess>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>sn.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Build|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Build\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="IIdentified.cs" />
<Compile Include="IStartRole.cs" />
<Compile Include="IAssociation.cs" />
<Compile Include="IAttribute.cs" />
<Compile Include="IClass.cs" />
<Compile Include="IEndRole.cs" />
<Compile Include="IModel.cs" />
<Compile Include="IOperation.cs" />
<Compile Include="IPackage.cs" />
<Compile Include="IParameter.cs" />
<Compile Include="IRole.cs" />
<Compile Include="IExtendable.cs" />
<Compile Include="IStereotype.cs" />
<Compile Include="ITagValuePair.cs" />
<Compile Include="IVersionable.cs" />
</ItemGroup>
<ItemGroup>
<None Include="sn.snk" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Binary file not shown.

View File

@@ -0,0 +1,15 @@
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyProduct("Kr<4B>ta")]
[assembly: AssemblyTitle("Kreta project")]
[assembly: AssemblyCompany("eKR<4B>TA Zrt. http://www.ekreta.hu/")]
[assembly: AssemblyCopyright("Copyright <20> eKR<4B>TA.ZRT")]
[assembly: AssemblyTrademark("eKRETA.NET<45>")]
[assembly: ComVisible(false)]
[assembly: Guid("77c398b5-005b-4cd0-b1dc-e1ce06f5a5a4")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]