Esempio n. 1
0
        private async void loadTree()
        {
            loadingProgressBar.Visible = true;
            treeViewSubscribed.Nodes.Clear();
            User user = GetUser();

            textBoxUserLogin.Text = user.Login;
            textBoxUserName.Text  = user.FirstName + " " + user.LastName;
            textBoxUserPhone.Text = user.PhoneNumber;
            textBoxUserMail.Text  = user.MailAddress;

            var task = new Task <ICollection <College> >(() =>
            {
                return(CollegeGetItems.Invoke());
            });

            task.Start();

            var colleges = await task;

            foreach (var college in colleges)
            {
                TreeNode nodeCollege = treeViewSubscribed.Nodes.Add(college.Name);
                var      taskFac     = new Task <ICollection <Faculty> >(() => { return(FacultyGetItems.Invoke(college.Name)); });
                taskFac.Start();

                var faculties = await taskFac;
                foreach (var faculty in faculties)
                {
                    TreeNode nodeFaculty = nodeCollege.Nodes.Add(faculty.Name);
                    var      taskSpec    = new Task <ICollection <Specialization> >(() => { return(SpecializationsGetItems.Invoke(faculty.Name)); });
                    taskSpec.Start();

                    var specializations = await taskSpec;
                    if (specializations.Count < 1)
                    {
                        treeViewSubscribed.Nodes.Remove(nodeFaculty);
                    }
                    foreach (var specialization in specializations)
                    {
                        TreeNode nodeSpecialization = nodeFaculty.Nodes.Add(specialization.Name);
                        nodeSpecialization.Tag = specialization;
                        var taskSubject = new Task <ICollection <Subject> >(() => { return(SubjectGetItems.Invoke(specialization.Name)); });
                        taskSubject.Start();

                        var subjects = await taskSubject;
                        foreach (var subject in subjects)
                        {
                            TreeNode nodeSubject = nodeSpecialization.Nodes.Add(subject.Name);
                        }
                    }
                }
            }



            loadingProgressBar.Visible = false;
        }
Esempio n. 2
0
        private async void NoteControl_Load(object sender, EventArgs e)
        {
            loadingProgressBar.Visible = true;

            var task = new Task <ICollection <College> >(() =>
            {
                return(CollegeGetItems.Invoke());
            });

            task.Start();

            var colleges = await task;

            foreach (var college in colleges)
            {
                TreeNode nodeCollege = treeViewNotes.Nodes.Add(college.Name);
                var      taskFac     = new Task <ICollection <Faculty> >(() => { return(FacultyGetItems.Invoke(college.Name)); });
                taskFac.Start();

                var faculties = await taskFac;
                foreach (var faculty in faculties)
                {
                    TreeNode nodeFaculty = nodeCollege.Nodes.Add(faculty.Name);
                    var      taskSpec    = new Task <ICollection <Specialization> >(() => { return(SpecializationsGetItems.Invoke(faculty.Name)); });
                    taskSpec.Start();

                    var specializations = await taskSpec;
                    if (specializations.Count < 1)
                    {
                        treeViewNotes.Nodes.Remove(nodeFaculty);
                    }
                    foreach (var specialization in specializations)
                    {
                        TreeNode nodeSpecialization = nodeFaculty.Nodes.Add(specialization.Name);
                        var      taskSubject        = new Task <ICollection <Subject> >(() => { return(SubjectGetItems.Invoke(specialization.Name)); });
                        taskSubject.Start();

                        var subjects = await taskSubject;
                        foreach (var subject in subjects)
                        {
                            TreeNode nodeSubject  = nodeSpecialization.Nodes.Add(subject.Name);
                            var      taskMaterial = new Task <ICollection <Material> >(() => { return(MaterialGetItems.Invoke(subject.Name)); });
                            taskMaterial.Start();

                            var materials = await taskMaterial;
                            foreach (var material in materials)
                            {
                                TreeNode nodeMats = nodeSubject.Nodes.Add(material.Title);
                                nodeMats.Tag = material;
                            }
                        }
                    }
                }
            }

            loadingProgressBar.Visible = false;
        }