public IList <SiteMenusAccessInfo> GetListByJoin(string sqlWhere, params SqlParameter[] cmdParms) { StringBuilder sb = new StringBuilder(500); sb.Append(@"select sma.ApplicationId,sma.AccessId,sma.OperationAccess,sma.AccessType from SiteMenusAccess sma join aspnet_Applications a on a.ApplicationId = sma.ApplicationId "); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } sb.Append("order by ApplicationId "); var list = new List <SiteMenusAccessInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.AspnetDbConnString, CommandType.Text, sb.ToString(), cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { var model = new SiteMenusAccessInfo(); model.ApplicationId = reader.IsDBNull(0) ? Guid.Empty : reader.GetGuid(0); model.AccessId = reader.IsDBNull(1) ? Guid.Empty : reader.GetGuid(1); model.OperationAccess = reader.IsDBNull(2) ? string.Empty : reader.GetString(2); model.AccessType = reader.IsDBNull(3) ? string.Empty : reader.GetString(3); list.Add(model); } } } return(list); }
public IList <SiteMenusAccessInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms) { StringBuilder sb = new StringBuilder(500); sb.Append(@"select AccessId,OperationAccess,AccessType from SiteMenusAccess "); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } sb.Append("order by AccessType "); IList <SiteMenusAccessInfo> list = new List <SiteMenusAccessInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.AspnetDbConnString, CommandType.Text, sb.ToString(), cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { SiteMenusAccessInfo model = new SiteMenusAccessInfo(); model.AccessId = reader.GetGuid(0); model.OperationAccess = reader.GetString(1); model.AccessType = reader.GetString(2); list.Add(model); } } } return(list); }
public SiteMenusAccessInfo GetModel(Guid accessId) { SiteMenusAccessInfo model = null; StringBuilder sb = new StringBuilder(300); sb.Append(@"select top 1 AccessId,OperationAccess,AccessType from SiteMenusAccess where AccessId = @AccessId " ); SqlParameter[] parms = { new SqlParameter("@AccessId", SqlDbType.UniqueIdentifier) }; parms[0].Value = accessId; using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.AspnetDbConnString, CommandType.Text, sb.ToString(), parms)) { if (reader != null) { if (reader.Read()) { model = new SiteMenusAccessInfo(); model.AccessId = reader.GetGuid(0); model.OperationAccess = reader.GetString(1); model.AccessType = reader.GetString(2); } } } return(model); }
public IList <SiteMenusAccessInfo> GetList() { StringBuilder sb = new StringBuilder(300); sb.Append(@"select AccessId,OperationAccess,AccessType from SiteMenusAccess order by AccessType " ); IList <SiteMenusAccessInfo> list = new List <SiteMenusAccessInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.AspnetDbConnString, CommandType.Text, sb.ToString())) { if (reader != null && reader.HasRows) { while (reader.Read()) { SiteMenusAccessInfo model = new SiteMenusAccessInfo(); model.AccessId = reader.GetGuid(0); model.OperationAccess = reader.GetString(1); model.AccessType = reader.GetString(2); list.Add(model); } } } return(list); }
public int Insert(SiteMenusAccessInfo model) { model.Id = Guid.NewGuid(); _db.SiteMenusAccess.Insert(model); return(1); }
public IList <SiteMenusAccessInfo> GetList(int pageIndex, int pageSize, string sqlWhere, params SqlParameter[] cmdParms) { StringBuilder sb = new StringBuilder(500); int startIndex = (pageIndex - 1) * pageSize + 1; int endIndex = pageIndex * pageSize; sb.Append(@"select * from(select row_number() over(order by AccessType) as RowNumber, AccessId,OperationAccess,AccessType from SiteMenusAccess " ); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex); IList <SiteMenusAccessInfo> list = new List <SiteMenusAccessInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.AspnetDbConnString, CommandType.Text, sb.ToString(), cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { SiteMenusAccessInfo model = new SiteMenusAccessInfo(); model.AccessId = reader.GetGuid(1); model.OperationAccess = reader.GetString(2); model.AccessType = reader.GetString(3); list.Add(model); } } } return(list); }
public int Update(SiteMenusAccessInfo model) { StringBuilder sb = new StringBuilder(500); sb.Append(@"update SiteMenusAccess set OperationAccess = @OperationAccess,AccessType = @AccessType where AccessId = @AccessId " ); SqlParameter[] parms = { new SqlParameter("@AccessId", SqlDbType.UniqueIdentifier), new SqlParameter("@OperationAccess", SqlDbType.NText, 1073741823), new SqlParameter("@AccessType", SqlDbType.NVarChar, 50) }; parms[0].Value = model.AccessId; parms[1].Value = model.OperationAccess; parms[2].Value = model.AccessType; return(SqlHelper.ExecuteNonQuery(SqlHelper.AspnetDbConnString, CommandType.Text, sb.ToString(), parms)); }
public int Insert(SiteMenusAccessInfo model) { StringBuilder sb = new StringBuilder(300); sb.Append(@"insert into SiteMenusAccess (AccessId,OperationAccess,AccessType) values (@AccessId,@OperationAccess,@AccessType) " ); SqlParameter[] parms = { new SqlParameter("@AccessId", SqlDbType.UniqueIdentifier), new SqlParameter("@OperationAccess", SqlDbType.NText, 1073741823), new SqlParameter("@AccessType", SqlDbType.NVarChar, 50) }; parms[0].Value = model.AccessId; parms[1].Value = model.OperationAccess; parms[2].Value = model.AccessType; return(SqlHelper.ExecuteNonQuery(SqlHelper.AspnetDbConnString, CommandType.Text, sb.ToString(), parms)); }
public int Update(SiteMenusAccessInfo model) { return(dal.Update(model)); }
public int Insert(SiteMenusAccessInfo model) { return(dal.Insert(model)); }
//private void SaveBarcodeTemplate(HttpContext context) //{ // try // { // var isInsert = false; // Guid Id = Guid.Empty; // if (!string.IsNullOrWhiteSpace(context.Request.Form["Id"])) Guid.TryParse(context.Request.Form["Id"], out Id); // if (Id.Equals(Guid.Empty)) // { // Id = Guid.NewGuid(); // isInsert = true; // } // var sTypeName = context.Request.Form["TypeName"].Trim(); // var userId = WebCommon.GetUserId(); // BarcodeTemplateInfo modelInfo = null; // var sTitle = context.Request.Form["Title"].Trim(); // var sJContent = HttpUtility.UrlDecode(context.Request.Form["JContent"]).Trim(); // var isDefault = bool.Parse(context.Request.Form["IsDefault"]); // if (string.IsNullOrWhiteSpace(sTitle) && string.IsNullOrWhiteSpace(sJContent) && string.IsNullOrWhiteSpace(sTypeName)) // { // throw new ArgumentException(MC.M_RuleInvalidError); // } // if (sTypeName == "Barcode") // { // var sBarcode = context.Request.Form["Barcode"].Trim(); // var sBarcodeFormat = context.Request.Form["BarcodeFormat"].Trim(); // var width = int.Parse(context.Request.Form["Width"]); // var height = int.Parse(context.Request.Form["Height"]); // var margin = int.Parse(context.Request.Form["Margin"]); // var barcodeInfo = new BarcodeInfo(sBarcode, sBarcodeFormat, width, height, margin, ""); // barcodeInfo.ImageUrl = FilesHelper.GetRndUrl("Barcodes", // barcodeInfo.ImageUrl = ZxingHelper.CreateBarcode(barcodeInfo, Id.ToString(), true); // modelInfo = new BarcodeTemplateInfo(Id, userId, sTitle, JsonConvert.SerializeObject(barcodeInfo), isDefault, sTypeName, DateTime.Now); // } // else // { // modelInfo = new BarcodeTemplateInfo(Id, userId, sTitle, sJContent, isDefault, sTypeName, DateTime.Now); // } // var bll = new BarcodeTemplate(); // int effect = -1; // if (isInsert) // { // effect = bll.InsertByOutput(modelInfo); // } // else // { // effect = bll.Update(modelInfo); // } // if (effect < 1) context.Response.Write(ResResult.ResJsonString(false, MC.M_Save_Error, "")); // context.Response.Write(ResResult.ResJsonString(true, "", "")); // } // catch (Exception ex) // { // context.Response.Write(ResResult.ResJsonString(false, ex.Message, "")); // } //} #endregion #region 系统管理 private void SaveMenuAccess(HttpContext context) { if (!(HttpContext.Current.User.IsInRole("Administrators") || HttpContext.Current.User.IsInRole("System"))) { throw new ArgumentException(MC.Role_InvalidError); } var sRoleName = context.Request.Form["RoleName"]; var sUserName = context.Request.Form["UserName"]; var sMenuItemJson = context.Request.Form["MenuItemJson"]; if (string.IsNullOrWhiteSpace(sMenuItemJson)) { throw new ArgumentException(MC.Request_Params_InvalidError); } sMenuItemJson = HttpUtility.UrlDecode(sMenuItemJson); if (string.IsNullOrWhiteSpace(sRoleName) && string.IsNullOrWhiteSpace(sUserName)) { throw new ArgumentException(MC.Request_Params_InvalidError); } List <SiteMenusAccessItemInfo> list = JsonConvert.DeserializeObject <List <SiteMenusAccessItemInfo> >(sMenuItemJson); var accessId = Guid.Empty; var isRole = !string.IsNullOrWhiteSpace(sRoleName); var accessType = isRole ? "Roles" : "Users"; if (isRole) { if (sRoleName.ToLower() == "administrators") { throw new ArgumentException(MC.GetString(MC.Params_SaveRoleAccessError, sRoleName)); } var roleBll = new SiteRoles(); accessId = roleBll.GetAspnetModel(Membership.ApplicationName, sRoleName).Id; } else { if (Roles.GetRolesForUser(sUserName).Contains("administrators")) { throw new ArgumentException(MC.GetString(MC.Params_SaveUserAccessError, sUserName)); } accessId = Guid.Parse(Membership.GetUser(sUserName).ProviderUserKey.ToString()); } var menuBll = new SiteMenus(); var maBll = new SiteMenusAccess(); List <SiteMenusAccessItemInfo> maitems = null; var appId = new Applications().GetAspnetAppId(Membership.ApplicationName); var menusAccessInfo = maBll.GetModel(appId, accessId); if (menusAccessInfo != null) { maitems = JsonConvert.DeserializeObject <List <SiteMenusAccessItemInfo> >(menusAccessInfo.OperationAccess); } else { maitems = new List <SiteMenusAccessItemInfo>(); } foreach (var item in list) { var menuId = Guid.Parse(item.MenuId.ToString()); var itemIndex = maitems.FindIndex(m => m.MenuId.Equals(menuId)); if (itemIndex > -1) { maitems[itemIndex] = item; } else { maitems.Add(item); } } if (menusAccessInfo != null) { menusAccessInfo.OperationAccess = JsonConvert.SerializeObject(maitems); maBll.Update(menusAccessInfo); } else { menusAccessInfo = new SiteMenusAccessInfo(appId, accessId, JsonConvert.SerializeObject(maitems), accessType); maBll.Insert(menusAccessInfo); } context.Response.Write(ResResult.ResJsonString(true, "", "")); }
public int Update(SiteMenusAccessInfo model) { _db.SiteMenusAccess.Update(model); return(1); }