/// <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();
        }
        /// <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();
        }
        /// <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);
        }
Пример #5
0
        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 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");
            }
        }
        /// <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;
        }
Пример #9
0
 /// <summary>
 /// Extracts status information from the server's response.
 /// </summary>
 /// <param name='status'>
 /// The structure to be dissected.
 /// </param>
 internal Status(System.Collections.Generic.IDictionary<string, object> status)
 {
     this.Process = new StatusProcess((System.Collections.Generic.IDictionary<string, object>)status["process"]);
     this.System = new StatusSystem((System.Collections.Generic.IDictionary<string, object>)status["system"]);
 }