Esempio n. 1
0
        static async Task Main(string[] args)
        {
            // The port number(5001) must match the port of the gRPC server.
            var channel = GrpcChannel.ForAddress("https://localhost:5001");
            // var client = new Greeter.GreeterClient(channel);
            //var reply = await client.SayHelloAsync(
            //                 new HelloRequest { Name = "GreeterClient" });

            var client = new Api.ApiClient(channel);
            var reply  = await client.AddPostAsync(
                new Post
            {
                Description = "Descrieree"
            }
                );

            Console.WriteLine("Raspuns: " + reply.Resp);
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
Esempio n. 2
0
        /// <summary>
        /// 开始答题-进入学习页面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StartStudy(object sender, RoutedEventArgs e)
        {
            if (!mPageData.IsPractice)
            {
                return;
            }
            btnPractice.Button("loading", "正在创建练习记录");
            this.UIAsync(win =>
            {
                //设置正在参与的学生
                var studentIds = this.mStudentViews.Where(m => m.IsOnline && m.IsSelected).Select(m => m.StudentId).ToList();

                var api    = new Api.ApiClient();
                var result = api.AcademicCurrent(APP.StudySession.GardenId);
                if (result.flag)
                {
                    var dbResult = CreatePracticeRecord(studentIds, result.data);
                    if (dbResult.flag)
                    {
                        APP.StudySession.StartStudy(studentIds, mPaperPractice.paper_id.Value, dbResult.data);
                        this.UICall(() =>
                        {
                            btnPractice.Button("reset");
                            StudyWindow window = new StudyWindow();
                            window.Show();
                        });
                    }
                    else
                    {
                        this.UICall(() => { this.ShowMessageError(dbResult.msg); btnPractice.Button("reset"); });
                    }
                }
                else
                {
                    this.UICall(() => { this.ShowMessageError("获取学年失败"); btnPractice.Button("reset"); });
                }
            });
        }
Esempio n. 3
0
        /// <summary>
        /// 加载学生
        /// </summary>
        /// <param name="classes"></param>
        private void loadStudent(ViewModels.Classes classes)
        {
            mCurrentClasses      = classes;
            mPageData.HeaderText = "加载中...";
            mStudentViews.Clear();

            this.UIAsync(m =>
            {
                var api    = new Api.ApiClient();
                var result = api.StudentClassStudents(APP.StudySession.GardenId, classes.ClassId, null);
                if (result.flag)
                {
                    this.UICall(list =>
                    {
                        APP.StudySession.AllStudents = list;
                        mPageData.HeaderText         = $"班主任:{classes.TeacherName}   学生人数:{list.Count}人";
                        foreach (var item in list)
                        {
                            mStudentViews.Add(new ViewModels.StudentView(item)
                            {
                                IsOnline   = PenController.Instance.GetPenStatus(item.id).IsOnline,
                                IsSelected = true
                            });
                        }
                        refreshOnlineCount();
                        EmptyBind(list.Count == 0);
                    }, result.data);
                }
                else
                {
                    this.UICall(() =>
                    {
                        this.ShowMessageInformation(result.msg);
                    });
                }
            });
        }
Esempio n. 4
0
 /// <summary>
 /// 加载班级
 /// </summary>
 private void loadClasses()
 {
     this.UIAsync(m =>
     {
         var api = new Api.ApiClient();
         //获取登录讲师所在园区的班级列表
         var result = api.OrganizationTeacherGardenClasses(APP.StudySession.GardenId, APP.StudySession.Account.accountId);
         if (result.flag)
         {
             this.UICall(list =>
             {
                 foreach (var item in list)
                 {
                     mClasses.Add(new ViewModels.Classes(item));
                 }
                 if (list.Count > 0)
                 {
                     ClassesListView.SelectedIndex = 0;
                     loadStudent(mClasses[0]);
                 }
                 else
                 {
                     mPageData.HeaderText = "没有绑定任何班级";
                     EmptyBind(true);
                 }
             }, result.data);
         }
         else
         {
             this.UICall(() =>
             {
                 this.ShowMessageInformation(result.msg);
             });
         }
     });
 }