/// <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);
        }
Esempio n. 2
0
        /// <summary>
        /// 补位
        /// </summary>
        /// yaoy 16.07.11
        /// <param name="data"></param>
        /// <param name="dataSegmentId"></param>
        /// <returns></returns>
        public string CoverPosition(string data, int dataSegmentId)
        {
            string str = string.Empty;

            DataSegmentInfo         dataSegmentInfo  = GetDataSegmentInfoById(dataSegmentId);
            List <SegmentRulesInfo> segmentRulesList = GetSegmentRulesList(dataSegmentId);

            if (segmentRulesList != null)
            {
                foreach (SegmentRulesInfo segmentRulesInfo in segmentRulesList)
                {
                    MetaInfo           metaInfo           = GetMetaInfoByCode(segmentRulesInfo.MetaCode);
                    MetaComponentsInfo metaComponentsInfo = GetMetaComponentsInfoByCode(segmentRulesInfo.MetaCode);

                    if (metaInfo != null && metaComponentsInfo != null)
                    {
                        var start = segmentRulesInfo.Position - 1;
                        str  = new DataAndRuleComPare().ComplementBits(metaInfo, string.Empty);
                        data = data.Insert(start, str);
                    }
                }
            }

            return(data);
        }
        /// <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);
        }