예제 #1
0
        private async Task LoadOrgAsync()
        {
            if (orgLoaded)
            {
                return;
            }

            var rev = await _userSvc.GetOrg(this.Session);

            if (rev == null)
            {
                this.orgLoaded = true;
                return;
            }

            this.Region = new OrgValue
            {
                Code = rev.Idx.ToString(),
                Name = rev.Name,
                Deep = 1
            };


            if (rev.ChildList == null || rev.ChildList.Count == 0)
            {
                this.orgLoaded = true;
                return;
            }

            //学校...
            foreach (var item in rev.ChildList)
            {
                this.Schools = this.AddOrgItem(this.Schools, item, rev.Idx.ToString(), 2);

                // 学段
                if (item.HasChildern() == false)
                {
                    continue;
                }

                foreach (var sectionItem in item.ChildList)
                {
                    this.Section = this.AddOrgItem(this.Section, sectionItem, item.Idx.ToString(), 3);

                    if (sectionItem.HasChildern() == false)
                    {
                        continue;
                    }

                    //年级....
                    foreach (var grade in sectionItem.ChildList)
                    {
                        this.Grade = this.AddOrgItem(this.Grade, grade, sectionItem.Idx.ToString(), 4);

                        if (grade.HasChildern() == false)
                        {
                            continue;
                        }
                        foreach (var classItem in grade.ChildList)
                        {
                            this.Class = this.AddOrgItem(this.Class, classItem, grade.Idx.ToString(), 5);
                        }
                    }
                }
            }

            this.orgLoaded = true;
        }