public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
		{
			PropertyDefine pd = new PropertyDefine();

			pd.Name = DictionaryHelper.GetValue(dictionary, "name", string.Empty);
			pd.DisplayName = DictionaryHelper.GetValue(dictionary, "displayName", string.Empty);
			pd.Category = DictionaryHelper.GetValue(dictionary, "category", string.Empty);
			pd.DefaultValue = DictionaryHelper.GetValue(dictionary, "defaultValue", string.Empty);
			pd.DataType = DictionaryHelper.GetValue(dictionary, "dataType", PropertyDataType.String);
			pd.Description = DictionaryHelper.GetValue(dictionary, "description", string.Empty);
			pd.ReadOnly = DictionaryHelper.GetValue(dictionary, "readOnly", false);
			pd.Visible = DictionaryHelper.GetValue(dictionary, "visible", true);
			pd.EditorKey = DictionaryHelper.GetValue(dictionary, "editorKey", string.Empty);
			pd.PersisterKey = DictionaryHelper.GetValue(dictionary, "persisterKey", string.Empty);
            pd.EditorParamsSettingsKey = DictionaryHelper.GetValue(dictionary, "editorParamsSettingsKey", string.Empty);
            pd.EditorParams = DictionaryHelper.GetValue(dictionary, "editorParams", string.Empty);
			pd.SortOrder = DictionaryHelper.GetValue(dictionary, "sortOrder", 0xFFFF);
			pd.MaxLength = DictionaryHelper.GetValue(dictionary, "maxLength", 0xFFFF);
			pd.IsRequired = DictionaryHelper.GetValue(dictionary, "isRequired", false);
            pd.ShowTitle = DictionaryHelper.GetValue(dictionary, "showTitle", true);

			if (dictionary.ContainsKey("validators") == true)
			{
				PropertyValidatorDescriptorCollection validators = JSONSerializerExecute.Deserialize<PropertyValidatorDescriptorCollection>(dictionary["validators"]);
				pd.Validators.Clear();
				pd.Validators.CopyFrom(validators);
			}

			PropertyValue pv = new PropertyValue(pd);

			pv.StringValue = DictionaryHelper.GetValue(dictionary, "value", (string)null);

			return pv;
		}
예제 #2
0
        public Column(PropertyInfo property, PropertyDefine propertyDefine)
        {
            Property       = property;
            PropertyDefine = propertyDefine;

            if (DataType.FullName != DataTypeNames.String && propertyDefine.Length > 0)
            {
                throw new SpiderException("Only string property can set length.");
            }
            DefaultValue = Property.PropertyType.IsValueType ? Activator.CreateInstance(Property.PropertyType) : null;
            Option       = propertyDefine.Option;
            Selector     = new BaseSelector
            {
                Expression = propertyDefine.Expression,
                Type       = propertyDefine.Type,
                Argument   = propertyDefine.Argument
            };
            NotNull     = propertyDefine.NotNull;
            IgnoreStore = propertyDefine.IgnoreStore;
            Length      = propertyDefine.Length;

            foreach (var formatter in property.GetCustomAttributes <Formatter.Formatter>(true))
            {
                Formatters.Add(formatter);
            }
        }
예제 #3
0
        public Column(PropertyInfo property, PropertyDefine propertyDefine)
        {
            Property       = property;
            PropertyDefine = propertyDefine;

            var type = Property.PropertyType;

            if (DataType.FullName != DataTypeNames.String && propertyDefine.Length > 0)
            {
                throw new SpiderException("Only string property can set length.");
            }

            Multi    = typeof(IList).IsAssignableFrom(type);
            Option   = propertyDefine.Option;
            Selector = new BaseSelector
            {
                Expression = propertyDefine.Expression,
                Type       = propertyDefine.Type,
                Argument   = propertyDefine.Argument
            };
            NotNull     = propertyDefine.NotNull;
            IgnoreStore = propertyDefine.IgnoreStore;
            Length      = propertyDefine.Length;

            foreach (var formatter in property.GetCustomAttributes <Formatter.Formatter>(true))
            {
                Formatters.Add(formatter);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="newActDesp"></param>
        /// <param name="createParams"></param>
        private static void AdjustActivityDescriptorProperties(WfActivityDescriptor newActDesp, WfActivityDescriptorCreateParams createParams)
        {
            newActDesp.Name = createParams.Name;

            if (createParams.Variables != null)
            {
                foreach (WfVariableDescriptor variable in createParams.Variables)
                {
                    if (newActDesp.Properties.ContainsKey(variable.Key) == false)
                    {
                        PropertyDefine pd = new PropertyDefine();

                        pd.Name         = variable.Key;
                        pd.DataType     = PropertyDataType.Boolean;
                        pd.DefaultValue = variable.OriginalValue;

                        newActDesp.Properties.Add(new PropertyValue(pd));
                    }

                    newActDesp.Properties.SetValue(variable.Key, variable.ActualValue);
                }
            }

            if (createParams.Users != null)
            {
                newActDesp.Resources.Clear();
                createParams.Users.ForEach(u => newActDesp.Resources.Add(new WfUserResourceDescriptor(u)));
            }

            if (createParams.CirculateUsers != null)
            {
                newActDesp.EnterEventReceivers.Clear();
                createParams.CirculateUsers.ForEach(u => newActDesp.EnterEventReceivers.Add(new WfUserResourceDescriptor(u)));
            }

            newActDesp.BranchProcessTemplates.Clear();

            if (createParams.AllAgreeWhenConsign && newActDesp.Resources.Count > 1)
            {
                newActDesp.Properties.SetValue("AutoMoveAfterPending", true);

                if (newActDesp.BranchProcessTemplates.ContainsKey(WfTemplateBuilder.AutoStartSubProcessTemplateKey))
                {
                    newActDesp.BranchProcessTemplates.Remove(t => t.Key == WfTemplateBuilder.AutoStartSubProcessTemplateKey);
                }

                WfBranchProcessTemplateDescriptor template = new WfBranchProcessTemplateDescriptor(WfTemplateBuilder.AutoStartSubProcessTemplateKey);

                template.BranchProcessKey = WfProcessDescriptorManager.DefaultConsignProcessKey;
                template.ExecuteSequence  = WfBranchProcessExecuteSequence.Parallel;
                template.BlockingType     = WfBranchProcessBlockingType.WaitAllBranchProcessesComplete;

                template.Resources.CopyFrom(newActDesp.Resources);

                newActDesp.BranchProcessTemplates.Add(template);
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="newActDesp"></param>
        /// <param name="createParams"></param>
        private static void AdjustActivityDescriptorProperties(WfActivityDescriptor newActDesp, WfActivityDescriptorCreateParams createParams)
        {
            newActDesp.Name = createParams.Name;

            if (createParams.Variables != null)
            {
                foreach (WfVariableDescriptor variable in createParams.Variables)
                {
                    if (newActDesp.Properties.ContainsKey(variable.Key) == false)
                    {
                        PropertyDefine pd = new PropertyDefine();

                        pd.Name = variable.Key;
                        pd.DataType = PropertyDataType.Boolean;
                        pd.DefaultValue = variable.OriginalValue;

                        newActDesp.Properties.Add(new PropertyValue(pd));
                    }

                    newActDesp.Properties.SetValue(variable.Key, variable.ActualValue);
                }
            }

            if (createParams.Users != null)
            {
                newActDesp.Resources.Clear();
                createParams.Users.ForEach(u => newActDesp.Resources.Add(new WfUserResourceDescriptor(u)));
            }

            if (createParams.CirculateUsers != null)
            {
                newActDesp.EnterEventReceivers.Clear();
                createParams.CirculateUsers.ForEach(u => newActDesp.EnterEventReceivers.Add(new WfUserResourceDescriptor(u)));
            }

            newActDesp.BranchProcessTemplates.Clear();

            if (createParams.AllAgreeWhenConsign && newActDesp.Resources.Count > 1)
            {
                newActDesp.Properties.SetValue("AutoMoveAfterPending", true);

				if (newActDesp.BranchProcessTemplates.ContainsKey(WfTemplateBuilder.AutoStartSubProcessTemplateKey))
					newActDesp.BranchProcessTemplates.Remove(t => t.Key == WfTemplateBuilder.AutoStartSubProcessTemplateKey);

				WfBranchProcessTemplateDescriptor template = new WfBranchProcessTemplateDescriptor(WfTemplateBuilder.AutoStartSubProcessTemplateKey);

                template.BranchProcessKey = WfProcessDescriptorManager.DefaultConsignProcessKey;
                template.ExecuteSequence = WfBranchProcessExecuteSequence.Parallel;
                template.BlockingType = WfBranchProcessBlockingType.WaitAllBranchProcessesComplete;

                template.Resources.CopyFrom(newActDesp.Resources);

                newActDesp.BranchProcessTemplates.Add(template);
            }
        }
예제 #6
0
        public virtual void SetControlsPropertyDefineFromEditorParams(PropertyDefine propertyDefine)
        {
            var editorParams = "";

            if (string.IsNullOrEmpty(propertyDefine.EditorParamsSettingsKey) == false)
            {
                var curSettings = PropertyEditorParamsSettings.GetConfig().EditorParams[propertyDefine.EditorParamsSettingsKey];
                if (curSettings == null)
                {
                    throw new System.Configuration.ConfigurationErrorsException(string.Format("找不到Name为{0}的EditorParamsSettings", propertyDefine.EditorParamsSettingsKey));
                }

                editorParams = curSettings.EditorParamsValue.ValueText;
            }
            else if (string.IsNullOrEmpty(propertyDefine.EditorParams) && Regex.IsMatch(propertyDefine.EditorParams, @"\{[^{}]*}") == true)
            {
                editorParams = propertyDefine.EditorParams;
            }

            if (string.IsNullOrEmpty(editorParams) == false)
            {
                EditorParamsDefine paraDefine = JSONSerializerExecute.Deserialize <EditorParamsDefine>(editorParams);

                if (paraDefine.ServerControlProperties.Count > 0)
                {
                    if (string.IsNullOrEmpty(paraDefine.CloneControlID))
                    {
                        paraDefine.CloneControlID = this.DefaultCloneControlName();
                    }

                    if (this.IsCloneControlEditor)
                    {
                        if (this.ControlsPropertyDefine.ContainsKey(paraDefine.CloneControlID))
                        {
                            this.ControlsPropertyDefine[paraDefine.CloneControlID].ControlPropertyDefineList = paraDefine.ServerControlProperties;
                            this.ControlsPropertyDefine[paraDefine.CloneControlID].ExtendedSettings          = paraDefine.ExtendedSettings;
                            this.ControlsPropertyDefine[paraDefine.CloneControlID].UseTemplate = paraDefine.UseTemplate;
                        }
                        else
                        {
                            this.ControlsPropertyDefine.Add(new ControlPropertyDefineWrapper()
                            {
                                ControlID = paraDefine.CloneControlID, ControlPropertyDefineList = paraDefine.ServerControlProperties, ExtendedSettings = paraDefine.ExtendedSettings, UseTemplate = paraDefine.UseTemplate
                            });
                        }
                    }
                }

                if (string.IsNullOrEmpty(paraDefine.ExtendedSettings) == false)
                {
                    paraDefine.ExtendedSettings = null;
                    propertyDefine.EditorParams = JSONSerializerExecute.Serialize(paraDefine);
                }
            }
        }
        public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            PropertyDefine pd = new PropertyDefine();

            pd.Name = DictionaryHelper.GetValue(dictionary, "name", string.Empty);

            PropertyValue pv = new PropertyValue(pd);

            pv.StringValue = DictionaryHelper.GetValue(dictionary, "value", (string)null);

            return pv;
        }
예제 #8
0
        public virtual void SetControlsPropertyDefineFromEditorParams(PropertyDefine propertyDefine)
        {
            var editorParams = "";

            if (string.IsNullOrEmpty(propertyDefine.EditorParamsSettingsKey) == false)
            {
                var curSettings = PropertyEditorParamsSettings.GetConfig().EditorParams[propertyDefine.EditorParamsSettingsKey];
                if (curSettings == null)
                    throw new System.Configuration.ConfigurationErrorsException(string.Format("找不到Name为{0}的EditorParamsSettings", propertyDefine.EditorParamsSettingsKey));

                editorParams = curSettings.EditorParamsValue.ValueText;


            }
            else if (string.IsNullOrEmpty(propertyDefine.EditorParams) && Regex.IsMatch(propertyDefine.EditorParams, @"\{[^{}]*}") == true)
            {
                editorParams = propertyDefine.EditorParams;
            }

            if (string.IsNullOrEmpty(editorParams) == false)
            {
                EditorParamsDefine paraDefine = JSONSerializerExecute.Deserialize<EditorParamsDefine>(editorParams);

                if (paraDefine.ServerControlProperties.Count > 0)
                {
                    if (string.IsNullOrEmpty(paraDefine.CloneControlID))
                        paraDefine.CloneControlID = this.DefaultCloneControlName();

                    if (this.IsCloneControlEditor)
                    {
                        if (this.ControlsPropertyDefine.ContainsKey(paraDefine.CloneControlID))
                        {
                            this.ControlsPropertyDefine[paraDefine.CloneControlID].ControlPropertyDefineList = paraDefine.ServerControlProperties;
                            this.ControlsPropertyDefine[paraDefine.CloneControlID].ExtendedSettings = paraDefine.ExtendedSettings;
                            this.ControlsPropertyDefine[paraDefine.CloneControlID].UseTemplate = paraDefine.UseTemplate;
                        }
                        else
                        {
                            this.ControlsPropertyDefine.Add(new ControlPropertyDefineWrapper() { ControlID = paraDefine.CloneControlID, ControlPropertyDefineList = paraDefine.ServerControlProperties, ExtendedSettings = paraDefine.ExtendedSettings, UseTemplate = paraDefine.UseTemplate });
                        }
                    }
                }

                if (string.IsNullOrEmpty(paraDefine.ExtendedSettings) == false)
                {
                    paraDefine.ExtendedSettings = null;
                    propertyDefine.EditorParams = JSONSerializerExecute.Serialize(paraDefine);
                }
            }
        }
예제 #9
0
        public void CopyFromPropertyDefine(PropertyDefine propertyDefine)
        {
            this.ID           = UuidHelper.NewUuidString();
            this.CreateDate   = SNTPClient.AdjustedTime;
            this.Creator      = DeluxeIdentity.CurrentUser;
            this.Name         = propertyDefine.Name;
            this.Length       = propertyDefine.MaxLength;
            this.Description  = propertyDefine.Description;
            this.DefaultValue = propertyDefine.DefaultValue;
            this.Category     = propertyDefine.Category;
            this.DisplayName  = propertyDefine.DisplayName;
            this.SortNo       = propertyDefine.SortOrder;
            this.Visible      = propertyDefine.Visible;
            this.ShowTitle    = propertyDefine.ShowTitle;
            this.IsRequired   = propertyDefine.IsRequired;
            this.MaxLength    = propertyDefine.MaxLength;
            this.ReadOnly     = propertyDefine.ReadOnly;
            this.EditorKey    = propertyDefine.EditorKey;
            this.EditorParams = propertyDefine.EditorParams;

            switch (propertyDefine.DataType)
            {
            case PropertyDataType.String:
                this.FieldType = FieldTypeEnum.String;
                break;

            case PropertyDataType.Integer:
                this.FieldType = FieldTypeEnum.Int;
                break;

            case PropertyDataType.Boolean:
                this.FieldType = FieldTypeEnum.Bool;
                break;

            case PropertyDataType.DateTime:
                this.FieldType = FieldTypeEnum.DateTime;
                break;

            case PropertyDataType.Decimal:
                this.FieldType = FieldTypeEnum.Decimal;
                break;

            default:
                this.FieldType = FieldTypeEnum.String;
                break;
            }

            //add validators
            //propertyDefine.Validators.ForEach(v => {this.Validators.Add(v)});
        }
예제 #10
0
        private static PropertyValue PreparePropertyValue()
        {
            PropertyDefine define = new PropertyDefine();

            define.Category    = "测试";
            define.DataType    = PropertyDataType.String;
            define.Name        = "测试属性";
            define.Description = "测试属性的描述";
            define.Visible     = false;

            PropertyValue pv = new PropertyValue(define);

            pv.StringValue = "你们认识张玲吗?";

            return(pv);
        }
        private static PropertyValueCollection PrepareProperties()
        {
            PropertyValueCollection properties = new PropertyValueCollection();

            PropertyDefine pd1 = new PropertyDefine();

            pd1.Name = "P1";

            properties.Add(new PropertyValue(pd1));

            PropertyDefine pd2 = new PropertyDefine();

            pd2.Name = "P2";

            properties.Add(new PropertyValue(pd2));

            return(properties);
        }
예제 #12
0
        private static PropertyValue PrepareDateTimePropertyValue()
        {
            PropertyDefine define = new PropertyDefine();

            define.Category    = "测试";
            define.DataType    = PropertyDataType.DateTime;
            define.Name        = "测试属性";
            define.Description = "测试属性的描述";
            define.Visible     = false;

            define.Validators.CopyFrom(PropertyValidatorDescriptorTest.PreparePropertyValidatorDescriptorCollection());

            PropertyValue pv = new PropertyValue(define);

            pv.StringValue = DateTime.MinValue.ToString("yyyy-MM-ddTHH:mm:ss");

            return(pv);
        }
예제 #13
0
        public PropertyDefine ToDynamicPropertyDefine()
        {
            PropertyDefine pd = new PropertyDefine();

            pd.Name         = this.Name;
            pd.Description  = this.Description;
            pd.DefaultValue = this.DefaultValue;
            pd.Category     = this.Category;
            pd.DisplayName  = this.DisplayName;
            pd.SortOrder    = this.SortNo;
            pd.Visible      = this.Visible;
            pd.ShowTitle    = this.ShowTitle;
            pd.IsRequired   = this.IsRequired;
            pd.MaxLength    = this.MaxLength;
            pd.ReadOnly     = this.ReadOnly;
            pd.DataType     = this.FieldType.ToPropertyDataType();
            pd.EditorKey    = this.EditorKey;
            pd.EditorParams = this.EditorParams;
            //add validators
            this.Validators.ForEach(v => pd.Validators.Add(v));
            return(pd);
        }
예제 #14
0
        public static void Output(this PropertyDefine property, TextWriter writer, int indent = 0)
        {
            string indentChars = new string('\t', indent);

            writer.WriteLine("{0}Name={1}, Desp={2}, Type={3}, Category={4}",
                             indentChars,
                             property.Name,
                             property.Description,
                             property.DataType,
                             property.Category);

            if (property.Validators.Count > 0)
            {
                indent++;

                WriteLine(writer, "Begin Validators", indent);

                indent++;
                property.Validators.ForEach(p => p.Output(writer, indent));
                indent--;

                WriteLine(writer, "End Validators", indent);
            }
        }
예제 #15
0
        public void PropertyStringEmptyValidatorTest()
        {
            PropertyDefine pd = new PropertyDefine();

            pd.Name = "UserName";

            PropertyValidatorDescriptor pvd = new PropertyValidatorDescriptor();

            pvd.MessageTemplate = "属性UserName不能为空";
            pvd.TypeDescription = "MCS.Library.Validation.StringEmptyValidator, MCS.Library";

            pd.Validators.Add(pvd);

            PropertyValue pv = new PropertyValue(pd);

            ValidationResults results = new ValidationResults();

            pv.Validate(results);

            Console.WriteLine(results);

            Assert.AreEqual(1, results.ResultCount);
            Assert.AreEqual(pvd.MessageTemplate, results.First().Message);
        }
예제 #16
0
        public PropertyValue(PropertyDefine def)
        {
            ExceptionHelper.FalseThrow<ArgumentNullException>(def != null, "def");

            this._Definition = def;
        }
예제 #17
0
        public PropertyValue ToDynamicPropertyValue()
        {
            PropertyDefine pd = this.ToDynamicPropertyDefine();

            return(new PropertyValue(pd));
        }
예제 #18
0
		public void PropertyStringEmptyValidatorTest()
		{
			PropertyDefine pd = new PropertyDefine();

			pd.Name = "UserName";

			PropertyValidatorDescriptor pvd = new PropertyValidatorDescriptor();

			pvd.MessageTemplate = "属性UserName不能为空";
			pvd.TypeDescription = "MCS.Library.Validation.StringEmptyValidator, MCS.Library";

			pd.Validators.Add(pvd);

			PropertyValue pv = new PropertyValue(pd);

			ValidationResults results = new ValidationResults();

			pv.Validate(results);

			Console.WriteLine(results);

			Assert.AreEqual(1, results.ResultCount);
			Assert.AreEqual(pvd.MessageTemplate, results.First().Message);
		}
예제 #19
0
        public static void Output(this PropertyDefineConfigurationElement propertyElem, TextWriter writer, int indent = 0)
        {
            PropertyDefine prop = new PropertyDefine(propertyElem);

            Output(prop, writer, indent);
        }
		private static PropertyValue PrepareDateTimePropertyValue()
		{
			PropertyDefine define = new PropertyDefine();

			define.Category = "测试";
			define.DataType = PropertyDataType.DateTime;
			define.Name = "测试属性";
			define.Description = "测试属性的描述";
			define.Visible = false;

			define.Validators.CopyFrom(PropertyValidatorDescriptorTest.PreparePropertyValidatorDescriptorCollection());

			PropertyValue pv = new PropertyValue(define);

			pv.StringValue = DateTime.MinValue.ToString("yyyy-MM-ddTHH:mm:ss");

			return pv;
		}
		private static PropertyValue PreparePropertyValue()
		{
			PropertyDefine define = new PropertyDefine();

			define.Category = "测试";
			define.DataType = PropertyDataType.String;
			define.Name = "测试属性";
			define.Description = "测试属性的描述";
			define.Visible = false;

			PropertyValue pv = new PropertyValue(define);
			pv.StringValue = "你们认识张玲吗?";

			return pv;
		}
예제 #22
0
        /// <summary>
        /// 为通用的序列化而显示实现接口IXElementSerializable
        /// </summary>
        /// <param name="node"></param>
        /// <param name="context"></param>
        void IXElementSerializable.Deserialize(XElement node, XmlDeserializeContext context)
        {
            this._Definition = new PropertyDefine();
            this._Definition.Deserialize(node, context);

            string sv = node.Attribute("_sv", this._StringValue);

            if (string.IsNullOrEmpty(sv))
                this._StringValue = this._Definition.DefaultValue;
            else
                this._StringValue = sv;
        }
예제 #23
0
        public void Deserialize(XElement node, XmlDeserializeContext context)
        {
            object pv = null;

            int objID = node.Attribute("v", -1);

            if (context.ObjectContext.TryGetValue(objID, out pv) == true)
            {
                this._Definition = ((PropertyValue)pv).Clone().Definition;
            }
            else
            {
                this._Definition = new PropertyDefine();
                this._Definition.Deserialize(node, context);

                objID = node.Attribute("id", -1);
                if (objID > -1)
                {
                    context.ObjectContext.Add(objID, this);
                }
            }

            string sv = node.Attribute("_sv", this._StringValue);

            if (string.IsNullOrEmpty(sv))
                this._StringValue = this._Definition.DefaultValue;
            else
                this._StringValue = sv;
        }
예제 #24
0
		public static void Output(this PropertyDefineConfigurationElement propertyElem, TextWriter writer, int indent = 0)
		{
			PropertyDefine prop = new PropertyDefine(propertyElem);

			Output(prop, writer, indent);
		}