Esempio n. 1
0
        public void ExportConfig()
        {
            GCInterface gcInterface = _interfaceView.GetSelectedInterface();

            if (gcInterface == null)
            {
                return;
            }

            base.SetStatus("Exporting interface configuration.");

            frmMain.Cursor = Cursors.WaitCursor;
            string[] filelist = _interfaceManager.DetectConfig(gcInterface, gcInterface.FolderPath);
            frmMain.Cursor = Cursors.Default;

            if (filelist == null)
            {
                Program.Log.Write(LogType.Warning, "{Interface} Export interface configuration failed : " + GCError.LastErrorInfor);
                if (GCError.LastError != null)
                {
                    Program.Log.Write(LogType.Error, GCError.LastError.ToString());
                }

                MessageBox.Show(frmMain, "Export interface configuration failed.\r\n\r\n" + GCError.LastErrorInfor,
                                "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                goto _ExportExit;
            }

            if (filelist.Length < 1)
            {
                MessageBox.Show(frmMain, "There is no configuration file in this interface (" + gcInterface.FolderPath + ")",
                                "Export Configuration", MessageBoxButtons.OK, MessageBoxIcon.Information);
                goto _ExportExit;
            }

            FolderBrowserDialog dlg = new FolderBrowserDialog();

            dlg.ShowNewFolderButton = true;
            dlg.Description         = "Please select a folder to export interface configuration.";
            if (dlg.ShowDialog(frmMain) != DialogResult.OK)
            {
                goto _ExportExit;
            }

            string    folderName = dlg.SelectedPath;
            FormFiles frm        = new FormFiles(FileOperator.Export, gcInterface, filelist, folderName);

            if (frm.ShowDialog(frmMain) == DialogResult.OK)
            {
                _interfaceView.RefreshView();
                _interfaceView.SelectInterface(gcInterface);
            }

_ExportExit:
            base.ClearStatus();
        }
Esempio n. 2
0
        private void WithCard(string[] args)
        {
            TreeNode treeNode   = classTree.TreeViewDialog("Добавление документа", "Добавить");
            int      idFolder   = Convert.ToInt32(treeNode.Name.Split('_')[1]);
            int      idTypeCard = classTypeCard.getIdByName("Пустая");
            string   res        = "";

            formFiles.Text = "Укажите имя файла";
            formFiles.textBoxNameFile.ReadOnly = true;
            formFiles.textBoxTreePath.Text     = treeNode.FullPath;
            formFiles.isCheck = false;
            formFiles.ShowDialog();

            // получаем получаем номер типа карточки документа по имени имав карточки
            idTypeCard = classTypeCard.getIdByName(formFiles.comboBox1.Text.ToString());

            foreach (string arg in args)
            {
                // если мы попали на ячеку массива с параметром коммандной строки
                if (arg == "withCard")
                {
                    continue;
                }

                string fileName = Path.GetFileName(arg);
                string pathSave = treeNode.FullPath;
                string fullPath = arg;
                int    idFile   = classFile.Create(idFolder, idTypeCard, fileName, fullPath, pathSave);

                // если файл не создался
                if (idFile != 0)
                {
                    res += arg + " Ошибка загрузки! \n";
                    continue;
                }
                Control.ControlCollection controlCollection = formFiles.panel1.Controls;
                sendValueOfFields(controlCollection, idFile);
            }

            if (res != "")
            {
                MessageBox.Show(res);
            }
        }
Esempio n. 3
0
        public void ImportConfig()
        {
            GCInterface gcInterface = _interfaceView.GetSelectedInterface();

            if (gcInterface == null)
            {
                return;
            }

            if (!gcInterface.Directory.Files.HasBackupableFile())
            {
                MessageBox.Show(frmMain, "There is no configuration file in this interface (" + gcInterface.FolderPath + ")",
                                "Import Configuration", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            base.SetStatus("Importing interface configuration.");

            FolderBrowserDialog dlg = new FolderBrowserDialog();

            dlg.ShowNewFolderButton = false;
            dlg.Description         = "Please select a folder which contains interface configuration to be imported.";
            if (dlg.ShowDialog(frmMain) != DialogResult.OK)
            {
                goto _ImportExit;
            }

            frmMain.Cursor = Cursors.WaitCursor;
            string folderName = dlg.SelectedPath;

            string[] filelist = _interfaceManager.DetectConfig(gcInterface, folderName);
            frmMain.Cursor = Cursors.Default;

            if (filelist == null)
            {
                Program.Log.Write(LogType.Warning, "{Interface} Import interface configuration failed : " + GCError.LastErrorInfor);
                if (GCError.LastError != null)
                {
                    Program.Log.Write(LogType.Error, GCError.LastError.ToString());
                }

                MessageBox.Show(frmMain, "Import interface configuration failed.\r\n\r\n" + GCError.LastErrorInfor,
                                "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                goto _ImportExit;
            }

            if (filelist.Length < 1)
            {
                MessageBox.Show(frmMain, "Cannot find any configuration file in " + folderName,
                                "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                goto _ImportExit;
            }

            FormFiles frm = new FormFiles(FileOperator.Import, gcInterface, filelist, gcInterface.FolderPath);

            if (frm.ShowDialog(frmMain) == DialogResult.OK)
            {
                //update AdapterService configuration (ServiceName, DataDBConnection, ConfigDBConnection, etc.)
                foreach (string fileName in filelist)
                {
                    string fName = Path.GetFileName(fileName);
                    if (fName == ConfigHelper.ServiceDefaultFileName)
                    {
                        fName = gcInterface.FolderPath + "\\" + fName;
                        AdapterServiceCfgMgt mgt = new AdapterServiceCfgMgt(fName);
                        if (mgt.Load())
                        {
                            mgt.Config.ServiceName        = gcInterface.InterfaceName;
                            mgt.Config.DataDBConnection   = Program.ConfigMgt.Config.DataDBConnection;
                            mgt.Config.ConfigDBConnection = Program.ConfigMgt.Config.ConfigDBConnection;
                            if (mgt.Save())
                            {
                                Program.Log.Write(LogType.Info, "AdapterService configuration updated.");
                            }
                        }
                    }
                }

                //update SQL scripts (SP)
                if (Program.ConfigMgt.Config.ShowConfigAfterImportConfig)
                {
                    CallAdapterConfigProcess(gcInterface, AdapterConfigArgument.InIMWizard);
                }
            }

_ImportExit:
            base.ClearStatus();
        }