Esempio n. 1
0
        public static string[] GetBillParas_Gener(string cfile, Attrs attrs)
        {
            cfile = cfile.Replace(".rtf.rtf", ".rtf");

            //  Attrs attrs = en.EnMap.Attrs;
            string[] paras   = new string[300];
            string   Billstr = Cash.GetBillStr(cfile, true);

            char[] chars     = Billstr.ToCharArray();
            string para      = "";
            int    i         = 0;
            bool   haveError = false;
            string msg       = "";

            foreach (char c in chars)
            {
                if (c == '>')
                {
                    #region 首先解决空格的问题.
                    string real = para.Clone().ToString();
                    if (attrs != null && real.Contains(" "))
                    {
                        real      = real.Replace(" ", "");
                        Billstr   = Billstr.Replace(para, real);
                        para      = real;
                        haveError = true;
                    }
                    #endregion 首先解决空格的问题.

                    #region 解决特殊符号
                    if (attrs != null && real.Contains("\\") && real.Contains("ND") == false)
                    {
                        haveError = true;
                        string findKey = null;
                        int    keyLen  = 0;
                        foreach (Attr attr in attrs)
                        {
                            if (real.Contains(attr.Key))
                            {
                                if (keyLen <= attr.Key.Length)
                                {
                                    keyLen  = attr.Key.Length;
                                    findKey = attr.Key;
                                }
                            }
                        }

                        if (findKey == null)
                        {
                            msg += "@参数:<font color=red><b>[" + real + "]</b></font>可能拼写错误。";
                            continue;
                        }

                        if (real.Contains(findKey + ".NYR") == true)
                        {
                            real = findKey + ".NYR";
                        }
                        else if (real.Contains(findKey + ".RMB") == true)
                        {
                            real = findKey + ".RMB";
                        }
                        else if (real.Contains(findKey + ".RMBDX") == true)
                        {
                            real = findKey + ".RMBDX";
                        }
                        else if (real.Contains(findKey + ".Year") == true)
                        {
                            real = findKey + ".Year";
                        }
                        else if (real.Contains(findKey + ".Month") == true)
                        {
                            real = findKey + ".Month";
                        }
                        else if (real.Contains(findKey + ".Day") == true)
                        {
                            real = findKey + ".Day";
                        }
                        else
                        {
                            real = findKey;
                        }

                        Billstr = Billstr.Replace(para, real);
                        // msg += "@参数:<font color=red><b>[" + para + "]</b></font>不符合规范。";
                        //continue;
                    }
                    #endregion 首先解决空格的问题.

                    paras.SetValue(para, i);
                    i++;
                }

                if (c == '<')
                {
                    para = ""; // 如果遇到了 '<' 开始记录
                }
                else
                {
                    if (c.ToString() == "")
                    {
                        continue;
                    }
                    para += c.ToString();
                }
            }

            if (haveError)
            {
                //string myfile = SystemConfig.PathOfDataUser + "\\CyclostyleFile\\" + cfile;
                //if (System.IO.File.Exists(myfile) == false)
                //    myfile = cfile;

                // throw new Exception("@没有文件:"+myfile);

                //StreamWriter wr = new StreamWriter(myfile,false, Encoding.ASCII);
                //wr.Write(Billstr);
                //wr.Close();
            }

            if (msg != "")
            {
                string s = "@帮助信息:用记事本打开它模板,找到红色的字体. 把尖括号内部的非法字符去了,例如:《|f0|fs20RDT.NYR|lang1033|kerning2》,修改后事例:《RDT.NYR》。@注意把双引号代替单引号,竖线代替反斜线。";
                //throw new Exception("@单据模板("+cfile+")如下标记出现错误,系统无法修复它,需要您手工的删除标记或者用记事本打开查找到这写标记修复他们.@" + msg + s);
            }
            return(paras);
        }