示例#1
0
        public static XDocument FixSnilsInDFile(XDocument doc, string folderIn)
        {
            //ЗАменить в CODE_MD код на СНИЛС
            ListSNILS ListSn   = new ListSNILS(folderIn + "SNILS.csv");
            int       counter1 = 0;

            var notFindedList = new List <String>();

            if (doc.Root != null)
            {
                foreach (var codeMd in doc.Descendants("CODE_MD"))
                {
                    string snils = ListSn.GetSNILS(codeMd.Value);
                    if (!String.IsNullOrWhiteSpace(snils))
                    {
                        codeMd.Value = snils;
                        counter1++;
                    }
                    else
                    {
                        if (!notFindedList.Contains(codeMd.Value))
                        {
                            notFindedList.Add(codeMd.Value);
                        }
                    }
                }

                var path = Path.Combine(folderIn, "notFindedDCodes.txt");
                if (File.Exists(path))
                {
                    File.Delete(path);
                }

                File.WriteAllLines(path, notFindedList);
            }
            Messenger.WriteMessage(String.Format("Исправлено {0} элементов", counter1));

            return(doc);
        }
示例#2
0
        public static XDocument FixSinlsInHFile(XDocument doc, string folderIn)
        {
            //ЗАменить в IDDOKT и CODE_MD код на СНИЛС
            ListSNILS ListSn        = new ListSNILS(folderIn + "SNILS.csv");
            int       counter1      = 0;
            int       counter2      = 0;
            var       notFindedList = new List <String>();

            if (doc.Root != null)
            {
                foreach (var sluch in doc.Descendants("SLUCH"))
                {
                    foreach (var usl in sluch.Elements("USL"))
                    {
                        //ЗАменить в CODE_MD код на СНИЛС
                        var code_md = usl.Element("CODE_MD");
                        if (code_md != null)
                        {
                            string snils = ListSn.GetSNILS(code_md.Value);
                            if (!String.IsNullOrWhiteSpace(snils))
                            {
                                code_md.Value = snils;
                                counter1++;
                            }
                            else
                            {
                                var value = string.Format("<CODE_MD>{0}</CODE_MD>", code_md.Value);
                                if (!notFindedList.Contains(value))
                                {
                                    notFindedList.Add(value);
                                }
                            }
                        }
                    }
                    //ЗАменить в IDDOKT код на СНИЛС
                    var iddokt = sluch.Element("IDDOKT");
                    if (iddokt != null)
                    {
                        string snils = ListSn.GetSNILS(iddokt.Value);
                        if (!String.IsNullOrWhiteSpace(snils))
                        {
                            iddokt.Value = snils;
                            counter2++;
                        }
                        else
                        {
                            var value = string.Format("<IDDOKT>{0}</IDDOKT>", iddokt.Value);
                            if (!notFindedList.Contains(value))
                            {
                                notFindedList.Add(value);
                            }
                        }
                    }
                }
            }
            var path = Path.Combine(folderIn, "notFindedHCodes.txt");

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            File.WriteAllLines(path, notFindedList);
            Messenger.WriteMessage(String.Format("Исправлено {0} элементов", counter1));
            Messenger.WriteMessage(String.Format("Исправлено {0} элементов", counter2));
            return(doc);
        }