Пример #1
0
        public virtual void SubmitFormProperty(IVariableScope variableScope, IVariableMap variables)
        {
            if (!IsWritable && variables.ContainsKey(id))
            {
                throw new ProcessEngineException("form property '" + id + "' is not writable");
            }

            if (IsRequired && !variables.ContainsKey(id) && (defaultExpression == null))
            {
                throw new ProcessEngineException("form property '" + id + "' is required");
            }

            object modelValue = null;

            if (variables.ContainsKey(id))
            {
                //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
                //ORIGINAL LINE: final Object propertyValue = variables.remove(id);
                object propertyValue = variables.Remove(id);
                if (Type != null)
                {
                    modelValue = Type.ConvertFormValueToModelValue(propertyValue);
                }
                else
                {
                    modelValue = propertyValue;
                }
            }
            else if (defaultExpression != null)
            {
                //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
                //ORIGINAL LINE: final Object expressionValue = defaultExpression.getValue(variableScope);
                //var expressionValue = defaultExpression.GetValue(variableScope);
                //if ((Type != null) && (expressionValue != null))
                //    modelValue = Type.ConvertFormValueToModelValue(expressionValue.ToString());
                //else if (expressionValue != null)
                //    modelValue = expressionValue.ToString();
                //else if (IsRequired)
                //    throw new ProcessEngineException("form property '" + id + "' is required");
            }

            //if (modelValue != null)
            //    if (!ReferenceEquals(variableName, null))
            //        variableScope.SetVariable(variableName, modelValue);
            //    else if (variableExpression != null)
            //        variableExpression.SetValue(modelValue, variableScope);
            //    else
            //        variableScope.SetVariable(id, modelValue);
        }
Пример #2
0
        private void checkVariables(IVariableMap map, int expectedSize)
        {
            var variables = engineRule.HistoryService.CreateHistoricVariableInstanceQuery()
                            /*.OrderByVariableName()*/
                            /*.Asc()*/

                            .ToList();

            Assert.AreEqual(expectedSize, variables.Count);

            Assert.AreEqual(variables.Count, map.Count);
            foreach (var instance in variables)
            {
                Assert.True(map.ContainsKey(instance.Name));
                var instanceValue = instance.TypedValue.Value;
                var mapValue      = map.GetValueTyped <ITypedValue>(instance.Name)
                                    .Value;
                if (instanceValue == null)
                {
                    Assert.IsNull(mapValue);
                }
                else if (instanceValue is byte[])
                {
                    Assert.Equals((byte[])instanceValue, (byte[])mapValue);
                }
                else
                {
                    Assert.AreEqual(instanceValue, mapValue);
                }
            }
        }