/// <summary> /// 获取任务列表 /// </summary> /// <param name="count"></param> /// <param name="skip"></param> /// <returns></returns> public ResultModel <TaskInfo[]> GetTasks(int count = -1, int skip = 0, string owner = null, string name = null) { //todo 实现获取指定条数 ResultModel <TaskInfo[]> result = new ResultModel <TaskInfo[]>(); IQueryable <TaskInfo> TaskInfoList; try { TaskInfoList = _cicadaDbContext.TaskInfos.OrderBy(f => f.TaskId); if (!string.IsNullOrEmpty(name)) { TaskInfoList = TaskInfoList.Where(i => i.Name == name); } if (!string.IsNullOrEmpty(owner)) { TaskInfoList = TaskInfoList.Where(i => i.Owner == owner); } if (count == -1) { TaskInfoList = TaskInfoList.Skip(skip); } else { TaskInfoList = TaskInfoList.Take(count).Skip(skip); } result.Data = TaskInfoList.ToArray(); result.Code = 200; } catch (Exception ex) { result.Code = 500; result.Msg = ex.Message; } return(result); }
/// <summary> /// 模型数据改变 /// </summary> /// <param name="obj"></param> private void dataChanged(TaskInfoModel taskInfoModel) { getPageData(pageRepuestParams.PageIndex, pageRepuestParams.PageSize); if (!Equals(taskInfoModel, null)) { var tmpModel = TaskInfoList.FirstOrDefault(a => a.Id == taskInfoModel.Id); this.TaskInfoModel = TaskInfoList.FirstOrDefault(); } }
private void LoadSortingLine(TaskInfoList taskInfoList) { itemPanel1.Items.Clear(); itemPanel1.BeginUpdate(); foreach (TaskInfo taskInfo in taskInfoList) { if (!taskInfo.LineName.Contains("罚没") && taskInfo.LineCode == AppUtil._SortingLineId) { CheckBoxItem checkBoxX = new CheckBoxItem(); checkBoxX.Text = taskInfo.LineName + "-任务号" + taskInfo.TaskNo; checkBoxX.Name = taskInfo.LineCode + taskInfo.TaskNo; checkBoxX.Tag = taskInfo; checkBoxX.Checked = true; itemPanel1.Items.Add(checkBoxX); } } itemPanel1.EndUpdate(true); }
/// <summary> /// 取得分页数据 /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> private void getPageData(int pageIndex, int pageSize) { #if DEBUG System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start(); #endif pageRepuestParams.SortField = GlobalData.SortField; pageRepuestParams.SortOrder = GlobalData.SortOrder; pageRepuestParams.PageIndex = pageIndex; pageRepuestParams.PageSize = pageSize; Utility.Http.HttpClientHelper.SetAccessTokenToHttpClient(GlobalData.AccessTocken); var result = Utility.Http.HttpClientHelper.PostResponse <OperationResult <PageResult <TaskInfoModel> > >(GlobalData.ServerRootUri + "TaskInfo/PageData", Utility.JsonHelper.ToJson(pageRepuestParams)); #if DEBUG stopwatch.Stop(); Utility.LogHelper.Info("获取TaskInfo信息用时(毫秒):" + stopwatch.ElapsedMilliseconds); Utility.LogHelper.Info("TaskInfo信息内容:" + Utility.JsonHelper.ToJson(result)); #endif if (!Equals(result, null) && result.Successed) { Application.Current.Resources["UiMessage"] = result?.Message; LogHelper.Info(Application.Current.Resources["UiMessage"].ToString()); if (result.Data.Data.Any()) { TaskInfoList = new ObservableCollection <TaskInfoModel>(result.Data.Data); TotalCounts = result.Data.Total; } else { TaskInfoList?.Clear(); TotalCounts = 0; Application.Current.Resources["UiMessage"] = "未找到数据"; } } else { //操作失败,显示错误信息 TaskInfoList = new ObservableCollection <TaskInfoModel>(); Application.Current.Resources["UiMessage"] = result?.Message ?? "查询路段信息失败,请联系管理员!"; } }
private void dateTimeInput1_ValueChanged(object sender, EventArgs e) { TaskInfoList taskInfoList = TaskInfoList.GetServerTaskBatchs(dateTimeInput1.Value.Date.ToString("yyyy-MM-dd"), false); try { LoadSortingLine(taskInfoList); } catch (Exception ex) { if (ex.Message.Contains("Unable to connect to any of the specified MySQL hosts")) { MessageBox.Show("无法连接到分拣信息服务器数据库"); } else { throw; } } }
public static TaskInfoList TaskFetchInfoList(TaskCriteria criteria) { return(TaskInfoList.FetchTaskInfoList(criteria)); }