예제 #1
0
        public static void Export(IPlugin plugin,
                                  ApplicationDataModel.ADM.ApplicationDataModel applicationDataModel,
                                  string initializeString,
                                  string exportPath,
                                  ApplicationDataModel.ADM.Properties properties)
        {
            InitializePlugin(plugin, initializeString);

            plugin.Export(applicationDataModel, exportPath, properties);
        }
예제 #2
0
        private void _exportDatacardButton_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            ApplicationDataModel.ADM.Properties properties = new ApplicationDataModel.ADM.Properties();
            foreach (DataGridViewRow row in _proprietaryDataGridView.Rows)
            {
                if (row.Cells[0].Value != null && row.Cells[1].Value != null)
                {
                    properties.SetProperty(row.Cells[0].Value.ToString(), row.Cells[1].Value.ToString());
                }
            }

            _model.Export(((KeyValuePair <string, string>)_loadedPluginsListBox.SelectedItem).Key,
                          _initializeStringTextBox.Text,
                          _exportPathTextBox.Text,
                          cardProfileSelection.SelectedItem.ToString(),
                          properties);

            Cursor.Current = Cursors.Default;

            DialogResult = DialogResult.OK;
        }
예제 #3
0
        private void _importButton_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            if (_model.ArePluginsLoaded(_pluginPathTextBox))
            {
                _treeView.Nodes.Clear();
                _dataGridViewRawData.Columns.Clear();

                ApplicationDataModel.ADM.Properties properties = new ApplicationDataModel.ADM.Properties();
                foreach (DataGridViewRow row in _proprietaryDataGridView.Rows)
                {
                    if (row.Cells[0].Value != null && row.Cells[1].Value != null)
                    {
                        properties.SetProperty(row.Cells[0].Value.ToString(), row.Cells[1].Value.ToString());
                    }
                }

                if (_model.Import(_importPathTextbox, _initializeStringTextBox.Text, _treeView, properties))
                {
                    // Content of _importPathComboBox was valid --> add to history.
                    string s = _importPathTextbox.Text;
                    if (_importPathHistory == null)
                    {
                        _importPathHistory = new AutoCompleteStringCollection();
                    }
                    if (!_importPathHistory.Contains(s))
                    {
                        _importPathHistory.Add(s);
                    }
                }

                DialogResult = DialogResult.OK;
            }

            Cursor.Current = Cursors.Default;
        }
예제 #4
0
        private void ImportDataCard(string datacardPath, string initializeString, TreeView treeView, ApplicationDataModel.ADM.Properties properties)
        {
            _treeView = treeView;

            Task.Run(() =>
            {
                DateTime start = DateTime.Now;  //170629 MSp

                _updateStatusAction(CurrentState, "Starting Import");

                ApplicationDataModels = _dataProvider.Import(datacardPath, initializeString, properties);
                if (ApplicationDataModels == null || ApplicationDataModels.Count == 0)
                {
                    MessageBox.Show(@"Not supported data format.");
                    CurrentState = State.StateIdle;
                    _updateStatusAction(CurrentState, "Done");
                    return;
                }

                _admIndex = 0;
                for (; _admIndex < ApplicationDataModels.Count; _admIndex++)
                {
                    var applicationDataModel = ApplicationDataModels[_admIndex];

                    applicationDataModel.Documents?.LoggedData.SelectMany(x => x.OperationData.ToList()).ToList();

                    var parentNode = (TreeNode)_treeView.Invoke(new Func <TreeNode>(() => treeView.Nodes.Add("ApplicationDataModel")));

                    AddNode(applicationDataModel, parentNode);
                }

                CurrentState = State.StateIdle;
                _updateStatusAction(CurrentState, "Done");

                //170629 MSp How long did it take to parse the data model into the tree?
                DateTime stop     = DateTime.Now;
                TimeSpan duration = new TimeSpan(stop.Ticks - start.Ticks);
                System.Diagnostics.Debug.Print($"ImportDataCard had a duration of {duration.Seconds:#,##0.0}.");
            });
        }
예제 #5
0
        public bool Import(TextBox dataCardTextBox, string initializeString, TreeView treeView, ApplicationDataModel.ADM.Properties properties)
        {
            if (IsValid(dataCardTextBox, "Datacard"))
            {
                CurrentState = State.StateImporting;
                treeView.BeginUpdate();

                ImportDataCard(dataCardTextBox.Text, initializeString, treeView, properties);

                treeView.EndUpdate();

                return(true);
            }

            return(false);
        }
예제 #6
0
        public void Export(string pluginName, string initializeString, string exportPath, string cardProfileSelectedText, ApplicationDataModel.ADM.Properties properties)
        {
            try
            {
                var plugin = _dataProvider.GetPlugin(pluginName);

                if (ApplicationDataModels == null || ApplicationDataModels.Count == 0 || plugin == null)
                {
                    MessageBox.Show(@"Could not export, either not a comptable plugin or no data model to export");
                    return;
                }

                Task.Run(() =>
                {
                    CurrentState = State.StateExporting;
                    _updateStatusAction(CurrentState, "Export in Progress");

                    var selectApplicationDataModel =
                        ApplicationDataModels.First(
                            x => x.Catalog.Description.ToLower().Equals(cardProfileSelectedText.ToLower()));
                    DataProvider.Export(plugin,
                                        selectApplicationDataModel,
                                        initializeString,
                                        GetExportDirectory(exportPath),
                                        properties);

                    CurrentState = State.StateIdle;
                    _updateStatusAction(CurrentState, "Done");
                });
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
예제 #7
0
        public IList <ApplicationDataModel.ADM.ApplicationDataModel> Import(string datacardPath, string initializeString, ApplicationDataModel.ADM.Properties properties)
        {
            var list = new List <ApplicationDataModel.ADM.ApplicationDataModel>();

            foreach (var availablePlugin in AvailablePlugins)
            {
                var plugin = GetPlugin(availablePlugin.Key);
                InitializePlugin(plugin, initializeString);

                if (plugin.IsDataCardSupported(datacardPath))
                {
                    list.AddRange(plugin.Import(datacardPath, properties));
                }
            }
            if (list.Any())
            {
                return(list);
            }
            return(null);
        }