CrazyIter_Bin преди 1 година
родител
ревизия
eb3f997b75

+ 3 - 3
TEAMModelBI/TEAMModelBI.csproj

@@ -65,9 +65,9 @@
 		<SpaRoot>ClientApp\</SpaRoot>
 		<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
 		<UserSecretsId>078b5d89-7d90-4f6a-88fc-7d96025990a8</UserSecretsId>
-		<Version>5.2310.18</Version>
-		<AssemblyVersion>5.2310.18.1</AssemblyVersion>
-		<FileVersion>5.2310.18.1</FileVersion>
+		<Version>5.2310.25</Version>
+		<AssemblyVersion>5.2310.25.1</AssemblyVersion>
+		<FileVersion>5.2310.25.1</FileVersion>
 		<Description>TEAMModelBI(BI)</Description>
 		<PackageReleaseNotes>BI版本说明版本切换标记2022000908</PackageReleaseNotes>
 		<PackageId>TEAMModelBI</PackageId>

+ 3 - 3
TEAMModelOS.FunctionV4/TEAMModelOS.FunctionV4.csproj

@@ -5,9 +5,9 @@
 		<OutputType>Exe</OutputType>
 		<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
 		<SignAssembly>true</SignAssembly>
-		<Version>5.2310.18</Version>
-		<AssemblyVersion>5.2310.18.1</AssemblyVersion>
-		<FileVersion>5.2310.18.1</FileVersion>
+		<Version>5.2310.25</Version>
+		<AssemblyVersion>5.2310.25.1</AssemblyVersion>
+		<FileVersion>5.2310.25.1</FileVersion>
 		<PackageId>TEAMModelOS.FunctionV4</PackageId>
 		<Authors>teammodel</Authors>
 		<Company>醍摩豆(成都)信息技术有限公司</Company>

+ 34 - 7
TEAMModelOS.SDK/Models/Cosmos/Common/Activity.cs

@@ -67,10 +67,7 @@ namespace TEAMModelOS.SDK.Models
         [Required(ErrorMessage = "模块不能为空")]
         [MinLength(1, ErrorMessage = "模块不能为空")]
         public List<string> modules { get; set; } = new List<string>();
-        /// <summary>
-        /// 本次活动的评审专家
-        /// </summary>
-        public List<Expert> experts { get; set; } = new List<Expert>();
+      
         /// <summary>
         /// 所属年份
         /// </summary>
@@ -98,7 +95,7 @@ namespace TEAMModelOS.SDK.Models
             pk="ActivityWebsite";
         }
         /// <summary>
-        /// (路由编码),公开的 teammodel ,区级(standard字段),校级(学校编码),可以修改
+        /// (路由编码),公开的 teammodel ,区级(区级简码),校级(学校编码),不可以修改
         /// </summary>
         [Required(ErrorMessage = "不能为空")]
         public string route { get; set; }
@@ -138,8 +135,7 @@ namespace TEAMModelOS.SDK.Models
         public long expire { get; set; }
     }
 
-    public class ActivityTeacher
-    {
+    public class InviteTeachers {
         public string id { get; set; }
         public string name { get; set; }
         public string picture { get; set; }
@@ -150,6 +146,18 @@ namespace TEAMModelOS.SDK.Models
         /// </summary>
         public int status { get; set; }
     }
+    public class ActivityTeacher : CosmosEntity
+    {
+        /// <summary>
+        /// id  如果活动是邀请制,则id是活动的id 。
+        /// code = ActivityTeacher 以个人身份参加的方式邀请。code = ActivityTeacher-{schoolId} 以学校教师的身份方式被邀请
+        /// </summary>
+        public ActivityTeacher()
+        {
+            pk="ActivityTeacher";
+        }
+       public List<InviteTeachers> inviteTeachers { get; set; } = new List<InviteTeachers>();
+    }
 
     public class ActivityInvitedSchool
     {
@@ -447,15 +455,34 @@ namespace TEAMModelOS.SDK.Models
         public int balance { get; set; }
     }
 
+    /// <summary>
+    /// 本次活动的评审专家
+    /// </summary>
+    
+    public class ActivityExpert : CosmosEntity
+    {
+        public ActivityExpert() {
+            pk="ActivityExpert";
+            code="ActivityExpert";
+        }
+        public List<Expert> experts { get; set; } = new List<Expert>();
+    }
     public class Expert { 
         public string id { get; set; }
         public string name { get; set; }
         public string mobile { get; set; }
         public string picture { get; set; }
         /// <summary>
+        /// 0 未确认,1 已确认  确认状态
+        /// </summary>
+        public int status { get; set; }
+        /// <summary>
         /// 职称
         /// </summary>
         public string title { get; set; }
+        /// <summary>
+        /// 科目
+        /// </summary>
         public List<ExpertSubject> subjects { get; set; } = new List<ExpertSubject>();
         /// <summary>
         /// 评审专家可以对哪些模块进行评审

+ 3 - 3
TEAMModelOS.SDK/TEAMModelOS.SDK.csproj

@@ -2,9 +2,9 @@
 
   <PropertyGroup>
     <TargetFramework>net6.0</TargetFramework>
-    <Version>5.2310.18</Version>
-    <AssemblyVersion>5.2310.18.1</AssemblyVersion>
-    <FileVersion>5.2310.18.1</FileVersion>
+    <Version>5.2310.25</Version>
+    <AssemblyVersion>5.2310.25.1</AssemblyVersion>
+    <FileVersion>5.2310.25.1</FileVersion>
     <PackageReleaseNotes>发版</PackageReleaseNotes>
   </PropertyGroup>
 

+ 215 - 37
TEAMModelOS/Controllers/Common/ActivityController.cs

@@ -22,10 +22,12 @@ using StackExchange.Redis;
 using System.Text.RegularExpressions;
 using Microsoft.AspNetCore.Authorization;
 using OpenXmlPowerTools;
+using System.IdentityModel.Tokens.Jwt;
+using Microsoft.AspNetCore.Routing;
 
 namespace TEAMModelOS.Controllers
 {
- 
+
 
     [ProducesResponseType(StatusCodes.Status200OK)]
     [ProducesResponseType(StatusCodes.Status400BadRequest)]
@@ -50,7 +52,7 @@ namespace TEAMModelOS.Controllers
             _serviceBus = serviceBus;
             _configuration = configuration;
             _azureStorage = azureStorage;
-            _azureRedis = azureRedis; 
+            _azureRedis = azureRedis;
             _coreAPIHttpService = coreAPIHttpService;
         }
 
@@ -64,8 +66,82 @@ namespace TEAMModelOS.Controllers
         [HttpPost("website-manage")]
         [Authorize(Roles = "IES")]
 
-        public async Task<IActionResult> RouteManage(JsonElement request) {
+        public async Task<IActionResult> WebsiteManage(JsonElement request) {
+            (string tmdid, _, _, string school) = HttpContext.GetAuthTokenInfo();
+            if (!request.TryGetProperty("grant_type", out JsonElement grant_type)) return BadRequest();
+            {
+                switch (true)
+                {
+                    case bool when $"{grant_type}".Equals("list", StringComparison.OrdinalIgnoreCase):
+                        {
+                            List<ActivityWebsite> websites = new List<ActivityWebsite>();
+                            if (!request.TryGetProperty("websiteId", out JsonElement _websiteId)) return BadRequest();
+                            if (!request.TryGetProperty("scope", out JsonElement _scope)) return BadRequest();
+                            string websiteId = _websiteId.GetString();
+                            if (websiteId.Equals("02944f32-f534-3397-ea56-e6f1fc6c3714", StringComparison.OrdinalIgnoreCase) )
+                            {
+                                Azure.Response teammodelResponse = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemStreamAsync("teammodel", new PartitionKey("ActivityWebsite"));
+                                if (teammodelResponse.Status == 200)
+                                {
+                                    ActivityWebsite activityWebsite = JsonDocument.Parse(teammodelResponse.Content).RootElement.ToObject<ActivityWebsite>();
+                                    websites.Add(activityWebsite);
+                                }
+                                else {
+                                    ActivityWebsite website = new ActivityWebsite
+                                    {
+                                        id="teammodel",
+                                        pk="ActivityWebsite",
+                                        code="ActivityWebsite",
+                                        route="teammodel",
+                                        scope="public",
+                                    };
+                                    await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).UpsertItemAsync(website, new PartitionKey(website.code));
+                                    websites.Add(website);
+                                }
+                            }
+                            Azure.Response activityWebsiteResponse = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemStreamAsync(websiteId, new PartitionKey("ActivityWebsite"));
+                            if (activityWebsiteResponse.Status == 200)
+                            {
+                                ActivityWebsite activityWebsite = JsonDocument.Parse(activityWebsiteResponse.Content).RootElement.ToObject<ActivityWebsite>();
+                                websites.Add(activityWebsite);
+                            }
+                            else {
+                                string route = string.Empty;
+                                if (_scope.GetString().Equals("area", StringComparison.OrdinalIgnoreCase))
+                                {
+                                    Area area = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<Area>(websiteId, new PartitionKey("Base-Area"));
+                                    if (!string.IsNullOrWhiteSpace(area.shortCode))
+                                    {
+                                        route=area.shortCode;
+                                    }
+                                }
+                                if (_scope.GetString().Equals("school", StringComparison.OrdinalIgnoreCase))
+                                {
+                                    route=websiteId;
+                                }
+                                if (!string.IsNullOrWhiteSpace(route))
+                                {
+                                    ActivityWebsite website = new ActivityWebsite
+                                    {
+                                        id=websiteId,
+                                        pk="ActivityWebsite",
+                                        code="ActivityWebsite",
+                                        route=route,
+                                        scope=_scope.GetString(),
+                                    };
+                                    await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).UpsertItemAsync(website, new PartitionKey(website.code));
+                                    websites.Add(website);
+                                }
+                                else {
+                                    return Ok(new { code = 1, msg = "区级简码未设置" });
+                                }
+                                return Ok(new { code = 200, websites });
+                            }
+                            break;
+                        }
+                }
 
+             }
             return Ok();
         }
 
@@ -79,7 +155,7 @@ namespace TEAMModelOS.Controllers
         [HttpPost("invite-target")]
         [Authorize(Roles = "IES")]
 
-        public async Task<IActionResult> InviteTarget (JsonElement request) 
+        public async Task<IActionResult> InviteTarget(JsonElement request)
         {
             (string tmdid, _, _, string school) = HttpContext.GetAuthTokenInfo();
             if (!request.TryGetProperty("grant_type", out JsonElement grant_type)) return BadRequest();
@@ -87,7 +163,7 @@ namespace TEAMModelOS.Controllers
             {
                 case bool when $"{grant_type}".Equals("schools", StringComparison.OrdinalIgnoreCase):
                     {
-                        
+
                         if (!request.TryGetProperty("scope", out JsonElement _scope)) return BadRequest();
                         string sql = string.Empty;
                         if (_scope.GetString().Equals("public", StringComparison.OrdinalIgnoreCase))
@@ -99,12 +175,12 @@ namespace TEAMModelOS.Controllers
                             sql = $"select c.id,c.name ,c.picture,c.region,c.province,c.city,c.areaId   from c where c.code='Base' and c.areaId='{_areaId}' ";
                         }
                         var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<School>(sql, "Base");
-                        var sc= result.list.FindAll(z => !string.IsNullOrWhiteSpace(z.areaId));
+                        var sc = result.list.FindAll(z => !string.IsNullOrWhiteSpace(z.areaId));
                         if (sc.IsNotEmpty()) {
-                            string areaSql = $"select value c from c where c.id in ({string.Join(",",sc.Select(z=>$"'{z.areaId}'").ToHashSet())})";
-                            var areaResult =  await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).GetList<Area>(sql, "Base-Area");
+                            string areaSql = $"select value c from c where c.id in ({string.Join(",", sc.Select(z => $"'{z.areaId}'").ToHashSet())})";
+                            var areaResult = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).GetList<Area>(sql, "Base-Area");
                             if (areaResult.list.IsNotEmpty()) {
-                                List<dynamic> schools= new List<dynamic>();
+                                List<dynamic> schools = new List<dynamic>();
                                 foreach (var item in result.list) {
                                     if (!string.IsNullOrWhiteSpace(item.areaId))
                                     {
@@ -117,15 +193,15 @@ namespace TEAMModelOS.Controllers
                                 }
                             }
                         }
-                        return Ok(new {code=200, schools = result.list.Select(z=>new { z.id,z.name,z.picture,z.region,z.province,z.city,z.areaId, areaName = string.Empty }) });
+                        return Ok(new { code = 200, schools = result.list.Select(z => new { z.id, z.name, z.picture, z.region, z.province, z.city, z.areaId, areaName = string.Empty }) });
                     }
                 case bool when $"{grant_type}".Equals("teachers", StringComparison.OrdinalIgnoreCase):
                     {
                         if (!string.IsNullOrWhiteSpace(school)) {
                             School schoolbase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
-                            string  sql = $"select c.id,c.name ,c.picture   from c where c.code='Teacher-{school}' ";
+                            string sql = $"select c.id,c.name ,c.picture   from c where c.code='Teacher-{school}' ";
                             var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<SchoolTeacher>(sql, $"Teacher-{school}");
-                            return Ok(new { code = 200, teachers  = result.list.Select(z=>new { z.id,z.name,z.picture,school,schooName = schoolbase.name}) });
+                            return Ok(new { code = 200, teachers = result.list.Select(z => new { z.id, z.name, z.picture, school, schooName = schoolbase.name }) });
                         }
                         break;
                     }
@@ -149,7 +225,7 @@ namespace TEAMModelOS.Controllers
             {
                 (string tmdid, _, _, string school) = HttpContext.GetAuthTokenInfo();
                 if (!request.TryGetProperty("grant_type", out JsonElement grant_type)) return BadRequest();
-               
+
                 var client = _azureCosmos.GetCosmosClient();
                 switch (true)
                 {
@@ -157,7 +233,7 @@ namespace TEAMModelOS.Controllers
                         {
                             if (!request.TryGetProperty("Activity", out JsonElement _activity)) return Ok(new { error = ResponseCode._400ParamsError, msg = "活动信息参数错误" });
                             Activity activity = _activity.ToObject<Activity>();
-                            activity.id=!string.IsNullOrWhiteSpace(activity.id)?activity.id: Guid.NewGuid().ToString();
+                            activity.id=!string.IsNullOrWhiteSpace(activity.id) ? activity.id : Guid.NewGuid().ToString();
                             activity.code="Activity";
                             activity.pk="Activity";
                             //如果是区级活动,enroll报名制,则学校的确认状态默认为1 。
@@ -168,7 +244,41 @@ namespace TEAMModelOS.Controllers
                             //醍摩豆智慧学区
                             if (!activity.owner.Equals("02944f32-f534-3397-ea56-e6f1fc6c3714", StringComparison.OrdinalIgnoreCase)  && activity.scope.Equals("public", StringComparison.OrdinalIgnoreCase))
                             {
-                                 return Ok(new { error = ResponseCode._400ParamsError, msg = "公开的活动只能由醍摩豆智慧学区发布!" });
+                                return Ok(new { error = ResponseCode._400ParamsError, msg = "公开的活动只能由醍摩豆智慧学区发布!" });
+                            }
+                            {
+                                string websiteId = activity.owner;
+                                string route = string.Empty;
+                                if (activity.owner.Equals("02944f32-f534-3397-ea56-e6f1fc6c3714", StringComparison.OrdinalIgnoreCase)  && activity.scope.Equals("public", StringComparison.OrdinalIgnoreCase)) {
+                                    websiteId="teammodel";
+                                    route="teammodel";
+                                }
+
+                                Azure.Response activityWebsiteResponse = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemStreamAsync(websiteId, new PartitionKey("ActivityWebsite"));
+                                if (activityWebsiteResponse.Status!=200) {
+                                    if (activity.scope.Equals("area", StringComparison.OrdinalIgnoreCase)) {
+                                        Area area = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<Area>(activity.owner, new PartitionKey("Base-Area"));
+                                        if (!string.IsNullOrWhiteSpace(area.shortCode)) {
+                                            route=area.shortCode;
+                                        }
+                                    }
+                                    if (activity.scope.Equals("school", StringComparison.OrdinalIgnoreCase))
+                                    {
+                                        route=activity.owner;
+                                    }
+                                    if (!string.IsNullOrWhiteSpace(route))
+                                    {
+                                        ActivityWebsite website = new ActivityWebsite
+                                        {
+                                            id=websiteId,
+                                            pk="ActivityWebsite",
+                                            code="ActivityWebsite",
+                                            route=route,
+                                            scope=activity.scope,
+                                        };
+                                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).UpsertItemAsync(website, new PartitionKey(website.code));
+                                    }
+                                }
                             }
                             ValidResult validResult = activity.Valid();
                             if (validResult.isVaild)
@@ -177,7 +287,7 @@ namespace TEAMModelOS.Controllers
                                 activity.createTime= DateTimeOffset.Now.ToUnixTimeMilliseconds();
                                 activity.year=DateTimeOffset.Now.Year;
                                 foreach (var module in activity.modules) {
-                                    switch (true) 
+                                    switch (true)
                                     {
                                         //赛课
                                         case bool when module.Equals("Contest"):
@@ -204,7 +314,7 @@ namespace TEAMModelOS.Controllers
                                                                 return Ok(new { error = ResponseCode._400ParamsError, msg = "评审未配置" });
                                                             }
                                                             ReviewRuleTree ruleTree = _reviewConfig.ToObject<ReviewRuleTree>();
-                                                            var reviewRule =  await ActivityService.UpsertReviewRule(ruleTree, activity, _azureCosmos);
+                                                            var reviewRule = await ActivityService.UpsertReviewRule(ruleTree, activity, _azureCosmos);
                                                             contest.review.ruleId = reviewRule.id;
                                                             contest.review.ruleName = reviewRule.name;
                                                         }
@@ -241,23 +351,23 @@ namespace TEAMModelOS.Controllers
                         {
                             if (!request.TryGetProperty("areaId", out JsonElement _areaId)) return BadRequest();
                             string yearSql = $" and c.year={DateTimeOffset.Now.Year}";
-                            
+
                             if (request.TryGetProperty("year", out JsonElement _year)) {
                                 yearSql = $" and c.year={_year}";
                             }
                             string sql = $"select value c from c where c.scope='area' and c.owner='{_areaId}' {yearSql}  ";
                             //醍摩豆智慧学区
                             if (_areaId.GetString().Equals("02944f32-f534-3397-ea56-e6f1fc6c3714", StringComparison.OrdinalIgnoreCase)) {
-                                sql = $"select value c from c where   c.owner='{_areaId}' {yearSql } and ( c.scope='area' or c.scope='public' ) ";
+                                sql = $"select value c from c where   c.owner='{_areaId}' {yearSql} and ( c.scope='area' or c.scope='public' ) ";
                             }
-                            var  result =  await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sql, "Activity");
-                            return Ok(new { activities = result.list.OrderByDescending(z=>z.stime) });
+                            var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sql, "Activity");
+                            return Ok(new { activities = result.list.OrderByDescending(z => z.stime) });
                         }
                     case bool when $"{grant_type}".Equals("list-school", StringComparison.OrdinalIgnoreCase):
                         {
                             if (!string.IsNullOrWhiteSpace(school)) {
                                 School schoolbase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
-                                List<Activity> activities = new List<Activity>();   
+                                List<Activity> activities = new List<Activity>();
                                 string yearSql = $" and c.year={DateTimeOffset.Now.Year}";
 
                                 if (request.TryGetProperty("year", out JsonElement _year))
@@ -269,7 +379,7 @@ namespace TEAMModelOS.Controllers
 
                                     //完全开放 所有的学校
                                     string sqlOpen = $"select value c from c where c.scope='public'{yearSql}  and (c.publish=1 or c.publish=2 )  and( ARRAY_LENGTH(c.invitedSchools)=0 or IS_DEFINED(c.invitedSchools) = false  ) ";
-                                    var resultOpen= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlOpen, "Activity");
+                                    var resultOpen = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlOpen, "Activity");
                                     activities.AddRange(resultOpen.list);
                                     //部分学校
                                     string sqlSchool = $"select value c from c  join s in c.invitedSchools  where c.scope='public'{yearSql}  and (c.publish=1 or c.publish=2 )  and s.id='{school}' ";
@@ -291,7 +401,7 @@ namespace TEAMModelOS.Controllers
                                 }
                                 //获取区级下放的
                                 {
-                                    
+
                                     if (!string.IsNullOrWhiteSpace(schoolbase.areaId)) {
                                         //区级所有学校
                                         string sqlOpen = $"select value c from c where c.scope='area'{yearSql}   and (c.publish=1 or c.publish=2 )  and  c.owner='{schoolbase.areaId}'  and( ARRAY_LENGTH(c.invitedSchools)=0 or IS_DEFINED(c.invitedSchools) = false) ";
@@ -312,7 +422,7 @@ namespace TEAMModelOS.Controllers
                                         activities.AddRange(resultOpen.list);
                                         //区级部分学校
                                         string sqlSchool = $"select value c from c  join s in c.invitedSchools  where c.scope='area'{yearSql}  and (c.publish=1 or c.publish=2 )  and  c.owner='{schoolbase.areaId}' and s.id='{school}' ";
-                                        var resultSchool= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
+                                        var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
                                         resultSchool.list.ForEach(z => {
                                             var confirmedSchool = z.confirmedSchools.Find(z => z.id.Equals(school));
                                             if (confirmedSchool==null)
@@ -334,13 +444,12 @@ namespace TEAMModelOS.Controllers
                                     string sqlSchool = $"select value c from c where c.scope='school'{yearSql} and  c.owner='{school}'  ";
                                     var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
                                     activities.AddRange(resultSchool.list);
-                                } 
+                                }
                                 return Ok(new { activities = activities.OrderByDescending(z => z.stime) });
                             }
                             break;
 
                         }
-                 
                     case bool when $"{grant_type}".Equals("list-teacher", StringComparison.OrdinalIgnoreCase):
                         {
                             List<Activity> activities = new List<Activity>();
@@ -354,7 +463,7 @@ namespace TEAMModelOS.Controllers
                                 School schoolbase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
                                 //获取区级下放的
                                 {
-                                  
+
                                     if (!string.IsNullOrWhiteSpace(schoolbase.areaId))
                                     {
                                         //区级所有学校
@@ -362,7 +471,7 @@ namespace TEAMModelOS.Controllers
                                         var resultOpen = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlOpen, "Activity");
                                         resultOpen.list.ForEach(z => {
                                             //处理是否是邀请制 
-                                            if (z.joinMode.Equals("invite")) 
+                                            if (z.joinMode.Equals("invite"))
                                             {
                                                 var inviteTeacher = z.inviteTeachers.Find(t => t.id.Equals(tmdid));
                                                 if (inviteTeacher!=null) {
@@ -442,19 +551,88 @@ namespace TEAMModelOS.Controllers
                             }
                             return Ok(new { activities = activities.OrderByDescending(z => z.stime) });
                         }
-                    case bool when $"{grant_type}".Equals("list-portal", StringComparison.OrdinalIgnoreCase):
-                        {
-                            if (!request.TryGetProperty("route", out JsonElement _route)) return BadRequest();
-                         
-
-                            break;
-                        }
                 }
-            }catch (Exception ex)
+            } catch (Exception ex)
             {
 
             }
             return Ok();
         }
+
+
+        /// <summary>
+        /// portal站的
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("list-portal")]
+        public async Task<IActionResult> ListPortal(JsonElement request) {
+            //var authtoken = HttpContext.GetXAuth("AuthToken");
+            //string userid = string.Empty;
+            //object schoolid = null;
+            //if (!string.IsNullOrWhiteSpace(authtoken)) {
+            //    var jwt = new JwtSecurityToken(authtoken);
+            //    //TODO 此驗證IdToken先簡單檢查,後面需向Core ID新API,驗證Token
+            //    userid= jwt.Payload.Sub;
+            //    jwt.Payload.TryGetValue("azp", out schoolid);
+            //}
+            if (!request.TryGetProperty("route", out JsonElement _route)) return BadRequest();
+            List<Activity> activities = new List<Activity>();
+            string sql = $"select value c from c where c.route='{_route}'";
+            var result=  await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).GetList<ActivityWebsite>(sql, "ActivityWebsite");
+            ActivityWebsite website = null;
+            if (result.list.Count>1)
+            {
+                return Ok(new { code = 1, msg = "路由匹配多个区校" });
+            }
+            else {
+                if (result.list.Count==1) {
+                    website= result.list[0];
+                }
+            }
+          
+            if (website!=null)
+            {
+                if (website.scope.Equals("area"))
+                {
+                    //区级所有学校
+                    string sqlOpen = $"select value c from c  where c.scope='area' and (c.publish=1 or c.publish=2 )  and  c.owner='{website.id}'   ";
+                    var resultOpen = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlOpen, "Activity");
+                    activities.AddRange(resultOpen.list);
+                }
+                if (website.scope.Equals("school"))
+                {
+                    School schoolbase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(website.id, new PartitionKey("Base"));
+                    //区级下放的
+                    if (!string.IsNullOrWhiteSpace(schoolbase.areaId))
+                    {
+                        //区级所有学校
+                        string sqlOpen = $"select value c from c join s in c.confirmedSchools where c.scope='area' and (c.publish=1 or c.publish=2 )  and  c.owner='{schoolbase.areaId}'  and( ARRAY_LENGTH(c.invitedSchools)=0 or IS_DEFINED(c.invitedSchools) = false) and s.id='{schoolbase.id}' and s.status=1 ";
+                        var resultOpen = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlOpen, "Activity");
+                        activities.AddRange(resultOpen.list);
+                        //区级部分学校
+                        string sqlSchool = $"select value c from c  join i in c.invitedSchools join s in c.confirmedSchools  where c.scope='area'and (c.publish=1 or c.publish=2 )  and  c.owner='{schoolbase.areaId}' and i.id='{schoolbase.id}'    and s.id='{schoolbase.id}' and s.status=1 ";
+                        var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
+                        activities.AddRange(resultSchool.list);
+                    }
+                    { 
+                        ///学校自己的 
+                        string sqlSchool = $"select value c from c where c.scope='school' and (c.publish=1 or c.publish=2 )  and  c.owner='{schoolbase.id}'  ";
+                        var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
+                        activities.AddRange(resultSchool.list);
+                    }
+                }
+                //获取开放的
+                {
+                    //完全开放 所有的学校
+                    string sqlOpen = $"select value c from c where c.scope='public' and (c.publish=1 or c.publish=2 )  ";
+                    var resultOpen = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlOpen, "Activity");
+                    activities.AddRange(resultOpen.list);
+                }
+            }
+             
+            return Ok(new { activities, website });
+        }
     }
 }

+ 61 - 16
TEAMModelOS/Controllers/Third/Sc/ScDataPushController.cs

@@ -30,6 +30,7 @@ using TEAMModelOS.Controllers.Third.LePei;
 using DocumentFormat.OpenXml.Wordprocessing;
 using System.Text.RegularExpressions;
 using Microsoft.Azure.Cosmos.Linq;
+using Flurl;
 
 namespace TEAMModelOS.Controllers
 {
@@ -1391,10 +1392,11 @@ namespace TEAMModelOS.Controllers
             long size = 0;
             List<string> schools=  json.GetProperty("schools").ToObject<List<string>>();
             List<dynamic> schoolData = new List<dynamic>();
-            int schoolFileCount = 0;
-            long schoolFileLength = 0;
+            
             foreach (var school in schools) 
             {
+                int schoolFileCount = 0;
+                long schoolFileLength = 0;
                 List<dynamic> teacherData= new List<dynamic>();
                 School  schoolBase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
                 var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher)
@@ -1406,24 +1408,43 @@ namespace TEAMModelOS.Controllers
                     long teacherFileLength = 0;
                     foreach (var off in teacherTrain.offlineRecords)
                     {
-                        string name = $"{off.name}-{off.other.First()?.name}";
-                       
+                        string name = "";
+                        if (off.other.IsNotEmpty())
+                        {
+                              name = $"{off.name}-{off.other.First()?.name}";
+                        }
+                        else {
+                              name = $"{off.name}.pdf";
+                        }
                         name = Regex.Replace(name, invalidChars, "");
-                         recordData.Add(new { type = "校本研修记录", name, off.url, off.size });
-                        teacherFileCount+=1;
-                        teacherFileLength+=off.size;
+                        if (!string.IsNullOrWhiteSpace(off.url)) {
+                            (string, string) a = BlobUrlString(off.url);
+                            var sas = _azureStorage.GetBlobSasUriRead(school, a.Item2);
+                            recordData.Add(new { type = "校本研修记录", name, url = $"{off.url}?{sas.sas}", off.size });
+                            teacherFileCount+=1;
+                            teacherFileLength+=off.size;
+                        }
+                       
                     }
                     if (teacherTrain.offlineReport!=null) {
-                        recordData.Add(new { type = "校本研修汇总", name = Regex.Replace(teacherTrain.offlineReport?.name, invalidChars, ""), teacherTrain.offlineReport?.url, teacherTrain.offlineReport?.size });
-                        teacherFileCount+=1;
-                        teacherFileLength+=teacherTrain.offlineReport.size;
+                        if (!string.IsNullOrWhiteSpace(teacherTrain.offlineReport?.url)) {
+                            (string, string) a = BlobUrlString(teacherTrain.offlineReport?.url);
+                            var sas = _azureStorage.GetBlobSasUriRead(school, a.Item2);
+                            recordData.Add(new { type = "校本研修汇总", name = Regex.Replace(teacherTrain.offlineReport?.name, invalidChars, ""), url = $"{teacherTrain.offlineReport?.url}?{sas.sas}", teacherTrain.offlineReport?.size });
+                            teacherFileCount+=1;
+                            teacherFileLength+=teacherTrain.offlineReport.size;
+                        }
                     }
                     
                     foreach (var teacherClass in teacherTrain.teacherClasses)
                     {
-                        recordData.Add(new { type = "课堂实录", name = Regex.Replace(teacherClass?.name, invalidChars, ""), teacherClass?.url, teacherClass?.size });
-                        teacherFileCount+=1;
-                        teacherFileLength+=teacherClass.size;
+                        if (!string.IsNullOrWhiteSpace(teacherClass?.url)) {
+                            (string, string) a = BlobUrlString(teacherClass?.url);
+                            var sas = _azureStorage.GetBlobSasUriRead(school, a.Item2);
+                            recordData.Add(new { type = "课堂实录", name = Regex.Replace(teacherClass?.name, invalidChars, ""), url = $"{teacherClass?.url}?{sas.sas}", teacherClass?.size });
+                            teacherFileCount+=1;
+                            teacherFileLength+=teacherClass.size;
+                        }
                     }
                     var resultAbility = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher)
                         .GetList<AbilitySub>("select value c from  c where c.pk='AbilitySub'", $"AbilitySub-{school}-{teacherTrain.id}");
@@ -1433,19 +1454,43 @@ namespace TEAMModelOS.Controllers
                         {
                             foreach (var url in upload.urls)
                             {
-                                recordData.Add(new { type = "认证材料",name =$"{ability.no}-{url?.name}", url?.url, url?.size });
-                                teacherFileCount+=1;
-                                teacherFileLength+=url.size;
+                                if (!string.IsNullOrWhiteSpace(url?.url))
+                                {
+                                    (string, string) a = BlobUrlString(url?.url);
+                                    var sas = _azureStorage.GetBlobSasUriRead(school, a.Item2);
+                                    recordData.Add(new { type = "认证材料", name = $"{ability.no}-{url?.name}", url = $"{url?.url}?{sas.sas}", url?.size });
+                                    teacherFileCount+=1;
+                                    teacherFileLength+=url.size;
+                                }
+                               
                             }
                         }
                     }
                     teacherData.Add(new { id = teacherTrain.id, teacherTrain.nickname, teacherFileCount, teacherFileLength, recordData });
+                    schoolFileLength+=teacherFileLength;
+                    schoolFileCount+=teacherFileCount;
                 }
                 schoolData.Add(new { teachers = teacherData, schoolBase.id, schoolBase.name, schoolFileCount, schoolFileLength });
                 size+=schoolFileLength;
             }
             return Ok(new { schoolData , size });
         }
+        private static (string, string) BlobUrlString(string sasUrl)
+        {
+            sasUrl = sasUrl.Substring(8);
+            string[] sasUrls = sasUrl.Split("/");
+            string ContainerName;
+            ContainerName = sasUrls[1].Clone().ToString();
+            string item = sasUrls[0] + "/" + sasUrls[1] + "/";
+            string blob = sasUrl.Replace(item, "");
+            return (ContainerName, blob);
+        }
+        private static bool IsBlobName(string BlobName)
+        {
+            return System.Text.RegularExpressions.Regex.IsMatch(BlobName,
+             @"(?!((^(con)$)|^(con)\\..*|(^(prn)$)|^(prn)\\..*|(^(aux)$)|^(aux)\\..*|(^(nul)$)|^(nul)\\..*|(^(com)[1-9]$)|^(com)[1-9]\\..*|(^(lpt)[1-9]$)|^(lpt)[1-9]\\..*)|^\\s+|.*\\s$)(^[^\\\\\\:\\<\\>\\*\\?\\\\\\""\\\\|]{1,255}$)");
+        }
+
     }
 
     public class DiagnosisInfoItem

+ 0 - 4
TEAMModelOS/Controllers/XTest/TestController.cs

@@ -771,10 +771,6 @@ namespace TEAMModelOS.Controllers
         public async Task<IActionResult> CheckPjx(JsonElement json)
         {
             
-            if (!json.TryGetProperty("itemID", out JsonElement _itemID)  ) {
-                return BadRequest();
-            }
-            int itemID = int.Parse($"{_itemID}");
             var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
             int itemId = 0;
             if (json.TryGetProperty("itemId", out JsonElement _itemId)) {

+ 4 - 4
TEAMModelOS/TEAMModelOS.csproj

@@ -74,11 +74,11 @@
     <SpaRoot>ClientApp\</SpaRoot>
     <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
     <UserSecretsId>078b5d89-7d90-4f6a-88fc-7d96025990a8</UserSecretsId>
-    <Version>5.2310.18</Version>
-    <AssemblyVersion>5.2310.18.1</AssemblyVersion>
-    <FileVersion>5.2310.18.1</FileVersion>
+    <Version>5.2310.25</Version>
+    <AssemblyVersion>5.2310.25.1</AssemblyVersion>
+    <FileVersion>5.2310.25.1</FileVersion>
     <Description>TEAMModelOS(IES5)</Description>
-    <PackageReleaseNotes>IES版本说明版本切换标记5.2310.18.1</PackageReleaseNotes>
+    <PackageReleaseNotes>IES版本说明版本切换标记5.2310.25.1</PackageReleaseNotes>
     <PackageId>TEAMModelOS</PackageId>
     <Authors>teammodel</Authors>
     <Company>醍摩豆(成都)信息技术有限公司</Company>

+ 33 - 33
TEAMModelOS/appsettings.Development.json

@@ -18,52 +18,52 @@
     "IdTokenSalt": "8263692E2213497BB55E74792B7900B4",
     "HttpTrigger": "https://teammodelosfunction-test.chinacloudsites.cn/api/",
     //"HttpTrigger": "http://localhost:7071/api/"
-    "Version": "5.2310.18.1"
+    "Version": "5.2310.25.1"
   },
   "Azure": {
     // 测试站数据库
-    "Storage": {
-      "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodeltest;AccountKey=O2W2vadCqexDxWO+px+QK7y1sHwsYj8f/WwKLdOdG5RwHgW/Dupz9dDUb4c1gi6ojzQaRpFUeAAmOu4N9E+37A==;EndpointSuffix=core.chinacloudapi.cn"
-    },
-    "Cosmos": {
-      "ConnectionString": "AccountEndpoint=https://cdhabookdep-free.documents.azure.cn:443/;AccountKey=JTUVk92Gjsx17L0xqxn0X4wX2thDPMKiw4daeTyV1HzPb6JmBeHdtFY1MF1jdctW1ofgzqkDMFOtcqS46by31A==;"
-    },
-    "Redis": {
-      "ConnectionString": "52.130.252.100:6379,password=habook,ssl=false,abortConnect=False,writeBuffer=10240"
-    },
-    "ServiceBus": {
-      "ConnectionString": "Endpoint=sb://teammodelos.servicebus.chinacloudapi.cn/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Sy4h4EQ8zP+7w/lOLi1X3tGord/7ShFHimHs1vC50Dc=",
-      "ActiveTask": "dep-active-task",
-      "ItemCondQueue": "dep-itemcond",
-      "GenPdfQueue": "dep-genpdf"
-    },
-    "SignalR": {
-      "ConnectionString": "Endpoint=https://channel.service.signalr.net;AccessKey=KrblW06tuA4a/GyqRPDU0ynFFmAWxbAvyJihHclSXbQ=;Version=1.0;"
-    }
-    // 正式站数据库
     //"Storage": {
-    //  "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelos;AccountKey=Dl04mfZ9hE9cdPVO1UtqTUQYN/kz/dD/p1nGvSq4tUu/4WhiKcNRVdY9tbe8620nPXo/RaXxs+1F9sVrWRo0bg==;EndpointSuffix=core.chinacloudapi.cn"
+    //  "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodeltest;AccountKey=O2W2vadCqexDxWO+px+QK7y1sHwsYj8f/WwKLdOdG5RwHgW/Dupz9dDUb4c1gi6ojzQaRpFUeAAmOu4N9E+37A==;EndpointSuffix=core.chinacloudapi.cn"
     //},
     //"Cosmos": {
-    //  "ConnectionString": "AccountEndpoint=https://teammodelos.documents.azure.cn:443/;AccountKey=clF73GwPECfP1lKZTCvs8gLMMyCZig1HODFbhDUsarsAURO7TcOjVz6ZFfPqr1HzYrfjCXpMuVD5TlEG5bFGGg==;"
+    //  "ConnectionString": "AccountEndpoint=https://cdhabookdep-free.documents.azure.cn:443/;AccountKey=JTUVk92Gjsx17L0xqxn0X4wX2thDPMKiw4daeTyV1HzPb6JmBeHdtFY1MF1jdctW1ofgzqkDMFOtcqS46by31A==;"
     //},
     //"Redis": {
-    //  "ConnectionString": "CoreRedisCN.redis.cache.chinacloudapi.cn:6380,password=LyJWP1ORJdv+poXWofAF97lhCEQPg1wXWqvtzXGXQuE=,ssl=True,abortConnect=False"
+    //  "ConnectionString": "52.130.252.100:6379,password=habook,ssl=false,abortConnect=False,writeBuffer=10240"
     //},
     //"ServiceBus": {
-    //  "ConnectionString": "Endpoint=sb://coreiotservicebuscnpro.servicebus.chinacloudapi.cn/;SharedAccessKeyName=TEAMModelOS;SharedAccessKey=llRPBMDJG9w1Nnifj+pGhV0g4H2REcq0PjvX2qqpcOg=",
-    //  "ActiveTask": "active-task",
-    //  "ItemCondQueue": "itemcond",
-    //  "GenPdfQueue": "genpdf"
+    //  "ConnectionString": "Endpoint=sb://teammodelos.servicebus.chinacloudapi.cn/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Sy4h4EQ8zP+7w/lOLi1X3tGord/7ShFHimHs1vC50Dc=",
+    //  "ActiveTask": "dep-active-task",
+    //  "ItemCondQueue": "dep-itemcond",
+    //  "GenPdfQueue": "dep-genpdf"
     //},
     //"SignalR": {
-    //  "ConnectionString": "Endpoint=https://channel.signalr.azure.cn;AccessKey=AtcB7JYFNUbUXb1rGxa3PVksQ2X5YSv3JOHZR9J88tw=;Version=1.0;"
-    //},
-    //"Speech": {
-    //  "SubscriptionKey": "a4f5f4e2e2e54c6e8b0a4a0b4a0a4a0b",
-    //  "Region": "chinanorth3",
-    //  "Endpoint": "https://chinanorth3.api.cognitive.azure.cn/sts/v1.0/issuetoken"
+    //  "ConnectionString": "Endpoint=https://channel.service.signalr.net;AccessKey=KrblW06tuA4a/GyqRPDU0ynFFmAWxbAvyJihHclSXbQ=;Version=1.0;"
     //}
+    // 正式站数据库
+    "Storage": {
+      "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelos;AccountKey=Dl04mfZ9hE9cdPVO1UtqTUQYN/kz/dD/p1nGvSq4tUu/4WhiKcNRVdY9tbe8620nPXo/RaXxs+1F9sVrWRo0bg==;EndpointSuffix=core.chinacloudapi.cn"
+    },
+    "Cosmos": {
+      "ConnectionString": "AccountEndpoint=https://teammodelos.documents.azure.cn:443/;AccountKey=clF73GwPECfP1lKZTCvs8gLMMyCZig1HODFbhDUsarsAURO7TcOjVz6ZFfPqr1HzYrfjCXpMuVD5TlEG5bFGGg==;"
+    },
+    "Redis": {
+      "ConnectionString": "CoreRedisCN.redis.cache.chinacloudapi.cn:6380,password=LyJWP1ORJdv+poXWofAF97lhCEQPg1wXWqvtzXGXQuE=,ssl=True,abortConnect=False"
+    },
+    "ServiceBus": {
+      "ConnectionString": "Endpoint=sb://coreiotservicebuscnpro.servicebus.chinacloudapi.cn/;SharedAccessKeyName=TEAMModelOS;SharedAccessKey=llRPBMDJG9w1Nnifj+pGhV0g4H2REcq0PjvX2qqpcOg=",
+      "ActiveTask": "active-task",
+      "ItemCondQueue": "itemcond",
+      "GenPdfQueue": "genpdf"
+    },
+    "SignalR": {
+      "ConnectionString": "Endpoint=https://channel.signalr.azure.cn;AccessKey=AtcB7JYFNUbUXb1rGxa3PVksQ2X5YSv3JOHZR9J88tw=;Version=1.0;"
+    },
+    "Speech": {
+      "SubscriptionKey": "a4f5f4e2e2e54c6e8b0a4a0b4a0a4a0b",
+      "Region": "chinanorth3",
+      "Endpoint": "https://chinanorth3.api.cognitive.azure.cn/sts/v1.0/issuetoken"
+    }
   },
   "HaBookAuth": {
     "CoreId": {

+ 1 - 1
TEAMModelOS/appsettings.json

@@ -18,7 +18,7 @@
     "Exp": 86400,
     "IdTokenSalt": "8263692E2213497BB55E74792B7900B4",
     "HttpTrigger": "https://teammodelosfunction.chinacloudsites.cn/api/",
-    "Version": "5.2310.18.1"
+    "Version": "5.2310.25.1"
   },
   "Azure": {
     "Storage": {