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(); }
private void InitializeControl() { ApiController = new ApiController("your virustotal api key"); formFile = new FormFiles(ApiController); formFile.ShowBallonTipHandler += (t, c) => notifyIcon.ShowBalloonTip(1000, t, c, ToolTipIcon.None); formUrls = new FormUrls(ApiController); this.Controls.Add(formFile); this.Controls.Add(formUrls); formFile.Parent = this.panel_forms; formUrls.Parent = this.panel_forms; //default ShowSelectedForm(FormType.FormFile); }
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(); }