public static async Task<HotFeed> GetHotFeed(int type_id, string article_id) { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>(); //paramList.Add(new KeyValuePair<string, string>("stuNum", appSetting.Values["stuNum"].ToString())); //paramList.Add(new KeyValuePair<string, string>("idNum", appSetting.Values["idNum"].ToString())); paramList.Add(new KeyValuePair<string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair<string, string>("idNum", credentialList[0].Password.ToString())); paramList.Add(new KeyValuePair<string, string>("type_id", type_id.ToString())); paramList.Add(new KeyValuePair<string, string>("article_id", article_id.ToString())); string response = await NetWork.getHttpWebRequest(api, paramList); Debug.WriteLine(response); try { if (response != "" || response != "[]") { JObject bbddfeeds = JObject.Parse(response); if (bbddfeeds["status"].ToString() == "200") { JObject feed = (JObject)bbddfeeds["data"][0]; HotFeed f = new HotFeed(); f.GetAttributes(feed); return f; } } } catch (Exception) { } return null; }
public static async Task<PeoInfo> GetPerson(string stunum_other) { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>(); //paramList.Add(new KeyValuePair<string, string>("stuNum", appSetting.Values["stuNum"].ToString())); //paramList.Add(new KeyValuePair<string, string>("idNum", appSetting.Values["idNum"].ToString())); paramList.Add(new KeyValuePair<string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair<string, string>("idNum", credentialList[0].Password)); paramList.Add(new KeyValuePair<string, string>("stunum_other", stunum_other)); string response = await NetWork.getHttpWebRequest(api, paramList); try { if (response != "" && response != "[]") { JObject bbddfeeds = JObject.Parse(response); if (bbddfeeds["status"].ToString() == "200") { JObject feed = (JObject)bbddfeeds["data"]; PeoInfo f = new PeoInfo(); f.GetAttributes(feed); return f; } } } catch (Exception) { } return null; }
private async void initScore() { //await Utils.ShowSystemTrayAsync(Color.FromArgb(255, 2, 140, 253), Colors.White, text: "正在紧张批改试卷...", isIndeterminate: true); var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>(); //paramList.Add(new KeyValuePair<string, string>("stuNum", appSetting.Values["stuNum"].ToString())); //paramList.Add(new KeyValuePair<string, string>("idNum", appSetting.Values["idNum"].ToString())); paramList.Add(new KeyValuePair<string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair<string, string>("idNum", credentialList[0].Password)); string score = await NetWork.getHttpWebRequest("api/examGrade", paramList); Debug.WriteLine("score->" + score); #if DEBUG //score = "{\"status\":200,\"term\":\"20151\",\"info\":\"success\",\"data\":[{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"}],\"version\":\"0.1.0\",\"stuNum\":\"2013211594\",\"idNum\":\"160155\"}"; #endif if (score != "") { JObject obj = JObject.Parse(score); if (Int32.Parse(obj["status"].ToString()) == 200) { List<ScoreList> scoreList = new List<ScoreList>(); JArray ScoreListArray = Utils.ReadJso(score); for (int i = 0; i < ScoreListArray.Count; i++) { ScoreList classitem = new ScoreList(); classitem.GetAttribute((JObject)ScoreListArray[i]); scoreList.Add(classitem); } ScoreListView.ItemsSource = scoreList; } else if (Int32.Parse(obj["status"].ToString()) == 300) { ListFailedStackPanelTextBlock.Text = "暂无数据,过几天再来看看"; ListFailedStackPanel.Visibility = Visibility.Visible; ListFailedStackPanelImage.Visibility = Visibility.Collapsed; ListFailedStackPanelTextBlock.Visibility = Visibility.Visible; } else { ListFailedStackPanelTextBlock.Text = "加载失败,点击重试"; ListFailedStackPanel.Visibility = Visibility.Visible; ListFailedStackPanelImage.Visibility = Visibility.Visible; ListFailedStackPanelTextBlock.Visibility = Visibility.Visible; } } else { ListFailedStackPanelTextBlock.Text = "加载失败,点击重试"; ListFailedStackPanel.Visibility = Visibility.Visible; ListFailedStackPanelImage.Visibility = Visibility.Visible; ListFailedStackPanelTextBlock.Visibility = Visibility.Visible; } //StatusBar statusBar = StatusBar.GetForCurrentView(); //await statusBar.ProgressIndicator.HideAsync(); }
private void URLTextBlock_TextChanged(object sender, TextChangedEventArgs e) { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); //URLTextBlock.Text = "http://hongyan.cqupt.edu.cn/api/kebiao_ics?xh=" + appSetting.Values["stuNum"].ToString(); URLTextBlock.Text = "http://hongyan.cqupt.edu.cn/api/kebiao_ics?xh=" + credentialList[0].UserName; }
private ApplicationDataContainer appSetting = ApplicationData.Current.LocalSettings; //本地存储 public async void Run(IBackgroundTaskInstance taskInstance) { var deferral = taskInstance.GetDeferral(); if (bool.Parse(appSetting.Values["isUseingBackgroundTask"].ToString())) { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); stuNum = credentialList[0].UserName; idNum = credentialList[0].Password; ToastNotificationActionTriggerDetail details = taskInstance.TriggerDetails as ToastNotificationActionTriggerDetail; if (details != null) { // 是否选择“确定” string arg = details.Argument; if ((arg.Split('+'))[0].Substring(0, 2) == "ok") { // 获取数据 string value = details.UserInput["content"] as string; Debug.WriteLine(arg.Substring(2)); if (value != "") { List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>(); paramList.Add(new KeyValuePair<string, string>("article_id", arg.Substring(2))); paramList.Add(new KeyValuePair<string, string>("type_id", "5")); paramList.Add(new KeyValuePair<string, string>("stuNum", stuNum)); paramList.Add(new KeyValuePair<string, string>("idNum", idNum)); paramList.Add(new KeyValuePair<string, string>("content", "回复 " + arg.Split('+')[2] + " : " + value)); paramList.Add(new KeyValuePair<string, string>("answer_user_id", arg.Split('+')[1])); string sendMark = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/ArticleRemark/postremarks", paramList); Debug.WriteLine(sendMark); try { if (sendMark != "") { JObject obj = JObject.Parse(sendMark); if (Int32.Parse(obj["state"].ToString()) == 200) { Utils.Toast("评论成功"); } else { Utils.Toast("评论失败"); } } else { Utils.Toast("评论失败"); } } catch (Exception) { } } } deferral.Complete(); } } }
/// <summary> /// 在此页将要在 Frame 中显示时进行调用。 /// </summary> /// <param name="e">描述如何访问此页的事件数据。 /// 此参数通常用于配置页。</param> protected override void OnNavigatedTo(NavigationEventArgs e) { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); //URLTextBlock.Text = "http://hongyan.cqupt.edu.cn/api/kebiao_ics?xh=" + appSetting.Values["stuNum"].ToString(); URLTextBlock.Text = "http://hongyan.cqupt.edu.cn/api/kebiao_ics?xh=" + credentialList[0].UserName; UmengSDK.UmengAnalytics.TrackPageStart("ImportKB2CalendarPage"); }
public static async Task<List<MyFeed>> GetMyFeeds(string stunum_other,int page = 0, int size = 15) { //TODO:未登陆时 不传入参数stuNum和idNum return await Task.Run(async () => { List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>(); try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (credentialList.Count > 0) { //paramList.Add(new KeyValuePair<string, string>("stuNum", appSetting.Values["stuNum"].ToString())); //paramList.Add(new KeyValuePair<string, string>("idNum", appSetting.Values["idNum"].ToString())); paramList.Add(new KeyValuePair<string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair<string, string>("idNum", credentialList[0].Password)); } } catch { } paramList.Add(new KeyValuePair<string, string>("page", page.ToString())); paramList.Add(new KeyValuePair<string, string>("size", size.ToString())); paramList.Add(new KeyValuePair<string, string>("stunum_other", stunum_other.ToString())); //string response = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/Article/searchtrends", paramList); string response = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/NewArticle/searchtrends", paramList); Debug.WriteLine(response); List<MyFeed> feeds = new List<MyFeed>(); try { if (response != "" || response != "[]") { JObject bbddfeeds = JObject.Parse(response); if (bbddfeeds["status"].ToString() == "200") { JArray bbddarray = JArray.Parse(bbddfeeds["data"].ToString()); for (int i = 0; i < bbddarray.Count; i++) { MyFeed f = new MyFeed(); f.GetAttributes((JObject)bbddarray[i]); feeds.Add(f); } } } } catch (Exception) { } return feeds; }); return null; }
public PersonalIno() { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); appSetting = ApplicationData.Current.LocalSettings; //本地存储 //this.Stunum = appSetting.Values["stuNum"].ToString(); this.Stunum = credentialList[0].UserName; this.Name = appSetting.Values["name"].ToString(); this.Classnum = appSetting.Values["classNum"].ToString(); this.Major = appSetting.Values["major"].ToString(); this.College = appSetting.Values["college"].ToString(); this.Gender = appSetting.Values["gender"].ToString(); }
public static async Task<List<MyNotification>> GetNotifications(int page = 0, int size = 15) { return await Task.Run(async () => { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>(); //paramList.Add(new KeyValuePair<string, string>("stuNum", appSetting.Values["stuNum"].ToString())); //paramList.Add(new KeyValuePair<string, string>("idNum", appSetting.Values["idNum"].ToString())); paramList.Add(new KeyValuePair<string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair<string, string>("idNum", credentialList[0].Password)); paramList.Add(new KeyValuePair<string, string>("page", page.ToString())); paramList.Add(new KeyValuePair<string, string>("size", size.ToString())); string response = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/Article/aboutme", paramList); //response = Utils.ConvertUnicodeStringToChinese(response); Debug.WriteLine(response); List<MyNotification> feeds = new List<MyNotification>(); try { if (response != "" || response != "[]") { JObject bbddfeeds = JObject.Parse(response); if (bbddfeeds["status"].ToString() == "200") { JArray bbddarray = JArray.Parse(bbddfeeds["data"].ToString()); for (int i = 0; i < bbddarray.Count; i++) { MyNotification f = new MyNotification(); f.GetAttributes((JObject)bbddarray[i]); feeds.Add(f); } } if (page == 0) //将第一面的数据存入文件,用于后台任务 { IStorageFolder applicationFolder = ApplicationData.Current.LocalFolder; IStorageFile storageFileWR = await applicationFolder.CreateFileAsync("aboutme.txt", CreationCollisionOption.ReplaceExisting); await FileIO.WriteTextAsync(storageFileWR, response); } } } catch (Exception) { } return feeds; }); return null; }
public async void Run(IBackgroundTaskInstance taskInstance) { try { Debug.WriteLine("开始动态磁贴后台任务"); //获取参数列表 var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); stuNum = credentialList[0].UserName; idNum = credentialList[0].Password; curriculumParamList.Add(new KeyValuePair<string, string>("stuNum", stuNum)); transactionParamList.Add(new KeyValuePair<string, string>("stuNum", stuNum)); transactionParamList.Add(new KeyValuePair<string, string>("idNum", idNum)); //异步后台任务开始 BackgroundTaskDeferral deferral = taskInstance.GetDeferral(); #region 获取课表 string curriculumTemp1 = await NetWork.getCurriculum(@"redapi2/api/kebiao", curriculumParamList); JObject jObject1 = (JObject)JsonConvert.DeserializeObject(curriculumTemp1); string curriculumTemp2 = jObject1["data"].ToString(); JArray jArray1 = (JArray)JsonConvert.DeserializeObject(curriculumTemp2); int nowWeek = int.Parse(jObject1["nowWeek"].ToString()); List<ClassList> tempList1 = JsonConvert.DeserializeObject<List<ClassList>>(jArray1.ToString()); #endregion #region 获取事项 string transactionTemp1 = await NetWork.getTransaction(@"http://hongyan.cqupt.edu.cn/cyxbsMobile/index.php/Home/Person/getTransaction", transactionParamList); JObject jObject2 = (JObject)JsonConvert.DeserializeObject(transactionTemp1); string transactionTemp2 = jObject2["data"].ToString(); JArray jArray2 = (JArray)JsonConvert.DeserializeObject(transactionTemp2); List<Transaction> tempList2 = JsonConvert.DeserializeObject<List<Transaction>>(jArray2.ToString()); #endregion //获取当地星期 string weekDay = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(DateTime.Now.DayOfWeek); Util.UpdateTile(tempList1, tempList2, nowWeek, weekDay); deferral.Complete(); //异步后台任务结束 Debug.WriteLine("结束动态磁贴后台任务"); } catch (Exception) { Debug.WriteLine("动态磁贴后台任务出现异常"); } }
//private ObservableCollection<uIdList> muIdList = new ObservableCollection<uIdList>(); public SearchFreeTimeNumPage() { appSetting = ApplicationData.Current.LocalSettings; //本地存储 this.InitializeComponent(); //HubSectionKBNum.Text = appSetting.Values["nowWeek"].ToString(); appSetting.Values["FreeWeek"] = appSetting.Values["nowWeek"]; this.SizeChanged += (s, e) => { //uIdListView.Height = e.NewSize.Height - 20 - 40; }; //SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested; //TODO:未登陆时 不能自动添加自己的信息 try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); //if (App.muIdList.Count == 0&&appSetting.Values.ContainsKey("idNum")) if (App.muIdList.Count == 0 && credentialList.Count > 0) //App.muIdList.Add(new uIdList { uId = appSetting.Values["stuNum"].ToString(), uName = appSetting.Values["name"].ToString() }); App.muIdList.Add(new uIdList { uId = credentialList[0].UserName, uName = appSetting.Values["name"].ToString() }); } catch { } }
private ApplicationDataContainer appSetting = ApplicationData.Current.LocalSettings; //本地存储 public async void Run(IBackgroundTaskInstance taskInstance) { if (bool.Parse(appSetting.Values["isUseingBackgroundTask"].ToString())) { Debug.WriteLine("开始吐司通知后台任务"); var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); stuNum = credentialList[0].UserName; idNum = credentialList[0].Password; try { string letterstatus = ""; BackgroundTaskDeferral deferral = taskInstance.GetDeferral(); //获取 BackgroundTaskDeferral 对象,表示后台任务延期 List <KeyValuePair <String, String> > paramList = new List <KeyValuePair <String, String> >(); paramList.Add(new KeyValuePair <string, string>("stuNum", stuNum)); paramList.Add(new KeyValuePair <string, string>("idNum", idNum)); paramList.Add(new KeyValuePair <string, string>("page", "0")); paramList.Add(new KeyValuePair <string, string>("size", "15")); letterstatus = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/Article/aboutme", paramList); Debug.WriteLine("letterstatus" + letterstatus); if (letterstatus != "") { string aboutme = ""; IStorageFolder applicationFolder = ApplicationData.Current.LocalFolder; try { IStorageFile storageFileRE = await applicationFolder.GetFileAsync("aboutme.txt"); IRandomAccessStream accessStream = await storageFileRE.OpenReadAsync(); using (StreamReader streamReader = new StreamReader(accessStream.AsStreamForRead((int)accessStream.Size))) { aboutme = streamReader.ReadToEnd(); } Debug.WriteLine("aboutme:" + aboutme); if (aboutme != letterstatus) { JObject obj = JObject.Parse(letterstatus); if (Int32.Parse(obj["status"].ToString()) == 200) { JArray jArray = (JArray)JsonConvert.DeserializeObject(obj["data"].ToString()); if (jArray[0]["type"].ToString() == "praise") { Utils.Toast(jArray[0]["nickname"].ToString() + "赞了你~~\n你可能还有有新的消息,快来看看吧"); } else if (jArray[0]["type"].ToString() == "remark") { Utils.actionsToast(jArray[0]["nickname"].ToString() + " 评论了 " + "\"" + jArray[0]["article_content"].ToString() + "\"", "\"" + jArray[0]["content"].ToString() + "\"", jArray[0]["article_id"].ToString() + "+" + jArray[0]["stunum"] + "+" + jArray[0]["nickname"]); //if (jArray[0]["content"].ToString().Length > 20) //{ // Utils.Toast(jArray[0]["nickname"].ToString() + "评论了你~\n" + "\"" + jArray[0]["content"].ToString().Substring(0, 20) + "\"" + "\n你可能还有有新的消息,快来看看吧"); //} //else //{ // Utils.Toast(jArray[0]["nickname"].ToString() + "评论了你~\n" + "\"" + jArray[0]["content"].ToString() + "\"" + "\n你可能还有有新的消息,快来看看吧"); //} } else { Utils.Toast("你可能有新的消息,快来看看吧"); } } IStorageFile storageFileWR = await applicationFolder.CreateFileAsync("aboutme.txt", CreationCollisionOption.ReplaceExisting); await FileIO.WriteTextAsync(storageFileWR, letterstatus); } } catch (FileNotFoundException) { IStorageFile storageFileWR = await applicationFolder.CreateFileAsync("aboutme.txt", CreationCollisionOption.ReplaceExisting); await FileIO.WriteTextAsync(storageFileWR, letterstatus); } } deferral.Complete(); //所有的异步调用完成之后,释放延期,表示后台任务的完成 Debug.WriteLine("吐司通知后台任务结束"); } catch (Exception) { Debug.WriteLine("吐司通知后台任务异常"); } } }
private bool GetCredentials() { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialsLoaded = true; try { var allCreds = vault.FindAllByResource("BuildLight"); var credential = allCreds.FirstOrDefault(); if (credential != null) { credential.RetrievePassword(); Settings.Username = credential.UserName; Settings.Password = credential.Password; } else { credentialsLoaded = false; } } catch (Exception ex) { credentialsLoaded = false; Telemetry.TrackError(ex); } return credentialsLoaded; }
private async void sendMarkButton_Click(object sender, RoutedEventArgs e) { //TODO:未登陆时 不能发表评论 sendMarkButton.IsEnabled = false; sendMarkProgressRing.Visibility = Visibility.Visible; string id = ""; string type_id = ""; if (ViewModel.Item != null) { id = ViewModel.Item.id; type_id = ViewModel.Item.type_id; } else { type_id = "5"; id = (ee.Parameter as MyNotification).article_id; } var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); List <KeyValuePair <String, String> > paramList = new List <KeyValuePair <String, String> >(); paramList.Add(new KeyValuePair <string, string>("article_id", id)); paramList.Add(new KeyValuePair <string, string>("type_id", type_id)); //paramList.Add(new KeyValuePair<string, string>("stuNum", appSetting.Values["stuNum"].ToString())); //paramList.Add(new KeyValuePair<string, string>("idNum", appSetting.Values["idNum"].ToString())); paramList.Add(new KeyValuePair <string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair <string, string>("idNum", credentialList[0].Password)); paramList.Add(new KeyValuePair <string, string>("content", sendMarkTextBox.Text)); paramList.Add(new KeyValuePair <string, string>("answer_user_id", Mark2PeoNum)); string sendMark = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/ArticleRemark/postremarks", paramList); Debug.WriteLine(sendMark); try { if (sendMark != "") { JObject obj = JObject.Parse(sendMark); if (Int32.Parse(obj["state"].ToString()) == 200) { Utils.Toast("评论成功"); issend = true; markList.Clear(); remarkPage = 0; sendMarkTextBox.Text = ""; getMark(); } else { Utils.Toast("评论失败"); } } else { Utils.Toast("评论失败"); } sendMarkProgressRing.Visibility = Visibility.Collapsed; } catch (Exception) { } }
private async void initExam() { string exam = ""; List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>(); var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); //await Utils.ShowSystemTrayAsync(Color.FromArgb(255, 2, 140, 253), Colors.White, text: "正在紧张安排考试...", isIndeterminate: true); //TODO:未登陆时 没有考试/补考信息 if (IsExamOrRe == 2) { //paramList.Add(new KeyValuePair<string, string>("stuNum", appSetting.Values["stuNum"].ToString())); //paramList.Add(new KeyValuePair<string, string>("idNum", appSetting.Values["idNum"].ToString())); paramList.Add(new KeyValuePair<string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair<string, string>("idNum", credentialList[0].Password)); exam = await NetWork.getHttpWebRequest("api/examSchedule", paramList); } else if (IsExamOrRe == 3) { #if DEBUG paramList.Add(new KeyValuePair<string, string>("stu", "2014214136")); #else //paramList.Add(new KeyValuePair<string, string>("stu", appSetting.Values["stuNum"].ToString())); paramList.Add(new KeyValuePair<string, string>("stu", credentialList[0].UserName)); #endif exam = await NetWork.getHttpWebRequest("examapi/index.php", paramList); } Debug.WriteLine("exam->" + exam); if (exam != "") { try { JObject obj = JObject.Parse(exam); if (Int32.Parse(obj["status"].ToString()) == 200) { List<ExamList> examList = new List<ExamList>(); JArray ExamListArray = Utils.ReadJso(exam); for (int i = 0; i < ExamListArray.Count; i++) { ExamList examitem = new ExamList(); examitem.GetAttribute((JObject)ExamListArray[i]); if (IsExamOrRe == 2) examitem.DateTime = "第" + examitem.Week + "周周" + examitem.Weekday + "\r\n" + examitem.Begin_time + "-" + examitem.End_time; else if (IsExamOrRe == 3) examitem.DateTime = "日期:" + examitem.Date + "\r\n" + "时间:" + examitem.Time; examList.Add(examitem); } examList = examList.OrderBy(x => x.DateTime).ToList(); var nonzeroweek = from x in examList where x.Begin_time=="待定" select x;// examList.Select(x => !x.DateTime.Contains("周0")).ToList(); var zeroweek = from x in examList where x.Begin_time!="待定" select x;// examList.Select(x => x.DateTime.Contains("周0")); List<ExamList> orderedlist = new List<ExamList>(); orderedlist.AddRange(zeroweek); orderedlist.AddRange(nonzeroweek); ObservableCollection<ExamList> move = new ObservableCollection<ExamList>(); ExamListView.ItemsSource = move; for (int i = 0; i < orderedlist.Count; i++) { move.Add(orderedlist[i]); await Task.Delay(60); } } else if (Int32.Parse(obj["status"].ToString()) == 300) { ListFailedStackPanelTextBlock.Text = "暂无数据,过几天再来看看"; ListFailedStackPanel.Visibility = Visibility.Visible; ListFailedStackPanelImage.Visibility = Visibility.Collapsed; ListFailedStackPanelTextBlock.Visibility = Visibility.Visible; } else if (Int32.Parse(obj["status"].ToString()) == 0) { ListFailedStackPanelTextBlock.Text = "没补考的孩子别瞎点"; ListFailedStackPanel.Visibility = Visibility.Visible; ListFailedStackPanelImage.Visibility = Visibility.Collapsed; ListFailedStackPanelTextBlock.Visibility = Visibility.Visible; } else { ListFailedStackPanelTextBlock.Text = "加载失败,点击重试"; ListFailedStackPanel.Visibility = Visibility.Visible; ListFailedStackPanelImage.Visibility = Visibility.Visible; ListFailedStackPanelTextBlock.Visibility = Visibility.Visible; } } catch (Exception) { Debug.WriteLine("考试信息->解析异常"); ListFailedStackPanelTextBlock.Text = "加载失败,点击重试"; ListFailedStackPanel.Visibility = Visibility.Visible; ListFailedStackPanelImage.Visibility = Visibility.Visible; ListFailedStackPanelTextBlock.Visibility = Visibility.Visible; } } else { ListFailedStackPanelTextBlock.Text = "加载失败,点击重试"; ListFailedStackPanel.Visibility = Visibility.Visible; ListFailedStackPanelImage.Visibility = Visibility.Visible; ListFailedStackPanelTextBlock.Visibility = Visibility.Visible; } //StatusBar statusBar = StatusBar.GetForCurrentView(); //await statusBar.ProgressIndicator.HideAsync(); }
/// <summary> /// Navigate to the Page for the selected <paramref name="listViewItem"/>. /// </summary> /// <param name="sender"></param> /// <param name="listViewItem"></param> private async void NavMenuList_ItemInvoked(object sender, ListViewItem listViewItem) { var item = (NavMenuItem)((NavMenuListView)sender).ItemFromContainer(listViewItem); if (item != null) { if (item.DestPage != null && item.DestPage != this.AppFrame.CurrentSourcePageType) { //appSetting.Values["CommunityPerInfo"] = false; //TODO:未登录时 不能传入社区个人信息和个人信息页信息 谨慎处理 //if (!bool.Parse(appSetting.Values["CommunityPerInfo"].ToString()) && (item.DestPage == typeof(MyPage) || item.DestPage == typeof(CommunityPage))) try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (!bool.Parse(appSetting.Values["CommunityPerInfo"].ToString()) && (item.DestPage == typeof(MyPage))) { if (credentialList.Count > 0) { BackOpacityGrid.Visibility = Visibility.Visible; loadingStackPanel.Visibility = Visibility.Visible; List <KeyValuePair <String, String> > paramList = new List <KeyValuePair <String, String> >(); //paramList.Add(new KeyValuePair<string, string>("stuNum", appSetting.Values["stuNum"].ToString())); //paramList.Add(new KeyValuePair<string, string>("idNum", appSetting.Values["idNum"].ToString())); paramList.Add(new KeyValuePair <string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair <string, string>("idNum", credentialList[0].Password)); string perInfo = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/Person/search", paramList); if (perInfo != "") { JObject jPerInfo = JObject.Parse(perInfo); if (jPerInfo["data"].ToString() == "") { var dig = new MessageDialog("没有完善资料不能登入友谊的小船哟"); var btnOk = new UICommand("马上完善"); dig.Commands.Add(btnOk); var btnCancel = new UICommand("暂时不了"); dig.Commands.Add(btnCancel); var result = await dig.ShowAsync(); if (null != result && result.Label == "马上完善") { Debug.WriteLine("添加信息"); BackOpacityGrid.Visibility = Visibility.Collapsed; loadingStackPanel.Visibility = Visibility.Collapsed; this.AppFrame.Navigate(typeof(SetPersonInfoPage), item.DestPage); } else if (null != result && result.Label == "暂时不了") { BackOpacityGrid.Visibility = Visibility.Collapsed; loadingStackPanel.Visibility = Visibility.Collapsed; } } else { appSetting.Values["CommunityPerInfo"] = true; appSetting.Values["Community_people_id"] = jPerInfo["data"]["id"].ToString(); appSetting.Values["Community_nickname"] = jPerInfo["data"]["nickname"].ToString(); appSetting.Values["Community_headimg_src"] = jPerInfo["data"]["photo_src"].ToString(); appSetting.Values["Community_introduction"] = jPerInfo["data"]["introduction"].ToString(); appSetting.Values["Community_phone"] = jPerInfo["data"]["phone"].ToString(); appSetting.Values["Community_qq"] = jPerInfo["data"]["qq"].ToString(); Debug.WriteLine(appSetting.Values["Community_headimg_src"].ToString()); Debug.WriteLine(jPerInfo["data"]["id"].ToString()); BackOpacityGrid.Visibility = Visibility.Collapsed; loadingStackPanel.Visibility = Visibility.Collapsed; if ((item.DestPage != typeof(MyPage))) { this.AppFrame.Navigate(item.DestPage, item.Arguments); } SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; } } } else { if ((item.DestPage != typeof(MyPage))) { this.AppFrame.Navigate(item.DestPage, item.Arguments); var msgPopup = new Data.loginControl("您还没有登录 不能访问个人中心~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); } else { var msgPopup = new Data.loginControl("您还没有登录 不能访问个人中心~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); } } } else { this.AppFrame.Navigate(item.DestPage, item.Arguments); SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; } } catch { if (!bool.Parse(appSetting.Values["CommunityPerInfo"].ToString()) && (item.DestPage == typeof(MyPage))) { if ((item.DestPage != typeof(MyPage))) { this.AppFrame.Navigate(item.DestPage, item.Arguments); var msgPopup = new Data.loginControl("您还没有登录 不能访问个人中心~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); } else { var msgPopup = new Data.loginControl("您还没有登录 不能访问个人中心~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); } } else { this.AppFrame.Navigate(item.DestPage, item.Arguments); SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; } } } } }
public MainPage() { this.InitializeComponent(); // HamburgerButton.Click += HamburgerButton_Click; this.Loaded += (sender, args) => { Current = this; //然并卵 this.TogglePaneButton.Focus(FocusState.Programmatic); }; //this.AppFrame.Navigate(navlist[0].DestPage, navlist[0].Arguments); if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { Utils.ShowSystemTrayAsync(Color.FromArgb(255, 6, 140, 253), Colors.White); } else if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) { Windows.Phone.UI.Input.HardwareButtons.BackPressed += OnBackPressed; } else { var view = ApplicationView.GetForCurrentView(); view.TitleBar.BackgroundColor = Color.FromArgb(255, 4, 131, 239); view.TitleBar.ButtonBackgroundColor = Color.FromArgb(255, 4, 131, 239); view.TitleBar.ButtonHoverBackgroundColor = Color.FromArgb(255, 2, 126, 231); view.TitleBar.ButtonPressedBackgroundColor = Color.FromArgb(255, 2, 111, 203); } this.SizeChanged += (s, e) => { Debug.WriteLine(e.NewSize.Width); if (e.NewSize.Width >= 400) { RootSplitView.CompactPaneLength = 48; TogglePaneButton.Visibility = Visibility.Visible; TogglePaneLightButton.Visibility = Visibility.Collapsed; App.showpane = true; } else { RootSplitView.CompactPaneLength = 0; TogglePaneButton.Visibility = Visibility.Collapsed; TogglePaneLightButton.Visibility = Visibility.Visible; App.showpane = false; } if (e.NewSize.Height - 96 < navlist.Count * 48) { //高度太小 NavMenuList.Margin = new Thickness(0, 48, 0, 48); } else { NavMenuList.Margin = new Thickness(0, 48, 0, 0); } }; //TODO:未登录时 没有名字 //if (appSetting.Values.ContainsKey("idNum")) try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (credentialList.Count > 0) stuNameTextBlock.Text = appSetting.Values["name"].ToString(); else stuNameTextBlock.Text = "尚未登陆~"; } catch { stuNameTextBlock.Text = "尚未登陆~"; } SystemNavigationManager.GetForCurrentView().BackRequested += SystemNavigationManager_BackRequseted; //如果是在手机上,有实体键,隐藏返回键。 if (ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) { //this.BackButton.Visibility = Visibility.Collapsed; } NavMenuList.ItemsSource = navlist; ActivateWindow(); //NavMenuList.SelectedIndex = 0; var a = DateTime.Now; if (DateTimeOffset.Now < DateTimeOffset.Parse("2016/3/15 00:00:00")) showNotice(); else appSetting.Values.Remove("showNotice"); //TODO:未登录时采用默认头像 //if (appSetting.Values.ContainsKey("idNum")) try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (credentialList.Count > 0) initHeadImage(); } catch { } }
private async void LikeButton_Click(object sender, RoutedEventArgs e) { //TODO:未登陆时 不能点赞 //if (appSetting.Values.ContainsKey("idNum")) try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (credentialList.Count > 0) { var b = sender as Button; string num_id = b.TabIndex.ToString(); Debug.WriteLine(num_id); Debug.WriteLine("id " + num_id.Substring(2)); string like_num = ""; if (ViewModel.BBDD != null) { BBDDFeed bbddfeed = ViewModel.BBDD; if (bbddfeed.is_my_like == "true" || bbddfeed.is_my_like == "True") { like_num = await CommunityFeedsService.setPraise(bbddfeed.type_id, num_id.Substring(2), false); if (like_num != "") { bbddfeed.like_num = like_num; bbddfeed.is_my_like = "false"; //if (args is HotFeed) //{ // HotFeed h = args as HotFeed; // h.like_num = like_num; // h.is_my_Like = "false"; //} } } else { like_num = await CommunityFeedsService.setPraise(bbddfeed.type_id, num_id.Substring(2), true); if (like_num != "") { bbddfeed.like_num = like_num; bbddfeed.is_my_like = "true"; //if (args is HotFeed) //{ // HotFeed h = args as HotFeed; // h.like_num = like_num; // h.is_my_Like = "true"; //} } } } if (ViewModel.hotfeed != null) { HotFeed hotfeed = ViewModel.hotfeed; if (hotfeed.is_my_Like == "true" || hotfeed.is_my_Like == "True") { like_num = await CommunityFeedsService.setPraise(hotfeed.type_id, num_id.Substring(2), false); if (like_num != "") { hotfeed.like_num = like_num; hotfeed.is_my_Like = "false"; //if (args is HotFeed) //{ // HotFeed h = args as HotFeed; // h.like_num = like_num; // h.is_my_Like = "false"; //} } } else { like_num = await CommunityFeedsService.setPraise(hotfeed.type_id, num_id.Substring(2), true); if (like_num != "") { hotfeed.like_num = like_num; hotfeed.is_my_Like = "true"; //if (args is HotFeed) //{ // HotFeed h = args as HotFeed; // h.like_num = like_num; // h.is_my_Like = "true"; //} } } } } else { var msgPopup = new Data.loginControl("您还没有登录 无法点赞~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先四处逛一逛~"); }; msgPopup.ShowWIndow(); } } catch { var msgPopup = new Data.loginControl("您还没有登录 无法点赞~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先四处逛一逛~"); }; msgPopup.ShowWIndow(); } }
private async void addArticleAppBarButton_Click(object sender, RoutedEventArgs e) { addArticleAppBarButton.IsEnabled = false; string imgPhoto_src = ""; string imgThumbnail_src = ""; addProgressBar.Visibility = Visibility.Visible; var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (imageList.Count > 1) { int count = 0; if (imageList.Count == 9) { if (imageList[8].imgName != "CommunityAddImg.png") { count = 9; } else { count = 8; } } else { count = imageList.Count - 1; } addProgressBar.IsIndeterminate = false; addProgressBar.Maximum = count; addProgressBar.Value = 0; for (int i = 0; i < count; i++) { try { //string imgUp = await NetWork.headUpload(appSetting.Values["stuNum"].ToString(), imageList[i].imgAppPath, "http://hongyan.cqupt.edu.cn/cyxbsMobile/index.php/Home/Photo/uploadArticle", false); string imgUp = await NetWork.headUpload(credentialList[0].UserName, imageList[i].imgAppPath, "http://hongyan.cqupt.edu.cn/cyxbsMobile/index.php/Home/Photo/uploadArticle", false); if (imgUp != "" && imgUp.IndexOf("Request Entity Too Large") == -1) { JObject obj = JObject.Parse(imgUp); if (Int32.Parse(obj["state"].ToString()) == 200) { string a = obj["data"].ToString(); JObject objdata = JObject.Parse(obj["data"].ToString()); //appSetting.Values["headimgdate"] = objdata["date"].ToString(); imageList[i].imgPhoto_src = objdata["photosrc"].ToString(); imageList[i].imgThumbnail_src = objdata["thumbnail_src"].ToString(); imgPhoto_src += ("," + objdata["photosrc"].ToString()); imgThumbnail_src += ("," + objdata["thumbnail_src"].ToString()); imgPhoto_src = imgPhoto_src.Replace("http://hongyan.cqupt.edu.cn/cyxbsMobile/Public/photo/", ""); imgThumbnail_src = imgThumbnail_src.Replace("http://hongyan.cqupt.edu.cn/cyxbsMobile/Public/photo/thumbnail/", ""); } } else if (imgUp.IndexOf("Request Entity Too Large") != -1) { Debug.WriteLine("第" + (int)(i + 1) + "张图片太大"); Utils.Toast("第" + (int)(i + 1) + "张图片超出4M限制"); addArticleAppBarButton.IsEnabled = true; addProgressBar.Visibility = Visibility.Collapsed; return; } else { Debug.WriteLine("图片上传失败"); Utils.Toast("发表失败"); addArticleAppBarButton.IsEnabled = true; addProgressBar.Visibility = Visibility.Collapsed; return; } addProgressBar.Value += 1; } catch (Exception) { Debug.WriteLine("图片上传失败"); addArticleAppBarButton.IsEnabled = true; addProgressBar.Visibility = Visibility.Collapsed; return; } } try { for (int i = 0; i < count; i++) { StorageFile imgfile = await StorageFile.GetFileFromApplicationUriAsync(new Uri(imageList[i].imgAppPath)); imgfile.DeleteAsync(); } } catch (Exception) { } if (imgPhoto_src != "") { imgPhoto_src = imgPhoto_src.Substring(1); } if (imgThumbnail_src != "") { imgThumbnail_src = imgThumbnail_src.Substring(1); } } addProgressBar.IsIndeterminate = true; List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>(); paramList.Add(new KeyValuePair<string, string>("type_id", "5")); //现在只有哔哔叨叨 paramList.Add(new KeyValuePair<string, string>("title", addContentTextBox.Text)); //paramList.Add(new KeyValuePair<string, string>("user_id", appSetting.Values["Community_people_id"].ToString())); //记得改了 paramList.Add(new KeyValuePair<string, string>("content", addContentTextBox.Text)); paramList.Add(new KeyValuePair<string, string>("photo_src", imgPhoto_src)); paramList.Add(new KeyValuePair<string, string>("thumbnail_src", imgThumbnail_src)); //paramList.Add(new KeyValuePair<string, string>("stuNum", appSetting.Values["stuNum"].ToString())); //paramList.Add(new KeyValuePair<string, string>("idNum", appSetting.Values["idNum"].ToString())); paramList.Add(new KeyValuePair<string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair<string, string>("idNum", credentialList[0].Password)); string ArticleUp = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/Article/addArticle", paramList); Debug.WriteLine(ArticleUp); try { if (ArticleUp != "") { JObject obj = JObject.Parse(ArticleUp); if (Int32.Parse(obj["state"].ToString()) == 200) { Utils.Toast("发表成功"); Frame rootFrame = Window.Current.Content as Frame; //addTitleTextBox.Text = ""; addContentTextBox.Text = ""; if (imageList.Count > 1) { for (int i = 0; i < imageList.Count - 1; i++) { imageList.RemoveAt(i); } } page.Visibility = Visibility.Collapsed; commandbar.Visibility = Visibility.Collapsed; SystemNavigationManager.GetForCurrentView().BackRequested -= App_BackRequested; SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; //ee.Handled = false; //Frame.GoBack(); } } } catch (Exception) { } addArticleAppBarButton.IsEnabled = true; addProgressBar.Visibility = Visibility.Collapsed; }
public async Task RemoveStoredCredential(string username) { var userInfoDb = await GetUserInfoDB(); try { //go find the one we're updating and actually do it var userCredentialsCursor = await userInfoDb.SelectAsync(userInfoDb.GetKeys().First(), "credentials", DBReadFlags.AutoLock); if (userCredentialsCursor != null) { using (userCredentialsCursor) { do { var credential = JsonConvert.DeserializeObject<UserCredential>(userCredentialsCursor.GetString()); if (credential.Username == username) { await userCredentialsCursor.DeleteAsync(); } } while (await userCredentialsCursor.MoveNextAsync()); } } } catch { //let it fail } var passwordVault = new Windows.Security.Credentials.PasswordVault(); try { var windowsCredentials = passwordVault.FindAllByResource("Baconography"); var matchingWindowsCredential = windowsCredentials.FirstOrDefault(windowsCredential => string.Compare(windowsCredential.UserName, username, StringComparison.CurrentCultureIgnoreCase) == 0); if (matchingWindowsCredential != null) { passwordVault.Remove(matchingWindowsCredential); } } catch { } }
/// <summary> /// 在应用程序由最终用户正常启动时进行调用。 /// 将在启动应用程序以打开特定文件等情况下使用。 /// </summary> /// <param name="e">有关启动请求和过程的详细信息。</param> protected async override void OnLaunched(LaunchActivatedEventArgs e) { //#if DEBUG // if (System.Diagnostics.Debugger.IsAttached) // { // this.DebugSettings.EnableFrameRateCounter = true; // } //#endif //UmengAnalytics.IsDebug = true; Frame rootFrame = Window.Current.Content as Frame; // 不要在窗口已包含内容时重复应用程序初始化, // 只需确保窗口处于活动状态 if (rootFrame == null) { // 创建要充当导航上下文的框架,并导航到第一页 rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: 从之前挂起的应用程序加载状态 } // 将框架放在当前窗口中 Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // 当导航堆栈尚未还原时,导航到第一页, // 并通过将所需信息作为导航参数传入来配置 // 参数 #if WINDOWS_PHONE_APP Debug.WriteLine("#if WINDOWS_PHONE_APP"); #endif try { //if (e.Kind == ActivationKind.Launch && (e.Arguments == "/jwzx" || e.Arguments == "/more") && appSetting.Values.ContainsKey("idNum")) var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (e.Kind == ActivationKind.Launch && (e.Arguments == "/jwzx" || e.Arguments == "/more") && credentialList.Count > 0) { if (!rootFrame.Navigate(typeof(MainPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } } else { //if (!appSetting.Values.ContainsKey("idNum")) if (!(credentialList.Count > 0)) { //if (!rootFrame.Navigate(typeof(LoginPage), e.Arguments)) if (!rootFrame.Navigate(typeof(MainPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } Window.Current.Activate(); } else { if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar") && Utils.getPhoneWidth() < 400) { Debug.WriteLine("小于400的Phone" + Utils.getPhoneWidth()); //if (!rootFrame.Navigate(typeof(MainPage_m), e.Arguments)) //{ // throw new Exception("Failed to create initial page"); //} if (!rootFrame.Navigate(typeof(MainPage), "/kb")) { throw new Exception("Failed to create initial page"); } } else { Debug.WriteLine("大于400的phone OR PC"); if (!rootFrame.Navigate(typeof(MainPage), "/kb")) { throw new Exception("Failed to create initial page"); } } } } } catch { if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar") && Utils.getPhoneWidth() < 400) { Debug.WriteLine("小于400的Phone" + Utils.getPhoneWidth()); //if (!rootFrame.Navigate(typeof(MainPage_m), e.Arguments)) //{ // throw new Exception("Failed to create initial page"); //} if (!rootFrame.Navigate(typeof(MainPage), "/kb")) { throw new Exception("Failed to create initial page"); } } else { Debug.WriteLine("大于400的phone OR PC"); if (!rootFrame.Navigate(typeof(MainPage), "/kb")) { throw new Exception("Failed to create initial page"); } } } } // 确保当前窗口处于活动状态 //await UmengAnalytics.StartTrackAsync("55cd8c8be0f55a20ba00440d", "Marketplace_Win10"); //私有 await UmengAnalytics.StartTrackAsync("57317d07e0f55a28fe002bec", "Marketplace_Win10"); //公共 //await InitNotificationsAsync(); ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size { Width = 400, Height = 480 }); }
// Manual Login Activation private async void Login_Click(object sender, RoutedEventArgs e) { // if theres nothing in the password box complain and cancel if (API_password.Password == "" || API_username.Text == "" || API_Mobile.Text == "" || API_Account.Text == "") { // spring up a complaint and then cancel var MessageDialog = new MessageDialog("Please enter valid credentials to log in"); await MessageDialog.ShowAsync(); return; } // configure an API access SIMAPI auth_api_check = new SIMAPI(API_username.Text, API_password.Password, API_Account.Text, API_Mobile.Text); // check if we are authorised bool success = await auth_api_check.CheckAuthAsync(); // if we failed to correctly access the API if (!success) { // spring up a complaint and then cancel var MessageDialog = new MessageDialog("Failed to log in, please try again"); await MessageDialog.ShowAsync(); return; } // otherwise we have succeeded and we can move forwards // store the credentials Constants.API_PASSWORD_STORE = API_password.Password.ToString(); Constants.API_USERNAME_STORE = API_username.Text.ToString(); Constants.API_MOBILE_STORE = API_Mobile.Text.ToString(); Constants.API_ACCOUNT_STORE = API_Account.Text.ToString(); // if remember me is checked // -- save the details to the secure vault overwriting existing ones // -- ensure an app data file exists for it to be checked next time // else // -- delete the appdata file // get the path StorageFolder localFolder = ApplicationData.Current.LocalFolder; string path = localFolder.Path; path += "\\rememberme.txt"; if (Remember_me.IsChecked == true) { var vault = new Windows.Security.Credentials.PasswordVault(); // check if there are already credentials, if so delete all of them (no more than one pls) try { var credentialList = vault.FindAllByResource(Constants.vault_resource); if (credentialList.Count > 0) { foreach (Windows.Security.Credentials.PasswordCredential pw in credentialList) { vault.Remove(pw); } } } catch (System.Runtime.InteropServices.COMException q) { // there werent any anyway so it doesnt matter Debug.WriteLine("No credentials need to be deleted - none exist: {0}", q.ToString()); } // save details to secure vault vault.Add(new Windows.Security.Credentials.PasswordCredential(Constants.vault_resource, Constants.API_USERNAME_STORE, Constants.API_PASSWORD_STORE)); // create an appdata file to tick it next time if (!System.IO.File.Exists(path)) { System.IO.File.Create(path); } } else { // delete the appdata file to tick it next time if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } } Frame parentFrame = Window.Current.Content as Frame; parentFrame.Navigate(typeof(Messages)); }
/// <summary> /// 在应用程序由最终用户正常启动时进行调用。 /// 将在启动应用程序以打开特定文件等情况下使用。 /// </summary> /// <param name="e">有关启动请求和过程的详细信息。</param> protected async override void OnLaunched(LaunchActivatedEventArgs e) { //#if DEBUG // if (System.Diagnostics.Debugger.IsAttached) // { // this.DebugSettings.EnableFrameRateCounter = true; // } //#endif //UmengAnalytics.IsDebug = true; Frame rootFrame = Window.Current.Content as Frame; // 不要在窗口已包含内容时重复应用程序初始化, // 只需确保窗口处于活动状态 if (rootFrame == null) { // 创建要充当导航上下文的框架,并导航到第一页 rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: 从之前挂起的应用程序加载状态 } // 将框架放在当前窗口中 Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // 当导航堆栈尚未还原时,导航到第一页, // 并通过将所需信息作为导航参数传入来配置 // 参数 #if WINDOWS_PHONE_APP Debug.WriteLine("#if WINDOWS_PHONE_APP"); #endif try { //if (e.Kind == ActivationKind.Launch && (e.Arguments == "/jwzx" || e.Arguments == "/more") && appSetting.Values.ContainsKey("idNum")) var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (e.Kind == ActivationKind.Launch && (e.Arguments == "/jwzx" || e.Arguments == "/more") && credentialList.Count > 0) { if (!rootFrame.Navigate(typeof(StartPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } } else { //if (!appSetting.Values.ContainsKey("idNum")) if (!(credentialList.Count > 0)) { //if (!rootFrame.Navigate(typeof(LoginPage), e.Arguments)) if (!rootFrame.Navigate(typeof(StartPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } } else { if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar") && Utils.getPhoneWidth() < 400) { Debug.WriteLine("小于400的Phone" + Utils.getPhoneWidth()); //if (!rootFrame.Navigate(typeof(StartPage_m), e.Arguments)) //{ // throw new Exception("Failed to create initial page"); //} if (!rootFrame.Navigate(typeof(StartPage), "/kb")) { throw new Exception("Failed to create initial page"); } } else { Debug.WriteLine("大于400的phone OR PC"); if (!rootFrame.Navigate(typeof(StartPage), "/kb")) { throw new Exception("Failed to create initial page"); } } } } } catch { if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar") && Utils.getPhoneWidth() < 400) { Debug.WriteLine("小于400的Phone" + Utils.getPhoneWidth()); //if (!rootFrame.Navigate(typeof(StartPage_m), e.Arguments)) //{ // throw new Exception("Failed to create initial page"); //} if (!rootFrame.Navigate(typeof(StartPage), "/kb")) { throw new Exception("Failed to create initial page"); } } else { Debug.WriteLine("大于400的phone OR PC"); if (!rootFrame.Navigate(typeof(StartPage), "/kb")) { throw new Exception("Failed to create initial page"); } } } } Window.Current.Activate(); // 确保当前窗口处于活动状态 //await UmengAnalytics.StartTrackAsync("55cd8c8be0f55a20ba00440d", "Marketplace_Win10"); //私有 await UmengAnalytics.StartTrackAsync("57317d07e0f55a28fe002bec", "Marketplace_Win10"); //公共 //await InitNotificationsAsync(); ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size { Width = 400, Height = 480 }); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="args">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs args) { Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.Style = Resources["RootFrameStyle"] as Style; if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } /* SplashScreen splash = args.SplashScreen; * Splash eSplash = new Splash(splash); * splash.Dismissed += TypedEventHandler<SplashScreen, object>(eSplash.onSplashScreenDismissed); */ // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter try { var vault = new Windows.Security.Credentials.PasswordVault(); var creds = vault.FindAllByResource("VkApp").FirstOrDefault(); if (creds != null) { ApplicationService.Instance.Settings.UserId = creds.UserName; ApplicationService.Instance.Settings.AccessToken = vault.Retrieve("VkApp", ApplicationService.Instance.Settings.UserId).Password; //ApplicationService.Instance.Settings.Save(); ViewModelLocator.AuthService.SetLoginInfoVk(); //Messenger.Default.Send<GoHomeMessage>(new GoHomeMessage()); //((LoginViewModel)DataContext).GoProfileCommand.Execute(null); //Messenger.Default.Send<GoHomeMessage>(new GoHomeMessage()); if (!rootFrame.Navigate(typeof(ProfileViewPage), args.Arguments)) { throw new Exception("Failed to create initial page"); } //Frame.Navigate(typeof(ProfileViewPage)); /* Messenger.Default.Send<NavigateToPageMessage>(new NavigateToPageMessage * { * Page = "/ProfileViewPage" * }); */ } } catch (Exception ex) { if (!rootFrame.Navigate(typeof(LoginView), args.Arguments)) { throw new Exception("Failed to create initial page"); } } } // Ensure the current window is active Window.Current.Activate(); }
/// <summary> /// 获取动态列表 /// </summary> /// <param name="type">动态参数,重邮新闻cyxw=>1,教务咨询jwzx=>2,xsjz=>3,xwgg=>4,bbdd=>5</param> /// <returns>返回参数对应的列表数据</returns> public static async Task <List <BBDDFeed> > GetBBDD(int type = 1, int page = 0, int size = 15, int typeid = 5) { //TODO:未登陆时 不添加参数stuNum和idNum return(await Task.Run(async() => { List <KeyValuePair <String, String> > paramList = new List <KeyValuePair <String, String> >(); try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (credentialList.Count > 0) { //paramList.Add(new KeyValuePair<string, string>("stuNum", appSetting.Values["stuNum"].ToString())); //paramList.Add(new KeyValuePair<string, string>("idNum", appSetting.Values["idNum"].ToString())); paramList.Add(new KeyValuePair <string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair <string, string>("idNum", credentialList[0].Password)); } } catch { } paramList.Add(new KeyValuePair <string, string>("page", page.ToString())); paramList.Add(new KeyValuePair <string, string>("size", size.ToString())); if (typeid != 0) { paramList.Add(new KeyValuePair <string, string>("type_id", typeid.ToString())); } string response = await NetWork.getHttpWebRequest(feedsapi[type], paramList); //response = Utils.ConvertUnicodeStringToChinese(response); List <BBDDFeed> feeds = new List <BBDDFeed>(); try { if (response != "" || response != "[]") { JObject bbddfeeds = JObject.Parse(response); if (bbddfeeds["status"].ToString() == "200") { JArray bbddarray = JArray.Parse(bbddfeeds["data"].ToString()); for (int i = 0; i < bbddarray.Count; i++) { BBDDFeed f = new BBDDFeed(); f.GetAttributes((JObject)bbddarray[i]); feeds.Add(f); } } } } catch (Exception) { } return feeds; })); /* try * { * JArray jsonstr = JArray.Parse(response); * * List<BBDDFeed> feedslist = new List<BBDDFeed>(); * * for (int j = 0; j < jsonstr.Count; j++) * { * JObject jsondetail = (JObject)(jsonstr[j]); * if (jsondetail["status"].ToString() == "200") * { * JObject jo = (JObject)jsondetail["data"]; * BBDDFeed f = new BBDDFeed(); * f.GetAttributes(jo); * feedslist.Add(f); * } * } * return feedslist; * } * catch (Newtonsoft.Json.JsonReaderException) * { * List<BBDDFeed> feedslist = new List<BBDDFeed>(); * JObject jsonobj = JObject.Parse(response); * if (jsonobj["status"].ToString() == "200") * { * string jsonstr = jsonobj["data"].ToString(); * JArray feedsarray = Utils.ReadJso(response); * for (int i = 0; i < feedsarray.Count; i++) * { * JObject f = (JObject)feedsarray[i]; * BBDDFeed fd = new BBDDFeed(); * fd.GetAttributes(f); * feedslist.Add(fd); * } * return feedslist; * } * } * catch (InvalidCastException e) * { * Debug.WriteLine(e.Message); * } */ return(null); }
private async void initHeadImage() { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>(); //paramList.Add(new KeyValuePair<string, string>("stuNum", appSetting.Values["stuNum"].ToString())); //paramList.Add(new KeyValuePair<string, string>("idNum", appSetting.Values["idNum"].ToString())); paramList.Add(new KeyValuePair<string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair<string, string>("idNum", credentialList[0].Password)); string headimg = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/Person/search", paramList); if (headimg != "") { try { JObject obj = JObject.Parse(headimg); if (Int32.Parse(obj["status"].ToString()) == 200) { if (obj["data"].ToString() != "") { string a = obj["data"].ToString(); JObject objdata = JObject.Parse(obj["data"].ToString()); headimgImageBrush.ImageSource = new BitmapImage(new Uri(objdata["photo_src"].ToString())); appSetting.Values["Community_headimg_src"] = objdata["photo_src"].ToString(); Size downloadSize = new Size(48, 48); await Utils.DownloadAndScale("headimg.png", objdata["photo_src"].ToString(), new Size(100, 100)); } } } catch (Exception) { Debug.WriteLine("头像下载失败"); } } else { try { appSetting.Values["Community_headimg_src"] = ""; IStorageFolder applicationFolder = ApplicationData.Current.LocalFolder; IStorageFile storageFileRE = await applicationFolder.GetFileAsync("headimg.png"); headimgImageBrush.ImageSource = new BitmapImage(new Uri(storageFileRE.Path)); } catch (Exception) { Debug.WriteLine("缓存头像文件不存在"); } } }
private void AddOrUpdateWindowsCredential(UserCredential existingCredential, string password) { var passwordVault = new Windows.Security.Credentials.PasswordVault(); try { var windowsCredentials = passwordVault.FindAllByResource("Baconography"); var matchingWindowsCredential = windowsCredentials.FirstOrDefault(credential => string.Compare(credential.UserName, existingCredential.Username, StringComparison.CurrentCultureIgnoreCase) == 0); if (matchingWindowsCredential != null) { matchingWindowsCredential.RetrievePassword(); if (matchingWindowsCredential.Password != password) { passwordVault.Remove(matchingWindowsCredential); } else passwordVault.Add(new Windows.Security.Credentials.PasswordCredential("Baconography", existingCredential.Username, password)); } else passwordVault.Add(new Windows.Security.Credentials.PasswordCredential("Baconography", existingCredential.Username, password)); } catch { passwordVault.Add(new Windows.Security.Credentials.PasswordCredential("Baconography", existingCredential.Username, password)); } }
//TODO:未登录时不能选择上传头像 private async void headimgRectangle_Tapped(object sender, TappedRoutedEventArgs e) { //if (appSetting.Values.ContainsKey("idNum")) try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (credentialList.Count > 0) { FileOpenPicker openPicker = new FileOpenPicker(); openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; openPicker.FileTypeFilter.Add(".png"); openPicker.FileTypeFilter.Add(".jpg"); openPicker.FileTypeFilter.Add(".bmp"); openPicker.FileTypeFilter.Add(".gif"); openPicker.ContinuationData["Operation"] = "img"; StorageFile file = await openPicker.PickSingleFileAsync(); if (file != null) { ClipHeadGrid.Visibility = Visibility.Visible; BackOpacityGrid.Visibility = Visibility.Visible; SoftwareBitmap sb = null; using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read)) { // Create the decoder from the stream BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream); // Get the SoftwareBitmap representation of the file SoftwareBitmap softwareBitmap = await decoder.GetSoftwareBitmapAsync(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied); sb = softwareBitmap; // return softwareBitmap; } SoftwareBitmapSource source = new SoftwareBitmapSource(); await source.SetBitmapAsync(sb); headImage.Source = source; } } else { var msgPopup = new Data.loginControl("您还没有登录 不能上传头像哦~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); } } catch { var msgPopup = new Data.loginControl("您还没有登录 不能上传头像哦~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); } }
private async Task<User> LoginWithCredentials(UserCredential credential) { if (await _redditService.CheckLogin(credential.LoginCookie)) { var loggedInUser = new User { Username = credential.Username, LoginCookie = credential.LoginCookie, NeedsCaptcha = false }; loggedInUser.Me = await _redditService.GetMe(loggedInUser); return loggedInUser; } else { //we dont currently posses a valid login cookie, see if windows has a stored credential we can use for this username var passwordVault = new Windows.Security.Credentials.PasswordVault(); try { var windowsCredentials = passwordVault.FindAllByResource("Baconography"); var matchingWindowsCredential = windowsCredentials.FirstOrDefault(windowsCredential => string.Compare(windowsCredential.UserName, credential.Username, StringComparison.CurrentCultureIgnoreCase) == 0); if (matchingWindowsCredential != null) { matchingWindowsCredential.RetrievePassword(); return await _redditService.Login(matchingWindowsCredential.UserName, matchingWindowsCredential.Password); } } catch { } } return null; }
private async void initExam() { string exam = ""; List <KeyValuePair <String, String> > paramList = new List <KeyValuePair <String, String> >(); var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); //await Utils.ShowSystemTrayAsync(Color.FromArgb(255, 2, 140, 253), Colors.White, text: "正在紧张安排考试...", isIndeterminate: true); //TODO:未登陆时 没有考试/补考信息 if (IsExamOrRe == 2) { //paramList.Add(new KeyValuePair<string, string>("stuNum", appSetting.Values["stuNum"].ToString())); //paramList.Add(new KeyValuePair<string, string>("idNum", appSetting.Values["idNum"].ToString())); paramList.Add(new KeyValuePair <string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair <string, string>("idNum", credentialList[0].Password)); exam = await NetWork.getHttpWebRequest("api/examSchedule", paramList); } else if (IsExamOrRe == 3) { #if DEBUG paramList.Add(new KeyValuePair <string, string>("stu", "2014214136")); #else //paramList.Add(new KeyValuePair<string, string>("stu", appSetting.Values["stuNum"].ToString())); paramList.Add(new KeyValuePair <string, string>("stu", credentialList[0].UserName)); #endif exam = await NetWork.getHttpWebRequest("examapi/index.php", paramList); } Debug.WriteLine("exam->" + exam); if (exam != "") { try { JObject obj = JObject.Parse(exam); if (Int32.Parse(obj["status"].ToString()) == 200) { List <ExamList> examList = new List <ExamList>(); JArray ExamListArray = Utils.ReadJso(exam); for (int i = 0; i < ExamListArray.Count; i++) { ExamList examitem = new ExamList(); examitem.GetAttribute((JObject)ExamListArray[i]); if (IsExamOrRe == 2) { examitem.DateTime = "第" + examitem.Week + "周周" + examitem.Weekday + "\r\n" + examitem.Begin_time + "-" + examitem.End_time; } else if (IsExamOrRe == 3) { examitem.DateTime = "日期:" + examitem.Date + "\r\n" + "时间:" + examitem.Time; } examList.Add(examitem); } examList = examList.OrderBy(x => x.DateTime).ToList(); var nonzeroweek = from x in examList where x.Begin_time == "待定" select x; // examList.Select(x => !x.DateTime.Contains("周0")).ToList(); var zeroweek = from x in examList where x.Begin_time != "待定" select x; // examList.Select(x => x.DateTime.Contains("周0")); List <ExamList> orderedlist = new List <ExamList>(); orderedlist.AddRange(zeroweek); orderedlist.AddRange(nonzeroweek); ObservableCollection <ExamList> move = new ObservableCollection <ExamList>(); ExamListView.ItemsSource = move; for (int i = 0; i < orderedlist.Count; i++) { move.Add(orderedlist[i]); await Task.Delay(60); } } else if (Int32.Parse(obj["status"].ToString()) == 300) { ListFailedStackPanelTextBlock.Text = "暂无数据,过几天再来看看"; ListFailedStackPanel.Visibility = Visibility.Visible; ListFailedStackPanelImage.Visibility = Visibility.Collapsed; ListFailedStackPanelTextBlock.Visibility = Visibility.Visible; } else if (Int32.Parse(obj["status"].ToString()) == 0) { ListFailedStackPanelTextBlock.Text = "没补考的孩子别瞎点"; ListFailedStackPanel.Visibility = Visibility.Visible; ListFailedStackPanelImage.Visibility = Visibility.Collapsed; ListFailedStackPanelTextBlock.Visibility = Visibility.Visible; } else { ListFailedStackPanelTextBlock.Text = "加载失败,点击重试"; ListFailedStackPanel.Visibility = Visibility.Visible; ListFailedStackPanelImage.Visibility = Visibility.Visible; ListFailedStackPanelTextBlock.Visibility = Visibility.Visible; } } catch (Exception) { Debug.WriteLine("考试信息->解析异常"); ListFailedStackPanelTextBlock.Text = "加载失败,点击重试"; ListFailedStackPanel.Visibility = Visibility.Visible; ListFailedStackPanelImage.Visibility = Visibility.Visible; ListFailedStackPanelTextBlock.Visibility = Visibility.Visible; } } else { ListFailedStackPanelTextBlock.Text = "加载失败,点击重试"; ListFailedStackPanel.Visibility = Visibility.Visible; ListFailedStackPanelImage.Visibility = Visibility.Visible; ListFailedStackPanelTextBlock.Visibility = Visibility.Visible; } //StatusBar statusBar = StatusBar.GetForCurrentView(); //await statusBar.ProgressIndicator.HideAsync(); }
private async void publishBtn_Click(object sender, RoutedEventArgs e) { if (typeTb.Text != "" && DescribeBox.Text != "" && timebox.Text != "" && addressBox.Text != "") { if (telBox.Text == "" && qqbox.Text == "") { Utils.Message("请至少输入一个联系方式"); } else { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); //TODO:post string property = ""; if (islost) { property = "寻物启事"; } else { property = "失物招领"; } List <KeyValuePair <String, String> > paramList = new List <KeyValuePair <String, String> >(); paramList.Add(new KeyValuePair <string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair <string, string>("idNum", credentialList[0].Password)); paramList.Add(new KeyValuePair <string, string>("property", property)); paramList.Add(new KeyValuePair <string, string>("category", typeTb.Text)); paramList.Add(new KeyValuePair <string, string>("detail", DescribeBox.Text)); paramList.Add(new KeyValuePair <string, string>("pickTime", timebox.Text)); paramList.Add(new KeyValuePair <string, string>("place", addressBox.Text)); if (telBox.Text == "") { paramList.Add(new KeyValuePair <string, string>("qq", qqbox.Text)); } else if (qqbox.Text == "") { paramList.Add(new KeyValuePair <string, string>("phone", telBox.Text)); } else { paramList.Add(new KeyValuePair <string, string>("phone", telBox.Text)); paramList.Add(new KeyValuePair <string, string>("qq", qqbox.Text)); } string postup = await NetWork.getHttpWebRequest("laf/api/create", paramList); if (postup != "") { JObject obj = JObject.Parse(postup); if (obj["state"].ToString() == "成功添加失物招领信息") { Utils.Message("发表成功 青协审核后将发布在失物招领中~"); } else { Utils.Message(obj["state"].ToString()); } } } } else { Utils.Message("请完善信息"); } }
private async void sendMarkButton_Click(object sender, RoutedEventArgs e) { try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (credentialList.Count > 0) { sendMarkButton.IsEnabled = false; sendMarkProgressRing.Visibility = Visibility.Visible; string id = ""; string type_id = ""; id = al[0].article_id.ToString(); type_id = "7"; List <KeyValuePair <String, String> > paramList = new List <KeyValuePair <String, String> >(); paramList.Add(new KeyValuePair <string, string>("article_id", id)); paramList.Add(new KeyValuePair <string, string>("type_id", type_id)); paramList.Add(new KeyValuePair <string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair <string, string>("idNum", credentialList[0].Password)); paramList.Add(new KeyValuePair <string, string>("content", sendMarkTextBox.Text)); paramList.Add(new KeyValuePair <string, string>("answer_user_id", "0")); string sendMark = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/ArticleRemark/postremarks", paramList); Debug.WriteLine(sendMark); try { if (sendMark != "") { JObject obj = JObject.Parse(sendMark); if (Int32.Parse(obj["state"].ToString()) == 200) { Utils.Toast("评论成功"); sendMarkTextBox.Text = ""; rl.Clear(); GetRemark(); int temp = int.Parse(al[0].remark_num); al[0].remark_num = (++temp).ToString(); } else { Utils.Toast("评论失败"); } } else { Utils.Toast("评论失败"); } sendMarkProgressRing.Visibility = Visibility.Collapsed; } catch (Exception) { } } else { var msgPopup = new Data.loginControl("您还没有登录 无法评论帖子~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先四处逛一逛~"); }; msgPopup.ShowWIndow(); } } catch { var msgPopup = new Data.loginControl("您还没有登录 无法评论帖子~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先四处逛一逛~"); }; msgPopup.ShowWIndow(); } }
/// <summary> /// 课表网络请求 /// </summary> /// <param name="isRefresh"> 是否为刷新</param> private async void initKB(bool isRefresh = false) { //if (stuNum == appSetting.Values["stuNum"].ToString() && !isRefresh) try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (stuNum == credentialList[0].UserName && !isRefresh) { try { IStorageFolder applicationFolder = ApplicationData.Current.LocalFolder; IStorageFile storageFileRE = await applicationFolder.GetFileAsync("kb"); IRandomAccessStream accessStream = await storageFileRE.OpenReadAsync(); using (StreamReader streamReader = new StreamReader(accessStream.AsStreamForRead((int)accessStream.Size))) { kb = streamReader.ReadToEnd(); } HubSectionKBNum.Text = "第" + appSetting.Values["nowWeek"].ToString() + "周"; showKB(2); } catch (Exception) { Debug.WriteLine("主页->课表数据缓存异常"); } } //if (stuNum == appSetting.Values["stuNum"].ToString()) if (stuNum == credentialList[0].UserName) { HubSectionKBTitle.Text = "我的课表"; HubSectionKBTitle.FontSize = 35; } } catch { } await Utils.ShowSystemTrayAsync(Color.FromArgb(255, 2, 140, 253), Colors.White, text: "课表刷新中...", isIndeterminate: true); List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>(); paramList.Add(new KeyValuePair<string, string>("stuNum", stuNum)); string kbtemp = await NetWork.getHttpWebRequest("redapi2/api/kebiao", paramList); //新 //string kbtemp = await NetWork.getHttpWebRequest("api/kebiao", paramList); //旧 if (!appSetting.Values.ContainsKey("HttpTime")) appSetting.Values["HttpTime"] = DateTimeOffset.Now.ToString(); if (kbtemp != "") { kb = kbtemp; Debug.WriteLine("DateTimeOffset.Now.ToString()" + DateTimeOffset.Now.ToString()); appSetting.Values["HttpTime"] = DateTimeOffset.Now.Year.ToString() + "/" + DateTimeOffset.Now.Month.ToString() + "/" + DateTimeOffset.Now.Day.ToString(); } Debug.WriteLine("kb->" + kb); if (kb != "") { JObject obj = JObject.Parse(kb); if (Int32.Parse(obj["status"].ToString()) == 200) { IStorageFile storageFileWR = await applicationFolder.CreateFileAsync("kb", CreationCollisionOption.OpenIfExists); try { await FileIO.WriteTextAsync(storageFileWR, kb); } catch (Exception) { Debug.WriteLine("主页 -> 课表缓存,读取异常"); } //保存当前星期 if (kbtemp == "") { Debug.WriteLine(appSetting.Values["HttpTime"].ToString()); DateTimeOffset d = DateTimeOffset.Parse(appSetting.Values["HttpTime"].ToString()); int httpweekday = (Int16)DateTimeOffset.Parse(appSetting.Values["HttpTime"].ToString()).DayOfWeek == 0 ? 7 : (Int16)DateTimeOffset.Parse(appSetting.Values["HttpTime"].ToString()).DayOfWeek; Debug.WriteLine((DateTimeOffset.Now - DateTimeOffset.Parse(appSetting.Values["HttpTime"].ToString())).TotalDays); double weekday = (DateTimeOffset.Now - DateTimeOffset.Parse(appSetting.Values["HttpTime"].ToString())).TotalDays - (7 - httpweekday); Debug.WriteLine("weekday_前" + weekday); //if (weekday % ((Int16)weekday) > 0 || weekday > 0 && weekday < 1) // weekday = (Int16)weekday + 1; weekday = (Int16)weekday; Debug.WriteLine("weekday_后" + weekday); if (weekday > 0) appSetting.Values["nowWeek"] = Int16.Parse(obj["nowWeek"].ToString()) + (Int16)(weekday + 6) / 7; else appSetting.Values["nowWeek"] = obj["nowWeek"].ToString(); Debug.WriteLine(" appSetting.Values[\"nowWeek\"]" + appSetting.Values["nowWeek"].ToString()); } else appSetting.Values["nowWeek"] = obj["nowWeek"].ToString(); HubSectionKBNum.Text = "第" + appSetting.Values["nowWeek"].ToString() + "周"; //showKB(2, Int32.Parse(appSetting.Values["nowWeek"].ToString())); #if DEBUG showKB(2); #else showKB(2); #endif } } DateTime now = DateTime.Now; DateTime weekstart = GetWeekFirstDayMon(now); DateTime weekend = GetWeekLastDaySun(now); this.HubSectionKBDate.Text = weekstart.Month + "." + weekstart.Day + "--" + weekend.Month + "." + weekend.Day; StatusBar statusBar = StatusBar.GetForCurrentView(); await statusBar.ProgressIndicator.HideAsync(); }
private async void ClearButton_Click(object sender, RoutedEventArgs e) { var dig = new MessageDialog("若应用无法使用,请尝试清除数据,清除数据后会应用将返回登陆界面。\n\n是否继续?", "警告"); var btnOk = new UICommand("是"); dig.Commands.Add(btnOk); var btnCancel = new UICommand("否"); dig.Commands.Add(btnCancel); var result = await dig.ShowAsync(); if (null != result && result.Label == "是") { try { appSetting.Values.Clear(); } catch (Exception ex) { Debug.WriteLine(ex.Message); } DelectRemind(); try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); foreach (var item in credentialList) { vault.Remove(item); } } catch { } appSetting.Values["CommunityPerInfo"] = false; appSetting.Values["isUseingBackgroundTask"] = false; IStorageFolder applicationFolder = ApplicationData.Current.LocalFolder; IStorageFile storageFileWR = await applicationFolder.CreateFileAsync("kb", CreationCollisionOption.OpenIfExists); try { await storageFileWR.DeleteAsync(); if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.StartScreen.JumpList")) { if (JumpList.IsSupported()) { DisableSystemJumpListAsync(); } } } catch (Exception) { Debug.WriteLine("个人 -> 切换账号删除课表数据异常"); } try { await storageFileWR.DeleteAsync(); } catch (Exception error) { Debug.WriteLine(error.Message); Debug.WriteLine("设置 -> 重置应用异常"); } //Application.Current.Exit(); Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); } else if (null != result && result.Label == "否") { } }
public MainPage_m() { this.InitializeComponent(); appSetting = ApplicationData.Current.LocalSettings; //本地存储 appSettingclass = ApplicationData.Current.RoamingSettings; this.InitializeComponent(); this.NavigationCacheMode = NavigationCacheMode.Required; //MoreGRNameTextBlock.Text = appSetting.Values["name"].ToString(); //MoreGRClassTextBlock.Text = appSetting.Values["classNum"].ToString(); //MoreGRNumTextBlock.Text = appSetting.Values["stuNum"].ToString(); //this.navigationHelper = new NavigationHelper(this); //this.navigationHelper.LoadState += this.NavigationHelper_LoadState; //stuNum = appSetting.Values["stuNum"].ToString(); var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); stuNum = credentialList[0].UserName; //initKB(); initJW(); }
/// <summary> /// 课表网络请求 /// </summary> /// <param name="isRefresh"> 是否为刷新</param> private async void initKB(bool isRefresh = false) { //if (stuNum == appSetting.Values["stuNum"].ToString() && !isRefresh) try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (stuNum == credentialList[0].UserName && !isRefresh) { try { IStorageFolder applicationFolder = ApplicationData.Current.LocalFolder; IStorageFile storageFileRE = await applicationFolder.GetFileAsync("kb"); IRandomAccessStream accessStream = await storageFileRE.OpenReadAsync(); using (StreamReader streamReader = new StreamReader(accessStream.AsStreamForRead((int)accessStream.Size))) { kb = streamReader.ReadToEnd(); } HubSectionKBNum.Text = "第" + appSetting.Values["nowWeek"].ToString() + "周"; showKB(2); } catch (Exception) { Debug.WriteLine("主页->课表数据缓存异常"); } } //if (stuNum == appSetting.Values["stuNum"].ToString()) if (stuNum == credentialList[0].UserName) { HubSectionKBTitle.Text = "我的课表"; HubSectionKBTitle.FontSize = 35; } } catch { } await Utils.ShowSystemTrayAsync(Color.FromArgb(255, 2, 140, 253), Colors.White, text : "课表刷新中...", isIndeterminate : true); List <KeyValuePair <String, String> > paramList = new List <KeyValuePair <String, String> >(); paramList.Add(new KeyValuePair <string, string>("stuNum", stuNum)); string kbtemp = await NetWork.getHttpWebRequest("redapi2/api/kebiao", paramList); //新 //string kbtemp = await NetWork.getHttpWebRequest("api/kebiao", paramList); //旧 if (!appSetting.Values.ContainsKey("HttpTime")) { appSetting.Values["HttpTime"] = DateTimeOffset.Now.ToString(); } if (kbtemp != "") { kb = kbtemp; Debug.WriteLine("DateTimeOffset.Now.ToString()" + DateTimeOffset.Now.ToString()); appSetting.Values["HttpTime"] = DateTimeOffset.Now.Year.ToString() + "/" + DateTimeOffset.Now.Month.ToString() + "/" + DateTimeOffset.Now.Day.ToString(); } Debug.WriteLine("kb->" + kb); if (kb != "") { JObject obj = JObject.Parse(kb); if (Int32.Parse(obj["status"].ToString()) == 200) { IStorageFile storageFileWR = await applicationFolder.CreateFileAsync("kb", CreationCollisionOption.OpenIfExists); try { await FileIO.WriteTextAsync(storageFileWR, kb); } catch (Exception) { Debug.WriteLine("主页 -> 课表缓存,读取异常"); } //保存当前星期 if (kbtemp == "") { Debug.WriteLine(appSetting.Values["HttpTime"].ToString()); DateTimeOffset d = DateTimeOffset.Parse(appSetting.Values["HttpTime"].ToString()); int httpweekday = (Int16)DateTimeOffset.Parse(appSetting.Values["HttpTime"].ToString()).DayOfWeek == 0 ? 7 : (Int16)DateTimeOffset.Parse(appSetting.Values["HttpTime"].ToString()).DayOfWeek; Debug.WriteLine((DateTimeOffset.Now - DateTimeOffset.Parse(appSetting.Values["HttpTime"].ToString())).TotalDays); double weekday = (DateTimeOffset.Now - DateTimeOffset.Parse(appSetting.Values["HttpTime"].ToString())).TotalDays - (7 - httpweekday); Debug.WriteLine("weekday_前" + weekday); //if (weekday % ((Int16)weekday) > 0 || weekday > 0 && weekday < 1) // weekday = (Int16)weekday + 1; weekday = (Int16)weekday; Debug.WriteLine("weekday_后" + weekday); if (weekday > 0) { appSetting.Values["nowWeek"] = Int16.Parse(obj["nowWeek"].ToString()) + (Int16)(weekday + 6) / 7; } else { appSetting.Values["nowWeek"] = obj["nowWeek"].ToString(); } Debug.WriteLine(" appSetting.Values[\"nowWeek\"]" + appSetting.Values["nowWeek"].ToString()); } else { appSetting.Values["nowWeek"] = obj["nowWeek"].ToString(); } HubSectionKBNum.Text = "第" + appSetting.Values["nowWeek"].ToString() + "周"; //showKB(2, Int32.Parse(appSetting.Values["nowWeek"].ToString())); #if DEBUG showKB(2); #else showKB(2); #endif } } DateTime now = DateTime.Now; DateTime weekstart = GetWeekFirstDayMon(now); DateTime weekend = GetWeekLastDaySun(now); this.HubSectionKBDate.Text = weekstart.Month + "." + weekstart.Day + "--" + weekend.Month + "." + weekend.Day; StatusBar statusBar = StatusBar.GetForCurrentView(); await statusBar.ProgressIndicator.HideAsync(); }
public MainPage() { this.InitializeComponent(); // HamburgerButton.Click += HamburgerButton_Click; this.Loaded += (sender, args) => { Current = this; //然并卵 this.TogglePaneButton.Focus(FocusState.Programmatic); }; //this.AppFrame.Navigate(navlist[0].DestPage, navlist[0].Arguments); if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { Utils.ShowSystemTrayAsync(Color.FromArgb(255, 6, 140, 253), Colors.White); } else if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) { Windows.Phone.UI.Input.HardwareButtons.BackPressed += OnBackPressed; } else { var view = ApplicationView.GetForCurrentView(); view.TitleBar.BackgroundColor = Color.FromArgb(255, 4, 131, 239); view.TitleBar.ButtonBackgroundColor = Color.FromArgb(255, 4, 131, 239); view.TitleBar.ButtonHoverBackgroundColor = Color.FromArgb(255, 2, 126, 231); view.TitleBar.ButtonPressedBackgroundColor = Color.FromArgb(255, 2, 111, 203); } this.SizeChanged += (s, e) => { Debug.WriteLine(e.NewSize.Width); if (e.NewSize.Width >= 400) { RootSplitView.CompactPaneLength = 48; TogglePaneButton.Visibility = Visibility.Visible; TogglePaneLightButton.Visibility = Visibility.Collapsed; App.showpane = true; } else { RootSplitView.CompactPaneLength = 0; TogglePaneButton.Visibility = Visibility.Collapsed; TogglePaneLightButton.Visibility = Visibility.Visible; App.showpane = false; } if (e.NewSize.Height - 96 < navlist.Count * 48) { //高度太小 NavMenuList.Margin = new Thickness(0, 48, 0, 48); } else { NavMenuList.Margin = new Thickness(0, 48, 0, 0); } }; //TODO:未登录时 没有名字 //if (appSetting.Values.ContainsKey("idNum")) try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (credentialList.Count > 0) { stuNameTextBlock.Text = appSetting.Values["name"].ToString(); } else { stuNameTextBlock.Text = "尚未登陆~"; } } catch { stuNameTextBlock.Text = "尚未登陆~"; } SystemNavigationManager.GetForCurrentView().BackRequested += SystemNavigationManager_BackRequseted; //如果是在手机上,有实体键,隐藏返回键。 if (ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) { //this.BackButton.Visibility = Visibility.Collapsed; } NavMenuList.ItemsSource = navlist; ActivateWindow(); //NavMenuList.SelectedIndex = 0; var a = DateTime.Now; if (DateTimeOffset.Now < DateTimeOffset.Parse("2016/3/15 00:00:00")) { showNotice(); } else { appSetting.Values.Remove("showNotice"); } //TODO:未登录时采用默认头像 //if (appSetting.Values.ContainsKey("idNum")) try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (credentialList.Count > 0) { initHeadImage(); } } catch { } }
private async void getMark() { string id = ""; string type_id = ""; if (ViewModel.Item != null) { id = ViewModel.Item.id; type_id = ViewModel.Item.type_id; } else { type_id = "5"; id = (ee.Parameter as MyNotification).article_id; } //if (ViewModel.BBDD != null) //{ // id = ViewModel.BBDD.id; // type_id = ViewModel.BBDD.type_id; //} //else //{ // id = ViewModel.hotfeed.article_id; // type_id = ViewModel.hotfeed.type_id; //} //TODO:未登陆时 不添加参数stuNum和idNum var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); List <KeyValuePair <String, String> > paramList = new List <KeyValuePair <String, String> >(); paramList.Add(new KeyValuePair <string, string>("article_id", id)); paramList.Add(new KeyValuePair <string, string>("type_id", type_id)); //paramList.Add(new KeyValuePair<string, string>("stuNum", appSetting.Values["stuNum"].ToString())); //paramList.Add(new KeyValuePair<string, string>("idNum", appSetting.Values["idNum"].ToString())); paramList.Add(new KeyValuePair <string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair <string, string>("idNum", credentialList[0].Password)); paramList.Add(new KeyValuePair <string, string>("size", "15")); paramList.Add(new KeyValuePair <string, string>("page", remarkPage.ToString())); string mark = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/ArticleRemark/getremark", paramList); Debug.WriteLine(mark); try { if (mark != "") { JObject obj = JObject.Parse(mark); if (Int32.Parse(obj["state"].ToString()) == 200) { //markList.Clear(); JArray markListArray = Utils.ReadJso(mark); if (markListArray.Count != 0) { isfirst = false; NoMarkGrid.Visibility = Visibility.Collapsed; if (ViewModel.Item != null) { //ViewModel.Item.remark_num = markListArray.Count.ToString(); if (type_id == "5") { MyFeed x = await CommunityMyContentService.GetFeed(int.Parse(type_id), id); //MyFeed y = ee.Parameter as MyFeed; //y.remark_num = x.remark_num; //var z = ViewModel.Item.remark_num; ViewModel.Item.remark_num = x.remark_num; } } //if (args is HotFeed) //{ // HotFeed h = args as HotFeed; // h.remark_num = ViewModel.BBDD.remark_num; //} for (int i = 0; i < markListArray.Count; i++) { Mark Markitem = new Mark(); Markitem.GetListAttribute((JObject)markListArray[i]); markList.Add(Markitem); } remarkPage++; } else if (isfirst) { NoMarkGrid.Visibility = Visibility.Visible; } issend = false; } } } catch (Exception) { } isMark2Peo = false; }
private void CommunityAddAppBarButton_Click(object sender, RoutedEventArgs e) { //TODO:未登陆时 无法发表新帖 CommunityFrame.Visibility = Visibility.Visible; SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested; SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; //if (appSetting.Values.ContainsKey("idNum")) try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (credentialList.Count > 0) CommunityFrame.Navigate(typeof(CommunityAddPage)); else { var msgPopup = new Data.loginControl("您还没有登录 无法发布新帖~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { Debug.WriteLine("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); } } catch { var msgPopup = new Data.loginControl("您还没有登录 无法发布新帖~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { Debug.WriteLine("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); } }
private async void MoreListView_ItemClick(object sender, ItemClickEventArgs e) { var item = e.ClickedItem as Morepageclass; if ((MoreListgrid.Width == 300) || item.UniqueID == "Card") { //MoreBackAppBarButton.Visibility = Visibility.Collapsed; SystemNavigationManager.GetForCurrentView().BackRequested -= App_BackRequested; SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; } else { //MoreBackAppBarButton.Visibility = Visibility.Visible; SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested; SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; HubSectionKBTitle.Text = item.Itemname; } //MoreFrame.Visibility = Visibility.Visible; MoreContentTitleTextBlock.Text = item.Itemname; //TODO:未登陆时 没有 补考/考试/分数信息 可查询空闲 无法自动添加自己的信息 Debug.WriteLine(item.UniqueID); { int count; var vault = new Windows.Security.Credentials.PasswordVault(); try { var credentialList = vault.FindAllByResource(resourceName); count = credentialList.Count; } catch { count = 0; } switch (item.UniqueID) { case "ReExam": //if (appSetting.Values.ContainsKey("idNum")) if (count > 0) { MoreFrame.Navigate(typeof(ExamPage), 3);; MoreFrame.Visibility = Visibility.Visible; isFreeRe = 0; break; } else { var msgPopup = new Data.loginControl("您还没有登录 无法查看补考信息~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); break; } case "Volunteer": MoreFrame.Navigate(typeof(VolunteerPage)); MoreFrame.Visibility = Visibility.Visible; isFreeRe = 0; break; case "Exam": //if (appSetting.Values.ContainsKey("idNum")) if (count > 0) { MoreFrame.Navigate(typeof(ExamPage), 2); MoreFrame.Visibility = Visibility.Visible; isFreeRe = 0; break; } else { var msgPopup = new Data.loginControl("您还没有登录 无法查看考试信息~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); break; } case "Socre": //if (appSetting.Values.ContainsKey("idNum")) if (count > 0) { MoreFrame.Navigate(typeof(ScorePage)); MoreFrame.Visibility = Visibility.Visible; isFreeRe = 0; break; } else { var msgPopup = new Data.loginControl("您还没有登录 无法查看成绩~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); break; } case "ClassRoom": //if (appSetting.Values.ContainsKey("idNum")) if (count > 0) { MoreFrame.Navigate(typeof(EmptyRoomsPage)); MoreFrame.Visibility = Visibility.Visible; isFreeRe = 0; break; } else { var msgPopup = new Data.loginControl("您还没有登录 无法查询空教室~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); break; } case "Calendar": MoreFrame.Navigate(typeof(CalendarPage)); MoreFrame.Visibility = Visibility.Visible; isFreeRe = 0; break; case "FreeTime": if (count > 0) { MoreFrame.Navigate(typeof(SearchFreeTimeNumPage)); MoreFrame.Visibility = Visibility.Visible; isFreeRe = 0; break; } else { var msgPopup = new Data.loginControl("您还没有登录 无法查询空闲~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); break; } case "Card": var a = await Launcher.LaunchUriAsync(new Uri("cquptcard:")); MoreFrame.Visibility = Visibility.Collapsed; break; case "freshMan": Frame.Navigate(typeof(FirstPage)); MoreFrame.Visibility = Visibility.Collapsed; isFreeRe = 0; break; case "Electricity": Frame.Navigate(typeof(ElectricityPage)); MoreFrame.Visibility = Visibility.Collapsed; isFreeRe = 0; break; default: break; } } }
private async void liskButton_Click(object sender, RoutedEventArgs e) { //TODO:未登陆时 不能点赞 //if (appSetting.Values.ContainsKey("idNum")) try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (credentialList.Count > 0) { var b = sender as Button; string num_id = b.TabIndex.ToString(); Debug.WriteLine(num_id); Debug.WriteLine("id " + num_id.Substring(2)); string like_num = ""; try { if (int.Parse(num_id[0].ToString()) < 5) //hot { HotFeed hotfeed = ViewModel.HotFeeds.First(p => p.article_id.Equals(num_id.Substring(2))); if (hotfeed.is_my_Like == "true" || hotfeed.is_my_Like == "True") { like_num = await CommunityFeedsService.setPraise(hotfeed.type_id, num_id.Substring(2), false); if (like_num != "") { hotfeed.like_num = like_num; hotfeed.is_my_Like = "false"; if (ViewModel.BBDD.Count(p => p.id.Equals(num_id.Substring(2))) != 0) { BBDDFeed s = ViewModel.BBDD.First(p => p.id.Equals(num_id.Substring(2))); if (s != null) { s.like_num = like_num; s.is_my_like = "false"; } } } } else { like_num = await CommunityFeedsService.setPraise(hotfeed.type_id, num_id.Substring(2), true); if (like_num != "") { hotfeed.like_num = like_num; hotfeed.is_my_Like = "true"; if (ViewModel.BBDD.Count(p => p.id.Equals(num_id.Substring(2))) != 0) { BBDDFeed s = ViewModel.BBDD.First(p => p.id.Equals(num_id.Substring(2))); if (s != null) { s.like_num = like_num; s.is_my_like = "true"; } } } } } else if (num_id[0] == '5') //bbdd { BBDDFeed bbddfeed = ViewModel.BBDD.First(p => p.id.Equals(num_id.Substring(2))); if (bbddfeed.is_my_like == "true" || bbddfeed.is_my_like == "True") { like_num = await CommunityFeedsService.setPraise(bbddfeed.type_id, num_id.Substring(2), false); if (like_num != "") { bbddfeed.like_num = like_num; bbddfeed.is_my_like = "false"; if (ViewModel.HotFeeds.Count(p => p.article_id.Equals(num_id.Substring(2))) != 0) { HotFeed h = ViewModel.HotFeeds.First(p => p.article_id.Equals(num_id.Substring(2))); if (h != null) { h.like_num = like_num; h.is_my_Like = "false"; } } } } else { like_num = await CommunityFeedsService.setPraise(bbddfeed.type_id, num_id.Substring(2), true); if (like_num != "") { bbddfeed.like_num = like_num; bbddfeed.is_my_like = "true"; if (ViewModel.HotFeeds.Count(p => p.article_id.Equals(num_id.Substring(2))) != 0) { HotFeed h = ViewModel.HotFeeds.First(p => p.article_id.Equals(num_id.Substring(2))); if (h != null) { h.like_num = like_num; h.is_my_Like = "true"; } } } } } } catch (Exception) { Debug.WriteLine("点赞异常"); } } else { var msgPopup = new Data.loginControl("您还没有登录 无法点赞~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { Debug.WriteLine("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); } } catch { var msgPopup = new Data.loginControl("您还没有登录 无法点赞~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { Debug.WriteLine("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); } }
private async void addArticleAppBarButton_Click(object sender, RoutedEventArgs e) { addArticleAppBarButton.IsEnabled = false; string imgPhoto_src = ""; string imgThumbnail_src = ""; addProgressBar.Visibility = Visibility.Visible; var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (imageList.Count > 1) { int count = 0; if (imageList.Count == 9) { if (imageList[8].imgName != "CommunityAddImg.png") { count = 9; } else { count = 8; } } else { count = imageList.Count - 1; } addProgressBar.IsIndeterminate = false; addProgressBar.Maximum = count; addProgressBar.Value = 0; for (int i = 0; i < count; i++) { try { //string imgUp = await NetWork.headUpload(appSetting.Values["stuNum"].ToString(), imageList[i].imgAppPath, "http://hongyan.cqupt.edu.cn/cyxbsMobile/index.php/Home/Photo/uploadArticle", false); string imgUp = await NetWork.headUpload(credentialList[0].UserName, imageList[i].imgAppPath, "http://hongyan.cqupt.edu.cn/cyxbsMobile/index.php/Home/Photo/uploadArticle", false); if (imgUp != "" && imgUp.IndexOf("Request Entity Too Large") == -1) { JObject obj = JObject.Parse(imgUp); if (Int32.Parse(obj["state"].ToString()) == 200) { string a = obj["data"].ToString(); JObject objdata = JObject.Parse(obj["data"].ToString()); //appSetting.Values["headimgdate"] = objdata["date"].ToString(); imageList[i].imgPhoto_src = objdata["photosrc"].ToString(); imageList[i].imgThumbnail_src = objdata["thumbnail_src"].ToString(); imgPhoto_src += ("," + objdata["photosrc"].ToString()); imgThumbnail_src += ("," + objdata["thumbnail_src"].ToString()); imgPhoto_src = imgPhoto_src.Replace("http://hongyan.cqupt.edu.cn/cyxbsMobile/Public/photo/", ""); imgThumbnail_src = imgThumbnail_src.Replace("http://hongyan.cqupt.edu.cn/cyxbsMobile/Public/photo/thumbnail/", ""); } } else if (imgUp.IndexOf("Request Entity Too Large") != -1) { Debug.WriteLine("第" + (int)(i + 1) + "张图片太大"); Utils.Toast("第" + (int)(i + 1) + "张图片超出4M限制"); addArticleAppBarButton.IsEnabled = true; addProgressBar.Visibility = Visibility.Collapsed; return; } else { Debug.WriteLine("图片上传失败"); Utils.Toast("发表失败"); addArticleAppBarButton.IsEnabled = true; addProgressBar.Visibility = Visibility.Collapsed; return; } addProgressBar.Value += 1; } catch (Exception) { Debug.WriteLine("图片上传失败"); addArticleAppBarButton.IsEnabled = true; addProgressBar.Visibility = Visibility.Collapsed; return; } } try { for (int i = 0; i < count; i++) { StorageFile imgfile = await StorageFile.GetFileFromApplicationUriAsync(new Uri(imageList[i].imgAppPath)); imgfile.DeleteAsync(); } } catch (Exception) { } if (imgPhoto_src != "") { imgPhoto_src = imgPhoto_src.Substring(1); } if (imgThumbnail_src != "") { imgThumbnail_src = imgThumbnail_src.Substring(1); } } addProgressBar.IsIndeterminate = true; List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>(); if (para != null) { paramList.Add(new KeyValuePair<string, string>("type_id", "7")); //rua paramList.Add(new KeyValuePair<string, string>("topic_id", para.topic_id.ToString())); //rua } else paramList.Add(new KeyValuePair<string, string>("type_id", "5")); //现在只有哔哔叨叨 paramList.Add(new KeyValuePair<string, string>("title", addContentTextBox.Text)); //paramList.Add(new KeyValuePair<string, string>("user_id", appSetting.Values["Community_people_id"].ToString())); //记得改了 paramList.Add(new KeyValuePair<string, string>("content", addContentTextBox.Text)); paramList.Add(new KeyValuePair<string, string>("photo_src", imgPhoto_src)); paramList.Add(new KeyValuePair<string, string>("thumbnail_src", imgThumbnail_src)); //paramList.Add(new KeyValuePair<string, string>("stuNum", appSetting.Values["stuNum"].ToString())); //paramList.Add(new KeyValuePair<string, string>("idNum", appSetting.Values["idNum"].ToString())); paramList.Add(new KeyValuePair<string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair<string, string>("idNum", credentialList[0].Password)); string ArticleUp = ""; if (para != null) { ArticleUp = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/Topic/addTopicArticle", paramList); } else ArticleUp = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/Article/addArticle", paramList); Debug.WriteLine(ArticleUp); try { if (ArticleUp != "") { JObject obj = JObject.Parse(ArticleUp); if (Int32.Parse(obj["state"].ToString()) == 200) { Utils.Toast("发表成功"); Frame rootFrame = Window.Current.Content as Frame; //addTitleTextBox.Text = ""; addContentTextBox.Text = ""; if (imageList.Count > 1) { for (int i = 0; i < imageList.Count - 1; i++) { imageList.RemoveAt(i); } } page.Visibility = Visibility.Collapsed; commandbar.Visibility = Visibility.Collapsed; SystemNavigationManager.GetForCurrentView().BackRequested -= App_BackRequested; SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; //ee.Handled = false; //Frame.GoBack(); } } } catch (Exception) { } addArticleAppBarButton.IsEnabled = true; addProgressBar.Visibility = Visibility.Collapsed; }
private void StackPanel_Tapped(object sender, TappedRoutedEventArgs e) { //if (appSetting.Values.ContainsKey("idNum")) var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (credentialList.Count > 0) { BBDDFeed b = ((StackPanel)sender).DataContext as BBDDFeed; App.ViewModel = ViewModel; App.CommunityPivotState = CommunityPivot.SelectedIndex; App.CommunityScrollViewerOffset = BBDDScrollViewer.VerticalOffset; isPersonInfo = true; Frame.Navigate(typeof(CommunityPersonInfo), b.stunum); } else { var msgPopup = new Data.loginControl("登录即可查看他人动态~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先四处逛一逛~"); }; msgPopup.ShowWIndow(); } }
/// <summary> /// Navigate to the Page for the selected <paramref name="listViewItem"/>. /// </summary> /// <param name="sender"></param> /// <param name="listViewItem"></param> private async void NavMenuList_ItemInvoked(object sender, ListViewItem listViewItem) { var item = (NavMenuItem)((NavMenuListView)sender).ItemFromContainer(listViewItem); if (item != null) { if (item.DestPage != null && item.DestPage != this.AppFrame.CurrentSourcePageType) { //appSetting.Values["CommunityPerInfo"] = false; //TODO:未登录时 不能传入社区个人信息和个人信息页信息 谨慎处理 //if (!bool.Parse(appSetting.Values["CommunityPerInfo"].ToString()) && (item.DestPage == typeof(MyPage) || item.DestPage == typeof(CommunityPage))) try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (!bool.Parse(appSetting.Values["CommunityPerInfo"].ToString()) && (item.DestPage == typeof(MyPage))) { if (credentialList.Count > 0) { BackOpacityGrid.Visibility = Visibility.Visible; loadingStackPanel.Visibility = Visibility.Visible; List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>(); //paramList.Add(new KeyValuePair<string, string>("stuNum", appSetting.Values["stuNum"].ToString())); //paramList.Add(new KeyValuePair<string, string>("idNum", appSetting.Values["idNum"].ToString())); paramList.Add(new KeyValuePair<string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair<string, string>("idNum", credentialList[0].Password)); string perInfo = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/Person/search", paramList); if (perInfo != "") { JObject jPerInfo = JObject.Parse(perInfo); if (jPerInfo["data"].ToString() == "") { var dig = new MessageDialog("没有完善资料不能登入友谊的小船哟"); var btnOk = new UICommand("马上完善"); dig.Commands.Add(btnOk); var btnCancel = new UICommand("暂时不了"); dig.Commands.Add(btnCancel); var result = await dig.ShowAsync(); if (null != result && result.Label == "马上完善") { Debug.WriteLine("添加信息"); BackOpacityGrid.Visibility = Visibility.Collapsed; loadingStackPanel.Visibility = Visibility.Collapsed; this.AppFrame.Navigate(typeof(SetPersonInfoPage), item.DestPage); } else if (null != result && result.Label == "暂时不了") { BackOpacityGrid.Visibility = Visibility.Collapsed; loadingStackPanel.Visibility = Visibility.Collapsed; } } else { appSetting.Values["CommunityPerInfo"] = true; appSetting.Values["Community_people_id"] = jPerInfo["data"]["id"].ToString(); appSetting.Values["Community_nickname"] = jPerInfo["data"]["nickname"].ToString(); appSetting.Values["Community_headimg_src"] = jPerInfo["data"]["photo_src"].ToString(); appSetting.Values["Community_introduction"] = jPerInfo["data"]["introduction"].ToString(); appSetting.Values["Community_phone"] = jPerInfo["data"]["phone"].ToString(); appSetting.Values["Community_qq"] = jPerInfo["data"]["qq"].ToString(); Debug.WriteLine(appSetting.Values["Community_headimg_src"].ToString()); Debug.WriteLine(jPerInfo["data"]["id"].ToString()); BackOpacityGrid.Visibility = Visibility.Collapsed; loadingStackPanel.Visibility = Visibility.Collapsed; if ((item.DestPage != typeof(MyPage))) this.AppFrame.Navigate(item.DestPage, item.Arguments); SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; } } } else { if ((item.DestPage != typeof(MyPage))) { this.AppFrame.Navigate(item.DestPage, item.Arguments); var msgPopup = new Data.loginControl("您还没有登录 不能访问个人中心~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); } else { var msgPopup = new Data.loginControl("您还没有登录 不能访问个人中心~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); } } } else { this.AppFrame.Navigate(item.DestPage, item.Arguments); SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; } } catch { if (!bool.Parse(appSetting.Values["CommunityPerInfo"].ToString()) && (item.DestPage == typeof(MyPage))) { if ((item.DestPage != typeof(MyPage))) { this.AppFrame.Navigate(item.DestPage, item.Arguments); var msgPopup = new Data.loginControl("您还没有登录 不能访问个人中心~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); } else { var msgPopup = new Data.loginControl("您还没有登录 不能访问个人中心~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); } } else { this.AppFrame.Navigate(item.DestPage, item.Arguments); SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; } } } } }
private async void clipHeadOKButton_Click(object sender, RoutedEventArgs e) { upClipHeadProgressBar.Visibility = Visibility.Visible; try { //HttpClient _httpClient = new HttpClient(); //CancellationTokenSource _cts = new CancellationTokenSource(); RenderTargetBitmap mapBitmap = new RenderTargetBitmap(); await mapBitmap.RenderAsync(headScrollViewer); var pixelBuffer = await mapBitmap.GetPixelsAsync(); IStorageFolder applicationFolder = ApplicationData.Current.LocalFolder; IStorageFile saveFile = await applicationFolder.CreateFileAsync("temphead.png", CreationCollisionOption.OpenIfExists); using (var fileStream = await saveFile.OpenAsync(FileAccessMode.ReadWrite)) { var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, fileStream); encoder.SetPixelData( BitmapPixelFormat.Bgra8, BitmapAlphaMode.Ignore, (uint)mapBitmap.PixelWidth, (uint)mapBitmap.PixelHeight, DisplayInformation.GetForCurrentView().LogicalDpi, DisplayInformation.GetForCurrentView().LogicalDpi, pixelBuffer.ToArray()); await encoder.FlushAsync(); } var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); //string uphead = await NetWork.headUpload(appSetting.Values["stuNum"].ToString(), "ms-appdata:///local/temphead.png"); string uphead = await NetWork.headUpload(credentialList[0].UserName, "ms-appdata:///local/temphead.png"); Debug.WriteLine(uphead); if (uphead != "") { JObject obj = JObject.Parse(uphead); if (Int32.Parse(obj["state"].ToString()) == 200) { ClipHeadGrid.Visibility = Visibility.Collapsed; BackOpacityGrid.Visibility = Visibility.Collapsed; initHeadImage(); } else { Utils.Toast("头像上传错误"); } } else { Utils.Toast("头像上传错误"); } upClipHeadProgressBar.Visibility = Visibility.Collapsed; } catch (Exception) { Debug.WriteLine("设置头像,保存新头像异常"); } }
private async void initScore() { //await Utils.ShowSystemTrayAsync(Color.FromArgb(255, 2, 140, 253), Colors.White, text: "正在紧张批改试卷...", isIndeterminate: true); var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); List <KeyValuePair <String, String> > paramList = new List <KeyValuePair <String, String> >(); //paramList.Add(new KeyValuePair<string, string>("stuNum", appSetting.Values["stuNum"].ToString())); //paramList.Add(new KeyValuePair<string, string>("idNum", appSetting.Values["idNum"].ToString())); paramList.Add(new KeyValuePair <string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair <string, string>("idNum", credentialList[0].Password)); string score = await NetWork.getHttpWebRequest("api/examGrade", paramList); Debug.WriteLine("score->" + score); #if DEBUG //score = "{\"status\":200,\"term\":\"20151\",\"info\":\"success\",\"data\":[{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"},{\"student\":\"2013211594\",\"course\":\"英语口笔译基础\",\"grade\":\"99\",\"property\":\"必修\",\"status\":\"1\",\"term\":\"2\"}],\"version\":\"0.1.0\",\"stuNum\":\"2013211594\",\"idNum\":\"160155\"}"; #endif if (score != "") { JObject obj = JObject.Parse(score); if (Int32.Parse(obj["status"].ToString()) == 200) { List <ScoreList> scoreList = new List <ScoreList>(); JArray ScoreListArray = Utils.ReadJso(score); for (int i = 0; i < ScoreListArray.Count; i++) { ScoreList classitem = new ScoreList(); classitem.GetAttribute((JObject)ScoreListArray[i]); scoreList.Add(classitem); } ScoreListView.ItemsSource = scoreList; } else if (Int32.Parse(obj["status"].ToString()) == 300) { ListFailedStackPanelTextBlock.Text = "暂无数据,过几天再来看看"; ListFailedStackPanel.Visibility = Visibility.Visible; ListFailedStackPanelImage.Visibility = Visibility.Collapsed; ListFailedStackPanelTextBlock.Visibility = Visibility.Visible; } else { ListFailedStackPanelTextBlock.Text = "加载失败,点击重试"; ListFailedStackPanel.Visibility = Visibility.Visible; ListFailedStackPanelImage.Visibility = Visibility.Visible; ListFailedStackPanelTextBlock.Visibility = Visibility.Visible; } } else { ListFailedStackPanelTextBlock.Text = "加载失败,点击重试"; ListFailedStackPanel.Visibility = Visibility.Visible; ListFailedStackPanelImage.Visibility = Visibility.Visible; ListFailedStackPanelTextBlock.Visibility = Visibility.Visible; } //StatusBar statusBar = StatusBar.GetForCurrentView(); //await statusBar.ProgressIndicator.HideAsync(); }
private async void SetPersonInfoOKAppBarButton_Click(object sender, RoutedEventArgs e) { appSetting.Values["Community_nickname"] = nameTextBox.Text; var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>(); //paramList.Add(new KeyValuePair<string, string>("stuNum", appSetting.Values["stuNum"].ToString())); //paramList.Add(new KeyValuePair<string, string>("idNum", appSetting.Values["idNum"].ToString())); //paramList.Add(new KeyValuePair<string, string>("stuuum", appSetting.Values["stuNum"].ToString())); paramList.Add(new KeyValuePair<string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair<string, string>("idNum", credentialList[0].Password)); paramList.Add(new KeyValuePair<string, string>("stuuum", credentialList[0].UserName)); paramList.Add(new KeyValuePair<string, string>("nickname", nameTextBox.Text)); paramList.Add(new KeyValuePair<string, string>("introduction", abstractTextBox.Text)); paramList.Add(new KeyValuePair<string, string>("qq", qqTextBox.Text)); paramList.Add(new KeyValuePair<string, string>("phone", phoneTextBox.Text)); string setinfo = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/Person/setInfo", paramList); try { if (setinfo != "") { JObject obj = JObject.Parse(setinfo); if (Int32.Parse(obj["status"].ToString()) == 200) { string perInfo = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/Person/search", paramList); if (perInfo != "") { JObject jPerInfo = JObject.Parse(perInfo); appSetting.Values["Community_people_id"] = jPerInfo["data"]["id"].ToString(); Debug.WriteLine(jPerInfo["data"]["id"].ToString()); } var navPage = ee.Parameter; if (navPage == typeof(CommunityPage)) { Utils.Toast("新建个人信息成功~~,尽情享用吧"); this.Frame.Navigate(typeof(CommunityPage)); } else if (navPage == typeof(MyPage)) { Utils.Toast("新建个人信息成功~~,尽情享用吧"); this.Frame.Navigate(typeof(MyPage)); } else { Frame.GoBack(); } } else if (Int32.Parse(obj["status"].ToString()) == 801) { Utils.Toast("更新资料失败,请检查是否包含特殊词"); } } } catch (Exception) { } }
/// <summary> /// 课表刷新 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void KBRefreshAppBarButton_Click(object sender, RoutedEventArgs e) { //stuNum = appSetting.Values["stuNum"].ToString(); var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); stuNum = credentialList[0].UserName; wOa = 1; initKB(true); }
private async void sendMarkButton_Click(object sender, RoutedEventArgs e) { //TODO:未登陆时 不能评论 //if (appSetting.Values.ContainsKey("idNum")) try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (credentialList.Count > 0) { sendMarkButton.IsEnabled = false; sendMarkProgressRing.Visibility = Visibility.Visible; string id = ""; string type_id = ""; if (ViewModel.BBDD != null) { id = ViewModel.BBDD.id; type_id = ViewModel.BBDD.type_id; } else { id = ViewModel.hotfeed.article_id; type_id = ViewModel.hotfeed.type_id; } List <KeyValuePair <String, String> > paramList = new List <KeyValuePair <String, String> >(); paramList.Add(new KeyValuePair <string, string>("article_id", id)); paramList.Add(new KeyValuePair <string, string>("type_id", type_id)); //paramList.Add(new KeyValuePair<string, string>("stuNum", appSetting.Values["stuNum"].ToString())); //paramList.Add(new KeyValuePair<string, string>("idNum", appSetting.Values["idNum"].ToString())); paramList.Add(new KeyValuePair <string, string>("stuNum", credentialList[0].UserName)); paramList.Add(new KeyValuePair <string, string>("idNum", credentialList[0].Password)); paramList.Add(new KeyValuePair <string, string>("content", sendMarkTextBox.Text)); paramList.Add(new KeyValuePair <string, string>("answer_user_id", Mark2PeoNum)); string sendMark = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/ArticleRemark/postremarks", paramList); Debug.WriteLine(sendMark); try { if (sendMark != "") { JObject obj = JObject.Parse(sendMark); if (Int32.Parse(obj["state"].ToString()) == 200) { Utils.Toast("评论成功"); issend = true; sendMarkTextBox.Text = ""; markList.Clear(); remarkPage = 0; getMark(); if (type_id == "6") { ViewModel.hotfeed.remark_num = (int.Parse(ViewModel.hotfeed.remark_num) + 1).ToString(); } } else { Utils.Toast("评论失败"); } } else { Utils.Toast("评论失败"); } sendMarkProgressRing.Visibility = Visibility.Collapsed; } catch (Exception) { } isMark2Peo = false; } else { var msgPopup = new Data.loginControl("您还没有登录 无法评论帖子~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先四处逛一逛~"); }; msgPopup.ShowWIndow(); } } catch { var msgPopup = new Data.loginControl("您还没有登录 无法评论帖子~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先四处逛一逛~"); }; msgPopup.ShowWIndow(); } }