CrazyIter_Bin 11 月之前
父節點
當前提交
3ddd04fd73

File diff suppressed because it is too large
+ 551 - 551
TEAMModelOS.FunctionV4/HttpTrigger/BIHttpTrigger.cs


+ 1 - 35
TEAMModelOS.FunctionV4/HttpTrigger/IESHttpTrigger.cs

@@ -74,41 +74,7 @@ namespace TEAMModelOS.FunctionV4
             _option = option?.Value;
             _configuration = configuration;
         }
-        // <summary>
-        /// </summary>
-        /// <param name="req"></param>
-        /// <param name="log"></param>
-        /// <returns></returns>
-        [Function("http-log")]
-        public async Task<HttpResponseData> HttpLog([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestData req) {
-            var response = req.CreateResponse(HttpStatusCode.OK);
-            try {
-                string data;
-                using (var reader = new StreamReader(req.Body))
-                {
-                    data = await reader.ReadToEndAsync();
-                }
-                var gmt8Time = DateTimeOffset.UtcNow.GetGMTTime(8);
-                var appendBlob = _azureStorage.GetBlobContainerClient("0-service-log").GetAppendBlobClient($"http-log/{gmt8Time:yyyy}/{gmt8Time:MM}/{gmt8Time:dd}/{gmt8Time:HH}.log");
-                if (!await appendBlob.ExistsAsync())
-                {
-                    await appendBlob.CreateAsync();
-                }
-                using (var stream = new MemoryStream(Encoding.UTF8.GetBytes($"{data},\n")))
-                {
-                    await appendBlob.AppendBlockAsync(stream);
-                }
-                await response.WriteAsJsonAsync(new { code = 1 });
-                return response;  
-
-            } catch(Exception ex ) {
-                await _dingDing.SendBotMsg($"{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
-                await response.WriteAsJsonAsync(new { code = 1 });
-                return response;
-            }
-           
-        }
-
+       
          /// <summary>
          /// </summary>
          /// <param name="req"></param>

+ 10 - 10
TEAMModelOS.SDK/Models/Service/Common/TeacherService.cs

@@ -184,11 +184,11 @@ namespace TEAMModelOS.Services
             //換取AuthToken,提供給前端
 
             //用户在线记录
-            try
-            {
-                _ = _httpTrigger.RequestHttpTrigger(new { school = defaultschool, scope = $"{Constant.ScopeTeacher}", id = $"{id}", ip = $"{ip}", expire = 1 }, _option.Location, "online-record");
-            }
-            catch { }
+            //try
+            //{
+            //    _ = _httpTrigger.RequestHttpTrigger(new { school = defaultschool, scope = $"{Constant.ScopeTeacher}", id = $"{id}", ip = $"{ip}", expire = 1 }, _option.Location, "online-record");
+            //}
+            //catch { }
 
             //換取AuthToken,提供給前端
             var auth_token = JwtAuthExtension.CreateAuthToken(_option.HostName, id, name?.ToString(), picture?.ToString(), _option.JwtSecretKey, Website: "IES", timezone: timezone, scope: Constant.ScopeTeacher, standard:  "", roles: roles.ToArray(), expire: 1);
@@ -496,11 +496,11 @@ namespace TEAMModelOS.Services
             var auth_token = JwtAuthExtension.CreateAuthToken(_option.HostName, id, name?.ToString(), picture?.ToString(), _option.JwtSecretKey, Website: "IES", timezone: timezone, scope: Constant.ScopeTeacher, standard: areaa != null ? areaa.standard : "", roles: roles.ToArray(), expire: 1);
 
             //用户在线记录
-            try
-            {
-                _ = _httpTrigger.RequestHttpTrigger(new { school = defaultschool, scope = $"{Constant.ScopeTeacher}", id = $"{id}", ip = $"{ip}", expire = 1 }, _option.Location, "online-record");
-            }
-            catch { }
+            //try
+            //{
+            //    _ = _httpTrigger.RequestHttpTrigger(new { school = defaultschool, scope = $"{Constant.ScopeTeacher}", id = $"{id}", ip = $"{ip}", expire = 1 }, _option.Location, "online-record");
+            //}
+            //catch { }
 
 
             //取得Teacher Blob 容器位置及SAS 

+ 5 - 5
TEAMModelOS/Controllers/Client/HiScanController.cs

@@ -122,11 +122,11 @@ namespace TEAMModelOS.Controllers.Core
                 }
 
                 //用户在线记录
-                try
-                {
-                    _ = _httpTrigger.RequestHttpTrigger(new { school = response.defaultSchool, scope = Constant.ScopeTeacher, id = $"{id}", ip = ip, expire = 1 }, _option.Location, "online-record");
-                }
-                catch { }
+                //try
+                //{
+                //    _ = _httpTrigger.RequestHttpTrigger(new { school = response.defaultSchool, scope = Constant.ScopeTeacher, id = $"{id}", ip = ip, expire = 1 }, _option.Location, "online-record");
+                //}
+                //catch { }
 
                 var (tblob_uri, tblob_sas) = _azureStorage.GetBlobContainerSAS($"{id}", BlobContainerSasPermissions.Write | BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List | BlobContainerSasPermissions.Delete);
                 return Ok(new { schools, teacher = new { name, picture, id, bloburl = tblob_uri, blobsas = tblob_sas } });

+ 5 - 5
TEAMModelOS/Controllers/Client/HiTAControlller.cs

@@ -630,11 +630,11 @@ namespace TEAMModelOS.Controllers.Client
                     //}
 
                     //用户在线记录
-                    try
-                    {
-                        _ = _httpTrigger.RequestHttpTrigger(new { school = defaultschool, scope = $"{Constant.ScopeTeacher}", id = $"{id}", ip = $"{ip}", expire = 1 }, _option.Location, "online-record");
-                    }
-                    catch { }
+                    //try
+                    //{
+                    //    _ = _httpTrigger.RequestHttpTrigger(new { school = defaultschool, scope = $"{Constant.ScopeTeacher}", id = $"{id}", ip = $"{ip}", expire = 1 }, _option.Location, "online-record");
+                    //}
+                   // catch { }
                     await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate { client="hita", count=1, id="ies", key="tmd_login", name="醍摩豆账号登录", scope="ies", target="ies" });
                     return Ok(new { schools, defaultschool, courses, size, resCount, itemCount, paperCount, activityCount });
                 }

+ 10 - 10
TEAMModelOS/Controllers/Client/HiTeachController.cs

@@ -2394,11 +2394,11 @@ namespace TEAMModelOS.Controllers.Client
                     }
                 }
                 //用户在线记录
-                try
-                {
-                    _ = _httpTrigger.RequestHttpTrigger(new { school = defaultschool, scope = $"{Constant.ScopeTeacher}", id = $"{id}", ip = $"{ip}", expire = 1 }, _option.Location, "online-record");
-                }
-                catch { }
+                //try
+                //{
+                //    _ = _httpTrigger.RequestHttpTrigger(new { school = defaultschool, scope = $"{Constant.ScopeTeacher}", id = $"{id}", ip = $"{ip}", expire = 1 }, _option.Location, "online-record");
+                //}
+                //catch { }
 
                 //取得Teacher Blob 容器位置及SAS 
                 var container = _azureStorage.GetBlobContainerClient(id);
@@ -2969,11 +2969,11 @@ namespace TEAMModelOS.Controllers.Client
                 }
 
                 //用户在线记录
-                try
-                {
-                    _ = _httpTrigger.RequestHttpTrigger(new { school = school_code.GetString(), scope = $"{Constant.ScopeTeacher}", id = $"{id}", ip = $"{ip}", expire = 1 }, _option.Location, "online-record");
-                }
-                catch { }
+                //try
+                //{
+                //    _ = _httpTrigger.RequestHttpTrigger(new { school = school_code.GetString(), scope = $"{Constant.ScopeTeacher}", id = $"{id}", ip = $"{ip}", expire = 1 }, _option.Location, "online-record");
+                //}
+                //catch { }
 
                 //取得School Blob 容器位置及SAS
                 string school_code_blob = school_code.GetString().ToLower();

+ 10 - 10
TEAMModelOS/Controllers/Student/StudentController.cs

@@ -744,11 +744,11 @@ namespace TEAMModelOS.Controllers
             var auth_token = JwtAuthExtension.CreateAuthToken(_option.HostName, id, name, picture, _option.JwtSecretKey, scope: Constant.ScopeStudent, Website: "IES", timezone: timezone, areaId: areaId, schoolID: school_code, roles: new[] { "student" }, expire: 4,year: student.year);
 
             //用户在线记录
-            try
-            {
-                _ = _httpTrigger.RequestHttpTrigger(new { school = school_code, scope = $"{Constant.ScopeStudent}", id = $"{id}", ip = $"{ip}", expire = 1 }, _option.Location, "online-record");
-            }
-            catch {}
+            //try
+            //{
+            //    _ = _httpTrigger.RequestHttpTrigger(new { school = school_code, scope = $"{Constant.ScopeStudent}", id = $"{id}", ip = $"{ip}", expire = 1 }, _option.Location, "online-record");
+            //}
+            //catch {}
 
             await cosmosClient.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<Student>(student, id, new PartitionKey($"Base-{school_code}"));
           
@@ -1337,11 +1337,11 @@ namespace TEAMModelOS.Controllers
                         var auth_token = JwtAuthExtension.CreateAuthToken(_option.HostName, id.GetString(), name.GetString(), picture.GetString(), _option.JwtSecretKey, Website: "IES", timezone: timezone, areaId: schoolInfo.areaId, scope: Constant.ScopeStudent, schoolID: school_code.GetString(), roles: new[] { "student" }, expire: 4);
                         
                         //用户在线记录
-                        try
-                        {
-                            _ = _httpTrigger.RequestHttpTrigger(new { school = school_code.GetString(), scope = $"{Constant.ScopeStudent}", id = $"{id}", ip = $"{ip}", expire = 1 }, _option.Location, "online-record");
-                        }
-                        catch { }
+                        //try
+                        //{
+                        //    _ = _httpTrigger.RequestHttpTrigger(new { school = school_code.GetString(), scope = $"{Constant.ScopeStudent}", id = $"{id}", ip = $"{ip}", expire = 1 }, _option.Location, "online-record");
+                        //}
+                        //catch { }
 
 
                         //保存学生登录信息

+ 5 - 5
TEAMModelOS/Controllers/Student/TmdUserController.cs

@@ -167,11 +167,11 @@ namespace TEAMModelOS.Controllers
                 var auth_token = JwtAuthExtension.CreateAuthToken(_option.HostName, id, name?.ToString(), picture?.ToString(), _option.JwtSecretKey, Website: "IES", timezone: timezone, scope: Constant.ScopeTmdUser, roles: new[] { "student" }, expire: 1);
 
                 //用户在线记录
-                try
-                {
-                    _ = _httpTrigger.RequestHttpTrigger(new { school = defaultschool, scope = $"{Constant.ScopeTmdUser}", id = $"{id}", ip = $"{ip}", expire = 1 }, _option.Location, "online-record");
-                }
-                catch { }
+                //try
+                //{
+                //    _ = _httpTrigger.RequestHttpTrigger(new { school = defaultschool, scope = $"{Constant.ScopeTmdUser}", id = $"{id}", ip = $"{ip}", expire = 1 }, _option.Location, "online-record");
+                //}
+                //catch { }
 
                 if (!string.IsNullOrEmpty(defaultschool))
                 {