浏览代码

添加PPT解析

CrazyIter 5 年之前
父节点
当前提交
24b196e074
共有 25 个文件被更改,包括 4110 次插入9 次删除
  1. 18 0
      TEAMModelOS.Service/Models/PowerPoint/Border.cs
  2. 11 0
      TEAMModelOS.Service/Models/PowerPoint/Chart.cs
  3. 19 0
      TEAMModelOS.Service/Models/PowerPoint/Connector.cs
  4. 10 0
      TEAMModelOS.Service/Models/PowerPoint/Diagram.cs
  5. 26 0
      TEAMModelOS.Service/Models/PowerPoint/Fill.cs
  6. 17 0
      TEAMModelOS.Service/Models/PowerPoint/FontStyle.cs
  7. 11 0
      TEAMModelOS.Service/Models/PowerPoint/Group.cs
  8. 19 0
      TEAMModelOS.Service/Models/PowerPoint/Item.cs
  9. 14 0
      TEAMModelOS.Service/Models/PowerPoint/Math.cs
  10. 39 0
      TEAMModelOS.Service/Models/PowerPoint/Paragraph.cs
  11. 77 0
      TEAMModelOS.Service/Models/PowerPoint/Path.cs
  12. 15 0
      TEAMModelOS.Service/Models/PowerPoint/Picture.cs
  13. 34 0
      TEAMModelOS.Service/Models/PowerPoint/Position.cs
  14. 22 0
      TEAMModelOS.Service/Models/PowerPoint/Pptx.cs
  15. 24 0
      TEAMModelOS.Service/Models/PowerPoint/Shape.cs
  16. 22 0
      TEAMModelOS.Service/Models/PowerPoint/Slide.cs
  17. 14 0
      TEAMModelOS.Service/Models/PowerPoint/Style.cs
  18. 24 0
      TEAMModelOS.Service/Models/PowerPoint/Table.cs
  19. 1741 0
      TEAMModelOS.Service/Services/PowerPoint/Implement/PowerPointHelper.cs
  20. 1242 0
      TEAMModelOS.Service/Services/PowerPoint/Implement/PowerPointService.cs
  21. 670 0
      TEAMModelOS.Service/Services/PowerPoint/Implement/ShapeGenerator.cs
  22. 16 0
      TEAMModelOS.Service/Services/PowerPoint/Interface/IPowerPointService.cs
  23. 0 4
      TEAMModelOS.Service/TEAMModelOS.Service.csproj
  24. 21 5
      TEAMModelOS/Controllers/Core/FileController.cs
  25. 4 0
      TEAMModelOS/Startup.cs

+ 18 - 0
TEAMModelOS.Service/Models/PowerPoint/Border.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HiTeachCC.Model.PowerPoint
+{
+    public  class Border
+    {
+
+        public int Width { get; set; }
+        public string Color { get; set; }
+        public string Type { get; set; }
+        /// <summary>
+        /// 描边
+        /// </summary>
+        public string Stroke{ get; set; }
+    }
+}

+ 11 - 0
TEAMModelOS.Service/Models/PowerPoint/Chart.cs

@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HiTeachCC.Model.PowerPoint
+{
+    public class Chart : Item
+    {
+        
+    }
+}

+ 19 - 0
TEAMModelOS.Service/Models/PowerPoint/Connector.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HiTeachCC.Model.PowerPoint
+{
+
+    public class Connector : Item
+    {
+        
+        /// <summary>
+        ///连接线 p:cxnSp
+        /// </summary>
+        public string CxnType { get; set; }
+        public string HeadEnd { get; set; }
+        public string TailEnd { get; set; }
+        public Border Border { get; set; }
+    }
+}

+ 10 - 0
TEAMModelOS.Service/Models/PowerPoint/Diagram.cs

@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HiTeachCC.Model.PowerPoint
+{
+    public class Diagram :Item
+    {
+    }
+}

+ 26 - 0
TEAMModelOS.Service/Models/PowerPoint/Fill.cs

@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HiTeachCC.Model.PowerPoint
+{
+    public class Fill
+    {
+        /// <summary>
+        /// [a:noFill, solidFill, gradFill, blipFill, pattFill, grpFill]
+        ///0,无填充 1.纯色填充 2.渐变填充 3.图片或纹理填充 4.图案填充
+        /// </summary>
+        public int Type { get; set; }
+        public string Color { get; set; }
+        public string Image { get; set; }
+        public FillStyle FillStyle { get; set; }
+
+    }
+    public class FillStyle {
+        public int Left { get; set; } = 0;
+        public int Top { get; set; } = 0;
+        public int Right { get; set; } = 0;
+        public int Bottom { get; set; } = 0;
+    }
+
+}

+ 17 - 0
TEAMModelOS.Service/Models/PowerPoint/FontStyle.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HiTeachCC.Model.PowerPoint
+{
+    public  class FontStyle
+    {
+        public string Color { get; set; }
+        public int Size { get; set; }
+        public string Type { get; set; }
+        public string Bold { get; set; }
+        public string Italic { get; set; }
+        public string Decoration { get; set; }
+        public string VertAlign { get; set; }
+    }
+}

+ 11 - 0
TEAMModelOS.Service/Models/PowerPoint/Group.cs

@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HiTeachCC.Model.PowerPoint
+{
+    public  class Group : Item
+    {
+        public List<Item> Shapes { get; set; }
+    }
+}

+ 19 - 0
TEAMModelOS.Service/Models/PowerPoint/Item.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HiTeachCC.Model.PowerPoint
+{
+    public abstract class Item
+    {
+        public string Type { get; set; }
+        public Position Position { get; set; }
+        public string Xml { get; set; }
+        public int Index { get; set; }
+        //public Picture Picture { get; set; }
+        //public Shape Shape { get; set; }
+        //public Math Math { get; set; }
+        //public Table Table { get; set; }
+        //public Chart Chart { get; set; }
+    }
+}

+ 14 - 0
TEAMModelOS.Service/Models/PowerPoint/Math.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HiTeachCC.Model.PowerPoint
+{
+    public class Math : Item
+    {
+    
+        public string Content { get; set; }
+        public Fill Fill { get; set; }
+        public Border Border { get; set; }
+    }
+}

+ 39 - 0
TEAMModelOS.Service/Models/PowerPoint/Paragraph.cs

@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HiTeachCC.Model.PowerPoint
+{
+    public class Paragraph
+    {
+
+        public ParagraphStyle ParagraphStyle { get; set; }
+        public Paragraph() {
+            Texts = new List<Text>();
+        }
+        public BuChar BuChar { get; set; }
+        public List<Text> Texts { get; set; }
+    }
+    public class Text
+    {
+        public string Content { get; set; }
+        public string Href { get; set; }
+      
+        public FontStyle FontStyle { get; set; }
+    }
+
+    public class BuChar{
+        public int MarginLeft { get; set; }
+        public int MarginRiht { get; set; }
+        public string Buchar { get; set; }
+        public string Typeface { get; set; }
+        public int  FontSize { get; set; }
+    }
+
+    public class ParagraphStyle
+    {
+        public string VertAlign { get; set; }
+        // public string LeftMargin { get; set; }
+        public string HoriAlign { get; set; }
+    }
+}

+ 77 - 0
TEAMModelOS.Service/Models/PowerPoint/Path.cs

@@ -0,0 +1,77 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HiTeachCC.Model.PowerPoint
+{
+    public abstract class Path
+    {
+        public string Type { get; set; }
+    }
+    public   class ClosePath :Path
+    {
+        public bool Close { get; set; } = false;
+    }
+
+    /// <summary>
+    /// 起点 <a:moveTo>
+    /// </summary>
+    public class MoveToPath : Path
+    {
+        public MoveToPath()
+        {
+            Pts = new List<Point> { };
+        }
+        public List<Point> Pts { get; set; }
+    }
+    /// <summary>
+    /// 弧形 <a:arcTo>
+    /// </summary>
+    public class ArcToPath : Path
+    {
+        public string WidthRadius { get; set; }
+        public string HeightRadius { get; set; }
+        public string StartAngle { get; set; }
+        public string SwingAngle { get; set; }
+    }
+
+
+    /// <summary>
+    /// 画线 <a:lnTo>
+    /// </summary>
+    public class LineToPath : Path
+    {
+        public LineToPath()
+        {
+            Pts = new List<Point> { };
+        }
+        public List<Point> Pts { get; set; }
+    }
+    /// <summary>
+    /// 三次贝塞尔曲线<a:cubicBezTo>
+    /// </summary>
+    public class CubicBezPath : Path
+    {
+        public CubicBezPath()
+        {
+            Pts = new List<Point> { };
+        }
+        public List<Point> Pts { get; set; }
+    }/// <summary>
+     /// 二次贝塞尔曲线  <a:quadBezTo>
+     /// </summary>
+    public class QuadBezPath : Path
+    {
+        public QuadBezPath()
+        {
+            Pts = new List<Point> { };
+        }
+        public List<Point> Pts { get; set; }
+    }
+
+    public class Point
+    {
+        public double X { get; set; }
+        public double Y { get; set; }
+    }
+}

+ 15 - 0
TEAMModelOS.Service/Models/PowerPoint/Picture.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HiTeachCC.Model.PowerPoint
+{
+    public   class Picture : Item
+    {
+        
+        //图片连接
+        public string Image { get; set; }
+        public Fill Fill { get; set; }
+        public Border Border { get; set; }
+    }
+}

+ 34 - 0
TEAMModelOS.Service/Models/PowerPoint/Position.cs

@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HiTeachCC.Model.PowerPoint
+{
+    public class Position
+    {
+        //旋转角度
+        public Int64 Rot { get; set; } = 0;
+        //水平翻转
+        public int FlipH { get; set; } = 0;
+        //垂直翻转
+        public int FlipV { get; set; } = 0;
+        //x轴
+        public Int64 X { get; set; } = 0;
+        //y轴
+        public Int64 Y { get; set; } = 0;
+        //宽度
+        public Int64 Cx { get; set; } = 0;
+        //高度
+        public Int64 Cy { get; set; } = 0;
+        ////初始坐标x
+        //public Int64 ChX { get; set; } = 0;
+        ////初始坐标Y
+        //public Int64 ChY { get; set; } = 0;
+        ////拉伸宽度
+        //public Int64 ChCX { get; set; } = 0;
+        ////拉伸高度
+        //public Int64 ChCY { get; set; } = 0;
+        //层级
+      
+    }
+}

+ 22 - 0
TEAMModelOS.Service/Models/PowerPoint/Pptx.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HiTeachCC.Model.PowerPoint
+{
+    public class Pptx
+    {   
+        //宽度
+        public double Width { get; set; }
+        //高度
+        public double Height { get; set; }
+        //缩略图
+        public string Thumbnail { get; set; }
+        //PPT幻灯片集合
+        public List<string> HiXmls { get; set; }
+        public string PptUrl { get; set; }
+        public string Sha1Code { get; set; }
+        //页数
+        public int PageSize { get; set; }
+    }
+}

+ 24 - 0
TEAMModelOS.Service/Models/PowerPoint/Shape.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HiTeachCC.Model.PowerPoint
+{
+     public class Shape : Item
+    { 
+        public string ShapeType;
+        public List<Paragraph> Paragraph { get; set; }
+        public Fill Fill { get; set; }
+        public Border Border { get; set; }
+       
+        public List<ShapeGuide> ShapeGuides { get; set; }
+        public List<Path> Paths { get; set; }
+
+    }
+    public class ShapeGuide
+    {
+        public string Name { get; set; }
+        public string Fmla { get; set; }
+
+    }
+}

+ 22 - 0
TEAMModelOS.Service/Models/PowerPoint/Slide.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HiTeachCC.Model.PowerPoint
+{
+    public class Slide
+    {
+        public Slide()
+        {
+            Item = new List<Item>();
+        }
+        public List<Item> Item { get; set; }
+        public Fill Fill { get; set; }
+      //  public string Xml { get; set; }
+        public int Index { get; set; }
+        //宽度
+        public double Width { get; set; }
+        //高度
+        public double Height { get; set; }
+    }
+}

+ 14 - 0
TEAMModelOS.Service/Models/PowerPoint/Style.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Xml;
+
+namespace HiTeachCC.Model.PowerPoint
+{
+    public class Style
+    {
+        public XmlDocument IdTable { get; set; }
+        public XmlDocument IdxTable { get; set; }
+        public XmlDocument TypeTable { get; set; }
+    }
+}

+ 24 - 0
TEAMModelOS.Service/Models/PowerPoint/Table.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HiTeachCC.Model.PowerPoint
+{
+    public class Table :Item
+    {
+        public Border Border { get; set; }
+        public Fill Fill { get; set; }
+        public List<Tr> Tr { get; set; }
+    }
+
+    public class Tr {
+        public List<Td> Td { get; set; }
+
+    }
+    public class Td
+    {
+        public int Rowspan { get; set; }
+        public int Colspan { get; set; }
+        public Paragraph Paragraph { get; set; }
+    }
+}

文件差异内容过多而无法显示
+ 1741 - 0
TEAMModelOS.Service/Services/PowerPoint/Implement/PowerPointHelper.cs


文件差异内容过多而无法显示
+ 1242 - 0
TEAMModelOS.Service/Services/PowerPoint/Implement/PowerPointService.cs


文件差异内容过多而无法显示
+ 670 - 0
TEAMModelOS.Service/Services/PowerPoint/Implement/ShapeGenerator.cs


+ 16 - 0
TEAMModelOS.Service/Services/PowerPoint/Interface/IPowerPointService.cs

@@ -0,0 +1,16 @@
+using HiTeachCC.Model.PowerPoint;
+using HiTeachCC.Service.Core.Interface;
+using Microsoft.AspNetCore.Http;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HiTeachCC.Service.PowerPoint.Interface
+{
+    public interface IPowerPointService : IBusinessService, IBaseService
+    {
+        Task<Dictionary<string, object>> LoadPresentation(IFormFile file); 
+    }
+}

+ 0 - 4
TEAMModelOS.Service/TEAMModelOS.Service.csproj

@@ -4,10 +4,6 @@
     <TargetFramework>netcoreapp3.0</TargetFramework>
   </PropertyGroup>
 
-  <ItemGroup>
-    <Folder Include="Services\" />
-  </ItemGroup>
-
   <ItemGroup>
     <ProjectReference Include="..\TEAMModelOS.SDK\TEAMModelOS.SDK.csproj" />
   </ItemGroup>

+ 21 - 5
TEAMModelOS/Controllers/Core/FileController.cs

@@ -1,4 +1,6 @@
-using Microsoft.AspNetCore.Http;
+using HiTeachCC.Service.PowerPoint.Implement;
+using HiTeachCC.Service.PowerPoint.Interface;
+using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using System;
 using System.Collections.Generic;
@@ -9,12 +11,9 @@ using TEAMModelOS.SDK.Context.Constant.Common;
 using TEAMModelOS.SDK.Extension.DataResult.JsonRpcRequest;
 using TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
-using TEAMModelOS.SDK.Helper.Common.JsonHelper;
-using TEAMModelOS.SDK.Helper.Common.XmlHelper;
 using TEAMModelOS.SDK.Module.AzureBlob.Container;
 using TEAMModelOS.SDK.Module.AzureBlob.Interfaces;
 using TEAMModelOS.SDK.Module.AzureTable.Interfaces;
-using TEAMModelOS.SDK.Module.PowerPointX.Model;
 
 namespace TEAMModelOS.Controllers.Syllabus
 {
@@ -24,10 +23,12 @@ namespace TEAMModelOS.Controllers.Syllabus
     {
         private readonly IAzureTableDBRepository azureTableDBRepository;
         private readonly IAzureBlobDBRepository _azureBlobDBRepository;
-        public FileController(IAzureTableDBRepository _azureTableDBRepository, IAzureBlobDBRepository azureBlobDBRepository)
+        private readonly IPowerPointService powerPointService;
+        public FileController(IAzureTableDBRepository _azureTableDBRepository, IAzureBlobDBRepository azureBlobDBRepository , IPowerPointService _powerPointService)
         {
             azureTableDBRepository = _azureTableDBRepository;
             _azureBlobDBRepository = azureBlobDBRepository;
+            powerPointService = _powerPointService;
         }
 
 
@@ -130,5 +131,20 @@ namespace TEAMModelOS.Controllers.Syllabus
                 return responseBuilder.Data(null).build();
             }
         }
+
+        /// <summary>
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [HttpPost("UploadDocument")]
+        [RequestSizeLimit(102_400_000_00)] //最大10000m左右
+        public async Task<BaseJosnRPCResponse> UploadDocument([FromForm] IFormFile file)
+        {
+            JsonRPCResponseBuilder responseBuilder = new JsonRPCResponseBuilder();
+
+            Dictionary<string, object> model = await powerPointService.LoadPresentation(file);
+
+            return responseBuilder.Data(model).build();
+        }
     }
 }

+ 4 - 0
TEAMModelOS/Startup.cs

@@ -4,6 +4,8 @@ using System.IdentityModel.Tokens.Jwt;
 using System.Linq;
 using System.Reflection;
 using System.Threading.Tasks;
+using HiTeachCC.Service.PowerPoint.Implement;
+using HiTeachCC.Service.PowerPoint.Interface;
 using Microsoft.AspNetCore.Authentication.JwtBearer;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Hosting;
@@ -102,6 +104,8 @@ namespace TEAMModelOS
             services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
             //引入Jwt配置
             services.JwtAuth(Configuration.GetSection("JwtSetting"));
+
+            //services.AddSingleton<PowerPointService, PowerPointService>();
             //全局扫描基于IBusinessService接口的实现类
             services.Scan(scan => scan.FromApplicationDependencies()
                .AddClasses(classes => classes.AssignableTo<IBusinessService>())