public ImportPopulateByTable( LogInstance log, ExportTableRecord job, AdminShell.Submodel sm, AdminShell.AdministrationShellEnv env, ExportTableOptions options) { // context _log = log; _job = job; _sm = sm; _env = env; _options = options; // prepare Submodel if (sm == null || _job.Top == null || _job.Body == null) { return; } if (sm.submodelElements == null) { sm.submodelElements = new AdminShell.SubmodelElementWrapperCollection(); } // prepare matchers _matcherTop = _job.Top.Select((s) => ImportCellMatcherBase.Create(s)).ToList(); _matcherBody = _job.Body.Select((s) => ImportCellMatcherBase.Create(s)).ToList(); }
private ExportTableRecord ThisToPreset() { var x = new ExportTableRecord(this.rows, this.cols, "", this.textBoxesHeader.Select(tb => tb.Text), this.textBoxesElements.Select(tb => tb.Text) ); x.Format = ComboBoxFormat.SelectedIndex; x.ReplaceFailedMatches = CheckBoxReplaceFailed.IsChecked == true; x.FailText = TextBoxFailText.Text; return(x); }
private void ThisFromPreset(ExportTableRecord preset) { // access if (preset == null || preset.RowsTop < 1 || preset.RowsBody < 1 || preset.Cols < 1) { return; } // take over _rowsTop = preset.RowsTop; _rowsBody = preset.RowsBody; _cols = preset.Cols; ComboBoxFormat.SelectedIndex = Math.Max(0, Math.Min(ComboBoxFormat.Items.Count - 1, preset.Format)); TextBoxNumRowsTop.Text = "" + _rowsTop; TextBoxNumRowsBody.Text = "" + _rowsBody; TextBoxNumRowsBody.Text = "" + _rowsBody; TextBoxNumCols.Text = "" + _cols; CheckBoxReplaceFailed.IsChecked = preset.ReplaceFailedMatches; TextBoxFailText.Text = "" + preset.FailText; CheckBoxActInHierarchy.IsChecked = preset.ActInHierarchy; TextBoxNumRowsGap.Text = "" + preset.RowsGap; AdaptRowsCols(GridOuterTop, _textBoxesTop, _rowsTop, _cols); AdaptRowsCols(GridOuterBody, _textBoxesBody, _rowsBody, _cols); if (preset.Top != null) { for (int i = 0; i < preset.Top.Count; i++) { if (i < _textBoxesTop.Count) { _textBoxesTop[i].Text = preset.Top[i]; } } } if (preset.Body != null) { for (int i = 0; i < preset.Body.Count; i++) { if (i < _textBoxesBody.Count) { _textBoxesBody[i].Text = preset.Body[i]; } } } }
private void ThisFromPreset(ExportTableRecord preset) { // access if (preset == null || preset.Rows < 1 || preset.Cols < 1) { return; } // take over this.rows = preset.Rows; this.cols = preset.Cols; ComboBoxFormat.SelectedIndex = Math.Max(0, Math.Min(ComboBoxFormat.Items.Count - 1, preset.Format)); TextBoxNumRows.Text = "" + this.rows; TextBoxNumCols.Text = "" + this.cols; CheckBoxReplaceFailed.IsChecked = preset.ReplaceFailedMatches; TextBoxFailText.Text = "" + preset.FailText; AdaptRowsCols(GridOuterHeader, textBoxesHeader, this.rows, this.cols); AdaptRowsCols(GridOuterElements, textBoxesElements, this.rows, this.cols); if (preset.Header != null) { for (int i = 0; i < preset.Header.Count; i++) { if (i < this.textBoxesHeader.Count) { this.textBoxesHeader[i].Text = preset.Header[i]; } } } if (preset.Elements != null) { for (int i = 0; i < preset.Elements.Count; i++) { if (i < this.textBoxesElements.Count) { this.textBoxesElements[i].Text = preset.Elements[i]; } } } }
private ExportTableRecord ThisToPreset() { var x = new ExportTableRecord(_rowsTop, _rowsBody, _cols, "", _textBoxesTop.Select(tb => tb.Text), _textBoxesBody.Select(tb => tb.Text) ); x.Format = ComboBoxFormat.SelectedIndex; x.ReplaceFailedMatches = CheckBoxReplaceFailed.IsChecked == true; x.FailText = TextBoxFailText.Text; x.ActInHierarchy = CheckBoxActInHierarchy.IsChecked == true; if (int.TryParse(TextBoxNumRowsGap.Text, out var i)) { x.RowsGap = i; } else { x.RowsGap = 0; } return(x); }
private void Button_Click(object sender, RoutedEventArgs e) { if (sender == ButtonStart) { this.Result = this.ThisToPreset(); ControlClosed?.Invoke(); } if (sender == ButtonResize) { // save the old state int oldRowsTop = _rowsTop, oldRowsBody = _rowsBody, oldCols = _cols; var oldHeader = _textBoxesTop.Select(tb => tb.Text).ToList(); var oldElements = _textBoxesBody.Select(tb => tb.Text).ToList(); if (!int.TryParse("" + TextBoxNumRowsTop.Text, out int irowsT) || !int.TryParse("" + TextBoxNumRowsBody.Text, out int irowsB) || !int.TryParse("" + TextBoxNumCols.Text, out int icols)) { return; } _rowsTop = Math.Max(1, irowsT); _rowsBody = Math.Max(1, irowsB); _cols = Math.Max(1, icols); AdaptRowsCols(GridOuterTop, _textBoxesTop, _rowsTop, _cols); AdaptRowsCols(GridOuterBody, _textBoxesBody, _rowsBody, _cols); Action <List <TextBox>, List <string>, int, int> reAssign = (tbs, oldText, rows, oldrows) => { for (int nr = 0; nr < 1 + rows; nr++) { for (int nc = 0; nc < 1 + _cols; nc++) { var txt = ""; var oldNdx = nr * (1 + oldCols) + nc; if (nr < 1 + oldrows && nc < 1 + oldCols && oldNdx < oldText.Count) { txt = oldText[oldNdx]; } var newNdx = nr * (1 + _cols) + nc; if (newNdx < tbs.Count) { tbs[newNdx].Text = txt; } } } }; reAssign(_textBoxesTop, oldHeader, _rowsTop, oldRowsTop); reAssign(_textBoxesBody, oldElements, _rowsBody, oldRowsBody); } if (sender == ButtonSavePreset) { // choose filename var dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = "new.json"; dlg.DefaultExt = "*.json"; dlg.Filter = "Preset JSON file (*.json)|*.json|All files (*.*)|*.*"; // save if (true == dlg.ShowDialog()) { try { var pr = this.ThisToPreset(); pr.SaveToFile(dlg.FileName); } catch (Exception ex) { AdminShellNS.LogInternally.That.SilentlyIgnoredError(ex); } } } if (sender == ButtonLoadPreset) { // choose filename var dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = "new.json"; dlg.DefaultExt = "*.json"; dlg.Filter = "Preset JSON file (*.json)|*.json|All files (*.*)|*.*"; // save if (true == dlg.ShowDialog()) { try { var pr = ExportTableRecord.LoadFromFile(dlg.FileName); this.ThisFromPreset(pr); } catch (Exception ex) { AdminShellNS.LogInternally.That.SilentlyIgnoredError(ex); } } } }
private void ButtonHelp_Click(object sender, RoutedEventArgs e) { this.Result = null; this.CloseForHelp = true; ControlClosed?.Invoke(); }
private void ButtonClose_Click(object sender, RoutedEventArgs e) { this.Result = null; ControlClosed?.Invoke(); }
private void Button_Click(object sender, RoutedEventArgs e) { if (sender == ButtonExport) { this.Result = this.ThisToPreset(); ControlClosed?.Invoke(); } if (sender == ButtonResize) { if (!int.TryParse("" + TextBoxNumRows.Text, out int irows) || !int.TryParse("" + TextBoxNumCols.Text, out int icols)) { return; } this.rows = Math.Max(1, irows); this.cols = Math.Max(1, icols); AdaptRowsCols(GridOuterHeader, textBoxesHeader, this.rows, this.cols); AdaptRowsCols(GridOuterElements, textBoxesElements, this.rows, this.cols); } if (sender == ButtonSavePreset) { // choose filename var dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = "new.json"; dlg.DefaultExt = "*.json"; dlg.Filter = "Preset JSON file (*.json)|*.json|All files (*.*)|*.*"; // save if (true == dlg.ShowDialog()) { try { var pr = this.ThisToPreset(); pr.SaveToFile(dlg.FileName); } catch (Exception ex) { AdminShellNS.LogInternally.That.SilentlyIgnoredError(ex); } } } if (sender == ButtonLoadPreset) { // choose filename var dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = "new.json"; dlg.DefaultExt = "*.json"; dlg.Filter = "Preset JSON file (*.json)|*.json|All files (*.*)|*.*"; // save if (true == dlg.ShowDialog()) { try { var pr = ExportTableRecord.LoadFromFile(dlg.FileName); this.ThisFromPreset(pr); } catch (Exception ex) { AdminShellNS.LogInternally.That.SilentlyIgnoredError(ex); } } } }
public ItemProcessor(ExportTableRecord record, ExportTableAasEntitiesItem item) { this.Record = record; this.Item = item; }