Пример #1
0
        public static bool IsEmpty(dynamic value)
        {
            var result = true;

            if (value != null)
            {
                var valueAsString = value.ToString();

                if (!string.IsNullOrEmpty(valueAsString))
                {
                    var valueAsDynamic = DynamicWrapperExtensions.ToDynamic(value);

                    if (valueAsDynamic != null)
                    {
                        foreach (var property in valueAsDynamic)
                        {
                            result = false;
                            break;
                        }
                    }
                }
            }

            return(result);
        }
Пример #2
0
        private void repositoryItemButtonEdit_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            if (e.Button.Kind == ButtonPredefines.Delete)
            {
                ((BaseEdit)sender).EditValue = new DynamicWrapper().ToString();
            }
            else if (e.Button.Kind == ButtonPredefines.Glyph)
            {
                var value = ((BaseEdit)sender).EditValue;
                var form  = new ValueEdit();
                form.Value = value != null?value.ToString() : string.Empty;

                form.ShowDialog();
            }
            else if (e.Button.Kind == ButtonPredefines.Ellipsis)
            {
                var instance = _dataSource.ToArray()[PropertiesView.FocusedRowHandle];
                CollectionProperty property = _rows[instance];

                //если разбираем свойство являющееся объектом
                var valueProperty = property.Properties[PropertiesView.FocusedColumn.FieldName] as ObjectProperty;


                dynamic propertyValue = null;
                try
                {
                    propertyValue =
                        DynamicWrapperExtensions.ToDynamic(
                            (string)
                            ObjectHelper.GetProperty(instance, PropertiesView.FocusedColumn.FieldName).ToString());
                    DesignerExtensions.SetSimplePropertiesFromInstance(valueProperty.SimpleProperties, propertyValue);
                    DesignerExtensions.SetCollectionPropertiesFromInstance(valueProperty.CollectionProperties,
                                                                           propertyValue);
                }
                catch (Exception)
                {
                    propertyValue =
                        DynamicWrapperExtensions.ToDynamicList(
                            (string)
                            ObjectHelper.GetProperty(instance, PropertiesView.FocusedColumn.FieldName).ToString());
                }


                if (valueProperty != null)
                {
                    SelectObjectProperty(sender, valueProperty);
                }

                var collectionProperty =
                    property.Properties[PropertiesView.FocusedColumn.FieldName] as CollectionProperty;

                if (collectionProperty != null)
                {
                    SelectCollectionProperty(sender, collectionProperty);
                }
            }
        }
        private void CreateButton_Click(object sender, EventArgs e)
        {
            if (NameEditor.EditValue == null)
            {
                MessageBox.Show("Необходимо указать наименование");
                return;
            }

            if (ComboBoxSelectViewType.EditValue == null)
            {
                MessageBox.Show("Необходимо указать тип представления");
                return;
            }



            dynamic viewByString = null;

            if (MetadataGeneratorSelect.EditValue != null)
            {
                dynamic item = MetadataGeneratorSelect.EditValue;
                viewByString = CreateGeneratedView(item.DocumentId, item.Name, ComboBoxSelectViewType.EditValue.ToString());
            }

            _view = viewByString != null?DynamicWrapperExtensions.ToDynamic((string)viewByString) : new DynamicWrapper();

            _view.Id      = Guid.NewGuid().ToString();
            _view.Name    = NameEditor.EditValue.ToString();
            _view.Caption = CaptionEditor.EditValue != null?CaptionEditor.EditValue.ToString() : "";

            _view.Description = DescriptionEditor.EditValue != null?DescriptionEditor.EditValue.ToString() : "";

            _view.MetadataType = ComboBoxSelectViewType.EditValue;

            MessageBox.Show("View metadata created successfully.");

            OnValueChanged(_view, new EventArgs());
        }
        private void RefreshBindings()
        {
            if (_process == null)
            {
                return;
            }
            //ищем схему предзаполнения документа
            if (_process.Transitions != null && _process.Transitions.Count > 0)
            {
                var schemaPrefillString = _process.Transitions[0].SchemaPrefill;
                if (schemaPrefillString != null)
                {
                    _schemaPrefill = DynamicWrapperExtensions.ToDynamic(JObject.Parse(schemaPrefillString));
                }


                if (_process.Transitions[0].ComplexPrefill != null)
                {
                    ComplexPrefillEditor.EditValue = ComplexPrefillEditor.Properties.Items.Cast <ImageComboBoxItem>()
                                                     .FirstOrDefault(i => _process.Transitions[0].ComplexPrefill.ScenarioId == ((dynamic)i.Value).HandlerId);
                }
                if (_process.Transitions[0].ValidationPointError != null)
                {
                    ComplexValidationErrorEditor.EditValue = ComplexValidationErrorEditor.Properties.Items.Cast <ImageComboBoxItem>()
                                                             .FirstOrDefault(
                        i => _process.Transitions[0].ValidationPointError.ScenarioId == ((dynamic)i.Value).HandlerId);
                }

                if (_process.Transitions[0].ValidationPointWarning != null)
                {
                    ComplexValidationWarningEditor.EditValue = ComplexValidationWarningEditor.Properties.Items.Cast <ImageComboBoxItem>()
                                                               .FirstOrDefault(
                        i => _process.Transitions[0].ValidationPointWarning.ScenarioId == ((dynamic)i.Value).HandlerId);
                }

                if (_process.Transitions[0].SuccessPoint != null)
                {
                    SuccessSaveEditor.EditValue = SuccessSaveEditor.Properties.Items.Cast <ImageComboBoxItem>().FirstOrDefault(
                        i => _process.Transitions[0].SuccessPoint.ScenarioId == ((dynamic)i.Value).HandlerId);
                }

                if (_process.Transitions[0].FailPoint != null)
                {
                    FailSaveEditor.EditValue = FailSaveEditor.Properties.Items.Cast <ImageComboBoxItem>().FirstOrDefault(
                        i => _process.Transitions[0].FailPoint.ScenarioId == ((dynamic)i.Value).HandlerId);
                }

                if (_process.Transitions[0].DeletePoint != null)
                {
                    DeleteDocumentEditor.EditValue = DeleteDocumentEditor.Properties.Items.Cast <ImageComboBoxItem>().FirstOrDefault(
                        i => _process.Transitions[0].DeletePoint.ScenarioId == ((dynamic)i.Value).HandlerId);
                }

                if (_process.Transitions[0].DeletingDocumentValidationPoint != null)
                {
                    DeletingDocumentValidationErrorEditor.EditValue = DeletingDocumentValidationErrorEditor.Properties.Items.Cast <ImageComboBoxItem>().FirstOrDefault(
                        i => _process.Transitions[0].DeletingDocumentValidationPoint.ScenarioId == ((dynamic)i.Value).HandlerId);
                }

                if (_process.Transitions[0].CredentialsPoint != null && _process.Transitions[0].CredentialsType == "CustomCredentials")
                {
                    DefaultProcessCredentialsAction.EditValue = DefaultProcessCredentialsAction.Properties.Items.Cast <ImageComboBoxItem>().FirstOrDefault(
                        i => _process.Transitions[0].CredentialsPoint.ScenarioId == ((dynamic)i.Value).HandlerId);
                }

                DefaultProcessCredentialsType.EditValue = _process.Transitions[0].CredentialsType;

                SimpleValidationErrorEditor.EditValue = _process.Transitions[0].ValidationRuleError;

                DeletingDocumentValidationErrorEditor.EditValue = _process.Transitions[0].DeletingDocumentValidationRuleError;

                SimpleValidationWarningEditor.EditValue = _process.Transitions[0].ValidationRuleWarning;
            }

            //если схема предзаполнения документа не найдена, создаем новую схему
            if (_schemaPrefill == null)
            {
                ReloadSchema();
            }

            FillPropertiesBySchema();

            TextEditProcessName.EditValue    = _process.Name;
            TextEditProcessCaption.EditValue = _process.Caption;
        }
 public dynamic GetLayout()
 {
     return(DynamicWrapperExtensions.ToDynamic((string)_simpleProperties["ControlLayout"].Value.ToString()));
 }