Example #1
0
        /// <summary>
        /// 格式化错误描述信息,填充错误参数
        /// </summary>
        /// <param name="delegateHandler">委托线程</param>
        /// <param name="langId">langId</param>
        /// <param name="errDesc">带格式的错误描述,需要补充参数</param>
        /// <returns>格式化以后的错误描述内容</returns>
        public string ToFormatedErrDesc(DelegateGetErrorDesc delegateHandler, int langId, string errDesc)
        {
            //获取标识符以及标识符对应的替代值字典
            Dictionary <string, string> errParams = this.GetErrorInfo(delegateHandler, langId, errDesc);

            string formatedString = errDesc;

            if (null != errParams || 0 != errParams.Count)
            {
                Dictionary <string, string> .KeyCollection paramKey = errParams.Keys;

                //填充描述字串参数
                foreach (string s in paramKey)
                {
                    formatedString = errDesc.Replace(s, errParams[s]);
                    errDesc        = formatedString;
                }
            }

            //处理批量操作的错误描述
            if (null != this.MultipleErrs && this.MultipleErrs.Count != 0)
            {
                formatedString += "<br />";
                foreach (SmcErr err in this.MultipleErrs)
                {
                    //DTS2012080206396 批量添加失败报错,错误提示有"<br />"
                    //将这里的"<br />"去掉
                    formatedString += err.ToFomatedErrDesc(langId);
                }
            }

            return(formatedString);
        }
Example #2
0
        /// <summary>
        /// 取出字典{标识符,标识符替代值}
        /// </summary>
        /// <param name="delegateHandler">委托数据库取描述字串</param>
        /// <param name="langId">语种ID</param>
        /// <param name="errDesc">带格式的错误描述,需补充参数</param>
        /// <returns>字典{标识符,标识符替代值}</returns>
        public virtual Dictionary <string, string> GetErrorInfo(DelegateGetErrorDesc delegateHandler, int langId, string errDesc)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            //提取描述格式中的参数
            List <SignStruct> properties = this.GetProperties(errDesc);

            //根据参数名,从Dictionary中取值
            foreach (SignStruct o in properties)
            {
                //标识符序号
                int num = Convert.ToInt32(o.number);
                ////标识符名称
                string sign = o.sign;
                //初始化该字典项为“”;
                dictionary[o.data] = string.Empty;
                //嵌套错误码
                if (sign.Equals(err))
                {
                    //将标识符与错误描述填入字典中
                    if (this.ExternErrs.Count > num)
                    {
                        dictionary[o.data] = this.ExternErrs[num].ToFomatedErrDesc(langId);
                    }

                    continue;
                }


                //统一按名称匹配,暂时不处理名称一样,有多个索引的问题
                foreach (List <ValueDictionary> valueList in this.ParametersDictionary)
                {
                    if (valueList == null)
                    {
                        continue;
                    }

                    foreach (ValueDictionary valueDic in valueList)
                    {
                        if (sign.Equals(valueDic.Name))
                        {
                            dictionary[o.data] = valueDic.Value;
                            break;
                        }
                    }
                }
            }

            return(dictionary);
        }
Example #3
0
        /// <summary>
        /// 取查询错误描述的委托
        /// </summary>
        /// <returns>DelegateGetErrorDesc</returns>
        public DelegateGetErrorDesc GetDelegate()
        {
            DelegateGetErrorDesc delegateHandler = new DelegateGetErrorDesc(ResHelper.Instance().GetErrDesc);

            return delegateHandler;
        }
Example #4
0
        /// <summary>
        /// 格式化错误描述信息,填充错误参数
        /// </summary>
        /// <param name="delegateHandler">委托线程</param>
        /// <param name="langId">langId</param>
        /// <param name="errDesc">带格式的错误描述,需要补充参数</param>
        /// <returns>格式化以后的错误描述内容</returns>
        public string ToFormatedErrDesc(DelegateGetErrorDesc delegateHandler, int langId, string errDesc)
        {
            //获取标识符以及标识符对应的替代值字典
            Dictionary<string, string> errParams = this.GetErrorInfo(delegateHandler, langId, errDesc);

            string formatedString = errDesc;

            if (null != errParams || 0 != errParams.Count)
            {
                Dictionary<string, string>.KeyCollection paramKey = errParams.Keys;

                //填充描述字串参数
                foreach (string s in paramKey)
                {
                    formatedString = errDesc.Replace(s, errParams[s]);
                    errDesc = formatedString;
                }
            }

            //处理批量操作的错误描述
            if (null != this.MultipleErrs && this.MultipleErrs.Count != 0)
            {
                formatedString += "<br />";
                foreach (SmcErr err in this.MultipleErrs)
                {
                    //DTS2012080206396 批量添加失败报错,错误提示有"<br />"
                    //将这里的"<br />"去掉
                    formatedString += err.ToFomatedErrDesc(langId);
                }
            }

            return formatedString;
        }
Example #5
0
        /// <summary>
        /// 取出字典{标识符,标识符替代值}
        /// </summary>
        /// <param name="delegateHandler">委托数据库取描述字串</param>
        /// <param name="langId">语种ID</param>
        /// <param name="errDesc">带格式的错误描述,需补充参数</param>
        /// <returns>字典{标识符,标识符替代值}</returns>
        public virtual Dictionary<string, string> GetErrorInfo(DelegateGetErrorDesc delegateHandler, int langId, string errDesc)
        {
            Dictionary<string, string> dictionary = new Dictionary<string, string>();

            //提取描述格式中的参数
            List<SignStruct> properties = this.GetProperties(errDesc);

            //根据参数名,从Dictionary中取值
            foreach (SignStruct o in properties)
            {
                //标识符序号
                int num = Convert.ToInt32(o.number);
                ////标识符名称
                string sign = o.sign;
                //初始化该字典项为“”;
                dictionary[o.data] = string.Empty;
                //嵌套错误码
                if (sign.Equals(err))
                {
                    //将标识符与错误描述填入字典中
                    if (this.ExternErrs.Count > num)
                    {
                        dictionary[o.data] = this.ExternErrs[num].ToFomatedErrDesc(langId);
                    }

                    continue;
                }

                //统一按名称匹配,暂时不处理名称一样,有多个索引的问题
                foreach (List<ValueDictionary> valueList in this.ParametersDictionary)
                {
                    if (valueList == null)
                    {
                        continue;
                    }

                    foreach (ValueDictionary valueDic in valueList)
                    {
                        if (sign.Equals(valueDic.Name))
                        {
                            dictionary[o.data] = valueDic.Value;
                            break;
                        }
                    }
                }
            }

            return dictionary;
        }