瀏覽代碼

Merge branch 'develop5.0-tmd' of http://106.12.23.251:10000/TEAMMODEL/TEAMModelOS into develop5.0-tmd

zhouj1203@hotmail.com 3 年之前
父節點
當前提交
37031fbbc4

+ 1 - 1
TEAMModelFunction/TriggerStudy.cs

@@ -78,7 +78,7 @@ namespace TEAMModelFunction
             }
             catch (Exception ex)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}投票活动异常{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}研修活动异常{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
             }
 
         }

+ 1 - 0
TEAMModelOS.SDK/Models/Cosmos/Teacher/TeacherWork.cs

@@ -97,6 +97,7 @@ namespace TEAMModelOS.SDK.Models
         /// </summary>
         public int? status { get; set; } = 0;
         public long? size { get; set; } = 0;
+        public string areaId { get; set; }
         public List<Submits> teachers { get; set; } = new List<Submits>();
     }
     public class Submits {

+ 40 - 0
TEAMModelOS.SDK/Models/Service/TeacherWorkService.cs

@@ -0,0 +1,40 @@
+using Azure.Cosmos;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading.Tasks;
+using TEAMModelOS.SDK.DI;
+
+namespace TEAMModelOS.SDK.Models.Service
+{
+	public static class TeacherWorkService
+	{
+        public static async Task<string> saveMoreAsync(CosmosClient client, DingDing _dingDing, TeacherWork work)
+        {
+            try
+            {
+                work.ttl = -1;
+                work.code = "TeacherWork-" + work.school;
+                long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                work.createTime = now;
+
+                if (string.IsNullOrEmpty(work.id))
+                {
+                    work.id = Guid.NewGuid().ToString();
+                    await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(work, new PartitionKey($"{work.code}"));
+                }
+                else
+                {
+                    await client.GetContainer("TEAMModelOS", "Common").UpsertItemAsync(work, new PartitionKey($"{work.code}"));
+                }
+                return work.id;
+            }
+            catch (Exception e)
+            {
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-TeacherWorkService-saveMore\n{e.Message}{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
+                return "";
+
+            }
+        }
+    }
+}

+ 1 - 1
TEAMModelOS/ClientApp/src/common/BaseLayout.vue

@@ -343,7 +343,7 @@ export default {
                     role: 'admin',
                     permission: '',
                     subName: 'scTrain',
-                    isShow: process.env.NODE_ENV == 'development',
+                    isShow: this.srvAdr == 'China',
                     child: [
                         {
                             icon: 'iconfont icon-policy',

+ 42 - 0
TEAMModelOS/Controllers/Common/AreaController.cs

@@ -229,6 +229,7 @@ namespace TEAMModelOS.Controllers
                     study.createTime = now;
                     study.tchLists = pa.gId;
                     study.pId = areaStudy.id;
+                    study.scope = "school";
                     study.targetType = "research";
                     if (pa.gName.Count == 0)
                     {
@@ -263,6 +264,7 @@ namespace TEAMModelOS.Controllers
                             trExam.school = pa.sId;
                             trExam.areaId = id.GetString();
                             trExam.tchLists = pa.gId;
+                            trExam.scope = "school";
                             trExam.targetType = "research";
                             trExam.blob = $"/{trExam.areaId}/exam/{study.pId}/index.json";
                             //处理发布对象
@@ -286,6 +288,7 @@ namespace TEAMModelOS.Controllers
                             trSurvey.school = pa.sId;
                             trSurvey.areaId = id.GetString();
                             trSurvey.tchLists = pa.gId;
+                            trSurvey.scope = "school";
                             trSurvey.targetType = "research";
                             trSurvey.blob = $"/{trSurvey.areaId}/survey/{study.pId}/index.json";
                             await getMoreSurvey(pa, trSurvey);
@@ -299,6 +302,28 @@ namespace TEAMModelOS.Controllers
                                 study.surveyId = surveyId;
                             }
                         }
+                        if (setting.Equals("work"))
+                        {
+                            if (!request.TryGetProperty("work", out JsonElement work)) return BadRequest();
+                            TeacherWork teacherWork = work.ToObject<TeacherWork>();
+                            teacherWork.owner = "area";
+                            teacherWork.school = pa.sId;
+                            teacherWork.areaId = id.GetString();
+                            teacherWork.tchLists = pa.gId;
+                            teacherWork.scope = "school";
+                            teacherWork.targetType = "research";
+                            teacherWork.blob = $"/{teacherWork.areaId}/survey/{study.pId}/index.json";
+                            await getMoreWork(pa, teacherWork);
+                            string workId = await TeacherWorkService.saveMoreAsync(client, _dingDing, teacherWork);
+                            if (string.IsNullOrEmpty(workId))
+                            {
+                                return Ok(new { code = (int)HttpStatusCode.BadRequest, msg = "作业活动异常" });
+                            }
+                            else
+                            {
+                                study.workId = workId;
+                            }
+                        }
                     }
                     if (string.IsNullOrEmpty(study.id))
                     {
@@ -1195,6 +1220,23 @@ namespace TEAMModelOS.Controllers
             }
             return Task.FromResult(trSurvey);
         }
+        private Task<TeacherWork> getMoreWork(parameter pa, TeacherWork work)
+        {
+            if (pa.gName.Count == 0)
+            {
+
+                //trSurvey.targets.Add("所有老师(未分组)");
+                string json = "所有老师(未分组)";
+                work.targets.Add(json.ToJsonString().ToObject<JsonElement>());
+            }
+            else
+            {
+                var tn = pa.gName.ToJsonString().ToObject<List<JsonElement>>();
+                work.targets = tn;
+
+            }
+            return Task.FromResult(work);
+        }
 
         private async Task<List<(string id, string name)>> getInfo(CosmosClient client, string id)
         {

+ 2 - 2
TEAMModelOS/Controllers/Research/AppraiseController.cs

@@ -251,8 +251,8 @@ namespace TEAMModelOS.Controllers.Research
                         Debate rdebate = null;
                         try {
                               rdebate = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Debate>($"{_videoId}", new PartitionKey($"Debate-{_atSchool}"));
-                        } catch (CosmosException ex) { 
-                        
+                        } catch (CosmosException ex) {
+                            rdebate = null;
                         }
                         if (appraises.roles != null) {
                             appraises.roles.ToList().ForEach(x => {

+ 0 - 15
TEAMModelOS/MSBuild_Logs/MSBuild_pid-1876_f6a33b090fd448c2b17d2796477abb8e.failure.txt

@@ -1,15 +0,0 @@
-UNHANDLED EXCEPTIONS FROM PROCESS 1876:
-=====================
-2021/9/9 15:59:50
-System.UnauthorizedAccessException: 对路径“C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\MSBuild_Logs”的访问被拒绝。
-   在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
-   在 System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)
-   在 System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
-   在 Microsoft.Build.Shared.ExceptionHandling.DumpExceptionToFile(Exception ex)
-   在 Microsoft.Build.BackEnd.NodeEndpointOutOfProcBase.RunReadLoop(Stream localReadPipe, Stream localWritePipe, ConcurrentQueue`1 localPacketQueue, AutoResetEvent localPacketAvailable, AutoResetEvent localTerminatePacketPump)
-   在 Microsoft.Build.BackEnd.NodeEndpointOutOfProcBase.PacketPumpProc()
-   在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
-   在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
-   在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
-   在 System.Threading.ThreadHelper.ThreadStart()
-===================