public static AccessRightsCollection Search(SearchFilter value) { AccessRightsCollection items = new AccessRightsCollection(); string key = string.Format(SETTINGS_Search_KEY, value.CompanyID + value.Keyword + value.Page + value.PageSize + value.OrderBy + value.OrderDirection); if (SystemConfig.AllowSearchCache) { object obj2 = HttpCache.Get(key); if ((obj2 != null)) { return((AccessRightsCollection)obj2); } } using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue)) { HttpResponseMessage response = client.PostAsJsonAsync(Resource + "?method=search", value).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { items = response.Content.ReadAsAsync <AccessRightsCollection>().GetAwaiter().GetResult(); } } if (SystemConfig.AllowSearchCache) { HttpCache.Max(key, items); } return(items); }
//change by pham thanh public static AccessRights InsertOrUpdateItem(AccessRights model) { SiteMapCollection listSiteMap = SiteMapManager.GetAllItem(model.CompanyID); AccessRights itemAccess = new AccessRights(); AccessRightsCollection ListAccess = GetItemByID(model.RoleName, model.CompanyID, model.ApplicationName, null); int count = model.ListAccess.Count; foreach (var item in listSiteMap) { if (!string.IsNullOrEmpty(item.Url) && item.Url.Trim() != "/") { if (ListAccess.Count != 0) { itemAccess = ListAccess.Where(m => m.NodeID.Equals(item.NodeID)).FirstOrDefault(); if (itemAccess == null) { itemAccess = new AccessRights(); } } model.Access = 0; model.NodeID = item.NodeID; bool isUpdate = false; if (count > 0) { foreach (var access in model.ListAccess) { if (access.NodeID == item.NodeID) { model.Access = access.Access; isUpdate = true; break; } } } if (itemAccess.RoleName != null) { if (isUpdate) { SqlHelper.ExecuteReader(CommandType.StoredProcedure, "AccessRights_InsertOrUpdate", CreateSqlParameter(model)); } } else { ///chưa tồn tại trong db /// SqlHelper.ExecuteReader(CommandType.StoredProcedure, "AccessRights_InsertOrUpdate", CreateSqlParameter(model)); } } } return(model); }
public static AccessRightsCollection GetbyUser(string CreatedUser) { AccessRightsCollection collection = new AccessRightsCollection(); AccessRights obj; using (var reader = SqlHelper.ExecuteReader("AccessRights_GetAll_byUser", new SqlParameter("@CreatedUser", CreatedUser))) { while (reader.Read()) { obj = GetItemFromReader(reader); collection.Add(obj); } } return(collection); }
public static AccessRightsCollection Search(SearchFilter SearchKey) { AccessRightsCollection collection = new AccessRightsCollection(); using (var reader = SqlHelper.ExecuteReader("AccessRights_Search", SearchFilterManager.SqlSearchParam(SearchKey))) { while (reader.Read()) { AccessRights obj = new AccessRights(); obj = GetItemFromReader(reader); collection.Add(obj); } } return(collection); }
public static AccessRightsCollection GetAllItem(int CompanyID) { AccessRightsCollection collection = new AccessRightsCollection(); var sqlParams = new SqlParameter[1]; sqlParams[0] = new SqlParameter("@CompanyID", CompanyID); using (var reader = SqlHelper.ExecuteReader("AccessRights_GetAll", sqlParams)) { while (reader.Read()) { AccessRights obj = new AccessRights(); obj = GetItemFromReader(reader); collection.Add(obj); } } return(collection); }
public static AccessRightsCollection GetbyNoteParent(string roleName, string applicationName, string nodeParentID, int companyID) { AccessRightsCollection collection = new AccessRightsCollection(); AccessRights obj; var par = new SqlParameter[] { new SqlParameter("@RoleName", roleName), new SqlParameter("@CompanyID", companyID), new SqlParameter("@ApplicationName", applicationName), new SqlParameter("@NodeParentID", new Guid(nodeParentID)), }; using (var reader = SqlHelper.ExecuteReader("AccessRights_GetByNoteParent", par)) { while (reader.Read()) { obj = GetItemFromReader(reader); collection.Add(obj); } } return(collection); }
public static AccessRightsCollection GetItemByID(String RoleName, int CompanyID, string ApplicationName, Guid?NodeID) { AccessRightsCollection collection = new AccessRightsCollection(); var sqlParams = new SqlParameter[4]; sqlParams[0] = new SqlParameter("@CompanyID", CompanyID); sqlParams[1] = new SqlParameter("@RoleName", RoleName); sqlParams[2] = new SqlParameter("@ApplicationName", ApplicationName); sqlParams[3] = new SqlParameter("@NodeID", NodeID); using (var reader = SqlHelper.ExecuteReader("AccessRights_GetByID", sqlParams)) { while (reader.Read()) { AccessRights obj = new AccessRights(); obj = GetItemFromReader(reader); collection.Add(obj); //item = GetItemFromReader(reader); } } return(collection); }
public static AccessRightsCollection GetAll(int CompanyID) { AccessRightsCollection items = new AccessRightsCollection(); string key = String.Format(SETTINGS_ALL_KEY, CompanyID); object obj2 = HttpCache.Get(key); if ((obj2 != null)) { return((AccessRightsCollection)obj2); } using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue)) { HttpResponseMessage response = client.GetAsync(string.Format(Resource + "?CompanyID={0}", CompanyID)).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { items = response.Content.ReadAsAsync <AccessRightsCollection>().GetAwaiter().GetResult(); } } HttpCache.Max(key, items); return(items); }
public AccessRights() { ListAccess = new AccessRightsCollection(); }