Просмотр исходного кода

Merge branch 'develop3.0' of http://106.12.23.251:10080/TEAMMODEL/TEAMModelOS into develop3.0

李思淳 5 лет назад
Родитель
Сommit
a00117c0c0

+ 0 - 1
TEAMModelOS.SDK/Module/AzureBlob/Configuration/AzureBlobOptions.cs

@@ -9,7 +9,6 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Configuration
         public string ConnectionString { get; set; } 
         public string AzureTableDialect { get; set; }
         public string Container { get; set; }
-        public string DialectKey { get; set; }
         /// <summary>
         /// 
         /// </summary>

+ 24 - 19
TEAMModelOS.SDK/Module/AzureBlob/Implements/AzureBlobDBRepository.cs

@@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Http;
 using TEAMModelOS.SDK.Extension.SnowFlake;
 using TEAMModelOS.SDK.Context.Constant;
 using TEAMModelOS.SDK.Helper.Common.JsonHelper;
+using TEAMModelOS.SDK.Helper.Security.ShaHash;
 
 namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
 {
@@ -32,16 +33,6 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
             {
                 blobClient = BlobClientSingleton.getInstance(options.ConnectionString).GetBlobClient();
             }
-            else if (AzureBlobConfig.AZURE_CHINA.Equals(options.AzureTableDialect))
-            {
-                AESCrypt crypt = new AESCrypt();
-                blobClient = BlobClientSingleton.getInstance(crypt.Decrypt(china, options.AzureTableDialect)).GetBlobClient();
-            }
-            else if (AzureBlobConfig.AZURE_GLOBAL.Equals(options.AzureTableDialect))
-            {
-                AESCrypt crypt = new AESCrypt();
-                blobClient = BlobClientSingleton.getInstance(crypt.Decrypt(global, options.AzureTableDialect)).GetBlobClient();
-            }
             else { throw new BizException("请设置正确的AzureBlob文件存储配置信息!"); }
         }
 
@@ -125,9 +116,11 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
                     }
                 }
                 await blockBlob.UploadFromStreamAsync(f.OpenReadStream());
+                string sha1= ShaHashHelper.GetSHA1(f.OpenReadStream());
                 AzureBlobModel model = new AzureBlobModel(f, _options.Container, groupName, name)
                 {
-                    BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + name
+                    BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + name,
+                    Sha1Code = sha1
                 };
                 list.Add(model);
             }
@@ -180,6 +173,7 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
             //var memi = provider.Mappings[fileext];
             AzureBlobModel model = new AzureBlobModel(file, _options.Container, groupName, name , content_type)
             {
+                Sha1Code=ShaHashHelper.GetSHA1(file.Create()),
                 BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + name
             };
             return model;
@@ -230,12 +224,14 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
                 blockBlob.Properties.ContentType = content_type;
             }
             
-            long length = System.Text.Encoding.Default.GetBytes(text).Length;
+        
             await blockBlob.UploadTextAsync(text);
+            byte[] bytes = System.Text.Encoding.Default.GetBytes(text);
             //var provider = new FileExtensionContentTypeProvider();
             //var memi = provider.Mappings[fileext];
-            AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, name, content_type, length)
+            AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, name, content_type, bytes.Length)
             {
+                Sha1Code = ShaHashHelper.GetSHA1(bytes),
                 BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + name
             };
             return model;
@@ -283,12 +279,14 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
                 blockBlob.Properties.ContentType = content_type;
             }
             string objStr = obj.ToJsonAbs();
-            long length = System.Text.Encoding.Default.GetBytes(objStr).Length;
+         
             await blockBlob.UploadTextAsync(objStr);
             //var provider = new FileExtensionContentTypeProvider();
             //var memi = provider.Mappings[fileext];
-            AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, name, content_type , length)
+            byte[] bytes = System.Text.Encoding.Default.GetBytes(objStr);
+            AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, name, content_type , bytes.Length)
             {
+                Sha1Code = ShaHashHelper.GetSHA1(bytes),
                 BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + name
             };
             return model;
@@ -330,8 +328,10 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
                 }
             }
             await blockBlob.UploadFromStreamAsync(file.OpenReadStream());
+            string sha1 = ShaHashHelper.GetSHA1(file.OpenReadStream());
             AzureBlobModel model = new AzureBlobModel(file, _options.Container, groupName, name)
-            {
+            {   
+                Sha1Code=sha1,
                 BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + name
             };
             return model;
@@ -379,6 +379,7 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
             blockBlob.UploadFromStreamAsync(fileSteam).GetAwaiter().GetResult() ;
             AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, fileName, folder, blockBlob.Properties.ContentType, fileSteam.Length)
             {
+                Sha1Code = ShaHashHelper.GetSHA1(fileSteam),
                 BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + fileName
             };
             return model;
@@ -426,8 +427,10 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
                 }
             }
             await blockBlob.UploadFromStreamAsync(fileSteam);
-            AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, fileName, folder, blockBlob.Properties.ContentType , fileSteam.Length)
+            string sha1 = ShaHashHelper.GetSHA1(fileSteam);
+            AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, fileName, folder, blockBlob.Properties.ContentType, fileSteam.Length)
             {
+                Sha1Code = sha1,
                 BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + fileName
             };
             return model;
@@ -461,10 +464,12 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
                 blockBlob.Properties.ContentType = content_type;
             }
 
-            long length = System.Text.Encoding.Default.GetBytes(text).Length;
+            
             await blockBlob.UploadTextAsync(text);
-            AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, fileName, folder, blockBlob.Properties.ContentType, length)
+            byte[] bytes = System.Text.Encoding.Default.GetBytes(text);
+            AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, fileName, folder, blockBlob.Properties.ContentType, bytes.Length)
             {
+                Sha1Code = ShaHashHelper.GetSHA1(bytes),
                 BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + fileName
             };
             return model;

+ 14 - 11
TEAMModelOS.Service/Services/PowerPoint/Implement/ShapeGenerator.cs

@@ -263,7 +263,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
                 themeContent = xdoc.GetTextByPath("//pkg:part[@pkg:name='" + themeFilename + "']");
             }
             Console.WriteLine(sldFileName, layoutFilename, masterFilename, themeFilename);
-            // =====< Step 3 >=====
+            // =====< Step 3 >===== throw new NotImplementedException();
             var slideContent = xdoc.GetTextByPath("//pkg:part[@pkg:name='" + sldFileName + "']");
             var spTreeNode = slideContent.GetTextByPath("pkg:xmlData/p:sld/p:cSld/p:spTree");
             WarpObj warpObj = new WarpObj
@@ -379,17 +379,17 @@ namespace HiTeachCC.Service.PowerPoint.Implement
 
         private string GenDiagram(XmlNode node, WarpObj warpObj)
         {
-            throw new NotImplementedException();
+           return "";
         }
 
         private string GenChart(XmlNode node, WarpObj warpObj)
         {
-            throw new NotImplementedException();
+            return "";
         }
 
         private string GenTable(XmlNode node, WarpObj warpObj)
         {
-            throw new NotImplementedException();
+            return "";
         }
 
         private async Task<Media> ProcessPicNode(XmlNode node, int order, WarpObj warpObj)
@@ -531,8 +531,6 @@ namespace HiTeachCC.Service.PowerPoint.Implement
             rtrnData += "</div>";
             //console.log(rtrnData)
             return media;
-
-            //throw new NotImplementedException();
         }
 
         private async Task<string> ProcessCxnSpNode(XmlNode node, int order, WarpObj warpObj)
@@ -583,7 +581,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
                 }
             }
             string s = await GenShape(node, slideLayoutSpNode, slideMasterSpNode, id, name, idx, type, order, warpObj);
-            throw new NotImplementedException();
+           return "";
         }
         public XmlNode GetNodesTable(XmlNode id , XmlNode idx,XmlNode type  , WarpObj warpObj ,string LayoutOrMaster)
         {
@@ -662,17 +660,22 @@ namespace HiTeachCC.Service.PowerPoint.Implement
         {
             var xfrmList = "p:spPr/a:xfrm";
             var slideXfrmNode = node.GetTextByPath(xfrmList);
-            XmlNode slideLayoutXfrmNode;
+            XmlNode slideLayoutXfrmNode = null;
             if (slideLayoutSpNode != null)
             {
                 slideLayoutXfrmNode = slideLayoutSpNode.GetTextByPath(xfrmList);
             }
-            XmlNode slideMasterXfrmNode;
+            XmlNode slideMasterXfrmNode = null;
             if (slideMasterSpNode != null)
             {
                 slideMasterXfrmNode = slideMasterSpNode.GetTextByPath(xfrmList);
             }
-
+            if (slideXfrmNode == null) {
+                slideXfrmNode = slideLayoutXfrmNode;
+            }
+            if (slideXfrmNode == null) {
+                slideXfrmNode = slideMasterXfrmNode;
+            }
             var result = "";
             var shpId = node.GetTextByPath("/@order");
             var shapType = node.GetTextByPath("p:spPr/a:prstGeom/@prst");
@@ -779,7 +782,7 @@ namespace HiTeachCC.Service.PowerPoint.Implement
                 }
                 result += "</defs>";
             }
-            throw new NotImplementedException();
+            return "";
         }
         public Border GetBorder(XmlNode node, bool isSvgMode, string bType)
         {

+ 2 - 4
TEAMModelOS/appsettings.Development.json

@@ -9,13 +9,11 @@
   "AllowedHosts": "*",
   "Azure": {
     "Table": {
-      "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelostest;AccountKey=QB/zYHHCAtZfl9tf4emL1Y9ZXGc6fqZ+nNbCxIHM70HnziC8dMdEAu7+Pa4mbKLlbswV90wWHAF3nMjrKB54Lw==;EndpointSuffix=core.chinacloudapi.cn",
-      "AzureTableDialect": ""
+      "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelostest;AccountKey=QB/zYHHCAtZfl9tf4emL1Y9ZXGc6fqZ+nNbCxIHM70HnziC8dMdEAu7+Pa4mbKLlbswV90wWHAF3nMjrKB54Lw==;EndpointSuffix=core.chinacloudapi.cn"
     },
     "Blob": {
       "ConnectionString": "https://teammodelstorage.blob.core.chinacloudapi.cn/teammodelos?st=2019-05-09T07%3A54%3A03Z&se=2070-05-10T07%3A54%3A00Z&sp=rwdl&sv=2018-03-28&sr=c&sig=F3uke8DNrp4JgAdGbbPidXVSIxphL1AsfD9%2BSi1mBSo%3D",
-      "Container": "teammodelos",
-      "AzureTableDialect": ""
+      "Container": "teammodelos"
     },
     "CosmosDB": {
       "ConnectionString": "https://192.168.8.128:8081",

+ 2 - 4
TEAMModelOS/appsettings.json

@@ -9,13 +9,11 @@
   "AllowedHosts": "*",
   "Azure": {
     "Table": {
-      "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelostest;AccountKey=QB/zYHHCAtZfl9tf4emL1Y9ZXGc6fqZ+nNbCxIHM70HnziC8dMdEAu7+Pa4mbKLlbswV90wWHAF3nMjrKB54Lw==;EndpointSuffix=core.chinacloudapi.cn",
-      "AzureTableDialect": ""
+      "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelostest;AccountKey=QB/zYHHCAtZfl9tf4emL1Y9ZXGc6fqZ+nNbCxIHM70HnziC8dMdEAu7+Pa4mbKLlbswV90wWHAF3nMjrKB54Lw==;EndpointSuffix=core.chinacloudapi.cn"
     },
     "Blob": {
       "ConnectionString": "https://teammodelstorage.blob.core.chinacloudapi.cn/teammodelos?st=2019-05-09T07%3A54%3A03Z&se=2070-05-10T07%3A54%3A00Z&sp=rwdl&sv=2018-03-28&sr=c&sig=F3uke8DNrp4JgAdGbbPidXVSIxphL1AsfD9%2BSi1mBSo%3D",
-      "Container": "teammodelos",
-      "AzureTableDialect": ""
+      "Container": "teammodelos"
     },
     "CosmosDB": {
       "ConnectionString": "https://teammodelos.documents.azure.cn:443/",