Ejemplo n.º 1
0
        public void UpdateSettings()
        {
            JsonOperation jsonOperation = new JsonOperation();
            Setting       settings      = jsonOperation.GetSettingsInfo();

            var directory = Environment.CurrentDirectory + "\\config";
            var path      = Path.Combine(directory, "settings.json");

            settings.SelectedUniversityIndex = University.SelectedIndex;
            settings.StudentId        = StudentId.Text;
            settings.RememberPassword = RememberPassword.IsChecked.Value;
            settings.AutoLogin        = AutoLogin.IsChecked.Value;

            if (RememberPassword.IsChecked.Value)
            {
                settings.Password = Password.Password;
            }
            else
            {
                settings.Password  = string.Empty;
                settings.AutoLogin = false;
            }

            jsonOperation.UpdateJson <Setting>(path, settings);
        }
Ejemplo n.º 2
0
        private void Edit_Click(object sender, RoutedEventArgs e)
        {
            EditServer    editServer    = new EditServer();
            JsonOperation jsonOperation = new JsonOperation();
            ServerList    server        = jsonOperation.GetServerInfo();

            foreach (var item in server.Info)
            {
                editServer.UniversityList.Items.Add(item.University);
            }

            editServer.UniversityList.SelectedIndex = 0;
            editServer.ShowDialog();
        }
Ejemplo n.º 3
0
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            var           path          = Path.Combine(MainWindow.configPath, "server.json");
            JsonOperation jsonOperation = new JsonOperation();
            ServerList    server        = jsonOperation.GetServerInfo();

            bool removeStatus = server.Info.Remove(server.Info[UniversityList.SelectedIndex]);

            jsonOperation.UpdateJson <ServerList>(path, server);

            if (removeStatus)
            {
                MessageBox.Show("删除成功");
            }
        }
Ejemplo n.º 4
0
        public async void ShowContentAsync()
        {
            FileOperation fileOperation = new FileOperation(FileGrid);
            JsonOperation notice        = new JsonOperation();
            NoticeDetail  detail        = await notice.GetContentInfoAsync(noticeId);

            title   = detail.Title;
            content = detail.Content;

            string text = Regex.Replace(content, @"<.*?>|&.*?;", string.Empty);

            text = "        " + text;

            DetailContent.Text = text;

            fileOperation.ShowFileAsync(token);
        }
Ejemplo n.º 5
0
        public async void ShowPage()
        {
            if (!int.TryParse(PageNumber.Text, out int checkNumber) || checkNumber <= 0)
            {
                MessageBox.Show("请输入正确的页数");
                PageNumber.Text = "1";
            }

            if (!int.TryParse(PageSize.Text, out checkNumber) || checkNumber <= 0)
            {
                MessageBox.Show("请输入正确的数字");
                PageSize.Text = "10";
            }

            JsonOperation notice   = new JsonOperation();
            PageObject    pageJson = await notice.GetPageInfoAsync(PageNumber.Text, PageSize.Text, SearchParam.Text);

            if (pageJson != null)
            {
                ObservableCollection <PageInfo> PageData = new ObservableCollection <PageInfo>();

                foreach (var item in pageJson.Qp.AList)
                {
                    PageData.Add(new PageInfo()
                    {
                        Title          = item.Title,
                        ReadCount      = int.Parse(item.Read_Count),
                        PublishPeople  = item.Publish_User_Name,
                        PublishDept    = item.Publish_User_Dept_Name,
                        PublishTime    = item.Create_time,
                        LastUpdateTime = item.Update_Time,
                        NoticeId       = item.Wid,
                        Attachment     = item.Attachment
                    });
                }

                TotalSize.Text       = pageJson.Qp.TotalSize;
                PageGrid.DataContext = PageData;
            }
            else
            {
                SearchParam.Text = String.Empty;
                PageNumber.Text  = "1";
            }
        }
Ejemplo n.º 6
0
        public void GetSettings()
        {
            JsonOperation jsonOperation = new JsonOperation();
            Setting       settings      = jsonOperation.GetSettingsInfo();

            University.SelectedIndex   = settings.SelectedUniversityIndex.Value;
            RememberPassword.IsChecked = settings.RememberPassword;
            AutoLogin.IsChecked        = settings.AutoLogin;
            StudentId.Text             = settings.StudentId;
            Password.Password          = settings.Password;

            if (settings.AutoLogin)
            {
                ButtonAutomationPeer peer  = new ButtonAutomationPeer(Login);
                IInvokeProvider      login = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
                login.Invoke();
            }
        }
Ejemplo n.º 7
0
        public async void ShowFileAsync(string token)
        {
            JsonOperation notice   = new JsonOperation();
            FileList      fileList = await notice.GetFileInfoAsync(token);

            ObservableCollection <FileInfo> fileData = new ObservableCollection <FileInfo>();

            foreach (var item in fileList.AList)
            {
                fileData.Add(new FileInfo()
                {
                    FileName  = item.FileName,
                    FileSize  = item.FileSize,
                    FileToken = item.FileToken
                });
            }

            fileGrid.DataContext = fileData;
        }
Ejemplo n.º 8
0
        public void UpdateServerAddress()
        {
            JsonOperation jsonOperation = new JsonOperation();
            ServerList    server        = jsonOperation.GetServerInfo();

            University.Items.Clear();
            AuthserverHttp.Items.Clear();
            EhallHttp.Items.Clear();

            foreach (var item in server.Info)
            {
                University.Items.Add(item.University);
                AuthserverHttp.Items.Add(item.AuthserverHttp);
                EhallHttp.Items.Add(item.EhallHttp);
            }

            University.SelectedIndex     = 0;
            AuthserverHttp.SelectedIndex = 0;
            EhallHttp.SelectedIndex      = 0;
        }
Ejemplo n.º 9
0
        public void AddServerInfo()
        {
            var path = Path.Combine(MainWindow.configPath, "server.json");

            Server newServer = new Server()
            {
                University     = NewUniversity.Text,
                AuthserverHttp = NewAuthServer.Text,
                EhallHttp      = NewEhallServer.Text
            };

            JsonOperation jsonOperation = new JsonOperation();
            ServerList    server        = jsonOperation.GetServerInfo();

            server.Info.Add(newServer);

            jsonOperation.UpdateJson <ServerList>(path, server);

            MessageBox.Show("添加成功");
        }