Ejemplo n.º 1
0
        /// <summary>
        /// 数据和规则校验
        /// </summary>
        /// yaoy    16.06.01
        /// <param name="infoType"></param>
        /// <param name="messageInfo"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool DataAndRuleCompare(InfoTypeInfo infoType, MessageInfo messageInfo, int recordID, int reportID, ref string message)
        {
            message = string.Empty;

            PropertyInfo[] ps = messageInfo.GetType().GetProperties();
            //数据校验

            foreach (PropertyInfo pi in ps)
            {
                List <Dictionary <string, string> > list = (List <Dictionary <string, string> >)pi.GetValue(messageInfo);
                if (pi.Name == "C" && list.Count > 0)
                {
                    ParagraphCode = pi.Name;
                }
                List <DataSegmentInfo> dataSegmentList = infoType.DataSegmentList;
                if (dataSegmentList != null)
                {
                    foreach (DataSegmentInfo dataSegmentInfo in dataSegmentList)
                    {
                        List <SegmentRulesInfo> segmentRulesList = dataSegmentInfo.SegmnetRulesList;

                        foreach (SegmentRulesInfo segmentRulesInfo in segmentRulesList)
                        {
                            MetaInfo metaInfo = segmentRulesInfo.MetaInfo;
                            if (list != null)
                            {
                                foreach (Dictionary <string, string> dic in list)
                                {
                                    foreach (var info in dic)
                                    {
                                        if (info.Key == dataSegmentInfo.ParagraphCode + segmentRulesInfo.SegmentRulesId.ToString())
                                        {
                                            if (info.Value != "")
                                            {
                                                bool result = DataValidate(infoType, metaInfo, info, dataSegmentInfo.ParagraphCode, recordID, reportID, ref message);
                                                if (result == false)
                                                {
                                                    return(false);
                                                }
                                            }
                                            else
                                            {
                                                if (segmentRulesInfo.IsRequired == "M")
                                                {
                                                    throw new ApplicationException(metaInfo.Name + "为必填项!");
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            Validates.ValidatesFactoryModel.Create(infoType.InfoTypeId, messageInfo);

            return(true);
        }
        /// <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);
        }
Ejemplo n.º 3
0
        private void LoadData()
        {
            int id = GetInt("id");

            if (id > 0)
            {
                CurrentInfoType = InfoTypes.Instance.GetModel(id);
                if (CurrentInfoType == null)
                {
                    WriteMessage("/message.aspx", "系统提示", "无效信息类型!", "", "/index.aspx");
                }
                else
                {
                    if (!Admin.Administrator && Admin.CorporationID != CurrentInfoType.CorporationID)
                    {
                        WriteMessage("/message.aspx", "系统提示", "没有权限!", "", "/index.aspx");
                    }
                    List <CustomerLevelInfo> cllist = CustomerLevels.Instance.GetListByCorpid(CurrentInfoType.CorporationID, true);
                    cblLocklevel.DataSource     = cllist;
                    cblLocklevel.DataTextField  = "Name";
                    cblLocklevel.DataValueField = "ID";
                    cblLocklevel.DataBind();
                    foreach (ListItem item in cblLocklevel.Items)
                    {
                        if (CurrentInfoType.Locklevel.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Contains(item.Value))
                        {
                            item.Selected = true;
                        }
                    }

                    txtName.Value = CurrentInfoType.Name;
                    SetSelectedByValue(rblLocked, CurrentInfoType.Locked.ToString());
                    txtLockday.Value = CurrentInfoType.Lockday.ToString();
                    if (!Admin.Administrator && CurrentInfoType.DataLevel == 0)
                    {
                        txtName.Attributes["readonly"] = "true";
                    }
                }
            }
            else
            {
                int corpid = GetInt("corpid");

                if (corpid > 0)
                {
                    List <CustomerLevelInfo> cllist = CustomerLevels.Instance.GetListByCorpid(corpid, true);
                    cblLocklevel.DataSource     = cllist;
                    cblLocklevel.DataTextField  = "Name";
                    cblLocklevel.DataValueField = "ID";
                    cblLocklevel.DataBind();
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 封装信息类型报文
        /// </summary>
        /// yaoy    16.06.01
        /// yand    16.07.15(修改)
        /// <returns></returns>
        public string EncapsulateData(InfoTypeInfo infoTypeInfo, string content)
        {
            string        result      = string.Empty;
            StringBuilder sb          = new StringBuilder();
            MessageInfo   messageInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <MessageInfo>(content);

            PropertyInfo[] ps = messageInfo.GetType().GetProperties();

            // 获取数据段列表
            List <DataSegmentInfo> dataSegmentList = infoTypeInfo.DataSegmentList;

            foreach (PropertyInfo pi in ps)
            {
                foreach (DataSegmentInfo dataSegment in dataSegmentList)
                {
                    // 获取数据段规则集合
                    List <SegmentRulesInfo> segmentRulesList = dataSegment.SegmnetRulesList;

                    // 获取段
                    List <Dictionary <string, string> > list = (List <Dictionary <string, string> >)pi.GetValue(messageInfo);

                    if (list != null)
                    {
                        foreach (Dictionary <string, string> dic in list)
                        {
                            foreach (SegmentRulesInfo segmentRules in segmentRulesList)
                            {
                                foreach (var info in dic)
                                {
                                    if (segmentRules != null)
                                    {
                                        // 获取数据元实体
                                        MetaInfo metaInfo = segmentRules.MetaInfo;

                                        // 判断前端传的Key值与数据段Code值和该数据段下的数据段规则Id值是否相等
                                        if (info.Key == dataSegment.ParagraphCode + segmentRules.SegmentRulesId.ToString())
                                        {
                                            // 判断前端传的Value值长度小于或等于元数据长度
                                            if (System.Text.Encoding.GetEncoding("GB2312").GetByteCount(info.Value) <= metaInfo.DatasLength)
                                            {
                                                sb.Append(ComplementBits(metaInfo, info.Value));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(sb.ToString());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 通过信息类型ID获取数据规则对象
        /// </summary>
        /// yaoy    16.05.27
        /// <param name="infoTypeId"></param>
        /// <returns></returns>
        public InfoTypeInfo GetDataRuleByInfoTypeId(int infoTypeId)
        {
            InfoTypeInfo infoTypeInfo = GetInfoTypeInfoById(infoTypeId);

            infoTypeInfo.DataSegmentList = GetDataSegmentList(infoTypeId);

            foreach (DataSegmentInfo dataSegmentInfo in infoTypeInfo.DataSegmentList)
            {
                dataSegmentInfo.SegmnetRulesList = GetSegmentRulesList(dataSegmentInfo.DataSegmentId);

                foreach (SegmentRulesInfo segmentRulesInfo in dataSegmentInfo.SegmnetRulesList)
                {
                    segmentRulesInfo.MetaInfo = GetMetaInfoByCode(segmentRulesInfo.MetaCode);
                }
            }

            return(infoTypeInfo);
        }
Ejemplo n.º 6
0
        /// <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);
        }
Ejemplo n.º 7
0
        private void FillData(InfoTypeInfo entity)
        {
            entity.Name          = txtName.Value;
            entity.Locked        = DataConvert.SafeInt(rblLocked.SelectedValue);
            entity.Lockday       = DataConvert.SafeInt(txtLockday.Value);
            entity.CorporationID = GetInt("corpid");
            List <string> locklevel     = new List <string>();
            List <string> locklevelname = new List <string>();

            foreach (ListItem item in cblLocklevel.Items)
            {
                if (item.Selected)
                {
                    locklevel.Add(item.Value);
                    locklevelname.Add(item.Text);
                }
            }
            entity.Locklevel     = string.Join("|", locklevel);
            entity.LocklevelName = string.Join(",", locklevelname);
        }
Ejemplo n.º 8
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            InfoTypeInfo entity = new InfoTypeInfo();
            int          id     = GetInt("id");

            if (id > 0)
            {
                entity = InfoTypes.Instance.GetModel(id, true);
                FillData(entity);
                InfoTypes.Instance.Update(entity);
            }
            else
            {
                FillData(entity);
                entity.DataLevel = GetInt("corpid") == 0 ? 0 : 1;
                InfoTypes.Instance.Add(entity);
            }

            InfoTypes.Instance.ReloadInfoTypeListCache();

            Response.Redirect(string.IsNullOrEmpty(FromUrl) ? "infotypemg.aspx" : FromUrl);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 用于补位
        /// </summary>
        /// yand    16.07.15 测试补充没有的字段
        /// <param name="infoType"></param>
        /// <param name="messageInfo"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public MessageInfo DataAndRuleCompare1(InfoTypeInfo infoType, MessageInfo messageInfo, ref string message)
        {
            message = string.Empty;

            PropertyInfo[] ps = messageInfo.GetType().GetProperties();

            foreach (PropertyInfo pi in ps)
            {
                List <Dictionary <string, string> > list = (List <Dictionary <string, string> >)pi.GetValue(messageInfo);
                List <DataSegmentInfo> dataSegmentList   = infoType.DataSegmentList;
                if (dataSegmentList != null)
                {
                    foreach (DataSegmentInfo dataSegmentInfo in dataSegmentList)
                    {
                        List <SegmentRulesInfo> segmentRulesList = dataSegmentInfo.SegmnetRulesList;

                        foreach (SegmentRulesInfo segmentRulesInfo in segmentRulesList)
                        {
                            MetaInfo metaInfo = segmentRulesInfo.MetaInfo;

                            if (list != null)
                            {
                                foreach (Dictionary <string, string> dic in list)
                                {
                                    if (pi.Name == dataSegmentInfo.ParagraphCode)
                                    {
                                        // 段标识
                                        if (metaInfo.MetaCode == 8105 || metaInfo.MetaCode == 7543)
                                        {
                                            dic.Add(dataSegmentInfo.ParagraphCode + segmentRulesInfo.SegmentRulesId, dataSegmentInfo.ParagraphCode);
                                        }

                                        // 信息记录长度
                                        else if (metaInfo.MetaCode == 8103 || metaInfo.MetaCode == 4501)
                                        {
                                            dic.Add(dataSegmentInfo.ParagraphCode + segmentRulesInfo.SegmentRulesId, "0");
                                        }

                                        //// 个人金融机构代码
                                        //else if (metaInfo.MetaCode == 6101)
                                        //{
                                        //    dic.Add(dataSegmentInfo.ParagraphCode + segmentRulesInfo.SegmentRulesId, "B10211000H0001");
                                        //}

                                        // 企业金融机构代码
                                        else if (metaInfo.MetaCode == 6501)
                                        {
                                            dic.Add(dataSegmentInfo.ParagraphCode + segmentRulesInfo.SegmentRulesId, "33207991216");
                                        }

                                        // 企业审计时间
                                        else if (metaInfo.MetaCode == 2589)
                                        {
                                            dic.Add(dataSegmentInfo.ParagraphCode + segmentRulesInfo.SegmentRulesId, DateTime.Now.ToString("yyyyMMdd"));
                                        }

                                        // 业务号
                                        //else if (metaInfo.MetaCode == 7101)
                                        //{
                                        //    dic.Add(dataSegmentInfo.ParagraphCode + segmentRulesInfo.SegmentRulesId, "999123123123999");
                                        //}

                                        // 信息记录跟踪编号
                                        else if (metaInfo.MetaCode == 7641)
                                        {
                                            dic.Add(dataSegmentInfo.ParagraphCode + segmentRulesInfo.SegmentRulesId, "00000000000000000000");
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(messageInfo);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 数据跨信息记录校验
        /// </summary>
        /// yand    16.09.27
        /// <param name="infoType">信息记录实体</param>
        /// <param name="metaInfo">数据元实体</param>
        /// <param name="info">前端传递过来的键值对值</param>
        /// <param name="recordID">信息记录保存的ID</param>
        /// <param name="message">返回的错误信息</param>
        /// <returns></returns>
        public bool DataValidate(InfoTypeInfo infoType, MetaInfo metaInfo, KeyValuePair <string, string> info, string dataSegmentParagraphCode, int recordID, int reportID, ref string message)
        {
            if (!VarificationData(metaInfo, info.Value))
            {
                throw new ApplicationException(metaInfo.Name + "数据类型错误!");
            }
            if (Encoding.GetEncoding("GB2312").GetByteCount(info.Value) > metaInfo.DatasLength)
            {
                throw new ApplicationException(metaInfo.Name + "数据长度错误!");
            }
            if (!(new CodeProofMethod().BaseInfo(infoType.InfoTypeId, info)))
            {
                throw new ApplicationException(metaInfo.Name + "下拉选项有误!");
            }
            //校验时间类型
            if (metaInfo.RuleType.TimeType == true && info.Value != "")
            {
                DateTime dt = new DateTime();
                DateTime.TryParse(info.Value, out dt);
                if (dt == null)
                {
                    throw new ApplicationException(metaInfo.Name + "时间格式有错误");
                }
            }
            //根据财务报表中信息记录类型判断借款人概况信息中借款人性质
            if (infoType.InfoTypeId == 3 || infoType.InfoTypeId == 4 || infoType.InfoTypeId == 5 || infoType.InfoTypeId == 6 || infoType.InfoTypeId == 7)
            {
                if (metaInfo.MetaCode == 7653)
                {
                    //借款人性质
                    string segmentRuleID = "D26";
                    //根据还款记录对应的借据信息记录
                    int infoid = 1;

                    ReportInfo reportInfo = new DAL.BankCredit.ReportMapper().FindByReportID(reportID);

                    string s = InfoValueValidate(infoid, reportInfo.ReportFileID, info, jjbh, segmentRuleID);
                    if (string.IsNullOrEmpty(s))
                    {
                        throw new ApplicationException("未能找到该报文下对应的借款人概况信息记录,请先填写借款人概况信息");
                    }
                    else
                    {
                        if (s != "04" && (info.Value == "46" || info.Value == "47"))
                        {
                            throw new ApplicationException("当为“事业单位资产负债表信息记录”或“事业单位收入支出表信息记录”时,借款人概况信息中的借款人性质只能是“事业单位”");
                        }
                        if (s == "04" && (info.Value == "43" || info.Value == "44" || info.Value == "45"))
                        {
                            throw new ApplicationException("当为“2007版资产负债表信息记录”或“2007版利润及利润分配表信息记录”或“2007版现金流量表信息记录”时,借款人概况信息中的借款人性质不能为“事业单位”");
                        }
                    }
                }
            }

            //借据信息记录中贷款合同编号
            if (info.Key == "B513")
            {
                //需要获取的贷款合同信息记录中的贷款合同编号
                string segmentRuleID = "B489";
                //根据合同信息记录编号
                int infoid = 10;

                ReportInfo reportInfo = new DAL.BankCredit.ReportMapper().FindByReportID(reportID);

                string s = InfoValueValidate(infoid, reportInfo.ReportFileID, info, info.Value, segmentRuleID);
                if (string.IsNullOrEmpty(s) || info.Value != s)
                {
                    throw new ApplicationException("未能找到该贷款合同号码对应的贷款合同信息");
                }
            }
            if (metaInfo.MetaCode == 7511)
            {
                czType = info.Value;
                if (info.Value == "4" && recordID == 0)
                {
                    throw new ApplicationException("该条信息记录不存在,信息记录操作类型不能为删除操作");
                }
                if (info.Value == "4" && ParagraphCode == "C")
                {
                    throw new ApplicationException("当信息记录操作类型为删除时不能存在标识变更段");
                }
            }
            if (metaInfo.MetaCode == 2501)
            {
                //根据recordId获取信息获取保存的报文文件ID

                ReportInfo reportInfo = new DAL.BankCredit.ReportMapper().FindByReportID(reportID);

                bool result = ValidateInfos(infoType.InfoTypeId, reportInfo.ReportFileID, metaInfo.MetaCode, info, dataSegmentParagraphCode);
            }
            // 借据编号
            if (info.Key == "H566" || info.Key == "G548")
            {
                jjbh = info.Value;
            }
            //展期金额
            if (metaInfo.MetaCode == 1517)
            {
                //展期金额赋值
                zqje = info.Value;
                //需要获取的借据金额对应的段标识
                string segmentRuleID = "F523";
                //根据还款记录对应的借据信息记录
                int infoid = 11;

                ReportInfo reportInfo = new DAL.BankCredit.ReportMapper().FindByReportID(reportID);
                string     s          = InfoValueValidate(infoid, reportInfo.ReportFileID, info, jjbh, segmentRuleID);
                if (string.IsNullOrEmpty(s))
                {
                    throw new ApplicationException("未能找到该借据编号对应的借据信息");
                }
                else
                {
                    if (Convert.ToDouble(s) < Convert.ToDouble(info.Value))
                    {
                        throw new ApplicationException("展期金额应小于贷款业务借款中借据金额");
                    }
                }
            }
            //贷款业务展期
            if (infoType.InfoTypeId == 13)
            {
                //展期还款次数
                if (info.Key == "H567")
                {
                    zqcs = info.Value;
                }
                //展期金额
                if (info.Key == "H569")
                {
                    if (zqcs == "1")
                    {
                        ReportInfo reportInfo = new DAL.BankCredit.ReportMapper().FindByReportID(reportID);
                        //jjbh该展期对应的借据编号
                        //借据还款信息记录ID
                        infoType.InfoTypeId = 12;
                        string result = Validate160(infoType.InfoTypeId, reportInfo.ReportFileID, jjbh);
                        if (!string.IsNullOrEmpty(result))
                        {
                            if (Convert.ToDouble(result) != Convert.ToDouble(zqje))
                            {
                                throw new ApplicationException("对于贷款业务展期信息记录,当展期次数为1,同时该展期信息记录的对应的贷款业务借据信息记录下无还款信息记录时,展期金额等于该展期信息记录对应的最新贷款业务借据记录的借据余额");
                            }
                        }
                    }
                    //操作类型为新增
                    if (czType == "1")
                    {
                        //需要获取的展期标志对应的段标识
                        string segmentRuleID = "F532";
                        //根据还款记录对应的借据信息记录
                        int infoid = 11;

                        ReportInfo reportInfo = new DAL.BankCredit.ReportMapper().FindByReportID(reportID);

                        string s = InfoValueValidate(infoid, reportInfo.ReportFileID, info, jjbh, segmentRuleID);
                        if (string.IsNullOrEmpty(s))
                        {
                            throw new ApplicationException("未能找到该借据编号对应的借据信息");
                        }
                        else
                        {
                            if (s == "2")
                            {
                                throw new ApplicationException("当信息记录操作类型为新增时借据信息记录中展期标志必须为‘是’");
                            }
                        }
                    }
                }
            }

            //展期起始时间
            if (info.Key == "H570")
            {
                //需要获取的借据时间对应的段标识
                string segmentRuleID = "F525";
                //根据还款记录对应的借据信息记录
                int infoid = 11;

                ReportInfo reportInfo = new DAL.BankCredit.ReportMapper().FindByReportID(reportID);

                string s = InfoValueValidate(infoid, reportInfo.ReportFileID, info, jjbh, segmentRuleID);
                if (string.IsNullOrEmpty(s))
                {
                    throw new ApplicationException("未能找到该借据编号对应的借据信息");
                }
                else
                {
                    if (Convert.ToDouble(s) > Convert.ToDouble(info.Value))
                    {
                        throw new ApplicationException("展期起始日期不应该小于贷款业务借款中借据放款日期");
                    }
                }
            }
            //借据还款日期
            if (info.Key == "G549")
            {
                //需要获取的借据时间对应的段标识
                string segmentRuleID = "F525";
                //根据还款记录对应的借据信息记录
                int infoid = 11;

                ReportInfo reportInfo = new DAL.BankCredit.ReportMapper().FindByReportID(reportID);

                string s = InfoValueValidate(infoid, reportInfo.ReportFileID, info, jjbh, segmentRuleID);
                if (string.IsNullOrEmpty(s))
                {
                    throw new ApplicationException("未能找到该借据编号对应的借据信息");
                }
                else
                {
                    if (Convert.ToDouble(s) > Convert.ToDouble(info.Value))
                    {
                        throw new ApplicationException("还款日期不应该小于贷款业务借款中借据放款日期");
                    }
                }
            }
            //TODO 增加 163中的还款信息记录中的业务发生时间和借据信息中的业务发生日期的校验
            return(true);
        }