Exemplo n.º 1
0
 /// <summary>
 /// 保存电表日报表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="ammeDailyEntity">电表日报实体</param>
 /// <returns></returns>
 public void SaveAmmeDailyForm(string keyValue, AmmeDailyEntity ammeDailyEntity)
 {
     try
     {
         service.SaveAmmeDailyForm(keyValue, ammeDailyEntity);
         CacheFactory.Cache().RemoveCache(cacheKey);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 保存岗位表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="postEntity">岗位实体</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, RoleEntity postEntity)
 {
     try
     {
         service.SaveForm(keyValue, postEntity);
         CacheFactory.Cache().RemoveCache(cacheKey);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 删除岗位
 /// </summary>
 /// <param name="keyValue">主键</param>
 public void RemoveForm(string keyValue)
 {
     try
     {
         service.RemoveForm(keyValue);
         CacheFactory.Cache().RemoveCache(cacheKey);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 修改用户登录密码
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="Password">新密码(MD5 小写)</param>
 public void RevisePassword(string keyValue, string Password)
 {
     try
     {
         service.RevisePassword(keyValue, Password);
         CacheFactory.Cache().RemoveCache(cacheKey);
     }
     catch (Exception)
     {
         throw;
     }
 }
        /// <summary>
        /// 移除车辆识别后自动抬杆放行权限
        /// </summary>
        /// <param name="CarNo"></param>
        public void RemoveCarpermission(string CarNo)
        {
            #region  除车辆进出权限

            string key     = CacheFactory.Cache().GetCache <string>("Hik:key");  // "21049470";
            string sign    = CacheFactory.Cache().GetCache <string>("Hik:sign"); // "4gZkNoh3W92X6C66Rb6X";
            string baseUrl = CacheFactory.Cache().GetCache <string>("Hik:baseUrl");
            if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(key))
            {
                var pitem = dataItemDetailBLL.GetItemValue("Hikappkey");//海康服务器密钥
                if (!string.IsNullOrEmpty(pitem))
                {
                    key  = pitem.Split('|')[0];
                    sign = pitem.Split('|')[1];
                    CacheFactory.Cache().WriteCache <string>(key, "Hik:key");
                    CacheFactory.Cache().WriteCache <string>(sign, "Hik:sign");
                }
            }
            if (string.IsNullOrEmpty(baseUrl))
            {
                baseUrl = dataItemDetailBLL.GetItemValue("HikBaseUrl");//海康服务器地址
                CacheFactory.Cache().WriteCache <string>(baseUrl, "Hik:baseUrl");
            }

            if (!string.IsNullOrEmpty(CarNo))
            {
                var selectmodel = new
                {
                    pageNo   = 1,
                    pageSize = 1,
                    plateNo  = CarNo
                };
                var            existsVehicleStr = SocketHelper.LoadCameraList(selectmodel, baseUrl, "/artemis/api/resource/v1/vehicle/advance/vehicleList", key, sign);
                dynamic        existsVehicle    = JsonConvert.DeserializeObject <dynamic>(existsVehicleStr);
                List <dynamic> vechileList      = new List <dynamic>();

                if (existsVehicle.code == "0" && existsVehicle.data.total > 0)
                {
                    foreach (dynamic obj in existsVehicle.data.list)
                    {
                        vechileList.Add(obj.vehicleId);
                        break;
                    }
                    var delModel = new
                    {
                        vehicleIds = vechileList
                    };
                    SocketHelper.LoadCameraList(delModel, baseUrl, "/artemis/api/resource/v1/vehicle/batch/delete", key, sign);
                }
            }
            #endregion
        }
Exemplo n.º 6
0
        public HttpResponseMessage CheckTicket(string ticket)
        {
            UserEntity userEntity = CacheFactory.Cache().GetCache <UserEntity>(ticket);

            if (userEntity != null)
            {
                return(Success("通过", userEntity));
            }
            else
            {
                return(Error("错误"));
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// 删除部门
 /// </summary>
 /// <param name="keyValue">主键</param>
 public bool RemoveForm(string keyValue)
 {
     try
     {
         service.RemoveForm(keyValue);
         CacheFactory.Cache().RemoveCache(cacheKey);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// 修改用户基本信息
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="userEntity">用户实体</param>
 /// <returns></returns>
 public string UpdateUserInfo(string keyValue, UserEntity userEntity)
 {
     try
     {
         service.UpdateEntity(userEntity);
         CacheFactory.Cache().RemoveCache(cacheKey);
         return(keyValue);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// 保存明细表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="dataItemDetailEntity">明细实体</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, DataItemDetailEntity dataItemDetailEntity)
 {
     try
     {
         dataItemDetailEntity.SimpleSpelling = Str.PinYin(dataItemDetailEntity.ItemName);
         service.SaveForm(keyValue, dataItemDetailEntity);
         CacheFactory.Cache().RemoveCache(cacheKey);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, HrDepartmentEntity entity)
 {
     try
     {
         service.SaveForm(keyValue, entity);
         CacheFactory.Cache().RemoveCache(cacheKey);
         CacheFactory.Cache().RemoveCache("DepartmentCache");
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// 获取生成好的验证码并加入缓存 默认10分钟
        /// </summary>
        /// <param name="mobile"></param>
        /// <returns></returns>
        public static string GetStoreVerifiyCode(string mobile)
        {
            string mobileKey = "VerifiyCode_KEY_" + mobile;
            string code      = CacheFactory.Cache().GetCache <string>(mobileKey);

            if (!code.IsNullEmpty())
            {
                CacheFactory.Cache().RemoveCache(mobileKey);//每次生成新的
            }
            code = CreateVerificationCode(6);
            CacheFactory.Cache().WriteCache(mobileKey, code, DateTime.Now.AddMinutes(SMSCommons.VerificationCodeTimeOutMinutes));
            return(code);
        }
Exemplo n.º 12
0
        /// <summary>
        ///  读取配置文件(MVC模式下已弃用)
        /// </summary>
        //public SiteConfig LoadConfig()
        //{
        //    SiteConfig model = CacheHelper.Get<SiteConfig>(SysKeys.CACHE_SYS_CONFIG);
        //    if (model == null)
        //    {
        //        string path = Utils.GetXmlMapPath(SysKeys.FILE_SYS_XML_CONFING);
        //        CacheHelper.Insert(SysKeys.CACHE_SYS_CONFIG, LoadConfig(path),
        //            Utils.GetXmlMapPath(SysKeys.FILE_SYS_XML_CONFING));
        //        model = CacheHelper.Get<SiteConfig>(SysKeys.CACHE_SYS_CONFIG);
        //    }
        //    return model;
        //}

        /// <summary>
        ///  读取配置文件
        /// </summary>
        public SiteConfig LoadConfig()
        {
            SiteConfig model = CacheFactory.Cache().GetCache <SiteConfig>(SysKeys.CACHE_SYS_CONFIG);

            if (model == null)
            {
                string path = Utils.GetXmlMapPath(SysKeys.FILE_SYS_XML_CONFING);
                model = LoadConfig(path);
                CacheFactory.Cache().WriteCache(model, SysKeys.CACHE_SYS_CONFIG);
                model = CacheFactory.Cache().GetCache <SiteConfig>(SysKeys.CACHE_SYS_CONFIG);
            }
            return(model);
        }
Exemplo n.º 13
0
        //[HandlerMonitor(3, "根据部门查询用户列表!")]
        public ActionResult GetListJson(string departmentId)
        {
            var userdata = CacheFactory.Cache().GetCache <IEnumerable <UserEntity> >(userBLL.cacheKey); //userCache.GetList();

            if (userdata == null)
            {
                userdata = userBLL.GetList();
            }

            var data = userdata.Where(x => x.DepartmentId == departmentId).ToList();

            return(Content(data.ToJson()));
        }
Exemplo n.º 14
0
 /// <summary>
 /// 删除用户
 /// </summary>
 /// <param name="keyValue">主键</param>
 public void RemoveForm(string keyValue)
 {
     try
     {
         service.RemoveForm(keyValue);
         CacheFactory.Cache().RemoveCache(cacheKey);
         UpdateIMUserList(keyValue, false, null);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 15
0
 /// <summary>
 /// 保存用户表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="userEntity">用户实体</param>
 /// <returns></returns>
 public string SaveForm(string keyValue, UserEntity userEntity)
 {
     try
     {
         keyValue = service.SaveForm(keyValue, userEntity);
         CacheFactory.Cache().RemoveCache(cacheKey);
         return(keyValue);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 16
0
        public bool RoleValidate(string roleId)
        {
            var authorizeurldata = new List <AuthorizeActionModel>();
            var cachedata        = CacheFactory.Cache().GetCache <List <AuthorizeActionModel> >("authorizeurldata_" + roleId);

            if (cachedata == null)
            {
                var moduledata = moduleApp.GetList();
                var buttondata = moduleButtonApp.GetList();
                var role       = roleservice.FindEntity(roleId);
                if (role != null && role.F_EnabledMark != false)
                {
                    var authorizedata = service.IQueryable(t => t.F_ObjectId == roleId).ToList();
                    foreach (var item in authorizedata)
                    {
                        try
                        {
                            if (item.F_ItemType == 1)
                            {
                                ModuleEntity moduleEntity = moduledata.Find(t => t.F_Id == item.F_ItemId);
                                authorizeurldata.Add(new AuthorizeActionModel {
                                    F_Id = moduleEntity.F_Id, F_UrlAddress = moduleEntity.F_UrlAddress
                                });
                            }
                            else if (item.F_ItemType == 2)
                            {
                                ModuleButtonEntity moduleButtonEntity = buttondata.Find(t => t.F_Id == item.F_ItemId);
                                authorizeurldata.Add(new AuthorizeActionModel {
                                    F_Id = moduleButtonEntity.F_ModuleId, F_UrlAddress = moduleButtonEntity.F_UrlAddress
                                });
                            }
                        }
                        catch (Exception ex)
                        {
                            string e = ex.Message;
                            continue;
                        }
                    }
                    CacheFactory.Cache().WriteCache(authorizeurldata, "authorizeurldata_" + roleId, DateTime.Now.AddHours(1));
                }
            }
            else
            {
                authorizeurldata = cachedata;
            }
            if (authorizeurldata != null)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 17
0
        public bool ActionValidate(string roleId, string moduleId, string action)
        {
            var authorizeurldata = new List <AuthorizeActionModel>();
            var cachedata        = CacheFactory.Cache().GetCache <List <AuthorizeActionModel> >("authorizeurldata_" + roleId);

            if (cachedata == null)
            {
                var moduledata    = moduleApp.GetList();
                var buttondata    = moduleButtonApp.GetList();
                var authorizedata = service.IQueryable(t => t.F_ObjectId == roleId).ToList();
                foreach (var item in authorizedata)
                {
                    if (item.F_ItemType == 1)
                    {
                        ModuleEntity moduleEntity = moduledata.Find(t => t.Id == item.F_ItemId);
                        authorizeurldata.Add(
                            new AuthorizeActionModel {
                            Id           = moduleEntity.Id,
                            F_UrlAddress = moduleEntity.F_UrlAddress
                        });
                    }
                    else if (item.F_ItemType == 2)
                    {
                        ModuleButtonEntity moduleButtonEntity = buttondata.Find(t => t.Id == item.F_ItemId);
                        authorizeurldata.Add(
                            new AuthorizeActionModel {
                            Id           = moduleButtonEntity.F_ModuleId,
                            F_UrlAddress = moduleButtonEntity.F_UrlAddress
                        });
                    }
                }
                CacheFactory.Cache().WriteCache(authorizeurldata, "authorizeurldata_" + roleId, DateTime.Now.AddMinutes(5));
            }
            else
            {
                authorizeurldata = cachedata;
            }
            authorizeurldata = authorizeurldata.FindAll(t => t.Id.Equals(moduleId));
            foreach (var item in authorizeurldata)
            {
                if (!string.IsNullOrEmpty(item.F_UrlAddress))
                {
                    string[] url = item.F_UrlAddress.Split('?');
                    if (item.Id == moduleId && url[0] == action)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 18
0
 public ObjectResultEx GovtLogin(RequestGovtInfo Param)
 {
     try
     {
         var    GovtAdmin = GovtWebService.GovtLogin(Param);
         string Code      = string.Empty;
         if (!Param.IsApp)
         {
             Code = CacheFactory.Cache().GetCache <string>("ValidateCode").Trim();
             if (GovtAdmin != null && Code.ToUpper().Equals(Param.ValidateCode.Trim().ToUpper()))
             {
                 CookieInfo cookie = new CookieInfo();
                 VerificationExtension.WriteToken(cookie, GovtAdmin);
                 return(ObjectResultEx.Instance(new { ResponseCookieInfo.RSAToKen, ResponseCookieInfo.RSAApiKey, ResponseCookieInfo.RSASysKey, GovtAdmin }, 1, RetrunMessge.SUCCESS, HttpCode.Success));
             }
             else if (!Code.ToUpper().Equals(Param.ValidateCode.Trim().ToUpper()))
             {
                 return(ObjectResultEx.Instance(null, -1, "验证码错误", HttpCode.NoAuth));
             }
             else
             {
                 return(ObjectResultEx.Instance(null, -1, "登录失败或账户冻结", HttpCode.NoAuth));
             }
         }
         else
         {
             if (GovtAdmin != null)
             {
                 CookieInfo cookie = new CookieInfo();
                 VerificationExtension.WriteToken(cookie, GovtAdmin);
                 return(ObjectResultEx.Instance(new { ResponseCookieInfo.RSAToKen, ResponseCookieInfo.RSAApiKey, ResponseCookieInfo.RSASysKey, GovtAdmin }, 1, RetrunMessge.SUCCESS, HttpCode.Success));
             }
             else if (GovtAdmin == null)
             {
                 return(ObjectResultEx.Instance(null, -1, "请检查用户名和密码是否正确", HttpCode.NoAuth));
             }
             else if (!Code.ToUpper().Equals(Param.ValidateCode.Trim().ToUpper()))
             {
                 return(ObjectResultEx.Instance(null, -1, "验证码错误", HttpCode.NoAuth));
             }
             else
             {
                 return(ObjectResultEx.Instance(null, -1, "登录失败或账户冻结", HttpCode.NoAuth));
             }
         }
     }
     catch (Exception)
     {
         return(ObjectResultEx.Instance(null, -1, "请输入验证码", HttpCode.FAIL));
     }
 }
Exemplo n.º 19
0
 /// <summary>
 /// 获取字典
 /// </summary>
 /// <returns></returns>
 private Model.manager_role GetCache(int id)
 {
     Model.manager_role model = CacheFactory.Cache().GetCache <Model.manager_role>(string.Format(cacheString, id));
     if (model == null)
     {
         model = dal.Get(id);
         if (model != null)
         {
             model.manager_role_values = new BLL.manager_role_value().GetModelList(0, "role_id=" + id, "", "");
             CacheFactory.Cache().WriteCache(model, string.Format(cacheString, id), cacheTime);
         }
     }
     return(model);
 }
Exemplo n.º 20
0
        public static bool CheckVerifiyCode(string mobile, string verifyCode)
        {
            string mobileKey = "VerifiyCode_KEY_" + mobile;

            try
            {
                string code = CacheFactory.Cache().GetCache <string>(mobileKey);
                return(code == verifyCode ? true : false);
            }
            catch
            {
                return(false);
            }
        }
        /// <summary>
        /// 角色授权功能验证
        /// </summary>
        /// <param name="roleGuid">当前角色Huid</param>
        /// <param name="moduleGuid">当前模块Guid</param>
        /// <param name="action">操作方法</param>
        /// <returns>返回是否具有该操作方法的权限 </returns>
        public bool ActionValidate(string roleGuid, string moduleGuid, string action)
        {
            var authUrlData      = new List <AuthorizeActionOutputDto>();                                                            //当前角色的功能
            var role             = roleRepository.FindEntity(roleGuid);
            var cacheAuthUrlData = CacheFactory.Cache().GetCache <List <AuthorizeActionOutputDto> >("authurldata_" + role.roleGuid); //读取缓存

            if (cacheAuthUrlData == null)
            {
                var moduleData    = moduleApp.FindList(c => c.isEnabled == true).ToList();
                var moduleBtnData = buttonApp.FindList(c => c.isEnabled == true).ToList();
                var roleAuthData  = this.FindList(r => r.authRoleGuid == role.roleGuid).ToList();//查询当前角色的功能
                foreach (var item in roleAuthData)
                {
                    if (item.authModuleType == 1)
                    {
                        ModuleEntity sysModule = moduleData.Find(m => m.moduleGuid == item.authModuleGuid);
                        authUrlData.Add(new AuthorizeActionOutputDto()
                        {
                            moduleGuid = sysModule.moduleGuid, moduleUrlAddress = sysModule.moduleUri
                        });
                    }
                    else if (item.authModuleType == 2)
                    {
                        ModuleButtonEntity moduleButton = moduleBtnData.Find(b => b.btnGuid == item.authModuleGuid);
                        authUrlData.Add(new AuthorizeActionOutputDto()
                        {
                            moduleGuid = moduleButton.btnGuid, moduleUrlAddress = moduleButton.btnUri
                        });
                    }
                }
                CacheFactory.Cache().WriteCache(authUrlData, "authurldata_" + roleGuid, DateTime.Now.AddMinutes(5));//写入缓存
            }
            else
            {
                authUrlData = cacheAuthUrlData;
            }
            authUrlData = authUrlData.FindAll(m => m.moduleGuid.Equals(moduleGuid));
            foreach (var item in authUrlData)
            {
                if (!string.IsNullOrEmpty(item.moduleUrlAddress))
                {
                    string[] url = item.moduleUrlAddress.Split('?');
                    if (item.moduleGuid == moduleGuid && url[0] == action)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 22
0
 /// <summary>
 /// 保存用户表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="userEntity">用户实体</param>
 /// <returns></returns>
 public string SaveForm(string keyValue, UserEntity userEntity)
 {
     try
     {
         keyValue = InstanceDAL.SaveForm(keyValue, userEntity);
         CacheFactory.Cache().RemoveCache(cacheKey);
         //UpdateIMUserList(keyValue, true, userEntity);
         return(keyValue);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 23
0
        private bool ActionValidate(string roleId, string moduleId, string action)
        {
            Sys_ModuleBLL        modulebll        = new Sys_ModuleBLL();
            Sys_ModuleButtonBLL  moduleButtonbll  = new Sys_ModuleButtonBLL();
            Sys_RoleAuthorizeBLL roleAuthorizebll = new Sys_RoleAuthorizeBLL();
            var authorizeurldata = new List <AuthorizeActionModel>();
            var cachedata        = CacheFactory.Cache().GetCache <List <AuthorizeActionModel> >("authorizeurldata_" + roleId);

            if (cachedata == null)
            {
                var moduledata    = modulebll.GetModelList("");
                var buttondata    = moduleButtonbll.GetModelList("");
                var authorizedata = roleAuthorizebll.GetModelList("F_ObjectId ='" + roleId + "'");
                foreach (var item in authorizedata)
                {
                    if (item.F_ItemType == 1)
                    {
                        var moduleEntity = moduledata.Find(t => t.F_Id == item.F_ItemId);
                        authorizeurldata.Add(new AuthorizeActionModel {
                            F_Id = moduleEntity.F_Id, F_UrlAddress = moduleEntity.F_UrlAddress
                        });
                    }
                    else if (item.F_ItemType == 2)
                    {
                        var moduleButtonEntity = buttondata.Find(t => t.F_Id == item.F_ItemId);
                        authorizeurldata.Add(new AuthorizeActionModel {
                            F_Id = moduleButtonEntity.F_ModuleId, F_UrlAddress = moduleButtonEntity.F_UrlAddress
                        });
                    }
                }
                CacheFactory.Cache().WriteCache(authorizeurldata, "authorizeurldata_" + roleId, DateTime.Now.AddMinutes(5));
            }
            else
            {
                authorizeurldata = cachedata;
            }
            authorizeurldata = authorizeurldata.FindAll(t => t.F_Id.Equals(moduleId));
            foreach (var item in authorizeurldata)
            {
                if (!string.IsNullOrEmpty(item.F_UrlAddress))
                {
                    string[] url = item.F_UrlAddress.Split('?');
                    if (item.F_Id == moduleId && url[0] == action)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 24
0
 /// <summary>
 /// 删除登录信息
 /// </summary>
 public virtual void EmptyCurrent()
 {
     if (LoginProvider == "Cookie")
     {
         WebHelper.RemoveCookie(LoginUserKey.Trim());
         #region 解决cookie时,设置数据权限较多时无法登陆的bug
         CacheFactory.Cache().RemoveCache(LoginUserKey);
         #endregion
     }
     else
     {
         WebHelper.RemoveSession(LoginUserKey.Trim());
     }
 }
Exemplo n.º 25
0
 /// <summary>
 /// 根据编码获取项目
 /// </summary>
 /// <param name="code"></param>
 /// <returns></returns>
 public DataItemEntity GetDataItemEntityByCode(string code)
 {
     if (!string.IsNullOrEmpty(code))
     {
         DataItemEntity entity = CacheFactory.Cache().GetCache <DataItemEntity>("__" + code + "__");
         if (entity == null)
         {
             entity = dataItemBll.GetEntityByCode(code);
             CacheFactory.Cache().WriteCache(entity, "__" + code + "__");
         }
         return(entity);
     }
     return(default(DataItemEntity));
 }
Exemplo n.º 26
0
 /// <summary>
 /// 根据字典详细信息ID获取字典实体集合
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public List <DataItemDetailEntity> GetDataItemListById(string id)
 {
     if (!string.IsNullOrEmpty(id))
     {
         List <DataItemDetailEntity> entity = CacheFactory.Cache().GetCache <List <DataItemDetailEntity> >("__" + id + "__DATA__ITEM__LIST__");
         if (entity == null)
         {
             entity = busines.GetDataItemListById(id);
             CacheFactory.Cache().WriteCache(entity, "__" + id + "__DATA__ITEM__LIST__");
         }
         return(entity);
     }
     return(default(List <DataItemDetailEntity>));
 }
Exemplo n.º 27
0
 /// <summary>
 /// 根据字典详细信息ID获取字典实体
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public DataItemDetailEntity GetDataItemEntityById(string id)
 {
     if (!string.IsNullOrEmpty(id))
     {
         DataItemDetailEntity entity = CacheFactory.Cache().GetCache <DataItemDetailEntity>("__" + id + "__");
         if (entity == null)
         {
             entity = busines.GetEntityById(id);
             CacheFactory.Cache().WriteCache(entity, "__" + id + "__");
         }
         return(entity);
     }
     return(default(DataItemDetailEntity));
 }
Exemplo n.º 28
0
 /// <summary>
 /// 当前用户
 /// </summary>
 /// <returns></returns>
 public virtual Operator Current()
 {
     try
     {
         Operator user   = new Operator();
         string   userId = GetUserId();
         userId = "UID_" + userId + "_" + LoginUserKey;
         user   = CacheFactory.Cache().GetCache <Operator>(userId);
         if (user != null)
         {
             return(user);
         }
         if (LoginProvider == "AppClient")
         {
             if (string.IsNullOrEmpty(userId))
             {
                 user = CacheFactory.Cache().GetCache <Operator>("UID_" + AppUserId + "_" + LoginUserKey);
             }
             else
             {
                 user = CacheFactory.Cache().GetCache <Operator>(userId);
             }
         }
         else
         {
             string key = FormsAuth.GetUserKey();
             user = string.IsNullOrEmpty(key) ? null : CacheFactory.Cache().GetCache <Operator>("UID_" + key + "_" + LoginUserKey);
             if (user == null)
             {
                 if (string.IsNullOrEmpty(userId))
                 {
                     if (!string.IsNullOrEmpty(AppUserId))
                     {
                         user = CacheFactory.Cache().GetCache <Operator>("UID_" + AppUserId + "_" + LoginUserKey);
                     }
                 }
                 else
                 {
                     user = CacheFactory.Cache().GetCache <Operator>(userId);
                 }
             }
         }
         return(user);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Exemplo n.º 29
0
        public ActionResult GetDepartmentTreeJson(string roleId)
        {
            var roleEntity     = roleBLL.GetEntity(roleId);
            var organizeEntity = organizeBLL.GetEntity(roleEntity.OrganizeId);
            var data           = CacheFactory.Cache().GetCache <IEnumerable <DepartmentEntity> >(departmentBLL.cacheKey); //departmentCache.GetList(roleEntity.OrganizeId);

            if (data == null)
            {
                data = departmentBLL.GetList();
            }
            data = data.Where(x => x.OrganizeId == roleEntity.OrganizeId);

            var        treeList = new List <TreeEntity>();
            TreeEntity tree     = new TreeEntity();

            if (organizeEntity != null)
            {
                tree.id    = organizeEntity.OrganizeId;
                tree.text  = organizeEntity.FullName;
                tree.value = organizeEntity.OrganizeId;
            }

            tree.isexpand    = true;
            tree.complete    = true;
            tree.hasChildren = true;
            tree.parentId    = "0";
            treeList.Add(tree);
            foreach (DepartmentEntity item in data)
            {
                tree = new TreeEntity();
                bool hasChildren = data.Count(t => t.ParentId == item.DepartmentId) == 0 ? false : true;
                tree.id    = item.DepartmentId;
                tree.text  = item.FullName;
                tree.value = item.DepartmentId;
                if (item.ParentId == "0")
                {
                    tree.parentId = roleEntity.OrganizeId;
                }
                else
                {
                    tree.parentId = item.ParentId;
                }
                tree.isexpand    = true;
                tree.complete    = true;
                tree.hasChildren = hasChildren;
                treeList.Add(tree);
            }
            return(Content(treeList.TreeToJson()));
        }
Exemplo n.º 30
0
        /// <summary>
        /// 部门列表
        /// </summary>
        /// <returns></returns>
        public IEnumerable <DepartmentEntity> GetList()
        {
            var cacheList = CacheFactory.Cache().GetCache <IEnumerable <DepartmentEntity> >(busines.cacheKey);

            if (cacheList == null)
            {
                var data = busines.GetList();
                CacheFactory.Cache().WriteCache(data, busines.cacheKey);
                return(data);
            }
            else
            {
                return(cacheList);
            }
        }