public void ProcessRequest(HttpContext context) { TimerMission bll = new TimerMission(); context.Response.ContentType = "text/plain"; //获取当前任务ID,用于查询 string missionid = HttpContext.Current.Request.Params["missionid"]; if (missionid == null) { throw new ArgumentNullException("context"); } //获取Model Model.TimerMission model = bll.GetModel(new Guid(missionid)); //JSON输出 JavaScriptSerializer scriptSerializer = new JavaScriptSerializer(); if (model != null) { var states = EnumDescriptionExtension.GetDescription(typeof(MissionStateEnum), value: model.MissionState.ToString(), key: "show"); //只显示状态名称,不显示图标 model.StateString = states.Substring(states.IndexOf("</i>", StringComparison.Ordinal) + 4); model.StartTimeStr = model.StartTime.ToString(); model.EndTimeStr = model.EndTime.ToString(); string missionjson = scriptSerializer.Serialize(model); //输出JSON HttpContext.Current.Response.Write(missionjson); } HttpContext.Current.Response.End(); }
private void NewDatabind(int count) { int totalpage = 0; int index = Convert.ToInt32(Webpageindex); int totalrecord = 0; Model.TimerMission model = new Model.TimerMission { //任务名称(模糊搜索) MissionName = txtMissionName.Text.Trim(), //任务所在组名称(模糊搜索) GroupName = txtGroupName.Text.Trim(), //要检索的任务状态 MissionState = Convert.ToInt32(ddlState.SelectedValue) }; if (txtStartTime.Text.Trim() != "") { //任务开始执行事件 model.StartTime = Convert.ToDateTime(txtStartTime.Text.Trim()); } if (txtEndTime.Text.Trim() != "") { //任务结束时间 model.EndTime = Convert.ToDateTime(txtEndTime.Text.Trim()); } //分页获取数据方法 DataTable dt = new Bizlog().GetAllData(model, "createtime", 1, count, Convert.ToInt32(Webpageindex), ref totalpage, ref index, ref totalrecord); if (dt != null) { //要显示出来的数据进行处理 dt.Columns.Add("StateString", typeof(string)); foreach (DataRow dr in dt.Rows) { try { dr["SqlStr"] = dr["SqlStr"].ToString().Replace("\"", "'"); string state = dr["MissionState"].ToString(); //获取任务状态的中文名称(当前的任务名称中包含了HTML的图标代码) dr["StateString"] = EnumDescriptionExtension.GetDescription(typeof(MissionStateEnum), state, "show"); dr["TimeCorn"] = dr["TimeCorn"].ToString().Trim();//去除空白 } catch (Exception) { throw; } } if (totalpage < index) {//如果当前页面比总页面的数值大,则默认设置当前页为总页数最后一页 Webpageindex = index; } } WebPageCount = totalpage; Webpagerecord = totalrecord; //当前Repeater控件数据绑定 Repeatergoods.DataSource = dt; Repeatergoods.DataBind(); }
private async void EditTour(object commandParameter) { AddTourViewModel plusButtonVM; PlusButtonWindow plusWin = new(); plusButtonVM = (AddTourViewModel)plusWin.DataContext; //creates link to new window's data --> IMPORTANT plusButtonVM.Input = CurrentItem.Name; plusButtonVM.Goal = CurrentItem.TourInfo.Goal; plusButtonVM.Start = CurrentItem.TourInfo.Start; plusButtonVM.SelectedDate = CurrentItem.TourInfo.CreationTime; Debug.Print("Before"); foreach (var item in Tours) { plusButtonVM.TourList.Add(item); } plusButtonVM.RefreshList(); plusWin.ShowDialog(); //when using List List<string> tempList = new List<string>(stringList); StringList = tempList; if (plusButtonVM.Input != null) { try { var tempVar = await this.tourItemFactory.EditTour(CurrentItem.Name, plusButtonVM.Input, plusButtonVM.Start, plusButtonVM.Goal, plusButtonVM.SelectedDate, EnumDescriptionExtension.GetDescription(plusButtonVM.Method)); if (tempVar == null) { MessageBox.Show("There has been an error updating your tour, please try again!"); } else { await this.tourItemFactory.ShowMapTourAsync(plusButtonVM.Start, plusButtonVM.Goal, plusButtonVM.Input); } } catch (Exception e) { log.Error(e); } Tours.Clear(); FillListBox(); } }