Beispiel #1
0
        private async void insert_files(string[] filePaths)
        {
            using (GUI.MessageListBox msgbox = new GUI.MessageListBox("Review Files", "You are about to import the following files!\r\n\r\nAre you sure you want to do that?", filePaths))
            {
                msgbox.ShowDialog(GUI.Main.Instance);
                if (msgbox.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
            }

            try
            {
                tab_disabled = true;

                if (filePaths.Length == 1)
                {
                    string path = filePaths[0];
                    string msg  = $"Importing: {Path.GetFileName(path)}";
                    ts_status.Text = msg;
                    lManager.Enter(Sender.DATA, Level.NOTICE, msg);

                    await Task.Run(() => { core.ImportFileEntry(path); });
                }
                else if (filePaths.Length > 1)
                {
                    await Task.Run(() => { core.ImportFileEntries(filePaths); });
                }

                core.Save();
            }
            catch (Exception ex)
            {
                Core_CurrentProgressReset(null, new CurrentResetArgs(false));
                MessageBox.Show(ex.Message, "Import Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                lManager.Enter(Sender.DATA, Level.ERROR, ex);
            }
            finally
            {
                tab_disabled   = false;
                ts_status.Text = string.Empty;
            }
        }
Beispiel #2
0
        private async void insert_files(string[] filePaths)
        {
            using (GUI.MessageListBox msgbox = new GUI.MessageListBox("Review Files", "You are about to import the following files!\r\n\r\nAre you sure you want to do that?", filePaths))
            {
                msgbox.ShowDialog(GUI.Main.Instance);
                if (msgbox.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
            }

            try
            {
                foreach (string filePath in filePaths)
                {
                    tab_disabled = true;
                    string msg = string.Format("Importing: {0}...", Path.GetFileName(filePath));
                    ts_status.Text = msg;
                    lManager.Enter(Logs.Sender.DATA, Logs.Level.NOTICE, msg);

                    await Task.Run(() => { core.ImportFileEntry(filePath); });
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Import Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                lManager.Enter(Logs.Sender.DATA, Logs.Level.ERROR, ex);
            }
            finally
            {
                core.Save();

                tab_disabled   = false;
                ts_status.Text = string.Empty;
            }
        }