예제 #1
0
        /// <summary>
        /// Экспортировать Xml фалы в указанну. директорию
        /// </summary>
        /// <param name="path">Путь, куда необходимо охранить файлы</param>
        /// <param name="orgProperty">Свойства организации</param>
        /// <param name="szv3Xml">Файл XML</param>
        /// <param name="szv2XmlArray">Массив файлов XML</param>
        /// <param name="szv1XmlArray">Массив файлов XML</param>
        /// <returns></returns>
        public static bool ExportXml(string path, OrgPropXml orgProperty, XmlDocument szv3Xml,
                                     IEnumerable <XmlDocument> szv2XmlArray,
                                     IEnumerable <IEnumerable <XmlDocument> > szv1XmlArray)
        {
            if (szv2XmlArray.Count() != szv1XmlArray.Count())
            {
                return(false);
            }
            string        rootDirStr = string.Format(@"{0}\{1}\{2}", path, orgProperty.orgRegnum, orgProperty.repYear);
            DirectoryInfo rootDir    = Directory.CreateDirectory(rootDirStr);

            szv3Xml.PreserveWhitespace = true;
            szv3Xml.Save(rootDir.FullName + @"\сводная.xml");

            for (int i = 0; i < szv2XmlArray.Count(); i++)
            {
                IEnumerable <XmlDocument> szv1XmlNodeArr = szv1XmlArray.ElementAt(i);
                XmlDocument szv2Xml = szv2XmlArray.ElementAt(i);
                szv2Xml.PreserveWhitespace = true;
                szv2Xml.Save(string.Format(@"{0}\z_опись_{1:000}.xml", rootDir.FullName, i + 1));
                DirectoryInfo packetDir =
                    Directory.CreateDirectory(string.Format(@"{0}\Пакет_Z{1:000}", rootDir.FullName, i + 1));

                for (int j = 0; j < szv1XmlNodeArr.Count(); j++)
                {
                    XmlDocument szv1Xml = szv1XmlNodeArr.ElementAt(j);
                    szv1Xml.PreserveWhitespace = true;
                    szv1Xml.Save(string.Format(@"{0}\z_документ_L{1:000}_D{2:000}.xml", packetDir.FullName, i + 1, j + 1));
                }
            }
            return(true);
        }
예제 #2
0
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            mapXml    = null;
            szv3Xml   = null;
            szv2Array = null;
            szv1Array = null;

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            if (Convert.ToInt32(e.Argument) == 1)
            {
                long[] markedLists = MarkedLists();

                Storage.MakeXml(_repYear, _organization, markedLists, _connection,
                                out mapXml, out szv3Xml, out szv2Array, out szv1Array);
            }
            else if (Convert.ToInt32(e.Argument) == 2)
            {
                bool          isCorrect;
                DirectoryInfo dir =
                    Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Settings.Default.TempFolder));
                using (StreamWriter writer = new StreamWriter(Path.Combine(dir.FullName, "Ошибки XML.txt"), false))
                {
                    writer.AutoFlush = true;
                    OrgPropXml orgProperties = GetOrgProperties();
                    isCorrect = Storage.ImportXml(xmlPathTextBox.Text, orgProperties,
                                                  out szv3Xml, out szv2Array, out szv1Array, writer);
                }
                if (!isCorrect)
                {
                    MainForm.ShowErrorMessage(
                        "Импорт xml файлов прошел некорректно.\nФормирование электронного контейнера невозможно!");
                    Process.Start(Path.Combine(dir.FullName, "Ошибки XML.txt"));
                    return;
                }
                mapXml = MapXml.GetXml(szv2Array, szv1Array);
            }

            if (mapXml != null && szv3Xml != null && szv2Array != null && szv1Array != null)
            {
                MakeContainer(mapXml, szv3Xml, szv2Array, szv1Array);
                stopWatch.Stop();
                TimeSpan ts          = stopWatch.Elapsed;
                string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                     ts.Hours, ts.Minutes, ts.Seconds,
                                                     ts.Milliseconds / 10);
                MainForm.ShowInfoMessage(
                    string.Format(
                        "Файл с электронными данными успешно сформирован и готов к предоставлению в Фонд.\nДлительность операции: {0} ",
                        elapsedTime), "Формирование завершено");
            }
        }
예제 #3
0
        private int MakeContainer(XmlDocument mapXml, XmlDocument szv3Xml,
                                  IEnumerable <XmlDocument> szv2Array,
                                  IEnumerable <IEnumerable <XmlDocument> > szv1Array)
        {
            if (_diskKey == null || _diskTable == null)
            {
                return(-1);
            }
            if (_container != null)
            {
                _container.Close();
            }

            DirectoryInfo dir = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Settings.Default.TempFolder));

            if (flashRButton.Checked)
            {
                string flashRoot = GetFlashRoot();
                dir = Directory.CreateDirectory(string.Format(
                                                    @"{0}:\\Государственный пенсионный фонд ПМР\{1}.{2}",
                                                    flashRoot, _organization.regnumVal, _repYear));
            }
            else if (internetRButton.Checked)
            {
                dir = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Settings.Default.TempFolder));
            }

            string containerFilename = Path.Combine(dir.FullName, "edatacon.pfs");
            string mdcFilename       = Path.Combine(dir.FullName, "mdc");

            OrgPropXml orgProp = GetOrgProperties();

            _container = Storage.MakeContainer(mapXml, szv3Xml, szv2Array, szv1Array,
                                               _diskKey, _diskTable);
            _container.Save(containerFilename);
            _container.Close();

            CfProperties.AddProperty(containerFilename, orgProp);

            byte[] hash = Mathdll.GostHash(containerFilename, _diskTable);
            File.WriteAllBytes(mdcFilename, hash);
            return(0);
        }
예제 #4
0
        private OrgPropXml GetOrgProperties()
        {
            OrgPropXml orgProp = new OrgPropXml();

            orgProp.orgName        = _organization.nameVal;
            orgProp.orgRegnum      = _organization.regnumVal;
            orgProp.directorType   = _organization.chiefpostVal;
            orgProp.directorFIO    = _organization.chieffioVal;
            orgProp.bookkeeperFIO  = _organization.bookerfioVal;
            orgProp.operatorName   = _operator.nameVal;
            orgProp.repYear        = ((int)yearBox.Value).ToString();
            orgProp.performer      = _operator.nameVal;
            orgProp.programName    = "Персонифицированный учет (для организаций)";
            orgProp.version        = "3";
            orgProp.programVersion = "4.0";
            orgProp.date           = DateTime.Now;
            //
            return(orgProp);
        }
예제 #5
0
        private void viewDataButton_Click(object sender, EventArgs e)
        {
            string errMessage;
            bool   checkRes = CheckDrives(out errMessage);

            if (!checkRes)
            {
                MainForm.ShowErrorFlexMessage(errMessage, "Внимание");
                return;
            }

            string filename = "";

            if (flashRButton.Checked)
            {
                string flashRoot = flashBox.Text.Substring(0, 1);
                filename = string.Format(@"{0}:\\Государственный пенсионный фонд ПМР\{1}.{2}\edatacon.pfs",
                                         flashRoot, _organization.regnumVal, _repYear);
            }
            else if (internetRButton.Checked)
            {
                filename = Path.Combine(Path.GetTempPath(), Settings.Default.TempFolder);
                filename = Path.Combine(filename, "edatacon.pfs");
            }

            try
            {
                if (!ReadDisk(out errMessage))
                {
                    MainForm.ShowWarningMessage(errMessage, "Внимание");
                }
            }
            catch
            {
                if (cdRButton.Checked)
                {
                    errMessage = "Не удалось считать ключевые данные с диска!\nВозможно Вы вставили неверный диск.";
                }
                else
                {
                    errMessage = "Не удалось считать ключевые данные с файла!\nВозможно Вы вставили неверный файл.";
                }
                MainForm.ShowWarningMessage(errMessage, "Внимание");
                return;
            }


            if (!File.Exists(filename))
            {
                MainForm.ShowInfoMessage("Сначала необходимо сформировать электронный файл для обмена с ЕГФСС",
                                         "Внимание");
                return;
            }

            if (_container != null)
            {
                _container.Close();
            }
            _container = new CompoundFile(filename);
            CFStream mapStream = _container.RootStorage.GetStream("map");

            byte[] mapBytes = Storage.DecryptStream(mapStream, _diskKey, _diskTable);
            //string mapStr = Encoding.GetEncoding(1251).GetString(mapBytes);
            CFStorage stylesDir      = _container.RootStorage.GetStorage("styles");
            CFStream  mapStyleStream = stylesDir.GetStream("map_style");

            byte[] mapStyleBytes = Storage.DecryptStream(mapStyleStream, _diskKey, _diskTable);
            //string styleStr = Encoding.GetEncoding(1251).GetString(mapStyleBytes);
            _container.Close();

            OrgPropXml props    = CfProperties.ReadProperty(filename);
            string     propHtml = props.GetHTML();

            string htmlStr;

            try
            {
                htmlStr = MapXml.GetHTML(mapBytes, mapStyleBytes);
            }
            catch (XsltException ex)
            {
                #region Текст сообщения всплывающего сообщения

                MainForm.ShowWarningFlexMessage(
                    "Электронный контейнер был сформирован программой версси 3.2.06 или ниже.\nБудет использован файл стиля из текущей версии программы.\n" +
                    ex.Message, "Внимание");

                #endregion

                htmlStr = MapXml.GetHTML(mapBytes);
            }
            catch (Exception ex)
            {
                MainForm.ShowWarningFlexMessage(ex.Message, "Необработанная ошибка");
                htmlStr = MapXml.GetHTML(mapBytes);
            }
            WebBrowser reportWb = new WebBrowser();
            htmlStr = htmlStr.Replace("<DIV class=\"insert_here\" />", propHtml);
            reportWb.DocumentText = htmlStr;
            MyPrinter.ShowWebPage(reportWb);
            reportWb.Navigating += new WebBrowserNavigatingEventHandler(reportWB_Navigating);
        }
예제 #6
0
        private bool CheckTabPageXML(out string errMessage)
        {
            bool res = true;

            errMessage = "";
            string path = xmlPathTextBox.Text;

            if (!Directory.Exists(path))
            {
                errMessage += "\nНе найден указанный каталог.";
                return(false);
            }

            OrgPropXml orgProperty = GetOrgProperties();

            string rootDirStr = string.Format(@"{0}\{1}\{2}", path, orgProperty.orgRegnum, orgProperty.repYear);

            // если в корневой директории (папке) нет подпапки с Рег номером организации,
            // в которой в свою очередь нет папки с отчетным годом (RepYear),
            // то процесс импорта невозможен
            if (!Directory.Exists(rootDirStr))
            {
                errMessage += string.Format("\nВ корневом каталоге не найдены необходимые директории: '{0}\\{1}'",
                                            orgProperty.orgRegnum, orgProperty.repYear);
                return(false);
            }
            string szv3Filename = rootDirStr + @"\сводная.xml";

            // если нет файла сводной ведомости (СЗВ-3) импорт не может быть закончен
            if (!File.Exists(szv3Filename))
            {
                errMessage += "\nНе найден файл сводной ведомости СЗВ-3 (сводная.xml).";
                res         = false;
            }
            DirectoryInfo rootDir = new DirectoryInfo(rootDirStr);

            DirectoryInfo[] packetDirs   = rootDir.GetDirectories("Пакет_Z???");
            FileInfo[]      opisFiles    = rootDir.GetFiles("z_опись_???.xml");
            FileInfo[][]    szv1FilesArr = new FileInfo[packetDirs.Count()][];
            // если количество директорий (папок) с документами СЗВ-1
            // отличается от количества файлов с описями (документы СЗВ-2)
            // процесс импорта следует прекратить
            if (!packetDirs.Any())
            {
                errMessage +=
                    string.Format("\nКоличество директорий (папок) ({0}) с документами СЗВ-1 не может быть меньше 1.",
                                  packetDirs.Count());
                res = false;
            }

            if (!opisFiles.Any())
            {
                errMessage += string.Format("\nКоличество описей СЗВ-2 ({0}) не может быть меньше 1.",
                                            opisFiles.Count());
                res = false;
            }
            if (packetDirs.Count() != opisFiles.Count())
            {
                errMessage +=
                    string.Format(
                        "\nКоличество директорий (папок) ({0}) с документами СЗВ-1 отличается от количества файлов с описями (документы СЗВ-2) ({1}).",
                        packetDirs.Count(), opisFiles.Count());
                res = false;
            }

            string[] dirNumArr  = new string[packetDirs.Count()];
            string[] fileNumArr = new string[opisFiles.Count()];
            int      i;
            string   tmpStr;

            for (i = 0; i < dirNumArr.Length; i++)
            {
                tmpStr       = packetDirs[i].Name;
                dirNumArr[i] = tmpStr.Substring(tmpStr.Length - 3, 3);
            }
            for (i = 0; i < fileNumArr.Length; i++)
            {
                tmpStr        = opisFiles[i].Name;
                fileNumArr[i] = tmpStr.Substring(tmpStr.Length - 7, 3);
            }
            int count = 0;

            if (dirNumArr.Length == fileNumArr.Length)
            {
                for (i = 0; i < dirNumArr.Length; i++)
                {
                    if (dirNumArr.Contains(fileNumArr[i]))
                    {
                        count++;
                    }
                }
                // не всем файлам описей (СЗВ-2) найдены
                // соответствующие директории (папки) пакетов
                if (count < dirNumArr.Length)
                {
                    errMessage += "\nНе всем файлам описей СЗВ-2 найдены соответствующие директории (папки) пакетов";
                    res         = false;
                }
            }

            count = 0;
            for (i = 0; i < dirNumArr.Length; i++)
            {
                szv1FilesArr[i] = packetDirs[i].GetFiles(string.Format("z_документ_L{0}_D???.xml", dirNumArr[i]));
                // если в директории (папке) есть файлы удовлетворяющие фильиру,
                // то увеличиваем счетчик
                if (szv1FilesArr[i].Length > 0)
                {
                    count++;
                }
            }
            // если есть директории пакетов без файлов документов СЗВ-1,
            // то импорт невозможен
            if (count < dirNumArr.Length)
            {
                errMessage += "\nЕсть директории пакетов без файлов документов СЗВ-1";
                res         = false;
            }

            if (errMessage.Length == 0)
            {
                errMessage = null;
            }
            //
            return(res);
        }
예제 #7
0
        public static OrgPropXml ReadProperty(string path)
        {
            IStorage   Is;
            OrgPropXml properties = null;

            if (StgOpenStorage(path, null, (int)(Stgm.ShareExclusive | Stgm.ReadWrite), IntPtr.Zero, 0, out Is) == 0 &&
                Is != null)
            {
                IPropertySetStorage pss;
                if (StgCreatePropSetStg(Is, 0, out pss) == 0)
                {
                    var FMTID_CustomInformation = new Guid("{D170DF2E-1117-11D2-AA01-00805FFE11B8}");
                    //var pCLSID = new Guid("{00000000-0000-0000-0000-000000000000}");
                    IPropertyStorage ps;
                    UInt32           propCount = 12;
                    pss.Open(ref FMTID_CustomInformation, (Stgm.ShareExclusive | Stgm.Read), out ps);
                    if (ps != null)
                    {
                        PropertySpec[]    propSpec    = new PropertySpec[propCount];
                        PropertyVariant[] propVariant = new PropertyVariant[propCount];

                        propSpec[0]  = CreateProperty(OrgPropXml.tagOrgRegnum);
                        propSpec[1]  = CreateProperty(OrgPropXml.tagOrgName);
                        propSpec[2]  = CreateProperty(OrgPropXml.tagRepyear);
                        propSpec[3]  = CreateProperty(OrgPropXml.tagDirectorType);
                        propSpec[4]  = CreateProperty(OrgPropXml.tagDirectorFIO);
                        propSpec[5]  = CreateProperty(OrgPropXml.tagBookkeeperFIO);
                        propSpec[6]  = CreateProperty(OrgPropXml.tagPerformer);
                        propSpec[7]  = CreateProperty(OrgPropXml.tagOperatorName);
                        propSpec[8]  = CreateProperty(OrgPropXml.tagDate);
                        propSpec[9]  = CreateProperty(OrgPropXml.tagVersion);
                        propSpec[10] = CreateProperty(OrgPropXml.tagProgramName);
                        propSpec[11] = CreateProperty(OrgPropXml.tagProgramVersion);

                        ps.ReadMultiple(propCount, propSpec, propVariant);

                        properties = new OrgPropXml();

                        properties.orgRegnum     = GetString(propVariant[0].unionmember.pszVal);
                        properties.orgName       = GetString(propVariant[1].unionmember.pszVal);
                        properties.repYear       = GetString(propVariant[2].unionmember.pszVal);
                        properties.directorType  = GetString(propVariant[3].unionmember.pszVal);
                        properties.directorFIO   = GetString(propVariant[4].unionmember.pszVal);
                        properties.bookkeeperFIO = GetString(propVariant[5].unionmember.pszVal);
                        properties.performer     = GetString(propVariant[6].unionmember.pszVal);
                        properties.operatorName  = GetString(propVariant[7].unionmember.pszVal);
                        properties.date          = DateTime.ParseExact(GetString(propVariant[8].unionmember.pszVal),
                                                                       "dd.MM.yyyy H:mm:ss",
                                                                       CultureInfo.InvariantCulture);
                        properties.version        = GetString(propVariant[9].unionmember.pszVal);
                        properties.programName    = GetString(propVariant[10].unionmember.pszVal);
                        properties.programVersion = GetString(propVariant[11].unionmember.pszVal);


                        Marshal.FinalReleaseComObject(ps);
                    }
                    else
                    {
                        Console.WriteLine("Could not open property storage");
                    }

                    Marshal.FinalReleaseComObject(pss);
                }
                else
                {
                    Console.WriteLine("Could not create property set storage");
                }

                Marshal.FinalReleaseComObject(Is);
            }
            else
            {
                Console.WriteLine("File does not contain a structured storage");
            }

            GC.Collect();
            return(properties);
        }
예제 #8
0
        public static void AddProperty(string path, OrgPropXml properties)
        {
            IStorage Is;

            if (StgOpenStorage(path, null, (int)(Stgm.ShareExclusive | Stgm.ReadWrite), IntPtr.Zero, 0, out Is) == 0 &&
                Is != null)
            {
                IPropertySetStorage pss;
                if (StgCreatePropSetStg(Is, 0, out pss) == 0)
                {
                    var FMTID_CustomInformation = new Guid("{D170DF2E-1117-11D2-AA01-00805FFE11B8}");
                    var pCLSID = new Guid("{00000000-0000-0000-0000-000000000000}");
                    IPropertyStorage ps;
                    pss.Create(ref FMTID_CustomInformation, ref pCLSID, (uint)grfFlags.PROPSETFLAG_DEFAULT,
                               (uint)(Stgm.ShareExclusive | Stgm.ReadWrite), out ps);

                    if (ps == null)
                    {
                        throw new Exception("Don't create container custom property");
                    }

                    PropertySpec[]    propSpec    = new PropertySpec[12];
                    PropertyVariant[] propVariant = new PropertyVariant[12];

                    propSpec[0]  = CreateProperty(OrgPropXml.tagOrgRegnum);
                    propSpec[1]  = CreateProperty(OrgPropXml.tagOrgName);
                    propSpec[2]  = CreateProperty(OrgPropXml.tagRepyear);
                    propSpec[3]  = CreateProperty(OrgPropXml.tagDirectorType);
                    propSpec[4]  = CreateProperty(OrgPropXml.tagDirectorFIO);
                    propSpec[5]  = CreateProperty(OrgPropXml.tagBookkeeperFIO);
                    propSpec[6]  = CreateProperty(OrgPropXml.tagPerformer);
                    propSpec[7]  = CreateProperty(OrgPropXml.tagOperatorName);
                    propSpec[8]  = CreateProperty(OrgPropXml.tagDate);
                    propSpec[9]  = CreateProperty(OrgPropXml.tagVersion);
                    propSpec[10] = CreateProperty(OrgPropXml.tagProgramName);
                    propSpec[11] = CreateProperty(OrgPropXml.tagProgramVersion);

                    propVariant[0]  = CreatePropertyValue(properties.orgRegnum);
                    propVariant[1]  = CreatePropertyValue(properties.orgName);
                    propVariant[2]  = CreatePropertyValue(properties.repYear);
                    propVariant[3]  = CreatePropertyValue(properties.directorType);
                    propVariant[4]  = CreatePropertyValue(properties.directorFIO);
                    propVariant[5]  = CreatePropertyValue(properties.bookkeeperFIO);
                    propVariant[6]  = CreatePropertyValue(properties.performer);
                    propVariant[7]  = CreatePropertyValue(properties.operatorName);
                    propVariant[8]  = CreatePropertyValue(properties.date.ToString("dd.MM.yyyy H:mm:ss"));
                    propVariant[9]  = CreatePropertyValue(properties.version);
                    propVariant[10] = CreatePropertyValue(properties.programName);
                    propVariant[11] = CreatePropertyValue(properties.programVersion);

                    ps.WriteMultiple(12, propSpec, propVariant, 2);
                    ps.Commit(0);

                    ReleaseProperties(propSpec, propVariant);
                    Marshal.FinalReleaseComObject(pss);
                }
                else
                {
                    Console.WriteLine("Could not create property set storage");
                }

                Marshal.FinalReleaseComObject(Is);
            }
            else
            {
                Console.WriteLine("File does not contain a structured storage");
            }

            GC.Collect();
        }
예제 #9
0
        /// <summary>
        /// Импортировать XML файлы по указанной директории
        /// </summary>
        /// <param name="path">Путь расположения файлов</param>
        /// <param name="orgProperty">Свойства организации</param>
        /// <param name="szv3Xml">Выходной параметр</param>
        /// <param name="szv2XmlArray">Выходной параметр</param>
        /// <param name="szv1XmlArray">Выходной параметр</param>
        /// <returns></returns>
        public static bool ImportXml(string path, OrgPropXml orgProperty,
                                     out XmlDocument szv3Xml,
                                     out IEnumerable <XmlDocument> szv2XmlArray,
                                     out IEnumerable <IEnumerable <XmlDocument> > szv1XmlArray,
                                     StreamWriter writer)
        {
            szv3Xml      = null;
            szv2XmlArray = null;
            szv1XmlArray = null;
            string rootDirStr = Path.Combine(path, orgProperty.orgRegnum);

            rootDirStr = Path.Combine(rootDirStr, orgProperty.repYear);
            // если в корневой директории (папке) нет подпапки с Рег номером организации,
            // в которой в свою очередь нет папки с отчетным годом (RepYear),
            // то процесс импорта невозможен
            //if (!Directory.Exists(rootDirStr))
            //{
            //    writer.WriteLine("Не найдена папка \"{0}\"", rootDirStr);
            //    writer.WriteLine("---");
            //    return false;
            //}
            string szv3Filename = rootDirStr + @"\сводная.xml";
            // если нет файла Описи (СЗВ-3) импорт не может быть закончен
            //if (!File.Exists(szv3Filename))
            //{
            //    writer.WriteLine("Не найден файл \"{0}\"", szv3Filename);
            //    writer.WriteLine("---");
            //    return false;
            //}
            DirectoryInfo rootDir = new DirectoryInfo(rootDirStr);

            DirectoryInfo[] packetDirs   = rootDir.GetDirectories("Пакет_Z???");
            FileInfo[]      opisFiles    = rootDir.GetFiles("z_опись_???.xml");
            FileInfo[][]    szv1FilesArr = new FileInfo[packetDirs.Count()][];
            // если количество директорий (папок) с документами СЗВ-1
            // отличается от количества файлов с описями (документы СЗВ-2)
            // процесс импорта следует прекратить
            //if (packetDirs.Count() != opisFiles.Count())
            //{
            //    writer.WriteLine("Количество директорий (папок) с документами СЗВ-1 {0} отличается от количества файлов с описями (документы СЗВ-2) {1} ", packetDirs.Count(), opisFiles.Count());
            //    writer.WriteLine("---");
            //    return false;
            //}

            //if (packetDirs.Count() < 1)
            //{
            //    writer.WriteLine("Количество директорий (папок) с документами СЗВ-1 {0} не может быть меньше 1", packetDirs.Count());
            //    writer.WriteLine("---");
            //    return false;
            //}

            string[] dirNumArr  = new string[packetDirs.Count()];
            string[] fileNumArr = new string[opisFiles.Count()];
            int      i;

            for (i = 0; i < dirNumArr.Length; i++)
            {
                string tmpStr = packetDirs[i].Name;
                dirNumArr[i]  = tmpStr.Substring(tmpStr.Length - 3, 3);
                tmpStr        = opisFiles[i].Name;
                fileNumArr[i] = tmpStr.Substring(tmpStr.Length - 7, 3);
            }
            //int count = 0;
            //for (i = 0; i < dirNumArr.Length; i++)
            //{
            //    if (dirNumArr.Contains(fileNumArr[i]))
            //    {
            //        count++;
            //    }
            //}
            //// не всем файлам описей (СЗВ-2) найдены
            //// соответствующие директории (папки) пакетов
            //if (count < dirNumArr.Length)
            //{
            //    writer.WriteLine("Не для всех файлов описей (СЗВ-2) найдены соответствующие директории (папки) пакетов");
            //    writer.WriteLine("---");
            //    return false;
            //}
            //count = 0;
            for (i = 0; i < dirNumArr.Length; i++)
            {
                szv1FilesArr[i] = packetDirs[i].GetFiles(string.Format("z_документ_L{0}_D???.xml", dirNumArr[i]));
                // если в директории (папке) есть файлы удовлетворяющие фильиру,
                // то увеличиваем счетчик
                //if (szv1FilesArr[i].Length > 0)
                //{
                //    count++;
                //}
                //else
                //{
                //    writer.WriteLine("В директории (папке)  \"{0}\" не найдены документы СЗВ-1", packetDirs[i].FullName);
                //    writer.WriteLine("---");
                //}
            }
            // если есть директории пакетов без файлов документов СЗВ-1,
            // то импорт невозможен
            //if (count < dirNumArr.Length)
            //{
            //    return false;
            //}

            // Все проверки окончены, теперь можно проводить непосредственно импорт
            bool isValid = true;
            List <IEnumerable <XmlDocument> > szv1Lists = new List <IEnumerable <XmlDocument> >(opisFiles.Length);
            List <XmlDocument> szv2List = new List <XmlDocument>(opisFiles.Length);

            for (i = 0; i < opisFiles.Count(); i++)
            {
                XmlDocument szv2Xml = XmlData.ReadXml(opisFiles[i].FullName);
                szv2Xml.PreserveWhitespace = true;
                isValid &= XmlData.ValidateXml(Properties.Settings.Default.xsd_szv2, opisFiles[i].FullName, writer);
                szv2List.Add(szv2Xml);

                List <XmlDocument> szv1Docs = new List <XmlDocument>(szv1FilesArr[i].Length);
                for (int j = 0; j < szv1FilesArr[i].Length; j++)
                {
                    #region COM Validate XML

                    //string xmlText = File.ReadAllText(szv1FilesArr[i][j].FullName);
                    //try
                    //{
                    //    // create an XML6 parser
                    //    MSXML2.DOMDocument60 msxml =
                    //       new MSXML2.DOMDocument60();
                    //    msxml.async = false;
                    //    msxml.resolveExternals = false;


                    //    MSXML2.XMLSchemaCache60Class msSchema =
                    //       new MSXML2.XMLSchemaCache60Class();
                    //    msSchema.add("", Properties.Settings.Default.xsd_szv1);

                    //    msxml.schemas = msSchema;
                    //    // load XML
                    //    msxml.loadXML(xmlText);
                    //    if (msxml.parseError.errorCode != 0)
                    //    {
                    //        // some kind of parsing error found..
                    //        throw new Exception("parsing error:  " +
                    //                 msxml.parseError.reason);
                    //    }
                    //}
                    //catch (Exception e)
                    //{
                    //    // an exception happened.
                    //    Console.WriteLine(e.Message);
                    //}

                    #endregion

                    XmlDocument szv1Xml = XmlData.ReadXml(szv1FilesArr[i][j].FullName);
                    szv1Xml.PreserveWhitespace = true;
                    isValid &= XmlData.ValidateXml(Properties.Settings.Default.xsd_szv1, szv1FilesArr[i][j].FullName, writer);
                    szv1Docs.Add(szv1Xml);
                }
                szv1Lists.Add(szv1Docs.ToArray());
            }
            // заполнение выходных параметров
            szv3Xml = XmlData.ReadXml(szv3Filename);
            szv3Xml.PreserveWhitespace = true;
            isValid &= XmlData.ValidateXml(Properties.Settings.Default.xsd_szv3, szv3Filename, writer);

            szv2XmlArray = szv2List;
            szv1XmlArray = szv1Lists.ToArray();
            //
            return(isValid);
        }