浏览代码

解决修改复制能力点时,文件没有的情况

Li 3 年之前
父节点
当前提交
73cb2c5bcc
共有 1 个文件被更改,包括 14 次插入8 次删除
  1. 14 8
      TEAMModelBI/Controllers/BISchool/BatchAreaController.cs

+ 14 - 8
TEAMModelBI/Controllers/BISchool/BatchAreaController.cs

@@ -596,10 +596,13 @@ namespace TEAMModelBI.Controllers.BISchool
                 catch
                 {
                 }
-                if (tempFile != null)                 
-                    await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReplaceItemAsync<StandardFile>(saveFile, saveFile.id, new PartitionKey("StandardFile")); //直接替换以前的数据
-                else
-                   await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(saveFile, new PartitionKey($"StandardFile")); // 需要删除原来的政策文件数据在进行添加
+                if (tempFile.id != null)
+                {
+                    if (tempFile.id.Equals(saveFile.id))
+                        await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReplaceItemAsync<StandardFile>(saveFile, saveFile.id, new PartitionKey("StandardFile")); //直接替换以前的数据
+                    else
+                        await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(saveFile, new PartitionKey($"StandardFile")); // 需要删除原来的政策文件数据在进行添加
+                }
 
                 //新的区域设置
                 AreaSetting saveSetting = new AreaSetting();
@@ -622,10 +625,13 @@ namespace TEAMModelBI.Controllers.BISchool
                 catch
                 {
                 }
-                if (tempSetting != null)
-                    await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReplaceItemAsync<AreaSetting>(saveSetting, saveSetting.id, new PartitionKey($"AreaSetting"));   //直接替换以前的数据
-                else
-                    await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(saveSetting, new PartitionKey($"AreaSetting"));  //需要删除原来的区域设置数据在进行添加
+                if (tempSetting.id != null)
+                {
+                    if (tempSetting.id.Equals(saveSetting.id))
+                        await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReplaceItemAsync<AreaSetting>(saveSetting, saveSetting.id, new PartitionKey($"AreaSetting"));   //直接替换以前的数据
+                    else
+                        await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(saveSetting, new PartitionKey($"AreaSetting"));  //需要删除原来的区域设置数据在进行添加
+                }
 
                 //发送消息分区键
                 string partitionCode = "DelBeforeCopyAbility-mark";