CrazyIter_Bin há 1 ano atrás
pai
commit
a78c44d39a

+ 12 - 0
TEAMModelOS.FunctionV4/ServiceBus/ActiveTaskTopic.cs

@@ -1641,6 +1641,8 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
 
                                 lessonRecord.show = teacher.lessonShow;
                                 lessonRecord.upload = 0;
+
+
                                 if (!string.IsNullOrEmpty(lessonRecord.courseId))
                                 {
                                     CourseBase course = null;
@@ -1687,6 +1689,7 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
                                         lessonRecord.subjectId = course.subject?.id;
                                     }
                                 }
+                              
                                 //处理课堂选用的名单
                                 if (lessonRecord.groupIds.IsNotEmpty())
                                 {
@@ -1711,6 +1714,13 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
                                 {
                                     if (scope.Equals("school")) {
                                         School schoolBase = await client.GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
+
+                                        {
+                                            await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate
+                                            { client="hiteach", count=1, id=schoolBase.id, key="lesson-create", name=schoolBase.name, scope="school", target=schoolBase.id });
+                                            await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate
+                                            { client="hiteach", count=1, id=lessonRecord.tmdid, key="lesson-create", name="课例", scope="teacher", target=lessonRecord.tmdid });
+                                        }
                                         var space = await BlobService.GetSurplusSpace(school, scope, $"{Environment.GetEnvironmentVariable("Option:Location")}", _azureCosmos, _azureRedis, _azureStorage, _dingDing, _httpTrigger);
                                         SchoolSetting setting = null;
                                         Azure.Response schoolSetting = await client.GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemStreamAsync(school, new PartitionKey("SchoolSetting"));
@@ -2054,6 +2064,8 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
                                         {
                                             //=-1 则表示不限制上传数量
                                         }
+                                        await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate
+                                        { client="hiteach", count=1, id=lessonRecord.tmdid, key="lesson-create", name="课例", scope="teacher", target=lessonRecord.tmdid });
                                     }
                                 }
                                 catch (Exception e)

+ 3 - 5
TEAMModelOS.SDK/Models/Service/SystemService.cs

@@ -34,15 +34,13 @@ namespace TEAMModelOS.SDK.Models.Service
                 !string.IsNullOrWhiteSpace(id) && !string.IsNullOrWhiteSpace(name) && 
                 !string.IsNullOrWhiteSpace(scope)&& !string.IsNullOrWhiteSpace(client)) {
                 //处理UTC时差
-                 var nowTime = DateTimeOffset.UtcNow.GetGMTTime();
+                var nowTime = DateTimeOffset.UtcNow.GetGMTTime();
+                int difference = (DayOfWeek.Sunday - nowTime.DayOfWeek + 7) % 7; //1-7的结果0-6
                 var day = nowTime.ToString("yyyyMMdd");
-                ///一周的第一天
-                if (nowTime.DayOfWeek.Equals(DayOfWeek.Monday))
-                {
-                }
                 string redisKey = $"Accumulate:Daily:{scope}:{key}:{day}";
                 string member = $"{target}::{id}::{client}::{name}";
                 await azureRedis.GetRedisClient(8).SortedSetIncrementAsync(redisKey, member, count);
+                await azureRedis.GetRedisClient(8).KeyExpireAsync(redisKey,new TimeSpan((difference+1)*24, 10,0));
                 //if (key.Equals("lesson")  || key.StartsWith("login_"))
                 //{
                 //    redisKey = $"Accumulate:Daily:ies:{key}:{day}";

+ 1 - 0
TEAMModelOS/Controllers/Both/LessonRecordController.cs

@@ -450,6 +450,7 @@ namespace TEAMModelOS.Controllers
                     }
                 }
             }
+            count = records.Count;
             return Ok(new { count=count, records });
         }
         /// <summary>

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

@@ -241,7 +241,7 @@ namespace TEAMModelOS.Controllers.Client
                 auth_token = JwtAuthExtension.CreateAuthToken(_option.HostName, id_token.Payload.Sub, $"{name}",$"{picture}", _option.JwtSecretKey, Website: "IES", scope: Constant.ScopeTeacher, schoolID: join.school, areaId: school.areaId, standard: school.standard, roles: schoolTeacher.roles.ToArray(), permissions:schoolTeacher.permissions.ToArray(), expire: 1);
 
             }
-            await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate { client="hita", count=1, id=school.id, key="teacher_login", name="醍摩豆账号登录", scope="school", target=school.id });
+            await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate { client="hita", count=1, id=school.id, key="teacher_login", name=school.name, scope="school", target=school.id });
             return Ok(new { periodSubjects,auth_token });
         }
 

+ 2 - 0
TEAMModelOS/Controllers/Common/HomeworkController.cs

@@ -31,6 +31,7 @@ using DocumentFormat.OpenXml.Office2010.Excel;
 using TEAMModelOS.SDK.Services;
 using TEAMModelOS.SDK.Models.Service.BI;
 using OpenXmlPowerTools;
+using TEAMModelOS.SDK.Models.Service;
 
 namespace TEAMModelOS.Controllers.Learn
 {
@@ -834,6 +835,7 @@ namespace TEAMModelOS.Controllers.Learn
                                 if (!content.IsNotEmpty() && _hasPrime.ValueKind.Equals(JsonValueKind.True)) {
                                     await StatisticsService.SendServiceBus(($"{standard}", new List<string> { $"{userid}" }, $"{school}", new List<string>() { StatisticsService.OfflineRecord }, 0), _configuration, _serviceBus, client);
                                 }
+                                await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate { client="web", count=1, id=homework.id, key="homework-submit", name=homework.name, scope="teacher", target=homework.creatorId });
                             }
                             return Ok(new { msgid, taskStatus });
                         }

+ 4 - 0
TEAMModelOS/Controllers/Student/StudentController.cs

@@ -571,6 +571,7 @@ namespace TEAMModelOS.Controllers
                     {
                         (string auth_token, string blob_uri, string blob_sas, object classinfo, List<object> courses, AuthenticationResult token) = await StudentCheck(school,$"{id}", $"{classId}", $"{school_code}", $"{picture}", $"{name}", schoolClient, teacherClient,  school.areaId,ip, client, student);
                         int countAuthorized = await GetStudentAuthNumByScale($"{school_code}", school);
+                        await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate { client="web", count=1, id=school.id, key="student_login", name=school.name, scope="school", target=school.id });
                         return Ok(new {school.scale, countAuthorized, location = _option.Location, error = 0, auth_token, blob_uri, blob_sas, classinfo, courses, token = new { access_token = token.AccessToken, expires_in = token.ExpiresOn, id_token = auth_token, token_type = token.TokenType } });
                     }
                     else
@@ -826,6 +827,7 @@ namespace TEAMModelOS.Controllers
                     //Login流程回傳值
                     (string auth_token, string blob_uri, string blob_sas, object classinfo, List<object> courses, AuthenticationResult token) = await StudentCheck(school, $"{stuinfo.id}", $"{stuinfo.classId}", $"{schShortCode}", $"{stuinfo.picture}", $"{stuinfo.name}", schoolClient, teacherClient, school.areaId, ip, client, stuinfo);
                     int countAuthorized = await GetStudentAuthNumByScale($"{school.id}", school);
+                    await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate { client="web", count=1, id=school.id, key="student_login", name=school.name, scope="school", target=school.id });
                     return Ok(new { school.scale, countAuthorized, location = _option.Location, error = 0, auth_token, blob_uri, blob_sas, classinfo, courses, token = new { access_token = token.AccessToken, expires_in = token.ExpiresOn, id_token = auth_token, token_type = token.TokenType } });
                 }
                 //分歧2 無此學生 => 取得該校同名學生資訊
@@ -960,6 +962,7 @@ namespace TEAMModelOS.Controllers
                         stuResultRow.gradeName = (!string.IsNullOrWhiteSpace(gradeInfo.name)) ? gradeInfo.name : string.Empty;
                         stuResult.Add(stuResultRow);
                     }
+                    await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate { client="web", count=1, id=school.id, key="student_login", name=school.name, scope="school", target=school.id });
                     //回傳值
                     return Ok(new { openToken = encOpenToken, school = schResult, students = stuResult } );
                 }
@@ -1301,6 +1304,7 @@ namespace TEAMModelOS.Controllers
                         //其他訊息
                         dynamic school = new ExpandoObject();
                         //回傳
+                        await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate { client="web", count=1, id=schoolInfo.id, key="student_login", name=schoolInfo.name , scope="school", target=schoolInfo.id });
                         return Ok(new { error = 0, auth_token, classinfo, user });
                     }
                     else

+ 1 - 0
TEAMModelOS/Controllers/Student/TmdUserController.cs

@@ -174,6 +174,7 @@ namespace TEAMModelOS.Controllers
                 var (blob_uri, blob_sas) = _azureStorage.GetBlobContainerSAS(id, BlobContainerSasPermissions.Write | BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List);
                 blob_uri = blob_uri.Replace(id, "");
                 blob_sas = "";
+                await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate { client="web", count=1, id="ies", key="tmdstudent_login", name="醍摩豆账号登录", scope="ies", target="ies" });
                 return Ok(new { location = _option.Location, auth_token, schools, defaultschool, blob_uri, blob_sas, status = 200 });
 
             }

+ 3 - 1
TEAMModelOS/Controllers/System/CoreController.cs

@@ -727,7 +727,9 @@ namespace TEAMModelOS.Controllers
             } 
             string region = await _searcher.SearchIpAsync(ip);
             TimeZoneInfo localTimezone = TimeZoneInfo.Local; // 获取本地时区信息
-            return Ok(new { os, version, description, nowtime, region, ip, localTimezone , Hours = localTimezone.BaseUtcOffset.Hours, ticks=localTimezone.BaseUtcOffset.Ticks, utcNowoff =  DateTimeOffset.UtcNow, nowoff = DateTimeOffset.Now,utcNow =DateTime.UtcNow,now =DateTime.Now });
+            var nowTime = DateTimeOffset.UtcNow.GetGMTTime();
+            int difference = (DayOfWeek.Sunday - nowTime.DayOfWeek + 7) % 7;
+            return Ok(new { difference,os, version, description, nowtime, region, ip, localTimezone , Hours = localTimezone.BaseUtcOffset.Hours, ticks=localTimezone.BaseUtcOffset.Ticks, utcNowoff =  DateTimeOffset.UtcNow, nowoff = DateTimeOffset.Now,utcNow =DateTime.UtcNow,now =DateTime.Now });
         }
         /// <summary>
         /// 等待P1V3,啟動Dcoker,支持EMF GDI+

+ 3 - 3
TEAMModelOS/Controllers/Teacher/InitController.cs

@@ -537,7 +537,7 @@ namespace TEAMModelOS.Controllers
                 string lang = !string.IsNullOrWhiteSpace(teacherInfo.teacher.lang) ? teacherInfo.teacher.lang : head_lang;
                 //返回剩余空间
                 (long usedSize, long teach, long total, long surplus, Dictionary<string, double?> catalog) space =
-                    await BlobService.GetSurplusSpace(teacherInfo.teacher.id, "private", _option.Location, _azureCosmos, _azureRedis, _azureStorage, _dingDing, _httpTrigger);
+                await BlobService.GetSurplusSpace(teacherInfo.teacher.id, "private", _option.Location, _azureCosmos, _azureRedis, _azureStorage, _dingDing, _httpTrigger);
                 await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate {  client="web", count=1, id="ies", key="tmd_login", name="醍摩豆账号登录", scope="ies", target="ies"});
                 if (string.IsNullOrWhiteSpace(lang))
                 {
@@ -960,8 +960,8 @@ namespace TEAMModelOS.Controllers
                 }
                 //返回剩余空间
                 (long usedSize, long teach, long total, long surplus, Dictionary<string, double?> catalog) space =
-                    await BlobService.GetSurplusSpace(school_base.id, "school", _option.Location, _azureCosmos, _azureRedis, _azureStorage, _dingDing, _httpTrigger);
-                await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate { client="web", count=1, id=school_code, key="teacher_login", name="醍摩豆账号登录", scope="school", target=school_code});
+                await BlobService.GetSurplusSpace(school_base.id, "school", _option.Location, _azureCosmos, _azureRedis, _azureStorage, _dingDing, _httpTrigger);
+                await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate { client="web", count=1, id=school_code, key="teacher_login", name=school_base.name, scope="school", target=school_code});
                 return Ok(new
                 {
                     privateShows = shows?.FindAll(x => x.Scope.Equals("private")).Select(x => new { x.Type, x.Status, x.Scope, x.Code }),