/// <summary> /// 生成报文头 /// </summary> /// yaoy 16.07.05 /// <param name="fileId"></param> /// <param name="messageTypeId"></param> /// <returns></returns> public string BuildMessageTop(int fileId, int messageTypeId, int i) { // 报文头临时变量 string messageTopData = string.Empty; // 补位码临时变量 string complementBits = string.Empty; // 版本号 string version = "A2.1"; // 企业金融机构代码 string comFinancialInstitutionCode = "33207991216"; // 获取报文文件信息 ReportFilesInfo reportFilesInfo = _dataRule.GetReportFilesInfoById(fileId); int messageFileId = reportFilesInfo == null ? 0 : reportFilesInfo.MessageFileId; MessageFileInfo messageFileInfo = _dataRule.GetMessageFileInfoById(messageFileId); int messageFileTypeId = messageFileInfo == null ? 0 : messageFileInfo.MessageFileTypeId; MessageTypeInfo messageTypeInfo = _dataRule.GetMessageTypeInfoById(messageTypeId); string messageTypeCode = messageTypeInfo == null ? string.Empty : messageTypeInfo.BMP_Code; // 采集类报文文件 if (messageFileTypeId == 1) { messageTopData = version + comFinancialInstitutionCode + DateTime.Now.ToString("yyyyMMddHHmmss") + messageTypeCode + complementBits.PadRight(30, ' '); } // 业务管理类报文文件 if (messageFileTypeId == 2) { } // 反馈类报文文件 if (messageFileTypeId == 3) { } return(messageTopData); }
/// <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.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.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); }
public HttpResponseMessage GetFileTxt(int reportFileID) { HttpResponseMessage response = new HttpResponseMessage(); ReportFilesInfo rfInfo = _files.Get(reportFileID); string path = @"~\upload\messageFile\"; string fullpath = HttpContext.Current.Server.MapPath(path); string Filepath = fullpath + rfInfo.ReportTextName; response = GetFile(Filepath, rfInfo.ReportTextName); return(response); }
public bool Save(int FileId, string FilesName, string Remarks) { bool result = false; ReportFilesInfo reportFileInfo = new ReportFilesInfo(); reportFileInfo.FileID = FileId; reportFileInfo.FilesName = FilesName; reportFileInfo.Remarks = Remarks; result = reportFilesMapper.UpdateRemarks(reportFileInfo) > 0; return(result); }
/// <summary> /// 封装报文文件 /// </summary> /// yaoy 16.07.06 /// <param name="fileId"></param> /// <returns></returns> public string CombinaReportData(int fileId) { int i = 0; string reportData = string.Empty; ICombinaData combinaComData = new CombinaComMessageData(); ICombinaData combinaPerData = new CombinaPerMessageData(); ReportFilesInfo reportFilesInfo = GetReportFilesInfoById(fileId); int messageFileId = reportFilesInfo == null ? 0 : reportFilesInfo.MessageFileId; // 获取服务对象 int serviceObj = reportFilesInfo == null ? 0 : reportFilesInfo.ServiceObj; List <MessageTypeInfo> messageTypeList = GetMessageTypeList(messageFileId); if (messageTypeList != null) { foreach (MessageTypeInfo messageTypeInfo in messageTypeList) { if (serviceObj == 1) { string temp = combinaComData.BuildMessageBody(fileId, messageTypeInfo.MessageTypeId, out i); if (temp == "") { reportData += combinaComData.BuildMessageTop(fileId, messageTypeInfo.MessageTypeId, i) + "\r\n" + new DataUtil().BuildMessageTail(i) + "\r\n\r\n"; } else { reportData += combinaComData.BuildMessageTop(fileId, messageTypeInfo.MessageTypeId, i) + "\r\n" + temp + new DataUtil().BuildMessageTail(i) + "\r\n\r\n"; } } if (serviceObj == 2) { string temp = combinaPerData.BuildMessageBody(fileId, messageTypeInfo.MessageTypeId, out i); if (temp != "") { reportData += combinaPerData.BuildMessageTop(fileId, messageTypeInfo.MessageTypeId, i) + "\r\n\r\n" + temp + "\r\n"; } } } // 去掉最后一个换行符("\r\n") reportData = reportData.Substring(0, reportData.Length - 4); } return(reportData); }
/// <summary> /// 生成报文头 /// </summary> /// yaoy 16.07.05 /// <param name="fileId"></param> /// <param name="messageTypeId"></param> /// <returns></returns> public string BuildMessageTop(int fileId, int messageTypeId, int i) { //TODO:个人报文头需要获取“最早结算/应还款日期”和“最晚结算/应还款日期”获取联系人和联系电话 string Name = "严冬"; int GBlength = System.Text.Encoding.GetEncoding("GB2312").GetByteCount(Name);//用于获取字符串转换成GB2312的长度 int EncLength = Name.Length; Name = Name.PadRight(30, ' '); Name = Name.Substring(0, Name.Length - (GBlength - EncLength)); string Phone = "15824430950"; // 报文头临时变量 string messageTopData = string.Empty; // 补位码临时变量 string complementBits = string.Empty; // 版本号 string version = "1.3"; // 个人金融机构代码 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; string tempDate = GetValue(fileId); // 正常报文文件 if (messageFileTypeId == 4 && tempDate != "") { messageTopData = version + perFinancialInstitutionCode + DateTime.Now.ToString("yyyyMMddHHmmss") + "1.0" + "11" + i.ToString().PadLeft(10, '0') + tempDate + Name + Phone.PadRight(25, ' ') + string.Empty.PadLeft(30, ' '); } // 账户标识变更报文文件 if (messageFileTypeId == 5) { messageTopData = version + DateTime.Now.ToString("yyyyMMddHHmmss") + perFinancialInstitutionCode + "4" + i.ToString().PadLeft(8, '0'); } // 删除报文文件 if (messageFileTypeId == 6) { messageTopData = version + DateTime.Now.ToString("yyyyMMddHHmmss") + perFinancialInstitutionCode + i.ToString().PadLeft(8, '0') + "000000000000000000000000000000" + "0000000000000000000000000" + string.Empty.PadLeft(30, ' '); } return(messageTopData); }
/// <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); }
/// <summary> /// 添加 /// </summary> /// yaoy 16.05.25 /// <param name="value"></param> /// <returns></returns> public int Add(NameValueCollection data) { bool result = true; int reportFilesId = 0; ReportFilesInfo value = new ReportFilesInfo(); value.MessageFileId = Convert.ToInt32(data["messageFileId"].ToString()); value.ServiceObj = Convert.ToInt32(data["serviceObj"].ToString()); value.ReportState = 3;//编辑状态 value.CreateTime = DateTime.Now; value.Operator = new BLL.User.User().CurrentUser().Name; //获取报文类型列表 List <MessageTypeInfo> list = messageTypeMapper.List(value.MessageFileId); ReportInfo report = new ReportInfo(); using (TransactionScope scope = new TransactionScope()) { reportFilesId = reportFilesMapper.Insert(value); result = reportFilesId > 0; report.ReportFileID = reportFilesId; foreach (var item in list) { report.MessageTypeID = item.MessageTypeId; reportMapper.Insert(report); result = report.ReportID > 0; } if (result) { scope.Complete(); } } return(reportFilesId); }
public IHttpActionResult Modify(ReportFilesInfo value) { return(_files.Modify(value) ? (IHttpActionResult)Ok() : BadRequest("修改失败")); }
public int Add(ReportFilesInfo value) { NameValueCollection data = ApiHelper.GetParameters(); return(_files.Add(data)); }
/// <summary> /// 修改 /// </summary> /// yaoy 16.05.25 /// <param name="value"></param> /// <returns></returns> public bool Modify(ReportFilesInfo value) { return(reportFilesMapper.Update(value) > 0); }