Exemple #1
0
        public bool Add(Program model)
        {
            var programId = (from u in _programRepository.Table
                             where u.ParentID == model.ParentID
                             select u.ProgramID).DefaultIfEmpty().Max();

            model.ProgramID = programId == 0 ? 1000 * model.ParentID + 1 : programId + 1;
            return(ServiceExtensions.Add(this, model));
        }
Exemple #2
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="strLan"></param>
        /// <returns></returns>
        public List <GlobalResources> GetList(string strLan)
        {
            ICacheManager _cacheManager = IocObjectManager.GetInstance().Resolve <IHttpContextCacheManager>();
            var           resources     = _cacheManager.Get("GlobalResourcesByLan", 60, () =>
            {
                return(_globalResourcesRepository.Table.OrderBy(m => m.Lanuage).ToList().ToDictionaryWithMultipleKey(m => { return m.Lanuage; }, true));
            }, () =>
            {
                return(ServiceExtensions.FromIoc <IVersionControlService>().GetVersionFlag("GlobalResourcesByLan"));
            });

            return(resources[strLan]);
        }
Exemple #3
0
        public GlobalResourcesService(IRepository <GlobalResources> globalResourcesRepository, ICacheManager cacheManager)
        {
            _globalResourcesRepository = globalResourcesRepository;
            _cacheManager = cacheManager;

            _resourcesDic = _cacheManager.Get("GlobalResources", 60, () =>
            {
                var list = _globalResourcesRepository.Table.OrderBy(m => m.Name).ThenBy(m => m.Lanuage).ToList();
                SortedDictionary <string, string> resourcesDic = new SortedDictionary <string, string>();
                foreach (var item in list)
                {
                    resourcesDic.Add(item.Name + "_" + item.Lanuage, item.Value);
                }

                return(resourcesDic);
            }, () =>
            {
                return(ServiceExtensions.FromIoc <IVersionControlService>().GetVersionFlag("GlobalResources"));
            });
        }