/// <summary> /// 数据上报,只上报BIZANDREP.status为1的数据 /// </summary> /// <param name="qx"></param> public void DataSubmit(QXType qx, ExcuteTaskType et) { if (qx == QXType.None) { return; } //ShowDialogForm sdf = null; try { switch (qx) { case QXType.QY: db = new Database("qysubmit"); qxdm = "371423"; break; case QXType.QH: db = new Database("qhsubmit"); qxdm = "371425"; break; case QXType.PY: db = new Database("pysubmit"); qxdm = "371426"; break; case QXType.XJ: db = new Database("xjsubmit"); qxdm = "371427"; break; default: break; } sjdb = new Database("sjsubmit"); int istatus = (int)STATUSType.DefaultValue; string qrySQL = @"select * from RNANDCN t where exists (select * from BIZANDREP s where s.qxdm='" + qxdm + "' and s.status=" + istatus + " and s.ywh=t.ywh) and t.qxdm='" + qxdm + "' "; //List<BIZANDREP> lstBAR = curContext.GetList<BIZANDREP>(" where qxdm='" + qxdm + "' and status=" + istatus + "").ToList(); List <RNANDCN> lstRC = sjdb.Fetch <RNANDCN>(qrySQL); // SJbaseHelper.ConvertToList<RNANDCN>(SJbaseHelper.ExecuteDataReader(SJprovider, qrySQL)).ToList(); // SJprovider.Close(); if (!string.IsNullOrEmpty(lcqxdm)) { if (lstRC != null) { string qrySQL2 = @"select * from RNANDCN t where exists (select * from BIZANDREP s where s.qxdm='" + lcqxdm + "' and s.status=" + istatus + " and s.ywh=t.ywh) and t.qxdm='" + lcqxdm + "' "; List <RNANDCN> lstRC2 = sjdb.Fetch <RNANDCN>(qrySQL); //SJbaseHelper.ConvertToList<RNANDCN>(SJbaseHelper.ExecuteDataReader(SJprovider, qrySQL2)).ToList(); // SJprovider.Close(); if (lstRC2 != null) { lstRC.AddRange(lstRC2); } } } CheckBusinessTables cbt = XMLHelper.DeserializeByXmlFilePath <CheckBusinessTables>(SystemHandler.CheckBusinessTablesXMLFilePath); if (lstRC != null && lstRC.Count > 0) { int totalMain = lstRC.Count; if (et == ExcuteTaskType.Show) { //sdf = new ShowDialogForm("提示", "正在生成上报数据...", "请稍候"); //sdf.SetProgress(totalMain); } foreach (var rc in lstRC) { Head hd = null; string xmlPath = ""; try { // BusinessTypeClass btc = cbt.Business.Where(p => rc.JRYWBM.Equals(p.BusinessCode)).FirstOrDefault(); if (et == ExcuteTaskType.Show) { } //sdf.SetMessage("正在生成业务号:" + rc.YWH + " 报文数据"); if (btc != null) { List <TableClass> lstTables = btc.检查表.Where(p => p.是否必选).ToList(); if (lstTables != null) { hd = HeadHandler.Instance.ConstructHead(rc); List <dynamic> lstEntitys = new List <dynamic>(); dynamic entity = null; Assembly pAssembly = Assembly.LoadFrom(SystemHandler.assPath); foreach (var item in lstTables) { entity = pAssembly.CreateInstance("BDCSubmit.Business.SubmitModel." + item.表名); if (et == ExcuteTaskType.Show) { } //sdf.SetContentEX("正在生成表:" + item.表名 + "数据"); lstEntitys.AddRange(GetSJInstance(item.表名, rc, db)); } //生成xml //1 XElement ele = XMLHelper.CreateBizEX <dynamic>(hd, lstEntitys); //2 XElement root = XElement.Load(SystemHandler.configFilePath); //3 List <City> lstCity = SystemHandler.Instance.GetGeneralCitys(); City city = lstCity.Where(p => qxdm.Equals(p.CityCode)).FirstOrDefault(); if (city != null) { string BizMsgPath = city.BizMsgPath; if (!string.IsNullOrEmpty(BizMsgPath) && Directory.Exists(BizMsgPath)) { xmlPath = BizMsgPath + "/" + "Biz" + hd.BizMsgID + ".xml"; ele.Save(xmlPath); HeadHandler.Instance.CreateMsgWithSignature(xmlPath); //每次修改完,这要重新保存一下 //修改市级 BIZANDREP.STATUS值 BIZANDREP bar = sjdb.Fetch <BIZANDREP>(" where qxdm='" + qxdm + "' and ywh='" + rc.YWH + "'").FirstOrDefault(); bar.STATUS = (int)STATUSType.Submiting; bar.BIZFILEPATH = xmlPath; bar.BIZMSGID = hd.BizMsgID; sjdb.Update(bar); //修改区县 BIZANDREP.STATUS值 BIZANDREP qxbar = db.Fetch <BIZANDREP>(" where qxdm='" + qxdm + "' and ywh='" + rc.YWH + "'").FirstOrDefault(); if (qxbar != null) { qxbar.STATUS = (int)STATUSType.Submiting; qxbar.BIZMSGID = hd.BizMsgID; db.Update(qxbar); } if (et == ExcuteTaskType.Show) { } //sdf.SetMessageEX("生成业务号:" + rc.YWH + " 报文数据完成"); } } } } } catch (Exception ex) { try { //删除生成的报文 if (!string.IsNullOrEmpty(xmlPath) && File.Exists(xmlPath)) { File.Delete(xmlPath); } // } catch { throw ex; } } } } } catch (Exception ex) { throw ex; } finally { //if (sdf != null) //{ // sdf.Close(); sdf.Dispose(); //} } }