CrazyIter_Bin 3 years ago
parent
commit
b14163b09b

+ 1 - 0
TEAMModelOS.FunctionV4/CosmosDB/TriggerCorrect.cs

@@ -25,6 +25,7 @@ namespace TEAMModelOS.FunctionV4
         {
             if ((tdata.status != null && tdata.status.Value == 404))
             {
+                await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(tdata.id, new PartitionKey(tdata.code));
                 ActivityList data = input.ToObject<ActivityList>();
                 await ActivityService.DeleteActivity(_coreAPIHttpService, client, _dingDing, data);
                 return;

+ 1 - 0
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -28,6 +28,7 @@ namespace TEAMModelOS.FunctionV4
             {
                 if ((data.status != null && data.status.Value == 404))
                 {
+                    await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync( data.id, new PartitionKey( data.code));
                     ActivityList activity = input.ToObject<ActivityList>();
                     await ActivityService.DeleteActivity(_coreAPIHttpService, client, _dingDing, activity);
                     return;

+ 1 - 0
TEAMModelOS.FunctionV4/CosmosDB/TriggerExamLite.cs

@@ -27,6 +27,7 @@ namespace TEAMModelOS.FunctionV4
             {
                 if ((tdata.status != null && tdata.status.Value == 404))
                 {
+                    await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(tdata.id, new PartitionKey(tdata.code));
                     ActivityList data = input.ToObject<ActivityList>();
                     await ActivityService.DeleteActivity(_coreAPIHttpService, client, _dingDing, data);
                     return;

+ 2 - 0
TEAMModelOS.FunctionV4/CosmosDB/TriggerHomework.cs

@@ -27,8 +27,10 @@ namespace TEAMModelOS.FunctionV4
             {
                 if ((tdata.status != null && tdata.status.Value == 404) )
                 {
+                    await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(tdata.id, new PartitionKey(tdata.code));
                     ActivityList data = input.ToObject<ActivityList>();
                     await ActivityService.DeleteActivity(_coreAPIHttpService, client, _dingDing, data);
+                   
                     return;
                 }
                 var adid = tdata.id;

+ 2 - 0
TEAMModelOS.FunctionV4/CosmosDB/TriggerStudy.cs

@@ -27,8 +27,10 @@ namespace TEAMModelOS.FunctionV4
             {
                 if ((tdata.status != null && tdata.status.Value == 404)  || tdata.publish == 1)
                 {
+                    await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(tdata.id, new PartitionKey(tdata.code));
                     ActivityList data = input.ToObject<ActivityList>();
                     await ActivityService.DeleteActivity(_coreAPIHttpService, client, _dingDing, data);
+                    
                     return;
                 }
                 var adid = tdata.id;

+ 2 - 0
TEAMModelOS.FunctionV4/CosmosDB/TriggerSurvey.cs

@@ -33,10 +33,12 @@ namespace TEAMModelOS.FunctionV4
             {
                 if ((tdata.status != null && tdata.status.Value == 404) )
                 {
+                    await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(tdata.id, new PartitionKey(tdata.code));
                     ActivityList data = input.ToObject<ActivityList>();
                     await ActivityService.DeleteActivity(_coreAPIHttpService, client, _dingDing, data);
                     _azureRedis.GetRedisClient(8).KeyDelete($"Survey:Record:{tdata.id}");
                     _azureRedis.GetRedisClient(8).KeyDelete($"Survey:Submit:{tdata.id}");
+
                     return;
                 }
                 var adid = tdata.id;

+ 1 - 0
TEAMModelOS.FunctionV4/CosmosDB/TriggerVote.cs

@@ -30,6 +30,7 @@ namespace TEAMModelOS.FunctionV4
             {
                 if ((tdata.status != null && tdata.status.Value == 404) )
                 {
+                    await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(tdata.id, new PartitionKey(tdata.code));
                     ActivityList data = input.ToObject<ActivityList>();
                     await ActivityService. DeleteActivity(_coreAPIHttpService, client, _dingDing, data);
                     _azureRedis.GetRedisClient(8).KeyDelete($"Vote:Record:{tdata.id}");

+ 3 - 3
TEAMModelOS/Controllers/Common/ExamLiteController.cs

@@ -201,7 +201,7 @@ namespace TEAMModelOS.Controllers.Common
             {
                 if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
-                var query = $"select c.id,c.name,c.createTime from c ";
+                var query = $"select c.id,c.name,c.createTime from c where (c.status<>-1 or IS_DEFINED(c.status) = false )   ";
                 string continuationToken = string.Empty;
                 string token = default;
                 //是否需要进行分页查询,默认不分页
@@ -297,7 +297,7 @@ namespace TEAMModelOS.Controllers.Common
                 if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
                 if (!requert.TryGetProperty("tId", out JsonElement tId)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
-                var query = $"select c.id,c.name,c.createTime,A0.time from c join A0 in c.teachers where A0.id = '{tId}'";
+                var query = $"select c.id,c.name,c.createTime,A0.time from c join A0 in c.teachers where (c.status<>-1 or IS_DEFINED(c.status) = false ) and  A0.id = '{tId}'";
                 List<object> exams = new();
                 await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamLite-{code}") }))
                 {
@@ -334,7 +334,7 @@ namespace TEAMModelOS.Controllers.Common
                 if (!requert.TryGetProperty("tId", out JsonElement tId)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
                 List<object> exams = new();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c join A0 in c.teachers where A0.id = '{tId}' and c.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamLite-{code}") }))
+                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c join A0 in c.teachers where (c.status<>-1 or IS_DEFINED(c.status) = false ) and  A0.id = '{tId}' and c.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamLite-{code}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)

+ 1 - 1
TEAMModelOS/Controllers/Common/HomeworkController.cs

@@ -269,7 +269,7 @@ namespace TEAMModelOS.Controllers.Learn
                     }
                 };
                 List<Homework> homeworks = new List<Homework>();
-                var query = $"select c.owner, c.id,c.name,c.code,c.startTime,c.endTime,c.progress,c.classes,c.scope,c.school from c where  c.createTime >= {stimestamp} and c.createTime <= {etimestamp}  {progresssql } and c.ttl=-1 ";
+                var query = $"select c.owner, c.id,c.name,c.code,c.startTime,c.endTime,c.progress,c.classes,c.scope,c.school from c where (c.status<>-1 or IS_DEFINED(c.status) = false ) and   c.createTime >= {stimestamp} and c.createTime <= {etimestamp}  {progresssql } and c.ttl=-1 ";
                 if (string.IsNullOrEmpty(school))
                 {
                     query = $"{query} and c.scope='private' ";

+ 3 - 3
TEAMModelOS/Controllers/Common/StudyController.cs

@@ -384,7 +384,7 @@ namespace TEAMModelOS.Controllers.Common
             {
                 if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
-                var query = $"select c.id,c.img,c.name,c.type,c.startTime,c.endTime,c.presenter,c.topic,c.address,c.owner,c.progress from c ";
+                var query = $"select c.id,c.img,c.name,c.type,c.startTime,c.endTime,c.presenter,c.topic,c.address,c.owner,c.progress from c where (c.status<>-1 or IS_DEFINED(c.status) = false )    ";
                 string continuationToken = string.Empty;
                 string token = default;
                 //是否需要进行分页查询,默认不分页
@@ -531,7 +531,7 @@ namespace TEAMModelOS.Controllers.Common
                 if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
                 if (!requert.TryGetProperty("tId", out JsonElement tId)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
-                var query = $"select c.id,c.img,c.name,c.startTime,c.type,c.endTime,c.presenter,c.topic,c.address,c.owner from c join A0 in c.teachers where A0.id = '{tId}'";
+                var query = $"select c.id,c.img,c.name,c.startTime,c.type,c.endTime,c.presenter,c.topic,c.address,c.owner from c join A0 in c.teachers where (c.status<>-1 or IS_DEFINED(c.status) = false ) and  A0.id = '{tId}'";
                 List<object> studies = new();
                 await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Study-{code}") }))
                 {
@@ -568,7 +568,7 @@ namespace TEAMModelOS.Controllers.Common
                 if (!requert.TryGetProperty("tId", out JsonElement tId)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
                 List<object> studies = new();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c join A0 in c.teachers where A0.id = '{tId}' and c.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Study-{code}") }))
+                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c join A0 in c.teachers where (c.status<>-1 or IS_DEFINED(c.status) = false ) and  A0.id = '{tId}' and c.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Study-{code}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)

+ 1 - 1
TEAMModelOS/Controllers/Common/SurveyController.cs

@@ -258,7 +258,7 @@ namespace TEAMModelOS.Controllers
                 }; 
                 List<Survey> surveys = new List<Survey>();
                 var client = _azureCosmos.GetCosmosClient();
-                var query = $"select c.owner, c.id,c.name,c.code,c.startTime,c.endTime,c.progress,c.classes,c.scope,c.school from c where  c.ttl=-1  {stimestamp}  {etimestamp}  {progresssql }   ";
+                var query = $"select c.owner, c.id,c.name,c.code,c.startTime,c.endTime,c.progress,c.classes,c.scope,c.school from c where (c.status<>-1 or IS_DEFINED(c.status) = false ) and   c.ttl=-1  {stimestamp}  {etimestamp}  {progresssql }   ";
                 if (string.IsNullOrEmpty(school)) {
                     query = $"{query} and c.scope='private' ";
                 }

+ 1 - 1
TEAMModelOS/Controllers/Common/VoteController.cs

@@ -248,7 +248,7 @@ namespace TEAMModelOS.Controllers
                 };
                 List<Vote> votes = new List<Vote>();
                 var client = _azureCosmos.GetCosmosClient();
-                var query = $"select c.owner,c.id,c.name,c.code,c.startTime,c.endTime,c.progress ,c.scope,c.school from c where c.ttl=-1 {stimestamp} {etimestamp}  {progresssql }   ";
+                var query = $"select c.owner,c.id,c.name,c.code,c.startTime,c.endTime,c.progress ,c.scope,c.school from c where (c.status<>-1 or IS_DEFINED(c.status) = false ) and  c.ttl=-1 {stimestamp} {etimestamp}  {progresssql }   ";
                 if (string.IsNullOrEmpty(school))
                 {
                     query = $"{query} and c.scope='private' ";

+ 4 - 4
TEAMModelOS/Controllers/Common/WorkController.cs

@@ -200,7 +200,7 @@ namespace TEAMModelOS.Controllers.Common
             {
                 if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
-                var query = $"select c.id,c.name,c.createTime from c ";
+                var query = $"select c.id,c.name,c.createTime from c where (c.status<>-1 or IS_DEFINED(c.status) = false ) ";
                 string continuationToken = string.Empty;
                 string token = default;
                 //是否需要进行分页查询,默认不分页
@@ -261,7 +261,7 @@ namespace TEAMModelOS.Controllers.Common
                 if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
                 List<Homework> works = new();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<Homework>(queryText: $"select value(c) from c where c.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Homework-{code}") }))
+                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<Homework>(queryText: $"select value(c) from c where (c.status<>-1 or IS_DEFINED(c.status) = false ) and  c.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Homework-{code}") }))
                 {
                     works.Add(item);
                 }
@@ -289,7 +289,7 @@ namespace TEAMModelOS.Controllers.Common
                 if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
                 if (!requert.TryGetProperty("tId", out JsonElement tId)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
-                var query = $"select c.id,c.name,c.createTime,A0.time from c join A0 in c.teachers where A0.id = '{tId}'";
+                var query = $"select c.id,c.name,c.createTime,A0.time from c join A0 in c.teachers where (c.status<>-1 or IS_DEFINED(c.status) = false ) and  A0.id = '{tId}'";
                 List<object> works = new();
                 await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Homework-{code}") }))
                 {
@@ -326,7 +326,7 @@ namespace TEAMModelOS.Controllers.Common
                 if (!requert.TryGetProperty("tId", out JsonElement tId)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
                 List<object> works = new();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c join A0 in c.teachers where A0.id = '{tId}' and c.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Homework-{code}") }))
+                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c join A0 in c.teachers  where (c.status<>-1 or IS_DEFINED(c.status) = false ) and  A0.id = '{tId}' and c.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Homework-{code}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)