//public delegate void private async void BindSubmitData() //窗体加载时绑定提交管理中各任务的数量 { /// modify by gatieme 2015-07-02 16:56 /// BUG[NO.20150702-000001] /// 定时器会定时更新数据, /// 但是会出现一个问题, /// 如果定时器刷新的时候, 某一项数据在TCP传输的时候,获取失败的话, /// 那么这项数据就成为null, 由于之间未进行null异常的处理,程序throw出异常信息 /// /// 2015-07-02 16:56发现此BUG /// 2015-07-02 16:56决定修复此BUG /// 我们目前有两种处理方案 /// /// 第一种处理方案 /// 如果有一个为空,就全部不重新加载,仍然使用久的数据源 /// /// 第二种处理方案 /// 哪一项数据获取不正常,就不加载,其他数据照样加载 try { List <SHDJContract> penddingList = null; //while (penddingList == null) //{ penddingList = await _sc.QuerySignPend(UserHelper.UserInfo.Id); //} List <SHDJContract> refuseList = null; while (refuseList == null) { refuseList = _sc.QuerySignRefuse(UserHelper.UserInfo.Id); } List <SHDJContract> agreeList = null; while (agreeList == null) { agreeList = _sc.QuerySignAgreeUndownload(UserHelper.UserInfo.Id); } // List<SHDJContract> penddingList = _sc.QuerySignPend(UserHelper.UserInfo.Id); // List<SHDJContract> refuseList = _sc.QuerySignRefuse(UserHelper.UserInfo.Id); //// List<SHDJContract> agreeList = _sc.QuerySignAgree(UserHelper.UserInfo.Id); // List<SHDJContract> agreeList = _sc.QuerySignAgreeUndownload(UserHelper.UserInfo.Id); // 只有当数据发生变化的时候,才需要跟新数据 // 首先如果全局数据为空,说明定时器第一次启动,则需要进行一次数据绑定 // 其次当数据存储更新时才更新数据 if (UserHelper.PenddingList != null && UserHelper.RefuseList != null && UserHelper.AgreeList != null && penddingList.Count == UserHelper.PenddingList.Count && refuseList.Count == UserHelper.RefuseList.Count && agreeList.Count == UserHelper.AgreeList.Count) { return; } // if (UserHelper.PenddingList == null //|| UserHelper.RefuseList == null //|| UserHelper.AgreeList == null //|| penddingList.Count != UserHelper.PenddingList.Count //|| refuseList.Count != UserHelper.RefuseList.Count //|| agreeList.Count != UserHelper.AgreeList.Count) //{ if (penddingList != null) { UserHelper.PenddingList = penddingList; } if (refuseList != null) { UserHelper.RefuseList = refuseList; } if (agreeList != null) { UserHelper.AgreeList = agreeList; } for (int i = 0; i < Application.OpenForms.Count; i++) { if (Application.OpenForms[i].Name == "SubmitManage") { ((SubmitManage)Application.OpenForms[i]).SignPendding.DataSource = UserHelper.PenddingList; ((SubmitManage)Application.OpenForms[i]).SignRefuse.DataSource = UserHelper.RefuseList; ((SubmitManage)Application.OpenForms[i]).SignAgree.DataSource = UserHelper.AgreeList; } } //} int sum = UserHelper.PenddingList.Count + UserHelper.RefuseList.Count + UserHelper.AgreeList.Count; if (sum > 0) { foreach (TreeNode n in this.treeView1.Nodes) { if (n.Text == "提交管理") { n.Text = "提交管理(" + sum + ")"; if (UserHelper.PenddingList.Count > 0) { n.Nodes[1].Text = "审核中(" + UserHelper.PenddingList.Count + ")"; } if (UserHelper.RefuseList.Count > 0) { n.Nodes[2].Text = "已拒绝(" + UserHelper.RefuseList.Count + ")"; MessageBox.Show("您有新的提交方案被拒绝,请及时查看!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (UserHelper.AgreeList.Count > 0) { n.Nodes[3].Text = "已通过(" + UserHelper.AgreeList.Count + ")"; } } else if (n.Text.Contains("提交管理(")) { n.Text = "提交管理(" + sum + ")"; if (UserHelper.PenddingList.Count > 0) { n.Nodes[1].Text = "审核中(" + UserHelper.PenddingList.Count + ")"; } else { n.Nodes[1].Text = "审核中"; } if (UserHelper.RefuseList.Count > 0) { n.Nodes[2].Text = "已拒绝(" + UserHelper.RefuseList.Count + ")"; } else { n.Nodes[2].Text = "已拒绝"; } if (UserHelper.AgreeList.Count > 0) { n.Nodes[3].Text = "已通过(" + UserHelper.AgreeList.Count + ")"; } else { n.Nodes[3].Text = "已通过"; } } } } else { foreach (TreeNode n in this.treeView1.Nodes) { if (n.Name == "SubmitManage") { n.Text = "提交管理"; n.Nodes[1].Text = "审核中"; n.Nodes[2].Text = "已拒绝"; n.Nodes[3].Text = "已通过"; break; } } } } catch (Exception e) { //throw; Logging.AddLog(e.Message + "HelloWord" + e.TargetSite); } }