public void Init() { var systemAction = new SystemAction { }; }
public override int GetHashCode() { int hash = 1; if (Type != global::Prisel.Protobuf.PacketType.Default) { hash ^= Type.GetHashCode(); } if (messageCase_ == MessageOneofCase.SystemAction) { hash ^= SystemAction.GetHashCode(); } if (messageCase_ == MessageOneofCase.Action) { hash ^= Action.GetHashCode(); } if (HasRequestId) { hash ^= RequestId.GetHashCode(); } if (status_ != null) { hash ^= Status.GetHashCode(); } if (payload_ != null) { hash ^= Payload.GetHashCode(); } hash ^= (int)messageCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public IActionResult Put([FromODataUri] Guid key, SystemAction systemaction) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } using (var trans = context.Database.BeginTransaction()) { try { if (context.SystemActions.Find(key) == null) { return(NotFound()); } //context = new ApplicationDbContext(context.Options); var local = context.SystemActions.Local.FirstOrDefault(it => it.ActionID.Equals(key)); if (local != null) { context.Entry(local).State = EntityState.Detached; } context.Entry(systemaction).State = EntityState.Modified; context.SaveChanges(); trans.Commit(); return(Ok(systemaction)); } catch (Exception ex) { trans.Rollback(); return(BadRequest(ex)); } } }
private void SystemEvents_SessionSwitch(object sender, Microsoft.Win32.SessionSwitchEventArgs e) { if (e.Reason == SessionSwitchReason.SessionLock) { backgroundManager.StopUnlockTimer(); int OrderNo = commonService.InfoViewModel.SystemActions.First().OrderNo + 1; var sysAction = new SystemAction { OrderNo = OrderNo, CurrentAction = ActionType.Lock, ActionTime = DateTime.Now }; commonService.InfoViewModel.SystemActions.Insert(0, sysAction); backgroundManager.SaveSystemAction(sysAction); } else if (e.Reason == SessionSwitchReason.SessionUnlock) { backgroundManager.StartUnlockTimer(); int OrderNo = commonService.InfoViewModel.SystemActions.First().OrderNo + 1; var sysAction = new SystemAction { OrderNo = OrderNo, CurrentAction = ActionType.Unlock, ActionTime = DateTime.Now }; commonService.InfoViewModel.SystemActions.Insert(0, sysAction); backgroundManager.SaveSystemAction(sysAction); } }
private void TestPermission(SystemAction a, string msg) { if (!this.ActionPermitted(a)) { throw new PermissionException(a, _user, msg); } }
public void WriteFile(SystemAction sysAction) { if (File.Exists(fileName)) { var fileInfo = new FileInfo(fileName); if (fileInfo.Length >= 100000) { string currentTimeString = fileInfo.CreationTime.ToString("yyyyMMddhhmmss"); string backUpFileName = fileInfo.Name.Substring(0, fileInfo.Name.Length - 4) + "_" + currentTimeString + fileInfo.Extension; if (!File.Exists(backUpFileName)) { File.Move(fileName, backUpFileName); } if (File.Exists(fileName)) { File.Delete(fileName); } } } if (!File.Exists(fileName)) { XmlWriterSettings xmlWriterSettings = new XmlWriterSettings(); xmlWriterSettings.Indent = true; xmlWriterSettings.NewLineOnAttributes = true; using (XmlWriter xmlWriter = XmlWriter.Create(fileName, xmlWriterSettings)) { xmlWriter.WriteStartDocument(); xmlWriter.WriteStartElement("SysActions"); xmlWriter.WriteStartElement("Action"); xmlWriter.WriteElementString("OrderNo", sysAction.OrderNo.ToString()); xmlWriter.WriteElementString("CurrentAction", sysAction.CurrentAction.ToString()); xmlWriter.WriteElementString("ActionTime", sysAction.ActionTime.ToString()); xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); xmlWriter.WriteEndDocument(); xmlWriter.Flush(); xmlWriter.Close(); } } else { XDocument xDocument = XDocument.Load(fileName); XElement root = xDocument.Element("SysActions"); IEnumerable <XElement> rows = root.Descendants("Action"); XElement firstRow = rows.First(); firstRow.AddBeforeSelf( new XElement("Action", new XElement("OrderNo", sysAction.OrderNo.ToString()), new XElement("CurrentAction", sysAction.CurrentAction.ToString()), new XElement("ActionTime", sysAction.ActionTime.ToString()) )); xDocument.Save(fileName); } }
/// <summary> /// Does my user have permission to perform this SystemAction? /// </summary> /// <param name="a"></param> /// <returns></returns> public bool ActionPermitted(SystemAction a) { Contract.Ensures( (!_user.HasPermission(a) && Contract.Result<bool>() == false) || (_user.HasPermission(a) && Contract.Result<bool>() == true)); return _user.HasPermission(a); }
/// <summary> /// Does my user have permission to perform this SystemAction? /// </summary> /// <param name="a"></param> /// <returns></returns> public bool ActionPermitted(SystemAction a) { Contract.Ensures( (!_user.HasPermission(a) && Contract.Result <bool>() == false) || (_user.HasPermission(a) && Contract.Result <bool>() == true)); return(_user.HasPermission(a)); }
public bool UserValidate(string controllerName, string actionName, string empNo, string systemName) { SystemControllerBll controller = new SystemControllerBll(); SystemModelBll model = new SystemModelBll(); SystemActionBll action = new SystemActionBll(); SystemPowerBll systemPowerBll = new SystemPowerBll(); try { lock (new object()) { SystemModel modelEntity = (model.Count(c => c.ModelName == systemName) < 1) ? model.AddEntity(new SystemModel() { ModelName = systemName, ModelUrl = "~/" + systemName }) : model.Single(c => c.ModelName == systemName); Entity.MANAGER.SystemController controllerEntity = (controller.Count(c => c.ControllerName == controllerName) < 1) ? controller.AddEntity(new Entity.MANAGER.SystemController { ModelId = modelEntity.ModelId, ControllerName = controllerName, CreateTime = DateTime.Now, IsDisplay = true, }) : controller.Single(c => c.ControllerName == controllerName); SystemAction actionEntity = ( action.Count( c => c.ControllerId == controllerEntity.ControllerId && c.ActionName == actionName) < 1) ? action.AddEntity(new SystemAction() { ControllerId = controllerEntity.ControllerId, ActionName = actionName, ActionDetails = "系统自动添加", }) : action.Single( c => c.ControllerId == controllerEntity.ControllerId && c.ActionName == actionName); return(systemPowerBll.Count(c => c.ActionId == actionEntity.ActionId && c.EmpNo == empNo) > 0); } } catch { return(false); } }
public void AddAction(SystemAction action) { if (this.Actions.Any (a => a.Action.Equals(action))) return; RoleAction ra = new RoleAction { Action = action, RoleID = this.ID }; RoleActionService.Save(ra); this.Actions.Add(ra); }
public void RemoveAction(SystemAction action) { RoleAction actionToRemove = this.Actions.Where(a => a.Action.Equals(action)).SingleOrDefault(); if (actionToRemove == null) return; RoleActionService.Delete(actionToRemove); this.Actions.Remove(actionToRemove); }
public SystemLogModel(string username, string thread, SystemAction action, SystemLogType type, string shortDesc) { Username = username; Thread = thread; Action = action; Type = type; ShortDescription = shortDesc; IsException = false; CreatedDate = DateTime.Now; }
private void SendStatusUpdate(Guid playerId, SystemAction action, QueueFolderTag tag) { var @event = new PlayerRegistrationChecked { DateChecked = DateTimeOffset.UtcNow, Action = action, Tag = tag, PlayerId = playerId }; _bus.Publish(@event); }
public ActionResult <Result <SystemAction> > Get(long id) { try { SystemAction systemAction = _systemActionService.GetById(id); _logger.LogInformation("Get one SystemAction"); return(new Result <SystemAction>(true, "", systemAction)); } catch (Exception ex) { _logger.LogError(ex, "Error occurred on SystemAction getting"); throw ex; } }
public ActionResult <Result <SystemAction> > Post([FromBody] SystemAction model) { try { _systemActionService.Add(model); _logger.LogInformation("Added one SystemAction"); return(new Result <SystemAction>(true, "SystemAction added successfully")); } catch (Exception ex) { _logger.LogError(ex, "Error occurred on SystemAction adding"); throw ex; } }
public ActionResult <Result <SystemAction> > Patch(long id, [FromBody] SystemAction model) { try { _systemActionService.Update(model, id); _logger.LogInformation("Updated one SystemAction"); return(new Result <SystemAction>(true, "SystemAction updated successfully")); } catch (Exception ex) { _logger.LogError(ex, "Error occurred on SystemAction updating"); throw ex; } }
public static EntityId ECS_SYSTEM <T1>(World world, SystemAction <T1> systemImpl, SystemKind kind, SystemSignatureBuilder signatureBuilder) where T1 : unmanaged { SystemActionDelegate del = delegate(ref Rows rows) { var set1 = (T1 *)_ecs.column(ref rows, Heap.SizeOf <T1>(), 1); systemImpl(ref rows, new Span <T1>(set1, (int)rows.count), ecs.get_delta_time(world)); }; // ensure our system doesnt get GCd and that our Component is registered Caches.AddSystemAction(world, del); var systemNamePtr = Caches.AddUnmanagedString(systemImpl.Target.GetType().FullName); return(ecs.new_system(world, systemNamePtr, kind, signatureBuilder.Build(), del)); }
public static EntityId ECS_SYSTEM <T1>(World world, SystemAction <T1> systemImpl, SystemKind kind) where T1 : unmanaged { SystemActionDelegate del = delegate(ref Rows rows) { var set1 = (T1 *)_ecs.column(ref rows, Heap.SizeOf <T1>(), 1); systemImpl(ref rows, new Span <T1>(set1, (int)rows.count)); }; // ensure our system doesnt get GCd and that our Component is registered Caches.AddSystemAction(world, del); Caches.GetComponentTypeId <T1>(world); var systemNamePtr = Caches.AddUnmanagedString(systemImpl.Method.Name); return(ecs.new_system(world, systemNamePtr, kind, typeof(T1).Name, del)); }
private long? InsertSystemAction(string guidString) { var actionToInsert = new SystemAction { Action = "TestAction", ActionGuid = new Guid(guidString), ActionType = SystemActionType.Create, Area = "TestArea", Controller = "TestController", Module = new SystemModule{ Id = 1 }, Title = "TestTitle" }; Repository.Insert(actionToInsert); insertedSystemAction = actionToInsert; return insertedSystemAction.Id; }
public async Task <bool> CheckControllerNameActionNameAsync(string sAreaName, string sControllerName, string sActionName, int iActionId) { SystemAction entitySystemAction = await _systemActionRepository.SelectAsync(iActionId); if (entitySystemAction != null) { SystemController entitySystemController = await _systemControllerService.SelectAsync(entitySystemAction.IcontrollerId); if (entitySystemController != null) { if (sAreaName == "Admin" && sControllerName == entitySystemController.ScontrollerName && sActionName == entitySystemAction.SactionName.Replace("Async", string.Empty)) { return(true); } } } return(false); }
public void ApplyAction(Guid playerId) { var repository = _container.Resolve <IFraudRepository>(); var duplicateScoreService = _container.Resolve <IDuplicateScoreService>(); var player = repository.Players.FirstOrDefault(x => x.Id == playerId); if (player == null) { return; } var score = duplicateScoreService.ScorePlayer(playerId); var configuration = repository .DuplicateMechanismConfigurations .FirstOrDefault(x => x.BrandId == player.BrandId); if (configuration == null) { return; } SystemAction action = SystemAction.NoAction; QueueFolderTag tag = QueueFolderTag.NoHandling; if (score > configuration.NoHandlingScoreMin && score <= configuration.NoHandlingScoreMax) { action = configuration.NoHandlingSystemAction; tag = QueueFolderTag.NoHandling; } else if (score > configuration.FraudulentScoreMin && score <= configuration.FraudulentScoreMax) { action = configuration.FraudulentSystemAction; tag = QueueFolderTag.Fraudlent; } else if (score > configuration.RecheckScoreMin && score <= configuration.RecheckScoreMax) { action = configuration.RecheckSystemAction; tag = QueueFolderTag.ReCheck; } SendStatusUpdate(playerId, action, tag); }
/// <summary> /// 获取当前页面的action集合 /// </summary> /// <param name="eid"></param> /// <param name="RoleTid"></param> /// <param name="currentMenuTid"></param> /// <returns></returns> public async Task <SystemAction> GetSystemUserActions(string eid, long RoleTid, long currentMenuTid) { var result = new SystemAction { IsGod = false, ActionList = new List <string>() }; if (GlobalSetting.GoldList.Contains(eid)) { result.IsGod = true; return(result); } if (string.IsNullOrEmpty(eid) || RoleTid < 1 || currentMenuTid < 1) { return(result); } var role = await this.Entity.FirstOrDefaultAsync(r => r.Tid.Equals(RoleTid)); if (role == null) { return(result); } if (string.IsNullOrEmpty(role.ActionList)) { role.ActionList = "[]"; } var actionList = JsonConvert.DeserializeObject <List <MenuActionSM> >(role.ActionList) .ToDictionary(r => r.MenuTid, g => g.ActionList); if (!actionList.ContainsKey(currentMenuTid)) { return(result); } result.IsGod = false; result.ActionList = actionList[currentMenuTid].Select(r => r.ActionId).ToList(); return(result); }
private void UpdatePlayer(SystemAction action, Guid playerId, string fraudTypeName, string remarks) { var player = _repository.Players.Single(x => x.Id == playerId); player.FolderAction = action; player.HandledDate = DateTimeOffset.UtcNow; player.CompletedDate = DateTimeOffset.UtcNow; player.FraudType = fraudTypeName; player.SignUpRemark = remarks; _repository.SaveChanges(); var @event = new PlayerRegistrationChecked { DateChecked = DateTimeOffset.UtcNow, Action = action, Tag = QueueFolderTag.Completed, PlayerId = playerId }; _bus.Publish(@event); }
public async Task <string> AddOrModifyAsync([FromForm] SystemAction model) { BaseResult baseResult = new BaseResult(); try { if (model != null) { SystemActionValidation validationRules = new SystemActionValidation(); ValidationResult validationResult = await validationRules.ValidateAsync(model); if (validationResult.IsValid) { if (await _systemActionService.AddOrModifySystemActionAsync(model, User.Identity.Name) != null) { baseResult.Code = 0; baseResult.Msg = "操作成功!"; } else { baseResult.Code = 1; baseResult.Msg = "操作失败!"; } } else { baseResult.Code = 3; baseResult.Msg = validationResult.ToString("<br>"); } } } catch (Exception ex) { baseResult.Code = 3; baseResult.Msg = ex.Message; } return(JsonHelper.ObjectToJSON(baseResult)); }
public async Task <SystemAction> AddOrModifySystemActionAsync(SystemAction model, string sOperator) { SystemAction entitySystemAction; if (model.Id == 0) { entitySystemAction = model; await _systemActionRepository.AppendAsync(entitySystemAction, sOperator); } else { entitySystemAction = await _systemActionRepository.SelectAsync(model.Id); if (entitySystemAction != null) { entitySystemAction.SactionName = model.SactionName; entitySystemAction.IcontrollerId = model.IcontrollerId; entitySystemAction.SresultType = model.SresultType; _systemActionRepository.Update(entitySystemAction, sOperator); } } return(entitySystemAction); }
protected void btnSave_ServerClick(object sender, EventArgs e) { if (nFunctionId <= 0) { PageUtil.PageAlert(this.Page, "请选择操作所属功能!"); return; } string strActionName = txt_Name.Value.Trim(); string strKey = txt_Key.Value.Trim(); string strControlName = txt_ControlName.Value.Trim(); if (string.IsNullOrEmpty(strActionName) || string.IsNullOrEmpty(strKey) || string.IsNullOrEmpty(strControlName)) return; SystemAction oAction = SystemAction.Get(nId); if (null == oAction) { oAction = new SystemAction(); oAction.FunctionId = nFunctionId; } PageUtil.PageFillEntity<SystemAction>(this, oAction); SystemAction.Save(oAction); PageUtil.PageAlert(this.Page, "保存成功!"); }
public IActionResult Post(SystemAction systemaction) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } using (var trans = context.Database.BeginTransaction()) { try { context.SystemActions.Add(systemaction); context.SaveChanges(); trans.Commit(); return(Ok(systemaction)); } catch (Exception ex) { trans.Rollback(); return(BadRequest(ex)); } } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); bool createNew; oneInstanceMutex = new Mutex(false, "BgInfo_OneInstanceMutex", out createNew); if (!createNew) { MessageBox.Show("Am running already!", "SimpleMan Blues", MessageBoxButton.OK, MessageBoxImage.Asterisk); Shutdown(); return; } commonService = CommonService.GetInstance(); mainWindow = new Blues.MainWindow(); commonService.CurrentMainWindow = mainWindow; infoWindow = new InfoWindow(); commonService.CurrentInfoWindow = infoWindow; backgroundManager = BackgroundManager.GetInstance(); backgroundManager.InitTray(); backgroundManager.StartUnlockTimer(); mainWindow.Show(); var sysAction = new SystemAction { OrderNo = 1, CurrentAction = ActionType.StartUp, ActionTime = DateTime.Now }; commonService.InfoViewModel.SystemActions.Add(sysAction); backgroundManager.SaveSystemAction(sysAction); Microsoft.Win32.SystemEvents.SessionSwitch += SystemEvents_SessionSwitch; }
public void AddAction(char sign, bool isDrawabale, SystemAction action) { _actions[sign] = new ActionData(isDrawabale, action); }
public ActionData(bool isDrawable, SystemAction action) { IsDrawable = isDrawable; Action = action; }
public PermissionException(SystemAction systemAction, User user, string msg = "You don't have permission to perform this SystemAction.") : base(msg) { _systemAction = systemAction; _user = user; }
public async Task <SystemAction> SelectAsync(SystemAction entitySystemAction = null, string sOperator = null, int iOrderGroup = 0, string sSortName = null, string sSortOrder = null) { return(await _systemActionRepository.SelectAsync(entitySystemAction, sOperator, iOrderGroup, sSortName, sSortOrder)); }
public async Task <IActionResult> Update([FromBody] List <UpdateSystemActionViewModel> listmodel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } List <SystemAction> screensUpdate = new List <SystemAction>(); List <SystemAction> screensAdd = new List <SystemAction>(); List <SystemAction> screensRemove = new List <SystemAction>(); //Actualiza masivamente foreach (var item in listmodel) { if (item.Id == null && item.IsNew == true) { SystemAction systemScreen = new SystemAction { Enabled = item.Enabled, SystemScreenId = item.SystemScreenId, Code = item.Code, Description = item.Description }; screensAdd.Add(systemScreen); } else { //Si no es a borrar, el modelo SystemAction systemScreen = _context.SystemAction.Find(item.Id); //Ahora me fijo si lo elimino o lo actualizo if (item.IsRemoved) { screensRemove.Add(systemScreen); } else { systemScreen.Enabled = item.Enabled; systemScreen.Code = item.Code; systemScreen.Description = item.Description; systemScreen.SystemScreenId = item.SystemScreenId; screensUpdate.Add(systemScreen); } } } //Agrego _context.SystemAction.AddRange(screensAdd); //Actualizo _context.SystemAction.UpdateRange(screensUpdate); //Borro _context.SystemAction.RemoveRange(screensRemove); try { await _context.SaveChangesAsync(); } catch (Exception ex) { return(BadRequest()); } return(Ok()); }
public SystemAction Select(SystemAction entitySystemAction = null, string sOperator = null, int iOrderGroup = 0, string sSortName = null, string sSortOrder = null) { return(_systemActionRepository.Select(entitySystemAction, sOperator, iOrderGroup, sSortName, sSortOrder)); }
public bool HasPermission(SystemAction a) { return(Validated && _permissions.Contains(a)); }
//[ValidateAntiForgeryToken] public async Task <string> ReflectionController() { BaseResult baseResult = new BaseResult(); try { List <SystemController> lstSystemController = new List <SystemController>(); List <SystemAction> lstSystemAction = new List <SystemAction>(); Assembly[] arrAssembly = AppDomain.CurrentDomain.GetAssemblies(); List <MethodInfo> lstMethodInfoController = new List <MethodInfo>(); for (int i = 0; i < arrAssembly.Length; i++) { if (arrAssembly[i].GetName().Name.Equals("Microsoft.AspNetCore.Mvc.ViewFeatures")) { foreach (Type item in arrAssembly[i].GetModule("Microsoft.AspNetCore.Mvc.ViewFeatures.dll").GetTypes()) { if (item.Name.Equals("Controller")) { lstMethodInfoController.AddRange(item.GetMethods()); break; } } } } for (int i = 0; i < arrAssembly.Length; i++) { if (arrAssembly[i].GetName().Name.Equals("Message.UI")) { foreach (Type item in arrAssembly[i].GetModule("Message.UI.dll").GetTypes()) { if (!string.IsNullOrWhiteSpace(item.Namespace)) { if (item.Namespace.ToString().Equals("Message.UI.Areas.Admin.Controllers") && item.Name.EndsWith("Controller")) { if (item.Name == "BaseAdminController") { continue; } SystemController entity = new SystemController() { ScontrollerName = item.Name.Replace("Controller", string.Empty) }; if (entity.ScontrollerName == "System") { entity.ScontrollerName += "Controller"; } lstSystemController.Add(entity); SystemController entitySystemController = await _SystemControllerService.SelectAsync(new SystemController() { ScontrollerName = entity.ScontrollerName }); if (entitySystemController == null) { await _SystemControllerService.AppendAsync(entity, User.Identity.Name); } else { entity.Id = entitySystemController.Id; } foreach (MethodInfo entityMethodInfo in item.GetMethods(BindingFlags.Instance | BindingFlags.Public)) { if (!lstMethodInfoController.Exists(x => x.Name.Equals(entityMethodInfo.Name))) { SystemAction entitySystemAction = new SystemAction() { IcontrollerId = entity.Id, SactionName = entityMethodInfo.Name, SresultType = entityMethodInfo.ReturnType.Name }; if (_systemActionService.Select(entitySystemAction) == null) { await _systemActionService.AppendAsync(entitySystemAction, User.Identity.Name); } } } } } } } } baseResult.Code = 0; baseResult.Msg = "操作成功!"; } catch (Exception ex) { baseResult.Code = 3; baseResult.Msg = ex.Message; throw; } return(JsonHelper.ObjectToJSON(baseResult)); }
protected void btn_UpdateModule_Click(object sender, EventArgs e) { txt_UpdateResult.Value = ""; string strConfigFullName = file_ModuleConfig.Value; if (string.IsNullOrEmpty(strConfigFullName)) { _setMessage("请先选择模块配置文件!", true); return; } string strFileName = System.IO.Path.GetFileName(strConfigFullName); string strFileEx = strFileName.Substring(strFileName.IndexOf(".")); if (strFileEx != ".cfg.xml") { _setMessage("请上传文件后缀名称为“.cfg.xml”的配置文件!", true); return; } string strUploadPath = string.Format("{0}\\{1}", Server.MapPath(SystemUtil.GetVirtualSysUploadPath()), strFileName); try { file_ModuleConfig.PostedFile.SaveAs(strUploadPath); _setMessage("上传配置文件成功!", true); } catch (Exception ee) { _setMessage("上传配置文件失败!", true); _setMessage("程序终止!", true); return; } XmlDocument xmlModuleConfig = new XmlDocument(); try { xmlModuleConfig.Load(strUploadPath); _setMessage("读取配置文件成功!", true); } catch (Exception ee) { _setMessage("读取配置文件失败!", true); _setMessage("程序终止!", true); return; } //模块配置文件有效性验证 if (!_vModuleConfig(xmlModuleConfig)) return; XmlNode moduleNode = xmlModuleConfig.SelectSingleNode("Module"); //if (!_vModuleNode(moduleNode)) // return; Hashtable htFns = new Hashtable(); //该模块下的所有功能 //配置模块基本信息 string strModuleKey = _GetChildNodeText(moduleNode, "Key"); SystemModule oModuleExist = SystemModule.Get(strModuleKey); bool bModuleAdd = null == oModuleExist; if (bModuleAdd) { oModuleExist = new SystemModule(); oModuleExist.Key = strModuleKey; } oModuleExist.Name = _GetChildNodeText(moduleNode, "Name"); oModuleExist.Description = _GetChildNodeText(moduleNode, "Description"); oModuleExist.Controller = _GetChildNodeText(moduleNode, "Controller"); oModuleExist.IconName = _GetChildNodeText(moduleNode, "IconName"); oModuleExist.OrderId = TypeUtil.ParseInt(_GetChildNodeText(moduleNode, "OrderId"), 1); int nModuleId = SystemModule.Save(oModuleExist); _setMessage("模块信息保存" + (nModuleId <= 0 ? "失败!" : "成功!"), true); if(nModuleId <= 0) return; //检测模块功能根节点是否自动新增 SystemFunction rootFn = SystemFunction.Get(strModuleKey); if (null == rootFn) { _setMessage(string.Format("模块根节点不存在!"), true); return; } //配置模块功能信息 XmlNodeList nlFnsRoot = moduleNode.SelectNodes("Functions/Function"); foreach (XmlNode nodeRootFn in nlFnsRoot) { //if (!_vFnNode(nodeRootFn)) // return; string strFnKey = _GetChildNodeText(nodeRootFn, "Key"); SystemFunction oFnExist = SystemFunction.Get(strFnKey); bool bFnAdd = null == oFnExist; if (bFnAdd) { oFnExist = new SystemFunction(); oFnExist.Key = strFnKey; oFnExist.Level = 2; } oFnExist.ParentId = rootFn.Id; oFnExist.ModuleId = nModuleId; oFnExist.Name = _GetChildNodeText(nodeRootFn, "Name"); oFnExist.Description = _GetChildNodeText(nodeRootFn, "Description"); oFnExist.IconName = _GetChildNodeText(nodeRootFn, "IconName"); oFnExist.OrderId = TypeUtil.ParseInt(_GetChildNodeText(nodeRootFn, "OrderId"), 1); int nFnId = SystemFunction.Save(oFnExist); if (nFnId <= 0) { _setMessage(string.Format("功能“{0}”信息保存失败!", oFnExist.Name), true); continue; } _setMessage(string.Format("功能“{0}”信息保存成功!", oFnExist.Name), true); if (!bModuleAdd) { htFns[strFnKey] = 1; } //功能Action信息保存 Hashtable htActions = new Hashtable(); XmlNodeList nlActions = nodeRootFn.SelectNodes("Actions/Action"); foreach (XmlNode nodeAction in nlActions) { //if (!_vActionNode(nodeAction)) // return; string strActionKey = _GetChildNodeText(nodeAction, "Key"); SystemAction oActionExist = SystemAction.Get(strActionKey); bool bActionAdd = null == oActionExist; if (bActionAdd) { oActionExist = new SystemAction(); oActionExist.Key = strActionKey; } oActionExist.FunctionId = nFnId; oActionExist.Name = _GetChildNodeText(nodeAction, "Name"); oActionExist.Description = _GetChildNodeText(nodeAction, "Description"); oActionExist.ActionType = _GetChildNodeText(nodeAction, "ActionType"); oActionExist.ActionValue = _GetChildNodeText(nodeAction, "ActionValue"); oActionExist.IsDefault = TypeUtil.ParseInt(_GetChildNodeText(nodeAction, "IsDefault"), 2); oActionExist.ControlName = _GetChildNodeText(nodeAction, "ControlName"); oActionExist.Tip = _GetChildNodeText(nodeAction, "Tip"); oActionExist.IconName = _GetChildNodeText(nodeAction, "IconName"); oActionExist.Target = _GetChildNodeText(nodeAction, "Target"); oActionExist.EntityCount = TypeUtil.ParseInt(_GetChildNodeText(nodeAction, "EntityCount"), 0); oActionExist.IsPopup = TypeUtil.ParseInt(_GetChildNodeText(nodeAction, "IsPopup"), 2); oActionExist.Width = TypeUtil.ParseInt(_GetChildNodeText(nodeAction, "Width"), 0); oActionExist.Height = TypeUtil.ParseInt(_GetChildNodeText(nodeAction, "Height"), 0); oActionExist.IsResize = TypeUtil.ParseInt(_GetChildNodeText(nodeAction, "IsResize"), 2); oActionExist.IsMove = TypeUtil.ParseInt(_GetChildNodeText(nodeAction, "IsMove"), 2); oActionExist.IsIncludeMinBox = TypeUtil.ParseInt(_GetChildNodeText(nodeAction, "IsIncludeMinBox"), 2); oActionExist.IsIncludeMaxBox = TypeUtil.ParseInt(_GetChildNodeText(nodeAction, "IsIncludeMaxBox"), 2); oActionExist.IsShowInTaskBar = TypeUtil.ParseInt(_GetChildNodeText(nodeAction, "IsShowInTaskBar"), 2); oActionExist.OrderId = TypeUtil.ParseInt(_GetChildNodeText(nodeAction, "OrderId"), 1); int nActionId = SystemAction.Save(oActionExist); if (nActionId <= 0) { _setMessage(string.Format("功能“{0}”的动作“{1}”信息保存失败!", oFnExist.Name, oActionExist.Name), true); continue; } if (!bFnAdd) { htActions[strActionKey] = 1; } } //删除该功能下的冗余操作(Action) if (!bFnAdd) { SystemAction[] alAtions = SystemAction.GetFunctionAction(nFnId); foreach (SystemAction action in alAtions) { if (!htActions.ContainsKey(action.Key)) SystemAction.Delete(action.Id); } _setMessage(string.Format("删除功能【{0}】冗余操作(Action)完成!", oFnExist.Name), true); } } ////删除该模块下的冗余功能(Function) if (!bModuleAdd) { SystemFunction moduleRootFn = SystemFunction.Get(strModuleKey); if(null == moduleRootFn) { _setMessage("删除模块冗余功能(Function)失败!", true); return; } SystemFunction[] alFns = SystemFunction.GetFunctions(moduleRootFn.Id, false); foreach (SystemFunction function in alFns) { if (!htFns.ContainsKey(function.Key)) SystemFunction.Delete(function.Id); } _setMessage("删除模块冗余功能(Function)成功!", true); } _setMessage("模块配置完成,请刷新浏览器!", true); }
public bool HasPermission(SystemAction a) { return Validated && _permissions.Contains(a); }
public async Task <int> AppendAsync(SystemAction entitySystemAction, string sOperator) { return(await _systemActionRepository.AppendAsync(entitySystemAction, sOperator)); }
private void TestPermission(SystemAction a, string msg) { if (!this.ActionPermitted(a)) throw new PermissionException(a, _user, msg); }
private SystemAction InsertNonLoadedSystemActionIntoDatabase() { var systemAction = new SystemAction { Title = "Bleep", Action = "Bleep", ActionGuid = Guid.NewGuid(), ActionType = SystemActionType.Folder, Area = "Bleep", Controller = "Bleep", Module = new SystemModule { Id = 1 } }; systemAction.Id = Repository.Insert(systemAction); return systemAction; }