コード例 #1
0
        /// <summary>
        /// 生成报文体
        /// </summary>
        /// yaoy    16.07.05
        /// <param name="fileId"></param>
        /// <param name="messageTypeId"></param>
        /// <param name="i"></param>
        /// <returns></returns>
        public string BuildMessageBody(int fileId, int messageTypeId, out int i)
        {
            int    j = 0;
            string messageBodyData = string.Empty;

            DataAndRuleComPare  compare      = new DataAndRuleComPare();
            List <InfoTypeInfo> infoTypeList = _dataRule.GetInfoTypeList(messageTypeId);

            // 遍历信息类型
            foreach (InfoTypeInfo infoTypeInfo in infoTypeList)
            {
                InfoTypeInfo infoType = _dataRule.GetDataRuleByInfoTypeId(infoTypeInfo.InfoTypeId);
                List <InformationRecordInfo> informationRecordList = _dataRule.GetInformationListByInfoTypeIdAndFileId(infoTypeInfo.InfoTypeId, fileId);

                if (informationRecordList != null)
                {
                    // 遍历信息记录
                    foreach (InformationRecordInfo informationRecordInfo in informationRecordList)
                    {
                        j++;

                        var context = informationRecordInfo.Context;
                        messageBodyData += new DataRule().ReplaceData(compare.EncapsulateData(infoType, context)) + "\r\n";
                    }
                }
            }

            i = j;

            return(messageBodyData);
        }
コード例 #2
0
        /// <summary>
        /// 添加信息记录数据校验
        /// </summary>
        /// yaoy    16.09.26
        /// <param name="postmessage"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool AddInfomationData(PostMessage postmessage, ref string message)
        {
            var result = true;

            MessageInfo messageInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <MessageInfo>(postmessage.Value);

            InfoTypeInfo        infoType            = new DataRule().GetDataRuleByInfoTypeId(postmessage.InfoTypeId);
            MessageFileTypeInfo messageFileTypeInfo = new DataRule().GetMessageFileTypeInfoById(postmessage.messageTypeID);

            // 数据合法性校验
            result &= new DataAndRuleComPare().Compare(infoType, postmessage.recordID, postmessage.ReportId, messageInfo, postmessage, ref message);

            // 数据规则校验
            // 企业通用规则校验
            if (messageFileTypeInfo.FileType == 1)
            {
                result &= new Validates.ComInformationValidate(infoType.InfoTypeId, messageInfo).BaseValidateMethod();
            }
            // 个人通用规则校验
            else
            {
                result &= new Validates.PerInformationValidate(infoType.InfoTypeId, messageInfo).BaseValidateMethod();
            }

            return(result);
        }
コード例 #3
0
ファイル: ReportFiles.cs プロジェクト: poppyred/ShrileFinance
        /// <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);
        }
コード例 #4
0
        /// <summary>
        /// 补位
        /// </summary>
        /// yaoy    16.06.01
        /// yand    16.08.02 修改
        /// <param name="metaInfo"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public string ComplementBits(MetaInfo metaInfo, string value)
        {
            int GBlength  = System.Text.Encoding.GetEncoding("GB2312").GetByteCount(value);//用于获取字符串转换成GB2312的长度
            int EncLength = value.Length;

            if (metaInfo != null)
            {
                MetaComponentsInfo metaComponentsInfo = new DataRule().GetMetaComponentsInfoByCode(metaInfo.MetaCode);

                // 特殊时间控件
                if (metaComponentsInfo.HtmlElementId == 9)
                {
                    var length = metaInfo.DatasLength;

                    if (length == 8)
                    {
                        value = DateTime.Now.ToString("yyyyMMdd");
                    }
                    if (length == 14)
                    {
                        value = DateTime.Now.ToString("yyyyMMddHHmmss");
                    }
                }

                //经营场地所有权、借款人成立年份、四级分类
                if ((metaInfo.MetaCode == 2503 || metaInfo.MetaCode == 8503 || metaInfo.MetaCode == 7539) && string.IsNullOrEmpty(value))
                {
                    value = value.PadLeft(metaInfo.DatasLength, ' ');
                }
                switch (metaInfo.DataType)
                {
                case "N":
                    value = value.PadLeft(metaInfo.DatasLength, '0');
                    value = value.Substring(GBlength - EncLength, value.Length);
                    break;

                case "AN":
                    value = value.PadRight(metaInfo.DatasLength, ' ');
                    value = value.Substring(0, value.Length - (GBlength - EncLength));
                    break;

                case "ANC":
                    value = value.PadRight(metaInfo.DatasLength, ' ');
                    value = value.Substring(0, value.Length - (GBlength - EncLength));
                    break;

                default:
                    return(null);
                }
            }

            return(value);
        }
コード例 #5
0
ファイル: DataUtil.cs プロジェクト: poppyred/ShrileFinance
        /// <summary>
        /// 生成txt文件
        /// </summary>
        /// yaoy    16.07.06
        /// <param name="fileId"></param>
        /// <returns></returns>
        public string CreateTxtFile(int fileId, string message)
        {
            string fileName    = string.Empty;
            string txtFileName = string.Empty;
            // 文件路径
            string dirPath = HttpContext.Current.Server.MapPath(path);

            ICombinaData combinaComData = new CombinaComMessageData();
            ICombinaData combinaPerData = new CombinaPerMessageData();

            ReportFilesInfo reportFilesInfo = new DataRule().GetReportFilesInfoById(fileId);

            // 获取服务对象
            int serviceObj = reportFilesInfo == null ? 0 : reportFilesInfo.ServiceObj;

            // 企业报文
            if (serviceObj == 1)
            {
                txtFileName = combinaComData.BuildMessageName(fileId);
            }
            // 个人报文
            if (serviceObj == 2)
            {
                txtFileName = combinaPerData.BuildMessageName(fileId);
            }

            if (!DirFile.IsExistDirectory(dirPath))
            {
                DirFile.CreateDirectory(dirPath);
            }

            if (txtFileName != string.Empty)
            {
                fileName = txtFileName + ".txt";
                string filePath = dirPath + fileName;

                DirFile.CreateFile(filePath);
                DirFile.WriteText(filePath, message, Encoding.GetEncoding("gb2312"));
            }

            return(fileName);
        }
コード例 #6
0
ファイル: DynamicLoad.cs プロジェクト: poppyred/ShrileFinance
        /// <summary>
        /// 根据段ID获取段中元素实体
        /// </summary>
        /// yand    16.07.04
        /// zouql   16.09.20    新增RuleType
        /// <param name="DataSegmentId">段ID</param>
        /// <returns></returns>
        public List <ComponentInfo> ComponentList(int DataSegmentId)
        {
            List <ComponentInfo> componentList = new List <ComponentInfo>();

            // 获取数据段规则
            List <SegmentRulesInfo> segmentRulesList = segmentRuleMapper.List(DataSegmentId);
            List <MetaInfo>         metaList         = new List <MetaInfo>();

            for (int i = 0; i < segmentRulesList.Count; i++)
            {
                // 获取数据元
                MetaInfo metaInfo = metaMapper.Find(segmentRulesList[i].MetaCode);
                metaInfo.RuleType = new RuleType().Get(metaInfo.RuleType.RuleTypeId);

                // 获取HTML标签
                List <HtmlElementInfo> htmlElementList             = new DAL.BankCredit.HtmlElementMapper().Find(segmentRulesList[i].MetaCode);
                MetaComponentsInfo     GetMetaComponentsInfoByCode = new DataRule().GetMetaComponentsInfoByCode(segmentRulesList[i].MetaCode);
                // 一个数据元可能对应多个标签
                for (int j = 0; j < htmlElementList.Count; j++)
                {
                    ComponentInfo componentInfo = new ComponentInfo();
                    componentInfo.HtmlElement    = htmlElementList[j].Html;
                    componentInfo.HtmlelementId  = htmlElementList[j].HtmlElementID;
                    componentInfo.Type           = GetMetaComponentsInfoByCode.Type;
                    componentInfo.IsRequired     = segmentRulesList[i].IsRequired;
                    componentInfo.Length         = metaInfo.DatasLength;
                    componentInfo.MetaName       = metaInfo.Name;
                    componentInfo.DataType       = metaInfo.DataType;
                    componentInfo.MetaCode       = metaInfo.MetaCode;
                    componentInfo.SegmentRulesId = segmentRulesList[i].SegmentRulesId;
                    componentInfo.Description    = segmentRulesList[i].Description;
                    componentInfo.RuleType       = metaInfo.RuleType ?? new RuleTypeInfo();
                    componentList.Add(componentInfo);
                }
            }

            return(componentList);
        }