public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var entryToken = (StringBasedDataSourceEntryEntityToken)entityToken;
            var definition = DynamicFormsFacade.GetFormByName(entryToken.FormName);
            var field      = definition.Model.Fields.Get(entryToken.FieldName);
            var dataSource = field.DataSource.ToList();

            dataSource.Remove(dataSource.Get(entryToken.Id));

            var dataSourceAttribute = field.Attributes.OfType <StringBasedDataSourceAttribute>().First();

            field.Attributes.Remove(dataSourceAttribute);

            dataSourceAttribute = new StringBasedDataSourceAttribute(dataSource.Select(itm => itm.Key).ToArray());

            field.Attributes.Add(dataSourceAttribute);

            DynamicFormsFacade.SaveForm(definition);

            new ParentTreeRefresher(flowControllerServicesContainer).PostRefreshMessages(entityToken);

            return(null);
        }
Пример #2
0
        public override void OnFinish(object sender, EventArgs e)
        {
            var dataSourceToken = (DataSourceEntityToken)EntityToken;

            var entryValue = GetBinding <string>("EntryValue");

            var definition  = DynamicFormsFacade.GetFormByName(dataSourceToken.FormName);
            var field       = definition.Model.Fields.Get(dataSourceToken.FieldName);
            var datasSource = field.DataSource.Select(itm => itm.Key).ToList();

            datasSource.Add(entryValue);

            var dataSourceAttribute = field.Attributes.OfType <StringBasedDataSourceAttribute>().First();

            field.Attributes.Remove(dataSourceAttribute);

            dataSourceAttribute = new StringBasedDataSourceAttribute(datasSource.ToArray());

            field.Attributes.Add(dataSourceAttribute);

            DynamicFormsFacade.SaveForm(definition);

            CreateAddNewTreeRefresher(EntityToken).PostRefreshMessages(new StringBasedDataSourceEntryEntityToken(dataSourceToken.FormName, dataSourceToken.FieldName, entryValue));
        }