瀏覽代碼

Merge branch 'develop' of http://52.130.252.100:10000/TEAMMODEL/TEAMModelOS into develop

CrazyIter_Bin 2 年之前
父節點
當前提交
c0bef6cb87

+ 2 - 0
TEAMModelOS.SDK/Models/Cosmos/Common/ArtMusic.cs

@@ -20,6 +20,8 @@ namespace TEAMModelOS.SDK.Models.Cosmos.Common
         public string questionName { get; set; }
         public List<MustSong> mustSong { get; set; } = new List<MustSong>();
         public List<MustSong> optionSong { get; set; } = new List<MustSong>();
+        //0未作答 1已作答
+        public int isAnswer { get; set; } = 0;
     }
     public class MustSong
     { 

+ 2 - 0
TEAMModelOS/ClientApp/public/lang/en-US.js

@@ -4532,6 +4532,8 @@ const LANG_EN_US = {
             error: "Failed to join the course",
             api: "API Error",
             noAgree: "The course is not open to join",
+            basicCourses: 'Base Course',
+            system: 'System',
         },
         coursesCardTitle: 'My Course List',
         newAddCourse: 'The latest addition',

+ 2 - 0
TEAMModelOS/ClientApp/public/lang/zh-CN.js

@@ -4535,6 +4535,8 @@ const LANG_ZH_CN = {
             error: "邀请码不存在,请重新输入",
             api: "API错误",
             noAgree: "课程名单未开放加入",
+            basicCourses: '基本课程',
+            system: '系统',
         },
         coursesCardTitle: '我的课程清单',
         newAddCourse: '最新加入课程',

+ 2 - 0
TEAMModelOS/ClientApp/public/lang/zh-TW.js

@@ -4536,6 +4536,8 @@ const LANG_ZH_TW = {
             error: "課程加入失敗",
             api: "API錯誤",
             noAgree: "課程名單未開放加入",
+            basicCourses: '基本課程',
+            system: '系統',
         },
         coursesCardTitle: '我的課程清單',
         newAddCourse: '最新加入課程',

+ 8 - 0
TEAMModelOS/ClientApp/src/view/mycourse/MyCourse.less

@@ -249,4 +249,12 @@
 .start-cus-info {
     color: #17233d;
     font-weight: 900;
+}
+
+.edit-name-content{
+    .edit-name-label{
+        margin-bottom: 0;
+        margin-right: 20px;
+        min-width: 30px;
+    }
 }

+ 7 - 5
TEAMModelOS/ClientApp/src/view/mycourse/MyCourse.vue

@@ -169,10 +169,12 @@
         {{$t('cusMgt.renameListTitle')}}
       </div>
       <div class="edit-name-content">
-        <p class="edit-name-label">
-          {{$t('cusMgt.listName')}}
-        </p>
-        <Input v-model="edName" :placeholder="renameBefore" />
+        <div style="display: flex; align-items: center;">
+          <p class="edit-name-label">
+            {{$t('cusMgt.listName')}}
+          </p>
+          <Input v-model="edName" :placeholder="renameBefore" />
+        </div>
         <Button :loading="btnLoading" @click="confirmRename" long type="primary" class="confirm-btn">{{ $t('syllabus.confirm') }}</Button>
       </div>
     </Modal>
@@ -198,7 +200,7 @@
             </RadioGroup>
           </FormItem>
           <FormItem :label="$t('cusMgt.name')" v-if="type == 'create'">
-            <Input v-file-name v-model="listName" :placeholder="$t('cusMgt.nameHolder')" style="width: 300px" />
+            <Input v-file-name v-model="listName" :placeholder="$t('cusMgt.nameHolder')" />
           </FormItem>
           <FormItem :label="$t('cusMgt.listLabel')" v-else>
             <Select v-model="listId" style="width:300px">

+ 10 - 7
TEAMModelOS/ClientApp/src/view/student-web/AppNew.vue

@@ -3,9 +3,12 @@
         <!--導航列-->
         <div class="myNav">
             <div>
-                <span @click="clickSidebarToggle()" v-if="MyNo != '1' && MyNo != '4' && MyNo != 'X' && MyNo != '7' && MyNo != '8'" class="sidebar-toggle">
+                <span @click="clickSidebarToggle()" v-if="MyNo != '1' && MyNo != '4' && MyNo != 'X' && MyNo != '7' && MyNo != '8' && MyNo != '12' && MyNo != '13'" class="sidebar-toggle">
                     <Icon class="menu-icon" type="md-menu" :class="{'menu-icon-close': this.$store.getters.getSidebarisOpen == false}" v-if="MyNo != '11'" />
                 </span>
+                <span v-show="MyNo === '13'" class="sidebar-toggle">
+                    <Icon custom="iconfont icon-exit" size="20" class="menu-icon" @click="$router.go(-1)"></Icon>
+                </span>
                 <span :class="['mytitle', {'no-show-title': MyNo === '1'}]">{{ MyName }}</span>
             </div>
             <div :class="courseList.length && !onlySystem ? 'selectClass' : 'addClass'" v-if="MyNo != '11'">
@@ -632,17 +635,17 @@ export default {
                             admClass = {
                                 id: "",
                                 no: "",
-                                name: "基本课程-系统",
+                                name: `${this.$t('studentWeb.courseType.basicCourses')}-${this.$t('studentWeb.courseType.system')}`,
                                 subject: "",
                                 scope: "school",
                                 school: this.$store.state.userInfo.azp,
                                 creatorId: "",
                                 desc: "",
                                 roster: undefined,
-                                teacherName: "系统",
+                                teacherName: this.$t('studentWeb.courseType.system'),
                                 list: this.user.studentProfile.classinfo.id,
                                 listName: this.user.studentProfile.classinfo.name,
-                                showName: `基本课程-系统(系统-${this.user.studentProfile.classinfo.name})`,
+                                showName: `${this.$t('studentWeb.courseType.basicCourses')}-${this.$t('studentWeb.courseType.system')}(${this.$t('studentWeb.courseType.system')}-${this.user.studentProfile.classinfo.name})`,
                                 courseAddDate: "",
                                 createTime: 0,
                                 isSystem: true,
@@ -656,17 +659,17 @@ export default {
                     let admClass = {
                         id: "",
                         no: "",
-                        name: "基本课程-系统",
+                        name: `${this.$t('studentWeb.courseType.basicCourses')}-${this.$t('studentWeb.courseType.system')}`,
                         subject: "",
                         scope: "school",
                         school: this.$store.state.userInfo.azp,
                         creatorId: "",
                         desc: "",
                         roster: undefined,
-                        teacherName: "系统",
+                        teacherName: this.$t('studentWeb.courseType.system'),
                         list: this.user.studentProfile.classinfo.id,
                         listName: this.user.studentProfile.classinfo.name,
-                        showName: `基本课程-系统(系统-${this.user.studentProfile.classinfo.name})`,
+                        showName: `${this.$t('studentWeb.courseType.basicCourses')}-${this.$t('studentWeb.courseType.system')}(${this.$t('studentWeb.courseType.system')}-${this.user.studentProfile.classinfo.name})`,
                         courseAddDate: "",
                         createTime: 0,
                         isSystem: true,

+ 45 - 12
TEAMModelOS/Controllers/Common/ArtController.cs

@@ -22,6 +22,7 @@ using System.Reflection;
 using System.Text;
 using System.Text.Json;
 using System.Threading.Tasks;
+using System.Xml.Linq;
 using TEAMModelOS.Filter;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK;
@@ -78,18 +79,19 @@ namespace TEAMModelOS.Controllers.Common
             try
             {
                 if (!request.TryGetProperty("art", out JsonElement art)) return BadRequest();
-               
+
                 var client = _azureCosmos.GetCosmosClient();
                 ArtEvaluation ae = art.ToObject<ArtEvaluation>();
                 bool flag = false;
                 ArtMusic music = new();
-                if (request.TryGetProperty("ArtMusic", out JsonElement am)) {
+                if (request.TryGetProperty("ArtMusic", out JsonElement am))
+                {
                     music = am.ToObject<ArtMusic>();
                     music.ttl = -1;
                     music.code = "ArtMusic";
                     flag = true;
                 };
-                
+
                 var (userid, _, _, school) = HttpContext.GetAuthTokenInfo();
                 string code = ae.school;
                 ae.ttl = -1;
@@ -106,19 +108,20 @@ namespace TEAMModelOS.Controllers.Common
                 }
                 if (string.IsNullOrEmpty(ae.id))
                 {
-                   
-                    ae.id = Guid.NewGuid().ToString();                  
+
+                    ae.id = Guid.NewGuid().ToString();
                     await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(ae, new PartitionKey($"{ae.code}"));
                     if (flag)
                     {
                         music.id = ae.id;
                         await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(music, new PartitionKey("ArtMusic"));
                     }
-                    
+
                 }
                 else
                 {
-                    if (flag) {
+                    if (flag)
+                    {
                         await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(music, music.id, new PartitionKey("ArtMusic"));
                     }
                     await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(ae, ae.id, new PartitionKey($"{ae.code}"));
@@ -134,6 +137,34 @@ namespace TEAMModelOS.Controllers.Common
 
         }
 
+        [ProducesDefaultResponseType]
+        [AuthToken(Roles = "teacher,admin,student")]
+        [HttpPost("update-state")]
+        [Authorize(Roles = "IES")]
+        public async Task<IActionResult> UpdateState(JsonElement request)
+        {
+            if (!request.TryGetProperty("isAnswer", out JsonElement isAnswer)) return BadRequest();
+            if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
+            var client = _azureCosmos.GetCosmosClient();
+            try
+            {
+                ArtMusic music = new();
+                var response = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(id.GetString(), new PartitionKey("ArtMusic"));
+                if (response.Status == 200)
+                {
+                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    music = json.ToObject<ArtMusic>();
+                    music.isAnswer = isAnswer.GetInt32();
+                    await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(music, music.id, new PartitionKey($"{music.code}"));
+                }
+                return Ok(music);
+            }
+            catch (Exception e)
+            {
+                return BadRequest(new { msg = e.Message });
+            }
+        }
+
         [ProducesDefaultResponseType]
         [AuthToken(Roles = "teacher,admin,student")]
         [HttpPost("upload")]
@@ -710,18 +741,20 @@ namespace TEAMModelOS.Controllers.Common
                         {
                             responses.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Student).CreateItemAsync(z, new PartitionKey(z.code)));
                         });
-                        if (responses.Count > 0) {
+                        if (responses.Count > 0)
+                        {
                             await responses.TaskPage(10);
-                        }                      
+                        }
                     }
                     if (!string.IsNullOrWhiteSpace(ae.id))
                     {
                         return Ok(new { art, classes, ae, music, code = 200 });
                     }
-                    else {
+                    else
+                    {
                         return Ok(new { art, classes, music, code = 200 });
                     }
-                    
+
 
 
                 }
@@ -764,7 +797,7 @@ namespace TEAMModelOS.Controllers.Common
 
                     if (!string.IsNullOrWhiteSpace(art.pId))
                     {
-                        var response = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(art.pId, new PartitionKey("ArtMusic"));                      
+                        var response = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(art.pId, new PartitionKey("ArtMusic"));
                         if (response.Status == 200)
                         {
                             using var json = await JsonDocument.ParseAsync(response.ContentStream);

+ 126 - 0
TEAMModelOS/Controllers/School/SchoolController.cs

@@ -664,6 +664,132 @@ namespace TEAMModelOS.Controllers
                 return BadRequest();
             }
         }
+
+        [ProducesDefaultResponseType]
+        [HttpPost("get-teach-count")]
+        //[AuthToken(Roles = "teacher,admin,student")]
+
+#if !DEBUG
+        [Authorize(Roles = "IES")]
+#endif
+        public async Task<IActionResult> GetTeacCount(JsonElement request)
+        {
+            try
+            {
+                if (!request.TryGetProperty("school_code", out JsonElement school_code)) return BadRequest();
+                var db = _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School");
+                var r8 = _azureRedis.GetRedisClient(8);
+
+                List<SchoolProductSerial> serial = new(); //承接DB資料用:序號
+                List<deviceForCoreService> uuidList = new(); //要向CoreService詢問deviceID及硬體資訊的UUID列表
+                long UTCNow = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
+
+                //軟體
+                List<string> serialPermitList = getSerialPermitProdcodeList();
+                string serialPermitJsonStr = JsonConvert.SerializeObject(serialPermitList);
+                string serialQueryText = $"SELECT * FROM c WHERE c.dataType = 'serial' AND ARRAY_CONTAINS({serialPermitJsonStr}, c.prodCode)";
+                await foreach (var itemsr in db.GetItemQueryStreamIterator(queryText: serialQueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{school_code}") }))
+                {
+                    using var json = await JsonDocument.ParseAsync(itemsr.ContentStream);
+                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                    {
+                        deviceForCoreService uuidForCore;
+                        foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
+                        {
+                            serial.Add(obj.ToObject<SchoolProductSerial>());
+                            if (obj.TryGetProperty("deviceBound", out JsonElement deviceBoundJobj) && !string.IsNullOrWhiteSpace(deviceBoundJobj.ToString()))
+                            {
+                                foreach (var deviceBoundTmpRow in deviceBoundJobj.EnumerateArray())
+                                {
+                                    uuidForCore = new deviceForCoreService
+                                    {
+                                        sn = (!string.IsNullOrWhiteSpace(Convert.ToString(obj.GetProperty("serial")))) ? Convert.ToString(obj.GetProperty("serial")) : null,
+                                        uuid1 = (!string.IsNullOrWhiteSpace(Convert.ToString(deviceBoundTmpRow.GetProperty("uuid")))) ? Convert.ToString(deviceBoundTmpRow.GetProperty("uuid")) : null,
+                                        uuid2 = (!string.IsNullOrWhiteSpace(Convert.ToString(deviceBoundTmpRow.GetProperty("uuid2")))) ? Convert.ToString(deviceBoundTmpRow.GetProperty("uuid2")) : null,
+                                        device_id = (!string.IsNullOrWhiteSpace(Convert.ToString(deviceBoundTmpRow.GetProperty("deviceId")))) ? Convert.ToString(deviceBoundTmpRow.GetProperty("deviceId")) : null,
+                                        class_id = (!string.IsNullOrWhiteSpace(Convert.ToString(deviceBoundTmpRow.GetProperty("classId")))) ? Convert.ToString(deviceBoundTmpRow.GetProperty("classId")) : null
+                                    };
+                                    uuidList.Add(uuidForCore);
+                                }
+                            }
+                        }
+                    }
+                }
+                ////取得DeviceInfo From Core 並更新序號資料
+                List<deviceFromCoreService> coreUuidList = (List<deviceFromCoreService>)GetDeviceFromCoreAsync(uuidList).GetAwaiter().GetResult();
+                List<deviceBoundExt> deviceBoundArray;
+                List<deviceBoundExt> counts = new();
+                List<deviceFromCoreService> coreUuid;
+                deviceForCoreService deviceBoundRow;
+                deviceBoundExt deviceBoundExt;
+                List<SchoolProductSerial> updSchoolProductSerialList = new List<SchoolProductSerial>(); //更新學校產品序號用
+                foreach (SchoolProductSerial serialRow in serial)
+                {
+                    deviceBoundArray = new List<deviceBoundExt>();
+                    coreUuid = coreUuidList
+                           .Where((deviceFromCoreService x) => x.sn == serialRow.serial)
+                           .ToList();
+                    foreach (deviceFromCoreService deviceRow in coreUuid)
+                    {
+                        if (!string.IsNullOrWhiteSpace(deviceRow.uuid1) || !string.IsNullOrWhiteSpace(deviceRow.uuid2) || !string.IsNullOrWhiteSpace(deviceRow.device_id)) //uuid1、uuid2、device_id 任一欄有值
+                        {
+                            //前端顯示用
+                            deviceBoundRow = uuidList.Where(u => u.sn == deviceRow.sn && u.uuid1 == deviceRow.uuid1 && u.uuid2 == deviceRow.uuid2).FirstOrDefault();
+                            deviceBoundExt = new deviceBoundExt
+                            {
+                                uuid = deviceBoundRow.uuid1,
+                                uuid2 = deviceBoundRow.uuid2,
+                                classId = deviceBoundRow.class_id,
+                                deviceId = deviceRow.device_id,
+                                os = deviceRow.os,
+                                ip = deviceRow.local_ip,
+                                cpu = deviceRow.cpu,
+                                pcname = deviceRow.pc_name,
+                                osver = deviceRow.os_ver
+                            };
+                            deviceBoundArray.Add(deviceBoundExt);                         
+                        }
+                    }
+                    if (deviceBoundArray.Count.Equals(0)) //無法取得CS的硬體資訊,則用序號的硬體資訊帶入
+                    {
+                        if (serialRow.deviceBound != null)
+                        {
+                            foreach (deviceBound serialRowDeviceBound in serialRow.deviceBound)
+                            {
+                                if (!string.IsNullOrEmpty(serialRowDeviceBound.uuid) || !string.IsNullOrEmpty(serialRowDeviceBound.uuid2))
+                                {
+                                    deviceBoundExt = new deviceBoundExt
+                                    {
+                                        uuid = serialRowDeviceBound.uuid,
+                                        uuid2 = serialRowDeviceBound.uuid2,
+                                        classId = serialRowDeviceBound.classId,
+                                        deviceId = serialRowDeviceBound.deviceId
+                                    };
+                                    deviceBoundArray.Add(deviceBoundExt);
+                                }
+                            }
+                        }
+                    }
+                    //序號更新
+                   //updSchoolProductSerialList.Add(serialRow);
+                   counts.AddRange(deviceBoundArray);
+                    //await db.ReplaceItemAsync<SchoolProductSerial>(serialRow, serialRow.id, new PartitionKey($"Product-{school_code}"));
+                }                    
+                //取得CC授權使用狀態
+                var hashs = await r8.HashGetAllAsync($"CC:License:{school_code.GetString()}");
+                var ccuser = hashs.Select(x => JsonDocument.Parse(x.Value.ToString())).ToList();
+
+                //更新學校產品序號
+                //_ = UpdupdSchoolProductSerialListAsync(updSchoolProductSerialList, school_code.GetString());
+                double Teachs = counts.Count + ccuser.Count;
+                return Ok(new { Teachs });
+            }
+            catch (Exception ex)
+            {
+                return BadRequest();
+            }
+        }
+
         //集體變更學校序號產品 (效能增進對策)
         private async Task UpdupdSchoolProductSerialListAsync(List<SchoolProductSerial> serialList, string schoolCode)
         {