Beispiel #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);
        }
 private void CheckOperators(List <dynamic> items)
 {
     for (var i = 0; i < items.Count; i++)
     {
         items[i].Operators = DynamicWrapperExtensions.ToDynamicList(items[i].Operators.ToString());
     }
 }
Beispiel #3
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);
                }
            }
        }
        public dynamic GetLayout()
        {
            dynamic instanceLayout = new DynamicWrapper();

            instanceLayout.Items = DynamicWrapperExtensions.ToDynamicList(_properties["Items"].Value.ToString());

            foreach (var simpleProperty in _properties)
            {
                var objectProperty = simpleProperty.Value as ObjectProperty;

                instanceLayout[simpleProperty.Key] =
                    objectProperty != null ? objectProperty.Value : simpleProperty.Value.Value;
            }


            return(instanceLayout);
        }
Beispiel #5
0
        private List <dynamic> ConvertDataSourceToDataTable(IEnumerable <dynamic> items)
        {
            //из-за того, что для Grid используется DataTable( грид не может показывать динамические объекты)
            //приходится выполнять обратное преобразование при возврате элементов коллекции
            var result = new List <dynamic>();

            foreach (var o in items)
            {
                dynamic instance = new DynamicWrapper();
                _rows.Add(instance, _collectionProperty.Clone(true));


                foreach (var property in _rows[instance].Properties)
                {
                    var objectProperty = property.Value as ObjectProperty;
                    if (objectProperty != null)
                    {
                        var propertyValue = ObjectHelper.GetProperty(o, property.Key) ?? new DynamicWrapper();
                        throw new ArgumentException("Необходим рефакторинг");
                        //objectProperty.SimpleProperties.SetSimplePropertiesFromInstance(propertyValue);
                        //objectProperty.CollectionProperties.SetCollectionPropertiesFromInstance(propertyValue);

                        instance[property.Key] = propertyValue;
                        continue;
                    }


                    var collectionProperty = property.Value as CollectionProperty;
                    if (collectionProperty != null)
                    {
                        var arr =
                            DynamicWrapperExtensions.ToDynamicList(ObjectHelper.GetProperty(o, property.Key).ToString());
                        collectionProperty.Items = arr.ToList();
                        instance[property.Key]   = ObjectHelper.GetProperty(o, property.Key).ToString();
                    }
                    else
                    {
                        instance[property.Key] = ObjectHelper.GetProperty(o, property.Key);
                    }
                }
                result.Add(instance);
            }
            return(result);
        }
        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()));
 }