private void ButtonCreateService_Click(object sender, EventArgs e) { try { dynamic service = _service; string serviceId = null; if (service != null && service.Id != null) { serviceId = service.Id; } _service = new DynamicWrapper(); _service.Id = serviceId ?? Guid.NewGuid().ToString(); _service.Name = TextEditServiceName.Text; _service.Caption = TextEditServiceCaption.Text; _service.Type = ViewModelExtension.BuildCompleteServiceType(ComboBoxServiceType.EditValue.ToString()); foreach (var extensionPoint in _extensionPoints) { _service.BuildCollectionItem("ExtensionPoints", (object)extensionPoint); } MessageBox.Show("Service metadata created successfully."); OnValueChanged(_service, new EventArgs()); } catch { MessageBox.Show("Ошибка создания сервиса"); } }
/// <summary> /// Нажатие на кнопку отката миграции /// </summary> private void DownButton_Click(object sender, EventArgs e) { var lines = new List <string>(MigrationMemoEdit.Lines) { string.Format("Migration {0} revert started.", MigrationsComboBox.Text) }; string resultString = null; var process = new StatusProcess(); process.StartOperation(() => { resultString = ViewModelExtension.RevertMigration(Version, Value.Name.ToString(), MigrationsComboBox.Text, GetParameterValues()); }); process.EndOperation(); lines.AddRange(resultString .Replace("\\r", "\r") .Replace("\\n", "\n") .Replace("\"", "") .Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries)); MigrationMemoEdit.Lines = lines.ToArray(); MigrationMemoEdit.SelectionStart = MigrationMemoEdit.Text.Length; MigrationMemoEdit.ScrollToCaret(); }
private void ButtonCheckGenerator_Click(object sender, EventArgs e) { if (ComboBoxSelectViewType.EditValue == null) { MessageBox.Show("Необходимо указать тип представления"); return; } var form = new CheckedBody(); string jsonParams = string.Empty; if (form.ShowDialog() == DialogResult.OK) { jsonParams = form.JsonBody; } dynamic item = MetadataGeneratorSelect.EditValue; var result = ViewModelExtension.CheckGetView(Version(), ConfigId(), item.DocumentId, NameEditor.Text, ComboBoxSelectViewType.EditValue.ToString(), jsonParams); var checkForm = new CheckForm(); checkForm.MemoText = result; checkForm.BodyText = ""; checkForm.UrlText = ""; checkForm.ShowDialog(); }
/// <summary> /// Нажатие на кнопку запуска всех верификаций /// </summary> private void RunAllChecksButton_Click(object sender, EventArgs e) { var lines = new List <string> { "Full verification started." }; var process = new StatusProcess(); process.StartOperation(() => { foreach (string verification in ViewModelExtension.BuildVerifications()) { string resultString = ViewModelExtension.RunVerification(Version, Value.Name.ToString(), verification); lines.Add(string.Format("Verification {0} started.", verification)); lines.AddRange(resultString .Replace("\\r", "\r") .Replace("\\n", "\n") .Replace("\"", "") .Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries)); } }); process.EndOperation(); VerificationMemoEdit.Lines = lines.ToArray(); VerificationMemoEdit.SelectionStart = VerificationMemoEdit.Text.Length; VerificationMemoEdit.ScrollToCaret(); }
private DataTable LoadTransitionStates() { if (_process == null || _process.Transitions == null) { return(new DataTable()); } return(ViewModelExtension.BuildStateTransitions(_process.Transitions)); }
private void ComboBoxServiceType_EditValueChanged(object sender, EventArgs e) { ComboBoxExtensionPoint.Properties.Items.Clear(); if (ComboBoxServiceType.EditValue == null) { return; } ComboBoxExtensionPoint.Properties.Items.AddRange(ViewModelExtension.BuildServiceTypeExtensionPointList((string)ComboBoxServiceType.EditValue).BuildImageComboBoxItems().ToList()); }
private void VerificationsComboBox_SelectedIndexChanged(object sender, EventArgs e) { var selectedVerification = VerificationsComboBox.Text; var verification = ViewModelExtension.BuildVerificationDetails(selectedVerification); if (verification != null) { VerificationDescriptionLabelControl.Text = verification.Description; } }
/// <summary> /// Выбрана другая миграция - необходимо обновить контролы для ввода параметров /// </summary> private void MigrationsComboBox_SelectedIndexChanged(object sender, EventArgs e) { var selectedMigration = MigrationsComboBox.Text; dynamic migration = null; var process = new StatusProcess(); process.StartOperation(() => { migration = ViewModelExtension.BuildMigrationDetails(Version, Value.Name.ToString(), selectedMigration); }); process.EndOperation(); if (migration == null) { return; } MigrationDescriptionLabelControl.Text = migration.Description; DownButton.Visible = migration.IsUndoable; if (migration.Parameters.Length == 0) { ParametersPanelControl.Visible = false; MigrationParametersControl.Visible = false; } else { ParametersPanelControl.Visible = true; MigrationParametersControl.Visible = true; ParametersPanelControl.Controls.Clear(); } var counter = 0; foreach (var parameter in migration.Parameters) { if (parameter.PossibleValues != null && parameter.PossibleValues.Count > 0) { AddComboBoxForParameter(parameter.Caption.ToString(), parameter.PossibleValues, counter++); continue; } if (parameter.InitialValue is bool) { AddCheckBoxForParameter(parameter.Caption.ToString(), parameter.InitialValue, counter++); } else { AddTextEditForParameter(parameter.Caption.ToString(), counter++); } } }
private DataTable LoadScenarios() { DataTable result = null; var process = new StatusProcess(); process.StartOperation(() => { result = ViewModelExtension.BuildDocumentScenarios(Version(), ConfigId(), DocumentId()); }); process.EndOperation(); return(result); }
private void ReloadExistingHandlers() { IEnumerable <HandlerDescription> actionHandlers = null; IEnumerable <HandlerDescription> validationHandlers = null; IEnumerable <string> validationRuleWarningHandlers = null; IEnumerable <string> validationRuleErrorHandlers = null; IEnumerable <string> states = null; actionHandlers = ViewModelExtension.BuildActionHandlerDescriptions(Version(), ConfigId(), DocumentId()); validationHandlers = ViewModelExtension.BuildValidationHandlerDescriptions(Version(), ConfigId(), DocumentId()); validationRuleWarningHandlers = ViewModelExtension.BuildValidationRuleWarningDescriptions(Version(), ConfigId(), DocumentId()); validationRuleErrorHandlers = ViewModelExtension.BuildValidationRuleErrorDescriptions(Version(), ConfigId(), DocumentId()); _selectedTemplate.ActionHandlers = actionHandlers; _selectedTemplate.ValidationErrors = validationRuleErrorHandlers; _selectedTemplate.ValidationWarnings = validationRuleWarningHandlers; _selectedTemplate.ValidationHandlers = validationHandlers; _selectedTemplate.DocumentStates = states; }
private string CreateGeneratedView(string documentId, string generatorName, string viewType) { var form = new CheckedBody(); string jsonParams = string.Empty; if (form.ShowDialog() == DialogResult.OK) { jsonParams = form.JsonBody; } try { return(ViewModelExtension.CheckGetView(Version(), ConfigId(), documentId, generatorName, viewType, jsonParams)); } catch (Exception e) { MessageBox.Show(e.Message); return(null); } }
private void InitEditor() { ComboBoxScenarioContextType.Properties.Items.Clear(); ComboBoxScenarioActionType.Properties.Items.Clear(); ComboBoxScenarioContextType.Properties.Items.AddRange(ViewModelExtension.BuildContextTypes().BuildImageComboBoxItems().ToList()); ComboBoxScenarioActionType.Properties.Items.AddRange(ViewModelExtension.BuildScriptUnitTypes().BuildImageComboBoxItems().ToList()); if (_scenario != null) { var selectedContextType = ComboBoxScenarioContextType.Properties.Items.Cast <ImageComboBoxItem>() .FirstOrDefault(c => (int)c.Value == _scenario.ContextType); var selectedScriptType = ComboBoxScenarioActionType.Properties.Items.Cast <ImageComboBoxItem>() .FirstOrDefault(c => (int)c.Value == _scenario.ScriptUnitType); ComboBoxScenarioActionType.EditValue = selectedScriptType; ComboBoxScenarioContextType.EditValue = selectedContextType; } }
void ButtonCheckGenerator_Click(object sender, EventArgs e) { var form = new CheckedBody(); string jsonParams = string.Empty; if (form.ShowDialog() == DialogResult.OK) { jsonParams = form.JsonBody; } var result = ViewModelExtension.CheckGetView(Version(), ConfigId(), DocumentId(), "", ComboBoxSelectViewType.EditValue.ToString(), jsonParams); var checkForm = new CheckForm { MemoText = result, BodyText = "", UrlText = "" }; checkForm.ShowDialog(); }
private void RefreshUnits(string version) { var process = new StatusProcess(); bool discoverResult = false; process.StartOperation(() => { discoverResult = _assemblyDiscovery.DiscoverAppliedAssemblies(_configurationName); }); process.EndOperation(); if (!discoverResult) { MessageBox.Show( string.Format( "Не найдены прикладные сборки.\n\rКорректно укажите в App.config параметр AppliedAssemblies для указания местоположения прикладных сборок: \n\rТекущее значение параметра: {0}", AppDomain.CurrentDomain.BaseDirectory)); } else { ComboBoxSelectGeneratorScenario.Properties.Items.Clear(); ComboBoxSelectGeneratorScenario.Properties.Items.AddRange(ViewModelExtension.BuildGeneratorScripts(_assemblyDiscovery.SourceAssemblyList).BuildImageComboBoxItems().ToList()); } }
/// <summary> /// Создание нового регистра /// </summary> private void CreateButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(RegisterNameTextEdit.Text)) { MessageBox.Show("Specify register name"); return; } _register.Name = RegisterNameTextEdit.Text; _register.Caption = RegisterNameTextEdit.Text; _register.Id = Guid.NewGuid().ToString(); _register.Properties = new List <dynamic>(); _register.Properties.Add(new { Property = RegisterConstants.RegistrarProperty, Type = RegisterPropertyType.Info }); _register.Properties.Add(new { Property = RegisterConstants.RegistrarTypeProperty, Type = RegisterPropertyType.Info }); _register.Properties.Add(new { Property = RegisterConstants.DocumentDateProperty, Type = RegisterPropertyType.Info }); _register.Properties.Add(new { Property = RegisterConstants.EntryTypeProperty, Type = RegisterPropertyType.Info }); PropertiesPanelControl.Visible = true; _documentSchema = ViewModelExtension.GetRegisterDocumentSchema(Version(), ConfigId(), _register.Name); if (_documentSchema == null) { var proc = new StatusProcess(); proc.StartOperation( delegate { _register.DocumentId = ViewModelExtension.CreateRegisterDocuments(Version(), ConfigId(), _register.Name); }); proc.EndOperation(); } if (OnValueChanged != null) { OnValueChanged(_register, new EventArgs()); } }
/// <summary> /// Добавление свойства регистра. /// Применение изменений схемы данных регистра производится сразу, /// так как при добавлении нового свойства должны быть добавлены /// соответствующие свойства различных служебных документов /// (например, документа, хранящего данные регистра и документа, хранящего рассчитанные итоги) /// </summary> private void AddPropertyButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(PropertyNameTextEdit.Text)) { MessageBox.Show("Specify property name"); return; } if (string.IsNullOrEmpty(DataTypeComboBoxEdit.Text)) { MessageBox.Show("Specify property data type"); return; } if (string.IsNullOrEmpty(PropertyTypeComboBoxEdit.Text)) { MessageBox.Show("Specify property type"); return; } var newProperty = new RegisterProperty( PropertyNameTextEdit.Text, DataTypeComboBoxEdit.Text, PropertyTypeComboBoxEdit.Text); PropertiesListBoxControl.Items.Add(newProperty); if (_register.Properties == null) { _register.Properties = new List <dynamic>(); } dynamic newRegisterProperty = new DynamicWrapper(); newRegisterProperty.Property = newProperty.Name; newRegisterProperty.Type = newProperty.Type; _register.Properties.Add(newRegisterProperty); // Обновляем схему документа, связанного с регистром if (_documentSchema == null) { _documentSchema = ViewModelExtension.GetRegisterDocumentSchema(Version(), ConfigId(), _register.Name); } if (_documentSchema == null) { var proc = new StatusProcess(); proc.StartOperation( delegate { _register.DocumentId = ViewModelExtension.CreateRegisterDocuments(Version(), ConfigId(), _register.Name); }); proc.EndOperation(); _documentSchema = ViewModelExtension.GetRegisterDocumentSchema(Version(), ConfigId(), _register.Name); } _documentSchema.Properties[newProperty.Name] = new { Type = DataTypeComboBoxEdit.Text }.ToDynamic(); var process = new StatusProcess(); process.StartOperation( () => ViewModelExtension.UpdateRegisterDocumentSchema(Version(), ConfigId(), _register.Name, _documentSchema)); process.EndOperation(); // Обновляем схему документа, рассчитываеющего промежуточные итоги по регистру // (поля реквизиты добавлять в схему итогов не нужно) if (newProperty.Type != RegisterPropertyType.Info) { if (_documentTotalSchema == null) { _documentTotalSchema = ViewModelExtension.GetRegisterDocumentTotalSchema(Version(), ConfigId(), _register.Name); } _documentTotalSchema.Properties[newProperty.Name] = new { Type = DataTypeComboBoxEdit.Text }.ToDynamic(); process = new StatusProcess(); process.StartOperation( () => ViewModelExtension.UpdateRegisterDocumentTotalSchema(Version(), ConfigId(), _register.Name, _documentTotalSchema)); process.EndOperation(); } if (OnValueChanged != null) { OnValueChanged(_register, new EventArgs()); } PropertyNameTextEdit.Text = string.Empty; }
private void ConfigVerifyDesignerView_Load(object sender, EventArgs e) { MigrationsComboBox.Properties.Items.AddRange(ViewModelExtension.BuildMigrations()); VerificationsComboBox.Properties.Items.AddRange(ViewModelExtension.BuildVerifications()); }
/// <summary> /// Удаление свойства регистра /// </summary> private void DeletePropertyButton_Click(object sender, EventArgs e) { if (PropertiesListBoxControl.SelectedIndex > -1) { DeletePropertyButton.Enabled = true; var propertyToDelete = (RegisterProperty)PropertiesListBoxControl.SelectedItem; var propertiesArray = new List <dynamic>(); if (_register.Properties != null) { foreach (var property in _register.Properties) { if (property.Property != null && property.Property.ToString() != propertyToDelete.Name) { propertiesArray.Add(property); } } } _register.Properties = propertiesArray; if (OnValueChanged != null) { OnValueChanged(_register, new EventArgs()); } if (_documentSchema == null) { _documentSchema = ViewModelExtension.GetRegisterDocumentSchema(Version(), ConfigId(), _register.Name); } _documentSchema.Properties[propertyToDelete.Name] = null; var process = new StatusProcess(); process.StartOperation( () => ViewModelExtension.UpdateRegisterDocumentSchema(Version(), ConfigId(), _register.Name, _documentSchema)); process.EndOperation(); // Обновляем схему документа, рассчитываеющего промежуточные итоги по регистру // (поля реквизиты добавлять в схему итогов не нужно) if (propertyToDelete.Type != RegisterPropertyType.Info) { if (_documentTotalSchema == null) { _documentTotalSchema = ViewModelExtension.GetRegisterDocumentTotalSchema(Version(), ConfigId(), _register.Name); } _documentTotalSchema.Properties[propertyToDelete.Name] = null; process = new StatusProcess(); process.StartOperation( () => ViewModelExtension.UpdateRegisterDocumentTotalSchema(Version(), ConfigId(), _register.Name, _documentTotalSchema)); process.EndOperation(); } PropertiesListBoxControl.Items.Remove(propertyToDelete); } else { MessageBox.Show("Specify property"); } }