/// <summary> /// 生成报文文件名 /// </summary> /// yaoy 16.07.05 /// <param name="fileId"></param> /// <returns></returns> public string BuildMessageName(int fileId) { string messageName = string.Empty; string messageFileType = string.Empty; int fileCount = 0; // 企业金融机构代码 string comFinancialInstitutionCode = "33207991216"; ReportFilesInfo reportFilesInfo = _dataRule.GetReportFilesInfoById(fileId); int messageFileId = reportFilesInfo == null ? 0 : reportFilesInfo.MessageFileId; int serviceObj = reportFilesInfo == null ? 0 : reportFilesInfo.ServiceObj; switch (messageFileId) { case 1: messageFileType = "11"; break; case 2: messageFileType = "12"; break; case 3: messageFileType = "14"; break; case 4: messageFileType = "31"; break; default: return(string.Empty); } string partnerName = "11" + comFinancialInstitutionCode + DateTime.Now.ToString("yyMMdd") + messageFileType + "1"; fileCount = new DAL.BankCredit.ReportFilesMapper().FindFileCount(partnerName); List <ReportFilesInfo> reportFileInfo = new DAL.BankCredit.ReportFilesMapper().FindFileByPartnerName(partnerName); if (reportFileInfo == null) { partnerName += "1".PadLeft(4, '0'); } else { partnerName += ((Convert.ToInt32(reportFileInfo[0].ReportTextName.Substring(22, 4))) + 1).ToString().PadLeft(4, '0'); } //if (fileCount >= 0 && fileCount < 9999) //{ // partnerName += (fileCount + 1).ToString().PadLeft(4, '0'); //} //else //{ // return string.Empty; //} messageName = partnerName + "00"; return(messageName); }
/// <summary> /// 生成报文名 /// </summary> /// yaoy 16.07.05 /// <param name="fileId"></param> /// <returns></returns> public string BuildMessageName(int fileId) { string messageName = string.Empty; string serialNumber = string.Empty; string serialNumberExt = string.Empty; string parterName = string.Empty; // 个人金融机构代码 string perFinancialInstitutionCode = "B10211000H0001"; ReportFilesInfo reportFilesInfo = _dataRule.GetReportFilesInfoById(fileId); int messageFileId = reportFilesInfo == null ? 0 : reportFilesInfo.MessageFileId; MessageFileInfo messageFileInfo = _dataRule.GetMessageFileInfoById(messageFileId); int messageFileTypeId = messageFileInfo == null ? 0 : messageFileInfo.MessageFileTypeId; if (messageFileTypeId == 4) { parterName = perFinancialInstitutionCode + DateTime.Now.ToString("yyyyMM"); } if (messageFileTypeId == 5) { parterName = perFinancialInstitutionCode + DateTime.Now.ToString("yyyyMMdd") + "04"; } if (messageFileTypeId == 6) { parterName = perFinancialInstitutionCode + DateTime.Now.ToString("yyyyMMdd") + "08"; } // 获取当天文件数量 int fileCount = new DAL.BankCredit.ReportFilesMapper().FindFileCount(parterName); if (fileCount >= 0) { string number = new DataUtil().ConvertTo36(fileCount + 1); if (number.Length <= 6 && number.Length >= 3) { serialNumber = number.Substring(0, 3); serialNumberExt = number.Substring(3, number.Length).PadLeft(3, '0'); } if (number.Length > 0 && number.Length < 3) { serialNumber = number.PadLeft(3, '0'); serialNumberExt = "000"; } } if (messageFileTypeId == 4) { messageName = parterName + serialNumber + "1" + serialNumberExt; } if (messageFileTypeId == 5) { messageName = parterName + "04" + serialNumber; } if (messageFileTypeId == 6) { messageName = parterName + "08" + serialNumber; } return(messageName); }
/// <summary> /// 发送报文文件信息 /// </summary> /// yaoy 16.07.04 /// <param name="fileId"></param> /// <returns></returns> public bool SendReportFileInfo(int fileId) { bool result = false; ReportFilesInfo reportFileInfo = new ReportFilesInfo(); // 生成报文文件内容 string reportFileContent = new DataRule().CombinaReportData(fileId); // 获取文件内容 if (reportFileContent != string.Empty) { // 获取文件名称 string reportFileName = new DataUtil().CreateTxtFile(fileId, reportFileContent); if (reportFileName != string.Empty) { ReportFilesInfo data = new DAL.BankCredit.ReportFilesMapper().Find(fileId); reportFileInfo.FileID = fileId; reportFileInfo.ReportState = 1; reportFileInfo.ServiceObj = data.ServiceObj; reportFileInfo.CreateTime = data.CreateTime; reportFileInfo.SendTime = DateTime.Now; reportFileInfo.MessageFileId = data.MessageFileId; reportFileInfo.ReportTextName = reportFileName; result = reportFilesMapper.Update(reportFileInfo) > 0; } } return(result); }
/// <summary> /// 信息记录保存 /// </summary> /// yand 16.06.02 /// <param name="infoType">信息记录实体</param> /// <param name="recordID">RecordID</param> /// <param name="messageInfo">报文实体</param> /// <param name="postmessage">前端参数</param> /// <param name="message"></param> /// <returns></returns> public bool Compare(InfoTypeInfo infoType, int recordID, int reportID, MessageInfo messageInfo, PostMessage postmessage, ref string message) { bool result = true; InformationRecordInfo informationRecord = new InformationRecordInfo(); informationRecord.InfoTypeID = postmessage.InfoTypeId; informationRecord.ReportID = postmessage.ReportId; informationRecord.Context = postmessage.Value; using (TransactionScope scope = new TransactionScope()) { informationRecord.Context = JsonConvert.SerializeObject(DataAndRuleCompare1(infoType, messageInfo, ref message)); if (recordID != 0) { informationRecord.RecordID = recordID; result &= DataAndRuleCompare(infoType, messageInfo, recordID, reportID, ref message) && new InformationRecord().Modify(informationRecord); } else { result &= DataAndRuleCompare(infoType, messageInfo, recordID, reportID, ref message) && new InformationRecord().Add(informationRecord); if (result) { DataTable dt = new DAL.BankCredit.ReportFilesMapper().FindData(postmessage.ReportId); if (dt.Rows.Count > 0) { ReportFilesInfo reportFile = new ReportFilesInfo(); // 已编辑 reportFile.ReportState = 2; reportFile.FileID = Convert.ToInt32(dt.Rows[0]["FileID"].ToString()); result = new DAL.BankCredit.ReportFilesMapper().UpdateState(reportFile) > 0; } } } if (result) { scope.Complete(); } } return(result); }