예제 #1
0
파일: Payment.cs 프로젝트: repon06/UFK
        public Dictionary <string, string> ParsePayment(string str, PaymentType type, PaymentFKTemplate templates, bool debug = false)
        {
            var values = str.Split(spliter);

            string[] template;// = templates.bdpdst.Split(spliter);

            switch (type)
            {
            case PaymentType.bd:
                template = templates.bd.Split(spliter);
                break;

            case PaymentType.fk:
                template = templates.fk.Split(spliter);
                break;

            case PaymentType.bdpd:
                template = templates.bdpd.Split(spliter);
                break;

            case PaymentType.bdpdst:
                template = templates.bdpdst.Split(spliter);
                break;

            default:
                template = null;
                break;
            }

            /// изменили кол-во параметров в шаблоне от 01.06.2020
            /// добавили: Код вида дохода	KOD_ INCOME
            if (values.Length == template.Length)
            {
                if (debug)
                {
                    Console.WriteLine($"tmpl.FK: {templates.fk}");
                    Console.WriteLine($"tmpl.BD: {templates.bd}");
                    Console.WriteLine($"tmpl.BDPD: {templates.bdpd}");
                    Console.WriteLine($"tmpl.BDPDST: {templates.bdpdst}");

                    foreach (string v in values)
                    {
                        Console.WriteLine($"values: '{v.Trim()}'");
                    }

                    foreach (string t in template)
                    {
                        Console.WriteLine($"fk_template: '{t.Trim().Replace(delete_chars, string.Empty)}'");
                    }
                }

                Dictionary <string, string> dic = template.Zip(values, (s, i) => new { s, i })
                                                  .ToDictionary(item => item.s.Replace(delete_chars, string.Empty), item => StringHelper.GetNotNull(item.i.Trim())); //значение триммим и ставим '0', если нет знач.

                return(dic);
            }
            else
            {
                throw new Exception("Различается кол-во параметров в платежке и в шаблоне!");
            }
        }
예제 #2
0
 public PaymentHelper()
 {
     templates = ReadTemplates(templatePath);
 }