示例#1
0
        /// <summary>
        /// 获取一个对象,自动从服务器获取并更新到缓存
        /// </summary>
        /// <param name="name">名称</param>
        /// <param name="method">从服务器获取对象的方法</param>
        /// <returns>存在则返回缓存,不存在则返回服务器对象</returns>
        public static object GetUpdate(string name, GetDataMethod method)
        {
            var obj = method();

            Add(name, obj);
            return(obj);
        }
示例#2
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="labelName">标签名称</param>
 /// <param name="getDataMethod">取值方法</param>
 /// <param name="configValue">配置值</param>
 /// <param name="dataSource">数据源名称</param>
 /// <param name="fieldName">字段名称</param>
 /// <param name="formatInfo">格式化类</param>
 public TextLabel(string labelName, GetDataMethod getDataMethod, string configValue, DataSource dataSource, string fieldName, FormatInfo formatInfo)
 {
     this.IsInput       = false;
     this.LabelName     = labelName;
     this.GetDataMethod = getDataMethod;
     this.ConfigValue   = configValue;
     this.dataSource    = dataSource;
     this.FieldName     = fieldName;
     this.FormatInfo    = formatInfo;
 }
示例#3
0
        /// <summary>
        /// 获取一个对象,自动从缓存服务器获取
        /// </summary>
        /// <param name="name">名称</param>
        /// <param name="method">从服务器获取对象的方法</param>
        /// <returns>存在则返回缓存,不存在则返回服务器对象</returns>
        public static object GetAuto(string name, GetDataMethod method)
        {
            if (Contains(name))
            {
                return(Cache[name]);
            }
            var obj = method();

            Add(name, obj);
            return(obj);
        }
示例#4
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="labelName">标签名称</param>
        /// <param name="labelConfig">配置信息</param>
        /// <param name="docTemplateType">模板类型</param>
        public DocLabel(string labelName, JToken labelConfig, DocMaster docMaster)
        {
            this.docMaster = docMaster;
            JObject config         = (JObject)labelConfig["Config"];
            string  dataSourceName = string.Empty;

            this.LabelName     = labelName;
            this.getDataMethod = (GetDataMethod)Enum.Parse(typeof(GetDataMethod), config["GetDataMethod"].Value <string>());
            if (config["DataSourceName"] != null)
            {
                dataSourceName  = config["DataSourceName"].Value <string>();
                this.dataSource = this.docMaster.DocTemplateType.DataSourceList.FirstOrDefault(t => t.DataSourceName == dataSourceName);
            }

            if (config["DocName"] != null)
            {
                this.docName = config["DocName"].Value <string>();
            }

            if (config["FileID"] != null)
            {
                this.fileID = config["FileID"].Value <decimal>();
            }

            if (config["FieldName"] != null)
            {
                this.fieldName = config["FieldName"].Value <string>();
            }

            if (config["FilterFieldName"] != null)
            {
                this.filterFieldName = config["FilterFieldName"].Value <string>();
            }

            if (config["FilterOperation"] != null)
            {
                this.filterOperation = config["FilterOperation"].Value <string>();
            }

            if (config["FilterValue"] != null)
            {
                this.filterValue = config["FilterValue"].Value <string>();
            }
        }
示例#5
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="labelName">标签名称</param>
 /// <param name="docName">文档名称</param>
 /// <param name="fileID">文件ID</param>
 /// <param name="getDataMethod">获取数据方法</param>
 /// <param name="dataSource">数据源</param>
 /// <param name="fieldName">字段名称</param>
 /// <param name="filterFieldName">过滤字段名称</param>
 /// <param name="filterOperation">过滤字段操作符</param>
 /// <param name="filterValue">过滤字段使用值</param>
 public DocLabel(
     string labelName,
     string docName,
     decimal fileID,
     GetDataMethod getDataMethod,
     DataSource dataSource,
     string fieldName,
     string filterFieldName,
     string filterOperation,
     string filterValue)
 {
     this.LabelName       = labelName;
     this.docName         = docName;
     this.fileID          = fileID;
     this.getDataMethod   = getDataMethod;
     this.dataSource      = dataSource;
     this.fieldName       = fieldName;
     this.filterFieldName = filterFieldName;
     this.filterOperation = filterOperation;
     this.filterValue     = filterValue;
 }
示例#6
0
 public TextLabelInfo(decimal id, StructureType structureType, string structureName, string labelName, string fieldName, string defaultValue, List <RelateItem> relate, FormatInfo format, BaseControl contorl, GetDataMethod getDataMethod
                      , string dataSourceName, string configValue, string filterFieldName, string filterOperation, string filterValue)
 {
     this.ID            = id;
     this.StructureType = structureType;
     this.LabelName     = labelName;
     this.FieldName     = fieldName;
     this.DefaultValue  = defaultValue;
     this.Relate        = relate;
     if (format != null)//format.ValueField, format.TextField,
     {
         this.Format = new FormatItem(format.DecimalCount, format.Dividend, format.DateFormatString, format.IsUpperDate);
     }
     this.Control         = contorl;
     GetDataMethod_Name   = EnumHelper.GetEnumDescription(getDataMethod);
     this.DataSourceName  = dataSourceName;
     this.ConifgValue     = configValue;
     this.FilterFieldName = filterFieldName;
     this.FilterOperation = filterOperation;
     this.FilterValue     = filterValue;
     this.GetDataMethod   = getDataMethod;
     this.StructureName   = structureName;
 }
示例#7
0
        /// <summary>
        /// 添加一个缓存,自动从服务器获取
        /// </summary>
        /// <param name="name">名称</param>
        /// <param name="method">从服务器获取对象的方法</param>
        /// <returns>存在则返回缓存,不存在则返回服务器对象</returns>
        public static void AddAuto(string name, GetDataMethod method)
        {
            var obj = method();

            Add(name, obj);
        }