Exemplo n.º 1
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);
        }