Exemple #1
0
        public async Task <ResultData> CheckToken([FromUri] string token)
        {
            ResultData oResultData = new ResultData();

            try
            {
                //Kiểm tra key có tồn tại và đã hết thời gian kích hoạt chưa
                if (!string.IsNullOrWhiteSpace(token) && MemoryCacheHelper.HasExitsKey(token))
                {
                    string          userName = Convert.ToString(MemoryCacheHelper.GetValue(token));
                    ApplicationUser user     = UserManager.FindByName <ApplicationUser, string>(userName);
                    if (user != null)
                    {
                        oResultData.Success = true;
                    }
                    else
                    {
                        oResultData.Success = false;
                    }
                }
                else
                {
                    oResultData.Success      = false;
                    oResultData.ErrorMessage = MT.Resources.GlobalResource.ErrorExpriedActiveLink;
                }
            }
            catch (Exception ex)
            {
                oResultData.SetError(ex);
            }
            return(oResultData);
        }
Exemple #2
0
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            cacheKey = String.Format("{0}.{1}",
                                     actionContext.ControllerContext.ControllerDescriptor.ControllerType.Name,
                                     actionContext.ActionDescriptor.ActionName);

            foreach (var value in actionContext.ActionArguments.Values)
            {
                cacheKey = String.Format("{0}.{1}", cacheKey, value);
            }

            HttpResponseMessage response = MemoryCacheHelper.GetValue <HttpResponseMessage>(cacheKey);

            if (response != null)
            {
                object content;
                response.TryGetContentValue(out content);

                actionContext.Response = actionContext.Request.CreateResponse(response.StatusCode, content);
            }
            else
            {
                base.OnActionExecuting(actionContext);
            }
        }
        public async Task <dynamic> EnterNewRecordLoad([FromBody] dynamic settings)
        {
            try
            {
                var settingConfig = System.Web.Helpers.Json.Decode(settings.ToString());

                var serverName = settingConfig.serverName;

                var cpuLoad = ((string)settingConfig.cpuLoad).ToNullableDouble() ?? 0;
                var ramLoad = ((string)settingConfig.ramLoad).ToNullableDouble() ?? 0;

                var memHelper = new MemoryCacheHelper();

                _loadRecords = await memHelper.GetValue("LoadRecords") as List <LoadRecord> ?? new List <LoadRecord>();

                var newRecord = new LoadRecord
                {
                    CpuLoad    = cpuLoad,
                    RamLoad    = ramLoad,
                    ServerName = serverName,
                    TimeStamp  = DateTimeOffset.UtcNow
                };

                _loadRecords.Add(newRecord);

                await memHelper.Add("LoadRecords", _loadRecords, DateTimeOffset.UtcNow.AddYears(1));

                return(new { Success = true, Message = string.Empty });
            }
            catch (Exception exception)
            {
                return(new { Success = false, Message = $"Failed to record load.  {exception.Message}" });
            }
        }
        public ActionResult SampleData(int id, Int64 FeedMappingID, string jsonFileName)
        {
            if (FeedMappingID > 0)
            {
                string contentRootPath = _hostingEnvironment.ContentRootPath;
                var    rootFilePath    = string.Concat(contentRootPath, "/", Settings.FeedJSONFilePath);
                JToken jToken          = null;
                if (!string.IsNullOrEmpty(jsonFileName))
                {
                    dynamic data = null;
                    using (StreamReader r = new StreamReader(Path.Combine(rootFilePath, jsonFileName)))
                    {
                        string json = r.ReadToEnd();
                        data = JsonConvert.DeserializeObject <dynamic>(json);
                    }
                    jToken = data as JToken;
                }

                if (jToken != null)
                {
                    //DbCall getFeed
                    var lstFeedSampleData = new List <FeedSampleData>();
                    var oResult           = MemoryCacheHelper.GetValue("GetSampleData_" + id);
                    if (oResult == null)
                    {
                        lstFeedSampleData = FilterRuleHelper.GetSampleData(id);
                        MemoryCacheHelper.Add("GetSampleData_" + id, lstFeedSampleData, DateTimeOffset.UtcNow.AddHours(1));
                    }
                    else
                    {
                        lstFeedSampleData = oResult as List <FeedSampleData>;
                    }

                    string jsonPath = lstFeedSampleData.FirstOrDefault(x => x.ID == FeedMappingID).ActualFeedKeyPath;
                    if (!string.IsNullOrEmpty(jsonPath))
                    {
                        jsonPath = jsonPath.Substring(jsonPath.LastIndexOf(']') + 1);
                        var jValue = jToken.Root.SelectTokens("$." + jsonPath).FirstOrDefault();
                        if (jValue != null)
                        {
                            var val = jValue.Value <object>();
                            return(Content(
                                       JsonConvert.SerializeObject(val, Formatting.Indented)
                                       , "application/json"));
                        }
                        else
                        {
                            return(Content(JsonConvert.SerializeObject("", Formatting.Indented), "application/json"));
                        }
                    }
                    else
                    {
                        return(Content(
                                   JsonConvert.SerializeObject("", Formatting.Indented)
                                   , "application/json"));
                    }
                }
            }
            return(Json(""));
        }
        public async Task <dynamic> GetLoadData([FromBody] dynamic settings)
        {
            try
            {
                var settingConfig = System.Web.Helpers.Json.Decode(settings.ToString());

                var serverName = settingConfig.serverName;

                var memHelper = new MemoryCacheHelper();

                _loadRecords = await memHelper.GetValue("LoadRecords") as List <LoadRecord>;

                if (_loadRecords == null || _loadRecords.Count <= 0)
                {
                    _loadRecords = await GenerateTestData(); //new List<LoadRecord>();

                    await memHelper.Add("LoadRecords", _loadRecords, DateTimeOffset.UtcNow.AddYears(1));
                }

                var serverRecords = _loadRecords.Where(record => record.ServerName == serverName && record.TimeStamp >= DateTimeOffset.UtcNow.Subtract(new TimeSpan(1, 0, 0, 0))).ToList();

                var serverAverageHourLoad =
                    serverRecords.Where(
                        record => record.TimeStamp >= DateTimeOffset.UtcNow.Subtract(new TimeSpan(1, 0, 0)))
                    .GroupBy(record => new { TimeKey = record.TimeStamp.ToString("HH:mm") })
                    .Select(
                        group =>
                        new
                {
                    CpuLoad = group.Average(p => p.CpuLoad),
                    RamLoad = group.Average(p => p.RamLoad),
                    group.First().ServerName,
                    group.Key.TimeKey
                }).OrderBy(list => list.TimeKey);

                var serverAverageDayLoad = serverRecords.GroupBy(
                    record => new { TimeKey = record.TimeStamp.ToString("MM/dd/yyyy HH:00") })
                                           .Select(
                    group =>
                    new
                {
                    CpuLoad = group.Average(p => p.CpuLoad),
                    RamLoad = group.Average(p => p.RamLoad),
                    group.First().ServerName,
                    group.Key.TimeKey
                }).OrderBy(list => list.TimeKey);


                return(new { HourReport = serverAverageHourLoad, DayReport = serverAverageDayLoad });

                //return new { Success = true, Message = string.Empty };
            }
            catch
            {
                return(new { Success = false, Message = "Failed to record load." });
            }
        }
Exemple #6
0
        public async Task <ResultData> Active([FromUri] string token)
        {
            ResultData oResultData = new ResultData();

            try
            {
                //Kiểm tra key có tồn tại và đã hết thời gian kích hoạt chưa
                if (!string.IsNullOrWhiteSpace(token) && MemoryCacheHelper.HasExitsKey(token))
                {
                    string          userName = Convert.ToString(MemoryCacheHelper.GetValue(token));
                    ApplicationUser user     = UserManager.FindByName <ApplicationUser, string>(userName);
                    if (user != null)
                    {
                        string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);

                        string passWordGenerate = MT.Library.CommonFunction.RandomPassword();

                        var result = await UserManager.ResetPasswordAsync(user.Id, code, passWordGenerate);

                        if (result.Succeeded)
                        {
                            MemoryCacheHelper.Delete(token);
                            string hostName = MT.Library.CommonFunction.GetDomainBEcore();

                            string pathEmail       = MT.Library.CommonFunction.GetMapPathEmail();
                            var    destinationPath = Path.Combine(pathEmail, "ActivePassword.html");
                            string strBody         = MT.Library.CommonFunction.ReadData(destinationPath);

                            strBody = strBody.Replace("#Link#", hostName);

                            strBody = strBody.Replace("#PassWord#", passWordGenerate);

                            //Gửi mail kích hoạt tài khoản
                            EmailUltility.SendMail(user.Email, "", MT.Resources.GlobalResource.Title_SendLinkActive, strBody, null);

                            oResultData.Success = true;
                        }
                        else
                        {
                            oResultData.Success = false;
                        }
                    }
                }
                else
                {
                    oResultData.Success      = false;
                    oResultData.ErrorMessage = MT.Resources.GlobalResource.ErrorExpriedActiveLink;
                }
            }
            catch (Exception ex)
            {
                oResultData.SetError(ex);
            }
            return(oResultData);
        }
        public T GetValueUpdateCache <T>(string url, string method, DateTimeOffset?timeOffset = null)
        {
            var value = MemoryCacheHelper.GetValue <T>(url + method);

            if (value == null)
            {
                try
                {
                    var response = _webProxy.GetResponse <T>(url, method);
                    MemoryCacheHelper.AddValue(url + method, response, timeOffset ?? DateTimeOffset.Now.AddMinutes(5));
                    return(response);
                }
                catch
                {
                    return(default);
Exemple #8
0
        public ActionResult GetAllActivities()
        {
            var oRequestCode = new Random().Next(0, int.MaxValue);
            var oRequestTime = DateTime.Now;

            LogHelper.InsertServiceLogs("search/allactivities (GetAllActivities) (" + oRequestCode + ")", null, oRequestTime);
            var activities = new List <string>();
            var oResult    = MemoryCacheHelper.GetValue("GetAllActivities");

            if (oResult == null)
            {
                activities = FeedHelper.GetAllActivities();
                MemoryCacheHelper.Add("GetAllActivities", activities, DateTimeOffset.UtcNow.AddHours(2));
            }
            else
            {
                activities = oResult as List <string>;
            }
            LogHelper.InsertServiceLogs("search/allactivities (GetAllActivities) - Response (" + oRequestCode + ")", null, oRequestTime, DateTime.Now);
            return(Ok(new { items = activities }));
        }
        private bool CheckAccessTokenValidity(string accessToken)
        {
            bool IsAuthorized = false;

            try
            {
                #region Allow same access token by pass added 01-04-2019
                var oCacheKey = string.Concat("AccessToken_", accessToken);
                var oResult   = MemoryCacheHelper.GetValue(oCacheKey);
                if (oResult != null && (string)oResult == accessToken)
                {
                    return(true);
                }
                #endregion

                var lstSqlParameter = new List <SqlParameter>();

                lstSqlParameter.Add(new SqlParameter()
                {
                    ParameterName = "@AccessToken", SqlDbType = SqlDbType.NVarChar, Value = (object)accessToken ?? DBNull.Value
                });

                var dt = DBProvider.GetDataTable("AccessToken_Authorize", CommandType.StoredProcedure, ref lstSqlParameter);
                if (dt != null && dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["IsAuthorized"] != DBNull.Value)
                    {
                        MemoryCacheHelper.Add(oCacheKey, accessToken, DateTimeOffset.UtcNow.AddDays(1));
                        IsAuthorized = Convert.ToBoolean(dt.Rows[0]["IsAuthorized"]);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.InsertErrorLogs("[DataLaundryApi] AuthorizationHandler", "CheckAccessTokenValid", ex.Message, ex.InnerException?.Message, ex.StackTrace);
            }
            return(IsAuthorized);
        }
Exemple #10
0
        public async Task <HttpResponseMessage> GetAll(HttpRequestMessage request, string filter = "")
        {
            return(await CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                IEnumerable <Function> model = null;
                var cacheFunctions = MemoryCacheHelper.GetValue("function");
                if (cacheFunctions != null)
                {
                    model = (IEnumerable <Function>)cacheFunctions;
                }
                else
                {
                    MemoryCacheHelper.Add("function", _functionService.GetAll(filter), DateTimeOffset.MaxValue);
                    model = _functionService.GetAll(filter);
                }
                IEnumerable <FunctionViewModel> modelVm = Mapper.Map <IEnumerable <Function>, IEnumerable <FunctionViewModel> >(model);

                response = request.CreateResponse(HttpStatusCode.OK, modelVm);

                return response;
            }));
        }
Exemple #11
0
        public ActionResult GetActivities(double?lat, double?lng, double?radius, [FromQuery] string[] source,
                                          [FromQuery] string[] kind, [FromQuery] string[] tag, [FromQuery] string[] excludeTag,
                                          [FromQuery] string[] disabilitySupport, [FromQuery] string[] weekdays, string gender = null,
                                          double?minCost = null, double?maxCost = null, string from = null, string to   = null,
                                          long?minTime   = null, long?maxTime   = null, long?minAge = null, long?maxAge = null)
        {
            #region Variable declaration or assignment
            lat    = lat ?? defaultLatitude;
            lng    = lng ?? defaultLongitude;
            radius = radius ?? defaultRadius;
            string sources            = null;
            string kinds              = null;
            string tags               = null;
            string excludeTags        = null;
            string disabilitySupports = null;
            string days               = null;

            if (source.Length > 0)
            {
                sources = string.Join(",", source);
            }
            if (kind.Length > 0)
            {
                kinds = string.Join(",", kind);
            }
            if (tag.Length > 0)
            {
                tags = string.Join(",", tag);
            }
            if (excludeTag.Length > 0)
            {
                excludeTags = string.Join(",", excludeTag);
            }
            if (disabilitySupport.Length > 0)
            {
                disabilitySupports = string.Join(",", disabilitySupport);
            }
            if (weekdays.Length > 0)
            {
                days = string.Join(",", weekdays);
            }
            #endregion
            var    oRequestCode = new Random().Next(0, int.MaxValue);
            var    oRequestTime = DateTime.Now;
            string Model        = string.Concat("{lat:", lat, ",lng:", lng, ",radius:", radius, ",sources:", sources, ",kinds:", kinds, ",tags:", tags, ",excludeTags:", excludeTags, ",disabilitySupports:", disabilitySupports, ",days:", days, ",gender:", gender, ",minCost:", minCost, ",maxCost:", maxCost, ",from:", from, ",to:", to, ",minTime:", minTime, ",maxTime:", maxTime, ",minAge:", minAge, ",maxAge:", maxAge, "}");
            var    oResult      = MemoryCacheHelper.GetValue(Model + "-Activities");
            var    activities   = new List <string>();
            LogHelper.InsertServiceLogs("search/activities (GetActivities) (" + oRequestCode + ")", Model, oRequestTime);
            if (oResult == null)
            {
                activities = FeedHelper.GetActivities(lat, lng, radius, sources, kinds, tags,
                                                      excludeTags, disabilitySupports, days,
                                                      minCost, maxCost, gender, minTime, maxTime,
                                                      minAge, maxAge, from, to);
                MemoryCacheHelper.Add(Model + "-Activities", activities, DateTimeOffset.UtcNow.AddHours(2));
            }
            else
            {
                activities = oResult as List <string>;
            }
            LogHelper.InsertServiceLogs("search/activities (GetActivities) - Response (" + oRequestCode + ")", Model, oRequestTime, DateTime.Now);
            return(Ok(new { items = activities }));
        }
Exemple #12
0
        private RoleState Get(string unitCode, string username, string machucnang)
        {
            RoleState roleState = new RoleState();

            if (username.Equals("admin") || username.Equals("hanghanh"))
            {
                roleState = new RoleState()
                {
                    Approve = true,
                    Delete  = true,
                    Add     = true,
                    STATE   = "all",
                    Edit    = true,
                    View    = true
                };
            }
            else
            {
                var cacheData = MemoryCacheHelper.GetValue(unitCode + "|" + machucnang + "|" + username);
                if (cacheData == null)
                {
                    using (var connection = new OracleConnection(ConfigurationManager.ConnectionStrings["Database.Connection"].ConnectionString))
                    {
                        connection.Open();
                        using (OracleCommand command = connection.CreateCommand())
                        {
                            command.CommandType = CommandType.Text;
                            command.CommandText =
                                @"SELECT XEM,THEM,SUA,XOA,DUYET FROM AU_NHOMQUYEN_CHUCNANG WHERE UNITCODE='" + unitCode + "' AND MACHUCNANG='" + machucnang +
                                "' AND MANHOMQUYEN IN (SELECT MANHOMQUYEN FROM AU_NGUOIDUNG_NHOMQUYEN WHERE UNITCODE='" + unitCode + "' AND USERNAME='******') UNION SELECT AU_NGUOIDUNG_QUYEN.XEM,AU_NGUOIDUNG_QUYEN.THEM,AU_NGUOIDUNG_QUYEN.SUA,AU_NGUOIDUNG_QUYEN.XOA,AU_NGUOIDUNG_QUYEN.DUYET " +
                                "FROM AU_NGUOIDUNG_QUYEN WHERE AU_NGUOIDUNG_QUYEN.UNITCODE='" + unitCode + "' AND AU_NGUOIDUNG_QUYEN.MACHUCNANG='" + machucnang + "' AND AU_NGUOIDUNG_QUYEN.USERNAME='******'";
                            using (OracleDataReader oracleDataReader = command.ExecuteReader())
                            {
                                if (!oracleDataReader.HasRows)
                                {
                                    roleState = new RoleState()
                                    {
                                        STATE   = string.Empty,
                                        View    = false,
                                        Approve = false,
                                        Delete  = false,
                                        Add     = false,
                                        Edit    = false
                                    };
                                }
                                else
                                {
                                    roleState.STATE = machucnang;
                                    while (oracleDataReader.Read())
                                    {
                                        int objXem = Int32.Parse(oracleDataReader["XEM"].ToString());
                                        if (objXem == 1)
                                        {
                                            roleState.View = true;
                                        }
                                        int objThem = Int32.Parse(oracleDataReader["THEM"].ToString());
                                        if (objThem == 1)
                                        {
                                            roleState.Add = true;
                                        }
                                        int objSua = Int32.Parse(oracleDataReader["SUA"].ToString());
                                        if (objSua == 1)
                                        {
                                            roleState.Edit = true;
                                        }
                                        int objXoa = Int32.Parse(oracleDataReader["XOA"].ToString());
                                        if (objXoa == 1)
                                        {
                                            roleState.Delete = true;
                                        }
                                        int objDuyet = Int32.Parse(oracleDataReader["DUYET"].ToString());
                                        if (objDuyet == 1)
                                        {
                                            roleState.Approve = true;
                                        }
                                    }
                                    MemoryCacheHelper.Add(unitCode + "|" + machucnang + "|" + username, roleState,
                                                          DateTimeOffset.Now.AddHours(6));
                                }
                            }
                        }
                    }
                }
                else
                {
                    roleState = (RoleState)cacheData;
                }
            }
            return(roleState);
        }
Exemple #13
0
        public ResultData SendLinkActive([FromUri] string userName, [FromUri] string capcha, [FromUri] string emailConfirm)
        {
            ResultData oResultData = new ResultData();

            try
            {
                if (!string.IsNullOrWhiteSpace(userName) && !string.IsNullOrWhiteSpace(capcha))
                {
                    //Kiểm tra user có tồn tại không
                    ApplicationUser user = UserManager.FindByName <ApplicationUser, string>(userName);
                    if (user != null)
                    {
                        //Kiểm tra capcha có hợp lệ không
                        object objCapcha = MemoryCacheHelper.GetValue(Commonkey.Capcha);
                        if (objCapcha == null && !string.IsNullOrWhiteSpace(capcha))
                        {
                            oResultData.Success      = false;
                            oResultData.ErrorMessage = MT.Resources.GlobalResource.WarnCodeExpried;
                        }
                        if (!objCapcha.ToString().Equals(capcha, StringComparison.OrdinalIgnoreCase))
                        {
                            oResultData.Success      = false;
                            oResultData.ErrorMessage = MT.Resources.GlobalResource.WarnCodeInValid;
                        }
                        else
                        {
                            MemoryCacheHelper.Delete(Commonkey.Capcha);
                        }
                        if (user.Email == emailConfirm)
                        {
                            Guid token = Guid.NewGuid();

                            MemoryCacheHelper.Add(token.ToString(), userName, DateTimeOffset.Now.AddDays(1));

                            string hostName = MT.Library.CommonFunction.GetDomainBEcore();

                            string pathEmail = MT.Library.CommonFunction.GetMapPathEmail();

                            //var destinationPath = Path.Combine(pathEmail, "ConfirmPassword.html");
                            var destinationPath = Path.Combine(pathEmail, "SetNewPassword.html");

                            string strBody = MT.Library.CommonFunction.ReadData(destinationPath);

                            strBody = strBody.Replace("#Link#", hostName);

                            strBody = strBody.Replace("#Token#", token.ToString());
                            //Gửi mail kích hoạt tài khoản
                            EmailUltility.SendMail(user.Email, "", MT.Resources.GlobalResource.Title_ActiveLink, strBody, null);
                            oResultData.Success = true;
                            oResultData.Data    = user.Email;
                        }
                        else
                        {
                            oResultData.Success      = false;
                            oResultData.ErrorMessage = MT.Resources.GlobalResource.InvalidEmailConfirm;
                        }
                    }
                    else
                    {
                        oResultData.Success      = false;
                        oResultData.ErrorMessage = MT.Resources.GlobalResource.UserNameInValid;
                    }
                }
                else
                {
                    oResultData.Success      = false;
                    oResultData.ErrorMessage = MT.Resources.GlobalResource.WarnUserNameOrCodeBlank;
                }
            }
            catch (Exception ex)
            {
                oResultData.SetError(ex);
            }
            return(oResultData);
        }
        private RoleState Get(string unitCode, string username, string machucnang)
        {
            RoleState roleState = new RoleState();

            if (username.Equals("admin"))
            {
                roleState = new RoleState()
                {
                    XEM   = true,
                    THEM  = true,
                    SUA   = true,
                    XOA   = true,
                    DUYET = true,
                    STATE = "all",
                };
            }
            else
            {
                var cacheData = MemoryCacheHelper.GetValue(unitCode + "|" + machucnang + "|" + username);
                if (cacheData == null)
                {
                    using (var connection = new OracleConnection(ConfigurationManager.ConnectionStrings["ERBusConnection"].ConnectionString))
                    {
                        connection.Open();
                        using (OracleCommand command = connection.CreateCommand())
                        {
                            command.CommandType = CommandType.Text;
                            command.CommandText =
                                @"SELECT XEM,THEM,SUA,XOA,DUYET FROM NHOMQUYEN_MENU WHERE UNITCODE LIKE '" + unitCode + "%' AND MA_MENU='" + machucnang +
                                "' AND MANHOMQUYEN IN (SELECT MANHOMQUYEN FROM NGUOIDUNG_NHOMQUYEN WHERE UNITCODE LIKE '" + unitCode + "%' AND USERNAME='******') UNION SELECT NGUOIDUNG_MENU.XEM,NGUOIDUNG_MENU.THEM,NGUOIDUNG_MENU.SUA,NGUOIDUNG_MENU.XOA,NGUOIDUNG_MENU.DUYET " +
                                "FROM NGUOIDUNG_MENU WHERE NGUOIDUNG_MENU.UNITCODE LIKE '" + unitCode + "%' AND NGUOIDUNG_MENU.MA_MENU='" + machucnang + "' AND NGUOIDUNG_MENU.USERNAME='******'";
                            using (OracleDataReader oracleDataReader = command.ExecuteReader())
                            {
                                if (!oracleDataReader.HasRows)
                                {
                                    roleState = new RoleState()
                                    {
                                        STATE = string.Empty,
                                        XEM   = false,
                                        THEM  = false,
                                        SUA   = false,
                                        XOA   = false,
                                        DUYET = false,
                                    };
                                }
                                else
                                {
                                    roleState.STATE = machucnang;
                                    while (oracleDataReader.Read())
                                    {
                                        int objXem = Int32.Parse(oracleDataReader["XEM"].ToString());
                                        if (objXem == 1)
                                        {
                                            roleState.XEM = true;
                                        }
                                        int objThem = Int32.Parse(oracleDataReader["THEM"].ToString());
                                        if (objThem == 1)
                                        {
                                            roleState.THEM = true;
                                        }
                                        int objSua = Int32.Parse(oracleDataReader["SUA"].ToString());
                                        if (objSua == 1)
                                        {
                                            roleState.SUA = true;
                                        }
                                        int objXoa = Int32.Parse(oracleDataReader["XOA"].ToString());
                                        if (objXoa == 1)
                                        {
                                            roleState.XOA = true;
                                        }
                                        int objDuyet = Int32.Parse(oracleDataReader["DUYET"].ToString());
                                        if (objDuyet == 1)
                                        {
                                            roleState.DUYET = true;
                                        }
                                    }
                                    MemoryCacheHelper.Add(unitCode + "|" + machucnang + "|" + username, roleState,
                                                          DateTimeOffset.Now.AddHours(6));
                                }
                            }
                        }
                    }
                }
                else
                {
                    roleState = (RoleState)cacheData;
                }
            }
            return(roleState);
        }