/// <summary> /// 修改权限 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Edit(long id) { //父级权限,名称,类型不可修改 Result <Base_Right> result = new Result <Base_Right>(); using (AdminClientProxy proxy = new AdminClientProxy(ProxyEx(Request))) { result = proxy.GetRightModel(id); } var model = result.Data; Helper.IsCheck(HttpContext, model.Belong + "Right", SystemRight.Modify.ToString(), true); Dictionary <string, string> isMenuList = new Dictionary <string, string>(); isMenuList.Add("False", "否"); isMenuList.Add("True", "是"); ViewBag.IsMenu = isMenuList.ToList().ToSelectList("Value", "Key", false, model.IsMenu.ToString()); RoleType rType = model.Belong.ToEnumReq <RoleType>(); if (rType == RoleType.Admin) { ViewBag.RightType = Enum <FunctionType> .AsEnumerable().ToDictionary(i => i.ToString(), j => j.GetText()).ToList().ToSelectList("Value", "Key", false, model.RightType); } else { ViewBag.RightType = Enum <WebFunctionType> .AsEnumerable().ToDictionary(i => i.ToString(), j => j.GetText()).ToList().ToSelectList("Value", "Key", false, model.RightType); } //ViewBag.RightType = Enum<FunctionType>.AsEnumerable().ToDictionary(i => i.ToString(), j => j.GetText()).ToList().ToSelectList("Value", "Key", false, model.RightType); return(View(model)); }
public void AsEnumerableTest() { foreach (var item in Enum <TypeCode> .AsEnumerable()) { Console.WriteLine(item); } }
/// <summary> /// 添加权限页面 /// </summary> /// <returns></returns> public ActionResult Add(string belong, long pId) { //权限检查 Helper.IsCheck(HttpContext, belong + "Right", SystemRight.Add.ToString(), true); Dictionary <string, string> isMenuList = new Dictionary <string, string>(); isMenuList.Add("False", "否"); isMenuList.Add("True", "是"); ViewBag.IsMenu = isMenuList.ToList().ToSelectList("Value", "Key", false); ViewBag.Belong = belong; ViewBag.pId = pId; //当前角色类型 RoleType rType = belong.ToEnumReq <RoleType>(); string selectedType = ""; ViewBag.Code = getSelectName(rType, pId, out selectedType); if (rType == RoleType.Admin) { ViewBag.RightType = Enum <FunctionType> .AsEnumerable().ToDictionary(i => i.ToString(), j => j.GetText()).ToList().ToSelectList("Value", "Key", false, selectedType); } else { ViewBag.RightType = Enum <WebFunctionType> .AsEnumerable().ToDictionary(i => i.ToString(), j => j.GetText()).ToList().ToSelectList("Value", "Key", false, selectedType); } ViewBag.Code2 = Enum <SystemRight> .AsEnumerable().ToDictionary(i => i.ToString(), j => j.GetText()).ToList().ToSelectList("Value", "Key", false); return(View()); }
public ActionResult Add() { ViewBag.IsConfirm = HelperExt.GetConfirmList(false); ViewBag.IsEnable = HelperExt.GetEnableList(false); ViewBag.Step = Enum <MessageStep> .AsEnumerable().ToDictionary(i => i.ToString(), j => j.GetText()).ToList().ToSelectList("Value", "Key", true); return(View()); }
public void GetEnumValues_ForTestEnum_ReturnArrayWithAllValuesFromTestEnum() { var enumValues = EnumUtils.GetEnumValues <TestEnum>(); Assert.Equal(5, enumValues.Length); var expectedValues = new Enum[] { TestEnum.None, TestEnum.FirstEntry, TestEnum.Extra, TestEnum.SomeMore, TestEnum.ElementWithoutAttribute }; Assert.Equal(expectedValues.AsEnumerable(), enumValues.AsEnumerable()); }
public ActionResult Edit(long id) { Result <Base_TypeDictionary> result = new Result <Base_TypeDictionary>(); using (AdminClientProxy proxy = new AdminClientProxy(ProxyEx(Request))) { result = proxy.GetTypeModel(id); } ViewBag.Type = Enum <DictionaryType> .AsEnumerable().ToDictionary(i => i.ToString(), j => j.GetText()).ToList().ToSelectList("Value", "Key", false, result.Data.Type); return(View(result.Data)); }
public ActionResult Index(string Name = "", string IsEnable = "0", string IsConfirm = "0", int pageIndex = 1, int pageSize = 10) { ViewBag.Name = Name; ViewBag.pageIndex = pageIndex; //下拉框 ViewBag.Step = Enum <MessageStep> .AsEnumerable().ToDictionary(i => i.ToString(), j => j.GetText()).ToList().ToSelectList("Value", "Key", true); ViewBag.IsConfirm = HelperExt.GetConfirmList(true, IsConfirm); ViewBag.IsEnable = HelperExt.GetEnableList(true, IsEnable); ConditionExpression ce = null; QueryCondition qc = new QueryCondition(); ce = new ConditionExpression(); if (!string.IsNullOrEmpty(Name)) { ce = new ConditionExpression(); ce.ExpName = "Name"; ce.ExpValue = "%" + Name + "%"; ce.ExpOperater = eConditionOperator.Like; ce.ExpLogical = eLogicalOperator.And; qc.ConditionList.Add(ce); } if (!string.IsNullOrEmpty(IsEnable) && IsEnable != "0") { ce = new ConditionExpression(); ce.ExpName = "IsEnable"; ce.ExpValue = IsEnable == EnumState.Enable.ToString(); ce.ExpOperater = eConditionOperator.Equal; ce.ExpLogical = eLogicalOperator.And; qc.ConditionList.Add(ce); } if (!string.IsNullOrEmpty(IsConfirm) && IsConfirm != "0") { ce = new ConditionExpression(); ce.ExpName = "IsConfirm"; ce.ExpValue = IsConfirm == EnumState.Confirmed.ToString(); ce.ExpOperater = eConditionOperator.Equal; ce.ExpLogical = eLogicalOperator.And; qc.ConditionList.Add(ce); } qc.PageInfo = GetPageInfo(pageIndex, pageSize); Result <List <Msg_SMSTemplete> > result = new Result <List <Msg_SMSTemplete> >(); using (MessageClientProxy proxy = new MessageClientProxy(ProxyEx(Request))) { result = proxy.GetSMSTempleteList(qc); ViewBag.Total = result.AllRowsCount; } return(View(result.Data)); }
// GET: Role/Edit/5 public ActionResult Edit(long id) { Result <Base_Role> result = new Result <Base_Role>(); using (AdminClientProxy proxy = new AdminClientProxy(ProxyEx(Request))) { result = proxy.GetRoleModel(id); } //权限检查 var model = result.Data; ViewBag.Belong = Enum <RoleType> .AsEnumerable().ToDictionary(i => i.ToString(), j => j.GetText()).ToList().ToSelectList("Value", "Key", false, model.Belong); return(View(result.Data)); }
public static IEnumerable <SelectListItem> SelectList <T>(this IDataHelper helper, bool hasNull = false) where T : struct { List <SelectListItem> l = new List <SelectListItem>(); if (hasNull) { l.Add(sliNull()); } foreach (T i in Enum <T> .AsEnumerable()) { SelectListItem sli = new SelectListItem(); sli.Text = (string)i.ToString(); sli.Value = Convert.ToInt32(Enum.Parse(typeof(T), sli.Text)).ToString(); l.Add(sli); } return(l); }
public ActionResult Edit(long id) { Result <Msg_SMSTemplete> result = new Result <Msg_SMSTemplete>(); using (MessageClientProxy proxy = new MessageClientProxy(ProxyEx(Request))) { result = proxy.GetSMSTempleteModel(id); } ViewBag.Step = Enum <MessageStep> .AsEnumerable().ToDictionary(i => i.ToString(), j => j.GetText()).ToList().ToSelectList("Value", "Key", true, result.Data.Step); var isConfirm = result.Data.IsConfirm ? EnumState.Confirmed.ToString() : EnumState.NoConfim.ToString(); var isEnable = result.Data.IsEnable ? EnumState.Enable.ToString() : EnumState.Disable.ToString(); ViewBag.IsEnable = HelperExt.GetEnableList(false, isEnable); ViewBag.IsConfirm = HelperExt.GetConfirmList(false, isConfirm); return(View(result.Data)); }
/// <summary> /// 类型管理 /// </summary> /// <param name="name"></param> /// <param name="type"></param> /// <param name="isEnable"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> // GET: TypeDictionary public ActionResult Index(string name = "", string Type = "", int pageIndex = 1, int pageSize = 10) { ViewBag.name = name; ViewBag.pageIndex = pageIndex; ViewBag.Type = Enum <DictionaryType> .AsEnumerable().ToDictionary(i => i.ToString(), j => j.GetText()).ToList().ToSelectList("Value", "Key", true, Type); ConditionExpression ce = null; QueryCondition qc = new QueryCondition(); if (!string.IsNullOrEmpty(name)) { ce = new ConditionExpression(); ce.ExpName = "Name"; ce.ExpValue = "%" + name + "%"; ce.ExpOperater = eConditionOperator.Like; ce.ExpLogical = eLogicalOperator.And; qc.ConditionList.Add(ce); } if (Type != "") { ce = new ConditionExpression(); ce.ExpName = "Type"; ce.ExpValue = Type; ce.ExpOperater = eConditionOperator.Equal; ce.ExpLogical = eLogicalOperator.And; qc.ConditionList.Add(ce); } qc.PageInfo = GetPageInfo(pageIndex, pageSize); qc.SortList.Add(new SortExpression("Type", eSortType.Asc)); qc.SortList.Add(new SortExpression("No", eSortType.Asc)); Result <List <Base_TypeDictionary> > result = new Result <List <Base_TypeDictionary> >(); using (AdminClientProxy proxy = new AdminClientProxy(ProxyEx(Request))) { result = proxy.GetTypeList(qc); ViewBag.Total = result.AllRowsCount; } return(View(result.Data)); }
public ActionResult Edit(string tableName, long id) { ViewBag.tableName = tableName; ViewBag.id = id; Result <Base_Protocol> result = new Result <Base_Protocol>(); using (AdminClientProxy proxy = new AdminClientProxy(ProxyEx(Request))) { result = proxy.GetProtocolModel(id); } var isConfirm = result.Data.IsConfirm ? EnumState.Confirmed.ToString() : EnumState.NoConfim.ToString(); var isEnable = result.Data.IsEnable ? EnumState.Enable.ToString() : EnumState.Disable.ToString(); ViewBag.Type = Enum <ProtocolType> .AsEnumerable().ToDictionary(i => i.ToString(), j => j.GetText()).ToList().ToSelectList("Value", "Key", false, result.Data.Type); ViewBag.IsEnable = HelperExt.GetEnableList(false, isEnable); ViewBag.IsConfirm = HelperExt.GetConfirmList(false, isConfirm); return(View(result.Data)); }
/// <summary> /// 修改资料界面根据companyID获取companyName /// </summary> /// <param name="id"></param> /// <returns></returns> //public ActionResult GetCompanyName(long id) //{ // Result<Base_Company> result = new Result<Base_Company>(); // using (AdminClientProxy proxy = new AdminClientProxy(ProxyEx(Request))) // { // result = proxy.GetCompanyModel(id); // } // return Json(result); //} /// <summary> /// 修改资料界面根据DepID获取DepName /// </summary> /// <param name="id"></param> /// <returns></returns> //public ActionResult GetDepName(long id) //{ // Result<Base_Dep> result = new Result<Base_Dep>(); // using (AdminClientProxy proxy = new AdminClientProxy(ProxyEx(Request))) // { // result = proxy.GeDepModel(id); // } // return Json(result); //} /// <summary> /// 全部用户检索 /// </summary> /// <returns></returns> public ActionResult UserRetrieve(string name, int pageIndex = 1, int pageSize = 10, string isLock = "0") { //权限检查 Helper.IsCheck(HttpContext, AdminModule.UserRetrieve.ToString(), SystemRight.Browse.ToString(), true); ViewBag.name = name; ViewBag.IsLock = Enum <EnumState> .AsEnumerable().Where(i => i == EnumState.Lock || i == EnumState.NoLock).ToDictionary(i => i.ToString(), j => j.GetText()).ToList().ToSelectList("Value", "Key", true); ConditionExpression ce = null; QueryCondition qc = new QueryCondition(); if (!string.IsNullOrEmpty(name)) { ce = new ConditionExpression(); ce.ExpName = "UserName"; ce.ExpValue = "%" + name + "%"; ce.ExpOperater = eConditionOperator.Like; ce.ExpLogical = eLogicalOperator.And; qc.ConditionList.Add(ce); } if (isLock != "0") { ce = new ConditionExpression(); ce.ExpName = "IsLock"; ce.ExpValue = isLock == EnumState.Lock.ToString();; ce.ExpOperater = eConditionOperator.Equal; ce.ExpLogical = eLogicalOperator.And; qc.ConditionList.Add(ce); } qc.PageInfo = GetPageInfo(pageIndex, pageSize); Result <List <Base_User> > result = new Result <List <Base_User> >(); using (AdminClientProxy proxy = new AdminClientProxy(ProxyEx(Request))) { result = proxy.GetUserList(qc); ViewBag.Total = result.AllRowsCount; ViewBag.pageIndex = pageIndex; } return(View(result.Data)); }
public ActionResult Add() { ViewBag.Type = Enum <DictionaryType> .AsEnumerable().ToDictionary(i => i.ToString(), j => j.GetText()).ToList().ToSelectList("Value", "Key", false); return(View()); }
public object GetUserMenu(long projectId) { try { if (projectId <= 0) { return(APIResult.GetSuccessNoDatas()); } var user = CurrentUserView; if (user != null) { var list = Enum <BusinessType> .AsEnumerable().ToDictionary(i => i.ToString(), j => j.GetText()).Select(p => new { code = p.Key }).ToList(); if (user.CompanyType.Equals(RoleType.Owner.ToString())) { list = list.Where(p => p.code == BusinessType.SecurityCheck.ToString() || p.code == BusinessType.Question.ToString()).ToList(); } if (user.CompanyType.Equals(RoleType.Supplier.ToString())) { using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(user))) { if (proxy.IsSupervisor(projectId, user.UserId)) { list = list.Where(p => p.code == BusinessType.Log.ToString() || p.code == BusinessType.Equipment.ToString() || p.code == BusinessType.Visa.ToString() || p.code == BusinessType.Question.ToString() || p.code == BusinessType.SecurityCheck.ToString() || //返回监理现场检查类型; p.code == BusinessType.Rectification.ToString() || //发起整改单 p.code == BusinessType.Dangerous.ToString()).ToList(); } else { list = list.Where(p => p.code == BusinessType.Track.ToString() || p.code == BusinessType.DelayApply.ToString() || p.code == BusinessType.Question.ToString()).ToList(); //list.Add(new //{ // code = SystemRight.UploadSecurityCheck.ToString() //}); list.Add(new { code = SystemRight.UploadWork.ToString() }); } } } list.Add(new { code = SystemRight.UploadSecurityCheck.ToString() }); list.Add(new { code = SystemRight.FaceAI.ToString() }); return(APIResult.GetSuccessResult(list)); } return(APIResult.GetErrorResult(MsgCode.InvalidToken)); } catch (Exception ex) { return(APIResult.GetErrorResult(ex.Message)); } finally { } }
/// <summary> /// 获取是否确认selectlist /// </summary> /// <param name="isDefault">是否生成请选择</param> /// <param name="selected">选中项的值</param> /// <returns></returns> public static SelectList GetConfirmList(bool isDefault = true, string selected = "0") { var list = Enum <EnumState> .AsEnumerable().Where(i => i == EnumState.Confirmed || i == EnumState.NoConfim).ToDictionary(i => i.ToString(), j => j.GetText()).ToList().ToSelectList("Value", "Key", isDefault, selected); return(list); }
/// <summary> /// 创建service /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCreateService_Click(object sender, EventArgs e) { List <TableModel> list = new List <TableModel>(); string db = tbDataOperate.Text; foreach (DataGridViewRow row in gvTables.Rows) { TableModel item = (TableModel)row.DataBoundItem; if (item.IsMap) { //获取表注释 item.Description = DBHelper.GetColumn(ConnectionString, item.Name).FirstOrDefault().TableDescription; list.Add(item); } } StringBuilder strClass = new StringBuilder(); var actionList = Enum <Operate> .AsEnumerable(); foreach (var item in list) { //class foreach (var action in actionList) { strClass.AppendLine("///<summary>"); strClass.AppendLine("///" + DBHelper.ActionText[action] + ":" + item.Description); strClass.AppendLine("///</summary>"); string actionName = action.GetText().Replace("{Model}", item.NoPrefixName); string data = "result.Data = -1;"; switch (action) { case Operate.Add: strClass.AppendLine(" /// <param name=\"model\">要添加的model</param>"); strClass.AppendLine(" /// <returns>受影响的行数</returns>"); strClass.AppendLine("public Result<int> " + actionName + "(" + item.Name + " model)"); strClass.AppendLine("{"); strClass.AppendLine("Result<int> result = new Result<int>();"); strClass.AppendLine("try"); strClass.AppendLine("{"); strClass.AppendLine("var rows = " + db + "<" + item.Name + ">.Get().Add(model);"); strClass.AppendLine(" result.Data = rows;"); strClass.AppendLine("result.Flag = EResultFlag.Success;"); strClass.AppendLine(" WriteLog(AdminModule." + item.NoPrefixName + ".GetText(), SystemRight.Add.GetText(), \"新增" + item.Description + ": \" + model.Id );"); break; case Operate.Edit: strClass.AppendLine(" /// <param name=\"model\">要修改的model</param>"); strClass.AppendLine(" /// <returns>受影响的行数</returns>"); strClass.AppendLine("public Result<int> " + actionName + "(" + item.Name + " model)"); strClass.AppendLine("{"); strClass.AppendLine("Result<int> result = new Result<int>();"); strClass.AppendLine("try"); strClass.AppendLine("{"); strClass.AppendLine("var rows = " + db + "<" + item.Name + ">.Get().Update(model);"); strClass.AppendLine("result.Data = rows;"); strClass.AppendLine("result.Flag = EResultFlag.Success;"); strClass.AppendLine(" WriteLog(AdminModule." + item.NoPrefixName + ".GetText(), SystemRight.Modify.GetText(), \"修改" + item.Description + ": \" + model.Id );"); break; case Operate.Delete: strClass.AppendLine(" /// <param name=\"ids\">要删除的Id集合</param>"); strClass.AppendLine(" /// <returns>受影响的行数</returns>"); strClass.AppendLine("public Result<int> " + actionName + "(List<long> ids)"); strClass.AppendLine("{"); strClass.AppendLine("Result<int> result = new Result<int>();"); strClass.AppendLine("try"); strClass.AppendLine("{"); strClass.AppendLine("var models = " + db + "<" + item.Name + ">.Get().GetList(i => ids.Contains(i.Id)).ToList();"); strClass.AppendLine("var rows = " + db + "<" + item.Name + ">.Get().DeleteRange(models);"); strClass.AppendLine("result.Data = rows;"); strClass.AppendLine("result.Flag = EResultFlag.Success;"); strClass.AppendLine(" WriteLog(AdminModule." + item.NoPrefixName + ".GetText(), SystemRight.Delete.GetText(), \"批量删除" + item.Description + ": \" + rows );"); break; case Operate.List: strClass.AppendLine(" /// <param name=\"qc\">查询条件</param>"); strClass.AppendLine(" /// <returns>符合条件的数据集合</returns>"); strClass.AppendLine("public Result<List<" + item.Name + ">> " + actionName + "(QueryCondition qc)"); strClass.AppendLine("{"); strClass.AppendLine(" qc = AddDefault(qc);"); strClass.AppendLine(" Result<List<" + item.Name + ">> result = new Result<List<" + item.Name + ">>();"); strClass.AppendLine("try"); strClass.AppendLine("{"); strClass.AppendLine("result = hc.Plat.Common.Service.DataOperate.QueryListSimple<" + item.Name + ">(context, qc);"); data = "result.Data = null;"; break; case Operate.Detail: strClass.AppendLine(" /// <param name=\"id\">数据Id</param>"); strClass.AppendLine(" /// <returns>数据详情model</returns>"); strClass.AppendLine("public Result<" + item.Name + "> " + actionName + "(long id)"); strClass.AppendLine("{"); strClass.AppendLine(" Result<" + item.Name + "> result = new Result<" + item.Name + ">();"); strClass.AppendLine("try"); strClass.AppendLine("{"); strClass.AppendLine(" var model = " + db + "<" + item.Name + ">.Get().GetModel(id);"); strClass.AppendLine("result.Data = model;"); strClass.AppendLine("result.Flag = EResultFlag.Success;"); data = "result.Data = null;"; break; default: break; } strClass.AppendLine(" }"); strClass.AppendLine("catch (Exception ex)"); strClass.AppendLine("{"); strClass.AppendLine(data); strClass.AppendLine("result.Flag = EResultFlag.Failure;"); strClass.AppendLine("result.Exception = new ExceptionEx(ex, \"" + actionName + "\");"); strClass.AppendLine("}"); strClass.AppendLine("return result;"); strClass.AppendLine("}"); } } ShowText m = new ShowText(); m.SetTextContent(strClass.ToString() + ""); m.Show(); }
public ActionResult Dev(string action = "") { switch (action) { case "right": #region 权限 //var adminMoudle = Enum<AdminModule>.AsEnumerable();//管理员 //var tenMoudle = Enum<TendererModule>.AsEnumerable();//招标人 //var biddingMoudle = Enum<BiddingModule>.AsEnumerable();//代理 //var bidderMoudle = Enum<BidderModule>.AsEnumerable();//投标人 //var expModule = Enum<ExpModule>.AsEnumerable();//专家 //var ops = Enum<SystemRight>.AsEnumerable();//操作 //var rt = Enum<RoleType>.AsEnumerable();//角色 //List<Base_Right> list = new List<Base_Right>(); //using (AdminClientProxy proxy = new AdminClientProxy(ProxyEx(Request))) //{ // var allRight = proxy.GetRightList(null); // ArrayList al = new ArrayList(); // foreach (var roleType in rt) // { // switch (roleType) // { // case RoleType.Admin: // al = new ArrayList(); // foreach (var a in adminMoudle) // { // al.Add(a); // } // break; // case RoleType.Tenderer: // al = new ArrayList(); // foreach (var a in tenMoudle) // { // al.Add(a); // } // break; // case RoleType.BiddingAgent: // al = new ArrayList(); // foreach (var a in biddingMoudle) // { // al.Add(a); // } // break; // case RoleType.Bidder: // al = new ArrayList(); // foreach (var a in bidderMoudle) // { // al.Add(a); // } // break; // case RoleType.Exp: // al = new ArrayList(); // foreach (var a in expModule) // { // al.Add(a); // } // break; // default: // throw new ArgumentOutOfRangeException(); // } // foreach (var module in al) // { // bool isAdd = true; // if (allRight.AllRowsCount > 0) // { // foreach (var item in allRight.Data) // { // if (item.Name == module.ToString()) // { // isAdd = false; // break; // } // } // } // //添加模块权限 // Base_Right moduleRight = new Base_Right(); // if (isAdd) // { // moduleRight.Belong = roleType.ToString(); // moduleRight.IsConfirm = true; // moduleRight.IsEnable = true; // moduleRight.OperateUserId = 0; // string s = ""; // switch (roleType) // { // case RoleType.Admin: // s = module.ToString().ToEnumReq<AdminModule>().GetText(); // break; // case RoleType.Tenderer: // s = module.ToString().ToEnumReq<TendererModule>().GetText(); // break; // case RoleType.BiddingAgent: // s = module.ToString().ToEnumReq<BiddingModule>().GetText(); // break; // case RoleType.Bidder: // s = module.ToString().ToEnumReq<BidderModule>().GetText(); // break; // case RoleType.Exp: // s = module.ToString().ToEnumReq<ExpModule>().GetText(); // break; // default: // throw new ArgumentOutOfRangeException(); // } // moduleRight.ActionName = module.ToString(); // moduleRight.OtherName = s; // moduleRight.ParentId = 0; // moduleRight.Remark = ""; // moduleRight.RightName = module.ToString(); // moduleRight.RightType = module.ToString(); // list.Add(moduleRight); // } // isAdd = true; // foreach (var op in ops) // { // string module_op = module.ToString() + "_" + op.ToString(); // if (allRight.AllRowsCount > 0) // { // foreach (var item in allRight.Data) // { // if (item.RightName == module_op) // { // isAdd = false; // break; // } // } // } // //添加操作权限 // if (isAdd) // { // Base_Right model = new Base_Right(); // model.Belong = roleType.ToString(); // model.IsConfirm = true; // model.IsEnable = true; // model.OperateUserId = 0; // model.OtherName = op.GetText(); // model.ParentId = moduleRight.Id; // model.Remark = ""; // model.RightName = module_op; // model.RightType = module.ToString(); // model.ActionName = op.ToString(); // list.Add(model); // } // } // } // } // proxy.AddRightRange(list); //} #endregion break; case "setting": var sets = Enum <Settings> .AsEnumerable(); //设置项 using (AdminClientProxy proxy = new AdminClientProxy(ProxyEx(Request))) { var allSets = proxy.LoadSettings(); foreach (var set in sets) { bool isAdd = true; foreach (var s in allSets.Data) { if (s.Code == set.ToString()) { isAdd = false; } } if (isAdd) { Base_Settings model = new Base_Settings(); model.Code = set.ToString(); model.Name = set.GetText(); model.Value = ""; proxy.AddSettings(model); } } } break; default: break; } return(Json(true)); }
/// <summary> /// 创建接口 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCreateInterface_Click(object sender, EventArgs e) { List <TableModel> list = new List <TableModel>(); string db = tbDataOperate.Text; foreach (DataGridViewRow row in gvTables.Rows) { TableModel item = (TableModel)row.DataBoundItem; if (item.IsMap) { //获取表注释 item.Description = DBHelper.GetColumn(ConnectionString, item.Name).FirstOrDefault().TableDescription; list.Add(item); } } StringBuilder strInterface = new StringBuilder(); var actionList = Enum <Operate> .AsEnumerable(); foreach (var item in list) { //interface foreach (var action in actionList) { string actionName = action.GetText().Replace("{Model}", item.NoPrefixName); strInterface.AppendLine("///<summary>"); strInterface.AppendLine("///" + DBHelper.ActionText[action] + ":" + item.Description); strInterface.AppendLine("///</summary>"); switch (action) { case Operate.Add: strInterface.AppendLine(" ///<param name=\"model\">要添加的model</param>"); strInterface.AppendLine(" ///<returns>受影响的行数</returns>"); strInterface.AppendLine("[OperationContract]"); strInterface.AppendLine(" Result<int> " + actionName + "(" + item.Name + " model);"); break; case Operate.Edit: strInterface.AppendLine(" ///<param name=\"model\">要修改的model</param>"); strInterface.AppendLine(" ///<returns>受影响的行数</returns>"); strInterface.AppendLine("[OperationContract]"); strInterface.AppendLine(" Result<int> " + actionName + "(" + item.Name + " model);"); break; case Operate.Delete: strInterface.AppendLine(" ///<param name=\"ids\">要删除的Id集合</param>"); strInterface.AppendLine(" ///<returns>受影响的行数</returns>"); strInterface.AppendLine("[OperationContract]"); strInterface.AppendLine(" Result<int> " + actionName + "(List<long> ids);"); break; case Operate.List: strInterface.AppendLine(" ///<param name=\"qc\">查询条件</param>"); strInterface.AppendLine(" ///<returns>符合条件的数据集合</returns>"); strInterface.AppendLine("[OperationContract]"); strInterface.AppendLine(" Result<List<" + item.Name + ">> " + actionName + "(QueryCondition qc);"); break; case Operate.Detail: strInterface.AppendLine(" ///<param name=\"id\">数据Id</param>"); strInterface.AppendLine(" ///<returns>数据详情model</returns>"); strInterface.AppendLine("[OperationContract]"); strInterface.AppendLine(" Result<" + item.Name + "> " + actionName + "(long id);"); break; default: break; } } } strInterface.AppendLine(""); strInterface.AppendLine(""); strInterface.AppendLine(""); foreach (var item in list) { //proxy foreach (var action in actionList) { string actionName = action.GetText().Replace("{Model}", item.NoPrefixName); strInterface.AppendLine("///<summary>"); strInterface.AppendLine("///" + DBHelper.ActionText[action] + ":" + item.Description); strInterface.AppendLine("///</summary>"); switch (action) { case Operate.Add: strInterface.AppendLine(" ///<param name=\"model\">要添加的model</param>"); strInterface.AppendLine(" ///<returns>受影响的行数</returns>"); strInterface.AppendLine(" public Result<int> " + actionName + "(" + item.Name + " model)"); strInterface.AppendLine(" {"); strInterface.AppendLine(" return base.Channel." + actionName + "(model);"); strInterface.AppendLine(" }"); break; case Operate.Edit: strInterface.AppendLine(" ///<param name=\"model\">要修改的model</param>"); strInterface.AppendLine(" ///<returns>受影响的行数</returns>"); strInterface.AppendLine(" public Result<int> " + actionName + "(" + item.Name + " model)"); strInterface.AppendLine(" {"); strInterface.AppendLine(" return base.Channel." + actionName + "(model);"); strInterface.AppendLine(" }"); break; case Operate.Delete: strInterface.AppendLine(" ///<param name=\"ids\">要删除的Id集合</param>"); strInterface.AppendLine(" ///<returns>受影响的行数</returns>"); strInterface.AppendLine(" public Result<int> " + actionName + "(List<long> ids)"); strInterface.AppendLine(" {"); strInterface.AppendLine(" return base.Channel." + actionName + "(ids);"); strInterface.AppendLine(" }"); break; case Operate.List: strInterface.AppendLine(" ///<param name=\"qc\">查询条件</param>"); strInterface.AppendLine(" ///<returns>符合条件的数据集合</returns>"); strInterface.AppendLine(" public Result<List<" + item.Name + ">> " + actionName + "(QueryCondition qc)"); strInterface.AppendLine(" {"); strInterface.AppendLine(" return base.Channel." + actionName + "(qc);"); strInterface.AppendLine(" }"); break; case Operate.Detail: strInterface.AppendLine(" ///<param name=\"id\">数据Id</param>"); strInterface.AppendLine(" ///<returns>数据详情model</returns>"); strInterface.AppendLine(" public Result<" + item.Name + "> " + actionName + "(long id)"); strInterface.AppendLine(" {"); strInterface.AppendLine(" return base.Channel." + actionName + "(id);"); strInterface.AppendLine(" }"); break; default: break; } } } ShowText m = new ShowText(); m.SetTextContent(strInterface.ToString() + ""); m.Show(); }
/// <summary> /// 获取资源信息 /// </summary> /// <param name="id"></param> /// <param name="systemid"></param> /// <returns></returns> public async Task <ResourceShowViewModel> GetResourceAsync(long id, long systemid) { ResourceShowViewModel model = new ResourceShowViewModel(); //获取基本数据 model.SysResource = await _databaseFixture.Db.SysResource.FindByIdAsync(id); if (model.SysResource == null) { model.SysResource = new SysResource() { IsDel = 0, IsShow = 1, Sort = 1 }; } model.ButtonViewModels = new List <ButtonViewModel>(); if (model.SysResource != null) { var dbbuttons = await _databaseFixture.Db.SysResource .FindAllAsync(m => m.ParentId == model.SysResource.ResourceId && m.IsDel == 0 && m.IsButton == 1); //获取所属按钮 var buttons = dbbuttons .Select(m => new { m.ResourceId, m.ResourceName, m.ButtonType }).ToList(); foreach (var item in buttons) { model.ButtonViewModels.Add(new ButtonViewModel() { Id = item.ResourceId, ButtonType = item.ButtonType.Value, ButtonModel = item.ButtonType.Value, Name = item.ResourceName }); } var btntypes = model.ButtonViewModels.Select(m => m.ButtonType).ToList(); //添加未选择的按钮 var btnEnums = Enum <ButtonType> .AsEnumerable().Select(m => (byte)m).ToList(); var pushEnums = btnEnums.Where(m => !btntypes.Contains(m) && m > 0).ToList(); foreach (var item in pushEnums) { model.ButtonViewModels.Add(new ButtonViewModel() { Id = 0, ButtonModel = 0, ButtonType = item, Name = GetButtonName(item) }); } //父节点选择菜单下拉 var dbpmenus = await _databaseFixture.Db.SysResource.FindAllAsync(m => m.ResourceId != model.SysResource.ResourceId && m.IsDel == 0 && m.IsShow == 1 && m.SystemId == systemid); model.ParentMenus = dbpmenus .Select(m => new ZTree() { id = m.ResourceId.ToString(), name = m.ResourceName, pId = m.ParentId, @checked = model.SysResource.ParentId == m.ResourceId }).ToList(); } else { model.SysResource = new SysResource(); model.ButtonViewModels = ButtonInit(); var dbpmenus = await _databaseFixture.Db.SysResource.FindAllAsync(m => m.IsDel == 0 && m.IsShow == 1 && m.SystemId == systemid); model.ParentMenus = dbpmenus .Select(m => new ZTree() { id = m.ResourceId.ToString(), name = m.ResourceName, pId = m.ParentId }).ToList(); } return(model); }