예제 #1
0
        /// <summary>
        /// automatically insert label in labels using CultureDev
        /// </summary>
        /// <returns>operation done sucessfully</returns>
        private static bool insertDefaultValue(
            string resourceSet,
            string resourceId,
            string defaultValue,
            ContentEditorProvider.Configuration.EditorTypeEnum textMode)
        {
            bool res = false;
            try
            {
                var man = new LabelsManager();
                var filter = new LabelsFilter();

                filter.ResourceSet = resourceSet;
                filter.ResourceId = resourceId;
                filter.CultureName = Config.CultureDev;

                var l = man.GetByFilter(filter, "");
                if (l.Count == 0)
                {
                    var o1 = new ResLabel();
                    o1.ResourceSet = resourceSet;
                    o1.ResourceId = resourceId;
                    o1.CultureName = Config.CultureDev;
                    o1.Value = defaultValue;
                    o1.Comment = "SYSTEM";
                    o1.TextMode = textMode;

                    //insert default value for current culture
                    man.Insert(o1);

                    Tracer.Log("LabelsProvider.GetLocalizedLabelFromList()>Insert new label["
                        + resourceSet + "|"
                        + resourceId + "|"
                        + o1.CultureName + "|"
                        + o1.TextMode.ToString() + "]=" + defaultValue,
                        TracerItemType.Debug);
                    res = true;
                }
            }
            catch (Exception ex)
            {
                Tracer.Log("LabelsProvider.GetLocalizedLabelFromList()>Insert new label ERR["
                    + resourceSet + "|" + resourceId + "|" + Config.CultureDefault + "]=" + defaultValue
                    + " ERR:" + ex.ToString(),
                    TracerItemType.Error);
            }
            return res;
        }
예제 #2
0
        public static List<ResLabel> GetLabelsByResourceSet(string resourceSet)
        {
            var result = new List<ResLabel>();

            var cache = new CacheManager<List<ResLabel>>(CacheKeyPrefix);
            if (cache.IsEmpty(resourceSet))
            {
                var man = new LabelsManager();
                var filter = new LabelsFilter();
                filter.ResourceSet = resourceSet;
                result = man.GetByFilter(filter, "");

                cache.Insert(resourceSet, result);
            }
            else
            {
                result = cache.GetValue(resourceSet);
            }
            return result;
        }
예제 #3
0
        private static List<ResLabel> getLabelsByResourceId(string resourceSet, string resourceId)
        {
            var result = new List<ResLabel>();

            var cache = new CacheManager<List<ResLabel>>(CacheKeyPrefix);
            string key = resourceSet + "_" + resourceId;
            if (cache.IsEmpty(key))
            {
                var man = new LabelsManager();
                var filter = new LabelsFilter();
                filter.ResourceSet = resourceSet;
                filter.ResourceId = resourceId;
                result = man.GetByFilter(filter, "");

                cache.Insert(key, result);
            }
            else
            {
                result = cache.GetValue(key);
            }
            return result;
        }