Пример #1
0
        private async void login_Click(object sender, RoutedEventArgs e)
        {
            //username = UserName.Text.ToString();
            //password = PassWord.Password.ToString();
            username    = "******";
            password    = "******";
            pg.IsActive = true;

            Net.Teachnet teachnet = new Net.Teachnet(username, password);
            // teachnet.initializeAsync();
            //   IAsyncOperation<string> iasync = teachnet.initializeAsync().Result;
            //   iasync.Completed = TeachnetCompleted;
            await Task.Delay(2000);

            // StToInfo saveToInfo = new StToInfo(teachnet.classinfo);
            //saveToInfo.SaveTodb();
            using (var db = new ClassDb())
            {
                if (db.Students.LongCount() != 0)
                {
                    SaveToRam Str = new SaveToRam();
                    Str.Analysis();
                }
            }

            pg.IsActive = false;
            Frame f = Window.Current.Content as Frame;

            f.Navigate(typeof(Views.ShellView));
            Hide();
            //  rootFrame.Navigate(typeof(Views.ShellView), e.Arguments);
        }
Пример #2
0
        private async void ContentDialog_SecondaryButtonClickAsync(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            bool isCheck = true;

            username    = UserName.Text.ToString();
            password    = PassWord.Password.ToString();
            pg.IsActive = true;

            Net.Teachnet teachnet = new Net.Teachnet(username, password);
            teachnet.initializeAsync();
            //   IAsyncOperation<string> iasync = teachnet.initializeAsync().Result;
            //   iasync.Completed = TeachnetCompleted;
            int t;

            t = 0;
            while (teachnet.classinfo == null && t < 3)
            {
                await Task.Delay(2000);

                t++;
            }

            StToInfo saveToInfo = new StToInfo(teachnet.classinfo);

            saveToInfo.SaveTodb();
            using (var db = new ClassDb())
            {
                if (db.Students.LongCount() != 0)
                {
                    SaveToRam Str = new SaveToRam();
                    Str.Analysis();
                }
            }

            pg.IsActive = false;
            args.Cancel = isCheck;
            Frame f = Window.Current.Content as Frame;

            f.Navigate(typeof(Views.ShellView));
        }