瀏覽代碼

完成图片,视频,音频解析,并存放至blob中。

CrazyIter 5 年之前
父節點
當前提交
e2d2af6dc8

+ 6 - 3
TEAMModelOS.Service/Models/PowerPoint/Picture.cs

@@ -4,10 +4,13 @@ using System.Text;
 
 namespace HiTeachCC.Model.PowerPoint
 {
-    public   class Picture : Item
+    public   class Media : Item
     {
-        
-        //图片连接
+        //image 图片 video.视频 audio 音频
+        public string MediaType { get; set; }
+        //视频资源链接
+        public string Url { get; set; }
+        //图片或视频音频缩略图链接
         public string Image { get; set; }
         public Fill Fill { get; set; }
         public Border Border { get; set; }

+ 5 - 34
TEAMModelOS.Service/Services/PowerPoint/Implement/PowerPointHelper.cs

@@ -85,40 +85,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
         }
 
 
-      public static async Task<AzureBlobModel>SaveBase64ToBolob(string data, string contentType ,string FolderName ,string fileName , IAzureBlobDBRepository azureBlobDBRepository ) {
-            string fileExt ;
-            if (ContentTypeDict.extdict.TryGetValue(contentType, out string ext))
-            {
-                fileExt = ext;
-            }
-            else
-            {
-                //解决多种扩展名不能获取的
-                string[] sp = contentType.Split("/");
-                fileExt = sp[sp.Length - 1];
-                sp = fileExt.Split("+");
-                fileExt = "." + sp[sp.Length - 1];
-            }
-            //data:image/jpeg;base64,
-            try {
-                if (string.IsNullOrEmpty(fileName))
-                {
-                    Stream stream = new MemoryStream(Convert.FromBase64String(data));
-                    string shaCode = ShaHashHelper.GetSHA1(stream);
-                    fileName = shaCode + fileExt;
-                }
-                else {
-                    if (fileName.Split(".").Length == 1) {
-                        fileName += fileExt;
-                    }
-                }
-                Stream streamBlob = new MemoryStream(Convert.FromBase64String(data));
-                AzureBlobModel model = await azureBlobDBRepository.UploadFileByFolder(streamBlob, FolderName , fileName, "pptx", false);
-                return model;
-            } catch (Exception x) {
-
-                throw new BizException(x.Message);          }
-        }
+  
         public static void GenPPTXShape(XmlNode shapeType)
         {
             string svgPath = "";
@@ -925,6 +892,10 @@ namespace HiTeachCC.Service.PowerPoint.Implement
             return colorHex;
         }
 
+
+    
+
+
         public static Dictionary<string, string> GetLayoutOrMasterColors(SlidePart slidePart, Dictionary<string, string> slideMasterColors, Theme theme)
         {
 

+ 8 - 8
TEAMModelOS.Service/Services/PowerPoint/Implement/PowerPointService.cs

@@ -27,7 +27,7 @@ using TEAMModelOS.SDK.Module.AzureTable.Interfaces;
 using BlipFill = DocumentFormat.OpenXml.Presentation.BlipFill;
 using ColorMap = DocumentFormat.OpenXml.Presentation.ColorMap;
 using Paragraph = HiTeachCC.Model.PowerPoint.Paragraph;
-using Picture = HiTeachCC.Model.PowerPoint.Picture;
+using Picture = HiTeachCC.Model.PowerPoint.Media;
 using Point = HiTeachCC.Model.PowerPoint.Point;
 using Shape = HiTeachCC.Model.PowerPoint.Shape;
 using Text = HiTeachCC.Model.PowerPoint.Text;
@@ -359,7 +359,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
 
             if (element is DocumentFormat.OpenXml.Presentation.Picture pic)//p:pic  图片
             {
-                Model.PowerPoint.Picture picture = ProcessPicNode(pic, idPartPairs, slideMaster, colorMaps, index, slideLayoutTables, slideMasterTables, SlideMasterTextStyles, theme);
+                Model.PowerPoint.Media picture = ProcessPicNode(pic, idPartPairs, slideMaster, colorMaps, index, slideLayoutTables, slideMasterTables, SlideMasterTextStyles, theme);
                 if (!string.IsNullOrEmpty(picture.Image)) {
                     string[] strs = picture.Image.Split(',');
                     string fileExt = StringHelper.SubMidString(strs[0], ":", ";");
@@ -388,7 +388,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
             else if (element is DocumentFormat.OpenXml.AlternateContent mc)//mc:alternatecontent   公式等 
             {
 
-                Model.PowerPoint.Picture picture = ProcessMcNode(mc, idPartPairs, slideMaster, colorMaps, index, slideLayoutTables, slideMasterTables, SlideMasterTextStyles, theme);
+                Model.PowerPoint.Media picture = ProcessMcNode(mc, idPartPairs, slideMaster, colorMaps, index, slideLayoutTables, slideMasterTables, SlideMasterTextStyles, theme);
                 if (!string.IsNullOrEmpty(picture.Image))
                 {
                     string[] strs = picture.Image.Split(',');
@@ -946,7 +946,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
         /// <param name="slideLayoutTables"></param>
         /// <param name="slideMasterTables"></param>
         /// <returns></returns>
-        public Model.PowerPoint.Picture ProcessPicNode(DocumentFormat.OpenXml.Presentation.Picture element,
+        public Model.PowerPoint.Media ProcessPicNode(DocumentFormat.OpenXml.Presentation.Picture element,
             IEnumerable<IdPartPair> idPartPairs, SlideMaster slideMaster, Dictionary<string, string> colors, int index,
             Style slideLayoutTables,
             Style slideMasterTables, XmlDocument slideMasterTextStyles, Theme theme)
@@ -971,7 +971,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
 
             Border border = PowerPointHelper.GetBorder(element.OuterXml, false, colors);
             Model.PowerPoint.Fill fill = PowerPointHelper.GetShapeFill(element.OuterXml, colors);
-            Model.PowerPoint.Picture picture = new Model.PowerPoint.Picture
+            Model.PowerPoint.Media picture = new Model.PowerPoint.Media
             {
                 Type = "Pic",
                 Position = picPosition,
@@ -995,7 +995,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
         /// <param name="slideLayoutTables"></param>
         /// <param name="slideMasterTables"></param>
         /// <returns></returns>
-        public Model.PowerPoint.Picture ProcessMcNode(DocumentFormat.OpenXml.AlternateContent element, IEnumerable<IdPartPair> slidePart,
+        public Model.PowerPoint.Media ProcessMcNode(DocumentFormat.OpenXml.AlternateContent element, IEnumerable<IdPartPair> slidePart,
             SlideMaster slideMaster, Dictionary<string, string> colors,
             int index,
             Style slideLayoutTables,
@@ -1022,7 +1022,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
         }
 
 
-        public Model.PowerPoint.Picture MathConvertImage(AlternateContent content, Theme theme, Dictionary<string, string> colors, IEnumerable<IdPartPair> slidePart, int index)
+        public Model.PowerPoint.Media MathConvertImage(AlternateContent content, Theme theme, Dictionary<string, string> colors, IEnumerable<IdPartPair> slidePart, int index)
         {
             var fallbacks = from contentChoice in content.Descendants<AlternateContentFallback>() select contentChoice;
             if (fallbacks.Count() > 0)
@@ -1053,7 +1053,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
                             Border border = PowerPointHelper.GetBorder(shape.OuterXml, false, colors);
                             Model.PowerPoint.Fill fill = PowerPointHelper.GetShapeFill(shape.OuterXml, colors);
                             //  picPosition.Index = index;
-                            Model.PowerPoint.Picture picture = new Model.PowerPoint.Picture
+                            Model.PowerPoint.Media picture = new Model.PowerPoint.Media
                             {
                                 Type = "Math",
                                 Position = picPosition,

File diff suppressed because it is too large
+ 404 - 267
TEAMModelOS.Service/Services/PowerPoint/Implement/ShapeGenerator.cs