Quellcode durchsuchen

Merge branch 'develop' of http://52.130.252.100:10000/TEAMMODEL/TEAMModelOS into develop

zhouj1203@hotmail.com vor 11 Monaten
Ursprung
Commit
bed229e697
100 geänderte Dateien mit 13696 neuen und 930 gelöschten Zeilen
  1. 0 2
      TEAMModelBI/Controllers/BICommon/BINoticeController.cs
  2. 0 1
      TEAMModelBI/Controllers/BICommon/StatsNoticeController.cs
  3. 1 2
      TEAMModelBI/Controllers/BINormal/AbilityMgmtController.cs
  4. 1 1
      TEAMModelBI/Controllers/BINormal/AbilityTaskMgmtController.cs
  5. 0 2
      TEAMModelBI/Controllers/BINormal/BatchAreaController.cs
  6. 0 6
      TEAMModelBI/Controllers/BISchool/BatchSchoolController.cs
  7. 0 1
      TEAMModelBI/Controllers/BISchool/SchoolController.cs
  8. 0 1
      TEAMModelBI/Controllers/BIServer/BiServersController.cs
  9. 0 1
      TEAMModelBI/Controllers/BITable/IES5OAuthController.cs
  10. 0 2
      TEAMModelBI/Controllers/BITable/TableDingDingInfoController.cs
  11. 0 4
      TEAMModelBI/Controllers/BITest/TestController.cs
  12. 0 1
      TEAMModelBI/Controllers/BITmid/TmidController.cs
  13. 0 1
      TEAMModelBI/Controllers/Census/ItemSticsController.cs
  14. 0 2
      TEAMModelBI/Controllers/Census/PaperController.cs
  15. 0 1
      TEAMModelBI/Controllers/LoginController.cs
  16. 0 3
      TEAMModelBI/Controllers/RepairApi/InitialAreaController.cs
  17. 0 2
      TEAMModelBI/Controllers/RepairApi/SchoolRepController.cs
  18. 0 2
      TEAMModelBI/Filter/RequestAuditFilter.cs
  19. 1 2
      TEAMModelBI/Models/ItemInfo.cs
  20. 0 2
      TEAMModelBI/Tool/CommonFind.cs
  21. 1 2
      TEAMModelBI/Tool/TimeHelper1.cs
  22. 1 1
      TEAMModelOS.Function/.gitignore
  23. 9 8
      TEAMModelOS.Function/IESCosmosDBTrigger.cs
  24. 73 73
      TEAMModelOS.Function/IESHttpTrigger.cs
  25. 803 799
      TEAMModelOS.Function/IESServiceBusTrigger.cs
  26. 8 8
      TEAMModelOS.Function/IESTimerTrigger.cs
  27. 174 0
      TEAMModelOS.Function/Properties/ServiceDependencies/TEAMModelOSFunction - Zip Deploy/profile.arm.json
  28. 51 0
      TEAMModelOS.HTEXLib/COMM/Globals.cs
  29. 43 0
      TEAMModelOS.HTEXLib/COMM/Helpers/CollectionHelper.cs
  30. 395 0
      TEAMModelOS.HTEXLib/COMM/Helpers/ContentTypeDict.cs
  31. 73 0
      TEAMModelOS.HTEXLib/COMM/Helpers/CustomXmlResolver.cs
  32. 85 0
      TEAMModelOS.HTEXLib/COMM/Helpers/HtmlHelper.cs
  33. 230 0
      TEAMModelOS.HTEXLib/COMM/Helpers/StringHelper.cs
  34. 17 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/BrushDIBColorsEnum.cs
  35. 24 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/BrushEnum.cs
  36. 21 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/BrushHSEnum.cs
  37. 34 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/FontCharsetEnum.cs
  38. 22 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/FontClipPrecisEnum.cs
  39. 21 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/FontFFEnum.cs
  40. 30 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/FontFWEnum.cs
  41. 25 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/FontOutPrecisEnum.cs
  42. 18 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/FontPitchEnum.cs
  43. 22 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/FontQualityEnum.cs
  44. 103 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/GdiEnum.cs
  45. 187 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/GdiUtils.cs
  46. 657 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/IGdi.cs
  47. 36 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/IGdiBrush.cs
  48. 102 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/IGdiFont.cs
  49. 15 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/IGdiObject.cs
  50. 30 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/IGdiPalette.cs
  51. 24 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/IGdiPatternBrush.cs
  52. 33 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/IGdiPen.cs
  53. 16 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/IGdiRegion.cs
  54. 22 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/PenEnum.cs
  55. 90 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/Point.cs
  56. 19 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/RegionEnum.cs
  57. 90 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/Size.cs
  58. 228 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/IO/DataInput.cs
  59. 132 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/Properties.cs
  60. 271 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgBrush.cs
  61. 976 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgDc.cs
  62. 532 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgFont.cs
  63. 2292 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgGdi.cs
  64. 77 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgObject.cs
  65. 67 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgPalette.cs
  66. 50 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgPatternBrush.cs
  67. 205 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgPen.cs
  68. 149 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgRectRegion.cs
  69. 38 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgRegion.cs
  70. 84 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Util/Base64.cs
  71. 15 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Util/ImageUtil.cs
  72. 74 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfBrush.cs
  73. 85 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfConstants.cs
  74. 250 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfFont.cs
  75. 1647 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfGdi.cs
  76. 49 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfObject.cs
  77. 65 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfPalette.cs
  78. 30 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfParseException.cs
  79. 821 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfParser.cs
  80. 52 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfPatternBrush.cs
  81. 75 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfPen.cs
  82. 92 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfRectRegion.cs
  83. 27 0
      TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfRegion.cs
  84. 23 0
      TEAMModelOS.HTEXLib/COMM/TransException.cs
  85. 24 0
      TEAMModelOS.HTEXLib/DOCX/Models/ItemInfo.cs
  86. 38 0
      TEAMModelOS.HTEXLib/DOCX/Models/LangConfig.cs
  87. 12 0
      TEAMModelOS.HTEXLib/DOCX/Models/ReplaceDto.cs
  88. 602 0
      TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/ChartUpdater.cs
  89. 36 0
      TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/ColorParser.cs
  90. 67 0
      TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/ComparisonUnit.cs
  91. 216 0
      TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/ComparisonUnitAtom.cs
  92. 77 0
      TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/ComparisonUnitGroup.cs
  93. 14 0
      TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/ComparisonUnitGroupType.cs
  94. 81 0
      TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/ComparisonUnitWord.cs
  95. 70 0
      TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/CorrelatedSequence.cs
  96. 16 0
      TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/CorrelationStatus.cs
  97. 15 0
      TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/PartSHA1HashAnnotation.cs
  98. 12 0
      TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/WithHierarchicalGroupingKey.cs
  99. 403 0
      TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/WmlComparer.Internal.Methods.ComparisonUnits.cs
  100. 0 0
      TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/WmlComparer.Private.Fields.cs

+ 0 - 2
TEAMModelBI/Controllers/BICommon/BINoticeController.cs

@@ -23,8 +23,6 @@ using TEAMModelOS.SDK.Models.Service.BI;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models;
-using DocumentFormat.OpenXml.Spreadsheet;
-using System.Net.Http.Json;
 
 
 namespace TEAMModelBI.Controllers.BICommon
 namespace TEAMModelBI.Controllers.BICommon
 {
 {

+ 0 - 1
TEAMModelBI/Controllers/BICommon/StatsNoticeController.cs

@@ -16,7 +16,6 @@ using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BICommon;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BICommon;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;
-using DocumentFormat.OpenXml.Office2010.Excel;
 
 
 namespace TEAMModelBI.Controllers.BICommon
 namespace TEAMModelBI.Controllers.BICommon
 {
 {

+ 1 - 2
TEAMModelBI/Controllers/BINormal/AbilityMgmtController.cs

@@ -11,13 +11,12 @@ using TEAMModelOS.Models;
 using Microsoft.Extensions.Options;
 using Microsoft.Extensions.Options;
 using System.Text.Json;
 using System.Text.Json;
 using Azure.Cosmos;
 using Azure.Cosmos;
-using HTEXLib.COMM.Helpers;
 using System.Text;
 using System.Text;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelBI.Filter;
 using TEAMModelBI.Filter;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelOS.SDK.Context.BI;
 using TEAMModelOS.SDK.Context.BI;
-
+using TEAMModelOS.SDK;
 namespace TEAMModelBI.Controllers.BINormal
 namespace TEAMModelBI.Controllers.BINormal
 {
 {
     [Route("biabilitymgmt")]
     [Route("biabilitymgmt")]

+ 1 - 1
TEAMModelBI/Controllers/BINormal/AbilityTaskMgmtController.cs

@@ -11,7 +11,6 @@ using Microsoft.Extensions.Options;
 using System.Text.Json;
 using System.Text.Json;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models;
 using Azure.Cosmos;
 using Azure.Cosmos;
-using HTEXLib.COMM.Helpers;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using System.Text;
 using System.Text;
 using TEAMModelBI.Filter;
 using TEAMModelBI.Filter;
@@ -19,6 +18,7 @@ using TEAMModelOS.SDK.Services;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Context.BI;
 using TEAMModelOS.SDK.Context.BI;
+using TEAMModelOS.SDK;
 
 
 namespace TEAMModelBI.Controllers.BINormal
 namespace TEAMModelBI.Controllers.BINormal
 {
 {

+ 0 - 2
TEAMModelBI/Controllers/BINormal/BatchAreaController.cs

@@ -11,7 +11,6 @@ using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models;
 using Azure.Cosmos;
 using Azure.Cosmos;
 using System.Text.Json;
 using System.Text.Json;
-using HTEXLib.COMM.Helpers;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
 using Azure.Messaging.ServiceBus;
 using Azure.Messaging.ServiceBus;
@@ -28,7 +27,6 @@ using System.Net;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.Context.BI;
 using TEAMModelOS.SDK.Context.BI;
 using System.Text;
 using System.Text;
-using DocumentFormat.OpenXml.Bibliography;
 using Microsoft.Extensions.Hosting;
 using Microsoft.Extensions.Hosting;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Hosting;
 using TEAMModelOS.SDK.Context.Constant;
 using TEAMModelOS.SDK.Context.Constant;

+ 0 - 6
TEAMModelBI/Controllers/BISchool/BatchSchoolController.cs

@@ -1,5 +1,4 @@
 using Azure.Cosmos;
 using Azure.Cosmos;
-using HTEXLib.COMM.Helpers;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
 using Microsoft.Extensions.Options;
@@ -32,13 +31,8 @@ using TEAMModelOS.SDK.Context.Constant;
 using Pipelines.Sockets.Unofficial.Arenas;
 using Pipelines.Sockets.Unofficial.Arenas;
 using Microsoft.Identity.Client;
 using Microsoft.Identity.Client;
 using TEAMModelOS.SDK.Models.Dtos;
 using TEAMModelOS.SDK.Models.Dtos;
-using DocumentFormat.OpenXml.Spreadsheet;
-using DocumentFormat.OpenXml.Wordprocessing;
-using DocumentFormat.OpenXml.Bibliography;
-using HTEXLib;
 using TEAMModelOS.SDK.Models.Service.BI;
 using TEAMModelOS.SDK.Models.Service.BI;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
-using DocumentFormat.OpenXml.Vml.Office;
 using System.Net.Http.Headers;
 using System.Net.Http.Headers;
 using System.Text.Encodings.Web;
 using System.Text.Encodings.Web;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations;

+ 0 - 1
TEAMModelBI/Controllers/BISchool/SchoolController.cs

@@ -1,5 +1,4 @@
 using Azure.Cosmos;
 using Azure.Cosmos;
-using HTEXLib.COMM.Helpers;
 using MathNet.Numerics.LinearAlgebra.Double;
 using MathNet.Numerics.LinearAlgebra.Double;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Http;

+ 0 - 1
TEAMModelBI/Controllers/BIServer/BiServersController.cs

@@ -13,7 +13,6 @@ using System.Net.Http;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Extension;
 using System.Text;
 using System.Text;
 using System.Net;
 using System.Net;
-using HTEXLib.COMM.Helpers;
 using System.Net.Http.Json;
 using System.Net.Http.Json;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK;
 using TEAMModelBI.Filter;
 using TEAMModelBI.Filter;

+ 0 - 1
TEAMModelBI/Controllers/BITable/IES5OAuthController.cs

@@ -1,6 +1,5 @@
 using Azure.Cosmos;
 using Azure.Cosmos;
 using Azure.Storage.Blobs;
 using Azure.Storage.Blobs;
-using DocumentFormat.OpenXml.Spreadsheet;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
 using Microsoft.Extensions.Options;

+ 0 - 2
TEAMModelBI/Controllers/BITable/TableDingDingInfoController.cs

@@ -17,7 +17,6 @@ using System.Net.Http.Json;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
 using System.Net;
 using System.Net;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Extension;
-using OpenXmlPowerTools;
 using System.Text;
 using System.Text;
 using Azure.Cosmos;
 using Azure.Cosmos;
 using Microsoft.Azure.Cosmos.Table;
 using Microsoft.Azure.Cosmos.Table;
@@ -30,7 +29,6 @@ using TEAMModelOS.SDK.Context.BI;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Context.Constant;
 using TEAMModelOS.SDK.Context.Constant;
 using TEAMModelOS.SDK.Models.Dtos;
 using TEAMModelOS.SDK.Models.Dtos;
-using DocumentFormat.OpenXml.Bibliography;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
 
 
 namespace TEAMModelBI.Controllers.BITable
 namespace TEAMModelBI.Controllers.BITable

+ 0 - 4
TEAMModelBI/Controllers/BITest/TestController.cs

@@ -2,7 +2,6 @@
 using DingTalk.Api;
 using DingTalk.Api;
 using DingTalk.Api.Request;
 using DingTalk.Api.Request;
 using DingTalk.Api.Response;
 using DingTalk.Api.Response;
-using HTEXLib.COMM.Helpers;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc;
@@ -53,12 +52,9 @@ using Azure.Storage.Blobs;
 using Azure.Storage.Blobs.Specialized;
 using Azure.Storage.Blobs.Specialized;
 using System.Web;
 using System.Web;
 using Azure.Storage.Sas;
 using Azure.Storage.Sas;
-using DocumentFormat.OpenXml.Drawing.Diagrams;
-using DocumentFormat.OpenXml.Bibliography;
 using TEAMModelOS.SDK.Models.Service.BIStatsWay;
 using TEAMModelOS.SDK.Models.Service.BIStatsWay;
 using MathNet.Numerics.LinearAlgebra.Double;
 using MathNet.Numerics.LinearAlgebra.Double;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
-using DocumentFormat.OpenXml.Drawing;
 using Microsoft.OData.Edm;
 using Microsoft.OData.Edm;
 using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
 using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BICommon;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BICommon;

+ 0 - 1
TEAMModelBI/Controllers/BITmid/TmidController.cs

@@ -1,5 +1,4 @@
 using Azure.Cosmos;
 using Azure.Cosmos;
-using DocumentFormat.OpenXml.Office2010.Excel;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Azure.Cosmos.Table;
 using Microsoft.Azure.Cosmos.Table;

+ 0 - 1
TEAMModelBI/Controllers/Census/ItemSticsController.cs

@@ -16,7 +16,6 @@ using TEAMModelOS.SDK.Context.BI;
 using Azure.Core;
 using Azure.Core;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Context.Constant;
 using TEAMModelOS.SDK.Context.Constant;
-using DocumentFormat.OpenXml.Wordprocessing;
 using TEAMModelOS.SDK.Models.Service.BI;
 using TEAMModelOS.SDK.Models.Service.BI;
 
 
 namespace TEAMModelBI.Controllers.Census
 namespace TEAMModelBI.Controllers.Census

+ 0 - 2
TEAMModelBI/Controllers/Census/PaperController.cs

@@ -2,7 +2,6 @@
 using Azure.Storage.Blobs;
 using Azure.Storage.Blobs;
 using Azure.Storage.Blobs.Models;
 using Azure.Storage.Blobs.Models;
 using Azure.Storage.Sas;
 using Azure.Storage.Sas;
-using DocumentFormat.OpenXml.Drawing.Diagrams;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
 using Microsoft.Extensions.Options;
@@ -23,7 +22,6 @@ using TEAMModelOS.Models;
 using TEAMModelOS.SDK.Context.BI;
 using TEAMModelOS.SDK.Context.BI;
 using TEAMModelOS.SDK.Context.Constant;
 using TEAMModelOS.SDK.Context.Constant;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI;
-using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
 using TEAMModelOS.SDK.Models.Cosmos.BI;

+ 0 - 1
TEAMModelBI/Controllers/LoginController.cs

@@ -12,7 +12,6 @@ using System.Text.Json;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models;
-using HTEXLib.COMM.Helpers;
 using TEAMModelOS.Models;
 using TEAMModelOS.Models;
 using Microsoft.Extensions.Options;
 using Microsoft.Extensions.Options;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Extension;

+ 0 - 3
TEAMModelBI/Controllers/RepairApi/InitialAreaController.cs

@@ -20,9 +20,6 @@ using System.Collections.Generic;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using System.Linq;
 using System.Linq;
 using Pipelines.Sockets.Unofficial.Arenas;
 using Pipelines.Sockets.Unofficial.Arenas;
-using TEAMModelOS.SDK.Models.Cosmos.BI;
-using TEAMModelBI.Filter;
-using HTEXLib.COMM.Helpers;
 using TEAMModelBI.Models;
 using TEAMModelBI.Models;
 
 
 namespace TEAMModelBI.Controllers.RepairApi
 namespace TEAMModelBI.Controllers.RepairApi

+ 0 - 2
TEAMModelBI/Controllers/RepairApi/SchoolRepController.cs

@@ -23,9 +23,7 @@ using Pipelines.Sockets.Unofficial.Arenas;
 using TEAMModelBI.Tool;
 using TEAMModelBI.Tool;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
-using DocumentFormat.OpenXml.Math;
 using TEAMModelOS.SDK.Models.Service.BI;
 using TEAMModelOS.SDK.Models.Service.BI;
-using TEAMModelBI.Tool.CosmosBank;
 using TEAMModelOS.SDK.Models.Service.BIStatsWay;
 using TEAMModelOS.SDK.Models.Service.BIStatsWay;
 using StackExchange.Redis;
 using StackExchange.Redis;
 using System.Text.RegularExpressions;
 using System.Text.RegularExpressions;

+ 0 - 2
TEAMModelBI/Filter/RequestAuditFilter.cs

@@ -11,14 +11,12 @@ using System.Linq;
 using Azure.Core;
 using Azure.Core;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI;
 using Microsoft.Extensions.Primitives;
 using Microsoft.Extensions.Primitives;
-using HTEXLib.Helpers.ShapeHelpers;
 using System.Net.Http;
 using System.Net.Http;
 using System.ServiceModel.Channels;
 using System.ServiceModel.Channels;
 using System.Net;
 using System.Net;
 using System.Net.Http.Json;
 using System.Net.Http.Json;
 using Microsoft.Extensions.Options;
 using Microsoft.Extensions.Options;
 using TEAMModelOS.Models;
 using TEAMModelOS.Models;
-using OpenXmlPowerTools;
 
 
 namespace TEAMModelOS.Filter
 namespace TEAMModelOS.Filter
 {
 {

+ 1 - 2
TEAMModelBI/Models/ItemInfo.cs

@@ -1,5 +1,4 @@
-using DocumentFormat.OpenXml.Office2010.ExcelAc;
-using System.Collections.Generic;
+using System.Collections.Generic;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models;
 
 
 namespace TEAMModelBI.Models
 namespace TEAMModelBI.Models

+ 0 - 2
TEAMModelBI/Tool/CommonFind.cs

@@ -1,5 +1,4 @@
 using Azure.Cosmos;
 using Azure.Cosmos;
-using DocumentFormat.OpenXml.Spreadsheet;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;
@@ -7,7 +6,6 @@ using System.Text.Json;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using TEAMModelBI.Models;
 using TEAMModelBI.Models;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models;
-using TEAMModelOS.SDK.Models.Cosmos.Common;
 
 
 namespace TEAMModelBI.Tool
 namespace TEAMModelBI.Tool
 {
 {

+ 1 - 2
TEAMModelBI/Tool/TimeHelper1.cs

@@ -1,5 +1,4 @@
-using DocumentFormat.OpenXml.Bibliography;
-using System;
+using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Threading.Tasks;
 using System.Threading.Tasks;

+ 1 - 1
TEAMModelOS.Function/.gitignore

@@ -2,7 +2,7 @@
 ## files generated by popular Visual Studio add-ons.
 ## files generated by popular Visual Studio add-ons.
 
 
 # Azure Functions localsettings file
 # Azure Functions localsettings file
-local.settings.json
+#local.settings.json
 
 
 # User-specific files
 # User-specific files
 *.suo
 *.suo

+ 9 - 8
TEAMModelOS.Function/IESCosmosDBTrigger.cs

@@ -1,4 +1,4 @@
-using System;
+锘縰sing System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text.Json;
 using System.Text.Json;
 using Microsoft.Azure.Functions.Worker;
 using Microsoft.Azure.Functions.Worker;
@@ -46,6 +46,7 @@ namespace TEAMModelOS.Function
             containerName: "Common",
             containerName: "Common",
             Connection = "Azure:Cosmos:ConnectionString",
             Connection = "Azure:Cosmos:ConnectionString",
             LeaseContainerName = "leases",
             LeaseContainerName = "leases",
+            LeaseContainerPrefix = "TEAMModelOS",
             CreateLeaseContainerIfNotExists = true,StartFromBeginning =false)] IReadOnlyList<JsonElement> input)
             CreateLeaseContainerIfNotExists = true,StartFromBeginning =false)] IReadOnlyList<JsonElement> input)
         {
         {
             if (input != null && input.Count > 0)
             if (input != null && input.Count > 0)
@@ -57,14 +58,14 @@ namespace TEAMModelOS.Function
                 foreach (var element in input) {
                 foreach (var element in input) {
                     element.TryGetProperty("_ts", out JsonElement _ts);
                     element.TryGetProperty("_ts", out JsonElement _ts);
                     element.TryGetProperty("id", out JsonElement _id);
                     element.TryGetProperty("id", out JsonElement _id);
-                    //_logger.LogInformation($"过期数据=>时间戳:{_ts.GetInt64()}-id:{_id}");
+                    //_logger.LogInformation($"过期数据=>时间戳:{_ts.GetInt64()}-id:{_id}");
                     //return;
                     //return;
 
 
                     //if (JsonValueKind.Number.Equals(_ts.ValueKind)  && 1719331200>_ts.GetInt64()) {
                     //if (JsonValueKind.Number.Equals(_ts.ValueKind)  && 1719331200>_ts.GetInt64()) {
-                    //    _logger.LogInformation($"过期数据=>时间戳:{_ts.GetInt64()}-id:{_id}"   );
+                    //    _logger.LogInformation($"过期数据=>时间戳:{_ts.GetInt64()}-id:{_id}"   );
                     //    return; 
                     //    return; 
                     //}
                     //}
-                    _logger.LogInformation("变化参数 " + element);
+                    _logger.LogInformation("鍙樺寲鍙傛暟 " + element);
                     element.TryGetProperty("pk", out JsonElement jsond);
                     element.TryGetProperty("pk", out JsonElement jsond);
                     if (!string.IsNullOrWhiteSpace($"{jsond}"))
                     if (!string.IsNullOrWhiteSpace($"{jsond}"))
                     {
                     {
@@ -72,7 +73,7 @@ namespace TEAMModelOS.Function
                             || $"{jsond}".Equals("Notice", StringComparison.OrdinalIgnoreCase)
                             || $"{jsond}".Equals("Notice", StringComparison.OrdinalIgnoreCase)
                             || $"{jsond}".Equals("ExamClassResult", StringComparison.OrdinalIgnoreCase))
                             || $"{jsond}".Equals("ExamClassResult", StringComparison.OrdinalIgnoreCase))
                         {
                         {
-                            ///通知接收者的变更
+                            ///閫氱煡鎺ユ敹鑰呯殑鍙樻洿
                             continue;
                             continue;
                         }
                         }
                         //else if ($"{jsond}".Equals("StatsNotice", StringComparison.OrdinalIgnoreCase)) 
                         //else if ($"{jsond}".Equals("StatsNotice", StringComparison.OrdinalIgnoreCase)) 
@@ -82,10 +83,10 @@ namespace TEAMModelOS.Function
                         else
                         else
                         {
                         {
                             TriggerData data = element.ToObject<TriggerData>();
                             TriggerData data = element.ToObject<TriggerData>();
-                            ///活动类型的变更
+                            ///活动类型的变更
 #if DEBUG
 #if DEBUG
-                            await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDBTrigger,{data.pk}触发变更\n{data.ToJsonString()}",
-                                            GroupNames.醍摩豆服務運維群組);
+                            await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDBTrigger,{data.pk}瑙﹀彂鍙樻洿\n{data.ToJsonString()}",
+                                            GroupNames.醍摩豆服務運維群組);
 #endif
 #endif
                             switch (data.pk)
                             switch (data.pk)
                             {
                             {

+ 73 - 73
TEAMModelOS.Function/IESHttpTrigger.cs

@@ -1,4 +1,4 @@
-using Microsoft.AspNetCore.Http;
+锘縰sing Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Azure.Functions.Worker;
 using Microsoft.Azure.Functions.Worker;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.Configuration;
@@ -161,7 +161,7 @@ namespace TEAMModelOS.Function
                             code = teacher.lang
                             code = teacher.lang
                         });
                         });
                     }
                     }
-                    //如果已经扩容请忽略此通知!
+                    //如果已经扩容请忽略此通知!
                     string key = scope.Equals("school", StringComparison.OrdinalIgnoreCase) ? $"Blob:Space:School:Notify:{name}" : $"Blob:Space:Private:Notify:{name}";
                     string key = scope.Equals("school", StringComparison.OrdinalIgnoreCase) ? $"Blob:Space:School:Notify:{name}" : $"Blob:Space:Private:Notify:{name}";
                     foreach (var idnamecode in ids)
                     foreach (var idnamecode in ids)
                     {
                     {
@@ -196,14 +196,14 @@ namespace TEAMModelOS.Function
                             }
                             }
                             else
                             else
                             {
                             {
-                                //已经发送过的不在提交
+                                //已经发送过的不在提交
                             }
                             }
                         }
                         }
                         else
                         else
                         {
                         {
                             if (blobSpaceNotify != null)
                             if (blobSpaceNotify != null)
                             {
                             {
-                                //撤销
+                                //鎾ら攢
                                 var index = blobSpaceNotify.notifyIndex;
                                 var index = blobSpaceNotify.notifyIndex;
                                 await _azureRedis.GetRedisClient(8).HashDeleteAsync(key, filed);
                                 await _azureRedis.GetRedisClient(8).HashDeleteAsync(key, filed);
                                 _coreAPIHttpService.CancelNotify(index, $"{Environment.GetEnvironmentVariable("Option:Location")}", _configuration);
                                 _coreAPIHttpService.CancelNotify(index, $"{Environment.GetEnvironmentVariable("Option:Location")}", _configuration);
@@ -215,7 +215,7 @@ namespace TEAMModelOS.Function
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {
-                    await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},空间不足,通知发送处理异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+                    await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},空间不足,通知发送处理异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
                 }
                 }
 
 
 
 
@@ -254,30 +254,30 @@ namespace TEAMModelOS.Function
                     {
                     {
                         foreach (var period in nottype_period)
                         foreach (var period in nottype_period)
                         {
                         {
-                            if (period.name.Contains("小学"))
+                            if (period.name.Contains("灏忓�"))
                             {
                             {
                                 period.periodType= "primary";
                                 period.periodType= "primary";
                             }
                             }
-                            if (period.name.Contains("初中"))
+                            if (period.name.Contains("鍒濅腑"))
                             {
                             {
                                 period.periodType = "junior";
                                 period.periodType = "junior";
                             }
                             }
-                            if (period.name.Contains("高中"))
+                            if (period.name.Contains("楂樹腑"))
                             {
                             {
                                 period.periodType = "senior";
                                 period.periodType = "senior";
                             }
                             }
                             if (string.IsNullOrWhiteSpace(period.periodType) && school.period.Count == 1)
                             if (string.IsNullOrWhiteSpace(period.periodType) && school.period.Count == 1)
                             {
                             {
-                                if (school.name.Contains("小学"))
+                                if (school.name.Contains("灏忓�"))
                                 {
                                 {
                                     period.periodType = "primary";
                                     period.periodType = "primary";
 
 
                                 }
                                 }
-                                if (school.name.Contains("初中"))
+                                if (school.name.Contains("鍒濅腑"))
                                 {
                                 {
                                     period.periodType = "junior";
                                     period.periodType = "junior";
                                 }
                                 }
-                                if (school.name.Contains("高中"))
+                                if (school.name.Contains("楂樹腑"))
                                 {
                                 {
                                     period.periodType = "senior";
                                     period.periodType = "senior";
                                 }
                                 }
@@ -292,11 +292,11 @@ namespace TEAMModelOS.Function
                     {
                     {
                         var dimension = artSetting.dimensions.FindAll(x => x.type.Intersect(new List<string> { period.periodType }).Any());
                         var dimension = artSetting.dimensions.FindAll(x => x.type.Intersect(new List<string> { period.periodType }).Any());
                         var bindIds = period.subjects.Where(s => !string.IsNullOrWhiteSpace(s.bindId)).Select(x => x.bindId);
                         var bindIds = period.subjects.Where(s => !string.IsNullOrWhiteSpace(s.bindId)).Select(x => x.bindId);
-                        //该学段未同步学科的。
+                        //该学段未同步学科的。
                         var unBindIds = dimension.Where(z => !string.IsNullOrWhiteSpace(z.subjectBind)).Select(x => x.subjectBind).ToHashSet().Except(bindIds);
                         var unBindIds = dimension.Where(z => !string.IsNullOrWhiteSpace(z.subjectBind)).Select(x => x.subjectBind).ToHashSet().Except(bindIds);
                         if (unBindIds.Any()  && unBindIds.Count()>0)
                         if (unBindIds.Any()  && unBindIds.Count()>0)
                         {
                         {
-                            //尝试寻找同名学科且没有设置bindId的
+                            //尝试寻找同名学科且没有设置bindId的
                             foreach (var unBindId in unBindIds)
                             foreach (var unBindId in unBindIds)
                             {
                             {
                                 var subjects = artSetting.dimensions.FindAll(d => !string.IsNullOrWhiteSpace(d.subjectBind) && !string.IsNullOrWhiteSpace(d.subject) && d.subjectBind.Equals(unBindId))?.Select(m => m.subject);
                                 var subjects = artSetting.dimensions.FindAll(d => !string.IsNullOrWhiteSpace(d.subjectBind) && !string.IsNullOrWhiteSpace(d.subject) && d.subjectBind.Equals(unBindId))?.Select(m => m.subject);
@@ -304,7 +304,7 @@ namespace TEAMModelOS.Function
                                 {
                                 {
                                     foreach (var subject in subjects)
                                     foreach (var subject in subjects)
                                     {
                                     {
-                                        //获取同名学科,且没绑定的
+                                        //鑾峰彇鍚屽悕瀛︾�锛屼笖娌$粦瀹氱殑
                                         var sub = period.subjects.FindAll(sub => sub.name.Contains(subject) && string.IsNullOrWhiteSpace(sub.bindId));
                                         var sub = period.subjects.FindAll(sub => sub.name.Contains(subject) && string.IsNullOrWhiteSpace(sub.bindId));
                                         if (sub.IsNotEmpty())
                                         if (sub.IsNotEmpty())
                                         {
                                         {
@@ -336,24 +336,24 @@ namespace TEAMModelOS.Function
                                     break;
                                     break;
                                 }
                                 }
 
 
-                                //同步知识块。
+                                //同步知识块。
 
 
                                 if (old != null)
                                 if (old != null)
                                 {
                                 {
                                     bool change = false;
                                     bool change = false;
-                                    //如果之前的是1 来源于区级,后面因区级删除,应该还原为0。
+                                    //如果之前的是1 来源于区级,后面因区级删除,应该还原为0。
                                     var oldBlocks = old.blocks.Select(x => x.name).ToHashSet();
                                     var oldBlocks = old.blocks.Select(x => x.name).ToHashSet();
                                     var dimBlocks = dim.SelectMany(d => d.blocks);
                                     var dimBlocks = dim.SelectMany(d => d.blocks);
-                                    //增加的
+                                    //增加的
                                     var addBlocks = dimBlocks.Except(oldBlocks);
                                     var addBlocks = dimBlocks.Except(oldBlocks);
-                                    //减少的
+                                    //减少的
                                     var cutBlocks = oldBlocks.Except(dimBlocks);
                                     var cutBlocks = oldBlocks.Except(dimBlocks);
                                     foreach (var add in addBlocks)
                                     foreach (var add in addBlocks)
                                     {
                                     {
                                         old.blocks.Add(new Block { name = add, source = 1 });
                                         old.blocks.Add(new Block { name = add, source = 1 });
                                         change = true;
                                         change = true;
                                     }
                                     }
-                                    //减少的还原为0
+                                    //鍑忓皯鐨勮繕鍘熶负0
                                     if (cutBlocks.Any())
                                     if (cutBlocks.Any())
                                     {
                                     {
                                         old.blocks.ForEach(ob => {
                                         old.blocks.ForEach(ob => {
@@ -379,7 +379,7 @@ namespace TEAMModelOS.Function
                                         await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReplaceItemAsync(old, old.id, new PartitionKey(old.code));
                                         await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReplaceItemAsync(old, old.id, new PartitionKey(old.code));
                                     }
                                     }
                                     var count = new { pcount = old.points != null ? old.points.Count : 0, bcount = old.blocks != null ? old.blocks.Count : 0 };
                                     var count = new { pcount = old.points != null ? old.points.Count : 0, bcount = old.blocks != null ? old.blocks.Count : 0 };
-                                    //处理知识点,知识块计数问题
+                                    //处理知识点,知识块计数问题
                                     await _azureRedis.GetRedisClient(8).HashSetAsync($"Knowledge:Count:{old.owner}-{old.subjectId}", old.periodId, count.ToJsonString());
                                     await _azureRedis.GetRedisClient(8).HashSetAsync($"Knowledge:Count:{old.owner}-{old.subjectId}", old.periodId, count.ToJsonString());
                                 }
                                 }
                                 else
                                 else
@@ -399,7 +399,7 @@ namespace TEAMModelOS.Function
                                         };
                                         };
                                         await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).CreateItemAsync(_new, new PartitionKey(_new.code));
                                         await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).CreateItemAsync(_new, new PartitionKey(_new.code));
                                         var count = new { pcount = _new.points != null ? _new.points.Count : 0, bcount = _new.blocks != null ? _new.blocks.Count : 0 };
                                         var count = new { pcount = _new.points != null ? _new.points.Count : 0, bcount = _new.blocks != null ? _new.blocks.Count : 0 };
-                                        //处理知识点,知识块计数问题
+                                        //处理知识点,知识块计数问题
                                         await _azureRedis.GetRedisClient(8).HashSetAsync($"Knowledge:Count:{_new.owner}-{_new.subjectId}", _new.periodId, count.ToJsonString());
                                         await _azureRedis.GetRedisClient(8).HashSetAsync($"Knowledge:Count:{_new.owner}-{_new.subjectId}", _new.periodId, count.ToJsonString());
                                     }
                                     }
                                 }
                                 }
@@ -411,7 +411,7 @@ namespace TEAMModelOS.Function
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},area-artsetting-change,{ex.Message}\n{ex.StackTrace}\n{msg}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},area-artsetting-change,{ex.Message}\n{ex.StackTrace}\n{msg}", GroupNames.醍摩豆服務運維群組);
             }
             }
             return new OkObjectResult(new { });
             return new OkObjectResult(new { });
         }
         }
@@ -424,7 +424,7 @@ namespace TEAMModelOS.Function
                 string data = await new StreamReader(req.Body).ReadToEndAsync();
                 string data = await new StreamReader(req.Body).ReadToEndAsync();
                 var json = JsonDocument.Parse(data).RootElement;
                 var json = JsonDocument.Parse(data).RootElement;
                 jsondata = json;
                 jsondata = json;
-                //await  _dingDing.SendBotMsg( "毕业状态变更:"+json.ToJsonString(), GroupNames.成都开发測試群組);
+                //await  _dingDing.SendBotMsg( "毕业状态变更:"+json.ToJsonString(), GroupNames.成都开发測試群組);
                 string schoolId = null;
                 string schoolId = null;
                 if (json.TryGetProperty("schoolId", out JsonElement _schoolId))
                 if (json.TryGetProperty("schoolId", out JsonElement _schoolId))
                 {
                 {
@@ -434,7 +434,7 @@ namespace TEAMModelOS.Function
                 {
                 {
                     return new OkObjectResult(new { });
                     return new OkObjectResult(new { });
                 }
                 }
-                //计算毕业的
+                //计算毕业的
                 if (json.TryGetProperty("graduate_classes", out JsonElement _graduate_classes))
                 if (json.TryGetProperty("graduate_classes", out JsonElement _graduate_classes))
                 {
                 {
                     List<Class> graduate_classes = _graduate_classes.ToObject<List<Class>>();
                     List<Class> graduate_classes = _graduate_classes.ToObject<List<Class>>();
@@ -461,7 +461,7 @@ namespace TEAMModelOS.Function
                         }
                         }
                     }
                     }
                 }
                 }
-                //未毕业的
+                //鏈�瘯涓氱殑
                 if (json.TryGetProperty("cancel_graduate_classes", out JsonElement _cancel_graduate_classes))
                 if (json.TryGetProperty("cancel_graduate_classes", out JsonElement _cancel_graduate_classes))
                 {
                 {
                     List<Class> cancel_graduate_classes = _cancel_graduate_classes.ToObject<List<Class>>();
                     List<Class> cancel_graduate_classes = _cancel_graduate_classes.ToObject<List<Class>>();
@@ -491,7 +491,7 @@ namespace TEAMModelOS.Function
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
-                await _dingDing.SendBotMsg($"graduate-change,{ex.Message}\n{ex.StackTrace}\n{jsondata.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"graduate-change,{ex.Message}\n{ex.StackTrace}\n{jsondata.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
             }
             }
             return new OkObjectResult(new {   });
             return new OkObjectResult(new {   });
         }
         }
@@ -525,7 +525,7 @@ namespace TEAMModelOS.Function
 
 
                     lessonRecords.ForEach(item =>
                     lessonRecords.ForEach(item =>
                     {
                     {
-                        //修改标签
+                        //淇�敼鏍囩�
                         if (!string.IsNullOrWhiteSpace(on._new))
                         if (!string.IsNullOrWhiteSpace(on._new))
                         {
                         {
                             for (int i = 0; i < item.category.Count; i++)
                             for (int i = 0; i < item.category.Count; i++)
@@ -538,7 +538,7 @@ namespace TEAMModelOS.Function
                         }
                         }
                         else
                         else
                         {
                         {
-                            //表示删除标签
+                            //琛ㄧず鍒犻櫎鏍囩�
                             item.category.RemoveAll(x => x.Equals(on._old));
                             item.category.RemoveAll(x => x.Equals(on._old));
                         }
                         }
                     });
                     });
@@ -580,7 +580,7 @@ namespace TEAMModelOS.Function
 
 
                     items.ForEach(item =>
                     items.ForEach(item =>
                     {
                     {
-                        //修改知识点
+                        //修改知识点
                         if (!string.IsNullOrEmpty(on._new))
                         if (!string.IsNullOrEmpty(on._new))
                         {
                         {
                             for (int i = 0; i < item.knowledge.Count; i++)
                             for (int i = 0; i < item.knowledge.Count; i++)
@@ -593,7 +593,7 @@ namespace TEAMModelOS.Function
                         }
                         }
                         else
                         else
                         {
                         {
-                            //表示删除知识点
+                            //表示删除知识点
                             item.knowledge.RemoveAll(x => x.Equals(on._old));
                             item.knowledge.RemoveAll(x => x.Equals(on._old));
                         }
                         }
                     });
                     });
@@ -654,17 +654,17 @@ namespace TEAMModelOS.Function
                 var cosmosClient = _azureCosmos.GetCosmosClient();
                 var cosmosClient = _azureCosmos.GetCosmosClient();
 
 
                 DateTimeOffset dateTime = DateTimeOffset.UtcNow;
                 DateTimeOffset dateTime = DateTimeOffset.UtcNow;
-                var dateHour = dateTime.ToString("yyyyMMddHH"); //获取当天的小时
-                var dateDay = dateTime.ToString("yyyyMMdd"); //获取当天的日期
-                var dateMonth = dateTime.ToString("yyyyMM");//获取当月的日期
-                var currentHour = dateTime.Hour;   //当前小时
-                var currentDay = dateTime.Day;   //当前天
-                long Expire = dateTime.AddHours(expire).ToUnixTimeMilliseconds();  //token到期时间
-                long now = dateTime.ToUnixTimeMilliseconds();   //当前时间戳
-                DateTime hour = DateTime.UtcNow.AddHours(25);   //25小时到期
-                DateTime month = DateTime.UtcNow.AddDays(32);   //一个月到期
-                var delTbHour = dateTime.AddHours(-168).ToString("yyyyMMddHH");   //168小时前
-                var delTbDay = dateTime.AddDays(-180).ToString("yyyyMMdd");   //180天前            
+                var dateHour = dateTime.ToString("yyyyMMddHH"); //获取当天的小时
+                var dateDay = dateTime.ToString("yyyyMMdd"); //获取当天的日期
+                var dateMonth = dateTime.ToString("yyyyMM");//获取当月的日期
+                var currentHour = dateTime.Hour;   //褰撳墠灏忔椂
+                var currentDay = dateTime.Day;   //当前天
+                long Expire = dateTime.AddHours(expire).ToUnixTimeMilliseconds();  //token鍒版湡鏃堕棿
+                long now = dateTime.ToUnixTimeMilliseconds();   //当前时间戳
+                DateTime hour = DateTime.UtcNow.AddHours(25);   //25灏忔椂鍒版湡
+                DateTime month = DateTime.UtcNow.AddDays(32);   //涓€涓�湀鍒版湡
+                var delTbHour = dateTime.AddHours(-168).ToString("yyyyMMddHH");   //168小时前
+                var delTbDay = dateTime.AddDays(-180).ToString("yyyyMMdd");   //180澶╁墠            
                 switch (scope)
                 switch (scope)
                 {
                 {
                     case "teacher":
                     case "teacher":
@@ -683,12 +683,12 @@ namespace TEAMModelOS.Function
                             //student.loginInfos = new List<LoginInfo>() { new LoginInfo { expire = Expire, ip = ip, time = now } };
                             //student.loginInfos = new List<LoginInfo>() { new LoginInfo { expire = Expire, ip = ip, time = now } };
                             //await cosmosClient.GetContainer("TEAMModelOS", Constant.Student).ReplaceItemAsync<Student>(student, student.id, new PartitionKey($"Base-{school}"));
                             //await cosmosClient.GetContainer("TEAMModelOS", Constant.Student).ReplaceItemAsync<Student>(student, student.id, new PartitionKey($"Base-{school}"));
                             string key = $"Login:School:{school}:student-day:{dateDay}";
                             string key = $"Login:School:{school}:student-day:{dateDay}";
-                            //记录一个学校每天每个学生登录的次数
+                            //璁板綍涓€涓��鏍℃瘡澶╂瘡涓��鐢熺櫥褰曠殑娆℃暟
                             await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync(key, id, 1);
                             await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync(key, id, 1);
-                            //获取key到期的时间
-                            await _azureRedis.GetRedisClient(8).KeyExpireAsync(key, hour);  //设置到期时间25小时
+                            //获取key到期的时间
+                            await _azureRedis.GetRedisClient(8).KeyExpireAsync(key, hour);  //璁剧疆鍒版湡鏃堕棿25灏忔椂
                         }
                         }
-                        catch (Exception ex) { await _dingDing.SendBotMsg($"{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組); }
+                        catch (Exception ex) { await _dingDing.SendBotMsg($"{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組); }
                         break;
                         break;
                     case "tmduser":
                     case "tmduser":
                         try
                         try
@@ -701,25 +701,25 @@ namespace TEAMModelOS.Function
                         break;
                         break;
                 }
                 }
 
 
-                //天
+                //天
                 SortedSetEntry[] dayCnt = null;
                 SortedSetEntry[] dayCnt = null;
-                //月
+                //月
                 SortedSetEntry[] monthCnt = null;
                 SortedSetEntry[] monthCnt = null;
                 try
                 try
                 {
                 {
-                    await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Login:IES:{scope}:{dateDay}", $"{currentHour}", 1);//一天24小时  小时为单位
-                    await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Login:IES:{scope}:{dateMonth}", $"{currentDay}", 1); //一天的累计   天为单位
+                    await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Login:IES:{scope}:{dateDay}", $"{currentHour}", 1);//一天24小时  小时为单位
+                    await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Login:IES:{scope}:{dateMonth}", $"{currentDay}", 1); //涓€澶╃殑绱��   澶╀负鍗曚綅
 
 
                     var resDay = await _azureRedis.GetRedisClient(8).KeyTimeToLiveAsync($"Login:IES:{scope}:{dateDay}");
                     var resDay = await _azureRedis.GetRedisClient(8).KeyTimeToLiveAsync($"Login:IES:{scope}:{dateDay}");
                     if (resDay == null)
                     if (resDay == null)
-                        await _azureRedis.GetRedisClient(8).KeyExpireAsync($"Login:IES:{scope}:{dateDay}", hour);  //设置到期时间
+                        await _azureRedis.GetRedisClient(8).KeyExpireAsync($"Login:IES:{scope}:{dateDay}", hour);  //璁剧疆鍒版湡鏃堕棿
                     var rspMonth = await _azureRedis.GetRedisClient(8).KeyTimeToLiveAsync($"Login:IES:{scope}:{dateMonth}");
                     var rspMonth = await _azureRedis.GetRedisClient(8).KeyTimeToLiveAsync($"Login:IES:{scope}:{dateMonth}");
                     if (rspMonth == null)
                     if (rspMonth == null)
-                        await _azureRedis.GetRedisClient(8).KeyExpireAsync($"Login:IES:{scope}:{dateMonth}", month);  //设置到期时间
+                        await _azureRedis.GetRedisClient(8).KeyExpireAsync($"Login:IES:{scope}:{dateMonth}", month);  //璁剧疆鍒版湡鏃堕棿
 
 
-                    //保存当前小时统计
+                    //淇濆瓨褰撳墠灏忔椂缁熻�
                     dayCnt = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Login:IES:{scope}:{dateDay}");
                     dayCnt = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Login:IES:{scope}:{dateDay}");
-                    //保存当前的统计数据
+                    //保存当前的统计数据
                     monthCnt = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Login:IES:{scope}:{dateMonth}");
                     monthCnt = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Login:IES:{scope}:{dateMonth}");
                 }
                 }
                 catch { }
                 catch { }
@@ -769,7 +769,7 @@ namespace TEAMModelOS.Function
                             }
                             }
                         }
                         }
                     }
                     }
-                    await table.SaveOrUpdateAll(hourLogins);  //保存和更新保存当前小时登录次数
+                    await table.SaveOrUpdateAll(hourLogins);  //保存和更新保存当前小时登录次数
                 }
                 }
                 if (monthCnt != null && monthCnt.Length > 0)
                 if (monthCnt != null && monthCnt.Length > 0)
                 {
                 {
@@ -778,7 +778,7 @@ namespace TEAMModelOS.Function
                     {
                     {
                         if (((int)mCnt.Element) == currentDay)
                         if (((int)mCnt.Element) == currentDay)
                         {
                         {
-                            //保存当天的峰值
+                            //保存当天的峰值
                             var tbDays = await table.QueryWhereString<DayLogin>($"PartitionKey eq 'DayLogin' and RowKey eq '{dateDay}'");
                             var tbDays = await table.QueryWhereString<DayLogin>($"PartitionKey eq 'DayLogin' and RowKey eq '{dateDay}'");
                             if (tbDays.Count > 0)
                             if (tbDays.Count > 0)
                             {
                             {
@@ -795,7 +795,7 @@ namespace TEAMModelOS.Function
                             }
                             }
                             else
                             else
                             {
                             {
-                                //保存当月每天的峰值
+                                //保存当月每天的峰值
                                 DayLogin dayLogin = new() { PartitionKey = $"DayLogin", RowKey = dateDay, Day = currentDay };
                                 DayLogin dayLogin = new() { PartitionKey = $"DayLogin", RowKey = dateDay, Day = currentDay };
                                 if (scope.Equals("teacher"))
                                 if (scope.Equals("teacher"))
                                 {
                                 {
@@ -819,7 +819,7 @@ namespace TEAMModelOS.Function
                             }
                             }
                         }
                         }
                     }
                     }
-                    await table.SaveOrUpdateAll(dayLogins);// 保存当月每天在线数据
+                    await table.SaveOrUpdateAll(dayLogins);// 淇濆瓨褰撴湀姣忓ぉ鍦ㄧ嚎鏁版嵁
                 }
                 }
 
 
                 string tbHourSql = $"PartitionKey eq 'HourLogin' and RowKey le '{delTbHour}'";
                 string tbHourSql = $"PartitionKey eq 'HourLogin' and RowKey le '{delTbHour}'";
@@ -827,32 +827,32 @@ namespace TEAMModelOS.Function
                 string tbDaySql = $"PartitionKey eq 'DayLogin' and RowKey le '{delTbDay}'";
                 string tbDaySql = $"PartitionKey eq 'DayLogin' and RowKey le '{delTbDay}'";
                 try
                 try
                 {
                 {
-                    await table.DeleteStringWhere<HourLogin>(rowKey: tbHourSql);  //删除168小时前的数据
-                    await table.DeleteStringWhere<DayLogin>(rowKey: tbDaySql);   //删除180天前的数据
+                    await table.DeleteStringWhere<HourLogin>(rowKey: tbHourSql);  //鍒犻櫎168灏忔椂鍓嶇殑鏁版嵁
+                    await table.DeleteStringWhere<DayLogin>(rowKey: tbDaySql);   //删除180天前的数据
                 }
                 }
                 catch { }
                 catch { }
 
 
                 if (!string.IsNullOrWhiteSpace(school))
                 if (!string.IsNullOrWhiteSpace(school))
                 {
                 {
-                    //天
+                    //天
                     SortedSetEntry[] scDayCnt = null;
                     SortedSetEntry[] scDayCnt = null;
-                    //月
+                    //月
                     SortedSetEntry[] scMonthCnt = null;
                     SortedSetEntry[] scMonthCnt = null;
                     try
                     try
                     {
                     {
-                        await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Login:School:{school}:{scope}:{dateDay}", $"{currentHour}", 1);//当天当前小时在线人加1
-                        await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Login:School:{school}:{scope}:{dateMonth}", $"{currentDay}", 1); //当天的在线加1
+                        await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Login:School:{school}:{scope}:{dateDay}", $"{currentHour}", 1);//褰撳ぉ褰撳墠灏忔椂鍦ㄧ嚎浜哄姞1
+                        await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Login:School:{school}:{scope}:{dateMonth}", $"{currentDay}", 1); //褰撳ぉ鐨勫湪绾垮姞1
 
 
                         var reScDay = await _azureRedis.GetRedisClient(8).KeyTimeToLiveAsync($"Login:School:{school}:{scope}:{dateDay}");
                         var reScDay = await _azureRedis.GetRedisClient(8).KeyTimeToLiveAsync($"Login:School:{school}:{scope}:{dateDay}");
                         if (reScDay == null)
                         if (reScDay == null)
-                            await _azureRedis.GetRedisClient(8).KeyExpireAsync($"Login:School:{school}:{scope}:{dateDay}", hour);  //设置到期时间
+                            await _azureRedis.GetRedisClient(8).KeyExpireAsync($"Login:School:{school}:{scope}:{dateDay}", hour);  //璁剧疆鍒版湡鏃堕棿
                         var reScMonth = await _azureRedis.GetRedisClient(8).KeyTimeToLiveAsync($"Login:School:{school}:{scope}:{dateMonth}");
                         var reScMonth = await _azureRedis.GetRedisClient(8).KeyTimeToLiveAsync($"Login:School:{school}:{scope}:{dateMonth}");
                         if (reScMonth == null)
                         if (reScMonth == null)
-                            await _azureRedis.GetRedisClient(8).KeyExpireAsync($"Login:School:{school}:{scope}:{dateMonth}", month);  //设置到期时间
+                            await _azureRedis.GetRedisClient(8).KeyExpireAsync($"Login:School:{school}:{scope}:{dateMonth}", month);  //璁剧疆鍒版湡鏃堕棿
 
 
-                        //保存学校当天每小时的
+                        //淇濆瓨瀛︽牎褰撳ぉ姣忓皬鏃剁殑
                         scDayCnt = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Login:School:{school}:{scope}:{dateDay}");
                         scDayCnt = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Login:School:{school}:{scope}:{dateDay}");
-                        //学校天峰值
+                        //学校天峰值
                         scMonthCnt = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Login:School:{school}:{scope}:{dateMonth}");
                         scMonthCnt = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Login:School:{school}:{scope}:{dateMonth}");
                     }
                     }
                     catch { }
                     catch { }
@@ -880,7 +880,7 @@ namespace TEAMModelOS.Function
                                 }
                                 }
                                 else
                                 else
                                 {
                                 {
-                                    //学校小时峰值
+                                    //学校小时峰值
                                     HourLoginSchool hourLoginSc = new() { PartitionKey = $"HourLogin-{school}", RowKey = dateHour, Hour = currentHour, School = school };
                                     HourLoginSchool hourLoginSc = new() { PartitionKey = $"HourLogin-{school}", RowKey = dateHour, Hour = currentHour, School = school };
                                     if (scope.Equals("teacher"))
                                     if (scope.Equals("teacher"))
                                     {
                                     {
@@ -929,7 +929,7 @@ namespace TEAMModelOS.Function
                                 }
                                 }
                                 else
                                 else
                                 {
                                 {
-                                    //学校天峰值
+                                    //学校天峰值
                                     DayLoginSchool dayLoginSc = new() { PartitionKey = $"DayLogin-{school}", RowKey = dateDay, Day = currentDay, School = school };
                                     DayLoginSchool dayLoginSc = new() { PartitionKey = $"DayLogin-{school}", RowKey = dateDay, Day = currentDay, School = school };
                                     if (scope.Equals("teacher"))
                                     if (scope.Equals("teacher"))
                                     {
                                     {
@@ -954,7 +954,7 @@ namespace TEAMModelOS.Function
                                 }
                                 }
                             }
                             }
                         }
                         }
-                        await table.SaveOrUpdateAll(DayLoginSchools);//保存学校当月在线数据
+                        await table.SaveOrUpdateAll(DayLoginSchools);//淇濆瓨瀛︽牎褰撴湀鍦ㄧ嚎鏁版嵁
                     }
                     }
 
 
                     string tbScHourSql = $"PartitionKey eq 'HourLogin-{school}' and RowKey le '{delTbHour}'";
                     string tbScHourSql = $"PartitionKey eq 'HourLogin-{school}' and RowKey le '{delTbHour}'";
@@ -962,7 +962,7 @@ namespace TEAMModelOS.Function
                     if (scHourLog.Count > 0)
                     if (scHourLog.Count > 0)
                         try
                         try
                         {
                         {
-                            //await table.DeleteStringWhere<HourLogin>(tbScHourSql); //删除学校168小时前的数据
+                            //await table.DeleteStringWhere<HourLogin>(tbScHourSql); //鍒犻櫎瀛︽牎168灏忔椂鍓嶇殑鏁版嵁
                             await table.DeleteAll(scHourLog);
                             await table.DeleteAll(scHourLog);
                         }
                         }
                         catch { }
                         catch { }
@@ -971,7 +971,7 @@ namespace TEAMModelOS.Function
                     if (scDayLog.Count > 0)
                     if (scDayLog.Count > 0)
                         try
                         try
                         {
                         {
-                            //await table.DeleteStringWhere<DayLogin>(tbScDaySql); //删除学校180天前的数据
+                            //await table.DeleteStringWhere<DayLogin>(tbScDaySql); //删除学校180天前的数据
                             await table.DeleteAll(scDayLog);
                             await table.DeleteAll(scDayLog);
                         }
                         }
                         catch { }
                         catch { }
@@ -981,7 +981,7 @@ namespace TEAMModelOS.Function
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-online-record 人数记录异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-online-record 人数记录异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
                 return new OkObjectResult(new { data = json });
                 return new OkObjectResult(new { data = json });
             }
             }
         }
         }

Datei-Diff unterdrückt, da er zu groß ist
+ 803 - 799
TEAMModelOS.Function/IESServiceBusTrigger.cs


+ 8 - 8
TEAMModelOS.Function/IESTimerTrigger.cs

@@ -1,4 +1,4 @@
-using System;
+锘縰sing System;
 using DinkToPdf.Contracts;
 using DinkToPdf.Contracts;
 using Microsoft.Azure.Functions.Worker;
 using Microsoft.Azure.Functions.Worker;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.Configuration;
@@ -13,8 +13,8 @@ namespace TEAMModelOS.Function
     {
     {
         private readonly ILogger _logger;
         private readonly ILogger _logger;
         /// <summary>
         /// <summary>
-        /// 文档。https://docs.microsoft.com/zh-cn/azure/azure-functions/functions-bindings-timer?tabs=in-process&pivots=programming-language-csharp
-        /// Timer 在线测试  https://ncrontab.swimburger.net/
+        /// 鏂囨。銆俬ttps://docs.microsoft.com/zh-cn/azure/azure-functions/functions-bindings-timer?tabs=in-process&pivots=programming-language-csharp
+        /// Timer 鍦ㄧ嚎娴嬭瘯  https://ncrontab.swimburger.net/
         /// </summary>
         /// </summary>
         private readonly AzureCosmosFactory _azureCosmos;
         private readonly AzureCosmosFactory _azureCosmos;
         private readonly DingDing _dingDing;
         private readonly DingDing _dingDing;
@@ -44,8 +44,8 @@ namespace TEAMModelOS.Function
 
 
 
 
         /// <summary>
         /// <summary>
-        /// //0 1 * * * * 一天中每小时的第 1 分钟
-        ///0 */10 * * * *  每五分钟一次
+        /// //0 1 * * * * 一天中每小时的第 1 分钟
+        ///0 */10 * * * *  每五分钟一次
         /// </summary>
         /// </summary>
         /// <param name="myTimer"></param>
         /// <param name="myTimer"></param>
         /// <returns></returns>
         /// <returns></returns>
@@ -55,7 +55,7 @@ namespace TEAMModelOS.Function
             _logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
             _logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
             try
             try
             {
             {
-                await _dingDing.SendBotMsg($"{_coreAPIHttpService.options.location},定时任务{DateTimeOffset.Now.ToString("yyyy-MM-dd HH:mm:ss")}", GroupNames.成都开发測試群組);
+                await _dingDing.SendBotMsg($"{_coreAPIHttpService.options.location},定时任务{DateTimeOffset.Now.ToString("yyyy-MM-dd HH:mm:ss")}", GroupNames.成都开发測試群組);
                 string local = Environment.GetEnvironmentVariable("Option:Location");
                 string local = Environment.GetEnvironmentVariable("Option:Location");
                 // if (local.Contains("Test")||local.Contains("Dep"))
                 // if (local.Contains("Test")||local.Contains("Dep"))
                 {
                 {
@@ -88,12 +88,12 @@ namespace TEAMModelOS.Function
                         client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
                         client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");
                     }
                     }
                     var data = await TEAMModelOS.SDK.Models.Service.SystemService.AccumulateDaily(_configuration, _azureRedis, _azureCosmos, _coreAPIHttpService, _dingDing, client, _snowflakeId, url, am, pm);
                     var data = await TEAMModelOS.SDK.Models.Service.SystemService.AccumulateDaily(_configuration, _azureRedis, _azureCosmos, _coreAPIHttpService, _dingDing, client, _snowflakeId, url, am, pm);
-                    //await _dingDing.SendBotMsg($"返回数据{data.ToJsonString()}", GroupNames.成都开发測試群組);
+                    //await _dingDing.SendBotMsg($"返回数据{data.ToJsonString()}", GroupNames.成都开发測試群組);
                 }
                 }
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
-                await _dingDing.SendBotMsg($"{DailyReport}\n{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+                await _dingDing.SendBotMsg($"{DailyReport}\n{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
             }
             }
 
 
             if (myTimer.ScheduleStatus is not null)
             if (myTimer.ScheduleStatus is not null)

+ 174 - 0
TEAMModelOS.Function/Properties/ServiceDependencies/TEAMModelOSFunction - Zip Deploy/profile.arm.json

@@ -0,0 +1,174 @@
+{
+  "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
+  "contentVersion": "1.0.0.0",
+  "metadata": {
+    "_dependencyType": "compute.function.windows.appService"
+  },
+  "parameters": {
+    "resourceGroupName": {
+      "type": "string",
+      "defaultValue": "TEAMModelChengdu",
+      "metadata": {
+        "description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
+      }
+    },
+    "resourceGroupLocation": {
+      "type": "string",
+      "defaultValue": "",
+      "metadata": {
+        "description": "Location of the resource group. Resource groups could have different location than resources, however by default we use API versions from latest hybrid profile which support all locations for resource types we support."
+      }
+    },
+    "resourceName": {
+      "type": "string",
+      "defaultValue": "TEAMModelOSFunction",
+      "metadata": {
+        "description": "Name of the main resource to be created by this template."
+      }
+    },
+    "resourceLocation": {
+      "type": "string",
+      "defaultValue": "[parameters('resourceGroupLocation')]",
+      "metadata": {
+        "description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
+      }
+    }
+  },
+  "resources": [
+    {
+      "type": "Microsoft.Resources/resourceGroups",
+      "name": "[parameters('resourceGroupName')]",
+      "location": "[parameters('resourceGroupLocation')]",
+      "apiVersion": "2019-10-01"
+    },
+    {
+      "type": "Microsoft.Resources/deployments",
+      "name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
+      "resourceGroup": "[parameters('resourceGroupName')]",
+      "apiVersion": "2019-10-01",
+      "dependsOn": [
+        "[parameters('resourceGroupName')]"
+      ],
+      "properties": {
+        "mode": "Incremental",
+        "expressionEvaluationOptions": {
+          "scope": "inner"
+        },
+        "parameters": {
+          "resourceGroupName": {
+            "value": "[parameters('resourceGroupName')]"
+          },
+          "resourceGroupLocation": {
+            "value": "[parameters('resourceGroupLocation')]"
+          },
+          "resourceName": {
+            "value": "[parameters('resourceName')]"
+          },
+          "resourceLocation": {
+            "value": "[parameters('resourceLocation')]"
+          }
+        },
+        "template": {
+          "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
+          "contentVersion": "1.0.0.0",
+          "parameters": {
+            "resourceGroupName": {
+              "type": "string"
+            },
+            "resourceGroupLocation": {
+              "type": "string"
+            },
+            "resourceName": {
+              "type": "string"
+            },
+            "resourceLocation": {
+              "type": "string"
+            }
+          },
+          "variables": {
+            "storage_name": "[toLower(concat('storage', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId))))]",
+            "appServicePlan_name": "[concat('Plan', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
+            "storage_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Storage/storageAccounts/', variables('storage_name'))]",
+            "appServicePlan_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Web/serverFarms/', variables('appServicePlan_name'))]",
+            "function_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Web/sites/', parameters('resourceName'))]"
+          },
+          "resources": [
+            {
+              "location": "[parameters('resourceLocation')]",
+              "name": "[parameters('resourceName')]",
+              "type": "Microsoft.Web/sites",
+              "apiVersion": "2015-08-01",
+              "tags": {
+                "[concat('hidden-related:', variables('appServicePlan_ResourceId'))]": "empty"
+              },
+              "dependsOn": [
+                "[variables('appServicePlan_ResourceId')]",
+                "[variables('storage_ResourceId')]"
+              ],
+              "kind": "functionapp",
+              "properties": {
+                "name": "[parameters('resourceName')]",
+                "kind": "functionapp",
+                "httpsOnly": true,
+                "reserved": false,
+                "serverFarmId": "[variables('appServicePlan_ResourceId')]",
+                "siteConfig": {
+                  "alwaysOn": true
+                }
+              },
+              "identity": {
+                "type": "SystemAssigned"
+              },
+              "resources": [
+                {
+                  "name": "appsettings",
+                  "type": "config",
+                  "apiVersion": "2015-08-01",
+                  "dependsOn": [
+                    "[variables('function_ResourceId')]"
+                  ],
+                  "properties": {
+                    "AzureWebJobsStorage": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storage_name'), ';AccountKey=', listKeys(variables('storage_ResourceId'), '2017-10-01').keys[0].value, ';EndpointSuffix=', 'core.windows.net')]",
+                    "FUNCTIONS_EXTENSION_VERSION": "~3",
+                    "FUNCTIONS_WORKER_RUNTIME": "dotnet"
+                  }
+                }
+              ]
+            },
+            {
+              "location": "[parameters('resourceGroupLocation')]",
+              "name": "[variables('storage_name')]",
+              "type": "Microsoft.Storage/storageAccounts",
+              "apiVersion": "2017-10-01",
+              "tags": {
+                "[concat('hidden-related:', concat('/providers/Microsoft.Web/sites/', parameters('resourceName')))]": "empty"
+              },
+              "properties": {
+                "supportsHttpsTrafficOnly": true
+              },
+              "sku": {
+                "name": "Standard_LRS"
+              },
+              "kind": "Storage"
+            },
+            {
+              "location": "[parameters('resourceGroupLocation')]",
+              "name": "[variables('appServicePlan_name')]",
+              "type": "Microsoft.Web/serverFarms",
+              "apiVersion": "2015-08-01",
+              "sku": {
+                "name": "S1",
+                "tier": "Standard",
+                "family": "S",
+                "size": "S1"
+              },
+              "properties": {
+                "name": "[variables('appServicePlan_name')]"
+              }
+            }
+          ]
+        }
+      }
+    }
+  ]
+}

Datei-Diff unterdrückt, da er zu groß ist
+ 51 - 0
TEAMModelOS.HTEXLib/COMM/Globals.cs


+ 43 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/CollectionHelper.cs

@@ -0,0 +1,43 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HTEXLib.COMM.Helpers
+{
+    public static class CollectionHelper
+    {
+        /// <summary>
+        /// 判断集合是否为空
+        /// </summary>
+        /// <param name="collection"></param>
+        /// <returns></returns>
+        public static bool IsEmpty(this ICollection collection)
+        {
+            if (collection != null && collection.Count > 0)
+            {
+                return false;
+            }
+            else
+            {
+                return true;
+            }
+        }
+        /// <summary>
+        /// 判断集合是否不为空
+        /// </summary>
+        /// <param name="collection"></param>
+        /// <returns></returns>
+        public static bool IsNotEmpty(this ICollection collection)
+        {
+            if (collection != null && collection.Count > 0)
+            {
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
+    }
+}

+ 395 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/ContentTypeDict.cs

@@ -0,0 +1,395 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HTEXLib.COMM.Helpers
+{
+    public static class ContentTypeDict
+    {
+        public static readonly Dictionary<string, string> extdict = new Dictionary<string, string> {
+            //{ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".xlsx"},
+            { "audio/x-ms-wma",".wma"},
+            {"video/3gpp",".3g2"},
+{"audio/mp4",".aac"},
+{"audio/ac3",".ac3"},
+{"text/x-adasrc",".adb"},
+{"image/x-applix-graphics",".ag"},
+{"audio/amr",".amr"},
+{"audio/x-ape",".ape"},
+{"image/x-sony-arw",".arw"},
+{"text/plain",".asc"},
+{"video/x-ms-asf",".asf"},
+{"text/x-ssa",".ass"},
+{"video/x-msvideo",".avi"},
+{"text/x-bibtex",".bib"},
+{"image/bmp",".bmp"},
+{"text/x-csrc",".c"},
+{"text/x-c++src",".c++"},
+{"image/cgm",".cgm"},
+{"text/x-tex",".cls"},
+{"text/x-cmake",".cmake"},
+{"image/x-canon-cr2",".cr2"},
+{"image/x-canon-crw",".crw"},
+{"text/x-csharp",".cs"},
+{"text/css",".css"},
+{"text/csv",".csv"},
+{"image/x-win-bitmap",".cur"},
+{"text/x-dsrc",".d"},
+{"text/x-dcl",".dcl"},
+{"image/x-kodak-dcr",".dcr"},
+{"image/x-dds",".dds"},
+{"text/x-patch",".diff"},
+{"image/vnd.djvu",".djv"},
+{"image/x-adobe-dng",".dng"},
+{"text/vnd.graphviz",".dot"},
+{"text/x-dsl",".dsl"},
+{"image/vnd.dwg",".dwg"},
+{"image/vnd.dxf",".dxf"},
+{"text/x-eiffel",".e"},
+{"text/x-emacs-lisp",".el"},
+{"image/x-emf",".emf"},
+{"image/x-eps",".eps"},
+{"image/x-bzeps",".eps.bz2"},
+{"image/x-gzeps",".eps.gz"},
+{"text/x-erlang",".erl"},
+{"text/x-setext",".etx"},
+{"image/x-exr",".exr"},
+{"text/x-fortran",".f"},
+{"image/x-xfig",".fig"},
+{"image/fits",".fits"},
+{"video/x-flv",".flv"},
+{"text/x-xslfo",".fo"},
+{"image/fax-g3",".g3"},
+{"text/directory",".gcrd"},
+{"image/gif",".gif"},
+{"text/x-google-video-pointer",".gvp"},
+{"text/x-chdr",".h"},
+{"text/x-c++hdr",".h++"},
+{"text/x-haskell",".hs"},
+{"text/html",".htm"},
+{"image/x-tga",".icb"},
+{"image/x-icns",".icns"},
+{"image/x-icon",".ico"},
+{"text/calendar",".ics"},
+{"text/x-idl",".idl"},
+{"image/ief",".ief"},
+{"image/x-iff",".iff"},
+{"image/x-ilbm",".ilbm"},
+{"text/x-imelody",".ime"},
+{"text/x-iptables",".iptables"},
+{"image/jp2",".j2k"},
+{"text/vnd.sun.j2me.app-descriptor",".jad"},
+{"text/x-java",".java"},
+{"image/x-jng",".jng"},
+{"image/jpeg",".jpeg"},
+{"application/javascript",".js"},
+{"application/json",".json"},
+{"application/jsonp",".jsonp"},
+{"image/x-kodak-k25",".k25"},
+{"image/x-kodak-kdc",".kdc"},
+{"text/x-ldif",".ldif"},
+{"text/x-literate-haskell",".lhs"},
+{"text/x-log",".log"},
+{"text/x-lua",".lua"},
+{"image/x-lwo",".lwo"},
+{"image/x-lws",".lws"},
+{"text/x-lilypond",".ly"},
+{"text/x-matlab",".m"},
+{"video/mpeg",".m2t"},
+{"audio/x-mpegurl",".m3u"},
+{"application/vnd.apple.mpegurl",".m3u8"},
+{"text/x-troff-me",".me"},
+{"video/x-matroska",".mkv"},
+{"text/x-ocaml",".ml"},
+{"text/x-troff-mm",".mm"},
+{"text/mathml",".mml"},
+{"text/x-moc",".moc"},
+{"text/x-mof",".mof"},
+{"audio/mpeg",".mp3"},
+{"video/mp4",".mp4"},
+{"text/x-mrml",".mrl"},
+{"image/x-minolta-mrw",".mrw"},
+{"text/x-troff-ms",".ms"},
+{"image/x-msod",".msod"},
+{"text/x-mup",".mup"},
+{"image/x-nikon-nef",".nef"},
+{"text/x-nfo",".nfo"},
+{"text/x-ocl",".ocl"},
+{"text/x-opml+xml",".opml"},
+{"image/openraster",".ora"},
+{"image/x-olympus-orf",".orf"},
+{"text/x-pascal",".p"},
+{"image/x-portable-bitmap",".pbm"},
+{"image/x-photo-cd",".pcd"},
+{"image/x-pcx",".pcx"},
+{"application/pdf",".pdf"},
+{"image/x-pentax-pef",".pef"},
+{"image/x-portable-graymap",".pgm"},
+{"image/x-pict",".pict"},
+{"image/png",".png"},
+{"image/x-portable-anymap",".pnm"},
+{"image/x-macpaint",".pntg"},
+{"text/x-gettext-translation",".po"},
+{"text/x-gettext-translation-template",".pot"},
+{"text/x-python",".py"},
+{"image/x-quicktime",".qif"},
+{"image/x-fuji-raf",".raf"},
+{"image/x-cmu-raster",".ras"},
+{"image/x-panasonic-raw",".raw"},
+{"text/x-ms-regedit",".reg"},
+{"image/x-rgb",".rgb"},
+{"image/rle",".rle"},
+{"text/troff",".roff"},
+{"image/vnd.rn-realpix",".rp"},
+{"text/vnd.rn-realtext",".rt"},
+{"text/richtext",".rtx"},
+{"text/x-scheme",".scm"},
+{"image/x-sgi",".sgi"},
+{"text/sgml",".sgm"},
+{"image/x-skencil",".sk"},
+{"text/spreadsheet",".slk"},
+{"text/x-rpm-spec",".spec"},
+{"text/x-sql",".sql"},
+{"image/x-sony-sr2",".sr2"},
+{"image/x-sony-srf",".srf"},
+{"text/x-subviewer",".sub"},
+{"image/x-sun-raster",".sun"},
+{"image/svg+xml",".svg"},
+{"image/svg+xml-compressed",".svgz"},
+{"text/x-txt2tags",".t2t"},
+{"text/x-tcl",".tcl"},
+{"text/x-texinfo",".texi"},
+{"image/tiff",".tif"},
+{"audio/x-voc",".voc"},
+{"image/x-wmf",".wmf"},
+{"text/vnd.wap.wml",".wml"},
+{"text/vnd.wap.wmlscript",".wmls"},
+{"video/x-ms-wmv",".wmv"},
+{"application/xhtml+xml",".xhtml"},
+{"application/xml",".xml"}
+        };
+
+        public static readonly Dictionary<string, string> dict = new Dictionary<string, string> {
+            {".3g2", "video/3gpp"},
+            {".3ga", "video/3gpp"},
+            {".3gp", "video/3gpp"},
+            {".aac", "audio/mp4"},
+            {".ac3", "audio/ac3"},
+            {".adb", "text/x-adasrc"},
+            {".ads", "text/x-adasrc"},
+            {".ag", "image/x-applix-graphics"},
+            {".amr", "audio/amr"},
+            {".ape", "audio/x-ape"},
+            {".arw", "image/x-sony-arw"},
+            {".asc", "text/plain"},
+            {".asf", "video/x-ms-asf"},
+            {".ass", "text/x-ssa"},
+            {".avi", "video/x-msvideo"},
+            {".bib", "text/x-bibtex"},
+            {".bmp", "image/bmp"},
+            {".c", "text/x-csrc"},
+            {".c++", "text/x-c++src"},
+            {".cc", "text/x-c++src"},
+            {".cgm", "image/cgm"},
+            {".cls", "text/x-tex"},
+            {".cmake", "text/x-cmake"},
+            {".cpp", "text/x-c++src"},
+            {".cr2", "image/x-canon-cr2"},
+            {".crw", "image/x-canon-crw"},
+            {".cs", "text/x-csharp"},
+            {".css", "text/css"},
+            {".cssl", "text/css"},
+            {".csv", "text/csv"},
+            {".cur", "image/x-win-bitmap"},
+            {".cxx", "text/x-c++src"},
+            {".d", "text/x-dsrc"},
+            {".dcl", "text/x-dcl"},
+            {".dcr", "image/x-kodak-dcr"},
+            {".dds", "image/x-dds"},
+            {".diff", "text/x-patch"},
+            {".djv", "image/vnd.djvu"},
+            {".djvu", "image/vnd.djvu"},
+            {".dng", "image/x-adobe-dng"},
+            {".dot", "text/vnd.graphviz"},
+            {".dsl", "text/x-dsl"},
+            {".dtx", "text/x-tex"},
+            {".dwg", "image/vnd.dwg"},
+            {".dxf", "image/vnd.dxf"},
+            {".e", "text/x-eiffel"},
+            {".eif", "text/x-eiffel"},
+            {".el", "text/x-emacs-lisp"},
+            {".emf", "image/x-emf"},
+            {".eps", "image/x-eps"},
+            {".eps.bz2", "image/x-bzeps"},
+            {".eps.gz", "image/x-gzeps"},
+            {".epsf", "image/x-eps"},
+            {".epsf.bz2", "image/x-bzeps"},
+            {".epsf.gz", "image/x-gzeps"},
+            {".epsi", "image/x-eps"},
+            {".epsi.bz2", "image/x-bzeps"},
+            {".epsi.gz", "image/x-gzeps"},
+            {".erl", "text/x-erlang"},
+            {".etx", "text/x-setext"},
+            {".exr", "image/x-exr"},
+            {".f", "text/x-fortran"},
+            {".f90", "text/x-fortran"},
+            {".f95", "text/x-fortran"},
+            {".fig", "image/x-xfig"},
+            {".fits", "image/fits"},
+            {".flv", "video/x-flv"},
+            {".fo", "text/x-xslfo"},
+            {".for", "text/x-fortran"},
+            {".g3", "image/fax-g3"},
+            {".gcrd", "text/directory"},
+            {".gif", "image/gif"},
+            {".gv", "text/vnd.graphviz"},
+            {".gvp", "text/x-google-video-pointer"},
+            {".h", "text/x-chdr"},
+            {".h++", "text/x-c++hdr"},
+            {".hh", "text/x-c++hdr"},
+            {".hp", "text/x-c++hdr"},
+            {".hpp", "text/x-c++hdr"},
+            {".hs", "text/x-haskell"},
+            {".htm", "text/html"},
+            {".html", "text/html"},
+            {".hxx", "text/x-c++hdr"},
+            {".icb", "image/x-tga"},
+            {".icns", "image/x-icns"},
+            {".ico", "image/x-icon"},
+            {".ics", "text/calendar"},
+            {".idl", "text/x-idl"},
+            {".ief", "image/ief"},
+            {".iff", "image/x-iff"},
+            {".ilbm", "image/x-ilbm"},
+            {".ime", "text/x-imelody"},
+            {".imy", "text/x-imelody"},
+            {".ins", "text/x-tex"},
+            {".iptables", "text/x-iptables"},
+            {".j2k", "image/jp2"},
+            {".jad", "text/vnd.sun.j2me.app-descriptor"},
+            {".java", "text/x-java"},
+            {".jng", "image/x-jng"},
+            {".jp2", "image/jp2"},
+            {".jpc", "image/jp2"},
+            {".jpe", "image/jpeg"},
+            {".jpeg", "image/jpeg"},
+            {".jpf", "image/jp2"},
+            {".jpg", "image/jpeg"},
+            {".jpx", "image/jp2"},
+            {".js", "application/javascript"},
+            {".json", "application/json"},
+            {".jsonp", "application/jsonp"},
+            {".k25", "image/x-kodak-k25"},
+            {".kdc", "image/x-kodak-kdc"},
+            {".latex", "text/x-tex"},
+            {".ldif", "text/x-ldif"},
+            {".lhs", "text/x-literate-haskell"},
+            {".log", "text/x-log"},
+            {".ltx", "text/x-tex"},
+            {".lua", "text/x-lua"},
+            {".lwo", "image/x-lwo"},
+            {".lwob", "image/x-lwo"},
+            {".lws", "image/x-lws"},
+            {".ly", "text/x-lilypond"},
+            {".m", "text/x-matlab"},
+            {".m2t", "video/mpeg"},
+            {".m3u", "audio/x-mpegurl"},
+            {".m3u8", "application/vnd.apple.mpegurl"},
+            {".me", "text/x-troff-me"},
+            {".mkv", "video/x-matroska"},
+            {".ml", "text/x-ocaml"},
+            {".mli", "text/x-ocaml"},
+            {".mm", "text/x-troff-mm"},
+            {".mml", "text/mathml"},
+            {".moc", "text/x-moc"},
+            {".mof", "text/x-mof"},
+            {".mp2", "video/mpeg"},
+            {".mp3", "audio/mpeg"},
+            {".mp4", "video/mp4"},
+            {".mpe", "video/mpeg"},
+            {".mpeg", "video/mpeg"},
+            {".mpg", "video/mpeg"},
+            {".mrl", "text/x-mrml"},
+            {".mrml", "text/x-mrml"},
+            {".mrw", "image/x-minolta-mrw"},
+            {".ms", "text/x-troff-ms"},
+            {".msod", "image/x-msod"},
+            {".mup", "text/x-mup"},
+            {".nef", "image/x-nikon-nef"},
+            {".nfo", "text/x-nfo"},
+            {".not", "text/x-mup"},
+            {".ocl", "text/x-ocl"},
+            {".opml", "text/x-opml+xml"},
+            {".ora", "image/openraster"},
+            {".orf", "image/x-olympus-orf"},
+            {".p", "text/x-pascal"},
+            {".pas", "text/x-pascal"},
+            {".patch", "text/x-patch"},
+            {".pbm", "image/x-portable-bitmap"},
+            {".pcd", "image/x-photo-cd"},
+            {".pcx", "image/x-pcx"},
+            {".pdf", "application/pdf"},
+            {".pef", "image/x-pentax-pef"},
+            {".pgm", "image/x-portable-graymap"},
+            {".pict", "image/x-pict"},
+            {".pict1", "image/x-pict"},
+            {".pict2", "image/x-pict"},
+            {".png", "image/png"},
+            {".pnm", "image/x-portable-anymap"},
+            {".pntg", "image/x-macpaint"},
+            {".po", "text/x-gettext-translation"},
+            {".pot", "text/x-gettext-translation-template"},
+            {".py", "text/x-python"},
+            {".qif", "image/x-quicktime"},
+            {".qtif", "image/x-quicktime"},
+            {".raf", "image/x-fuji-raf"},
+            {".ras", "image/x-cmu-raster"},
+            {".raw", "image/x-panasonic-raw"},
+            {".reg", "text/x-ms-regedit"},
+            {".rgb", "image/x-rgb"},
+            {".rle", "image/rle"},
+            {".roff", "text/troff"},
+            {".rp", "image/vnd.rn-realpix"},
+            {".rt", "text/vnd.rn-realtext"},
+            {".rtx", "text/richtext"},
+            {".scm", "text/x-scheme"},
+            {".sgi", "image/x-sgi"},
+            {".sgm", "text/sgml"},
+            {".sgml", "text/sgml"},
+            {".sk", "image/x-skencil"},
+            {".sk1", "image/x-skencil"},
+            {".slk", "text/spreadsheet"},
+            {".spec", "text/x-rpm-spec"},
+            {".sql", "text/x-sql"},
+            {".sr2", "image/x-sony-sr2"},
+            {".srf", "image/x-sony-srf"},
+            {".ssa", "text/x-ssa"},
+            {".sty", "text/x-tex"},
+            {".sub", "text/x-subviewer"},
+            {".sun", "image/x-sun-raster"},
+            {".svg", "image/svg+xml"},
+            {".svgz", "image/svg+xml-compressed"},
+            {".sylk", "text/spreadsheet"},
+            {".t2t", "text/x-txt2tags"},
+            {".tcl", "text/x-tcl"},
+            {".tex", "text/x-tex"},
+            {".texi", "text/x-texinfo"},
+            {".texinfo", "text/x-texinfo"},
+            {".tga", "image/x-tga"},
+            {".tif", "image/tiff"},
+            {".tiff", "image/tiff"},
+            {".tk", "text/x-tcl"},
+            {".tpic", "image/x-tga"},
+            {".tr", "text/troff"},
+            {".txt", "text/plain"},
+            {".vob", "video/mpeg"},
+            {".voc", "audio/x-voc"},
+            {".wmf", "image/x-wmf"},
+            {".wml", "text/vnd.wap.wml"},
+            {".wmls", "text/vnd.wap.wmlscript"},
+            {".wmv", "video/x-ms-wmv"},
+            {".xhtml", "application/xhtml+xml"},
+            {".xml", "application/xml"}
+        };
+    }
+}

+ 73 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/CustomXmlResolver.cs

@@ -0,0 +1,73 @@
+using HTEXLib.Models.Inner;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.Text;
+using System.Xml;
+
+namespace HTEXLib.COMM.Helpers
+{
+   public class CustomXmlResolver : XmlResolver
+    {
+        public CustomXmlResolver() { }
+
+
+
+        public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn)
+        {
+            MemoryStream entityStream = null;
+
+            switch (absoluteUri.Scheme)
+            {
+                case "custom-scheme":
+
+                    string absoluteUriOriginalString = absoluteUri.OriginalString;
+                    string ctgXsltEntityName = absoluteUriOriginalString.Substring(absoluteUriOriginalString.IndexOf(":") + 1);
+                    string entityXslt = "";
+                    // TODO: Replace the following with your own code to load data for referenced entities.
+                    switch (ctgXsltEntityName)
+                    {
+                        case "tokens.xsl":
+                            //entityXslt= System.IO.File.ReadAllText(@"D:\VSProjectCode\TEAMModelHTEX\HTEXMtahML\xslt\tokens.xsl");
+                            entityXslt = Globals.tokens;
+                            break;
+                        case "glayout.xsl":
+                            //entityXslt = System.IO.File.ReadAllText(@"D:\VSProjectCode\TEAMModelHTEX\HTEXMtahML\xslt\glayout.xsl");
+                            entityXslt = Globals.glayout;
+                            break;
+                        case "scripts.xsl":
+                            //entityXslt = System.IO.File.ReadAllText(@"D:\VSProjectCode\TEAMModelHTEX\HTEXMtahML\xslt\scripts.xsl");
+                            entityXslt = Globals.scripts; 
+                            break;
+                        case "tables.xsl":
+                            //entityXslt = System.IO.File.ReadAllText(@"D:\VSProjectCode\TEAMModelHTEX\HTEXMtahML\xslt\tables.xsl");
+                            entityXslt = Globals.tables;
+                            break;
+                        case "entities.xsl":
+                            //entityXslt = System.IO.File.ReadAllText(@"D:\VSProjectCode\TEAMModelHTEX\HTEXMtahML\xslt\entities.xsl");
+                            entityXslt = Globals.entities;
+                            break;
+                        case "cmarkup.xsl":
+                            //entityXslt = System.IO.File.ReadAllText(@"D:\VSProjectCode\TEAMModelHTEX\HTEXMtahML\xslt\cmarkup.xsl");
+                            entityXslt = Globals.cmarkup;
+                            break;
+                    }
+                    UTF8Encoding utf8Encoding = new UTF8Encoding();
+                    byte[] entityBytes = utf8Encoding.GetBytes(entityXslt);
+                    entityStream = new MemoryStream(entityBytes);
+                    break;
+            }
+            return entityStream;
+        }
+
+        public override Uri ResolveUri(Uri baseUri, string relativeUri)
+        {
+            // You might want to resolve all reference URIs using a custom scheme.
+            if (baseUri != null)
+                return base.ResolveUri(baseUri, relativeUri);
+            else
+                return new Uri("custom-scheme:" + relativeUri);
+        }
+    }
+}

+ 85 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/HtmlHelper.cs

@@ -0,0 +1,85 @@
+using HtmlAgilityPack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace HTEXLib.COMM.Helpers
+{
+    public class HtmlHelper
+    {
+        public static string DoUselessTag(string str)
+        {
+            if (str.StartsWith("</p>"))
+            {
+                str = str.Substring(4);
+            }
+            if (str.EndsWith("<p>"))
+            {
+                str = str.Substring(0, str.Length - 1 - 2);
+            }
+            if (str.EndsWith("<p >"))
+            {
+                str = str.Substring(0, str.Length - 1 - 3);
+            }
+            if (str.EndsWith("<p  >"))
+            {
+                str = str.Substring(0, str.Length - 1 - 4);
+            }
+            if (str.StartsWith("<p >") && !str.Contains("</p>"))
+            {
+                str = str.Replace("<p >", "");
+            }
+            if (str.StartsWith("<p  >") && !str.Contains("</p>"))
+            {
+                str = str.Replace("<p  >", "");
+            }
+            if (str.StartsWith("<p>") && !str.Contains("</p>"))
+            {
+                str = str.Replace("<p>", "");
+            }
+            if (str.EndsWith("</p>") && !str.Contains("<p>") && !str.Contains("<p >") && !str.Contains("<p  >"))
+            {
+                str = str.Replace("</p>", "");
+            }
+            str = Regex.Replace(str, "<p([^>]{0,})>\\s*</p>", "");
+            return str;
+        }
+
+        /// <summary>
+        /// 从html获取文本及img的url  去掉其他标签的干扰,空格。以获取更准确的sha1校验值
+        /// </summary>
+        /// <param name="html"></param>
+        /// <returns></returns>
+        public static string DoTextImg(string html)
+        {
+            HtmlDocument doc = new HtmlDocument();
+            doc.LoadHtml(html);
+            List<string> urls = GetHtmlImageUrlList(html);
+            StringBuilder builder = new StringBuilder(doc.DocumentNode.InnerText.Replace("&nbsp;", ""));
+            if (urls.IsNotEmpty())
+            {
+                foreach (string url in urls)
+                {
+                    builder.Append(url);
+                }
+            }
+            return builder.ToString();
+        }
+
+        public static List<string> GetHtmlImageUrlList(string sHtmlText)
+        {
+            // 定义正则表达式用来匹配 img 标签   
+            Regex regImg = new Regex(@"<img\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<imgUrl>[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*>", RegexOptions.IgnoreCase);
+
+            // 搜索匹配的字符串   
+            MatchCollection matches = regImg.Matches(sHtmlText);
+            //string[] sUrlList = new string[matches.Count];
+            List<string> urls = new List<string>();
+            // 取得匹配项列表   
+            foreach (Match match in matches)
+                urls.Add(match.Groups["imgUrl"].Value);
+            return urls;
+        }
+    }
+}

+ 230 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/StringHelper.cs

@@ -0,0 +1,230 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Text.Json;
+
+namespace HTEXLib.COMM.Helpers
+{
+    public class StringHelper
+    {
+        #region 截取字符串
+        public static string GetSubString(string pSrcString, int pLength, string pTailString)
+        {
+            return GetSubString(pSrcString, 0, pLength, pTailString);
+        }
+        public static string GetSubString(string pSrcString, int pStartIndex, int pLength, string pTailString)
+        {
+            string str = pSrcString;
+            byte[] bytes = Encoding.UTF8.GetBytes(pSrcString);
+            foreach (char ch in Encoding.UTF8.GetChars(bytes))
+            {
+                if (((ch > 'ࠀ') && (ch < '一')) || ((ch > 0xac00) && (ch < 0xd7a3)))
+                {
+                    if (pStartIndex >= pSrcString.Length)
+                    {
+                        return "";
+                    }
+                    return pSrcString.Substring(pStartIndex, ((pLength + pStartIndex) > pSrcString.Length) ? (pSrcString.Length - pStartIndex) : pLength);
+                }
+            }
+            if (pLength < 0)
+            {
+                return str;
+            }
+            byte[] sourceArray = Encoding.Default.GetBytes(pSrcString);
+            if (sourceArray.Length <= pStartIndex)
+            {
+                return str;
+            }
+            int length = sourceArray.Length;
+            if (sourceArray.Length > (pStartIndex + pLength))
+            {
+                length = pLength + pStartIndex;
+            }
+            else
+            {
+                pLength = sourceArray.Length - pStartIndex;
+                pTailString = "";
+            }
+            int num2 = pLength;
+            int[] numArray = new int[pLength];
+            byte[] destinationArray = null;
+            int num3 = 0;
+            for (int i = pStartIndex; i < length; i++)
+            {
+                if (sourceArray[i] > 0x7f)
+                {
+                    num3++;
+                    if (num3 == 3)
+                    {
+                        num3 = 1;
+                    }
+                }
+                else
+                {
+                    num3 = 0;
+                }
+                numArray[i] = num3;
+            }
+            if ((sourceArray[length - 1] > 0x7f) && (numArray[pLength - 1] == 1))
+            {
+                num2 = pLength + 1;
+            }
+            destinationArray = new byte[num2];
+            Array.Copy(sourceArray, pStartIndex, destinationArray, 0, num2);
+            return (Encoding.Default.GetString(destinationArray) + pTailString);
+        }
+        #endregion
+
+        /// <summary>
+        /// 将字符串转换为int类型数组
+        /// </summary>
+        /// <param name="str">如1,2,3,4,5</param>
+        /// <returns></returns>
+        public static List<string> StrToListString(string str)
+        {
+            var list = new List<string>();
+            if (!str.Contains(","))
+            {
+                list.Add(str);
+                return list;
+            }
+            var slist = str.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
+            foreach (var item in slist)
+            {
+                list.Add(item);
+            }
+            return list;
+        }
+
+        /// <summary>
+        /// 截取两个字符串中间的字符串
+        /// </summary>
+        /// <param name="sourse"></param>
+        /// <param name="startstr"></param>
+        /// <param name="endstr"></param>
+        /// <returns></returns>
+        public static string SubMidString(string sourse, string startstr, string endstr)
+        {
+            string result = string.Empty;
+            int startindex, endindex;
+            startindex = sourse.IndexOf(startstr);
+            if (startindex == -1)
+                return result;
+            string tmpstr = sourse.Substring(startindex + startstr.Length);
+            endindex = tmpstr.IndexOf(endstr);
+            if (endindex == -1)
+                return result;
+            result = tmpstr.Remove(endindex);
+            return result;
+        }
+        public static double[] ListTodouble(List<double> list)
+        {
+            Double[] doubles = new Double[list.Count];
+            int k = 0;
+            foreach (double p in list)
+            {
+                doubles[k] = p;
+                k++;
+            }
+            //doubles = list;
+            if (doubles == null)
+            {
+                return null;
+            }
+            double[] result = new double[doubles.Length];
+            for (int i = 0; i < doubles.Length; i++)
+            {
+                result[i] = doubles[i];
+            }
+            return result;
+        }
+        public static double[,] ListToDouble(List<List<double>> list)
+        {
+            int itemCount = 0;
+            //int stuCount = list.Count;
+            foreach (List<double> p in list)
+            {
+                if (p.Count != 0)
+                {
+                    itemCount = p.Count;
+                    break;
+                }
+
+            }
+            for (int k = 0; k < list.Count; k++)
+            {
+                if (list[k].Count == 0)
+                {
+                    list.Remove(list[k]);
+                }
+            }
+            double[,] doubles = new double[list.Count, itemCount];
+            for (int i = 0; i < list.Count; i++)
+            {
+                for (int j = 0; j < itemCount; j++)
+                {
+                    doubles[i, j] = list[i][j];
+                }
+            }
+            return doubles;
+        }
+
+        public static int getKeyCount(JsonElement element)
+        {
+            int keys = 0;
+            var emobj = element.EnumerateObject();
+            while (emobj.MoveNext())
+            {
+                keys++;
+            }
+            return keys;
+        }
+        public static string getEduName(string key)
+        {
+            string name = "";
+            switch (key)
+            {
+                case "0":
+                    name = "知识";
+                    break;
+                case "1":
+                    name = "理解";
+                    break;
+                case "2":
+                    name = "应用";
+                    break;
+                case "3":
+                    name = "分析";
+                    break;
+                case "4":
+                    name = "综合";
+                    break;
+                case "5":
+                    name = "评鉴";
+                    break;
+            }
+            return name;
+        }
+        public static string getTypeName(string key)
+        {
+            string name = "";
+            switch (key)
+            {
+                case "0":
+                    name = "Single";
+                    break;
+                case "1":
+                    name = "Multiple";
+                    break;
+                case "2":
+                    name = "Judge";
+                    break;
+                case "3":
+                    name = "Complete";
+                    break;
+            }
+            return name;
+        }
+    }
+}

+ 17 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/BrushDIBColorsEnum.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// DIB-Colors enum.
+    /// </summary>
+    public enum BrushDIBColorsEnum
+    {
+        DIB_PAL_COLORS = 1,
+        DIB_RGB_COLORS = 0,
+    }
+}

+ 24 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/BrushEnum.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Brush enum.
+    /// </summary>
+    public enum BrushBSEnum
+    {
+        BS_DIBPATTERN = 5,
+        BS_DIBPATTERN8X8 = 8,
+        BS_DIBPATTERNPT = 6,
+        BS_HATCHED = 2,
+        BS_HOLLOW = 1,
+        BS_NULL = 1,
+        BS_PATTERN = 3,
+        BS_PATTERN8X8 = 7,
+        BS_SOLID = 0,
+    }
+}

+ 21 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/BrushHSEnum.cs

@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// HS Brush enum
+    /// </summary>
+    public enum BrushHSEnum
+    {
+        HS_HORIZONTAL = 0,
+        HS_VERTICAL = 1,
+        HS_FDIAGONAL = 2,
+        HS_BDIAGONAL = 3,
+        HS_CROSS = 4,
+        HS_DIAGCROSS = 5,
+    }
+}

+ 34 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/FontCharsetEnum.cs

@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Charset Enum
+    /// </summary>
+    public enum FontCharsetEnum
+    {
+        ANSI_CHARSET = 0,
+        DEFAULT_CHARSET = 1,
+        SYMBOL_CHARSET = 2,
+        MAC_CHARSET = 77,
+        SHIFTJIS_CHARSET = 128,
+        HANGUL_CHARSET = 129,
+        JOHAB_CHARSET = 130,
+        GB2312_CHARSET = 134,
+        CHINESEBIG5_CHARSET = 136,
+        GREEK_CHARSET = 161,
+        TURKISH_CHARSET = 162,
+        VIETNAMESE_CHARSET = 163,
+        ARABIC_CHARSET = 178,
+        HEBREW_CHARSET = 177,
+        BALTIC_CHARSET = 186,
+        RUSSIAN_CHARSET = 204,
+        THAI_CHARSET = 222,
+        EASTEUROPE_CHARSET = 238,
+        OEM_CHARSET = 255,
+    }
+}

+ 22 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/FontClipPrecisEnum.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Clip Precis Enum
+    /// </summary>
+    public enum FontClipPrecisEnum
+    {
+        CLIP_DEFAULT_PRECIS = 0,
+        CLIP_CHARACTER_PRECIS = 1,
+        CLIP_STROKE_PRECIS = 2,
+        CLIP_MASK = 15,
+        CLIP_LH_ANGLES = 16,
+        CLIP_TT_ALWAYS = 32,
+        CLIP_EMBEDDED = 128,
+    }
+}

+ 21 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/FontFFEnum.cs

@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Font Family Enum.
+    /// </summary>
+    public enum FontFFEnum
+    {
+        FF_DONTCARE = 0,
+        FF_ROMAN = 16,
+        FF_SWISS = 32,
+        FF_MODERN = 48,
+        FF_SCRIPT = 64,
+        FF_DECORATIVE = 80,
+    }
+}

+ 30 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/FontFWEnum.cs

@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Font Weight Enum.
+    /// </summary>
+    public enum FontFWEnum
+    {
+        FW_DONTCARE = 0,
+        FW_THIN = 100,
+        FW_EXTRALIGHT = 200,
+        FW_ULTRALIGHT = 200,
+        FW_LIGHT = 300,
+        FW_NORMAL = 400,
+        FW_REGULAR = 400,
+        FW_MEDIUM = 500,
+        FW_SEMIBOLD = 600,
+        FW_DEMIBOLD = 600,
+        FW_BOLD = 700,
+        FW_EXTRABOLD = 800,
+        FW_ULTRABOLD = 800,
+        FW_HEAVY = 900,
+        FW_BLACK = 900,
+    }
+}

+ 25 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/FontOutPrecisEnum.cs

@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Out Preciss Enum
+    /// </summary>
+    public enum FontOutPrecisEnum
+    {
+        OUT_DEFAULT_PRECIS = 0,
+        OUT_STRING_PRECIS = 1,
+        OUT_CHARACTER_PRECIS = 2,
+        OUT_STROKE_PRECIS = 3,
+        OUT_TT_PRECIS = 4,
+        OUT_DEVICE_PRECIS = 5,
+        OUT_RASTER_PRECIS = 6,
+        OUT_TT_ONLY_PRECIS = 7,
+        OUT_OUTLINE_PRECIS = 8,
+        OUT_SCREEN_OUTLINE_PRECIS = 9,
+    }
+}

+ 18 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/FontPitchEnum.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Pitch Enum.
+    /// </summary>
+    public enum FontPitchEnum
+    {
+        DEFAULT_PITCH = 0,
+        FIXED_PITCH = 1,
+        VARIABLE_PITCH = 2,
+    }
+}

+ 22 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/FontQualityEnum.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Quality Enum.
+    /// </summary>
+    public enum FontQualityEnum
+    {
+        DEFAULT_QUALITY = 0,
+        DRAFT_QUALITY = 1,
+        PROOF_QUALITY = 2,
+        NONANTIALIASED_QUALITY = 3,
+        ANTIALIASED_QUALITY = 4,
+        CLEARTYPE_QUALITY = 5, // Windows XP only
+    }
+
+}

+ 103 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/GdiEnum.cs

@@ -0,0 +1,103 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Graphics Device Interface Enum
+    /// </summary>
+    public enum GdiEnum
+    {
+        OPAQUE = 2,
+        TRANSPARENT = 1,
+
+        TA_BASELINE = 24,
+        TA_BOTTOM = 8,
+        TA_TOP = 0,
+        TA_CENTER = 6,
+        TA_LEFT = 0,
+        TA_RIGHT = 2,
+        TA_NOUPDATECP = 0,
+        TA_RTLREADING = 256,
+        TA_UPDATECP = 1,
+        VTA_BASELINE = 24,
+        VTA_CENTER = 6,
+
+        ETO_CLIPPED = 4,
+        ETO_NUMERICSLOCAL = 1024,
+        ETO_NUMERICSLATIN = 2048,
+        ETO_GLYPH_INDEX = 16,
+        ETO_OPAQUE = 2,
+        ETO_PDY = 8192,
+        ETO_RTLREADING = 128,
+        ETO_IGNORELANGUAGE = 4096,
+
+        MM_ANISOTROPIC = 8,
+        MM_HIENGLISH = 5,
+        MM_HIMETRIC = 3,
+        MM_ISOTROPIC = 7,
+        MM_LOENGLISH = 4,
+        MM_LOMETRIC = 2,
+        MM_TEXT = 1,
+        MM_TWIPS = 6,
+
+        STRETCH_ANDSCANS = 2,
+        STRETCH_DELETESCANS = 3,
+        STRETCH_HALFTONE = 4,
+        STRETCH_ORSCANS = 2,
+        BLACKONWHITE = 2,
+        COLORONCOLOR = 3,
+        HALFTONE = 4,
+        WHITEONBLACK = 2,
+
+        ALTERNATE = 1,
+        WINDING = 2,
+
+        R2_BLACK = 1,
+        R2_COPYPEN = 13,
+        R2_MASKNOTPEN = 3,
+        R2_MASKPEN = 9,
+        R2_MASKPENNOT = 5,
+        R2_MERGENOTPEN = 12,
+        R2_MERGEPEN = 15,
+        R2_MERGEPENNOT = 14,
+        R2_NOP = 11,
+        R2_NOT = 6,
+        R2_NOTCOPYPEN = 4,
+        R2_NOTMASKPEN = 8,
+        R2_NOTMERGEPEN = 2,
+        R2_NOTXORPEN = 10,
+        R2_WHITE = 16,
+        R2_XORPEN = 7,
+
+        BLACKNESS = 66,
+        DSTINVERT = 5570569,
+        MERGECOPY = 12583114,
+        MERGEPAINT = 12255782,
+        NOTSRCCOPY = 3342344,
+        NOTSRCERASE = 1114278,
+        PATCOPY = 15728673,
+        PATINVERT = 5898313,
+        PATPAINT = 16452105,
+        SRCAND = 8913094,
+        SRCCOPY = 13369376,
+        SRCERASE = 4457256,
+        SRCINVERT = 6684742,
+        SRCPAINT = 15597702,
+        WHITENESS = 16711778,
+
+        DIB_RGB_COLORS = 0,
+        DIB_PAL_COLORS = 1,
+
+        LAYOUT_BITMAPORIENTATIONPRESERVED = 8,
+        LAYOUT_RTL = 1,
+
+        ABSOLUTE = 1,
+        RELATIVE = 2,
+
+        ASPECT_FILTERING = 1,
+    }
+}

+ 187 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/GdiUtils.cs

@@ -0,0 +1,187 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Utils functions.
+    /// </summary>
+    public class GdiUtils
+    {
+        #region Local Variables
+
+        private static int[,] FBA_SHIFT_JIS = new int[,] { { 0x81, 0x9F }, { 0xE0, 0xFC } };
+        private static int[,] FBA_HANGUL_CHARSET = new int[,] { { 0x80, 0xFF } };
+        private static int[,] FBA_JOHAB_CHARSET = new int[,] { { 0x80, 0xFF } };
+        private static int[,] FBA_GB2312_CHARSET = new int[,] { { 0x80, 0xFF } };
+        private static int[,] FBA_CHINESEBIG5_CHARSET = new int[,] { { 0xA1, 0xFE } };
+
+        #endregion
+
+        #region Public Methods
+
+        /// <summary>
+        /// Convert byte array to string using specified charset.
+        /// </summary>
+        /// <param name="chars"></param>
+        /// <param name="charset"></param>
+        /// <returns></returns>
+        public static string ConvertString(byte[] chars, int charset)
+        {
+            string str = null;
+
+            int length = 0;
+            while (length < chars.Count() && chars[length] != 0)
+            {
+                length++;
+            }
+
+            try
+            {
+                str = System.Text.Encoding.GetEncoding(GetCharset(charset)).GetString(chars).Substring(0, length);
+            }
+            catch (Exception ex)
+            {
+                try
+                {
+                    str = System.Text.Encoding.GetEncoding("US-ASCII").GetString(chars).Substring(0, length);
+                }
+                catch (Exception ex2)
+                {
+                    throw new Exception(ex.Message+ex2.Message);
+                }
+            }
+            return str;
+        }
+
+        /// <summary>
+        /// Get specified charset.
+        /// </summary>
+        /// <param name="charset"></param>
+        /// <returns></returns>
+        public static string GetCharset(int charset)
+        {
+            switch (charset)
+            {
+                case (int)FontCharsetEnum.ANSI_CHARSET:
+                    return "Cp1252";
+                case (int)FontCharsetEnum.SYMBOL_CHARSET:
+                    return "Cp1252";
+                case (int)FontCharsetEnum.MAC_CHARSET:
+                    return "MacRoman";
+                case (int)FontCharsetEnum.SHIFTJIS_CHARSET:
+                    return "MS932";
+                case (int)FontCharsetEnum.HANGUL_CHARSET:
+                    return "MS949";
+                case (int)FontCharsetEnum.JOHAB_CHARSET:
+                    return "Johab";
+                case (int)FontCharsetEnum.GB2312_CHARSET:
+                    return "MS936";
+                case (int)FontCharsetEnum.CHINESEBIG5_CHARSET:
+                    return "MS950";
+                case (int)FontCharsetEnum.GREEK_CHARSET:
+                    return "Cp1253";
+                case (int)FontCharsetEnum.TURKISH_CHARSET:
+                    return "Cp1254";
+                case (int)FontCharsetEnum.VIETNAMESE_CHARSET:
+                    return "Cp1258";
+                case (int)FontCharsetEnum.HEBREW_CHARSET:
+                    return "Cp1255";
+                case (int)FontCharsetEnum.ARABIC_CHARSET:
+                    return "Cp1256";
+                case (int)FontCharsetEnum.BALTIC_CHARSET:
+                    return "Cp1257";
+                case (int)FontCharsetEnum.RUSSIAN_CHARSET:
+                    return "Cp1251";
+                case (int)FontCharsetEnum.THAI_CHARSET:
+                    return "MS874";
+                case (int)FontCharsetEnum.EASTEUROPE_CHARSET:
+                    return "Cp1250";
+                case (int)FontCharsetEnum.OEM_CHARSET:
+                    return "Cp1252";
+                default:
+                    return "Cp1252";
+            }
+        }
+
+        /// <summary>
+        /// Get language using specified charset.
+        /// </summary>
+        /// <param name="charset"></param>
+        /// <returns></returns>
+        public static string GetLanguage(int charset)
+        {
+            switch (charset)
+            {
+                case (int)FontCharsetEnum.ANSI_CHARSET:
+                    return "en";
+                case (int)FontCharsetEnum.SYMBOL_CHARSET:
+                    return "en";
+                case (int)FontCharsetEnum.MAC_CHARSET:
+                    return "en";
+                case (int)FontCharsetEnum.SHIFTJIS_CHARSET:
+                    return "ja";
+                case (int)FontCharsetEnum.HANGUL_CHARSET:
+                    return "ko";
+                case (int)FontCharsetEnum.JOHAB_CHARSET:
+                    return "ko";
+                case (int)FontCharsetEnum.GB2312_CHARSET:
+                    return "zh-CN";
+                case (int)FontCharsetEnum.CHINESEBIG5_CHARSET:
+                    return "zh-TW";
+                case (int)FontCharsetEnum.GREEK_CHARSET:
+                    return "el";
+                case (int)FontCharsetEnum.TURKISH_CHARSET:
+                    return "tr";
+                case (int)FontCharsetEnum.VIETNAMESE_CHARSET:
+                    return "vi";
+                case (int)FontCharsetEnum.HEBREW_CHARSET:
+                    return "iw";
+                case (int)FontCharsetEnum.ARABIC_CHARSET:
+                    return "ar";
+                case (int)FontCharsetEnum.BALTIC_CHARSET:
+                    return "bat";
+                case (int)FontCharsetEnum.RUSSIAN_CHARSET:
+                    return "ru";
+                case (int)FontCharsetEnum.THAI_CHARSET:
+                    return "th";
+                case (int)FontCharsetEnum.EASTEUROPE_CHARSET:
+                    return null;
+                case (int)FontCharsetEnum.OEM_CHARSET:
+                    return null;
+                default:
+                    return null;
+            }
+        }
+
+
+        /// <summary>
+        /// Get the first byte area specified charset.
+        /// </summary>
+        /// <param name="charset"></param>
+        /// <returns></returns>
+        public static int[,] GetFirstByteArea(int charset)
+        {
+            switch (charset)
+            {
+                case (int)FontCharsetEnum.SHIFTJIS_CHARSET:
+                    return FBA_SHIFT_JIS;
+                case (int)FontCharsetEnum.HANGUL_CHARSET:
+                    return FBA_HANGUL_CHARSET;
+                case (int)FontCharsetEnum.JOHAB_CHARSET:
+                    return FBA_JOHAB_CHARSET;
+                case (int)FontCharsetEnum.GB2312_CHARSET:
+                    return FBA_GB2312_CHARSET;
+                case (int)FontCharsetEnum.CHINESEBIG5_CHARSET:
+                    return FBA_CHINESEBIG5_CHARSET;
+                default:
+                    return null;
+            }
+        }
+
+        #endregion
+    }
+}

+ 657 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/IGdi.cs

@@ -0,0 +1,657 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Graphics Device Interface - Represents graphics elements
+    /// </summary>
+    public interface IGdi
+    {
+        /// <summary>
+        /// Create header document.
+        /// </summary>
+        /// <param name="vsx"></param>
+        /// <param name="vsy"></param>
+        /// <param name="vex"></param>
+        /// <param name="vey"></param>
+        /// <param name="dpi"></param>
+        void PlaceableHeader(int vsx, int vsy, int vex, int vey, int dpi);
+
+        /// <summary>
+        /// Initialize Header document.
+        /// </summary>
+        void Header();
+
+        /// <summary>
+        /// Element is put inside a shape element and defines how an attribute of an element changes over the animation. 
+        /// The attribute will change from the initial value to the end value in the duration specified.
+        /// </summary>
+        /// <param name="palette"></param>
+        /// <param name="startIndex"></param>
+        /// <param name="entries"></param>
+        void AnimatePalette(IGdiPalette palette, int startIndex, int[] entries);
+
+        /// <summary>
+        /// Draws an elliptical arc.
+        /// </summary>
+        /// <param name="sxr"></param>
+        /// <param name="syr"></param>
+        /// <param name="exr"></param>
+        /// <param name="eyr"></param>
+        /// <param name="sxa"></param>
+        /// <param name="sya"></param>
+        /// <param name="exa"></param>
+        /// <param name="eya"></param>
+        void Arc(int sxr, int syr, int exr, int eyr,
+               int sxa, int sya, int exa, int eya);
+
+        /// <summary>
+        /// Execute a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context.
+        /// </summary>
+        /// <param name="image"></param>
+        /// <param name="dx"></param>
+        /// <param name="dy"></param>
+        /// <param name="dw"></param>
+        /// <param name="dh"></param>
+        /// <param name="sx"></param>
+        /// <param name="sy"></param>
+        /// <param name="rop"></param>
+        void BitBlt(byte[] image, int dx, int dy, int dw, int dh, int sx, int sy, long rop);
+
+        /// <summary>
+        /// Draws a chord (a region bounded by the intersection of an ellipse and a line segment, called a secant).
+        /// The chord is outlined by using the current pen and filled by using the current brush.
+        /// </summary>
+        /// <param name="sxr"></param>
+        /// <param name="syr"></param>
+        /// <param name="exr"></param>
+        /// <param name="eyr"></param>
+        /// <param name="sxa"></param>
+        /// <param name="sya"></param>
+        /// <param name="exa"></param>
+        /// <param name="eya"></param>
+        void Chord(int sxr, int syr, int exr, int eyr,
+                 int sxa, int sya, int exa, int eya);
+
+        /// <summary>
+        /// Creates a logical brush that has the specified style, color, and pattern.
+        /// </summary>
+        /// <param name="style"></param>
+        /// <param name="color"></param>
+        /// <param name="hatch"></param>
+        /// <returns></returns>
+        IGdiBrush CreateBrushIndirect(int style, int color, int hatch);
+
+        /// <summary>
+        /// Creates a logical font that has the specified characteristics. 
+        /// The font can subsequently be selected as the current font for any device context.
+        /// </summary>
+        /// <param name="height"></param>
+        /// <param name="width"></param>
+        /// <param name="escapement"></param>
+        /// <param name="orientation"></param>
+        /// <param name="weight"></param>
+        /// <param name="italic"></param>
+        /// <param name="underline"></param>
+        /// <param name="strikeout"></param>
+        /// <param name="charset"></param>
+        /// <param name="outPrecision"></param>
+        /// <param name="clipPrecision"></param>
+        /// <param name="quality"></param>
+        /// <param name="pitchAndFamily"></param>
+        /// <param name="faceName"></param>
+        /// <returns></returns>
+        IGdiFont CreateFontIndirect(int height, int width, int escapement,
+                         int orientation, int weight,
+                         bool italic, bool underline, bool strikeout,
+                         int charset, int outPrecision, int clipPrecision,
+                         int quality, int pitchAndFamily, byte[] faceName);
+
+        /// <summary>
+        /// Creates a logical palette.
+        /// </summary>
+        /// <param name="version"></param>
+        /// <param name="palEntry"></param>
+        /// <returns></returns>
+        IGdiPalette CreatePalette(int version, int[] palEntry);
+
+        /// <summary>
+        /// Creates a logical brush with the specified bitmap pattern.
+        /// The bitmap can be a DIB section bitmap, which is created by the CreateDIBSection function, or it can be a device-dependent bitmap.
+        /// </summary>
+        /// <param name="image"></param>
+        /// <returns></returns>
+        IGdiPatternBrush CreatePatternBrush(byte[] image);
+
+        /// <summary>
+        /// Creates a logical cosmetic pen that has the style, width, and color specified in a structure.
+        /// </summary>
+        /// <param name="style"></param>
+        /// <param name="width"></param>
+        /// <param name="color"></param>
+        /// <returns></returns>
+        IGdiPen CreatePenIndirect(int style, int width, int color);
+
+        /// <summary>
+        /// Creates a rectangular region.
+        /// </summary>
+        /// <param name="left"></param>
+        /// <param name="top"></param>
+        /// <param name="right"></param>
+        /// <param name="bottom"></param>
+        /// <returns></returns>
+        IGdiRegion CreateRectRgn(int left, int top, int right, int bottom);
+
+        /// <summary>
+        /// Deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object. 
+        /// After the object is deleted, the specified handle is no longer valid.
+        /// </summary>
+        /// <param name="obj"></param>
+        void DeleteObject(IGdiObject obj);
+
+        /// <summary>
+        /// Function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context.
+        /// </summary>
+        /// <param name="image"></param>
+        /// <param name="dx"></param>
+        /// <param name="dy"></param>
+        /// <param name="dw"></param>
+        /// <param name="dh"></param>
+        /// <param name="sx"></param>
+        /// <param name="sy"></param>
+        /// <param name="rop"></param>
+        void DibBitBlt(byte[] image, int dx, int dy, int dw, int dh,
+               int sx, int sy, long rop);
+
+        /// <summary>
+        /// Create Dib Pattern Brush object instance.
+        /// </summary>
+        /// <param name="image"></param>
+        /// <param name="usage"></param>
+        /// <returns></returns>
+        IGdiPatternBrush DibCreatePatternBrush(byte[] image, int usage);
+
+        /// <summary>
+        /// Copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary. 
+        /// The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context.
+        /// </summary>
+        /// <param name="image"></param>
+        /// <param name="dx"></param>
+        /// <param name="dy"></param>
+        /// <param name="dw"></param>
+        /// <param name="dh"></param>
+        /// <param name="sx"></param>
+        /// <param name="sy"></param>
+        /// <param name="sw"></param>
+        /// <param name="sh"></param>
+        /// <param name="rop"></param>
+        void DibStretchBlt(byte[] image, int dx, int dy, int dw, int dh,
+               int sx, int sy, int sw, int sh, long rop);
+
+        /// <summary>
+        /// Draws an ellipse. 
+        /// The center of the ellipse is the center of the specified bounding rectangle.
+        /// The ellipse is outlined by using the current pen and is filled by using the current brush.
+        /// </summary>
+        /// <param name="sx"></param>
+        /// <param name="sy"></param>
+        /// <param name="ex"></param>
+        /// <param name="ey"></param>
+        void Ellipse(int sx, int sy, int ex, int ey);
+
+        /// <summary>
+        /// Enables an application to access the system-defined device capabilities that are not available through GDI. 
+        /// Escape calls made by an application are translated and sent to the driver.
+        /// </summary>
+        /// <param name="data"></param>
+        void Escape(byte[] data);
+
+        /// <summary>
+        ///  Creates a new clipping region that consists of the existing clipping region minus the specified rectangle.
+        /// </summary>
+        /// <param name="left"></param>
+        /// <param name="top"></param>
+        /// <param name="right"></param>
+        /// <param name="bottom"></param>
+        /// <returns></returns>
+        int ExcludeClipRect(int left, int top, int right, int bottom);
+
+        /// <summary>
+        /// Fills an area of the display surface with the current brush.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="color"></param>
+        /// <param name="type"></param>
+        void ExtFloodFill(int x, int y, int color, int type);
+
+        /// <summary>
+        /// Draws text using the currently selected font, background color, and text color. 
+        /// You can optionally provide dimensions to be used for clipping, opaquing, or both.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="options"></param>
+        /// <param name="rect"></param>
+        /// <param name="text"></param>
+        /// <param name="lpdx"></param>
+        void ExtTextOut(int x, int y, int options, int[] rect, byte[] text, int[] lpdx);
+
+        /// <summary>
+        /// Fills a region by using the specified brush.
+        /// </summary>
+        /// <param name="rgn"></param>
+        /// <param name="brush"></param>
+        void FillRgn(IGdiRegion rgn, IGdiBrush brush);
+
+        /// <summary>
+        /// Fills an area of the display surface with the current brush. 
+        /// The area is assumed to be bounded as specified by the crFill parameter.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="color"></param>
+        void FloodFill(int x, int y, int color);
+
+        /// <summary>
+        /// Draws a border around the specified region by using the specified brush.
+        /// </summary>
+        /// <param name="rgn"></param>
+        /// <param name="brush"></param>
+        /// <param name="w"></param>
+        /// <param name="h"></param>
+        void FrameRgn(IGdiRegion rgn, IGdiBrush brush, int w, int h);
+
+        /// <summary>
+        /// Creates a new clipping region from the intersection of the current clipping region and the specified rectangle.
+        /// </summary>
+        /// <param name="left"></param>
+        /// <param name="top"></param>
+        /// <param name="right"></param>
+        /// <param name="bottom"></param>
+        void IntersectClipRect(int left, int top, int right, int bottom);
+
+        /// <summary>
+        /// Inverts the colors in the specified region.
+        /// </summary>
+        /// <param name="rgn"></param>
+        void InvertRgn(IGdiRegion rgn);
+
+        /// <summary>
+        /// Draws a line from the current position up to, but not including, the specified point.
+        /// </summary>
+        /// <param name="ex"></param>
+        /// <param name="ey"></param>
+        void LineTo(int ex, int ey);
+
+        /// <summary>
+        /// Updates the current position to the specified point and optionally returns the previous position.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="old"></param>
+        void MoveToEx(int x, int y, Point old);
+
+        /// <summary>
+        /// Moves the clipping region of a device context by the specified offsets.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        void OffsetClipRgn(int x, int y);
+
+        /// <summary>
+        /// Modifies the viewport origin for a device context using the specified horizontal and vertical offsets.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="point"></param>
+        void OffsetViewportOrgEx(int x, int y, Point point);
+
+        /// <summary>
+        /// Modifies the window origin for a device context using the specified horizontal and vertical offsets.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="point"></param>
+        void OffsetWindowOrgEx(int x, int y, Point point);
+
+        /// <summary>
+        /// Paints the specified region by using the brush currently selected into the device context.
+        /// </summary>
+        /// <param name="rgn"></param>
+        void PaintRgn(IGdiRegion rgn);
+
+        /// <summary>
+        /// Paints the specified rectangle using the brush that is currently selected into the specified device context.
+        /// The brush color and the surface color or colors are combined by using the specified raster operation.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="width"></param>
+        /// <param name="height"></param>
+        /// <param name="rop"></param>
+        void PatBlt(int x, int y, int width, int height, long rop);
+
+        /// <summary>
+        /// Draws a pie-shaped wedge bounded by the intersection of an ellipse and two radials. 
+        /// The pie is outlined by using the current pen and filled by using the current brush.
+        /// </summary>
+        /// <param name="sx"></param>
+        /// <param name="sy"></param>
+        /// <param name="ex"></param>
+        /// <param name="ey"></param>
+        /// <param name="sxr"></param>
+        /// <param name="syr"></param>
+        /// <param name="exr"></param>
+        /// <param name="eyr"></param>
+        void Pie(int sx, int sy, int ex, int ey, int sxr, int syr, int exr, int eyr);
+
+        /// <summary>
+        /// Draws a polygon consisting of two or more vertices connected by straight lines. 
+        /// The polygon is outlined by using the current pen and filled by using the current brush and polygon fill mode.
+        /// </summary>
+        /// <param name="points"></param>
+        void Polygon(Point[] points);
+
+        /// <summary>
+        /// Element is an SVG basic shape that creates straight lines connecting several points. 
+        /// Typically a polyline is used to create open shapes as the last point doesn't have to be connected to the first point. 
+        /// </summary>
+        /// <param name="points"></param>
+        void Polyline(Point[] points);
+
+        /// <summary>
+        ///  Draws a series of closed polygons. 
+        ///  Each polygon is outlined by using the current pen and filled by using the current brush and polygon fill mode. 
+        ///  The polygons drawn by this function can overlap.
+        /// </summary>
+        /// <param name="points"></param>
+        void PolyPolygon(Point[][] points);
+
+        /// <summary>
+        /// Maps palette entries from the current logical palette to the system palette.
+        /// </summary>
+        void RealizePalette();
+
+        /// <summary>
+        /// Restores a device context (DC) to the specified state. 
+        /// The DC is restored by popping state information off a stack created by earlier calls to the SaveDC function.
+        /// </summary>
+        /// <param name="savedDC"></param>
+        void RestoreDC(int savedDC);
+
+        /// <summary>
+        /// Draws a rectangle. 
+        /// The rectangle is outlined by using the current pen and filled by using the current brush.
+        /// </summary>
+        /// <param name="sx"></param>
+        /// <param name="sy"></param>
+        /// <param name="ex"></param>
+        /// <param name="ey"></param>
+        void Rectangle(int sx, int sy, int ex, int ey);
+
+        /// <summary>
+        /// Increases or decreases the size of a logical palette based on the specified value.
+        /// </summary>
+        /// <param name="palette"></param>
+        void ResizePalette(IGdiPalette palette);
+
+        /// <summary>
+        /// Draws a rectangle with rounded corners. 
+        /// The rectangle is outlined by using the current pen and filled by using the current brush.
+        /// </summary>
+        /// <param name="sx"></param>
+        /// <param name="sy"></param>
+        /// <param name="ex"></param>
+        /// <param name="ey"></param>
+        /// <param name="rw"></param>
+        /// <param name="rh"></param>
+        void RoundRect(int sx, int sy, int ex, int ey, int rw, int rh);
+
+        /// <summary>
+        /// Save device context (DC).
+        /// </summary>
+        void SeveDC();
+
+        /// <summary>
+        /// Modifies the viewport for a device context using the ratios formed by the specified multiplicands and divisors.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="xd"></param>
+        /// <param name="y"></param>
+        /// <param name="yd"></param>
+        /// <param name="old"></param>
+        void ScaleViewportExtEx(int x, int xd, int y, int yd, Size old);
+
+        /// <summary>
+        /// Modifies the window for a device context using the ratios formed by the specified multiplicands and divisors.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="xd"></param>
+        /// <param name="y"></param>
+        /// <param name="yd"></param>
+        /// <param name="old"></param>
+        void ScaleWindowExtEx(int x, int xd, int y, int yd, Size old);
+
+        /// <summary>
+        /// Selects a region as the current clipping region for the specified device context.
+        /// </summary>
+        /// <param name="rgn"></param>
+        void SelectClipRgn(IGdiRegion rgn);
+
+        /// <summary>
+        /// Selects an object into the specified device context (DC). The new object replaces the previous object of the same type.
+        /// </summary>
+        /// <param name="obj"></param>
+        void SelectObject(IGdiObject obj);
+
+        /// <summary>
+        /// Selects the specified logical palette into a device context.
+        /// </summary>
+        /// <param name="palette"></param>
+        /// <param name="mode"></param>
+        void SelectPalette(IGdiPalette palette, bool mode);
+
+        /// <summary>
+        /// Sets the current background color to the specified color value, or to the nearest physical color if the device cannot represent the specified color value.
+        /// </summary>
+        /// <param name="color"></param>
+        void SetBkColor(int color);
+
+        /// <summary>
+        /// Sets the background mix mode of the specified device context. 
+        /// The background mix mode is used with text, hatched brushes, and pen styles that are not solid lines.
+        /// </summary>
+        /// <param name="mode"></param>
+        void SetBkMode(int mode);
+
+        /// <summary>
+        /// Sets the pixels in the specified rectangle on the device that is associated with the destination device context using color data from a DIB, JPEG, or PNG image.
+        /// </summary>
+        /// <param name="dx"></param>
+        /// <param name="dy"></param>
+        /// <param name="dw"></param>
+        /// <param name="dh"></param>
+        /// <param name="sx"></param>
+        /// <param name="sy"></param>
+        /// <param name="startscan"></param>
+        /// <param name="scanlines"></param>
+        /// <param name="image"></param>
+        /// <param name="colorUse"></param>
+        void SetDIBitsToDevice(int dx, int dy, int dw, int dh, int sx, int sy,
+                       int startscan, int scanlines, byte[] image, int colorUse);
+
+        /// <summary>
+        /// Changes the layout of a device context (DC).
+        /// </summary>
+        /// <param name="layout"></param>
+        void SetLayout(long layout);
+
+        /// <summary>
+        /// Sets the mapping mode of the specified device context. 
+        /// The mapping mode defines the unit of measure used to transform page-space units into device-space units, and also defines the orientation of the device's x and y axes.
+        /// </summary>
+        /// <param name="mode"></param>
+        void SetMapMode(int mode);
+
+        /// <summary>
+        /// Alters the algorithm the font mapper uses when it maps logical fonts to physical fonts.
+        /// </summary>
+        /// <param name="flags"></param>
+        void SetMapperFlags(long flags);
+
+        /// <summary>
+        /// Sets RGB (red, green, blue) color values and flags in a range of entries in a logical palette.
+        /// </summary>
+        /// <param name="palette"></param>
+        /// <param name="startIndex"></param>
+        /// <param name="entries"></param>
+        void SetPaletteEntries(IGdiPalette palette, int startIndex, int[] entries);
+
+        /// <summary>
+        /// Sets the pixel at the specified coordinates to the specified color.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="color"></param>
+        void SetPixel(int x, int y, int color);
+
+        /// <summary>
+        /// Sets the polygon fill mode for functions that fill polygons.
+        /// </summary>
+        /// <param name="mode"></param>
+        void SetPolyFillMode(int mode);
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="mode"></param>
+        void SetRelAbs(int mode);
+
+        /// <summary>
+        /// Sets the current foreground mix mode. 
+        /// GDI uses the foreground mix mode to combine pens and interiors of filled objects with the colors already on the screen. 
+        /// The foreground mix mode defines how colors from the brush or pen and the colors in the existing image are to be combined.
+        /// </summary>
+        /// <param name="mode"></param>
+        void SetROP2(int mode);
+
+        /// <summary>
+        /// Sets the bitmap stretching mode in the specified device context.
+        /// </summary>
+        /// <param name="mode"></param>
+        void SetStretchBltMode(int mode);
+        
+        /// <summary>
+        /// Sets the text-alignment flags for the specified device context.
+        /// </summary>
+        /// <param name="align"></param>
+        void SetTextAlign(int align);
+
+        /// <summary>
+        /// Sets the intercharacter spacing. 
+        /// Intercharacter spacing is added to each character, including break characters, when the system writes a line of text.
+        /// </summary>
+        /// <param name="extra"></param>
+        void SetTextCharacterExtra(int extra);
+
+        /// <summary>
+        /// Sets the text color for the specified device context to the specified color.
+        /// </summary>
+        /// <param name="color"></param>
+        void SetTextColor(int color);
+
+        /// <summary>
+        /// Specifies the amount of space the system should add to the break characters in a string of text. 
+        /// The space is added when an application calls the TextOut or ExtTextOut functions.
+        /// </summary>
+        /// <param name="breakExtra"></param>
+        /// <param name="breakCount"></param>
+        void SetTextJustification(int breakExtra, int breakCount);
+
+        /// <summary>
+        /// Sets the horizontal and vertical extents of the viewport for a device context by using the specified values.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="old"></param>
+        void SetViewportExtEx(int x, int y, Size old);
+
+        /// <summary>
+        /// Specifies which device point maps to the window origin (0,0).
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="old"></param>
+        void SetViewportOrgEx(int x, int y, Point old);
+
+        /// <summary>
+        /// Sets the horizontal and vertical extents of the window for a device context by using the specified values.
+        /// </summary>
+        /// <param name="width"></param>
+        /// <param name="height"></param>
+        /// <param name="old"></param>
+        void SetWindowExtEx(int width, int height, Size old);
+
+        /// <summary>
+        /// Specifies which window point maps to the viewport origin (0,0).
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="old"></param>
+        void SetWindowOrgEx(int x, int y, Point old);
+
+        /// <summary>
+        /// Copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary. 
+        /// The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context.
+        /// </summary>
+        /// <param name="image"></param>
+        /// <param name="dx"></param>
+        /// <param name="dy"></param>
+        /// <param name="dw"></param>
+        /// <param name="dh"></param>
+        /// <param name="sx"></param>
+        /// <param name="sy"></param>
+        /// <param name="sw"></param>
+        /// <param name="sh"></param>
+        /// <param name="rop"></param>
+        void StretchBlt(byte[] image, int dx, int dy, int dw, int dh,
+               int sx, int sy, int sw, int sh, long rop);
+
+        /// <summary>
+        /// Copies the color data for a rectangle of pixels in a DIB, JPEG, or PNG image to the specified destination rectangle. 
+        /// If the destination rectangle is larger than the source rectangle, this function stretches the rows and columns of color data to fit the destination rectangle. If the destination rectangle is smaller than the source rectangle, this function compresses the rows and columns by using the specified raster operation.
+        /// </summary>
+        /// <param name="dx"></param>
+        /// <param name="dy"></param>
+        /// <param name="dw"></param>
+        /// <param name="dh"></param>
+        /// <param name="sx"></param>
+        /// <param name="sy"></param>
+        /// <param name="sw"></param>
+        /// <param name="sh"></param>
+        /// <param name="image"></param>
+        /// <param name="usage"></param>
+        /// <param name="rop"></param>
+        void StretchDIBits(int dx, int dy, int dw, int dh,
+                       int sx, int sy, int sw, int sh,
+                       byte[] image, int usage, long rop);
+
+        /// <summary>
+        /// Writes a character string at the specified location, using the currently selected font, background color, and text color.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="text"></param>
+        void TextOut(int x, int y, byte[] text);
+
+        /// <summary>
+        /// 
+        /// </summary>
+        void Footer();
+    }
+}

+ 36 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/IGdiBrush.cs

@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Graphics Device Interface - Represents a Brush object.
+    /// </summary>
+    public interface IGdiBrush : IGdiObject
+    {
+        #region Properties
+
+        /// <summary>
+        /// Object Style.
+        /// </summary>
+        /// <returns></returns>
+        int Style { get; }
+
+        /// <summary>
+        /// Object Color.
+        /// </summary>
+        /// <returns></returns>
+        int Color {get;}
+
+        /// <summary>
+        /// Object Hatch.
+        /// </summary>
+        /// <returns></returns>
+        int Hatch { get; }
+
+        #endregion
+    }
+}

+ 102 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/IGdiFont.cs

@@ -0,0 +1,102 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Graphics Device Interface - Represents a Font object.
+    /// </summary>
+    public interface IGdiFont : IGdiObject
+    {
+        #region Properties
+
+        /// <summary>
+        /// Object Height.
+        /// </summary>
+        /// <returns></returns>
+        int Height {get;}
+
+        /// <summary>
+        /// Object Width.
+        /// </summary>
+        /// <returns></returns>
+        int Width { get; }
+
+        /// <summary>
+        /// Object Escapement.
+        /// </summary>
+        /// <returns></returns>
+        int Escapement { get; }
+
+        /// <summary>
+        /// Object Orientation.
+        /// </summary>
+        /// <returns></returns>
+        int Orientation { get; }
+
+        /// <summary>
+        /// Object Weight.
+        /// </summary>
+        /// <returns></returns>
+        int Weight { get; }
+
+        /// <summary>
+        /// Italic font.
+        /// </summary>
+        /// <returns></returns>
+        bool IsItalic { get; }
+
+        /// <summary>
+        /// Underlined font.
+        /// </summary>
+        /// <returns></returns>
+        bool IsUnderlined { get; }
+
+        /// <summary>
+        /// Striked font.
+        /// </summary>
+        /// <returns></returns>
+        bool IsStrikedOut { get; }
+
+        /// <summary>
+        /// Object Charset.
+        /// </summary>
+        /// <returns></returns>
+        int Charset { get; }
+
+        /// <summary>
+        /// Object out precision.
+        /// </summary>
+        /// <returns></returns>
+        int OutPrecision { get; }
+
+        /// <summary>
+        /// Object clip precision.
+        /// </summary>
+        /// <returns></returns>
+        int ClipPrecision { get; }
+
+        /// <summary>
+        /// Object Quality.
+        /// </summary>
+        /// <returns></returns>
+        int Quality { get; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <returns></returns>
+        int PitchAndFamily { get; }
+
+        /// <summary>
+        /// Font face name.
+        /// </summary>
+        /// <returns></returns>
+        string FaceName { get; }
+
+        #endregion
+    }
+}

+ 15 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/IGdiObject.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Graphic Device Interface - Object base.
+    /// </summary>
+    public interface IGdiObject
+    {
+    }
+}

+ 30 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/IGdiPalette.cs

@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Graphics Device Interface - Represents a Palette object.
+    /// </summary>
+    public interface IGdiPalette : IGdiObject
+    {
+        #region Properties
+
+        /// <summary>
+        /// Object Version.
+        /// </summary>
+        /// <returns></returns>
+        int Version { get; }
+
+        /// <summary>
+        /// Object Entries.
+        /// </summary>
+        /// <returns></returns>
+        int[] Entries { get; }
+
+        #endregion
+    }
+}

+ 24 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/IGdiPatternBrush.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Graphics Device Interface - Represents a Pattern Brush object.
+    /// </summary>
+    public interface IGdiPatternBrush : IGdiObject
+    {
+        #region Properties
+
+        /// <summary>
+        /// Object Patterns.
+        /// </summary>
+        /// <returns></returns>
+        byte[] Pattern { get; }
+
+        #endregion
+    }
+}

+ 33 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/IGdiPen.cs

@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Graphics Device Interface - Represents a Pen object.
+    /// </summary>
+    public interface IGdiPen : IGdiObject
+    {
+        #region Properties
+
+        /// <summary>
+        /// Object Style.
+        /// </summary>
+        int Style { get; }
+
+        /// <summary>
+        /// Object Width.
+        /// </summary>
+        int Width { get; }
+
+        /// <summary>
+        /// Object Color.
+        /// </summary>
+        int Color { get; }
+
+        #endregion
+    }
+}

+ 16 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/IGdiRegion.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Graphics Device Interface - Represents a Region Object.
+    /// </summary>
+    public interface IGdiRegion : IGdiObject
+    {
+        
+    }
+}

+ 22 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/PenEnum.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Enumeração de Pen
+    /// </summary>
+    public enum PenPSEnum
+    {
+         PS_SOLID = 0,
+         PS_DASH = 1,
+         PS_DOT = 2,
+         PS_DASHDOT = 3,
+         PS_DASHDOTDOT = 4,
+         PS_NULL = 5,
+         PS_INSIDEFRAME = 6,
+    }
+}

+ 90 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/Point.cs

@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Represents a point (x,y).
+    /// </summary>
+    public class Point
+    {
+        #region Properties
+
+        /// <summary>
+        /// Point X
+        /// </summary>
+        public int X { get; set; }
+
+        /// <summary>
+        /// Point Y
+        /// </summary>
+        public int Y { get; set; }
+
+        #endregion
+
+        #region Constructors
+
+        /// <summary>
+        /// Default constructor.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        public Point(int x, int y)
+        {
+            X = x;
+            Y = y;
+        }
+
+        #endregion
+
+        #region Public Methods
+
+        /// <summary>
+        /// Serves as the default hash function.
+        /// </summary>
+        /// <returns></returns>
+        public override int GetHashCode()
+        {
+            int prime = 31;
+            int result = 1;
+            result = prime * result + X;
+            result = prime * result + Y;
+            return result;
+        }
+
+        /// <summary>
+        /// Determines whether the specified object is equal to the current object.
+        /// </summary>
+        /// <param name="obj"></param>
+        /// <returns></returns>
+        public override bool Equals(Object obj)
+        {
+            if (this == obj)
+                return true;
+            if (obj == null)
+                return false;
+            if (typeof(Point) != obj.GetType())
+                return false;
+            Point other = (Point)obj;
+            if (X != other.X)
+                return false;
+            if (Y != other.Y)
+                return false;
+            return true;
+        }
+
+        /// <summary>
+        /// Returns a string that represents the current object.
+        /// </summary>
+        /// <returns></returns>
+        public override string ToString()
+        {
+            return "Point [x=" + X + ", y=" + Y + "]";
+        }
+
+        #endregion
+    }
+}

+ 19 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/RegionEnum.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Region Enum
+    /// </summary>
+    public enum RegionEnum
+    {
+        NULLREGION = 1,
+        SIMPLEREGION = 2,
+        COMPLEXREGION = 3,
+        ERROR = 0,
+    }
+}

+ 90 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Gdi/Size.cs

@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Gdi
+{
+    /// <summary>
+    /// Represents a size object.
+    /// </summary>
+    public class Size
+    {
+        #region Properties
+
+        /// <summary>
+        /// Width of the object.
+        /// </summary>
+        public int Width { get; set; }
+
+        /// <summary>
+        /// Height of the object.
+        /// </summary>
+        public int Height { get; set; }
+
+        #endregion
+
+        #region Constructors
+
+        /// <summary>
+        /// Default constructor.
+        /// </summary>
+        /// <param name="width"></param>
+        /// <param name="height"></param>
+        public Size(int width, int height)
+        {
+            Width = width;
+            Height = height;
+        }
+
+        #endregion 
+
+        #region Public Methods
+
+        /// <summary>
+        /// Serves as the default hash function.
+        /// </summary>
+        /// <returns></returns>
+        public override int GetHashCode()
+        {
+            int prime = 31;
+            int result = 1;
+            result = prime * result + Height;
+            result = prime * result + Width;
+            return result;
+        }
+
+        /// <summary>
+        /// Determines whether the specified object is equal to the current object.
+        /// </summary>
+        /// <param name="obj"></param>
+        /// <returns></returns>
+        public override bool Equals(Object obj)
+        {
+            if (this == obj)
+                return true;
+            if (obj == null)
+                return false;
+            if (typeof(Size) != obj.GetType())
+                return false;
+            Size other = (Size)obj;
+            if (Height != other.Height)
+                return false;
+            if (Width != other.Width)
+                return false;
+            return true;
+        }
+
+        /// <summary>
+        /// Returns a string that represents the current object.
+        /// </summary>
+        /// <returns></returns>
+        public override string ToString()
+        {
+            return "Size [width=" + Width + ", height=" + Height + "]";
+        }
+
+        #endregion
+    }
+}

+ 228 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/IO/DataInput.cs

@@ -0,0 +1,228 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.IO
+{
+    /// <summary>
+    /// Read input stream of wmf file.
+    /// </summary>
+    public class DataInput
+    {
+        #region Local Variables
+
+        private System.IO.Stream _inputStream;
+        private bool _isLittleEndian = BitConverter.IsLittleEndian;
+
+        private byte[] _buf = new byte[4];
+        private int _count = 0;
+
+        #endregion
+
+        #region Properties
+
+        /// <summary>
+        /// Represents the count of bytes read
+        /// </summary>
+        public int Count
+        {
+            get
+            {
+                return _count;
+            }
+            set
+            {
+                _count = value;
+            }
+        }
+
+        #endregion
+
+        #region Constructors
+
+        /// <summary>
+        /// Default constructor.
+        /// Create a DataInput instance using native order.
+        /// </summary>
+        /// <param name="inputStream"></param>
+	    public DataInput(System.IO.Stream inputStream)
+        {
+            _isLittleEndian = BitConverter.IsLittleEndian;
+            _inputStream = inputStream;
+        }
+
+        /// <summary>
+        /// Default contructor.
+        /// Create a DataInput instance receving the order.
+        /// </summary>
+        /// <param name="inputStream"></param>
+        /// <param name="endian"></param>
+        public DataInput(System.IO.Stream inputStream, bool endian)
+        {
+            _inputStream = inputStream;
+            _isLittleEndian = endian;
+        }
+
+        #endregion 
+
+        #region Public Methods
+
+        /// <summary>
+        /// Reads the next one byte of this input stream as a signed 8-bit integer.
+	    /// </summary>
+	    /// <returns></returns>
+	    public int ReadByte()
+        {
+            if (_inputStream.Read(_buf, 0, 1) == 1)
+            {
+                _count += 1;
+                return (0xff & _buf[0]);
+            }
+            throw new System.IO.EndOfStreamException();
+        }
+
+        /// <summary>
+        /// Reads the next two bytes of this input stream as a signed 16-bit integer.
+        /// </summary>
+        /// <returns></returns>
+        public int ReadInt16()
+        {
+            if (_inputStream.Read(_buf, 0, 2) == 2)
+            {
+                short value = 0;
+                if (_isLittleEndian == false)
+                {
+                    value |= (short)(0xff & _buf[1]);
+                    value |= (short)((0xff & _buf[0]) << 8);
+                }
+                else
+                {
+                    value |= (short)(0xff & _buf[0]);
+                    value |= (short)((0xff & _buf[1]) << 8);
+                }
+                _count += 2;
+                return value;
+            }
+            throw new System.IO.EndOfStreamException();
+        }
+
+        /// <summary>
+        /// Reads the next four bytes of this input stream as a signed 32-bit integer.
+        /// </summary>
+        /// <returns></returns>
+	    public int ReadInt32()
+        {
+            if (_inputStream.Read(_buf, 0, 4) == 4)
+            {
+                int value = 0;
+                if (_isLittleEndian == false)
+                {
+                    value |= (0xff & _buf[3]);
+                    value |= (0xff & _buf[2]) << 8;
+                    value |= (0xff & _buf[1]) << 16;
+                    value |= (0xff & _buf[0]) << 24;
+                }
+                else
+                {
+                    value |= (0xff & _buf[0]);
+                    value |= (0xff & _buf[1]) << 8;
+                    value |= (0xff & _buf[2]) << 16;
+                    value |= (0xff & _buf[3]) << 24;
+                }
+                _count += 4;
+                return value;
+            }
+            throw new System.IO.EndOfStreamException();
+        }
+
+        /// <summary>
+        /// Reads the next two bytes of this input stream as a unsigned 16-bit integer.
+        /// </summary>
+        /// <returns></returns>
+        public int ReadUint16()
+        {
+            if (_inputStream.Read(_buf, 0, 2) == 2)
+            {
+                int value = 0;
+                if (_isLittleEndian == false)
+                {
+                    value |= (0xff & _buf[1]);
+                    value |= (0xff & _buf[0]) << 8;
+                }
+                else
+                {
+                    value |= (0xff & _buf[0]);
+                    value |= (0xff & _buf[1]) << 8;
+                }
+                _count += 2;
+                return value;
+            }
+            throw new System.IO.EndOfStreamException();
+        }
+
+        /// <summary>
+        /// Reads the next four bytes of this input stream as a unsigned 32-bit integer.
+        /// </summary>
+        /// <returns></returns>
+        public long ReadUint32()
+        {
+            if (_inputStream.Read(_buf, 0, 4) == 4)
+            {
+                long value = 0;
+                if (_isLittleEndian == false)
+                {
+                    value |= (0xff & _buf[3]);
+                    value |= (0xff & _buf[2]) << 8;
+                    value |= (0xff & _buf[1]) << 16;
+                    value |= (0xff & _buf[0]) << 24;
+                }
+                else
+                {
+                    value |= (0xff & _buf[0]);
+                    value |= (0xff & _buf[1]) << 8;
+                    value |= (0xff & _buf[2]) << 16;
+                    value |= (0xff & _buf[3]) << 24;
+                }
+                _count += 4;
+                return value;
+            }
+            throw new System.IO.EndOfStreamException();
+        }
+
+        /// <summary>
+        /// Reads the next n bytes.
+        /// </summary>
+        /// <param name="n"></param>
+        /// <returns></returns>
+	    public byte[] ReadBytes(int n)
+        {
+            byte[] array = new byte[n];
+            if (_inputStream.Read(array, 0, array.Length) == n)
+            {
+                _count += n;
+                return array;
+            }
+            throw new System.IO.EndOfStreamException();
+        }
+
+
+        /// <summary>
+        /// Close the input stream.
+        /// </summary>
+        public void Close()
+        {
+            try
+            {
+                _inputStream.Close();
+            }
+            catch (System.IO.IOException ex)
+            {
+                Console.Write(ex.Message);
+            }
+        }
+
+        #endregion 
+    }
+}

+ 132 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/Properties.cs

@@ -0,0 +1,132 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Svg
+{
+    public class Properties : Dictionary<string, string>
+    {
+        public void load()
+        {
+            var props = new Properties();
+            props.Add("alternative-font.\uff2d\uff33\u0020\u30b4\u30b7\u30c3\u30af", "MS Gothic");
+            props.Add("alternative-font.\uff2d\uff33\u0020\uff30\u30b4\u30b7\u30c3\u30af", "MS PGothic");
+            props.Add("alternative-font.\uff2d\uff33\u0020\u660e\u671d", "MS Mincho");
+            props.Add("alternative-font.\uff2d\uff33\u0020\uff30\u660e\u671d", "MS PMincho");
+            props.Add("alternative-font.\u30E1\u30A4\u30EA\u30AA", "Meiryo");
+
+            props.Add("font-emheight.Andalus", "0.655150351887396");
+            props.Add("font-emheight.Angsana\u0020New", "0.740285559371046");
+            props.Add("font-emheight.AngsanaUPC", "0.740285559371046");
+            props.Add("font-emheight.Aparajita", "0.846280991735537");
+            props.Add("font-emheight.Arabic\u0020Typesetting", "0.877463581833762");
+            props.Add("font-emheight.Arial", "0.895104895104895");
+            props.Add("font-emheight.Arial\u0020Black", "0.709141274238227");
+            props.Add("font-emheight.Browallia\u0020New", "0.800312622118015");
+            props.Add("font-emheight.BrowalliaUPC", "0.800312622118015");
+            props.Add("font-emheight.Calibri", "0.8192");
+            props.Add("font-emheight.Cambria", "0.852977925864223");
+            props.Add("font-emheight.Cambria\u0020Math", "0.179208960448022");
+            props.Add("font-emheight.Comic\u0020Sans\u0020MS", "0.717589348283111");
+            props.Add("font-emheight.Consolas", "0.854045037531276");
+            props.Add("font-emheight.Constantia", "0.8192");
+            props.Add("font-emheight.Corbel", "0.8192");
+            props.Add("font-emheight.Cordia\u0020New", "0.721380767876013");
+            props.Add("font-emheight.CordiaUPC", "0.721380767876013");
+            props.Add("font-emheight.Courier\u0020New", "0.882758620689655");
+            props.Add("font-emheight.DaunPenh", "0.745540589734256");
+            props.Add("font-emheight.David", "1.01637717121588");
+            props.Add("font-emheight.DejaVu\u0020Sans", "0.859060402684564");
+            props.Add("font-emheight.DejaVu\u0020Sans\u0020Mono", "0.859060402684564");
+            props.Add("font-emheight.DejaVu\u0020Serif", "0.859060402684564");
+            props.Add("font-emheight.DilleniaUPC", "0.766323666978485");
+            props.Add("font-emheight.DokChampa", "0.516259137887572");
+            props.Add("font-emheight.Dutch801\u0020SWC", "0.844187963726298");
+            props.Add("font-emheight.Ebrima", "0.751835535976505");
+            props.Add("font-emheight.Estrangelo\u0020Edessa", "0.894323144104804");
+            props.Add("font-emheight.EucrosiaUPC", "0.816912644595134");
+            props.Add("font-emheight.Euphemia", "0.761338289962825");
+            props.Add("font-emheight.Franklin\u0020Gothic\u0020Medium", "0.881998277347115");
+            props.Add("font-emheight.FrankRuehl", "1.07563025210084");
+            props.Add("font-emheight.FreesiaUPC", "0.834046019140705");
+            props.Add("font-emheight.Gabriola", "0.543236074270557");
+            props.Add("font-emheight.Gautami", "0.575928008998875");
+            props.Add("font-emheight.Gentium\u0020Basic", "0.864135021097046");
+            props.Add("font-emheight.Gentium\u0020Book\u0020Basic", "0.864135021097046");
+            props.Add("font-emheight.Georgia", "0.880103137086377");
+            props.Add("font-emheight.Gisha", "0.853333333333333");
+            props.Add("font-emheight.Impact", "0.819855884707766");
+            props.Add("font-emheight.IrisUPC", "0.790580968924918");
+            props.Add("font-emheight.Iskoola\u0020Pota", "0.880860215053763");
+            props.Add("font-emheight.JasmineUPC", "0.945958429561201");
+            props.Add("font-emheight.Kalinga", "0.673684210526316");
+            props.Add("font-emheight.Kartika", "0.701129750085587");
+            props.Add("font-emheight.Khmer\u0020UI", "0.883520276100086");
+            props.Add("font-emheight.KodchiangUPC", "1.0173869846001");
+            props.Add("font-emheight.Kokila", "0.867429055484964");
+            props.Add("font-emheight.Lao\u0020UI", "0.751835535976505");
+            props.Add("font-emheight.Latha", "0.728825622775801");
+            props.Add("font-emheight.Leelawadee", "0.836259697835851");
+            props.Add("font-emheight.Levenim\u0020MT", "0.757676655567888");
+            props.Add("font-emheight.Liberation\u0020Sans\u0020Narrow", "0.883139284174213");
+            props.Add("font-emheight.LilyUPC", "1.04944914168588");
+            props.Add("font-emheight.Lingoes\u0020Unicode", "0.746355685131195");
+            props.Add("font-emheight.Linux\u0020Biolinum\u0020G", "0.877087794432548");
+            props.Add("font-emheight.Linux\u0020Libertine\u0020G", "0.877087794432548");
+            props.Add("font-emheight.Lucida\u0020Sans\u0020Unicode", "0.650778519224658");
+            props.Add("font-emheight.Malgun\u0020Gothic", "0.751835535976505");
+            props.Add("font-emheight.Mangal", "0.595348837209302");
+            props.Add("font-emheight.Meiryo\u0020UI", "0.787389465590158");
+            props.Add("font-emheight.Microsoft\u0020JhengHei", "0.751835535976505");
+            props.Add("font-emheight.Microsoft\u0020New\u0020Tai\u0020Lue", "0.764464352370287");
+            props.Add("font-emheight.Microsoft\u0020PhagsPa", "0.781679389312977");
+            props.Add("font-emheight.Microsoft\u0020Sans\u0020Serif", "0.883520276100086");
+            props.Add("font-emheight.Microsoft\u0020Tai\u0020Le", "0.786482334869432");
+            props.Add("font-emheight.Microsoft\u0020YaHei", "0.757676655567888");
+            props.Add("font-emheight.Microsoft\u0020Yi\u0020Baiti", "0.999024390243902");
+            props.Add("font-emheight.Miriam\u0020Fixed", "1.01285855588526");
+            props.Add("font-emheight.Miriam", "0.99514091350826");
+            props.Add("font-emheight.Mongolian\u0020Baiti", "0.940312213039486");
+            props.Add("font-emheight.MoolBoran", "0.745540589734256");
+            props.Add("font-emheight.MV\u0020Boli", "0.620606060606061");
+            props.Add("font-emheight.Narkisim", "1.0123578843302");
+            props.Add("font-emheight.Nyala", "0.957009345794393");
+            props.Add("font-emheight.Palatino\u0020Linotype", "0.741223307998552");
+            props.Add("font-emheight.Plantagenet\u0020Cherokee", "0.787995382839554");
+            props.Add("font-emheight.Raavi", "0.602352941176471");
+            props.Add("font-emheight.Rod", "1.01941264310602");
+            props.Add("font-emheight.Sakkal\u0020Majalla", "0.716083916083916");
+            props.Add("font-emheight.Segoe\u0020Print", "0.573830204539087");
+            props.Add("font-emheight.Segoe\u0020Script", "0.631319358816276");
+            props.Add("font-emheight.Segoe\u0020UI", "0.751835535976505");
+            props.Add("font-emheight.Segoe\u0020UI\u0020Symbol", "0.751835535976505");
+            props.Add("font-emheight.Shonar\u0020Bangla", "0.772538664654847");
+            props.Add("font-emheight.Shruti", "0.594830090037758");
+            props.Add("font-emheight.Simplified\u0020Arabic", "0.603240058910162");
+            props.Add("font-emheight.Simplified\u0020Arabic\u0020Fixed", "0.915921288014311");
+            props.Add("font-emheight.Swiss742\u0020SWC", "0.803452334248725");
+            props.Add("font-emheight.Sylfaen", "0.759362254356693");
+            props.Add("font-emheight.Symbol", "0.816261458748505");
+            props.Add("font-emheight.Tahoma", "0.828478964401295");
+            props.Add("font-emheight.Times\u0020New\u0020Roman", "0.90299823633157");
+            props.Add("font-emheight.Traditional\u0020Arabic", "0.66906239790918");
+            props.Add("font-emheight.Trebuchet\u0020MS", "0.861227922624054");
+            props.Add("font-emheight.Tunga", "0.602352941176471");
+            props.Add("font-emheight.Utsaah", "0.893542757417103");
+            props.Add("font-emheight.Vani", "0.593795302986373");
+            props.Add("font-emheight.Verdana", "0.822820409803134");
+            props.Add("font-emheight.Vijaya", "0.993210475266731");
+            props.Add("font-emheight.Vrinda", "0.732737030411449");
+            props.Add("font-emheight.Wingdings", "0.901011878574571");
+            props.Add("font-emheight.Meiryo", "0.666666666666667");
+
+            props.Add("font-emheight.Academy\u0020Engraved\u0020LET", "0.870748299319728");
+            props.Add("font-emheight.Alma\u0020Iso", "0.997384481255449");
+            props.Add("font-emheight.Alma\u0020Large", "1.57250859106529");
+            props.Add("font-emheight.Alma\u0020Symbol", "0.997384481255449");
+            props.Add("font-emheight.AVGmdBU", "1.00986193293886");
+        }
+    }
+}

+ 271 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgBrush.cs

@@ -0,0 +1,271 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Svg
+{
+    /// <summary>
+    /// Scalable Vector Graphics - Represents a Brush SVG object.
+    /// </summary>
+    public class SvgBrush : SvgObject, Gdi.IGdiBrush
+    {
+        #region Local Variables 
+
+        private int _style;
+        private int _color;
+        private int _hatch;
+
+        #endregion
+
+        #region Properties
+
+        /// <summary>
+        /// Object style.
+        /// </summary>
+        public int Style
+        {
+            get
+            {
+                return _style;
+            }
+        }
+
+        /// <summary>
+        /// Object color.
+        /// </summary>
+        public int Color
+        {
+            get
+            {
+                return _color;
+            }
+        }
+
+        /// <summary>
+        /// Object hatch.
+        /// </summary>
+        public int Hatch
+        {
+            get
+            {
+                return _hatch;
+            }
+        }
+
+        #endregion
+
+        #region Constructors
+
+        /// <summary>
+        /// Default constructor.
+        /// </summary>
+        /// <param name="gdi"></param>
+        /// <param name="style"></param>
+        /// <param name="color"></param>
+        /// <param name="hatch"></param>
+        public SvgBrush(
+            SvgGdi gdi,
+            int style,
+            int color,
+            int hatch)
+            : base(gdi)
+        {
+            _style = style;
+            _color = color;
+            _hatch = hatch;
+        }
+
+        #endregion
+
+        #region Public Methods
+
+        /// <summary>
+        /// Create element FillPatern.
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        public System.Xml.XmlElement CreateFillPattern(string id)
+        {
+            System.Xml.XmlElement pattern = GDI.Document.CreateElement("pattern");
+
+            if (_style == (int)Gdi.BrushBSEnum.BS_HATCHED)
+            {
+                pattern.SetAttribute("id", id);
+                pattern.SetAttribute("patternUnits", "userSpaceOnUse");
+                pattern.SetAttribute("x", "" + ToRealSize(0));
+                pattern.SetAttribute("y", "" + ToRealSize(0));
+                pattern.SetAttribute("width", "" + ToRealSize(8));
+                pattern.SetAttribute("height", "" + ToRealSize(8));
+                GDI.Document.AppendChild(pattern);
+
+                if (GDI.DC.BkMode == (int)Gdi.GdiEnum.OPAQUE)
+                {
+                    System.Xml.XmlElement rect = GDI.Document.CreateElement("rect");
+                    rect.SetAttribute("fill", ToColor(GDI.DC.BkColor));
+                    rect.SetAttribute("x", "" + ToRealSize(0));
+                    rect.SetAttribute("y", "" + ToRealSize(0));
+                    rect.SetAttribute("width", "" + ToRealSize(8));
+                    rect.SetAttribute("height", "" + ToRealSize(8));
+                    pattern.AppendChild(rect);
+                }
+
+                switch (_hatch)
+                {
+                    case (int)Gdi.BrushHSEnum.HS_HORIZONTAL:
+                        {
+                            System.Xml.XmlElement path = GDI.Document.CreateElement("line");
+                            path.SetAttribute("stroke", ToColor(_color));
+                            path.SetAttribute("x1", "" + ToRealSize(0));
+                            path.SetAttribute("y1", "" + ToRealSize(4));
+                            path.SetAttribute("x2", "" + ToRealSize(8));
+                            path.SetAttribute("y2", "" + ToRealSize(4));
+                            pattern.AppendChild(path);
+                        } break;
+                    case (int)Gdi.BrushHSEnum.HS_VERTICAL:
+                        {
+                            System.Xml.XmlElement path = GDI.Document.CreateElement("line");
+                            path.SetAttribute("stroke", ToColor(_color));
+                            path.SetAttribute("x1", "" + ToRealSize(4));
+                            path.SetAttribute("y1", "" + ToRealSize(0));
+                            path.SetAttribute("x2", "" + ToRealSize(4));
+                            path.SetAttribute("y2", "" + ToRealSize(8));
+                            pattern.AppendChild(path);
+                        } break;
+                    case (int)Gdi.BrushHSEnum.HS_FDIAGONAL:
+                        {
+                            System.Xml.XmlElement path = GDI.Document.CreateElement("line");
+                            path.SetAttribute("stroke", ToColor(_color));
+                            path.SetAttribute("x1", "" + ToRealSize(0));
+                            path.SetAttribute("y1", "" + ToRealSize(0));
+                            path.SetAttribute("x2", "" + ToRealSize(8));
+                            path.SetAttribute("y2", "" + ToRealSize(8));
+                            pattern.AppendChild(path);
+                        } break;
+                    case (int)Gdi.BrushHSEnum.HS_BDIAGONAL:
+                        {
+                            System.Xml.XmlElement path = GDI.Document.CreateElement("line");
+                            path.SetAttribute("stroke", ToColor(_color));
+                            path.SetAttribute("x1", "" + ToRealSize(0));
+                            path.SetAttribute("y1", "" + ToRealSize(8));
+                            path.SetAttribute("x2", "" + ToRealSize(8));
+                            path.SetAttribute("y2", "" + ToRealSize(0));
+                            pattern.AppendChild(path);
+                        } break;
+                    case (int)Gdi.BrushHSEnum.HS_CROSS:
+                        {
+                            System.Xml.XmlElement path1 = GDI.Document.CreateElement("line");
+                            path1.SetAttribute("stroke", ToColor(_color));
+                            path1.SetAttribute("x1", "" + ToRealSize(0));
+                            path1.SetAttribute("y1", "" + ToRealSize(4));
+                            path1.SetAttribute("x2", "" + ToRealSize(8));
+                            path1.SetAttribute("y2", "" + ToRealSize(4));
+                            pattern.AppendChild(path1);
+                            System.Xml.XmlElement path2 = GDI.Document.CreateElement("line");
+                            path2.SetAttribute("stroke", ToColor(_color));
+                            path2.SetAttribute("x1", "" + ToRealSize(4));
+                            path2.SetAttribute("y1", "" + ToRealSize(0));
+                            path2.SetAttribute("x2", "" + ToRealSize(4));
+                            path2.SetAttribute("y2", "" + ToRealSize(8));
+                            pattern.AppendChild(path2);
+                        } break;
+                    case (int)Gdi.BrushHSEnum.HS_DIAGCROSS:
+                        {
+                            System.Xml.XmlElement path1 = GDI.Document.CreateElement("line");
+                            path1.SetAttribute("stroke", ToColor(_color));
+                            path1.SetAttribute("x1", "" + ToRealSize(0));
+                            path1.SetAttribute("y1", "" + ToRealSize(0));
+                            path1.SetAttribute("x2", "" + ToRealSize(8));
+                            path1.SetAttribute("y2", "" + ToRealSize(8));
+                            pattern.AppendChild(path1);
+                            System.Xml.XmlElement path2 = GDI.Document.CreateElement("line");
+                            path2.SetAttribute("stroke", ToColor(_color));
+                            path2.SetAttribute("x1", "" + ToRealSize(0));
+                            path2.SetAttribute("y1", "" + ToRealSize(8));
+                            path2.SetAttribute("x2", "" + ToRealSize(8));
+                            path2.SetAttribute("y2", "" + ToRealSize(0));
+                            pattern.AppendChild(path2);
+                        } break;
+                }
+            }
+
+            return pattern;
+        }
+
+        /// <summary>
+        /// Serves as the default hash function.
+        /// </summary>
+        /// <returns></returns>
+        public override int GetHashCode()
+        {
+            int PRIME = 31;
+            int result = 1;
+            result = PRIME * result + _color;
+            result = PRIME * result + _hatch;
+            result = PRIME * result + _style;
+            return result;
+        }
+
+        /// <summary>
+        /// Determines whether the specified object is equal to the current object.
+        /// </summary>
+        /// <param name="obj"></param>
+        /// <returns></returns>
+        public override bool Equals(Object obj)
+        {
+            if (this == obj)
+                return true;
+            if (obj == null)
+                return false;
+            if (typeof(SvgBrush) != obj.GetType())
+                return false;
+            SvgBrush other = (SvgBrush)obj;
+            if (_color != other._color)
+                return false;
+            if (_hatch != other._hatch)
+                return false;
+            if (_style != other._style)
+                return false;
+            return true;
+        }
+
+        /// <summary>
+        /// Create element inner text.
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        public System.Xml.XmlText CreateTextNode(string id)
+        {
+            return GDI.Document.CreateTextNode("." + id + " { " + ToString() + " }\r\n");
+        }
+
+        /// <summary>
+        /// Returns a string that represents the current object.
+        /// </summary>
+        /// <returns></returns>
+        public override string ToString()
+        {
+            System.Text.StringBuilder buffer = new System.Text.StringBuilder();
+
+            // fill
+            switch (_style)
+            {
+                case (int)Gdi.BrushBSEnum.BS_SOLID:
+                    buffer.Append("fill: ").Append(ToColor(_color)).Append("; ");
+                    break;
+                case (int)Gdi.BrushBSEnum.BS_HATCHED:
+                    break;
+                default:
+                    buffer.Append("fill: none; ");
+                    break;
+            }
+
+            if (buffer.Length > 0)
+                buffer.Length = buffer.Length - 1;
+            return buffer.ToString();
+        }
+
+        #endregion
+    }
+}

+ 976 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgDc.cs

@@ -0,0 +1,976 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Svg
+{
+    /// <summary>
+    /// Scalable Vector Graphics - Represents SVG document.
+    /// </summary>
+    public class SvgDc : ICloneable
+    {
+
+        #region Local Variables
+
+        private SvgGdi _gdi;
+
+        private int _dpi = 1440;
+
+        // window
+        private int _wx = 0;
+        private int _wy = 0;
+        private int _ww = 0;
+        private int _wh = 0;
+
+        // window offset
+        private int _wox = 0;
+        private int _woy = 0;
+
+        // window scale
+        private double _wsx = 1.0;
+        private double _wsy = 1.0;
+
+        // mapping scale
+        private double _mx = 1.0;
+        private double _my = 1.0;
+
+        // viewport
+        private int _vx = 0;
+        private int _vy = 0;
+        private int _vw = 0;
+        private int _vh = 0;
+
+        // viewport offset
+        private int _vox = 0;
+        private int _voy = 0;
+
+        // viewport scale
+        private double _vsx = 1.0;
+        private double _vsy = 1.0;
+
+        // current location
+        private int _cx = 0;
+        private int _cy = 0;
+
+        // clip offset
+        private int _cox = 0;
+        private int _coy = 0;
+
+        private int _mapMode = (int)Gdi.GdiEnum.MM_TEXT;
+        private int _bkColor = 0x00FFFFFF;
+        private int _bkMode = (int)Gdi.GdiEnum.OPAQUE;
+        private int _textColor = 0x00000000;
+        private int _textSpace = 0;
+        private int _textAlign = (int)Gdi.GdiEnum.TA_TOP | (int)Gdi.GdiEnum.TA_LEFT;
+        private int _textDx = 0;
+        private int _polyFillMode = (int)Gdi.GdiEnum.ALTERNATE;
+        private int _relAbsMode = 0;
+        private int _rop2Mode = (int)Gdi.GdiEnum.R2_COPYPEN;
+        private int _stretchBltMode = (int)Gdi.GdiEnum.STRETCH_ANDSCANS;
+        private long _layout = 0;
+        private long _mapperFlags = 0;
+
+        private SvgBrush _brush = null;
+        private SvgFont _font = null;
+        private SvgPen _pen = null;
+
+        private System.Xml.XmlElement _mask = null;
+
+        #endregion 
+
+        #region Properties
+
+        /// <summary>
+        /// Background color.
+        /// </summary>
+        public int BkColor
+        {
+            get
+            {
+                return _bkColor;
+            }
+            set
+            {
+                _bkColor = value;
+            }
+        }
+
+        /// <summary>
+        /// Background mode.
+        /// </summary>
+        public int BkMode
+        {
+            get
+            {
+                return _bkMode;
+            }
+            set
+            {
+                _bkColor = value;
+            }
+        }
+
+        /// <summary>
+        /// Text color.
+        /// </summary>
+        public int TextColor
+        {
+            get
+            {
+                return _textColor;
+            }
+            set
+            {
+                _textColor = value;
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public int PolyFillMode
+        {
+            get
+            {
+                return _polyFillMode;
+
+            }
+            set
+            {
+                _polyFillMode = value;
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public int RelAbs
+        {
+            get
+            {
+                return _relAbsMode;
+            }
+            set
+            {
+                _relAbsMode = value;
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public int ROP2
+        {
+            get
+            {
+                return _rop2Mode;
+            }
+            set
+            {
+                _rop2Mode = value;
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public int StretchBltMode
+        {
+            get
+            {
+                return _stretchBltMode;
+            }
+            set
+            {
+                _stretchBltMode = value;
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public int TextSpace
+        {
+            get
+            {
+                return _textSpace;
+            }
+            set
+            {
+                _textSpace = value;
+            }
+        }
+
+        /// <summary>
+        /// Text align.
+        /// </summary>
+        public int TextAlign
+        {
+            get
+            {
+                return _textAlign;
+            }
+            set
+            {
+                _textAlign = value;
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public int TextCharacterExtra
+        {
+            get
+            {
+                return _textDx;
+            }
+            set
+            {
+                _textDx = value;
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public long Layout
+        {
+            get
+            {
+                return _layout;
+            }
+            set
+            {
+                _layout = value;
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public long MapperFlags
+        {
+            get
+            {
+                return _mapperFlags;
+            }
+            set
+            {
+                _mapperFlags = value;
+            }
+        }
+
+        /// <summary>
+        /// Brush instance.
+        /// </summary>
+        public SvgBrush Brush
+        {
+            get
+            {
+                return _brush;
+            }
+            set
+            {
+                _brush = value;
+            }
+        }
+
+        /// <summary>
+        /// Font instance.
+        /// </summary>
+        public SvgFont Font
+        {
+            get
+            {
+                return _font;
+            }
+            set
+            {
+                _font = value;
+            }
+        }
+
+        /// <summary>
+        /// Pen instance.
+        /// </summary>
+        public SvgPen Pen
+        {
+            get
+            {
+                return _pen;
+            }
+            set
+            {
+                _pen = value;
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public System.Xml.XmlElement Mask
+        {
+            get
+            {
+                return _mask;
+            }
+            set
+            {
+                _mask = value;
+            }
+        }
+
+        /// <summary>
+        /// Current X Point.
+        /// </summary>
+        public int CurrentX
+        {
+            get
+            {
+                return _cx;
+            }
+        }
+
+        /// <summary>
+        /// Current Y Point.
+        /// </summary>
+        public int CurrentY
+        {
+            get
+            {
+                return _cy;
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public int OffsetClipX
+        {
+            get
+            {
+                return _cox;
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public int OffsetClipY
+        {
+            get
+            {
+                return _coy;
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public int MapMode
+        {
+            get
+            {
+                return _mapMode;
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public int Dpi
+        {
+            get
+            {
+                return _dpi;
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public int WindowX
+        {
+            get
+            {
+                return _wx;
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public int WindowY
+        {
+            get
+            {
+                return _wy;
+            }
+        }
+
+        /// <summary>
+        /// Represents window width.
+        /// </summary>
+        public int WindowWidth
+        {
+            get
+            {
+                return _ww;
+            }
+        }
+
+        /// <summary>
+        /// Represents window height.
+        /// </summary>
+        public int WindowHeight
+        {
+            get
+            {
+                return _wh;
+            }
+        }
+
+        #endregion
+
+        #region Constructors
+
+        /// <summary>
+        /// Default Constructor.
+        /// </summary>
+        /// <param name="gdi"></param>
+        public SvgDc(SvgGdi gdi)
+        {
+            _gdi = gdi;
+        }
+
+        #endregion
+
+        #region Public Methods
+
+        /// <summary>
+        /// Specifies which window point maps to the viewport origin (0,0).
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="old"></param>
+        public void SetWindowOrgEx(int x, int y, WMFConverter.Gdi.Point old)
+        {
+            if (old != null)
+            {
+                old.X = _wx;
+                old.Y = _wy;
+            }
+            _wx = x;
+            _wy = y;
+        }
+
+        /// <summary>
+        /// Sets the horizontal and vertical extents of the window for a device context by using the specified values.
+        /// </summary>
+        /// <param name="width"></param>
+        /// <param name="height"></param>
+        /// <param name="old"></param>
+        public void SetWindowExtEx(int width, int height, WMFConverter.Gdi.Size old)
+        {
+            if (old != null)
+            {
+                old.Width = _ww;
+                old.Height = _wh;
+            }
+            _ww = width;
+            _wh = height;
+        }
+
+        /// <summary>
+        /// Modifies the window origin for a device context using the specified horizontal and vertical offsets.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="old"></param>
+        public void OffSetWindowOrgEx(int x, int y, WMFConverter.Gdi.Point old)
+        {
+            if (old != null)
+            {
+                old.X = _wox;
+                old.Y = _woy;
+            }
+            _wox += x;
+            _woy += y;
+        }
+
+        /// <summary>
+        /// Modifies the window for a device context using the ratios formed by the specified multiplicands and divisors.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="xd"></param>
+        /// <param name="y"></param>
+        /// <param name="yd"></param>
+        /// <param name="old"></param>
+        public void ScaleWindowExtEx(int x, int xd, int y, int yd, WMFConverter.Gdi.Size old)
+        {
+            // TODO
+            _wsx = (_wsx * x) / xd;
+            _wsy = (_wsy * y) / yd;
+        }
+
+        /// <summary>
+        /// Specifies which device point maps to the window origin (0,0).
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="old"></param>
+        public void SetViewportOrgEx(int x, int y, WMFConverter.Gdi.Point old)
+        {
+            if (old != null)
+            {
+                old.X = _vx;
+                old.Y = _vy;
+            }
+            _vx = x;
+            _vy = y;
+        }
+
+        /// <summary>
+        /// Sets the horizontal and vertical extents of the viewport for a device context by using the specified values.
+        /// </summary>
+        /// <param name="width"></param>
+        /// <param name="height"></param>
+        /// <param name="old"></param>
+        public void SetViewportExtEx(int width, int height, WMFConverter.Gdi.Size old)
+        {
+            if (old != null)
+            {
+                old.Width = _vw;
+                old.Height = _vh;
+            }
+            _vw = width;
+            _vh = height;
+        }
+
+        /// <summary>
+        /// Modifies the viewport origin for a device context using the specified horizontal and vertical offsets.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="old"></param>
+        public void OffSetViewportOrgEx(int x, int y, WMFConverter.Gdi.Point old)
+        {
+            if (old != null)
+            {
+                old.X = _vox;
+                old.Y = _voy;
+            }
+            _vox = x;
+            _voy = y;
+        }
+
+        /// <summary>
+        /// Modifies the viewport for a device context using the ratios formed by the specified multiplicands and divisors.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="xd"></param>
+        /// <param name="y"></param>
+        /// <param name="yd"></param>
+        /// <param name="old"></param>
+        public void ScaleViewportExtEx(int x, int xd, int y, int yd, WMFConverter.Gdi.Size old)
+        {
+            // TODO
+            _vsx = (_vsx * x) / xd;
+            _vsy = (_vsy * y) / yd;
+        }
+
+        /// <summary>
+        /// Moves the clipping region of a device context by the specified offsets.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        public void OffSetClipRgn(int x, int y)
+        {
+            _cox = x;
+            _coy = y;
+        }
+
+        /// <summary>
+        /// Sets the mapping mode of the specified device context. 
+        /// The mapping mode defines the unit of measure used to transform page-space units into device-space units, and also defines the orientation of the device's x and y axes.
+        /// </summary>
+        /// <param name="mode"></param>
+        public void SetMapMode(int mode)
+        {
+            _mapMode = mode;
+            switch (mode)
+            {
+                case (int)Gdi.GdiEnum.MM_HIENGLISH:
+                    _mx = 0.09;
+                    _my = -0.09;
+                    break;
+                case (int)Gdi.GdiEnum.MM_LOENGLISH:
+                    _mx = 0.9;
+                    _my = -0.9;
+                    break;
+                case (int)Gdi.GdiEnum.MM_HIMETRIC:
+                    _mx = 0.03543307;
+                    _my = -0.03543307;
+                    break;
+                case (int)Gdi.GdiEnum.MM_LOMETRIC:
+                    _mx = 0.3543307;
+                    _my = -0.3543307;
+                    break;
+                case (int)Gdi.GdiEnum.MM_TWIPS:
+                    _mx = 0.0625;
+                    _my = -0.0625;
+                    break;
+                default:
+                    _mx = 1.0;
+                    _my = 1.0;
+                    break;
+            }
+        }
+
+        /// <summary>
+        /// Updates the current position to the specified point and optionally returns the previous position.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="old"></param>
+        public void MoveToEx(int x, int y, WMFConverter.Gdi.Point old)
+        {
+            if (old != null)
+            {
+                old.X = _cx;
+                old.Y = _cy;
+            }
+            _cx = x;
+            _cy = y;
+        }
+
+        /// <summary>
+        /// Return the absolute X position from x point.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <returns></returns>
+        public double ToAbsoluteX(double x)
+        {
+            // TODO Handle Viewport
+            return ((_ww >= 0) ? 1 : -1) * (_mx * x - (_wx + _wox)) / _wsx;
+        }
+
+        /// <summary>
+        /// Return the absolute Y position from y point.
+        /// </summary>
+        /// <param name="y"></param>
+        /// <returns></returns>
+        public double ToAbsoluteY(double y)
+        {
+            // TODO Handle Viewport
+            return ((_wh >= 0) ? 1 : -1) * (_my * y - (_wy + _woy)) / _wsy;
+        }
+
+        /// <summary>
+        /// Return the relative X position from x point.
+        /// </summary>
+        /// <param name="x"></param>
+        /// <returns></returns>
+        public double ToRelativeX(double x)
+        {
+            // TODO Handle Viewport
+            return ((_ww >= 0) ? 1 : -1) * (_mx * x) / _wsx;
+        }
+
+        /// <summary>
+        /// Return the relative Y position from y point.
+        /// </summary>
+        /// <param name="y"></param>
+        /// <returns></returns>
+        public double ToRelativeY(double y)
+        {
+            // TODO Handle Viewport
+            return ((_wh >= 0) ? 1 : -1) * (_my * y) / _wsy;
+        }
+
+        /// <summary>
+        /// Define Dpi value
+        /// </summary>
+        /// <param name="dpi"></param>
+        public void SetDpi(int dpi)
+        {
+            _dpi = (dpi > 0) ? dpi : 1440;
+        }
+
+        
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="rop"></param>
+        /// <returns></returns>
+        public string GetRopFilter(long rop)
+        {
+            string name = null;
+            System.Xml.XmlDocument doc = _gdi.Document;
+            
+            if (rop == (int)Gdi.GdiEnum.BLACKNESS)
+            {
+                name = "BLACKNESS_FILTER";
+                System.Xml.XmlElement filter = doc.GetElementById(name);
+                if (filter == null)
+                {
+                    filter = _gdi.Document.CreateElement("filter");
+                    filter.SetAttribute("id", name);
+                    //filter.setIdAttribute("id", true);
+
+                    System.Xml.XmlElement feColorMatrix = doc.CreateElement("feColorMatrix");
+                    feColorMatrix.SetAttribute("type", "matrix");
+                    feColorMatrix.SetAttribute("in", "SourceGraphic");
+                    feColorMatrix.SetAttribute("values", "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0");
+                    filter.AppendChild(feColorMatrix);
+
+                    _gdi.DefsElement.AppendChild(filter);
+                }
+            }
+            else if (rop == (int)Gdi.GdiEnum.NOTSRCERASE)
+            {
+                name = "NOTSRCERASE_FILTER";
+                System.Xml.XmlElement filter = doc.GetElementById(name);
+                if (filter == null)
+                {
+                    filter = _gdi.Document.CreateElement("filter");
+                    filter.SetAttribute("id", name);
+                    //filter.setIdAttribute("id", true);
+
+                    System.Xml.XmlElement feComposite = doc.CreateElement("feComposite");
+                    feComposite.SetAttribute("in", "SourceGraphic");
+                    feComposite.SetAttribute("in2", "BackgroundImage");
+                    feComposite.SetAttribute("operator", "arithmetic");
+                    feComposite.SetAttribute("k1", "1");
+                    feComposite.SetAttribute("result", "result0");
+                    filter.AppendChild(feComposite);
+
+                    System.Xml.XmlElement feColorMatrix = doc.CreateElement("feColorMatrix");
+                    feColorMatrix.SetAttribute("in", "result0");
+                    feColorMatrix.SetAttribute("values", "-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0");
+                    filter.AppendChild(feColorMatrix);
+
+                    _gdi.DefsElement.AppendChild(filter);
+                }
+            }
+            else if (rop == (int)Gdi.GdiEnum.NOTSRCCOPY)
+            {
+                name = "NOTSRCCOPY_FILTER";
+                System.Xml.XmlElement filter = doc.GetElementById(name);
+                if (filter == null)
+                {
+                    filter = _gdi.Document.CreateElement("filter");
+                    filter.SetAttribute("id", name);
+                    //filter.setIdAttribute("id", true);
+
+                    System.Xml.XmlElement feColorMatrix = doc.CreateElement("feColorMatrix");
+                    feColorMatrix.SetAttribute("type", "matrix");
+                    feColorMatrix.SetAttribute("in", "SourceGraphic");
+                    feColorMatrix.SetAttribute("values", "-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0");
+                    filter.AppendChild(feColorMatrix);
+
+                    _gdi.DefsElement.AppendChild(filter);
+                }
+            }
+            else if (rop == (int)Gdi.GdiEnum.SRCERASE)
+            {
+                name = "SRCERASE_FILTER";
+                System.Xml.XmlElement filter = doc.GetElementById(name);
+                if (filter == null)
+                {
+                    filter = _gdi.Document.CreateElement("filter");
+                    filter.SetAttribute("id", name);
+                    //filter.setIdAttribute("id", true);
+
+                    System.Xml.XmlElement feColorMatrix = doc.CreateElement("feColorMatrix");
+                    feColorMatrix.SetAttribute("type", "matrix");
+                    feColorMatrix.SetAttribute("in", "BackgroundImage");
+                    feColorMatrix.SetAttribute("values", "-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0");
+                    feColorMatrix.SetAttribute("result", "result0");
+                    filter.AppendChild(feColorMatrix);
+
+                    System.Xml.XmlElement feComposite = doc.CreateElement("feComposite");
+                    feComposite.SetAttribute("in", "SourceGraphic");
+                    feComposite.SetAttribute("in2", "result0");
+                    feComposite.SetAttribute("operator", "arithmetic");
+                    feComposite.SetAttribute("k2", "1");
+                    feComposite.SetAttribute("k3", "1");
+                    filter.AppendChild(feComposite);
+
+                    _gdi.DefsElement.AppendChild(filter);
+                }
+            }
+            else if (rop == (int)Gdi.GdiEnum.PATINVERT)
+            {
+                // TODO
+            }
+            else if (rop == (int)Gdi.GdiEnum.SRCINVERT)
+            {
+                // TODO
+            }
+            else if (rop == (int)Gdi.GdiEnum.DSTINVERT)
+            {
+                name = "DSTINVERT_FILTER";
+                System.Xml.XmlElement filter = doc.GetElementById(name);
+                if (filter == null)
+                {
+                    filter = _gdi.Document.CreateElement("filter");
+                    filter.SetAttribute("id", name);
+                    //filter.SetIdAttribute("id", true);
+
+                    System.Xml.XmlElement feColorMatrix = doc.CreateElement("feColorMatrix");
+                    feColorMatrix.SetAttribute("type", "matrix");
+                    feColorMatrix.SetAttribute("in", "BackgroundImage");
+                    feColorMatrix.SetAttribute("values", "-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0");
+                    filter.AppendChild(feColorMatrix);
+
+                    _gdi.DefsElement.AppendChild(filter);
+                }
+            }
+            else if (rop == (int)Gdi.GdiEnum.SRCAND)
+            {
+                name = "SRCAND_FILTER";
+                System.Xml.XmlElement filter = doc.GetElementById(name);
+                if (filter == null)
+                {
+                    filter = _gdi.Document.CreateElement("filter");
+                    filter.SetAttribute("id", name);
+                    //filter.setIdAttribute("id", true);
+
+                    System.Xml.XmlElement feComposite = doc.CreateElement("feComposite");
+                    feComposite.SetAttribute("in", "SourceGraphic");
+                    feComposite.SetAttribute("in2", "BackgroundImage");
+                    feComposite.SetAttribute("operator", "arithmetic");
+                    feComposite.SetAttribute("k1", "1");
+                    filter.AppendChild(feComposite);
+
+                    _gdi.DefsElement.AppendChild(filter);
+                }
+            }
+            else if (rop == (int)Gdi.GdiEnum.MERGEPAINT)
+            {
+                name = "MERGEPAINT_FILTER";
+                System.Xml.XmlElement filter = doc.GetElementById(name);
+                if (filter == null)
+                {
+                    filter = _gdi.Document.CreateElement("filter");
+                    filter.SetAttribute("id", name);
+                    //filter.setIdAttribute("id", true);
+
+                    System.Xml.XmlElement feColorMatrix = doc.CreateElement("feColorMatrix");
+                    feColorMatrix.SetAttribute("type", "matrix");
+                    feColorMatrix.SetAttribute("in", "SourceGraphic");
+                    feColorMatrix.SetAttribute("values", "-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0");
+                    feColorMatrix.SetAttribute("result", "result0");
+                    filter.AppendChild(feColorMatrix);
+
+                    System.Xml.XmlElement feComposite = doc.CreateElement("feComposite");
+                    feComposite.SetAttribute("in", "result0");
+                    feComposite.SetAttribute("in2", "BackgroundImage");
+                    feComposite.SetAttribute("operator", "arithmetic");
+                    feComposite.SetAttribute("k1", "1");
+                    filter.AppendChild(feComposite);
+
+                    _gdi.DefsElement.AppendChild(filter);
+                }
+            }
+            else if (rop == (int)Gdi.GdiEnum.MERGECOPY)
+            {
+                // TODO
+            }
+            else if (rop == (int)Gdi.GdiEnum.SRCPAINT)
+            {
+                name = "SRCPAINT_FILTER";
+                System.Xml.XmlElement filter = doc.GetElementById(name);
+                if (filter == null)
+                {
+                    filter = _gdi.Document.CreateElement("filter");
+                    filter.SetAttribute("id", name);
+                    //filter.setIdAttribute("id", true);
+
+                    System.Xml.XmlElement feComposite = doc.CreateElement("feComposite");
+                    feComposite.SetAttribute("in", "SourceGraphic");
+                    feComposite.SetAttribute("in2", "BackgroundImage");
+                    feComposite.SetAttribute("operator", "arithmetic");
+                    feComposite.SetAttribute("k2", "1");
+                    feComposite.SetAttribute("k3", "1");
+                    filter.AppendChild(feComposite);
+
+                    _gdi.DefsElement.AppendChild(filter);
+                }
+            }
+            else if (rop == (int)Gdi.GdiEnum.PATCOPY)
+            {
+                // TODO
+            }
+            else if (rop == (int)Gdi.GdiEnum.PATPAINT)
+            {
+                // TODO
+            }
+            else if (rop == (int)Gdi.GdiEnum.WHITENESS)
+            {
+                name = "WHITENESS_FILTER";
+                System.Xml.XmlElement filter = doc.GetElementById(name);
+                if (filter == null)
+                {
+                    filter = _gdi.Document.CreateElement("filter");
+                    filter.SetAttribute("id", name);
+                    //filter.SetIdAttribute("id", true);
+
+                    System.Xml.XmlElement feColorMatrix = doc.CreateElement("feColorMatrix");
+                    feColorMatrix.SetAttribute("type", "matrix");
+                    feColorMatrix.SetAttribute("in", "SourceGraphic");
+                    feColorMatrix.SetAttribute("values", "1 0 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 1 0");
+                    filter.AppendChild(feColorMatrix);
+
+                    _gdi.DefsElement.AppendChild(filter);
+                }
+            }
+
+            if (name != null)
+            {
+                if (!doc.DocumentElement.HasAttribute("enable-background"))
+                {
+                    doc.DocumentElement.SetAttribute("enable-background", "new");
+                }
+                return "url(#" + name + ")";
+            }
+            return null;
+        }
+
+        /// <summary>
+        /// Clone this object.
+        /// </summary>
+        /// <returns></returns>
+        public object Clone()
+        {
+            return this.Clone();
+        }
+
+        /// <summary>
+        /// Returns a string that represents the current object.
+        /// </summary>
+        /// <returns></returns>
+        public override string ToString()
+        {
+            return "SvgDc [gdi=" + _gdi + ", dpi=" + _dpi + ", wx=" + _wx + ", wy="
+                    + _wy + ", ww=" + _ww + ", wh=" + _wh + ", wox=" + _wox + ", woy="
+                    + _woy + ", wsx=" + _wsx + ", wsy=" + _wsy + ", mx=" + _mx
+                    + ", my=" + _my + ", vx=" + _vx + ", vy=" + _vy + ", vw=" + _vw
+                    + ", vh=" + _vh + ", vox=" + _vox + ", voy=" + _voy + ", vsx="
+                    + _vsx + ", vsy=" + _vsy + ", cx=" + _cx + ", cy=" + _cy
+                    + ", mapMode=" + _mapMode + ", bkColor=" + _bkColor + ", bkMode="
+                    + _bkMode + ", textColor=" + _textColor + ", textSpace="
+                    + _textSpace + ", textAlign=" + _textAlign + ", textDx=" + _textDx
+                    + ", polyFillMode=" + _polyFillMode + ", relAbsMode="
+                    + _relAbsMode + ", rop2Mode=" + _rop2Mode + ", stretchBltMode="
+                    + _stretchBltMode + ", brush=" + _brush + ", font=" + _font
+                    + ", pen=" + _pen + "]";
+        }
+
+        #endregion
+    }
+}

+ 532 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgFont.cs

@@ -0,0 +1,532 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Svg
+{
+    /// <summary>
+    /// Scalable Vector Graphics - Represents a SVG Font object.
+    /// </summary>
+    public class SvgFont : SvgObject,Gdi.IGdiFont
+    {
+        #region Properties
+
+        /// <summary>
+        /// Object height.
+        /// </summary>
+        public int Height
+        {
+            get
+            {
+                return _height;
+            }
+        }
+
+        /// <summary>
+        /// Object width.
+        /// </summary>
+        public int Width
+        {
+            get
+            {
+                return _width;
+            }
+        }
+
+        /// <summary>
+        /// Object escapement.
+        /// </summary>
+        public int Escapement
+        {
+            get
+            {
+                return _escapement;
+            }
+        }
+
+        /// <summary>
+        /// Object orientation
+        /// </summary>
+        public int Orientation
+        {
+            get
+            {
+                return _orientation;
+            }
+        }
+
+        /// <summary>
+        /// Object weight.
+        /// </summary>
+        public int Weight
+        {
+            get
+            {
+                return _weight;
+            }
+        }
+
+        /// <summary>
+        /// Italic font.
+        /// </summary>
+        public bool IsItalic
+        {
+            get
+            {
+                return _italic;
+            }
+        }
+
+        /// <summary>
+        /// Underlined font.
+        /// </summary>
+        public bool IsUnderlined
+        {
+            get
+            {
+                return _underline;
+            }
+        }
+
+        /// <summary>
+        /// Striked font.
+        /// </summary>
+        public bool IsStrikedOut
+        {
+            get
+            {
+                return _strikeout;
+            }
+        }
+
+        /// <summary>
+        /// Object charset.
+        /// </summary>
+        public int Charset
+        {
+            get
+            {
+                return _charset;
+            }
+        }
+
+        /// <summary>
+        /// Object precision.
+        /// </summary>
+        public int OutPrecision
+        {
+            get
+            {
+                return _outPrecision;
+            }
+        }
+
+        /// <summary>
+        /// Object ClipPrecision.
+        /// </summary>
+        public int ClipPrecision
+        {
+            get
+            {
+                return _clipPrecision;
+            }
+        }
+
+        /// <summary>
+        /// Font quality.
+        /// </summary>
+        public int Quality
+        {
+            get
+            {
+                return _quality;
+            }
+        }
+
+        /// <summary>
+        /// Defines pitch and family.
+        /// </summary>
+        public int PitchAndFamily
+        {
+            get
+            {
+                return _pitchAndFamily;
+            }
+        }
+
+        /// <summary>
+        /// Specifies the font name.
+        /// </summary>
+        public string FaceName
+        {
+            get
+            {
+                return _faceName;
+            }
+        }
+
+        /// <summary>
+        /// Font language.
+        /// </summary>
+        public string Lang
+        {
+            get
+            {
+                return _lang;
+            }
+        }
+        
+        /// <summary>
+        /// Font size.
+        /// </summary>
+        public int FontSize
+        {
+            get
+            {
+                return Math.Abs((int)GDI.DC.ToRelativeY(_height * _heightMultiply));
+            }
+        }
+
+        #endregion
+
+        #region Local Variables
+
+        private int _height;
+        private int _width;
+        private int _escapement;
+        private int _orientation;
+        private int _weight;
+        private bool _italic;
+        private bool _underline;
+        private bool _strikeout;
+        private int _charset;
+        private int _outPrecision;
+        private int _clipPrecision;
+        private int _quality;
+        private int _pitchAndFamily;
+
+        private string _faceName;
+        private double _heightMultiply = 1.0;
+        private string _lang;
+
+        #endregion
+
+        #region Constructors
+
+        /// <summary>
+        /// Default Constructor.
+        /// </summary>
+        /// <param name="gdi"></param>
+        /// <param name="height"></param>
+        /// <param name="width"></param>
+        /// <param name="escapement"></param>
+        /// <param name="orientation"></param>
+        /// <param name="weight"></param>
+        /// <param name="italic"></param>
+        /// <param name="underline"></param>
+        /// <param name="strikeout"></param>
+        /// <param name="charset"></param>
+        /// <param name="outPrecision"></param>
+        /// <param name="clipPrecision"></param>
+        /// <param name="quality"></param>
+        /// <param name="pitchAndFamily"></param>
+        /// <param name="faceName"></param>
+        public SvgFont(
+            SvgGdi gdi,
+            int height,
+            int width,
+            int escapement,
+            int orientation,
+            int weight,
+            bool italic,
+            bool underline,
+            bool strikeout,
+            int charset,
+            int outPrecision,
+            int clipPrecision,
+            int quality,
+            int pitchAndFamily,
+            byte[] faceName)
+            : base (gdi)
+        {
+            _height = height;
+            _width = width;
+            _escapement = escapement;
+            _orientation = orientation;
+            _weight = weight;
+            _italic = italic;
+            _underline = underline;
+            _strikeout = strikeout;
+            _charset = charset;
+            _outPrecision = outPrecision;
+            _clipPrecision = clipPrecision;
+            _quality = quality;
+            _pitchAndFamily = pitchAndFamily;
+            _faceName = WMFConverter.Gdi.GdiUtils.ConvertString(faceName, charset);
+
+            // xml:lang
+            _lang = WMFConverter.Gdi.GdiUtils.GetLanguage(charset);
+
+            string emheight = gdi.GetProperty("font-emheight." + _faceName);
+            if (emheight == null)
+            {
+                string alter = gdi.GetProperty("alternative-font." + _faceName);
+                if (alter != null)
+                {
+                    emheight = gdi.GetProperty("font-emheight." + alter);
+                }
+            }
+
+            if (emheight != null)
+            {
+                _heightMultiply = Convert.ToDouble(emheight);
+            }
+        }
+
+        #endregion
+
+        #region Public Methods
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="chars"></param>
+        /// <param name="dx"></param>
+        /// <returns></returns>
+        public int[] ValidateDx(byte[] chars, int[] dx)
+        {
+            if (dx == null || dx.Length == 0)
+            {
+                return null;
+            }
+
+            int[,] area = WMFConverter.Gdi.GdiUtils.GetFirstByteArea(_charset);
+            if (area == null)
+            {
+                return dx;
+            }
+
+            int n = 0;
+            bool skip = false;
+
+            for (int i = 0; i < chars.Length && i < dx.Length; i++)
+            {
+                int c = (0xFF & chars[i]);
+
+                if (skip)
+                {
+                    dx[n - 1] += dx[i];
+                    skip = false;
+                    continue;
+                }
+
+                for (int j = 0; j < area.Length; j++)
+                {
+                    if (area[j,0] <= c && c <= area[j,1])
+                    {
+                        skip = true;
+                        break;
+                    }
+                }
+
+                dx[n++] = dx[i];
+            }
+
+            int[] ndx = new int[n];
+            Array.Copy(dx, 0, ndx, 0, n);
+
+            return ndx;
+        }
+
+        /// <summary>
+        /// Serves as the default hash function.
+        /// </summary>
+        /// <returns></returns>
+        public override int GetHashCode() 
+        {
+		    int PRIME = 31;
+		    int result = 1;
+		    result = PRIME * result + _charset;
+		    result = PRIME * result + _clipPrecision;
+		    result = PRIME * result + _escapement;
+		    result = PRIME * result + ((_faceName == null) ? 0 : _faceName.GetHashCode());
+		    result = PRIME * result + _height;
+		    result = PRIME * result + (_italic ? 1231 : 1237);
+		    result = PRIME * result + _orientation;
+		    result = PRIME * result + _outPrecision;
+		    result = PRIME * result + _pitchAndFamily;
+		    result = PRIME * result + _quality;
+		    result = PRIME * result + (_strikeout ? 1231 : 1237);
+		    result = PRIME * result + (_underline ? 1231 : 1237);
+		    result = PRIME * result + _weight;
+		    result = PRIME * result + _width;
+		    return result;
+	    }
+
+        /// <summary>
+        /// Determines whether the specified object is equal to the current object.
+        /// </summary>
+        /// <param name="obj"></param>
+        /// <returns></returns>
+        public override bool Equals(Object obj) 
+        {
+		    if (this == obj)
+			    return true;
+		    if (obj == null)
+			    return false;
+		    if (typeof(SvgFont) != obj.GetType())
+			    return false;
+		    SvgFont other = (SvgFont) obj;
+		    if (_charset != other._charset)
+			    return false;
+		    if (_clipPrecision != other._clipPrecision)
+			    return false;
+		    if (_escapement != other._escapement)
+			    return false;
+		    if (_faceName == null) 
+            {
+			    if (other._faceName != null)
+				    return false;
+		    } 
+            else if (!_faceName.Equals(other._faceName))
+			    return false;
+		    if (_height != other._height)
+			    return false;
+		    if (_italic != other._italic)
+			    return false;
+		    if (_orientation != other._orientation)
+			    return false;
+		    if (_outPrecision != other._outPrecision)
+			    return false;
+		    if (_pitchAndFamily != other._pitchAndFamily)
+			    return false;
+		    if (_quality != other._quality)
+			    return false;
+		    if (_strikeout != other._strikeout)
+			    return false;
+		    if (_underline != other._underline)
+			    return false;
+		    if (_weight != other._weight)
+			    return false;
+		    if (_width != other._width)
+			    return false;
+		    return true;
+	    }
+
+        /// <summary>
+        /// Create inner text element.
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        public System.Xml.XmlText CreateTextNode(string id)
+        {
+            return GDI.Document.CreateTextNode("." + id + " { " + ToString() + " }\r\n");
+        }
+
+        /// <summary>
+        /// Returns a string that represents the current object.
+        /// </summary>
+        /// <returns></returns>
+        public override string ToString()
+        {
+            System.Text.StringBuilder buffer = new System.Text.StringBuilder();
+
+            // font-style
+            if (_italic)
+                buffer.Append("font-style: italic; ");
+
+            // font-weight
+            if (_weight != (int)Gdi.FontFWEnum.FW_DONTCARE && _weight != (int)Gdi.FontFWEnum.FW_NORMAL)
+            {
+                if (_weight < 100)
+                    _weight = 100;
+                else if (_weight > 900)
+                    _weight = 900;
+                else
+                    _weight = (_weight / 100) * 100;
+
+                if (_weight == (int)Gdi.FontFWEnum.FW_BOLD)
+                    buffer.Append("font-weight: bold; ");
+                else
+                    buffer.Append("font-weight: " + _weight + "; ");
+            }
+
+            int fontSize = FontSize;
+            if (fontSize != 0) 
+                buffer.Append("font-size: ").Append(fontSize).Append("px; ");
+
+            // font-family
+            List<string> fontList = new List<string>();
+            if (_faceName.Length != 0)
+            {
+                string fontFamily = _faceName;
+                if (_faceName.ElementAt(0) == '@') fontFamily = _faceName.Substring(1);
+                fontList.Add(fontFamily);
+
+                string altfont = GDI.GetProperty("alternative-font." + fontFamily);
+                if (altfont != null && altfont.Length != 0)
+                {
+                    fontList.Add(altfont);
+                }
+            }
+
+            // int pitch = pitchAndFamily & 0x00000003;
+            int family = _pitchAndFamily & 0x000000F0;
+            switch (family)
+            {
+                case (int)Gdi.FontFFEnum.FF_DECORATIVE:
+                    fontList.Add("fantasy");
+                    break;
+                case (int)Gdi.FontFFEnum.FF_MODERN:
+                    fontList.Add("monospace");
+                    break;
+                case (int)Gdi.FontFFEnum.FF_ROMAN:
+                    fontList.Add("serif");
+                    break;
+                case (int)Gdi.FontFFEnum.FF_SCRIPT:
+                    fontList.Add("cursive");
+                    break;
+                case (int)Gdi.FontFFEnum.FF_SWISS:
+                    fontList.Add("sans-serif");
+                    break;
+            }
+
+            if (fontList != null)
+                if (fontList.Count()>0)
+                {
+                    buffer.Append("font-family:");
+                    for (int i = 0; i < fontList.Count(); i ++ )
+                    {
+                        string font = fontList[i];
+                        if (font.IndexOf(" ") != -1)
+                            buffer.Append(" \"" + font + "\"");
+                        else
+                            buffer.Append(" " + font);
+
+                        if (i < fontList.Count())
+                            buffer.Append(",");
+                    }
+                    buffer.Append("; ");
+                }
+
+            // text-decoration
+            if (_underline || _strikeout)
+            {
+                buffer.Append("text-decoration:");
+                if (_underline)
+                    buffer.Append(" underline");
+                if (_strikeout)
+                    buffer.Append(" overline");
+                buffer.Append("; ");
+            }
+
+            if (buffer.Length > 0) 
+                buffer.Length = buffer.Length - 1;
+            return buffer.ToString();
+        }
+
+        #endregion
+    }
+}

Datei-Diff unterdrückt, da er zu groß ist
+ 2292 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgGdi.cs


+ 77 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgObject.cs

@@ -0,0 +1,77 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Svg
+{
+    /// <summary>
+    /// Scalable Vector Graphics - SVG base object.
+    /// </summary>
+    public abstract class SvgObject
+    {
+        #region Local Variables
+
+        private SvgGdi _gdi;
+
+        #endregion
+
+        #region Properties
+
+        /// <summary>
+        /// Gdi object instance.
+        /// </summary>
+        /// <returns></returns>
+        public SvgGdi GDI
+        {
+            get
+            {
+                return _gdi;
+            }
+        }
+
+        #endregion
+
+        #region Constructors
+
+        /// <summary>
+        /// Default constructor.
+        /// </summary>
+        /// <param name="gdi"></param>
+        public SvgObject(SvgGdi gdi)
+        {
+            _gdi = gdi;
+        }
+
+        #endregion
+
+        #region Public Methods
+
+        /// <summary>
+        /// Convert to real size.
+        /// </summary>
+        /// <param name="px"></param>
+        /// <returns></returns>
+        public int ToRealSize(int px)
+        {
+            return GDI.DC.Dpi * px / 90;
+        }
+
+        /// <summary>
+        /// Convert int color to rgb color.
+        /// </summary>
+        /// <param name="color"></param>
+        /// <returns></returns>
+        public static string ToColor(int color)
+        {
+            int b = (0x00FF0000 & color) >> 16;
+            int g = (0x0000FF00 & color) >> 8;
+            int r = (0x000000FF & color);
+
+            return "rgb(" + r + "," + g + "," + b + ")";
+        }
+
+        #endregion
+    }
+}

+ 67 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgPalette.cs

@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Svg
+{
+    /// <summary>
+    /// Scalable Vector Graphics - Represents a SVG Palette object.
+    /// </summary>
+    public class SvgPalette: SvgObject, Gdi.IGdiPalette
+    {
+        #region Local Variables
+
+        private int _version;
+        private int[] _entries;
+
+        #endregion
+
+        #region Properties
+
+        /// <summary>
+        /// Object version.
+        /// </summary>
+        public int Version
+        {
+            get
+            {
+                return _version;
+            }
+        }
+
+        /// <summary>
+        /// Object entries.
+        /// </summary>
+        public int[] Entries
+        {
+            get
+            {
+                return _entries;
+            }
+        }
+
+        #endregion
+
+        #region Constructors
+
+        /// <summary>
+        /// Default constructor.
+        /// </summary>
+        /// <param name="gdi"></param>
+        /// <param name="version"></param>
+        /// <param name="entries"></param>
+        public SvgPalette(
+            SvgGdi gdi,
+            int version,
+            int[] entries)
+            :base(gdi)
+        {
+            _version = version;
+            _entries = entries;
+        }
+
+        #endregion
+    }
+}

+ 50 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgPatternBrush.cs

@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Svg
+{
+    /// <summary>
+    /// Scalable Vector Graphics - Represents a SVG Pattern Brush object.
+    /// </summary>
+    public class SvgPatternBrush : SvgObject, Gdi.IGdiPatternBrush
+    {
+        #region Local Variables
+
+        private byte[] _bmp;
+
+        #endregion
+
+        #region Properties
+
+        /// <summary>
+        /// Object patterns
+        /// </summary>
+        public byte[] Pattern
+        {
+            get
+            {
+                return _bmp;
+            }
+        }
+
+        #endregion
+
+        #region Constructors
+
+        /// <summary>
+        /// Default constructor.
+        /// </summary>
+        /// <param name="gdi"></param>
+        /// <param name="bmp"></param>
+        public SvgPatternBrush(SvgGdi gdi, byte[] bmp)
+            : base(gdi)
+        {
+            _bmp = bmp;
+        }
+
+        #endregion
+    }
+}

+ 205 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgPen.cs

@@ -0,0 +1,205 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Svg
+{
+    /// <summary>
+    /// Scalable Vector Graphics - Represents a Pen object.
+    /// </summary>
+    public class SvgPen: SvgObject,Gdi.IGdiPen
+    {
+        #region Local Variables
+
+        private int _style;
+        private int _width;
+        private int _color;
+
+        #endregion
+
+        #region Properties
+
+        /// <summary>
+        /// Object style.
+        /// </summary>
+        public int Style
+        {
+            get
+            {
+                return _style;
+            }
+        }
+
+        /// <summary>
+        /// Object width.
+        /// </summary>
+        public int Width
+        {
+            get
+            {
+                return _width;
+            }
+        }
+
+        /// <summary>
+        /// Object color.
+        /// </summary>
+        public int Color
+        {
+            get
+            {
+                return _color;
+            }
+        }
+
+        #endregion
+
+        #region Constructors
+
+        /// <summary>
+        /// Construdor padrão.
+        /// </summary>
+        /// <param name="gdi"></param>
+        /// <param name="style"></param>
+        /// <param name="width"></param>
+        /// <param name="color"></param>
+        public SvgPen(
+            SvgGdi gdi,
+            int style,
+            int width,
+            int color)
+            :base(gdi)
+        {
+            _style = style;
+            _width = (width > 0) ? width : 1;
+            _color = color;
+        }
+
+        #endregion
+
+        #region Public Methods
+
+        /// <summary>
+        /// Serves as the default hash function.
+        /// </summary>
+        /// <returns></returns>
+        public override int GetHashCode() 
+        {
+		    int PRIME = 31;
+		    int result = 1;
+		    result = PRIME * result + _color;
+		    result = PRIME * result + _style;
+		    result = PRIME * result + _width;
+		    return result;
+	    }
+
+        /// <summary>
+        /// Determines whether the specified object is equal to the current object.
+        /// </summary>
+        /// <param name="obj"></param>
+        /// <returns></returns>
+        public override bool Equals(Object obj) 
+        {
+		    if (this == obj)
+			    return true;
+		    if (obj == null)
+			    return false;
+		    if (typeof(SvgPen) != obj.GetType())
+			    return false;
+		    SvgPen other = (SvgPen) obj;
+		    if (_color != other._color)
+			    return false;
+		    if (_style != other._style)
+			    return false;
+		    if (_width != other._width)
+			    return false;
+		    return true;
+	    }
+
+        /// <summary>
+        /// Create inner text element.
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        public System.Xml.XmlText CreateTextNode(String id)
+        {
+            return GDI.Document.CreateTextNode("." + id + " { " + ToString() + " }\r\n");
+        }
+
+        /// <summary>
+        /// Returns a string that represents the current object.
+        /// </summary>
+        /// <returns></returns>
+        public override string ToString()
+        {
+            System.Text.StringBuilder buffer = new System.Text.StringBuilder();
+
+            if (_style == (int)Gdi.PenPSEnum.PS_NULL)
+            {
+                buffer.Append("stroke: none; ");
+            }
+            else
+            {
+                // stroke
+                buffer.Append("stroke: " + ToColor(_color) + "; ");
+
+                // stroke-width
+                buffer.Append("stroke-width: " + _width + "; ");
+
+                // stroke-linejoin
+                buffer.Append("stroke-linejoin: round; ");
+
+                // stroke-dasharray
+                if (_width == 1 && (int)Gdi.PenPSEnum.PS_DASH <= _style && _style <= (int)Gdi.PenPSEnum.PS_DASHDOTDOT)
+                {
+                    buffer.Append("stroke-dasharray: ");
+                    switch (_style)
+                    {
+                        case (int)Gdi.PenPSEnum.PS_DASH:
+                            buffer.Append(
+                                "" + ToRealSize(18) + "," + ToRealSize(6));
+                            break;
+                        case (int)Gdi.PenPSEnum.PS_DOT:
+                            buffer.Append("" + ToRealSize(3) + "," + ToRealSize(3));
+                            break;
+                        case (int)Gdi.PenPSEnum.PS_DASHDOT:
+                            buffer.Append(
+                                ""
+                                    + ToRealSize(9)
+                                    + ","
+                                    + ToRealSize(3)
+                                    + ","
+                                    + ToRealSize(3)
+                                    + ","
+                                    + ToRealSize(3));
+                            break;
+                        case (int)Gdi.PenPSEnum.PS_DASHDOTDOT:
+                            buffer.Append(
+                                ""
+                                    + ToRealSize(9)
+                                    + ","
+                                    + ToRealSize(3)
+                                    + ","
+                                    + ToRealSize(3)
+                                    + ","
+                                    + ToRealSize(3)
+                                    + ","
+                                    + ToRealSize(3)
+                                    + ","
+                                    + ToRealSize(3));
+                            break;
+                    }
+                    buffer.Append("; ");
+                }
+            }
+
+            if (buffer.Length > 0) 
+                buffer.Length = buffer.Length - 1;
+            return buffer.ToString();
+        }
+
+        #endregion
+    }
+}

+ 149 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgRectRegion.cs

@@ -0,0 +1,149 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Svg
+{
+    /// <summary>
+    /// Scalable Vector Graphics - Represents SVG Rect Region object.
+    /// </summary>
+    public class SvgRectRegion : SvgRegion
+    {
+        #region Local Variables
+
+        private int _left;
+        private int _top;
+        private int _right;
+        private int _bottom;
+
+        #endregion
+
+        #region Properties
+
+        /// <summary>
+        /// Left value.
+        /// </summary>
+        public int Left
+        {
+            get
+            {
+                return _left;
+            }
+        }
+
+        /// <summary>
+        /// Top value.
+        /// </summary>
+        public int Top
+        {
+            get
+            {
+                return _top;
+            }
+        }
+
+        /// <summary>
+        /// Right value.
+        /// </summary>
+        public int Right
+        {
+            get
+            {
+                return _right;
+            }
+        }
+
+        /// <summary>
+        /// Bottom value.
+        /// </summary>
+        public int Bottom
+        {
+            get
+            {
+                return _bottom;
+            }
+        }
+
+        #endregion
+
+        #region Constructors
+
+        /// <summary>
+        /// Default constructor.
+        /// </summary>
+        /// <param name="gdi"></param>
+        /// <param name="left"></param>
+        /// <param name="top"></param>
+        /// <param name="right"></param>
+        /// <param name="bottom"></param>
+        public SvgRectRegion(SvgGdi gdi, int left, int top, int right, int bottom)
+            : base(gdi)
+        {
+            _left = left;
+            _top = top;
+            _right = right;
+            _bottom = bottom;
+        }
+
+        #endregion
+
+        #region Public Methods
+
+        /// <summary>
+        /// Create rect element.
+        /// </summary>
+        /// <returns></returns>
+        public override System.Xml.XmlElement CreateElement()
+        {
+            System.Xml.XmlElement elem = GDI.Document.CreateElement("rect");
+            elem.SetAttribute("x", "" + (int)GDI.DC.ToAbsoluteX(Left));
+            elem.SetAttribute("y", "" + (int)GDI.DC.ToAbsoluteY(Top));
+            elem.SetAttribute("width", "" + (int)GDI.DC.ToRelativeX(Right - Left));
+            elem.SetAttribute("height", "" + (int)GDI.DC.ToRelativeY(Bottom - Top));
+            return elem;
+        }
+
+        /// <summary>
+        /// Serves as the default hash function.
+        /// </summary>
+        /// <returns></returns>
+        public override int GetHashCode() {
+		    int prime = 31;
+		    int result = 1;
+		    result = prime * result + _bottom;
+		    result = prime * result + _left;
+		    result = prime * result + _right;
+		    result = prime * result + _top;
+		    return result;
+	    }
+
+        /// <summary>
+        /// Determines whether the specified object is equal to the current object.
+        /// </summary>
+        /// <param name="obj"></param>
+        /// <returns></returns>
+        public override bool Equals(Object obj)
+        {
+            if (this == obj)
+                return true;
+            if (obj == null)
+                return false;
+            if (typeof(SvgRectRegion) != obj.GetType())
+                return false;
+            SvgRectRegion other = (SvgRectRegion)obj;
+            if (_bottom != other._bottom)
+                return false;
+            if (_left != other._left)
+                return false;
+            if (_right != other._right)
+                return false;
+            if (_top != other._top)
+                return false;
+            return true;
+        }
+
+        #endregion
+    }
+}

+ 38 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Svg/SvgRegion.cs

@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Svg
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    public abstract class SvgRegion : SvgObject, Gdi.IGdiRegion
+    {
+        #region Constructors
+
+        /// <summary>
+        /// Default Constructor.
+        /// </summary>
+        /// <param name="gdi"></param>
+        public SvgRegion(SvgGdi gdi)
+            : base(gdi)
+        {
+
+        }
+
+        #endregion
+
+        #region Public Methods
+
+        /// <summary>
+        /// Create element - abstract method.
+        /// </summary>
+        /// <returns></returns>
+        public abstract System.Xml.XmlElement CreateElement();
+
+        #endregion
+    }
+}

+ 84 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Util/Base64.cs

@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Util
+{
+    /// <summary>
+    /// Base 64 encode
+    /// </summary>
+    public class Base64
+    {
+        #region Local Variables
+
+        private static char[] ENCODE_DATA = {
+		    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
+		    'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
+		    'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
+		    'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
+		    'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
+		    'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
+		    'w', 'x', 'y', 'z', '0', '1', '2', '3',
+		    '4', '5', '6', '7', '8', '9', '+', '/' 
+	    };
+
+        #endregion
+
+        #region Public Methods
+
+        /// <summary>
+        /// Encode byte array.
+        /// </summary>
+        /// <param name="data"></param>
+        /// <returns></returns>
+	    public static string Encode(byte[] data) 
+        {
+		    char[] buffer = null;
+
+		    if (data.Length % 3 == 0) 
+			    buffer = new char[data.Length / 3 * 4];
+		    else 
+			    buffer = new char[(data.Length / 3 + 1) * 4];
+		    
+
+		    int buf = 0;
+		    for (int i = 0; i < data.Length; i++) 
+            {
+			    switch (i % 3) 
+                {
+				    case 0 :
+					    buffer[i / 3 * 4] = ENCODE_DATA[(data[i] & 0xFC) >> 2];
+					    buf = (data[i] & 0x03) << 4;
+					    if (i + 1 == data.Length) 
+                        {
+						    buffer[i / 3 * 4 + 1] = ENCODE_DATA[buf];
+						    buffer[i / 3 * 4 + 2] = '=';
+						    buffer[i / 3 * 4 + 3] = '=';
+					    }
+					    break;
+				    case 1 :
+					    buf += (data[i] & 0xF0) >> 4;
+					    buffer[i / 3 * 4 + 1] = ENCODE_DATA[buf];
+					    buf = (data[i] & 0x0F) << 2;
+					    if (i + 1 == data.Length) 
+                        {
+						    buffer[i / 3 * 4 + 2] = ENCODE_DATA[buf];
+						    buffer[i / 3 * 4 + 3] = '=';
+					    }
+					    break;
+				    case 2 :
+					    buf += (data[i] & 0xC0) >> 6;
+					    buffer[i / 3 * 4 + 2] = ENCODE_DATA[buf];
+					    buffer[i / 3 * 4 + 3] = ENCODE_DATA[data[i] & 0x3F];
+					    break;
+			    }
+		    }
+
+		    return new string(buffer);
+        }
+
+        #endregion
+    }
+}

+ 15 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Util/ImageUtil.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Util
+{
+    
+    public class ImageUtil
+    {
+       //Not implemented.
+	
+    }
+}

+ 74 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfBrush.cs

@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Wmf
+{
+    /// <summary>
+    /// Windows Metafile - Represents WMF Brush object.
+    /// </summary>
+    public class WmfBrush : WmfObject, Gdi.IGdiBrush
+    {
+        #region Local Variables
+
+        private int _style;
+        private int _color;
+        private int _hatch;
+
+        #endregion
+
+        #region Properties
+
+        /// <summary>
+        /// Object Style.
+        /// </summary>
+        public int Style
+        {
+            get
+            {
+                return _style;
+            }
+        }
+
+        /// <summary>
+        /// Object Color.
+        /// </summary>
+        public int Color
+        {
+            get
+            {
+                return _color;
+            }
+        }
+
+        /// <summary>
+        /// Object Hatch.
+        /// </summary>
+        public int Hatch
+        {
+            get
+            {
+                return _hatch;
+            }
+        }
+
+        /// <summary>
+        /// Default Constructor
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="style"></param>
+        /// <param name="color"></param>
+        /// <param name="hatch"></param>
+        public WmfBrush(int id, int style, int color, int hatch)
+            :base (id)
+        {
+            _style = style;
+            _color = color;
+            _hatch = hatch;
+        }
+
+        #endregion
+    }
+}

+ 85 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfConstants.cs

@@ -0,0 +1,85 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Wmf
+{
+    /// <summary>
+    /// Constants Enum.
+    /// </summary>
+    public enum WmfConstants
+    {
+         RECORD_EOF = 0x0000,
+         RECORD_REALIZE_PALETTE = 0x0035,
+         RECORD_SET_PALETTE_ENTRIES = 0x0037,
+         RECORD_SET_BK_MODE = 0x0102,
+         RECORD_SET_MAP_MODE = 0x0103,
+         RECORD_SET_ROP2 = 0x0104,
+         RECORD_SET_REL_ABS = 0x0105,
+         RECORD_SET_POLY_FILL_MODE = 0x0106,
+         RECORD_SET_STRETCH_BLT_MODE = 0x0107,
+         RECORD_SET_TEXT_CHARACTER_EXTRA = 0x0108,
+         RECORD_RESTORE_DC = 0x0127,
+         RECORD_RESIZE_PALETTE = 0x0139,
+         RECORD_DIB_CREATE_PATTERN_BRUSH = 0x0142,
+         RECORD_SET_LAYOUT = 0x0149,
+         RECORD_SET_BK_COLOR = 0x0201,
+         RECORD_SET_TEXT_COLOR = 0x0209,
+         RECORD_OFFSET_VIEWPORT_ORG_EX = 0x0211,
+         RECORD_LINE_TO = 0x0213,
+         RECORD_MOVE_TO_EX = 0x0214,
+         RECORD_OFFSET_CLIP_RGN = 0x0220,
+         RECORD_FILL_RGN = 0x0228,
+         RECORD_SET_MAPPER_FLAGS = 0x0231,
+         RECORD_SELECT_PALETTE = 0x0234,
+         RECORD_POLYGON = 0x0324,
+         RECORD_POLYLINE = 0x0325,
+         RECORD_SET_TEXT_JUSTIFICATION = 0x020A,
+         RECORD_SET_WINDOW_ORG_EX = 0x020B,
+         RECORD_SET_WINDOW_EXT_EX = 0x020C,
+         RECORD_SET_VIEWPORT_ORG_EX = 0x020D,
+         RECORD_SET_VIEWPORT_EXT_EX = 0x020E,
+         RECORD_OFFSET_WINDOW_ORG_EX = 0x020F,
+         RECORD_SCALE_WINDOW_EXT_EX = 0x0410,
+         RECORD_SCALE_VIEWPORT_EXT_EX = 0x0412,
+         RECORD_EXCLUDE_CLIP_RECT = 0x0415,
+         RECORD_INTERSECT_CLIP_RECT = 0x0416,
+         RECORD_ELLIPSE = 0x0418,
+         RECORD_FLOOD_FILL = 0x0419,
+         RECORD_FRAME_RGN = 0x0429,
+         RECORD_ANIMATE_PALETTE = 0x0436,
+         RECORD_TEXT_OUT = 0x0521,
+         RECORD_POLY_POLYGON = 0x0538,
+         RECORD_EXT_FLOOD_FILL = 0x0548,
+         RECORD_RECTANGLE = 0x041B,
+         RECORD_SET_PIXEL = 0x041F,
+         RECORD_ROUND_RECT = 0x061C,
+         RECORD_PAT_BLT = 0x061D,
+         RECORD_SAVE_DC = 0x001E,
+         RECORD_PIE = 0x081A,
+         RECORD_STRETCH_BLT = 0x0B23,
+         RECORD_ESCAPE = 0x0626,
+         RECORD_INVERT_RGN = 0x012A,
+         RECORD_PAINT_RGN = 0x012B,
+         RECORD_SELECT_CLIP_RGN = 0x012C,
+         RECORD_SELECT_OBJECT = 0x012D,
+         RECORD_SET_TEXT_ALIGN = 0x012E,
+         RECORD_ARC = 0x0817,
+         RECORD_CHORD = 0x0830,
+         RECORD_BIT_BLT = 0x0922,
+         RECORD_EXT_TEXT_OUT = 0x0a32,
+         RECORD_SET_DIBITS_TO_DEVICE = 0x0d33,
+         RECORD_DIB_BIT_BLT = 0x0940,
+         RECORD_DIB_STRETCH_BLT = 0x0b41,
+         RECORD_STRETCH_DIBITS = 0x0f43,
+         RECORD_DELETE_OBJECT = 0x01f0,
+         RECORD_CREATE_PALETTE = 0x00f7,
+         RECORD_CREATE_PATTERN_BRUSH = 0x01F9,
+         RECORD_CREATE_PEN_INDIRECT = 0x02FA,
+         RECORD_CREATE_FONT_INDIRECT = 0x02FB,
+         RECORD_CREATE_BRUSH_INDIRECT = 0x02FC,
+         RECORD_CREATE_RECT_RGN = 0x06FF,
+    }
+}

+ 250 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfFont.cs

@@ -0,0 +1,250 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Wmf
+{
+    /// <summary>
+    /// Windows Metafile - Represents WMF Font object.
+    /// </summary>
+    public class WmfFont : WmfObject, Gdi.IGdiFont
+    {
+        #region Local Variables
+
+        private int _height;
+        private int _width;
+        private int _escapement;
+        private int _orientation;
+        private int _weight;
+        private bool _italic;
+        private bool _underline;
+        private bool _strikeout;
+        private int _charset;
+        private int _outPrecision;
+        private int _clipPrecision;
+        private int _quality;
+        private int _pitchAndFamily;
+
+        private string _faceName;
+
+        #endregion
+
+        #region Properties
+
+        /// <summary>
+        /// Object Height.
+        /// </summary>
+        public int Height
+        {
+            get
+            {
+                return _height;
+            }
+        }
+
+        /// <summary>
+        /// Object Width.
+        /// </summary>
+        public int Width
+        {
+            get
+            {
+                return _width;
+            }
+        }
+
+        /// <summary>
+        /// Object Escapement.
+        /// </summary>
+        public int Escapement
+        {
+            get
+            {
+                return _escapement;
+            }
+        }
+
+        /// <summary>
+        /// Object Orientation.
+        /// </summary>
+        public int Orientation
+        {
+            get
+            {
+                return _orientation;
+            }
+        }
+
+        /// <summary>
+        /// Object Weight.
+        /// </summary>
+        public int Weight
+        {
+            get
+            {
+                return _weight;
+            }
+        }
+
+        /// <summary>
+        /// Defines whether the font is italic.
+        /// </summary>
+        public bool IsItalic
+        {
+            get
+            {
+                return _italic;
+            }
+        }
+
+        /// <summary>
+        /// Defines whether the font is underlined.
+        /// </summary>
+        public bool IsUnderlined
+        {
+            get
+            {
+                return _underline;
+            }
+        }
+
+        /// <summary>
+        /// Defines whether the font is striked.
+        /// </summary>
+        public bool IsStrikedOut
+        {
+            get
+            {
+                return _strikeout;
+            }
+        }
+
+        /// <summary>
+        /// Defines the font charset.
+        /// </summary>
+        public int Charset
+        {
+            get
+            {
+                return _charset;
+            }
+        }
+
+        /// <summary>
+        /// Defines the font out precision.
+        /// </summary>
+        public int OutPrecision
+        {
+            get
+            {
+                return _outPrecision;
+            }
+        }
+
+        /// <summary>
+        /// Defines the clip precision.
+        /// </summary>
+        public int ClipPrecision
+        {
+            get
+            {
+                return _clipPrecision;
+            }
+        }
+
+        /// <summary>
+        /// Object quality.
+        /// </summary>
+        public int Quality
+        {
+            get
+            {
+                return _quality;
+            }
+        }
+
+        /// <summary>
+        /// Defines pitch and famility font.
+        /// </summary>
+        public int PitchAndFamily
+        {
+            get
+            {
+                return _pitchAndFamily;
+            }
+        }
+
+        /// <summary>
+        /// Defines face name rules.
+        /// </summary>
+        public string FaceName
+        {
+            get
+            {
+                return _faceName;
+            }
+        }
+
+        #endregion
+
+        #region Constructors
+
+        /// <summary>
+        /// Default Constructor.
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="height"></param>
+        /// <param name="width"></param>
+        /// <param name="escapement"></param>
+        /// <param name="orientation"></param>
+        /// <param name="weight"></param>
+        /// <param name="italic"></param>
+        /// <param name="underline"></param>
+        /// <param name="strikeout"></param>
+        /// <param name="charset"></param>
+        /// <param name="outPrecision"></param>
+        /// <param name="clipPrecision"></param>
+        /// <param name="quality"></param>
+        /// <param name="pitchAndFamily"></param>
+        /// <param name="faceName"></param>
+        public WmfFont(int id,
+            int height,
+            int width,
+            int escapement,
+            int orientation,
+            int weight,
+            bool italic,
+            bool underline,
+            bool strikeout,
+            int charset,
+            int outPrecision,
+            int clipPrecision,
+            int quality,
+            int pitchAndFamily,
+            byte[] faceName)
+            : base (id)
+        {
+
+            _height = height;
+            _width = width;
+            _escapement = escapement;
+            _orientation = orientation;
+            _weight = weight;
+            _italic = italic;
+            _underline = underline;
+            _strikeout = strikeout;
+            _charset = charset;
+            _outPrecision = outPrecision;
+            _clipPrecision = clipPrecision;
+            _quality = quality;
+            _pitchAndFamily = pitchAndFamily;
+            _faceName = WMFConverter.Gdi.GdiUtils.ConvertString(faceName, charset);
+        }
+
+        #endregion
+
+       
+    }
+}

Datei-Diff unterdrückt, da er zu groß ist
+ 1647 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfGdi.cs


+ 49 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfObject.cs

@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Wmf
+{
+    /// <summary>
+    /// Windows Metafile - Represents WMF Object base
+    /// </summary>
+    public class WmfObject : Gdi.IGdiObject
+    {
+        #region Local Variables
+
+        public int _id;
+
+        #endregion
+
+        #region Properties
+
+        /// <summary>
+        /// Object Id.
+        /// </summary>
+        public int Id
+        {
+            get
+            {
+                return _id;
+            }
+        }
+
+        #endregion
+
+        #region Constructors
+
+        /// <summary>
+        /// Default constructor.
+        /// </summary>
+        /// <param name="id"></param>
+        public WmfObject(int id)
+        {
+            _id = id;
+        }
+
+        #endregion
+       
+    }
+}

+ 65 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfPalette.cs

@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Wmf
+{
+    /// <summary>
+    /// Windows Metafile - Represents WMF Palette object.
+    /// </summary>
+    public class WmfPalette: WmfObject, Gdi.IGdiPalette
+    {
+        #region Local Variables
+
+        private int _version;
+        private int[] _entries;
+
+        #endregion
+
+        #region Properties
+
+        /// <summary>
+        /// Object version.
+        /// </summary>
+        public int Version
+        {
+            get
+            {
+                return _version;
+            }
+        }
+
+        /// <summary>
+        /// Object entries.
+        /// </summary>
+        public int[] Entries
+        {
+            get
+            {
+                return _entries;
+            }
+        }
+
+        #endregion
+
+        #region Constructors
+
+        /// <summary>
+        /// Default constructor.
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="version"></param>
+        /// <param name="entries"></param>
+        public WmfPalette(int id, int version, int[] entries)
+            : base(id)
+        {
+            _version = version;
+            _entries = entries;
+        }
+
+        #endregion
+
+    }
+}

+ 30 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfParseException.cs

@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Wmf
+{
+    public class WmfParseException : Exception
+    {
+        public WmfParseException()
+            :base()
+        {
+
+        }
+
+        public WmfParseException(String message)
+            : base(message)
+        {
+
+        }
+
+        public WmfParseException(String message, Exception t)
+            : base(message,t)
+        {
+
+        }
+
+    }
+}

+ 821 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfParser.cs

@@ -0,0 +1,821 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Wmf
+{
+    /// <summary>
+    /// Windows Metafile - Parse WMF to SVG 
+    /// </summary>
+    public class WmfParser
+    {
+        #region Constructors
+
+        /// <summary>
+        /// Default constructor.
+        /// </summary>
+        public WmfParser()
+        {
+        }
+
+        #endregion
+
+        #region Public Methods
+
+        /// <summary>
+        /// Parse WMF file to SVG file.
+        /// </summary>
+        /// <param name="stream"></param>
+        /// <param name="gdi"></param>
+        public void Parse(System.IO.Stream stream, Gdi.IGdi gdi) 
+        {
+            WMFConverter.IO.DataInput binReader = null;
+            bool isEmpty = true;
+
+            try
+            {
+                binReader = new WMFConverter.IO.DataInput(stream, true);
+
+                int mtType = 0;
+                int mtHeaderSize = 0;
+
+                long key = binReader.ReadUint32();
+                isEmpty = false;
+                if (key == -1698247209)//0x9AC6CDD7)
+                {
+                    int hmf = binReader.ReadInt16();
+                    int vsx = binReader.ReadInt16();
+                    int vsy = binReader.ReadInt16();
+                    int vex = binReader.ReadInt16();
+                    int vey = binReader.ReadInt16();
+                    int dpi = binReader.ReadUint16();
+                    long reserved = binReader.ReadUint32();
+                    int checksum = binReader.ReadUint16();
+
+                    gdi.PlaceableHeader(vsx, vsy, vex, vey, dpi);
+
+                    mtType = binReader.ReadUint16();
+                    mtHeaderSize = binReader.ReadUint16();
+                }
+                else
+                {
+                    mtType = (int)(key & 0x0000FFFF);
+                    mtHeaderSize = (int)((key & 0xFFFF0000) >> 16);
+                }
+
+                int mtVersion = binReader.ReadUint16();
+                long mtSize = binReader.ReadUint32();
+                int mtNoObjects = binReader.ReadUint16();
+                long mtMaxRecord = binReader.ReadUint32();
+                int mtNoParameters = binReader.ReadUint16();
+
+                if (mtType != 1 || mtHeaderSize != 9)
+                {
+                    throw new WmfParseException("invalid file format.");
+                }
+
+                gdi.Header();
+
+                WMFConverter.Gdi.IGdiObject[] objs = new WMFConverter.Gdi.IGdiObject[mtNoObjects];
+
+                while (true)
+                {
+                    int size = (int)binReader.ReadUint32() - 3;
+                    int id = binReader.ReadUint16();
+
+                    if (id == (int)WmfConstants.RECORD_EOF)
+                        break; // Last record
+
+                    binReader.Count = 0;
+
+                    switch (id)
+                    {
+                        case (int)WmfConstants.RECORD_REALIZE_PALETTE:
+                            gdi.RealizePalette();
+                            break;
+                        case (int)WmfConstants.RECORD_SET_PALETTE_ENTRIES:
+                            {
+                                int[] entries = new int[binReader.ReadUint16()];
+                                int startIndex = binReader.ReadUint16();
+                                int objID = binReader.ReadUint16();
+                                for (int i = 0; i < entries.Length; i++)
+                                    entries[i] = binReader.ReadInt32();
+                                gdi.SetPaletteEntries((Gdi.IGdiPalette)objs[objID], startIndex, entries);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SET_BK_MODE:
+                            {
+                                int mode = binReader.ReadInt16();
+                                gdi.SetBkMode(mode);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SET_MAP_MODE:
+                            {
+                                int mode = binReader.ReadInt16();
+                                gdi.SetMapMode(mode);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SET_ROP2:
+                            {
+                                int mode = binReader.ReadInt16();
+                                gdi.SetROP2(mode);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SET_REL_ABS:
+                            {
+                                int mode = binReader.ReadInt16();
+                                gdi.SetRelAbs(mode);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SET_POLY_FILL_MODE:
+                            {
+                                int mode = binReader.ReadInt16();
+                                gdi.SetPolyFillMode(mode);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SET_STRETCH_BLT_MODE:
+                            {
+                                int mode = binReader.ReadInt16();
+                                gdi.SetStretchBltMode(mode);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SET_TEXT_CHARACTER_EXTRA:
+                            {
+                                int extra = binReader.ReadInt16();
+                                gdi.SetTextCharacterExtra(extra);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_RESTORE_DC:
+                            {
+                                int dc = binReader.ReadInt16();
+                                gdi.RestoreDC(dc);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_RESIZE_PALETTE:
+                            {
+                                int objID = binReader.ReadUint16();
+                                gdi.ResizePalette((Gdi.IGdiPalette)objs[objID]);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_DIB_CREATE_PATTERN_BRUSH:
+                            {
+                                int usage = binReader.ReadInt32();
+                                byte[] image = binReader.ReadBytes(size * 2 - binReader.Count);
+
+                                for (int i = 0; i < objs.Length; i++)
+                                {
+                                    if (objs[i] == null)
+                                    {
+                                        objs[i] = gdi.DibCreatePatternBrush(image, usage);
+                                        break;
+                                    }
+                                }
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SET_LAYOUT:
+                            {
+                                long layout = binReader.ReadUint32();
+                                gdi.SetLayout(layout);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SET_BK_COLOR:
+                            {
+                                int color = binReader.ReadInt32();
+                                gdi.SetBkColor(color);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SET_TEXT_COLOR:
+                            {
+                                int color = binReader.ReadInt32();
+                                gdi.SetTextColor(color);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_OFFSET_VIEWPORT_ORG_EX:
+                            {
+                                int y = binReader.ReadInt16();
+                                int x = binReader.ReadInt16();
+                                gdi.OffsetViewportOrgEx(x, y, null);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_LINE_TO:
+                            {
+                                int ey = binReader.ReadInt16();
+                                int ex = binReader.ReadInt16();
+                                gdi.LineTo(ex, ey);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_MOVE_TO_EX:
+                            {
+                                int y = binReader.ReadInt16();
+                                int x = binReader.ReadInt16();
+                                gdi.MoveToEx(x, y, null);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_OFFSET_CLIP_RGN:
+                            {
+                                int y = binReader.ReadInt16();
+                                int x = binReader.ReadInt16();
+                                gdi.OffsetClipRgn(x, y);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_FILL_RGN:
+                            {
+                                int brushID = binReader.ReadUint16();
+                                int rgnID = binReader.ReadUint16();
+                                gdi.FillRgn((Gdi.IGdiRegion)objs[rgnID], (Gdi.IGdiBrush)objs[brushID]);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SET_MAPPER_FLAGS:
+                            {
+                                long flag = binReader.ReadUint32();
+                                gdi.SetMapperFlags(flag);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SELECT_PALETTE:
+                            {
+                                bool mode = (binReader.ReadInt16() != 0);
+                                if ((size * 2 - binReader.Count) > 0)
+                                {
+                                    int objID = binReader.ReadUint16();
+                                    gdi.SelectPalette((Gdi.IGdiPalette)objs[objID], mode);
+                                }
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_POLYGON:
+                            {
+                                WMFConverter.Gdi.Point[] points = new WMFConverter.Gdi.Point[binReader.ReadInt16()];
+                                for (int i = 0; i < points.Length; i++)
+                                    points[i] = new WMFConverter.Gdi.Point(binReader.ReadInt16(), binReader.ReadInt16());
+
+                                gdi.Polygon(points);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_POLYLINE:
+                            {
+                                WMFConverter.Gdi.Point[] points = new WMFConverter.Gdi.Point[binReader.ReadInt16()];
+                                for (int i = 0; i < points.Length; i++)
+                                    points[i] = new WMFConverter.Gdi.Point(binReader.ReadInt16(), binReader.ReadInt16());
+
+                                gdi.Polyline(points);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SET_TEXT_JUSTIFICATION:
+                            {
+                                int breakCount = binReader.ReadInt16();
+                                int breakExtra = binReader.ReadInt16();
+                                gdi.SetTextJustification(breakExtra, breakCount);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SET_WINDOW_ORG_EX:
+                            {
+                                int y = binReader.ReadInt16();
+                                int x = binReader.ReadInt16();
+                                gdi.SetWindowOrgEx(x, y, null);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SET_WINDOW_EXT_EX:
+                            {
+                                int height = binReader.ReadInt16();
+                                int width = binReader.ReadInt16();
+                                gdi.SetWindowExtEx(width, height, null);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SET_VIEWPORT_ORG_EX:
+                            {
+                                int y = binReader.ReadInt16();
+                                int x = binReader.ReadInt16();
+                                gdi.SetViewportOrgEx(x, y, null);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SET_VIEWPORT_EXT_EX:
+                            {
+                                int y = binReader.ReadInt16();
+                                int x = binReader.ReadInt16();
+                                gdi.SetViewportExtEx(x, y, null);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_OFFSET_WINDOW_ORG_EX:
+                            {
+                                int y = binReader.ReadInt16();
+                                int x = binReader.ReadInt16();
+                                gdi.OffsetWindowOrgEx(x, y, null);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SCALE_WINDOW_EXT_EX:
+                            {
+                                int yd = binReader.ReadInt16();
+                                int y = binReader.ReadInt16();
+                                int xd = binReader.ReadInt16();
+                                int x = binReader.ReadInt16();
+                                gdi.ScaleWindowExtEx(x, xd, y, yd, null);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SCALE_VIEWPORT_EXT_EX:
+                            {
+                                int yd = binReader.ReadInt16();
+                                int y = binReader.ReadInt16();
+                                int xd = binReader.ReadInt16();
+                                int x = binReader.ReadInt16();
+                                gdi.ScaleViewportExtEx(x, xd, y, yd, null);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_EXCLUDE_CLIP_RECT:
+                            {
+                                int ey = binReader.ReadInt16();
+                                int ex = binReader.ReadInt16();
+                                int sy = binReader.ReadInt16();
+                                int sx = binReader.ReadInt16();
+                                gdi.ExcludeClipRect(sx, sy, ex, ey);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_INTERSECT_CLIP_RECT:
+                            {
+                                int ey = binReader.ReadInt16();
+                                int ex = binReader.ReadInt16();
+                                int sy = binReader.ReadInt16();
+                                int sx = binReader.ReadInt16();
+                                gdi.IntersectClipRect(sx, sy, ex, ey);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_ELLIPSE:
+                            {
+                                int ey = binReader.ReadInt16();
+                                int ex = binReader.ReadInt16();
+                                int sy = binReader.ReadInt16();
+                                int sx = binReader.ReadInt16();
+                                gdi.Ellipse(sx, sy, ex, ey);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_FLOOD_FILL:
+                            {
+                                int color = binReader.ReadInt32();
+                                int y = binReader.ReadInt16();
+                                int x = binReader.ReadInt16();
+                                gdi.FloodFill(x, y, color);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_FRAME_RGN:
+                            {
+                                int height = binReader.ReadInt16();
+                                int width = binReader.ReadInt16();
+                                int brushID = binReader.ReadUint16();
+                                int rgnID = binReader.ReadUint16();
+                                gdi.FrameRgn((Gdi.IGdiRegion)objs[rgnID], (Gdi.IGdiBrush)objs[brushID], width, height);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_ANIMATE_PALETTE:
+                            {
+                                int[] entries = new int[binReader.ReadUint16()];
+                                int startIndex = binReader.ReadUint16();
+                                int objID = binReader.ReadUint16();
+                                for (int i = 0; i < entries.Length; i++)
+                                    entries[i] = binReader.ReadInt32();
+
+                                gdi.AnimatePalette((Gdi.IGdiPalette)objs[objID], startIndex, entries);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_TEXT_OUT:
+                            {
+                                int count = binReader.ReadInt16();
+                                byte[] text = binReader.ReadBytes(count);
+                                if (count % 2 == 1)
+                                {
+                                    binReader.ReadByte();
+                                }
+                                int y = binReader.ReadInt16();
+                                int x = binReader.ReadInt16();
+                                gdi.TextOut(x, y, text);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_POLY_POLYGON:
+                            {
+                                WMFConverter.Gdi.Point[][] points = new WMFConverter.Gdi.Point[binReader.ReadInt16()][];
+                                for (int i = 0; i < points.Length; i++)
+                                    points[i] = new WMFConverter.Gdi.Point[binReader.ReadInt16()];
+
+                                for (int i = 0; i < points.Length; i++)
+                                    for (int j = 0; j < points[i].Length; j++)
+                                        points[i][j] = new WMFConverter.Gdi.Point(binReader.ReadInt16(), binReader.ReadInt16());
+
+
+                                gdi.PolyPolygon(points);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_EXT_FLOOD_FILL:
+                            {
+                                int type = binReader.ReadUint16();
+                                int color = binReader.ReadInt32();
+                                int y = binReader.ReadInt16();
+                                int x = binReader.ReadInt16();
+                                gdi.ExtFloodFill(x, y, color, type);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_RECTANGLE:
+                            {
+                                int ey = binReader.ReadInt16();
+                                int ex = binReader.ReadInt16();
+                                int sy = binReader.ReadInt16();
+                                int sx = binReader.ReadInt16();
+                                gdi.Rectangle(sx, sy, ex, ey);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SET_PIXEL:
+                            {
+                                int color = binReader.ReadInt32();
+                                int y = binReader.ReadInt16();
+                                int x = binReader.ReadInt16();
+                                gdi.SetPixel(x, y, color);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_ROUND_RECT:
+                            {
+                                int rh = binReader.ReadInt16();
+                                int rw = binReader.ReadInt16();
+                                int ey = binReader.ReadInt16();
+                                int ex = binReader.ReadInt16();
+                                int sy = binReader.ReadInt16();
+                                int sx = binReader.ReadInt16();
+                                gdi.RoundRect(sx, sy, ex, ey, rw, rh);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_PAT_BLT:
+                            {
+                                long rop = binReader.ReadUint32();
+                                int height = binReader.ReadInt16();
+                                int width = binReader.ReadInt16();
+                                int y = binReader.ReadInt16();
+                                int x = binReader.ReadInt16();
+                                gdi.PatBlt(x, y, width, height, rop);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SAVE_DC:
+                            {
+                                gdi.SeveDC();
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_PIE:
+                            {
+                                int eyr = binReader.ReadInt16();
+                                int exr = binReader.ReadInt16();
+                                int syr = binReader.ReadInt16();
+                                int sxr = binReader.ReadInt16();
+                                int ey = binReader.ReadInt16();
+                                int ex = binReader.ReadInt16();
+                                int sy = binReader.ReadInt16();
+                                int sx = binReader.ReadInt16();
+                                gdi.Pie(sx, sy, ex, ey, sxr, syr, exr, eyr);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_STRETCH_BLT:
+                            {
+                                long rop = binReader.ReadUint32();
+                                int sh = binReader.ReadInt16();
+                                int sw = binReader.ReadInt16();
+                                int sy = binReader.ReadInt16();
+                                int sx = binReader.ReadInt16();
+                                int dh = binReader.ReadInt16();
+                                int dw = binReader.ReadInt16();
+                                int dy = binReader.ReadInt16();
+                                int dx = binReader.ReadInt16();
+
+                                byte[] image = binReader.ReadBytes(size * 2 - binReader.Count);
+
+                                gdi.StretchBlt(image, dx, dy, dw, dh, sx, sy, sw, sh, rop);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_ESCAPE:
+                            {
+                                byte[] data = binReader.ReadBytes(2 * size);
+                                gdi.Escape(data);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_INVERT_RGN:
+                            {
+                                int rgnID = binReader.ReadUint16();
+                                gdi.InvertRgn((Gdi.IGdiRegion)objs[rgnID]);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_PAINT_RGN:
+                            {
+                                int objID = binReader.ReadUint16();
+                                gdi.PaintRgn((Gdi.IGdiRegion)objs[objID]);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SELECT_CLIP_RGN:
+                            {
+                                int objID = binReader.ReadUint16();
+                                Gdi.IGdiRegion rgn = (objID > 0) ? (Gdi.IGdiRegion)objs[objID] : null;
+                                gdi.SelectClipRgn(rgn);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SELECT_OBJECT:
+                            {
+                                int objID = binReader.ReadUint16();
+                                gdi.SelectObject(objs[objID]);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SET_TEXT_ALIGN:
+                            {
+                                int align = binReader.ReadInt16();
+                                gdi.SetTextAlign(align);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_ARC:
+                            {
+                                int eya = binReader.ReadInt16();
+                                int exa = binReader.ReadInt16();
+                                int sya = binReader.ReadInt16();
+                                int sxa = binReader.ReadInt16();
+                                int eyr = binReader.ReadInt16();
+                                int exr = binReader.ReadInt16();
+                                int syr = binReader.ReadInt16();
+                                int sxr = binReader.ReadInt16();
+                                gdi.Arc(sxr, syr, exr, eyr, sxa, sya, exa, eya);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_CHORD:
+                            {
+                                int eya = binReader.ReadInt16();
+                                int exa = binReader.ReadInt16();
+                                int sya = binReader.ReadInt16();
+                                int sxa = binReader.ReadInt16();
+                                int eyr = binReader.ReadInt16();
+                                int exr = binReader.ReadInt16();
+                                int syr = binReader.ReadInt16();
+                                int sxr = binReader.ReadInt16();
+                                gdi.Chord(sxr, syr, exr, eyr, sxa, sya, exa, eya);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_BIT_BLT:
+                            {
+                                long rop = binReader.ReadUint32();
+                                int sy = binReader.ReadInt16();
+                                int sx = binReader.ReadInt16();
+                                int height = binReader.ReadInt16();
+                                int width = binReader.ReadInt16();
+                                int dy = binReader.ReadInt16();
+                                int dx = binReader.ReadInt16();
+
+                                byte[] image = binReader.ReadBytes(size * 2 - binReader.Count);
+
+                                gdi.BitBlt(image, dx, dy, width, height, sx, sy, rop);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_EXT_TEXT_OUT:
+                            {
+                                int rsize = size;
+
+                                int y = binReader.ReadInt16();
+                                int x = binReader.ReadInt16();
+                                int count = binReader.ReadInt16();
+                                int options = binReader.ReadUint16();
+                                rsize -= 4;
+
+                                int[] rect = null;
+                                if ((options & 0x0006) > 0)
+                                {
+                                    rect = new int[] { binReader.ReadInt16(), binReader.ReadInt16(), binReader.ReadInt16(), binReader.ReadInt16() };
+                                    rsize -= 4;
+                                }
+                                byte[] text = binReader.ReadBytes(count);
+                                if (count % 2 == 1)
+                                    binReader.ReadByte();
+
+                                rsize -= (count + 1) / 2;
+
+                                int[] dx = null;
+                                if (rsize > 0)
+                                {
+                                    dx = new int[rsize];
+                                    for (int i = 0; i < dx.Length; i++)
+                                        dx[i] = binReader.ReadInt16();
+                                }
+                                gdi.ExtTextOut(x, y, options, rect, text, dx);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_SET_DIBITS_TO_DEVICE:
+                            {
+                                int colorUse = binReader.ReadUint16();
+                                int scanlines = binReader.ReadUint16();
+                                int startscan = binReader.ReadUint16();
+                                int sy = binReader.ReadInt16();
+                                int sx = binReader.ReadInt16();
+                                int dh = binReader.ReadInt16();
+                                int dw = binReader.ReadInt16();
+                                int dy = binReader.ReadInt16();
+                                int dx = binReader.ReadInt16();
+
+                                byte[] image = binReader.ReadBytes(size * 2 - binReader.Count);
+
+                                gdi.SetDIBitsToDevice(dx, dy, dw, dh, sx, sy, startscan, scanlines, image, colorUse);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_DIB_BIT_BLT:
+                            {
+                                bool isRop = false;
+
+                                long rop = binReader.ReadUint32();
+                                int sy = binReader.ReadInt16();
+                                int sx = binReader.ReadInt16();
+                                int height = binReader.ReadInt16();
+                                if (height == 0)
+                                {
+                                    height = binReader.ReadInt16();
+                                    isRop = true;
+                                }
+                                int width = binReader.ReadInt16();
+                                int dy = binReader.ReadInt16();
+                                int dx = binReader.ReadInt16();
+
+                                if (isRop)
+                                    gdi.DibBitBlt(null, dx, dy, width, height, sx, sy, rop);
+                                else
+                                {
+                                    byte[] image = binReader.ReadBytes(size * 2 - binReader.Count);
+
+                                    gdi.DibBitBlt(image, dx, dy, width, height, sx, sy, rop);
+                                }
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_DIB_STRETCH_BLT:
+                            {
+                                long rop = binReader.ReadUint32();
+                                int sh = binReader.ReadInt16();
+                                int sw = binReader.ReadInt16();
+                                int sx = binReader.ReadInt16();
+                                int sy = binReader.ReadInt16();
+                                int dh = binReader.ReadInt16();
+                                int dw = binReader.ReadInt16();
+                                int dy = binReader.ReadInt16();
+                                int dx = binReader.ReadInt16();
+
+                                byte[] image = binReader.ReadBytes(size * 2 - binReader.Count);
+
+                                gdi.DibStretchBlt(image, dx, dy, dw, dh, sx, sy, sw, sh, rop);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_STRETCH_DIBITS:
+                            {
+                                long rop = binReader.ReadUint32();
+                                int usage = binReader.ReadUint16();
+                                int sh = binReader.ReadInt16();
+                                int sw = binReader.ReadInt16();
+                                int sy = binReader.ReadInt16();
+                                int sx = binReader.ReadInt16();
+                                int dh = binReader.ReadInt16();
+                                int dw = binReader.ReadInt16();
+                                int dy = binReader.ReadInt16();
+                                int dx = binReader.ReadInt16();
+
+                                byte[] image = binReader.ReadBytes(size * 2 - binReader.Count);
+
+                                gdi.StretchDIBits(dx, dy, dw, dh, sx, sy, sw, sh, image, usage, rop);
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_DELETE_OBJECT:
+                            {
+                                int objID = binReader.ReadUint16();
+                                gdi.DeleteObject(objs[objID]);
+                                objs[objID] = null;
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_CREATE_PALETTE:
+                            {
+                                int version = binReader.ReadUint16();
+                                int[] entries = new int[binReader.ReadUint16()];
+                                for (int i = 0; i < entries.Length; i++)
+                                    entries[i] = binReader.ReadInt32();
+
+
+                                for (int i = 0; i < objs.Length; i++)
+                                {
+                                    if (objs[i] == null)
+                                    {
+                                        objs[i] = gdi.CreatePalette(version, entries);
+                                        break;
+                                    }
+                                }
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_CREATE_PATTERN_BRUSH:
+                            {
+                                byte[] image = binReader.ReadBytes(size * 2 - binReader.Count);
+
+                                for (int i = 0; i < objs.Length; i++)
+                                {
+                                    if (objs[i] == null)
+                                    {
+                                        objs[i] = gdi.CreatePatternBrush(image);
+                                        break;
+                                    }
+                                }
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_CREATE_PEN_INDIRECT:
+                            {
+                                int style = binReader.ReadUint16();
+                                int width = binReader.ReadInt16();
+                                binReader.ReadInt16();
+                                int color = binReader.ReadInt32();
+                                for (int i = 0; i < objs.Length; i++)
+                                {
+                                    if (objs[i] == null)
+                                    {
+                                        objs[i] = gdi.CreatePenIndirect(style, width, color);
+                                        break;
+                                    }
+                                }
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_CREATE_FONT_INDIRECT:
+                            {
+                                int height = binReader.ReadInt16();
+                                int width = binReader.ReadInt16();
+                                int escapement = binReader.ReadInt16();
+                                int orientation = binReader.ReadInt16();
+                                int weight = binReader.ReadInt16();
+                                bool italic = (binReader.ReadByte() == 1);
+                                bool underline = (binReader.ReadByte() == 1);
+                                bool strikeout = (binReader.ReadByte() == 1);
+                                int charset = binReader.ReadByte();
+                                int outPrecision = binReader.ReadByte();
+                                int clipPrecision = binReader.ReadByte();
+                                int quality = binReader.ReadByte();
+                                int pitchAndFamily = binReader.ReadByte();
+                                byte[] faceName = binReader.ReadBytes(size * 2 - binReader.Count);
+
+                                Gdi.IGdiObject obj = gdi.CreateFontIndirect(height, width, escapement, orientation, weight, italic,
+                                        underline, strikeout, charset, outPrecision, clipPrecision, quality, pitchAndFamily,
+                                        faceName);
+
+                                for (int i = 0; i < objs.Length; i++)
+                                {
+                                    if (objs[i] == null)
+                                    {
+                                        objs[i] = obj;
+                                        break;
+                                    }
+                                }
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_CREATE_BRUSH_INDIRECT:
+                            {
+                                int style = binReader.ReadUint16();
+                                int color = binReader.ReadInt32();
+                                int hatch = binReader.ReadUint16();
+                                for (int i = 0; i < objs.Length; i++)
+                                {
+                                    if (objs[i] == null)
+                                    {
+                                        objs[i] = gdi.CreateBrushIndirect(style, color, hatch);
+                                        break;
+                                    }
+                                }
+                                break;
+                            }
+                        case (int)WmfConstants.RECORD_CREATE_RECT_RGN:
+                            {
+                                int ey = binReader.ReadInt16();
+                                int ex = binReader.ReadInt16();
+                                int sy = binReader.ReadInt16();
+                                int sx = binReader.ReadInt16();
+                                for (int i = 0; i < objs.Length; i++)
+                                {
+                                    if (objs[i] == null)
+                                    {
+                                        objs[i] = gdi.CreateRectRgn(sx, sy, ex, ey);
+                                        break;
+                                    }
+                                }
+                                break;
+                            }
+                        default:
+                            {
+                                //log.fine("unsuppored id find: " + id + " (size=" + size + ")");
+                                Console.Write("unsuppored id find:" + id + "(size=" + size + ")");
+                                break;
+                            }
+                    }
+
+                    int rest = size * 2 - binReader.Count;
+                    for (int i = 0; i < rest; i++)
+                    {
+                        binReader.ReadByte();
+                    }
+                }
+                binReader.Close();
+
+                gdi.Footer();
+            }
+            catch (Exception)
+            {
+                if (isEmpty) 
+                    throw new WmfParseException("input file size is zero.");
+            }
+        }
+
+        #endregion
+    }
+}

+ 52 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfPatternBrush.cs

@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Wmf
+{
+    /// <summary>
+    /// Windows Metafile - Represents WMF Pattern Brush object.
+    /// </summary>
+    public class WmfPatternBrush : WmfObject, Gdi.IGdiPatternBrush
+    {
+        #region Local Variables
+
+        private byte[] _image;
+
+        #endregion 
+
+        #region Properties
+
+        /// <summary>
+        /// Object pattern.
+        /// </summary>
+        public byte[] Pattern
+        {
+            get
+            {
+                return _image;
+            }
+        }
+
+        #endregion
+
+        #region Constructors
+
+        /// <summary>
+        /// Default constructor.
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="image"></param>
+        public WmfPatternBrush(int id, byte[] image)
+            : base (id)
+        {
+            _image = image;
+        }
+
+        #endregion 
+
+       
+    }
+}

+ 75 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfPen.cs

@@ -0,0 +1,75 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Wmf
+{
+    /// <summary>
+    /// Windows Metafile - Represents WMF Pen object.
+    /// </summary>
+    class WmfPen: WmfObject,Gdi.IGdiPen
+    {
+        #region Local Variables
+
+        private int _style;
+        private int _width;
+        private int _color;
+
+        #endregion
+
+        #region Properties
+
+        /// <summary>
+        /// Object style.
+        /// </summary>
+        public int Style
+        {
+            get
+            {
+                return _style;
+            }
+        }
+
+        /// <summary>
+        /// Object width.
+        /// </summary>
+        public int Width
+        {
+            get
+            {
+                return _width;
+            }
+        }
+
+        /// <summary>
+        /// Object color.
+        /// </summary>
+        public int Color
+        {
+            get
+            {
+                return _color;
+            }
+        }
+
+        #endregion
+
+        #region Constructors
+
+        /// <summary>
+        /// Default constructor.
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="style"></param>
+        /// <param name="width"></param>
+        /// <param name="color"></param>
+        public WmfPen(int id, int style, int width, int color)
+            : base(id)
+        {
+        }
+
+        #endregion
+    }
+}

+ 92 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfRectRegion.cs

@@ -0,0 +1,92 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Wmf
+{
+    /// <summary>
+    /// Windows Metafile - Representes WMF RecRegion object.
+    /// </summary>
+    public class WmfRectRegion: WmfObject, Gdi.IGdiRegion
+    {
+        #region Local Variables
+
+        private int _left;
+        private int _top;
+        private int _right;
+        private int _bottom;
+
+        #endregion
+
+        #region Properties
+        
+        /// <summary>
+        /// Get left value.
+        /// </summary>
+        public int Left
+        {
+            get
+            {
+                return _left;
+            }
+        }
+
+        /// <summary>
+        /// Get top value.
+        /// </summary>
+        public int Top
+        {
+            get
+            {
+                return _top;
+            }
+        }
+
+        /// <summary>
+        /// Get right value.
+        /// </summary>
+        public int Right
+        {
+            get
+            {
+                return _right;
+            }
+        }
+
+        /// <summary>
+        /// Get Bottom value.
+        /// </summary>
+        public int Bottom
+        {
+            get
+            {
+                return _bottom;
+            }
+        }
+
+        #endregion
+
+        #region Constructors
+
+        /// <summary>
+        /// Default constructor.
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="left"></param>
+        /// <param name="top"></param>
+        /// <param name="right"></param>
+        /// <param name="bottom"></param>
+        public WmfRectRegion(int id, int left, int top, int right, int bottom)
+            :base(id)
+        {
+            _left = left;
+            _top = top;
+            _right = right;
+            _bottom = bottom;
+        }
+
+        #endregion
+    }
+}

+ 27 - 0
TEAMModelOS.HTEXLib/COMM/Helpers/WMFConverter/Wmf/WmfRegion.cs

@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WMFConverter.Wmf
+{
+    /// <summary>
+    /// Windows Metafile - Represents WMF Region.
+    /// </summary>
+    public class WmfRegion : WmfObject,Gdi.IGdiRegion
+    {
+        #region Constructors
+
+        /// <summary>
+        /// Default constructor.
+        /// </summary>
+        /// <param name="id"></param>
+        public WmfRegion(int id)
+            :base (id)
+        {
+        }
+
+        #endregion
+    }
+}

+ 23 - 0
TEAMModelOS.HTEXLib/COMM/TransException.cs

@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Xml.Linq;
+
+namespace HTEXLib.COMM
+{
+    public class TransException : Exception
+    {
+        public XElement node { get; set; }
+        public TransException(XElement node) : base()
+        {
+           this. node = node;
+        }
+        public TransException(XElement node,string message):base(message) {
+            this.node = node;
+        }
+        public TransException(XElement node,string message, Exception innerException) : base(message, innerException)
+        {
+            this.node = node;
+        }
+    }
+}

+ 24 - 0
TEAMModelOS.HTEXLib/DOCX/Models/ItemInfo.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Text;
+
+namespace HTEXLib.DOCX.Models
+{
+    public class ItemInfo : BaseItem
+    {
+        public ItemInfo() {
+            answer = new List<string>();
+            knowledge = new List<string>();
+            gradeIds = new List<string>();
+            repair = new List<Repair>();
+            children = new List<ItemInfo>();
+            option = new List<CodeValue>();
+        }
+
+        public    List<ItemInfo> children { get; set; }
+        public string question { get; set; }
+        // 选项 单选 多选 判断
+        public List<CodeValue> option { get; set; }
+    }
+}

+ 38 - 0
TEAMModelOS.HTEXLib/DOCX/Models/LangConfig.cs

@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HTEXLib.DOCX.Models
+{
+    public class TagConfig {
+
+        public string Options{ get; set; }
+        public string Start { get; set; }
+        public string End { get; set; }
+        public List<LangConfig> LangConfig { get; set; }
+    }
+    public class LangConfig
+    {
+        public string Lang { get; set; }
+        public string Name { get; set; }
+        public string Alias { get; set; }
+        public ItemConfig Item { get; set; }
+    }
+    public class ItemConfig
+    {
+        public Dictionary<string, string> Type { get; set; }
+        public string Answer { get; set; }
+        public string Analysis { get; set; }
+        public string Ended { get; set; }
+        public string Options { get; set; }
+        public string Start { get; set; }
+        public string End { get; set; }
+        public string Score { get; set; }
+        public string Point { get; set; }
+        public string Filed { get; set; }
+        public string Judge { get; set; }
+        public string Level { get; set; }
+        public string Count { get; set; }
+        public string Taxonomy { get; set; }
+    }
+}

+ 12 - 0
TEAMModelOS.HTEXLib/DOCX/Models/ReplaceDto.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HTEXLib.DOCX.Models
+{
+    public class ReplaceDto
+    {
+        public string oldstr { get; set; }
+        public string newstr { get; set; }
+    }
+}

+ 602 - 0
TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/ChartUpdater.cs

@@ -0,0 +1,602 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Xml.Linq;
+using DocumentFormat.OpenXml.Packaging;
+using OpenXmlPowerTools;
+
+namespace OpenXmlPowerTools
+{
+    public enum ChartDataType
+    {
+        Number,
+        String,
+        DateTime,
+    }
+
+    // Format Codes
+    // 0 - general
+    // 1 - 0
+    // 2 - 0.00
+    // 3 - #,##0
+    // 4 - #,##0.00
+    // 9 - 0%
+    // 10 - 0.00%
+    // 11 - 0.00E+00
+    // 12 - # ?/?
+    // 13 - # ??/??
+    // 14 - mm-dd-yy
+    // 15 - d-mmm-yy
+    // 16 - d-mmm
+    // 17 - mmm-yy
+    // 18 - h:mm AM/PM
+    // 19 - h:mm:ss AM/PM
+    // 20 - h:mm
+    // 21 - h:mm:ss
+    // 22 - m/d/yy h:mm
+    // 37 - #,##0 ;(#,##0)
+    // 38 - #,##0 ;[Red](#,##0)
+    // 39 - #,##0.00;(#,##0.00)
+    // 40 - #,##0.00;[Red](#,##0.00)
+    // 45 - mm:ss
+    // 46 - [h]:mm:ss
+    // 47 - mmss.0
+    // 48 - ##0.0E+0
+    // 49 - @
+
+    public class ChartData
+    {
+        public string[] SeriesNames;
+
+        public ChartDataType CategoryDataType;
+        public int CategoryFormatCode;
+        public string[] CategoryNames;
+
+        public double[][] Values;
+    }
+
+    public class ChartUpdater
+    {
+        public static bool UpdateChart(WordprocessingDocument wDoc, string contentControlTag, ChartData chartData)
+        {
+            var mainDocumentPart = wDoc.MainDocumentPart;
+            var mdXDoc = mainDocumentPart.GetXDocument();
+            var cc = mdXDoc.Descendants(W.sdt)
+                .FirstOrDefault(sdt => (string)sdt.Elements(W.sdtPr).Elements(W.tag).Attributes(W.val).FirstOrDefault() == contentControlTag);
+            if (cc != null)
+            {
+                var chartRid = (string)cc.Descendants(C.chart).Attributes(R.id).FirstOrDefault();
+                if (chartRid != null)
+                {
+                    ChartPart chartPart = (ChartPart)mainDocumentPart.GetPartById(chartRid);
+                    UpdateChart(chartPart, chartData);
+                    var newContent = cc.Elements(W.sdtContent).Elements().Select(e => new XElement(e));
+                    cc.ReplaceWith(newContent);
+                    mainDocumentPart.PutXDocument();
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        public static void UpdateChart(ChartPart chartPart, ChartData chartData)
+        {
+            if (chartData.Values.Length != chartData.SeriesNames.Length)
+                throw new ArgumentException("Invalid chart data");
+            foreach (var ser in chartData.Values)
+            {
+                if (ser.Length != chartData.CategoryNames.Length)
+                    throw new ArgumentException("Invalid chart data");
+            }
+
+            UpdateSeries(chartPart, chartData);
+        }
+
+        private static Dictionary<int, string> FormatCodes = new Dictionary<int, string>()
+        {
+            { 0, "general" },
+            { 1, "0" },
+            { 2, "0.00" },
+            { 3, "#,##0" },
+            { 4, "#,##0.00" },
+            { 9, "0%" },
+            { 10, "0.00%" },
+            { 11, "0.00E+00" },
+            { 12, "# ?/?" },
+            { 13, "# ??/??" },
+            { 14, "mm-dd-yy" },
+            { 15, "d-mmm-yy" },
+            { 16, "d-mmm" },
+            { 17, "mmm-yy" },
+            { 18, "h:mm AM/PM" },
+            { 19, "h:mm:ss AM/PM" },
+            { 20, "h:mm" },
+            { 21, "h:mm:ss" },
+            { 22, "m/d/yy h:mm" },
+            { 37, "#,##0 ;(#,##0)" },
+            { 38, "#,##0 ;[Red](#,##0)" },
+            { 39, "#,##0.00;(#,##0.00)" },
+            { 40, "#,##0.00;[Red](#,##0.00)" },
+            { 45, "mm:ss" },
+            { 46, "[h]:mm:ss" },
+            { 47, "mmss.0" },
+            { 48, "##0.0E+0" },
+            { 49, "@" },
+        };
+
+        private static void UpdateSeries(ChartPart chartPart, ChartData chartData)
+        {
+            UpdateEmbeddedWorkbook(chartPart, chartData);
+
+            XDocument cpXDoc = chartPart.GetXDocument();
+            XElement root = cpXDoc.Root;
+            var firstSeries = root.Descendants(C.ser).FirstOrDefault();
+            var numRef = firstSeries.Elements(C.val).Elements(C.numRef).FirstOrDefault();
+            string sheetName = null;
+            var f = (string)firstSeries.Descendants(C.f).FirstOrDefault();
+            if (f != null)
+                sheetName = f.Split('!')[0];
+
+            // remove all but first series
+            XName chartType = firstSeries.Parent.Name;
+            firstSeries.Parent.Elements(C.ser).Skip(1).Remove();
+
+            var newSetOfSeries = chartData.SeriesNames
+                .Select((string sn, int si) =>
+                {
+                    XElement cat = null;
+
+                    var oldCat = firstSeries.Elements(C.cat).FirstOrDefault();
+                    if (oldCat == null)
+                        throw new OpenXmlPowerToolsException("Invalid chart markup");
+
+                    var catHasFormula = oldCat.Descendants(C.f).Any();
+                    if (catHasFormula)
+                    {
+                        XElement newFormula = null;
+                        if (sheetName != null)
+                            newFormula = new XElement(C.f, string.Format("{0}!$A$2:$A${1}", sheetName, chartData.CategoryNames.Length + 1));
+                        if (chartData.CategoryDataType == ChartDataType.String)
+                        {
+                            cat = new XElement(C.cat,
+                                new XElement(C.strRef,
+                                    newFormula,
+                                    new XElement(C.strCache,
+                                        new XElement(C.ptCount, new XAttribute("val", chartData.CategoryNames.Length)),
+                                        chartData.CategoryNames.Select((string cn, int ci) =>
+                                        {
+                                            var newPt = new XElement(C.pt,
+                                                new XAttribute("idx", ci),
+                                                new XElement(C.v, chartData.CategoryNames[ci]));
+                                            return newPt;
+                                        }))));
+                        }
+                        else
+                        {
+                            cat = new XElement(C.cat,
+                                new XElement(C.numRef,
+                                    newFormula,
+                                    new XElement(C.numCache,
+                                        new XElement(C.formatCode, FormatCodes[chartData.CategoryFormatCode]),
+                                        new XElement(C.ptCount, new XAttribute("val", chartData.CategoryNames.Length)),
+                                        chartData.CategoryNames.Select((string cn, int ci) =>
+                                        {
+                                            var newPt = new XElement(C.pt,
+                                                new XAttribute("idx", ci),
+                                                new XElement(C.v, chartData.CategoryNames[ci]));
+                                            return newPt;
+                                        }))));
+                        }
+                    }
+                    else
+                    {
+                        if (chartData.CategoryDataType == ChartDataType.String)
+                        {
+                            cat = new XElement(C.cat,
+                                new XElement(C.strLit,
+                                    new XElement(C.ptCount, new XAttribute("val", chartData.CategoryNames.Length)),
+                                    chartData.CategoryNames.Select((string cn, int ci) =>
+                                    {
+                                        var newPt = new XElement(C.pt,
+                                            new XAttribute("idx", ci),
+                                            new XElement(C.v, chartData.CategoryNames[ci]));
+                                        return newPt;
+                                    })));
+                        }
+                        else
+                        {
+                            cat = new XElement(C.cat,
+                                new XElement(C.numLit,
+                                    new XElement(C.ptCount, new XAttribute("val", chartData.CategoryNames.Length)),
+                                    chartData.CategoryNames.Select((string cn, int ci) =>
+                                    {
+                                        var newPt = new XElement(C.pt,
+                                            new XAttribute("idx", ci),
+                                            new XElement(C.v, chartData.CategoryNames[ci]));
+                                        return newPt;
+                                    })));
+                        }
+                    }
+
+                    XElement newCval = null;
+
+                    if (sheetName == null)
+                    {
+                        newCval = new XElement(C.val,
+                                new XElement(C.numLit,
+                                    new XElement(C.ptCount, new XAttribute("val", chartData.CategoryNames.Length)),
+                                    chartData.CategoryNames.Select((string cn, int ci) =>
+                                    {
+                                        var newPt = new XElement(C.pt,
+                                            new XAttribute("idx", ci),
+                                            new XElement(C.v, chartData.Values[si][ci]));
+                                        return newPt;
+                                    })));
+                    }
+                    else
+                    {
+                        newCval = new XElement(C.val,
+                                new XElement(C.numRef,
+                                    sheetName != null ?
+                                        new XElement(C.f, string.Format("{0}!${2}$2:${2}${1}", sheetName, chartData.CategoryNames.Length + 1, SpreadsheetMLUtil.IntToColumnId(si + 1))) : null,
+                                    new XElement(C.numCache,
+                                        sheetName != null ? numRef.Descendants(C.formatCode) : null,
+                                        new XElement(C.ptCount, new XAttribute("val", chartData.CategoryNames.Length)),
+                                        chartData.CategoryNames.Select((string cn, int ci) =>
+                                        {
+                                            var newPt = new XElement(C.pt,
+                                                new XAttribute("idx", ci),
+                                                new XElement(C.v, chartData.Values[si][ci]));
+                                            return newPt;
+                                        }))));
+                    }
+
+                    var serHasFormula = firstSeries.Descendants(C.f).Any();
+                    XElement tx = null;
+                    if (serHasFormula)
+                    {
+                        XElement newFormula = null;
+                        if (sheetName != null)
+                            newFormula = new XElement(C.f, string.Format("{0}!${1}$1", sheetName, SpreadsheetMLUtil.IntToColumnId(si + 1)));
+                        tx = new XElement(C.tx,
+                            new XElement(C.strRef,
+                                newFormula,
+                                new XElement(C.strCache,
+                                    new XElement(C.ptCount, new XAttribute("val", 1)),
+                                    new XElement(C.pt,
+                                        new XAttribute("idx", 0),
+                                        new XElement(C.v, chartData.SeriesNames[si])))));
+                    }
+                    else
+                    {
+                        tx = new XElement(C.tx,
+                            new XElement(C.v, chartData.SeriesNames[si]));
+                    }
+
+                    XElement newSer = null;
+
+                    if (chartType == C.area3DChart || chartType == C.areaChart)
+                    {
+                        newSer = new XElement(C.ser,
+                            // common
+                            new XElement(C.idx, new XAttribute("val", si)),
+                            new XElement(C.order, new XAttribute("val", si)),
+                            tx,
+                            firstSeries.Elements(C.spPr),
+
+                            // CT_AreaSer
+                            firstSeries.Elements(C.pictureOptions),
+                            firstSeries.Elements(C.dPt),
+                            firstSeries.Elements(C.dLbls),
+                            firstSeries.Elements(C.trendline),
+                            firstSeries.Elements(C.errBars),
+                            cat,
+                            newCval,
+                            firstSeries.Elements(C.extLst));
+                    }
+                    else if (chartType == C.bar3DChart || chartType == C.barChart)
+                    {
+                        newSer = new XElement(C.ser,
+                            // common
+                            new XElement(C.idx, new XAttribute("val", si)),
+                            new XElement(C.order, new XAttribute("val", si)),
+                            tx,
+                            firstSeries.Elements(C.spPr),
+
+                            // CT_BarSer
+                            firstSeries.Elements(C.invertIfNegative),
+                            firstSeries.Elements(C.pictureOptions),
+                            firstSeries.Elements(C.dPt),
+                            firstSeries.Elements(C.dLbls),
+                            firstSeries.Elements(C.trendline),
+                            firstSeries.Elements(C.errBars),
+                            cat,
+                            newCval,
+                            firstSeries.Elements(C.shape),
+                            firstSeries.Elements(C.extLst));
+                    }
+                    else if (chartType == C.line3DChart || chartType == C.lineChart || chartType == C.stockChart)
+                    {
+                        newSer = new XElement(C.ser,
+                            // common
+                            new XElement(C.idx, new XAttribute("val", si)),
+                            new XElement(C.order, new XAttribute("val", si)),
+                            tx,
+                            firstSeries.Elements(C.spPr),
+
+                            // CT_LineSer
+                            firstSeries.Elements(C.marker),
+                            firstSeries.Elements(C.dPt),
+                            firstSeries.Elements(C.dLbls),
+                            firstSeries.Elements(C.trendline),
+                            firstSeries.Elements(C.errBars),
+                            cat,
+                            newCval,
+                            firstSeries.Elements(C.smooth),
+                            firstSeries.Elements(C.extLst));
+                    }
+                    else if (chartType == C.doughnutChart || chartType == C.ofPieChart || chartType == C.pie3DChart || chartType == C.pieChart)
+                    {
+                        newSer = new XElement(C.ser,
+                            // common
+                            new XElement(C.idx, new XAttribute("val", si)),
+                            new XElement(C.order, new XAttribute("val", si)),
+                            tx,
+                            firstSeries.Elements(C.spPr),
+
+                            // CT_PieSer
+                            firstSeries.Elements(C.explosion),
+                            firstSeries.Elements(C.dPt),
+                            firstSeries.Elements(C.dLbls),
+                            cat,
+                            newCval,
+                            firstSeries.Elements(C.extLst));
+                    }
+                    else if (chartType == C.surface3DChart || chartType == C.surfaceChart)
+                    {
+                        newSer = new XElement(C.ser,
+                            // common
+                            new XElement(C.idx, new XAttribute("val", si)),
+                            new XElement(C.order, new XAttribute("val", si)),
+                            tx,
+                            firstSeries.Elements(C.spPr),
+
+                            // CT_SurfaceSer
+                            cat,
+                            newCval,
+                            firstSeries.Elements(C.extLst));
+                    }
+
+                    if (newSer == null)
+                        throw new OpenXmlPowerToolsException("Unsupported chart type");
+
+                    int accentNumber = (si % 6) + 1;
+                    newSer = (XElement)UpdateAccentTransform(newSer, accentNumber);
+                    return newSer;
+                });
+            firstSeries.ReplaceWith(newSetOfSeries);
+            chartPart.PutXDocument();
+        }
+
+        private static void UpdateEmbeddedWorkbook(ChartPart chartPart, ChartData chartData)
+        {
+            XDocument cpXDoc = chartPart.GetXDocument();
+            XElement root = cpXDoc.Root;
+            var firstSeries = root.Descendants(C.ser).FirstOrDefault();
+            if (firstSeries == null)
+                return;
+            var firstFormula = (string)firstSeries.Descendants(C.f).FirstOrDefault();
+            if (firstFormula == null)
+                return;
+            var sheet = firstFormula.Split('!')[0];
+            var embeddedSpreadsheetRid = (string)root.Descendants(C.externalData).Attributes(R.id).FirstOrDefault();
+            if (embeddedSpreadsheetRid == null)
+                return;
+            var embeddedSpreadsheet = chartPart.GetPartById(embeddedSpreadsheetRid);
+            if (embeddedSpreadsheet != null)
+            {
+                using (SpreadsheetDocument sDoc = SpreadsheetDocument.Open(embeddedSpreadsheet.GetStream(), true))
+                {
+                    var workbookPart = sDoc.WorkbookPart;
+                    var wbRoot = workbookPart.GetXDocument().Root;
+                    var sheetRid = (string)wbRoot
+                        .Elements(S.sheets)
+                        .Elements(S.sheet)
+                        .Where(s => (string)s.Attribute("name") == sheet)
+                        .Attributes(R.id)
+                        .FirstOrDefault();
+                    if (sheetRid != null)
+                    {
+                        var sheetPart = workbookPart.GetPartById(sheetRid);
+                        var xdSheet = sheetPart.GetXDocument();
+                        var sheetData = xdSheet.Descendants(S.sheetData).FirstOrDefault();
+
+                        var stylePart = workbookPart.WorkbookStylesPart;
+                        var xdStyle = stylePart.GetXDocument();
+
+                        int categoryStyleId = 0;
+                        if (chartData.CategoryFormatCode != 0)
+                            categoryStyleId = AddDxfToDxfs(xdSheet, xdStyle, chartData.CategoryFormatCode);
+                        stylePart.PutXDocument();
+
+                        var firstRow = new XElement(S.row,
+                            new XAttribute("r", "1"),
+                            new XAttribute("spans", string.Format("1:{0}", chartData.SeriesNames.Length + 1)),
+                            new [] { new XElement(S.c,
+                                new XAttribute("r", "A1"),
+                                new XAttribute("t", "str"),
+                                new XElement(S.v,
+                                    new XAttribute(XNamespace.Xml + "space", "preserve"),
+                                    " "))}
+                                .Concat(
+                                    chartData.SeriesNames
+                                        .Select((sn, i) => new XElement(S.c,
+                                            new XAttribute("r", RowColToString(0, i + 1)),
+                                            new XAttribute("t", "str"),
+                                            new XElement(S.v, sn)))));
+                        var otherRows = chartData
+                            .CategoryNames
+                            .Select((cn, r) =>
+                            {
+                                var row = new XElement(S.row,
+                                    new XAttribute("r", r + 2),
+                                    new XAttribute("spans", string.Format("1:{0}", chartData.SeriesNames.Length + 1)),
+                                    new[] {
+                                        new XElement(S.c,
+                                            new XAttribute("r", RowColToString(r + 1, 0)),
+                                            categoryStyleId != 0 ? new XAttribute("s", categoryStyleId) : null,
+                                            chartData.CategoryDataType == ChartDataType.String ? new XAttribute("t", "str") : null,
+                                            new XElement(S.v, cn))
+                                    }.Concat(
+                                        Enumerable.Range(0, chartData.Values.Length)
+                                            .Select((c, ci) =>
+                                            {
+                                                var cell = new XElement(S.c,
+                                                    new XAttribute("r", RowColToString(r + 1, ci + 1)),
+                                                    new XElement(S.v, chartData.Values[ci][r]));
+                                                return cell;
+                                            })));
+                                return row;
+                            });
+                        var allRows = new[] {
+                            firstRow
+                        }.Concat(otherRows);
+                        var newSheetData = new XElement(S.sheetData,
+                            allRows);
+                        sheetData.ReplaceWith(newSheetData);
+                        sheetPart.PutXDocument();
+
+                        var tablePartRid = (string)xdSheet
+                            .Root
+                            .Elements(S.tableParts)
+                            .Elements(S.tablePart)
+                            .Attributes(R.id)
+                            .FirstOrDefault();
+                        if (tablePartRid != null)
+                        {
+                            var partTable = sheetPart.GetPartById(tablePartRid);
+                            var xdTablePart = partTable.GetXDocument();
+                            var xaRef = xdTablePart.Root.Attribute("ref");
+                            xaRef.Value = string.Format("A1:{0}", RowColToString(chartData.CategoryNames.Length - 1, chartData.SeriesNames.Length));
+                            var xeNewTableColumns = new XElement(S.tableColumns,
+                                new XAttribute("count", chartData.SeriesNames.Count() + 1),
+                                new[] {
+                                    new XElement(S.tableColumn,
+                                        new XAttribute("id", 1),
+                                        new XAttribute("name", " "))
+                                }.Concat(
+                                    chartData.SeriesNames.Select((cn, ci) =>
+                                        new XElement(S.tableColumn,
+                                            new XAttribute("id", ci + 2),
+                                            new XAttribute("name", cn)))));
+                            var xeExistingTableColumns = xdTablePart.Root.Element(S.tableColumns);
+                            if (xeExistingTableColumns != null)
+                                xeExistingTableColumns.ReplaceWith(xeNewTableColumns);
+                            partTable.PutXDocument();
+                        }
+                    }
+                }
+            }
+        }
+
+        private static int AddDxfToDxfs(XDocument xdSheet, XDocument xdStyle, int formatCodeToAdd)
+        {
+            // add xf to cellXfs
+            var cellXfs = xdStyle
+                .Root
+                .Element(S.cellXfs);
+            if (cellXfs == null)
+            {
+                var cellStyleXfs = xdStyle
+                    .Root
+                    .Element(S.cellStyleXfs);
+                if (cellStyleXfs != null)
+                {
+                    cellStyleXfs.AddAfterSelf(
+                        new XElement(S.cellXfs,
+                            new XAttribute("count", 0)));
+                    cellXfs = xdSheet
+                        .Root
+                        .Element(S.cellXfs);
+                }
+            }
+            if (cellXfs == null)
+            {
+                var borders = xdStyle
+                    .Root
+                    .Element(S.borders);
+                if (borders != null)
+                {
+                    borders.AddAfterSelf(
+                        new XElement(S.cellXfs,
+                            new XAttribute("count", 0)));
+                    cellXfs = xdSheet
+                        .Root
+                        .Element(S.cellXfs);
+                }
+            }
+            if (cellXfs == null)
+                throw new OpenXmlPowerToolsException("Internal error");
+
+            var cnt = (int)cellXfs.Attribute("count");
+            cnt++;
+            cellXfs.Attribute("count").Value = cnt.ToString();
+            cellXfs.Add(
+                new XElement(S.xf,
+                    new XAttribute("numFmtId", formatCodeToAdd),
+                    new XAttribute("fontId", 0),
+                    new XAttribute("fillId", 0),
+                    new XAttribute("borderId", 0),
+                    new XAttribute("applyNumberFormat", 1)));
+            return cnt - 1;
+        }
+
+        private static string RowColToString(int row, int col)
+        {
+            var str = SpreadsheetMLUtil.IntToColumnId(col) + (row + 1).ToString();
+            return str;
+        }
+
+        private static object UpdateAccentTransform(XNode node, int accentNumber)
+        {
+            XElement element = node as XElement;
+            if (element != null)
+            {
+                if (element.Name == A.schemeClr && (string)element.Attribute("val") == "accent1")
+                    return new XElement(A.schemeClr, new XAttribute("val", "accent" + accentNumber));
+
+                return new XElement(element.Name,
+                    element.Attributes(),
+                    element.Nodes().Select(n => UpdateAccentTransform(n, accentNumber)));
+            }
+            return node;
+        }
+
+        public static bool UpdateChart(PresentationDocument pDoc, int slideNumber, ChartData chartData)
+        {
+            var presentationPart = pDoc.PresentationPart;
+            var pXDoc = presentationPart.GetXDocument();
+            var sldIdElement = pXDoc.Root.Elements(P.sldIdLst).Elements(P.sldId).Skip(slideNumber - 1).FirstOrDefault();
+            if (sldIdElement != null)
+            {
+                var rId = (string)sldIdElement.Attribute(R.id);
+                var slidePart = presentationPart.GetPartById(rId);
+                var sXDoc = slidePart.GetXDocument();
+                var chartRid = (string)sXDoc.Descendants(C.chart).Attributes(R.id).FirstOrDefault();
+                if (chartRid != null)
+                {
+                    ChartPart chartPart = (ChartPart)slidePart.GetPartById(chartRid);
+                    UpdateChart(chartPart, chartData);
+                    return true;
+                }
+                return true;
+            }
+            return false;
+        }
+    }
+}

+ 36 - 0
TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/ColorParser.cs

@@ -0,0 +1,36 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System.Drawing;
+
+namespace OpenXmlPowerTools
+{
+    public static class ColorParser
+    {
+        public static Color FromName(string name)
+        {
+            return Color.FromName(name);
+        }
+
+        public static bool TryFromName(string name, out Color color)
+        {
+            try
+            {
+                color = Color.FromName(name);
+
+                return color.IsNamedColor;
+            }
+            catch
+            {
+                color = default(Color);
+
+                return false;
+            }
+        }
+
+        public static bool IsValidName(string name)
+        {
+            return TryFromName(name, out _);
+        }
+    }
+}

+ 67 - 0
TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/ComparisonUnit.cs

@@ -0,0 +1,67 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace OpenXmlPowerTools
+{
+    public abstract class ComparisonUnit
+    {
+        private int? _descendantContentAtomsCount;
+
+        public CorrelationStatus CorrelationStatus { get; set; }
+
+        public List<ComparisonUnit> Contents { get; protected set; }
+
+        public string SHA1Hash { get; protected set; }
+
+        public int DescendantContentAtomsCount
+        {
+            get
+            {
+                if (_descendantContentAtomsCount != null) return (int) _descendantContentAtomsCount;
+
+                _descendantContentAtomsCount = DescendantContentAtoms().Count();
+                return (int) _descendantContentAtomsCount;
+            }
+        }
+
+        private IEnumerable<ComparisonUnit> Descendants()
+        {
+            var comparisonUnitList = new List<ComparisonUnit>();
+            DescendantsInternal(this, comparisonUnitList);
+            return comparisonUnitList;
+        }
+
+        public IEnumerable<ComparisonUnitAtom> DescendantContentAtoms()
+        {
+            return Descendants().OfType<ComparisonUnitAtom>();
+        }
+
+        private static void DescendantsInternal(
+            ComparisonUnit comparisonUnit,
+            List<ComparisonUnit> comparisonUnitList)
+        {
+            foreach (ComparisonUnit cu in comparisonUnit.Contents)
+            {
+                comparisonUnitList.Add(cu);
+                if (cu.Contents != null && cu.Contents.Any())
+                    DescendantsInternal(cu, comparisonUnitList);
+            }
+        }
+
+        public abstract string ToString(int indent);
+
+        internal static string ComparisonUnitListToString(ComparisonUnit[] cul)
+        {
+            var sb = new StringBuilder();
+            sb.Append("Dump Comparision Unit List To String" + Environment.NewLine);
+            foreach (ComparisonUnit item in cul) sb.Append(item.ToString(2) + Environment.NewLine);
+
+            return sb.ToString();
+        }
+    }
+}

+ 216 - 0
TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/ComparisonUnitAtom.cs

@@ -0,0 +1,216 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Xml.Linq;
+using DocumentFormat.OpenXml.Packaging;
+using OpenXmlPowerTools.Previous;
+
+namespace OpenXmlPowerTools
+{
+    public class ComparisonUnitAtom : ComparisonUnit
+    {
+        public ComparisonUnitAtom(
+            XElement contentElement,
+            XElement[] ancestorElements,
+            OpenXmlPart part,
+            WmlComparerSettings settings)
+        {
+            ContentElement = contentElement;
+            AncestorElements = ancestorElements;
+            Part = part;
+            RevTrackElement = GetRevisionTrackingElementFromAncestors(contentElement, AncestorElements);
+
+            if (RevTrackElement == null)
+            {
+                CorrelationStatus = CorrelationStatus.Equal;
+            }
+            else
+            {
+                if (RevTrackElement.Name == W.del)
+                {
+                    CorrelationStatus = CorrelationStatus.Deleted;
+                }
+                else if (RevTrackElement.Name == W.ins)
+                {
+                    CorrelationStatus = CorrelationStatus.Inserted;
+                }
+            }
+
+            var sha1Hash = (string) contentElement.Attribute(PtOpenXml.SHA1Hash);
+            if (sha1Hash != null)
+            {
+                SHA1Hash = sha1Hash;
+            }
+            else
+            {
+                string shaHashString = GetSha1HashStringForElement(ContentElement, settings);
+                SHA1Hash = PtUtils.SHA1HashStringForUTF8String(shaHashString);
+            }
+        }
+
+        // AncestorElements are kept in order from the body to the leaf, because this is the order in which we need to access in order
+        // to reassemble the document.  However, in many places in the code, it is necessary to find the nearest ancestor, i.e. cell
+        // so it is necessary to reverse the order when looking for it, i.e. look from the leaf back to the body element.
+
+        public XElement[] AncestorElements { get; }
+
+        public XElement ContentElement { get; }
+
+        public XElement RevTrackElement { get; }
+
+        public string[] AncestorUnids { get; set; }
+
+        public ComparisonUnitAtom ComparisonUnitAtomBefore { get; set; }
+
+        public XElement ContentElementBefore { get; set; }
+
+        public OpenXmlPart Part { get; }
+
+        private static string GetSha1HashStringForElement(XElement contentElement, WmlComparerSettings settings)
+        {
+            string text = contentElement.Value;
+            if (settings.CaseInsensitive)
+            {
+                text = text.ToUpper(settings.CultureInfo);
+            }
+
+            return contentElement.Name.LocalName + text;
+        }
+
+        private static XElement GetRevisionTrackingElementFromAncestors(
+            XElement contentElement,
+            IEnumerable<XElement> ancestors)
+        {
+            return contentElement.Name == W.pPr
+                ? contentElement.Elements(W.rPr).Elements().FirstOrDefault(e => e.Name == W.del || e.Name == W.ins)
+                : ancestors.FirstOrDefault(a => a.Name == W.del || a.Name == W.ins);
+        }
+
+        public override string ToString()
+        {
+            return ToString(0);
+        }
+
+        public override string ToString(int indent)
+        {
+            const int xNamePad = 16;
+            string indentString = "".PadRight(indent);
+
+            var sb = new StringBuilder();
+            sb.Append(indentString);
+
+            var correlationStatus = "";
+            if (CorrelationStatus != CorrelationStatus.Nil)
+            {
+                correlationStatus = $"[{CorrelationStatus.ToString().PadRight(8)}] ";
+            }
+
+            if (ContentElement.Name == W.t || ContentElement.Name == W.delText)
+            {
+                sb.AppendFormat(
+                    "Atom {0}: {1} {2} SHA1:{3} ",
+                    PadLocalName(xNamePad, this),
+                    ContentElement.Value,
+                    correlationStatus,
+                    SHA1Hash.Substring(0, 8));
+
+                AppendAncestorsDump(sb, this);
+            }
+            else
+            {
+                sb.AppendFormat(
+                    "Atom {0}:   {1} SHA1:{2} ",
+                    PadLocalName(xNamePad, this),
+                    correlationStatus,
+                    SHA1Hash.Substring(0, 8));
+
+                AppendAncestorsDump(sb, this);
+            }
+
+            return sb.ToString();
+        }
+
+        public string ToStringAncestorUnids()
+        {
+            return ToStringAncestorUnids(0);
+        }
+
+        private string ToStringAncestorUnids(int indent)
+        {
+            const int xNamePad = 16;
+            string indentString = "".PadRight(indent);
+
+            var sb = new StringBuilder();
+            sb.Append(indentString);
+
+            var correlationStatus = "";
+            if (CorrelationStatus != CorrelationStatus.Nil)
+            {
+                correlationStatus = $"[{CorrelationStatus.ToString().PadRight(8)}] ";
+            }
+
+            if (ContentElement.Name == W.t || ContentElement.Name == W.delText)
+            {
+                sb.AppendFormat(
+                    "Atom {0}: {1} {2} SHA1:{3} ",
+                    PadLocalName(xNamePad, this),
+                    ContentElement.Value,
+                    correlationStatus,
+                    SHA1Hash.Substring(0, 8));
+
+                AppendAncestorsUnidsDump(sb, this);
+            }
+            else
+            {
+                sb.AppendFormat(
+                    "Atom {0}:   {1} SHA1:{2} ",
+                    PadLocalName(xNamePad, this),
+                    correlationStatus,
+                    SHA1Hash.Substring(0, 8));
+
+                AppendAncestorsUnidsDump(sb, this);
+            }
+
+            return sb.ToString();
+        }
+
+        private static string PadLocalName(int xNamePad, ComparisonUnitAtom item)
+        {
+            return (item.ContentElement.Name.LocalName + " ").PadRight(xNamePad, '-') + " ";
+        }
+
+        private static void AppendAncestorsDump(StringBuilder sb, ComparisonUnitAtom sr)
+        {
+            string s = sr
+                .AncestorElements.Select(p => p.Name.LocalName + GetUnid(p) + "/")
+                .StringConcatenate()
+                .TrimEnd('/');
+
+            sb.Append("Ancestors:" + s);
+        }
+
+        private static void AppendAncestorsUnidsDump(StringBuilder sb, ComparisonUnitAtom sr)
+        {
+            var zipped = sr.AncestorElements.Zip(sr.AncestorUnids, (a, u) => new
+            {
+                AncestorElement = a,
+                AncestorUnid = u
+            });
+
+            string s = zipped
+                .Select(p => p.AncestorElement.Name.LocalName + "[" + p.AncestorUnid.Substring(0, 8) + "]/")
+                .StringConcatenate().TrimEnd('/');
+
+            sb.Append("Ancestors:" + s);
+        }
+
+        private static string GetUnid(XElement p)
+        {
+            var unid = (string) p.Attribute(PtOpenXml.Unid);
+            return unid == null ? "" : "[" + unid.Substring(0, 8) + "]";
+        }
+    }
+}

+ 77 - 0
TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/ComparisonUnitGroup.cs

@@ -0,0 +1,77 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Xml.Linq;
+
+namespace OpenXmlPowerTools
+{
+    internal class ComparisonUnitGroup : ComparisonUnit
+    {
+        public ComparisonUnitGroup(
+            IEnumerable<ComparisonUnit> comparisonUnitList,
+            ComparisonUnitGroupType groupType,
+            int level)
+        {
+            Contents = comparisonUnitList.ToList();
+            ComparisonUnitGroupType = groupType;
+            ComparisonUnit first = Contents.First();
+            ComparisonUnitAtom comparisonUnitAtom = GetFirstComparisonUnitAtomOfGroup(first);
+
+            XElement[] ancestorsToLookAt = comparisonUnitAtom
+                .AncestorElements
+                .Where(e => e.Name == W.tbl || e.Name == W.tr || e.Name == W.tc || e.Name == W.p || e.Name == W.txbxContent)
+                .ToArray();
+
+            XElement ancestor = ancestorsToLookAt[level];
+            if (ancestor == null) throw new OpenXmlPowerToolsException("Internal error: ComparisonUnitGroup");
+
+            SHA1Hash = (string) ancestor.Attribute(PtOpenXml.SHA1Hash);
+            CorrelatedSHA1Hash = (string) ancestor.Attribute(PtOpenXml.CorrelatedSHA1Hash);
+            StructureSHA1Hash = (string) ancestor.Attribute(PtOpenXml.StructureSHA1Hash);
+        }
+
+        public ComparisonUnitGroupType ComparisonUnitGroupType { get; }
+
+        public string CorrelatedSHA1Hash { get; }
+
+        public string StructureSHA1Hash { get; }
+
+        private static ComparisonUnitAtom GetFirstComparisonUnitAtomOfGroup(ComparisonUnit group)
+        {
+            ComparisonUnit thisGroup = group;
+            while (true)
+            {
+                if (thisGroup is ComparisonUnitGroup tg)
+                {
+                    thisGroup = tg.Contents.First();
+                    continue;
+                }
+
+                if (!(thisGroup is ComparisonUnitWord tw))
+                {
+                    throw new OpenXmlPowerToolsException("Internal error: GetFirstComparisonUnitAtomOfGroup");
+                }
+
+                var ca = (ComparisonUnitAtom) tw.Contents.First();
+                return ca;
+            }
+        }
+
+        public override string ToString(int indent)
+        {
+            var sb = new StringBuilder();
+            sb.Append("".PadRight(indent) + "Group Type: " + ComparisonUnitGroupType + " SHA1:" + SHA1Hash + Environment.NewLine);
+
+            foreach (ComparisonUnit comparisonUnitAtom in Contents)
+            {
+                sb.Append(comparisonUnitAtom.ToString(indent + 2));
+            }
+
+            return sb.ToString();
+        }
+    }
+}

+ 14 - 0
TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/ComparisonUnitGroupType.cs

@@ -0,0 +1,14 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace OpenXmlPowerTools
+{
+    internal enum ComparisonUnitGroupType
+    {
+        Paragraph,
+        Table,
+        Row,
+        Cell,
+        Textbox,
+    };
+}

+ 81 - 0
TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/ComparisonUnitWord.cs

@@ -0,0 +1,81 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Xml.Linq;
+
+namespace OpenXmlPowerTools
+{
+    internal class ComparisonUnitWord : ComparisonUnit
+    {
+        public static readonly XName[] ElementsWithRelationshipIds =
+        {
+            A.blip,
+            A.hlinkClick,
+            A.relIds,
+            C.chart,
+            C.externalData,
+            C.userShapes,
+            DGM.relIds,
+            O.OLEObject,
+            VML.fill,
+            VML.imagedata,
+            VML.stroke,
+            W.altChunk,
+            W.attachedTemplate,
+            W.control,
+            W.dataSource,
+            W.embedBold,
+            W.embedBoldItalic,
+            W.embedItalic,
+            W.embedRegular,
+            W.footerReference,
+            W.headerReference,
+            W.headerSource,
+            W.hyperlink,
+            W.printerSettings,
+            W.recipientData,
+            W.saveThroughXslt,
+            W.sourceFileName,
+            W.src,
+            W.subDoc,
+            WNE.toolbarData
+        };
+
+        public static readonly XName[] RelationshipAttributeNames =
+        {
+            R.embed,
+            R.link,
+            R.id,
+            R.cs,
+            R.dm,
+            R.lo,
+            R.qs,
+            R.href,
+            R.pict
+        };
+
+        public ComparisonUnitWord(IEnumerable<ComparisonUnitAtom> comparisonUnitAtomList)
+        {
+            Contents = comparisonUnitAtomList.OfType<ComparisonUnit>().ToList();
+            string sha1String = Contents.Select(c => c.SHA1Hash).StringConcatenate();
+            SHA1Hash = PtUtils.SHA1HashStringForUTF8String(sha1String);
+        }
+
+        public override string ToString(int indent)
+        {
+            var sb = new StringBuilder();
+            sb.Append("".PadRight(indent) + "Word SHA1:" + SHA1Hash.Substring(0, 8) + Environment.NewLine);
+
+            foreach (ComparisonUnit comparisonUnitAtom in Contents)
+            {
+                sb.Append(comparisonUnitAtom.ToString(indent + 2) + Environment.NewLine);
+            }
+
+            return sb.ToString();
+        }
+    }
+}

+ 70 - 0
TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/CorrelatedSequence.cs

@@ -0,0 +1,70 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+using System.Text;
+
+namespace OpenXmlPowerTools
+{
+    internal class CorrelatedSequence
+    {
+#if DEBUG
+        public string SourceFile;
+        public int SourceLine;
+#endif
+
+        public CorrelatedSequence()
+        {
+#if DEBUG
+            SourceFile = new System.Diagnostics.StackTrace(true).GetFrame(1).GetFileName();
+            SourceLine = new System.Diagnostics.StackTrace(true).GetFrame(1).GetFileLineNumber();
+#endif
+        }
+
+        public CorrelationStatus CorrelationStatus { get; set; }
+
+        // if ComparisonUnitList1 == null and ComparisonUnitList2 contains sequence, then inserted content.
+        // if ComparisonUnitList2 == null and ComparisonUnitList1 contains sequence, then deleted content.
+        // if ComparisonUnitList2 contains sequence and ComparisonUnitList1 contains sequence, then either is Unknown or Equal.
+        public ComparisonUnit[] ComparisonUnitArray1 { get; set; }
+
+        public ComparisonUnit[] ComparisonUnitArray2 { get; set; }
+
+        public override string ToString()
+        {
+            var sb = new StringBuilder();
+            const string indentString = "  ";
+            const string indentString4 = "    ";
+            sb.Append("CorrelatedSequence =====" + Environment.NewLine);
+#if DEBUG
+            sb.Append(indentString + "Created at Line: " + SourceLine + Environment.NewLine);
+#endif
+            sb.Append(indentString + "CorrelatedItem =====" + Environment.NewLine);
+            sb.Append(indentString4 + "CorrelationStatus: " + CorrelationStatus + Environment.NewLine);
+            if (CorrelationStatus == CorrelationStatus.Equal)
+            {
+                sb.Append(indentString4 + "ComparisonUnitList =====" + Environment.NewLine);
+                foreach (ComparisonUnit item in ComparisonUnitArray2)
+                    sb.Append(item.ToString(6) + Environment.NewLine);
+            }
+            else
+            {
+                if (ComparisonUnitArray1 != null)
+                {
+                    sb.Append(indentString4 + "ComparisonUnitList1 =====" + Environment.NewLine);
+                    foreach (ComparisonUnit item in ComparisonUnitArray1)
+                        sb.Append(item.ToString(6) + Environment.NewLine);
+                }
+
+                if (ComparisonUnitArray2 != null)
+                {
+                    sb.Append(indentString4 + "ComparisonUnitList2 =====" + Environment.NewLine);
+                    foreach (ComparisonUnit item in ComparisonUnitArray2)
+                        sb.Append(item.ToString(6) + Environment.NewLine);
+                }
+            }
+
+            return sb.ToString();
+        }
+    }
+}

+ 16 - 0
TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/CorrelationStatus.cs

@@ -0,0 +1,16 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace OpenXmlPowerTools
+{
+    public enum CorrelationStatus
+    {
+        Nil,
+        Normal,
+        Unknown,
+        Inserted,
+        Deleted,
+        Equal,
+        Group,
+    }
+}

+ 15 - 0
TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/PartSHA1HashAnnotation.cs

@@ -0,0 +1,15 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace OpenXmlPowerTools
+{
+    internal class PartSHA1HashAnnotation
+    {
+        public string Hash;
+
+        public PartSHA1HashAnnotation(string hash)
+        {
+            Hash = hash;
+        }
+    }
+}

+ 12 - 0
TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/WithHierarchicalGroupingKey.cs

@@ -0,0 +1,12 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace OpenXmlPowerTools
+{
+    internal class WithHierarchicalGroupingKey
+    {
+        public string[] HierarchicalGroupingArray { get; set; }
+
+        public ComparisonUnitWord ComparisonUnitWord { get; set; }
+    }
+}

+ 403 - 0
TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/WmlComparer.Internal.Methods.ComparisonUnits.cs

@@ -0,0 +1,403 @@
+
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Xml.Linq;
+using DocumentFormat.OpenXml.Packaging;
+using OpenXmlPowerTools.Previous;
+
+namespace OpenXmlPowerTools
+{
+    public static partial class WmlComparer
+    {
+        #region CreateComparisonUnitAtomList
+
+        internal static ComparisonUnitAtom[] CreateComparisonUnitAtomList(
+            OpenXmlPart part,
+            XElement contentParent,
+            WmlComparerSettings settings)
+        {
+            VerifyNoInvalidContent(contentParent);
+            AssignUnidToAllElements(contentParent); // add the Guid id to every element
+            MoveLastSectPrIntoLastParagraph(contentParent);
+            ComparisonUnitAtom[] cal = CreateComparisonUnitAtomListInternal(part, contentParent, settings).ToArray();
+
+            if (False)
+            {
+                var sb = new StringBuilder();
+                foreach (ComparisonUnitAtom item in cal)
+                    sb.Append(item + Environment.NewLine);
+                string sbs = sb.ToString();
+                TestUtil.NotePad(sbs);
+            }
+
+            return cal;
+        }
+
+        private static void VerifyNoInvalidContent(XElement contentParent)
+        {
+            XElement invalidElement = contentParent.Descendants().FirstOrDefault(d => InvalidElements.Contains(d.Name));
+            if (invalidElement == null)
+                return;
+
+            throw new NotSupportedException("Document contains " + invalidElement.Name.LocalName);
+        }
+
+        private static void MoveLastSectPrIntoLastParagraph(XElement contentParent)
+        {
+            List<XElement> lastSectPrList = contentParent.Elements(W.sectPr).ToList();
+            if (lastSectPrList.Count() > 1)
+                throw new OpenXmlPowerToolsException("Invalid document");
+
+            XElement lastSectPr = lastSectPrList.FirstOrDefault();
+            if (lastSectPr != null)
+            {
+                XElement lastParagraph = contentParent.Elements(W.p).LastOrDefault();
+                if (lastParagraph == null)
+                    throw new OpenXmlPowerToolsException("Invalid document");
+
+                XElement pPr = lastParagraph.Element(W.pPr);
+                if (pPr == null)
+                {
+                    pPr = new XElement(W.pPr);
+                    lastParagraph.AddFirst(W.pPr);
+                }
+
+                pPr.Add(lastSectPr);
+                contentParent.Elements(W.sectPr).Remove();
+            }
+        }
+
+        private static List<ComparisonUnitAtom> CreateComparisonUnitAtomListInternal(
+            OpenXmlPart part,
+            XElement contentParent,
+            WmlComparerSettings settings)
+        {
+            var comparisonUnitAtomList = new List<ComparisonUnitAtom>();
+            CreateComparisonUnitAtomListRecurse(part, contentParent, comparisonUnitAtomList, settings);
+            return comparisonUnitAtomList;
+        }
+
+        private static void CreateComparisonUnitAtomListRecurse(
+            OpenXmlPart part,
+            XElement element,
+            List<ComparisonUnitAtom> comparisonUnitAtomList,
+            WmlComparerSettings settings)
+        {
+            if (element.Name == W.body || element.Name == W.footnote || element.Name == W.endnote)
+            {
+                foreach (XElement item in element.Elements())
+                    CreateComparisonUnitAtomListRecurse(part, item, comparisonUnitAtomList, settings);
+                return;
+            }
+
+            if (element.Name == W.p)
+            {
+                IEnumerable<XElement> paraChildrenToProcess = element
+                    .Elements()
+                    .Where(e => e.Name != W.pPr);
+                foreach (XElement item in paraChildrenToProcess)
+                    CreateComparisonUnitAtomListRecurse(part, item, comparisonUnitAtomList, settings);
+                XElement paraProps = element.Element(W.pPr);
+                if (paraProps == null)
+                {
+                    var pPrComparisonUnitAtom = new ComparisonUnitAtom(
+                        new XElement(W.pPr),
+                        element.AncestorsAndSelf()
+                            .TakeWhile(a => a.Name != W.body && a.Name != W.footnotes && a.Name != W.endnotes).Reverse()
+                            .ToArray(),
+                        part,
+                        settings);
+                    comparisonUnitAtomList.Add(pPrComparisonUnitAtom);
+                }
+                else
+                {
+                    var pPrComparisonUnitAtom = new ComparisonUnitAtom(
+                        paraProps,
+                        element.AncestorsAndSelf()
+                            .TakeWhile(a => a.Name != W.body && a.Name != W.footnotes && a.Name != W.endnotes).Reverse()
+                            .ToArray(),
+                        part,
+                        settings);
+                    comparisonUnitAtomList.Add(pPrComparisonUnitAtom);
+                }
+
+                return;
+            }
+
+            if (element.Name == W.r)
+            {
+                IEnumerable<XElement> runChildrenToProcess = element
+                    .Elements()
+                    .Where(e => e.Name != W.rPr);
+                foreach (XElement item in runChildrenToProcess)
+                    CreateComparisonUnitAtomListRecurse(part, item, comparisonUnitAtomList, settings);
+                return;
+            }
+
+            if (element.Name == W.t || element.Name == W.delText)
+            {
+                string val = element.Value;
+                foreach (char ch in val)
+                {
+                    var sr = new ComparisonUnitAtom(
+                        new XElement(element.Name, ch),
+                        element.AncestorsAndSelf()
+                            .TakeWhile(a => a.Name != W.body && a.Name != W.footnotes && a.Name != W.endnotes).Reverse()
+                            .ToArray(),
+                        part,
+                        settings);
+                    comparisonUnitAtomList.Add(sr);
+                }
+
+                return;
+            }
+
+            if (AllowableRunChildren.Contains(element.Name) || element.Name == W._object)
+            {
+                var sr3 = new ComparisonUnitAtom(
+                    element,
+                    element.AncestorsAndSelf().TakeWhile(a => a.Name != W.body && a.Name != W.footnotes && a.Name != W.endnotes)
+                        .Reverse().ToArray(),
+                    part,
+                    settings);
+                comparisonUnitAtomList.Add(sr3);
+                return;
+            }
+
+            RecursionInfo re = RecursionElements.FirstOrDefault(z => z.ElementName == element.Name);
+            if (re != null)
+            {
+                AnnotateElementWithProps(part, element, comparisonUnitAtomList, re.ChildElementPropertyNames, settings);
+                return;
+            }
+
+            if (ElementsToThrowAway.Contains(element.Name))
+                return;
+
+            AnnotateElementWithProps(part, element, comparisonUnitAtomList, null, settings);
+        }
+
+        private static void AnnotateElementWithProps(
+            OpenXmlPart part,
+            XElement element,
+            List<ComparisonUnitAtom> comparisonUnitAtomList,
+            XName[] childElementPropertyNames,
+            WmlComparerSettings settings)
+        {
+            IEnumerable<XElement> runChildrenToProcess;
+            if (childElementPropertyNames == null)
+                runChildrenToProcess = element.Elements();
+            else
+                runChildrenToProcess = element
+                    .Elements()
+                    .Where(e => !childElementPropertyNames.Contains(e.Name));
+
+            foreach (XElement item in runChildrenToProcess)
+                CreateComparisonUnitAtomListRecurse(part, item, comparisonUnitAtomList, settings);
+        }
+
+        #endregion CreateComparisonUnitAtomList
+
+        #region GetComparisonUnitList
+
+        // The following method must be made internal if we ever turn this part of the partial class
+        // into its own class.
+        private static ComparisonUnit[] GetComparisonUnitList(
+            ComparisonUnitAtom[] comparisonUnitAtomList,
+            WmlComparerSettings settings)
+        {
+            var seed = new Atgbw
+            {
+                Key = null,
+                ComparisonUnitAtomMember = null,
+                NextIndex = 0
+            };
+
+            IEnumerable<Atgbw> groupingKey = comparisonUnitAtomList
+                .Rollup(seed, (sr, prevAtgbw, i) =>
+                {
+                    int? key;
+                    int nextIndex = prevAtgbw.NextIndex;
+                    if (sr.ContentElement.Name == W.t)
+                    {
+                        string chr = sr.ContentElement.Value;
+                        char ch = chr[0];
+                        if (ch == '.' || ch == ',')
+                        {
+                            var beforeIsDigit = false;
+                            if (i > 0)
+                            {
+                                ComparisonUnitAtom prev = comparisonUnitAtomList[i - 1];
+                                if (prev.ContentElement.Name == W.t && char.IsDigit(prev.ContentElement.Value[0]))
+                                    beforeIsDigit = true;
+                            }
+
+                            var afterIsDigit = false;
+                            if (i < comparisonUnitAtomList.Length - 1)
+                            {
+                                ComparisonUnitAtom next = comparisonUnitAtomList[i + 1];
+                                if (next.ContentElement.Name == W.t && char.IsDigit(next.ContentElement.Value[0]))
+                                    afterIsDigit = true;
+                            }
+
+                            if (beforeIsDigit || afterIsDigit)
+                            {
+                                key = nextIndex;
+                            }
+                            else
+                            {
+                                nextIndex++;
+                                key = nextIndex;
+                                nextIndex++;
+                            }
+                        }
+                        else if (settings.WordSeparators.Contains(ch))
+                        {
+                            nextIndex++;
+                            key = nextIndex;
+                            nextIndex++;
+                        }
+                        else
+                        {
+                            key = nextIndex;
+                        }
+                    }
+                    else if (WordBreakElements.Contains(sr.ContentElement.Name))
+                    {
+                        nextIndex++;
+                        key = nextIndex;
+                        nextIndex++;
+                    }
+                    else
+                    {
+                        key = nextIndex;
+                    }
+
+                    return new Atgbw
+                    {
+                        Key = key,
+                        ComparisonUnitAtomMember = sr,
+                        NextIndex = nextIndex
+                    };
+                })
+                .ToArray();
+
+            if (False)
+            {
+                var sb = new StringBuilder();
+                foreach (Atgbw item in groupingKey)
+                {
+                    sb.Append(item.Key + Environment.NewLine);
+                    sb.Append("    " + item.ComparisonUnitAtomMember.ToString(0) + Environment.NewLine);
+                }
+
+                string sbs = sb.ToString();
+                TestUtil.NotePad(sbs);
+            }
+
+            IEnumerable<IGrouping<int?, Atgbw>> groupedByWords = groupingKey
+                .GroupAdjacent(gc => gc.Key)
+                .ToArray();
+
+            if (False)
+            {
+                var sb = new StringBuilder();
+                foreach (IGrouping<int?, Atgbw> group in groupedByWords)
+                {
+                    sb.Append("Group ===== " + @group.Key + Environment.NewLine);
+                    foreach (Atgbw gc in @group)
+                    {
+                        sb.Append("    " + gc.ComparisonUnitAtomMember.ToString(0) + Environment.NewLine);
+                    }
+                }
+
+                string sbs = sb.ToString();
+                TestUtil.NotePad(sbs);
+            }
+
+            WithHierarchicalGroupingKey[] withHierarchicalGroupingKey = groupedByWords
+                .Select(g =>
+                    {
+                        string[] hierarchicalGroupingArray = g
+                            .First()
+                            .ComparisonUnitAtomMember
+                            .AncestorElements
+                            .Where(a => ComparisonGroupingElements.Contains(a.Name))
+                            .Select(a => a.Name.LocalName + ":" + (string) a.Attribute(PtOpenXml.Unid))
+                            .ToArray();
+
+                        return new WithHierarchicalGroupingKey
+                        {
+                            ComparisonUnitWord = new ComparisonUnitWord(g.Select(gc => gc.ComparisonUnitAtomMember)),
+                            HierarchicalGroupingArray = hierarchicalGroupingArray
+                        };
+                    }
+                )
+                .ToArray();
+
+            if (False)
+            {
+                var sb = new StringBuilder();
+                foreach (WithHierarchicalGroupingKey group in withHierarchicalGroupingKey)
+                {
+                    sb.Append("Grouping Array: " +
+                              @group.HierarchicalGroupingArray.Select(gam => gam + " - ").StringConcatenate() +
+                              Environment.NewLine);
+                    foreach (ComparisonUnit gc in @group.ComparisonUnitWord.Contents)
+                    {
+                        sb.Append("    " + gc.ToString(0) + Environment.NewLine);
+                    }
+                }
+
+                string sbs = sb.ToString();
+                TestUtil.NotePad(sbs);
+            }
+
+            ComparisonUnit[] cul = GetHierarchicalComparisonUnits(withHierarchicalGroupingKey, 0).ToArray();
+
+            if (False)
+            {
+                string str = ComparisonUnit.ComparisonUnitListToString(cul);
+                TestUtil.NotePad(str);
+            }
+
+            return cul;
+        }
+
+        private static IEnumerable<ComparisonUnit> GetHierarchicalComparisonUnits(
+            IEnumerable<WithHierarchicalGroupingKey> input,
+            int level)
+        {
+            IEnumerable<IGrouping<string, WithHierarchicalGroupingKey>> grouped = input
+                .GroupAdjacent(
+                    whgk => level >= whgk.HierarchicalGroupingArray.Length ? "" : whgk.HierarchicalGroupingArray[level]);
+
+            List<ComparisonUnit> retList = grouped
+                .Select(gc =>
+                {
+                    if (gc.Key == "")
+                    {
+                        return (IEnumerable<ComparisonUnit>) gc.Select(whgk => whgk.ComparisonUnitWord).ToList();
+                    }
+
+                    string[] spl = gc.Key.Split(':');
+                    ComparisonUnitGroupType groupType = WmlComparerUtil.ComparisonUnitGroupTypeFromLocalName(spl[0]);
+                    IEnumerable<ComparisonUnit> childHierarchicalComparisonUnits = GetHierarchicalComparisonUnits(gc, level + 1);
+                    var newCompUnitGroup = new ComparisonUnitGroup(childHierarchicalComparisonUnits, groupType, level);
+
+                    return new[] { newCompUnitGroup };
+                })
+                .SelectMany(m => m)
+                .ToList();
+
+            return retList;
+        }
+
+        #endregion GetComparisonUnitList
+    }
+}

+ 0 - 0
TEAMModelOS.HTEXLib/DOCX/OpenXmlTool/Comparer/WmlComparer.Private.Fields.cs


Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.