Esempio n. 1
0
        /// <summary>
        /// 取得UIParameter数组
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public static IAddinParameter[] GetPluginUIParameters(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }
            List <IAddinParameter> parameters = new List <IAddinParameter>();

            int iPos  = 0;
            int iPos2 = 0;

            //替换的变量只支持数字与字母,点与下划线

            iPos = text.IndexOf("@");
            while (iPos >= 0)
            {
                //取
                char[] chs;
                iPos2 = iPos;
                do
                {
                    iPos2 = iPos2 + 1;
                    if (iPos2 >= text.Length)
                    {
                        break;
                    }
                    string val = text.Substring(iPos2, 1);
                    chs = val.ToCharArray();
                } while (char.IsLetterOrDigit(chs[0]) || chs[0] == '.' || chs[0] == '_');


                string parameter = text.Substring(iPos + 1, iPos2 - iPos - 1);

                UIParameter p = new UIParameter();

                p.Name = "@" + parameter; //参数全名

                //UI参数的格式要么是@mstformdata.NewRow.cntno 三段式,要么是就是一段式,二段式都有可能
                //一段式:@Phid
                //二段式:@mstformdata.phid 表示从mstformdata的所有行中找出phid

                int iPos3 = 0;
                iPos3 = parameter.IndexOf(".");
                if (iPos3 > 0)
                {
                    //三段式UI格式
                    p.FirstPart = parameter.Substring(0, iPos3);
                    string part  = parameter.Substring(iPos3 + 1, parameter.Length - iPos3 - 1);
                    int    iPos4 = 0;
                    iPos4 = part.IndexOf(".");
                    if (iPos4 > 0)
                    {
                        p.SecondPart = part.Substring(0, iPos4);
                        p.ThirdPart  = part.Substring(iPos4 + 1, part.Length - iPos4 - 1);
                    }
                    else
                    {
                        //二段式,可以省略数据的类型,第二段为空
                        p.SecondPart = string.Empty;
                        p.ThirdPart  = part;
                    }
                }
                else
                {
                    //一段式UI参数
                    p.FirstPart  = string.Empty; //前缀为空
                    p.SecondPart = string.Empty; //来源的数据部分为空
                    p.ThirdPart  = parameter;
                }

                //判断是何种参数
                if (BizParameter.IsBizParameter(p.FirstPart))
                {
                    //业务参数
                    BizParameter bp = new BizParameter();
                    bp.Name       = p.Name;
                    bp.FirstPart  = p.FirstPart;
                    bp.SecondPart = p.SecondPart;
                    bp.ThirdPart  = p.ThirdPart;
                    parameters.Add(bp);
                }
                else if (SystemParameter.IsSystemParameter(p.FirstPart))
                {
                    //系统参数
                    SystemParameter sp = new SystemParameter();
                    sp.Name       = p.Name;
                    sp.FirstPart  = p.FirstPart;
                    sp.SecondPart = p.SecondPart;
                    sp.ThirdPart  = p.ThirdPart;
                    parameters.Add(sp);
                }
                else
                {
                    //UI参数
                    //如果第一段不为空,第二段为空,则第二段设置为All;
                    if (!string.IsNullOrEmpty(p.FirstPart) && string.IsNullOrEmpty(p.SecondPart))
                    {
                        p.SecondPart = EnumUIDataSourceType.All.ToString();
                    }
                    parameters.Add(p);
                }

                iPos = text.IndexOf("@", iPos + 1);
            }

            return(parameters.ToArray());
        }