CrazyIter 4 년 전
부모
커밋
c7eafa7c8c

+ 5 - 1
HTEXKiller/Program.cs

@@ -9,9 +9,13 @@ namespace HTEXKiller
 {
     class Program
     {
+
+        /// <summary>
+        /// kill指定端口的PID进程。
+        /// </summary>
+        /// <param name="args"></param>
         static void Main(string[] args)
         {
-            Console.WriteLine("Hello World!");
             int port = 5000;
             Process p = new Process();
             p.StartInfo.FileName = "cmd.exe";

+ 0 - 2
HTEXLib/Animations/JSONGenerator.cs

@@ -436,8 +436,6 @@ namespace HTEXLib.Animations
             ///路径方式
             if (AnimationTypes.TypePath.Equals(commonTimeNode.PresetClass))
             {
-
-               
                 return new MotionPathAnimation(commonTimeNode, Slide.slideIndex, SlideSizes);
             }
             ///进入

+ 4 - 1
HTEXLib/Animations/SimpleAnimation.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using DocumentFormat.OpenXml.Presentation;
@@ -17,6 +17,9 @@ namespace HTEXLib.Animations
         public int Length { get; set; }
         public string ObjectId { get; set; }
         public int Repetitions { get; set; }
+        /// <summary>
+        /// 1 进入 , 2 退出,3 强调 ,4 路径
+        /// </summary>
         public int InitialState { get; set; }
         public string Type { get; set; }
         public string AdditionalData { get; set; }

+ 2 - 2
HTEXLib/Builders/HtexBuilder.cs

@@ -57,10 +57,10 @@ namespace HTEXLib.Builders
 
          
 
-       public List<PPTSlide> GetPPTSlides(Stream stream) {
+       public List<PPTSlide> GetPPTSlides(PresentationDocument presentationDoc) {
             try
             {
-                presentationDocument = PresentationDocument.Open(stream, false);
+                presentationDocument = presentationDoc;   //PresentationDocument.Open(stream, false);
                 //get the slide sizes.
                 Presentation presentation = presentationDocument.PresentationPart.Presentation;
                 SlideSizes = presentation.SlideSize;

+ 13 - 2
HTEXLib/Builders/HtexGenerator.cs

@@ -1,18 +1,28 @@
+using DocumentFormat.OpenXml.Packaging;
 using HTEXLib.Controller;
 using HTEXLib.Models;
 using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Text;
+using System.Xml.Linq;
 
 namespace HTEXLib.Builders
 {
     public   class HtexGenerator
     {
         public Htex Generator(Stream stream) {
-
+            PresentationDocument presentation = null;
             var htexBuilder = new HtexBuilder();
-            var pptSlides = htexBuilder.GetPPTSlides(stream);
+            try {
+
+                XDocument document = XDocument.Load(stream);
+            } catch(Exception e) {
+                 presentation = PresentationDocument.Open(stream, false);
+            }
+            
+            
+            var pptSlides = htexBuilder.GetPPTSlides(presentation);
             double width = htexBuilder.getSlideWidth();
             double height = htexBuilder.getSlideHeight();
             int slideCounter = 1;
@@ -45,5 +55,6 @@ namespace HTEXLib.Builders
             htex.page = slides.Count;
             return htex;
         }
+       
     }
 }

+ 6 - 0
HTEXLib/Controller/HtexController.cs

@@ -178,6 +178,12 @@ namespace HTEXLib.Controller
                 //}
                 //JToken token=JsonHelper. FromJson<JToken>(s);
                 //slide.animations = token;
+
+
+                var Animations = _mSlide.Animations;
+                if (Animations != null) {
+                    slide.animations = Animations;
+                }
                 Background background = _mSlide.background;
                 if (background != null)
                 {

+ 3 - 1
HTEXLib/Models/HTEX/HtexChart.cs

@@ -101,7 +101,9 @@ namespace HTEXLib.Models.HTEX
             Shape shape= new Shape { type = "Shape", shapeType = "Rect", paragraph = paragraphs };
             shape.style.fill = shapeStyle != null ? shapeStyle.fill : null;
             shape.style.border = shapeStyle != null ? shapeStyle.border : null;
-            var  chart= new Chart { charts=charts,title=shape};
+            var  chart= new Chart { id = this.id,  charts =charts,title=shape};
+            Position position = new Position { cx = width, cy = height, x = left, y = top, rot = rot };
+            chart.style.position = position;
             chart.style.fill = shapeStyleChart != null ? shapeStyleChart.fill : null;
             chart.style.border = shapeStyleChart != null ? shapeStyleChart.border : null;
             return chart;

+ 1 - 1
HTEXLib/Models/HTEX/HtexGroupShape.cs

@@ -30,7 +30,7 @@ namespace HTEXLib.Models.HTEX
         {
             Position position = new Position { cx = width, cy = height, x = left, y = top, rot = rot };
             var ShapeStyle = PPTXHelper.DoShapeProperties(groupShape.element.GroupShapeProperties, slide, type, partForm);
-            Group group = new Group() {  type = type, index = index, animatable = animatable, invisible = invisible };
+            Group group = new Group() { id = this.id, type = type, index = index, animatable = animatable, invisible = invisible };
             group.style.border = ShapeStyle.border;
             group.style.fill = ShapeStyle.fill;
             group.style.position = position;

+ 1 - 1
HTEXLib/Models/HTEX/HtexImage.cs

@@ -35,7 +35,7 @@ namespace HTEXLib.Models.HTEX
         { 
             Position position = new Position { cx = width, cy = height, x = left, y = top, rot = rot };
             var ShapeStyle = PPTXHelper.DoShapeProperties(image.element.ShapeProperties, slide,type,partForm);
-            Media media = new Media() { mediaType= "image",type=type,index=index,animatable=animatable ,invisible=invisible};
+            Media media = new Media() { id = this.id, mediaType = "image",type=type,index=index,animatable=animatable ,invisible=invisible};
             media.style.position = position;
             /*
              *  cNvPicPr (非可视图片绘图属性)	§19.3.1.11

+ 1 - 1
HTEXLib/Models/HTEX/HtexMath.cs

@@ -43,7 +43,7 @@ namespace HTEXLib.Models.HTEX
             Position position = new Position { cx = width, cy = height, x = left, y = top, rot = rot };
             var ShapeStyle = PPTXHelper.DoShapeProperties(pptMath.element.ShapeProperties, slide, type, partForm);
             var shapeTypeNode = pptMath.element.ShapeProperties.GetFirstChild<PresetGeometry>();
-            Math math = new Math {  type = type, index = index, animatable = animatable, invisible = invisible };
+            Math math = new Math { id = this.id, type = type, index = index, animatable = animatable, invisible = invisible };
             math.style.position = position;
             SlideColor slideColor = PPTXHelper.DoShapeStyle(pptMath.element.ShapeStyle, slide, type);
             //从ShapeProperties 获取 p:spPr

+ 1 - 1
HTEXLib/Models/HTEX/HtexShape.cs

@@ -47,7 +47,7 @@ namespace HTEXLib.Models.HTEX
             Position position = new Position { cx= width, cy= height, x=left,y=top,rot=rot};
             var ShapeStyle =PPTXHelper.DoShapeProperties(Shape.element.ShapeProperties, slide,type,partForm);
             //position = position ,mediaType = "image",type = type,index = index,animatable = animatable ,invisible = invisible
-            Shape shape = new Shape() { paragraph = DrawText() ,type=type,index=index,animatable=animatable,invisible=invisible };
+            Shape shape = new Shape() {id=this.id, paragraph = DrawText() ,type=type,index=index,animatable=animatable,invisible=invisible };
             shape.style.position = position;
             var shapeTypeNode = Shape.element.ShapeProperties.GetFirstChild<PresetGeometry>();
             var shapeTypeCustom = Shape.element.ShapeProperties.GetFirstChild<CustomGeometry>();

+ 1 - 1
HTEXLib/Models/HTEX/HtexTable.cs

@@ -39,7 +39,7 @@ namespace HTEXLib.Models.HTEX
             tbStyle.ColumnWidth = columns.Select(x => x.Width * Globals.px96 * 1.0 / Globals.px914400).ToList();
             List<TableRow> rows = Table.Elements<TableRow>().ToList();
             var trs = DoTableRow(rows, slide, type, partForm);
-            Table table = new Table() { tr = trs, style = tbStyle, type =type, index = index, animatable = animatable, invisible = invisible };
+            Table table = new Table() { id = this.id, tr = trs, style = tbStyle, type =type, index = index, animatable = animatable, invisible = invisible };
             table.style.position = position;
             var elmt = new List<Item>();
             elmt.Add(table);

+ 7 - 1
HTEXLib/Models/Item.cs

@@ -7,7 +7,9 @@ namespace HTEXLib
 {
     public abstract class Item
     {
-       
+        /// <summary>
+        /// http://sc.chinaz.com/jiaobendemo.aspx?downloadid=42016103430419  动画插件
+        /// </summary>
         public List<IAnimation> animations { get; set; }
         public string id { get; set; }
         /// <summary>
@@ -30,6 +32,10 @@ namespace HTEXLib
         /// </summary>
         public string uid { get; set; } = Guid.NewGuid().ToString("N");
         /// <summary>
+        /// 当前页的ID
+        /// </summary>
+        public string sid { get; set; }
+        /// <summary>
         /// 画笔
         /// </summary>
         public Brush brush { get; set; }

+ 2 - 1
HTEXLib/Models/Slide.cs

@@ -1,3 +1,4 @@
+using HTEXLib.Animations;
 using Newtonsoft.Json.Linq;
 using System;
 using System.Collections.Generic;
@@ -8,7 +9,7 @@ namespace HTEXLib
 {
     public class Slide
     {
-        public JToken animations { get; set; }
+        public List<IAnimation> animations { get; set; }
         public List<Item> item { get; set; }
         public Fill fill { get; set; }
         public int index { get; set; }

+ 3 - 0
HTEXMarkWeb/ClientApp/package-lock.json

@@ -0,0 +1,3 @@
+{
+  "lockfileVersion": 1
+}

+ 60 - 0
HTEXMarkWeb/HTEXMarkWeb.csproj

@@ -3,5 +3,65 @@
   <PropertyGroup>
     <TargetFramework>netcoreapp3.1</TargetFramework>
   </PropertyGroup>
+  <ItemGroup>
+    <PackageReference Include="HTEXLib" Version="1.0.5" />
+    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.6" />
+    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.6" />
+    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" />
+    <PackageReference Include="VueCliMiddleware" Version="3.1.1" />
+  </ItemGroup>
+  <PropertyGroup>
+    <SpaRoot>ClientApp\</SpaRoot>
+    <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
+  </PropertyGroup>
+  <ItemGroup>
+    <!-- Don't publish the SPA source files, but do show them in the project files list -->
+    <Compile Remove="JsonFile\Subject\**" />
+    <Content Remove="$(SpaRoot)**" />
+
+    <Content Remove="JsonFile\Subject\**" />
+    <None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <Folder Include="logfile\" />
+    <Folder Include="wwwroot\" />
+    <Folder Include="ClientApp\" />
+  </ItemGroup>
+
+ 
+  <Target Name="DebugEnsureNodeEnv" BeforeTargets="Build">
+    <!-- Build Target:  Ensure Node.js is installed -->
+    <Exec Command="node --version" ContinueOnError="true">
+      <Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
+    </Exec>
+    <Exec Command="npm --version" ContinueOnError="true">
+      <Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
+    </Exec>
+    <Error Condition="'$(ErrorCode)' != '0'" Text="Node.js and npm are required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
+  </Target>
+
+  <Target Name="EnsureNodeModulesInstalled" BeforeTargets="Build" Inputs="package.json" Outputs="packages-lock.json" Condition="!Exists('$(SpaRoot)node_modules')">
+    <!-- Build Target: Restore NPM packages using npm -->
+    <Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
+    <Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
+  </Target>
+
+  <Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
+    <!-- Build Target: Run webpack dist build -->
+    <Message Importance="high" Text="Running npm build..." />
+    <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build" />
+
+    <!-- Include the newly-built files in the publish output -->
+    <ItemGroup>
+      <DistFiles Include="$(SpaRoot)dist\**" />
+      <ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
+        <RelativePath>%(DistFiles.Identity)</RelativePath>
+        <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
+        <ExcludeFromSingleFile>True</ExcludeFromSingleFile>
+      </ResolvedFileToPublish>
+    </ItemGroup>
+  </Target>
 
+  <!--<ProjectExtensions><VisualStudio><UserProperties properties_4launchsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>-->
 </Project>

+ 42 - 7
HTEXMarkWeb/Startup.cs

@@ -5,14 +5,17 @@ using System.Threading.Tasks;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.HttpsPolicy;
+using Microsoft.AspNetCore.SpaServices;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;
+using VueCliMiddleware;
 
 namespace HTEXMarkWeb
 {
     public class Startup
     {
+        readonly string MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
         public Startup(IConfiguration configuration)
         {
             Configuration = configuration;
@@ -22,7 +25,20 @@ namespace HTEXMarkWeb
 
         // This method gets called by the runtime. Use this method to add services to the container.
         public void ConfigureServices(IServiceCollection services)
-        {
+        {    //設定跨域請求
+            services.AddCors(options =>
+            {
+                options.AddPolicy(MyAllowSpecificOrigins,
+                builder =>
+                {
+                    builder.WithOrigins("http://teammodelos-test.chinacloudsites.cn",
+                                        "https://www.teammodel.cn", "https://localhost:5001",
+                                        "http://localhost:5000", "http://localhost:64524",
+                                        "https://localhost:44341", "https://localhost:8888", "http://localhost:8888")
+                    .AllowAnyHeader()
+                    .AllowAnyMethod();
+                });
+            });
             services.AddControllersWithViews();
         }
 
@@ -39,18 +55,37 @@ namespace HTEXMarkWeb
                 // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                 app.UseHsts();
             }
-            app.UseHttpsRedirection();
-            app.UseStaticFiles();
+            //TODO 目前不使用中間件全局攔截Exception,請在API中,明確處理200成功返回值或錯誤碼,Exception一率返回BadRequert 400,並選擇需要返回釘釘群組回報的API
+            //app.UseMiddleware<HttpGlobalExceptionInvoke>();
 
+            //以下需要按照順序載入中間件  如果应用调用 UseStaticFiles,请将 UseStaticFiles 置于 UseRouting之前。
+            app.UseStaticFiles();
+            //app.UseSpaStaticFiles(); //使用中間件不開
+            //  app.UseSpaStaticFiles();
             app.UseRouting();
 
-            app.UseAuthorization();
+            app.UseCors(MyAllowSpecificOrigins); //使用跨域設定
+            //app.UseHttpsRedirection(); //開發中暫時關掉
 
+            //如果应用使用身份验证/授权功能(如 AuthorizePage 或 [Authorize]),请将对 UseAuthentication 和 UseAuthorization的
+            //调用放在之后、UseRouting 和 UseCors,但在 UseEndpoints之前
+            app.UseAuthentication();
+            app.UseAuthorization();
             app.UseEndpoints(endpoints =>
             {
-                endpoints.MapControllerRoute(
-                    name: "default",
-                    pattern: "{controller=Home}/{action=Index}/{id?}");
+                endpoints.MapControllers();
+#if DEBUG
+                endpoints.MapToVueCliProxy(
+                    "{*path}",
+                    new SpaOptions { SourcePath = "ClientApp" },
+                    npmScript: (System.Diagnostics.Debugger.IsAttached) ? "serve" : null,
+                    // regex: "Compiled successfully",
+                    forceKill: true
+                    );
+#else
+                endpoints.MapFallbackToFile("index.html");
+#endif             
+
             });
         }
     }

+ 4 - 0
HTEXTest/Program.cs

@@ -18,6 +18,10 @@ namespace HTEXTest
 {
     class Program
     {
+        /// <summary>
+        /// 获取本地机器网卡的所有IP地址
+        /// </summary>
+        /// <returns></returns>
         public static List<string> getIPAddress()
         {
             return NetworkInterface.GetAllNetworkInterfaces()