// 撤销 private void barRepeal_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (!Utils.CheckUser()) { return; } try { //获取撤销的数据 List <string> vinList = new List <string>(); this.dgvCljbxx.DefaultView.PostEditor(); DataTable dt = (DataTable)this.dgvCljbxx.DataSource; if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { bool result = false; bool.TryParse(dt.Rows[i]["check"].ToString(), out result); if (result) { string vin = (string)dt.Rows[i]["vin"]; vinList.Add(vin); } } } if (vinList == null || vinList.Count < 1) { MessageBox.Show("请选择要撤销的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string delReason = string.Empty; ReasonForm rf = new ReasonForm(); Utils.SetFormMid(rf); rf.Text = "撤销原因"; rf.ShowDialog(); //Utils.Open("DELETE"); if (rf.DialogResult == DialogResult.OK) { pf = new ProcessForm(); pf.Show(); delReason = rf.Reason; // 撤销 List <OperateResult> orList = this.ApplyParamMultiRows(vinList, delReason); // 获取撤销结果 List <string> vinsSucc = new List <string>(); List <NameValuePair> vinsFail = new List <NameValuePair>(); Dictionary <string, string> dSuccVinVid = new Dictionary <string, string>(); Utils.getOperateResultListVins(orList, vinsSucc, vinsFail, dSuccVinVid); string strSucc = "";// "备案号(VIN):返回码(VID)"; // 修改本地状态为“3:已撤销” if (vinsSucc.Count > 0) { string strUpdate = ""; for (int i = 0; i < vinsSucc.Count; i++) { strUpdate += String.Format(",'{0}'", vinsSucc[i]); strSucc += String.Format("备案号(VIN):{0},\r反馈码(VID):{1}, \r成功 \r\n", vinsSucc[i], dSuccVinVid[vinsSucc[i]]); } // 删除已撤销数据 //Utils.DelVin(strUpdate.Substring(1)); DelteLocalData(strUpdate.Substring(1)); //Utils.setStatusForUpload(strUpdate.Substring(1), "3"); //// 反馈码入库 //Utils.setVidForUpload(dSuccVinVid); // 刷新当前页面 int pageNum = Convert.ToInt32(txtPage.Text.Substring(0, txtPage.Text.LastIndexOf("/"))); this.SearchLocal(pageNum); } string strFail = ""; if (vinsFail.Count > 0) { for (int i = 0; i < vinsFail.Count; i++) { strFail += String.Format("备案号(VIN):{0},\r反馈码(VID):, \r失败:{1} \r\n", vinsFail[i].Name, vinsFail[i].Value); } } string summary = string.Format("{0}条申请成功\r\n {1}条申请失败\r\n", vinsSucc.Count, vinsFail.Count); MessageForm mf = new MessageForm(String.Format("{0}{1} \n{2}", summary, strSucc, strFail)); Utils.SetFormMid(mf); mf.Text = "申请撤销结果"; mf.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (pf != null) { pf.Close(); } //Utils.Close("DELETE"); } }
private void btnUploadOT_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (!Utils.CheckUser()) { return; } try { //获取补传的数据 List <string> vinList = new List <string>(); this.dgvCljbxx.DefaultView.PostEditor(); DataTable dt = (DataTable)this.dgvCljbxx.DataSource; if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { bool result = false; bool.TryParse(dt.Rows[i]["check"].ToString(), out result); if (result) { string vin = String.Format("'{0}'", dt.Rows[i]["vin"]); vinList.Add(vin); } } } if (vinList == null || vinList.Count < 1) { MessageBox.Show("请选择要补传的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string delReason = string.Empty; ReasonForm rf = new ReasonForm(); Utils.SetFormMid(rf); rf.Text = "补传原因"; rf.ShowDialog(); //Utils.Open("INSERT_O"); if (rf.DialogResult == DialogResult.OK) { pf = new ProcessForm(); pf.Show(); // 补传 List <OperateResult> orList = this.applyOTParamMultiRows(vinList, rf.Reason); // 获取补传结果 List <string> vinsSucc = new List <string>(); List <NameValuePair> vinsFail = new List <NameValuePair>(); Dictionary <string, string> dSuccVinVid = new Dictionary <string, string>(); Utils.getOperateResultListVins(orList, vinsSucc, vinsFail, dSuccVinVid); string strSucc = "";// "备案号(VIN):返回码(VID)"; // 修改本地状态为“4:已申请补传” if (vinsSucc.Count > 0) { string strUpdate = ""; for (int i = 0; i < vinsSucc.Count; i++) { strUpdate += String.Format(",'{0}'", vinsSucc[i]); strSucc += String.Format("备案号(VIN):{0},\r反馈码(VID):{1}, \r成功 \r\n", vinsSucc[i], dSuccVinVid[vinsSucc[i]]); } //Utils.setStatusForUpload(strUpdate.Substring(1), "0"); //// 反馈码入库 //Utils.setVidForUpload(dSuccVinVid); Utils.setVidStatusForUpload(dSuccVinVid); // 刷新当前页面 this.searchLocal(); } string strFail = ""; if (vinsFail.Count > 0) { for (int i = 0; i < vinsFail.Count; i++) { strFail += String.Format("备案号(VIN):{0},\r反馈码(VID):, \r失败: {1} \r\n", vinsFail[i].Name, vinsFail[i].Value); } } string summary = string.Format("{0}条补传成功\r\n {1}条补传失败\r\n", vinsSucc.Count, vinsFail.Count); MessageForm mf = new MessageForm(String.Format("{0}{1} \n{2}", summary, strSucc, strFail)); Utils.SetFormMid(mf); mf.Text = "补传结果"; mf.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (pf != null) { pf.Close(); } //关端口 //Utils.Close("INSERT_O"); } }
// 上报已修改的信息 private void barUpdate_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (!Utils.CheckUser()) { return; } try { //获取上报修改的数据 List <string> vinList = new List <string>(); this.dgvCljbxx.DefaultView.PostEditor(); DataTable dt = (DataTable)this.dgvCljbxx.DataSource; if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { bool result = false; bool.TryParse(dt.Rows[i]["check"].ToString(), out result); if (result) { string vin = String.Format("'{0}'", dt.Rows[i]["vin"]); vinList.Add(vin); } } } if (vinList == null || vinList.Count < 1) { MessageBox.Show("请选择要上报修改的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ReasonForm rf = new ReasonForm(); Utils.SetFormMid(rf); rf.Text = "修改原因"; rf.ShowDialog(); //Utils.Open("UPDATE"); if (rf.DialogResult == DialogResult.OK) { pf = new ProcessForm(); pf.Show(); // 发出修改 List <OperateResult> orList = this.ApplyParamMultiRows(vinList, rf.Reason); //FuelDataSysClient.FuelDataService.OperateResult sor = service.ApplyUpdate(Utils.userId, Utils.password, Utils.FuelInfoC2S(vbiList).ToArray(), "CATARC_CUSTOM_2012"); //OperateResult or = Utils.OperateResultS2C(sor); // 获取修改结果 List <string> vinsSucc = new List <string>(); List <NameValuePair> vinsFail = new List <NameValuePair>(); Dictionary <string, string> dSuccVinVid = new Dictionary <string, string>(); //Utils.getOperateResultVins(or, vinsSucc, vinsFail, dSuccVinVid); Utils.getOperateResultListVins(orList, vinsSucc, vinsFail, dSuccVinVid); string strSucc = "";// "备案号(VIN):返回码(VID)"; // 修改本地状态为“0:已上报” if (vinsSucc.Count > 0) { string strUpdate = ""; for (int i = 0; i < vinsSucc.Count; i++) { strUpdate += String.Format(",'{0}'", vinsSucc[i]); strSucc += String.Format("备案号(VIN):{0},\r反馈码(VID):{1}, \r成功 \r\n", vinsSucc[i], dSuccVinVid[vinsSucc[i]]); } //Utils.setStatusForUpload(strUpdate.Substring(1), "0"); //// 反馈码入库 //Utils.setVidForUpload(dSuccVinVid); Utils.setVidStatusForUpload(dSuccVinVid); // 刷新当前页面 this.searchLocal(); } string strFail = ""; if (vinsFail.Count > 0) { for (int i = 0; i < vinsFail.Count; i++) { strFail += String.Format("备案号(VIN):{0}, \r失败:\r\n{1} \r\n", vinsFail[i].Name, vinsFail[i].Value); } } string summary = string.Format("{0}条申请成功\r\n {1}条申请失败\r\n", vinsSucc.Count, vinsFail.Count); MessageForm mf = new MessageForm(String.Format("{0}{1} \n{2}", summary, strSucc, strFail)); Utils.SetFormMid(mf); mf.Text = "申请修改结果"; mf.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (pf != null) { pf.Close(); } //Utils.Close("UPDATE"); } }
// 上报信息 public List <OperateResult> ApplyParamMultiRows(List <string> vinList) { // 一次调用接口上传数据条数 int pageSize = 50; // 返回结果 FuelDataService.OperateResult result = null; List <FuelDataService.OperateResult> resSerList = new List <FuelDataService.OperateResult>(); List <FuelDataModel.OperateResult> resCltList = new List <OperateResult>(); // 分组上传时的VIN临时变量 List <string> tempList = new List <string>(); pf.TotalMax = (int)Math.Ceiling((decimal)vinList.Count / (decimal)pageSize); pf.ShowProcessBar(); try { // 上报 if (vinList.Count > 0) { for (int i = 0; i < vinList.Count;) { // 最后一组上传不足50条 if (vinList.Count < pageSize) { pageSize = vinList.Count; } // 截取剩余记录中的pageSize条 var res = vinList.Take(pageSize); tempList = (from string s in res select s).ToList <string>(); List <VehicleBasicInfo> vbiList = Utils.GetApplyParam(tempList); // 上传 result = Utils.service.UploadInsertFuelDataList(Utils.userId, Utils.password, Utils.FuelInfoC2S(vbiList).ToArray(), "CATARC_CUSTOM_2012"); resSerList.Add(result); // 移除已上传的pageSize条记录 var leftRes = vinList.Skip(pageSize); vinList = (from string s in leftRes select s).ToList <string>(); pf.progressBarControl1.PerformStep(); Application.DoEvents(); } } else { return(null); } // 将service端OperateResult转换为Client端 foreach (FuelDataService.OperateResult res in resSerList) { resCltList.Add(Utils.OperateResultS2C(res)); } pf.Close(); } catch (Exception ex) { MessageBox.Show("上报过程发生异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(resCltList); }