Пример #1
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            // import selected table from dat format
            if (AppData.Connected)
            {
                var    selItem     = cbTable.SelectedItem;
                string logFileName = AppData.AppDirs.LogDir + "ScadaAdminImport.txt";
                bool   importOK;
                bool   logCreated;
                string msg;

                if (selItem is ImportAllTablesItem)
                {
                    // import all tables from a directory
                    importOK = ImportExport.ImportAllTables(txtFileName.Text, Tables.TableInfoList,
                                                            logFileName, out logCreated, out msg);
                }
                else if (selItem is ImportArchiveItem)
                {
                    // import archive
                    importOK = ImportExport.ImportArchive(txtFileName.Text, Tables.TableInfoList,
                                                          logFileName, out logCreated, out msg);
                }
                else
                {
                    // import table
                    var tableInfo = (Tables.TableInfo)selItem;
                    int minID     = gbIDs.Enabled && chkStartID.Checked ? Convert.ToInt32(numStartID.Value) : 0;
                    int maxID     = gbIDs.Enabled && chkFinalID.Checked ? Convert.ToInt32(numFinalID.Value) : int.MaxValue;
                    int newMinID  = gbIDs.Enabled && chkNewStartID.Checked ? Convert.ToInt32(numNewStartID.Value) : 0;
                    importOK = ImportExport.ImportTable(txtFileName.Text, tableInfo, minID, maxID, newMinID,
                                                        logFileName, out logCreated, out msg);
                }

                // display of the result message
                if (importOK)
                {
                    ScadaUiUtils.ShowInfo(msg);
                }
                else
                {
                    AppUtils.ProcError(msg);

                    // log display in notebook
                    if (logCreated)
                    {
                        Process.Start(logFileName);
                    }
                }
            }
        }
Пример #2
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            // импорт выбранной таблицы из формата DAT
            if (AppData.Connected)
            {
                object selItem     = cbTable.SelectedItem;
                string logFileName = AppData.AppDirs.LogDir + "ScadaAdminImport.txt";
                bool   importOK;
                bool   logCreated;
                string msg;

                if (selItem is ImportAllTablesItem)
                {
                    // импорт всех таблиц из директории
                    importOK = ImportExport.ImportAllTables(txtFileName.Text, Tables.TableInfoList,
                                                            logFileName, out logCreated, out msg);
                }
                else if (selItem is ImportArchiveItem)
                {
                    // импорт архива
                    importOK = ImportExport.ImportArchive(txtFileName.Text, Tables.TableInfoList,
                                                          logFileName, out logCreated, out msg);
                }
                else
                {
                    // импорт таблицы
                    Tables.TableInfo tableInfo = (Tables.TableInfo)selItem;
                    int minID    = gbIDs.Enabled && chkStartID.Checked ? Convert.ToInt32(numStartID.Value) : 0;
                    int maxID    = gbIDs.Enabled && chkFinalID.Checked ? Convert.ToInt32(numFinalID.Value) : int.MaxValue;
                    int newMinID = gbIDs.Enabled && chkNewStartID.Checked ? Convert.ToInt32(numNewStartID.Value) : 0;
                    importOK = ImportExport.ImportTable(txtFileName.Text, tableInfo, minID, maxID, newMinID,
                                                        logFileName, out logCreated, out msg);
                }

                // отображение сообщения о результате
                if (importOK)
                {
                    ScadaUiUtils.ShowInfo(msg);
                }
                else
                {
                    AppUtils.ProcError(msg);

                    // отображение журнала в блокноте
                    if (logCreated)
                    {
                        Process.Start(logFileName);
                    }
                }
            }
        }