public static SiteMapCollection Search(SearchFilter value) { SiteMapCollection items = new SiteMapCollection(); 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((SiteMapCollection)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 <SiteMapCollection>().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 SiteMapCollection GetbyUser(string CreatedUser, int CompanyID) { SiteMapCollection collection = new SiteMapCollection(); SiteMap obj; var sqlParams = new SqlParameter[] { new SqlParameter("@CreatedUser", CreatedUser), new SqlParameter("@CompanyID", CompanyID), }; using (var reader = SqlHelper.ExecuteReader("SiteMap_GetAll_byUser", sqlParams)) { while (reader.Read()) { obj = GetItemFromReader(reader); collection.Add(obj); } } return(collection); }
public static SiteMapCollection GetAllItem(int CompanyID) { SiteMapCollection collection = new SiteMapCollection(); var sqlParams = new SqlParameter[] { new SqlParameter("@CompanyID", CompanyID), }; using (var reader = SqlHelper.ExecuteReader("SiteMap_GetAll", sqlParams)) { while (reader.Read()) { SiteMap obj = new SiteMap(); obj = GetItemFromReader(reader); collection.Add(obj); } } return(collection); }
public static SiteMapCollection GetAll(int CompanyID) { SiteMapCollection items = new SiteMapCollection(); string key = String.Format(SETTINGS_ALL_KEY, CompanyID); object obj2 = HttpCache.Get(key); if ((obj2 != null)) { return((SiteMapCollection)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 <SiteMapCollection>().GetAwaiter().GetResult(); } } HttpCache.Max(key, items); return(items); }