/// <summary>
		/// 将所提供的字典转换为<see cref="SchemaDefine"/>类型的对象。
		/// </summary>
		/// <param name="dictionary">作为名称/值对存储的属性数据的 <see cref="T:System.Collections.Generic.IDictionary^2"/>  实例。</param>
		/// <param name="type">所生成对象的类型。</param>
		/// <param name="serializer"><see cref="System.Web.Script.Serialization.JavaScriptSerializer"/>实例。</param>
		/// <returns>反序列化的对象。</returns>
		public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
		{
			SchemaDefine schemaDefine = new SchemaDefine();

			schemaDefine.Name = DictionaryHelper.GetValue(dictionary, "name", string.Empty);
			schemaDefine.SnapshotTable = DictionaryHelper.GetValue(dictionary, "snapshotTable", string.Empty);
			schemaDefine.Category = DictionaryHelper.GetValue(dictionary, "category", string.Empty);
			schemaDefine.SortOrder = DictionaryHelper.GetValue(dictionary, "sortOrder", 0xFFFF);

			if (dictionary.ContainsKey("properties"))
			{
				SchemaPropertyDefineCollection properties = JSONSerializerExecute.Deserialize<SchemaPropertyDefineCollection>(dictionary["properties"]);
				schemaDefine.Properties.Clear();
				schemaDefine.Properties.CopyFrom(properties);
			}

			if (dictionary.ContainsKey("tabs"))
			{
				SchemaTabDefineColleciton tabs = JSONSerializerExecute.Deserialize<SchemaTabDefineColleciton>(dictionary["Tabs"]);
				schemaDefine.Tabs.Clear();
				schemaDefine.Tabs.CopyFrom(tabs);
			}

			return schemaDefine;
		}
示例#2
0
        /// <summary>
        /// 将所提供的字典转换为<see cref="SchemaDefine"/>类型的对象。
        /// </summary>
        /// <param name="dictionary">作为名称/值对存储的属性数据的 <see cref="T:System.Collections.Generic.IDictionary^2"/>  实例。</param>
        /// <param name="type">所生成对象的类型。</param>
        /// <param name="serializer"><see cref="System.Web.Script.Serialization.JavaScriptSerializer"/>实例。</param>
        /// <returns>反序列化的对象。</returns>
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            SchemaDefine schemaDefine = new SchemaDefine();

            schemaDefine.Name          = DictionaryHelper.GetValue(dictionary, "name", string.Empty);
            schemaDefine.SnapshotTable = DictionaryHelper.GetValue(dictionary, "snapshotTable", string.Empty);
            schemaDefine.Category      = DictionaryHelper.GetValue(dictionary, "category", string.Empty);
            schemaDefine.SortOrder     = DictionaryHelper.GetValue(dictionary, "sortOrder", 0xFFFF);

            if (dictionary.ContainsKey("properties"))
            {
                SchemaPropertyDefineCollection properties = JSONSerializerExecute.Deserialize <SchemaPropertyDefineCollection>(dictionary["properties"]);
                schemaDefine.Properties.Clear();
                schemaDefine.Properties.CopyFrom(properties);
            }

            if (dictionary.ContainsKey("tabs"))
            {
                SchemaTabDefineColleciton tabs = JSONSerializerExecute.Deserialize <SchemaTabDefineColleciton>(dictionary["Tabs"]);
                schemaDefine.Tabs.Clear();
                schemaDefine.Tabs.CopyFrom(tabs);
            }

            return(schemaDefine);
        }
示例#3
0
        /// <summary>
        /// 从Cache中获取SchemaDefine,如果Cache中不存在则创建一个
        /// </summary>
        /// <param name="schemaType"></param>
        /// <returns></returns>
        public static SchemaDefine GetSchema(string schemaType)
        {
            return((SchemaDefine)SchemaDefineCache.Instance.GetOrAddNewValue(schemaType, (cache, key) =>
            {
                SchemaDefine result = SchemaDefine.Create(schemaType);
                cache.Add(schemaType, result);

                return result;
            }));
        }
示例#4
0
        public static IOguObject ToOguObject(this SCSimpleObject obj)
        {
            OguBase result = null;

            string     category   = SchemaDefine.GetSchemaConfig(obj.SchemaType).Category;
            SchemaType schemaType = SchemaExtensions.SchemaCategoryToOguSchemaType(category);

            if (schemaType != OGUPermission.SchemaType.Unspecified)
            {
                result             = (OguBase)OguBase.CreateWrapperObject(obj.ID, schemaType);
                result.Name        = obj.Name;
                result.DisplayName = obj.DisplayName;
            }

            return(result);
        }
示例#5
0
        /// <summary>
        /// 生成名称/值对的字典。
        /// </summary>
        /// <param name="obj">要序列化的对象。</param>
        /// <param name="serializer">负责序列化的对象</param>
        /// <returns>一个对象,包含表示该对象数据的键/值对。</returns>
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            SchemaDefine schemaDefine = (SchemaDefine)obj;

            IDictionary <string, object> dictionary = new Dictionary <string, object>();

            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "name", schemaDefine.Name);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "snapshotTable", schemaDefine.SnapshotTable);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "category", schemaDefine.Category);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "sortOrder", schemaDefine.SortOrder);

            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "properties", schemaDefine.Properties);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "tabs", schemaDefine.Tabs);

            return(dictionary);
        }
示例#6
0
        public static List <string> SchemaToSqlFields(this SchemaDefine schema, ORMappingItemCollection mapping, params string[] ignoreProperties)
        {
            List <string> result = new List <string>();

            if (schema != null)
            {
                schema.Properties.ForEach(pd =>
                                          pd.SnapshotMode.IfInSnapshot(() =>
                {
                    if (Array.Exists(ignoreProperties, s => s == pd.Name) == false)
                    {
                        result.Add(GetFieldName(mapping, pd));
                    }
                }));

                result.Add("SearchContent");
                result.Add("SchemaType");
            }

            return(result);
        }
 protected override SchemaDefineBase GetSchema(string schemaType)
 {
     return(SchemaDefine.GetSchema(this.SchemaType));
 }
示例#8
0
		private SCAclPermissionCheckException CreateAclException(AUOperationType opType, SchemaDefine schemaInfo, string permissionName)
		{
			string opDesp = EnumItemDescriptionAttribute.GetDescription(opType);

			SCAclPermissionItem permissionInfo = schemaInfo.PermissionSet[permissionName];

			string permissionDesp = string.Empty;

			if (permissionInfo != null)
			{
				permissionDesp = permissionInfo.Description;

				if (permissionDesp.IsNullOrEmpty())
					permissionDesp = permissionInfo.Name;
			}

			return new SCAclPermissionCheckException(string.Format("不能执行\"{0}\"操作,您没有\"{0}\"权限", opDesp, permissionDesp));
		}