/// <summary> /// 新增 /// </summary> /// <param name="queryModel"></param> /// <returns></returns> public bool Add(FunctionModel queryModel) { Esmart_Sys_Functions functions = new Esmart_Sys_Functions() { AppId = queryModel.AppId, CreateId = queryModel.CreateId, CreateTime = DateTime.Now, FunctionKey = queryModel.FunctionKey, FunctionName = queryModel.FunctionName, Remark = queryModel.Remark }; return(FunctionDbAction.Add(functions)); }
private string GenerateIdentifierName(Function function, FunctionModel model) { if (function == null) { throw new ArgumentNullException(nameof(function)); } return(CreateIdentifier(GenerateUniqueName(function, model))); }
/// <summary> /// 更新 /// </summary> /// <param name="queryModel"></param> /// <returns></returns> public bool Update(FunctionModel queryModel) { Esmart_Sys_Functions functions = new Esmart_Sys_Functions() { AppId = queryModel.AppId, CreateId = queryModel.CreateId, FunctionKey = queryModel.FunctionKey, FunctionName = queryModel.FunctionName, Remark = queryModel.Remark, FunctionId = queryModel.FunctionId }; return(FunctionDbAction.Update(functions)); }
private async Task ApplyIndividualDefaultApplication(SecurityContractDefaultConfigurationApplication defaultApplication, Guid updatedById) { // Ensure that the application actually exists. Obtain all the application function relations too, as they will be used for validation. var application = await applicationRepository.GetByNameAsync(defaultApplication.Name); if (application == null) { logger.Warn($"Application '{defaultApplication.Name}' does not exist! Skipping and ignoring default application configuration for this application."); return; } if (defaultApplication.Functions == null || defaultApplication.Functions.Count == 0) { logger.Warn($"Default application '{defaultApplication.Name}' has no 'functions' configuration. Ignoring default configuration for this application."); return; } // Use the currrent state of the assigned application functions to determine which ones are potentially no longer in the YAML. await DetectFunctionsRemovedFromSecurityContractDefaultsAndRemoveFromApplication(application, defaultApplication.Functions); // Reset the state of the application functions, as the security contract declares the desired state and we have already used to the historic state // to clear any functions that don't appear within the security contract. application.Functions = new List <FunctionModel>(); application.ChangedBy = updatedById; foreach (var defaultFunction in defaultApplication.Functions) { if (defaultFunction.Permissions == null || defaultFunction.Permissions.Count == 0) { break; } var functionModelToAdd = new FunctionModel(); // check to see if there is an existing function. var existingFunction = await functionRepository.GetByNameAsync(defaultFunction.Name); if (existingFunction != null) { functionModelToAdd = existingFunction; } functionModelToAdd.Application = application; functionModelToAdd.Description = defaultFunction.Description; functionModelToAdd.Name = defaultFunction.Name; functionModelToAdd.ChangedBy = updatedById; // Clear the current permissions assigned to the function as they are to be re-created. functionModelToAdd.FunctionPermissions = new List <FunctionPermissionModel>(); AddPermissionsToFunctionsEnsuringTheyExistsAndAreAssigedToTheApplication(application, defaultFunction, defaultApplication, functionModelToAdd, updatedById); } // Update the application with its new application function state. await applicationRepository.Update(application); }
public void Test_RemoveSetPropertyMemberKeepsEdges([Values] TestingMode mode) { // test that removing a SetProperty member doesn't break the edge with it's Instance // i.e. here: check that removing Position keeps the link with Transform // |_TestFunction_____| // (Transform)---+-o Set Property | // | o Position | VariableDeclarationModel trDecl = GraphModel.CreateGraphVariableDeclaration("tr", typeof(Transform).GenerateTypeHandle(Stencil), true); IVariableModel trVar = GraphModel.CreateVariableNode(trDecl, Vector2.left); FunctionModel method = GraphModel.CreateFunction("TestFunction", Vector2.zero); SetPropertyGroupNodeModel setters = method.CreateSetPropertyGroupNode(0); GraphModel.CreateEdge(setters.InstancePort, trVar.OutputPort); PropertyInfo propertyToAdd = typeof(Transform).GetProperty("position"); var newMember = new TypeMember { Path = new List <string> { propertyToAdd?.Name }, Type = propertyToAdd.GetUnderlyingType().GenerateTypeHandle(Stencil) }; setters.AddMember(newMember); TestPrereqActionPostreq(mode, () => { RefreshReference(ref method); RefreshReference(ref setters); Assert.That(GetNodeCount(), Is.EqualTo(2)); Assert.That(GetEdgeCount(), Is.EqualTo(1)); Assert.That(method.NodeModels.Count(), Is.EqualTo(1)); Assert.That(setters.InputsByDisplayOrder.Count, Is.EqualTo(2)); Assert.That(setters.Members.Count, Is.EqualTo(1)); return(new EditPropertyGroupNodeAction( EditPropertyGroupNodeAction.EditType.Remove, setters, newMember)); }, () => { RefreshReference(ref method); RefreshReference(ref setters); Assert.That(GetNodeCount(), Is.EqualTo(2)); Assert.That(GetEdgeCount(), Is.EqualTo(1)); Assert.That(method.NodeModels.Count(), Is.EqualTo(1)); Assert.That(GetStackedNode(0, 0), Is.TypeOf <SetPropertyGroupNodeModel>()); Assert.That(setters.InputsByDisplayOrder.Count, Is.EqualTo(1)); Assert.That(setters.Members.Count, Is.EqualTo(0)); }); }
private async Task CheckForApplicationAndAssignToFunctionIfExists(FunctionModel function, FunctionSubmit functionSubmit) { var application = await applicationRepository.GetByIdAsync(functionSubmit.ApplicationId); if (application == null) { throw new ItemNotFoundException($"Application with UUID: '{functionSubmit.ApplicationId}' not found. Cannot create function '{functionSubmit.Name}' with this application."); } function.Application = application; }
static State CreateFunction(State previousState, CreateFunctionAction action) { VSGraphModel graphModel = (VSGraphModel)previousState.CurrentGraphModel; FunctionModel functionModel = graphModel.CreateFunction(action.Name, action.Position); previousState.EditorDataModel.ElementModelToRename = functionModel; previousState.MarkForUpdate(UpdateFlags.RequestRebuild); return(previousState); }
public ActionResult Detail(string ma) { ViewBag.Parent = new SelectList(new FunctionDao().load(), "Id", "Name"); FunctionModel model = new FunctionModel(); if (ma != null) { model = new FunctionDao().detail(ma); } return(PartialView("_DetailFunction", model)); }
private string GenerateUniqueName(Function function, FunctionModel model) { var numberOfNames = model.Functions.Where(p => p.Name == function.Name).Count(); if (numberOfNames > 1) { return(function.Name + CultureInfo.InvariantCulture.TextInfo.ToTitleCase(function.Schema)); } return(function.Name); }
public async Task <IActionResult> Create([Bind("Id,Name,ShouldExecuteDelegate,Script,Order,IsActive,Created,Imports,References")] FunctionModel functionModel) { if (ModelState.IsValid) { _context.Add(functionModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(functionModel)); }
public JsonResult FunctionEdit(FunctionModel model) { ResponseModel <int> responser = new ResponseModel <int>(); if (!_functionService.SaveFunction(model)) { responser.Header.ReturnCode = 1; responser.Header.Message = "Fail"; } return(Json(responser)); }
public GraphElementSearcherDatabase AddGraphsMethods() { string[] assetGUIDs = AssetDatabase.FindAssets($"t:{typeof(VSGraphAssetModel).Name}"); List <Tuple <IGraphModel, FunctionModel> > methods = assetGUIDs.SelectMany(assetGuid => { string assetPath = AssetDatabase.GUIDToAssetPath(assetGuid); VSGraphAssetModel graphAssetModel = AssetDatabase.LoadAssetAtPath <VSGraphAssetModel>(assetPath); if (!graphAssetModel || graphAssetModel.GraphModel == null) { return(Enumerable.Empty <Tuple <IGraphModel, FunctionModel> >()); } var functionModels = graphAssetModel.GraphModel.NodeModels.OfExactType <FunctionModel>() .Select(fm => new Tuple <IGraphModel, FunctionModel>(fm.GraphModel, fm)); return(functionModels.Concat(graphAssetModel.GraphModel.NodeModels.OfExactType <EventFunctionModel>() .Select(fm => new Tuple <IGraphModel, FunctionModel>(fm.GraphModel, fm)))); }).ToList(); if (methods.Count == 0) { return(this); } TypeHandle voidTypeHandle = typeof(void).GenerateTypeHandle(Stencil); foreach (Tuple <IGraphModel, FunctionModel> method in methods) { IGraphModel graphModel = method.Item1; FunctionModel functionModel = method.Item2; string graphName = graphModel.AssetModel.Name; SearcherItem graphRoot = SearcherItemUtility.GetItemFromPath(Items, $"{k_Graphs}/{graphName}"); if (functionModel.ReturnType == voidTypeHandle) { graphRoot.AddChild(new StackNodeModelSearcherItem( new FunctionRefSearcherItemData(graphModel, functionModel), data => data.CreateFunctionRefCallNode(functionModel), () => $"{k_Function} {functionModel.Title}" )); continue; } graphRoot.AddChild(new GraphNodeModelSearcherItem( new FunctionRefSearcherItemData(graphModel, functionModel), data => data.CreateFunctionRefCallNode(functionModel), () => $"{k_Function} {functionModel.Title}" )); } return(this); }
private async Task CheckForSubRealmAndAssignToFunctionIfExists(FunctionModel function, FunctionSubmit functionSubmit) { // Recall that submit models with empty GUIDs will not be null but rather Guid.Empty. if (functionSubmit.SubRealmId == null || functionSubmit.SubRealmId == Guid.Empty) { return; } var existingSubRealm = await subRealmRepository.GetByIdAsync(functionSubmit.SubRealmId, false); function.SubRealm = existingSubRealm ?? throw new ItemNotFoundException($"Sub-realm with ID '{functionSubmit.SubRealmId}' does not exist."); }
private void getFunctionPageData(int pageIndex, int pageSize) { #if DEBUG System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start(); #endif //pageRepuestParams.SortField = "LastUpdatedTime"; pageRepuestParams.SortOrder = "desc"; pageRepuestParams.PageIndex = pageIndex; pageRepuestParams.PageSize = pageSize; //_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); //Console.WriteLine(await (await _httpClient.GetAsync("/api/service/EnterpriseInfo/Get?id='1'")).Content.ReadAsStringAsync()); var result = Utility.Http.HttpClientHelper.PostResponse <OperationResult <PageResult <FunctionModel> > >(GlobalData.ServerRootUri + "FunctionManager/PageData", Utility.JsonHelper.ToJson(pageRepuestParams)); #if DEBUG stopwatch.Stop(); Utility.LogHelper.Info("获取功能信息用时(毫秒):" + stopwatch.ElapsedMilliseconds); Utility.LogHelper.Info("功能信息内容:" + Utility.JsonHelper.ToJson(result)); #endif if (!Equals(result, null) && result.Successed) { Application.Current.Resources["UiMessage"] = result?.Message; LogHelper.Info(Application.Current.Resources["UiMessage"].ToString()); if (result.Data.Data.Any()) { FunctionInfoList = new ObservableCollection <FunctionModel>(); foreach (var data in result.Data.Data) { FunctionModel modelData = new FunctionModel(); modelData = data; modelData.PropertyChanged += OnPropertyChangedCommand; FunctionInfoList.Add(modelData); } } else { FunctionInfoList?.Clear(); Application.Current.Resources["UiMessage"] = "未找到数据"; } } else { //操作失败,显示错误信息 FunctionInfoList = new ObservableCollection <FunctionModel>(); Application.Current.Resources["UiMessage"] = result?.Message ?? "查询功能信息失败,请联系管理员!"; } }
private void PerformSubrealmCheck(FunctionModel function, PermissionModel permission) { // If there is a Sub-Realm associated with function, we must ensure that the permission is associated with the same sub realm. if (function.SubRealm != null) { var subRealmPermission = permission.SubRealmPermissions.FirstOrDefault(psrp => psrp.SubRealm.Id == function.SubRealm.Id); if (subRealmPermission == null) { throw new ItemNotProcessableException($"Attempting to add a permission with ID '{permission.Id}' to a function within the '{function.SubRealm.Name}' sub-realm but the permission does not exist within that sub-realm."); } } }
public ActionResult Edit(FunctionModel model) { if (ModelState.IsValid) { _funService.EditFunction(model); return(Json(AjaxResult.Success())); } else { var erros = GetModelErrors(); return(Json(AjaxResult.Fail(erros))); } }
static void AddSharedComponentIfCriteriaMatch(VSGraphModel graphModel, FunctionModel onUpdateEntities) { var entityInstance = graphModel.CreateVariableNode( onUpdateEntities.FunctionParameterModels.Single( p => p.DataType == typeof(Entity).GenerateTypeHandle(graphModel.Stencil) ), Vector2.zero); var addComponent = onUpdateEntities.CreateStackedNode <AddComponentNodeModel>("add"); addComponent.ComponentType = typeof(DummySharedComponent).GenerateTypeHandle(graphModel.Stencil); graphModel.CreateEdge(addComponent.EntityPort, entityInstance.OutputPort); addComponent.DefineNode(); }
public void Test_FunctionVariableDeclarationsIsSerializedInGraphAsset() { VSGraphAssetModel graphAssetModel = (VSGraphAssetModel)GraphAssetModel.Create("test", "Assets/MyGraphTest.asset", typeof(VSGraphAssetModel)); VSGraphModel graph = graphAssetModel.CreateVSGraph <ClassStencil>("test"); FunctionModel method = graph.CreateFunction("TestFunction", Vector2.zero); VariableDeclarationModel declaration = method.CreateFunctionVariableDeclaration("var", typeof(int).GenerateTypeHandle(graph.Stencil)); string nodeModelPath = AssetDatabase.GetAssetPath(declaration.InitializationModel.NodeAssetReference); string graphAssetModelPath = AssetDatabase.GetAssetPath(graphAssetModel); Assert.That(nodeModelPath, Is.EqualTo(graphAssetModelPath)); AssetDatabase.DeleteAsset(graphAssetModelPath); }
public FunctionModel GetFunctioneById(int id) { var function = new FunctionModel(); if (id > 0) { function = _functionRepository.Queryable() .Where(r => r.Id == id) .AsNoTracking() .FirstOrDefault() .ToModel(); } return(function); }
public ActionResult Delete(string Code) { try { FunctionModel TModel = new FunctionModel(); TModel.FunctionId = Code; return(PartialView("DeleteView", TModel)); } catch (Exception ex) { Errorlog.ErrorManager.LogError(ex); return(PartialView()); } }
public ResponseFunction Validate_MasterFunction(FunctionModel data) { ResponseFunction resp = new ResponseFunction(); try { if (string.IsNullOrEmpty(data.code)) { resp.status = StatusResponse.Error; resp.message = "Code is required."; return(resp); } if (string.IsNullOrEmpty(data.name_thai)) { resp.status = StatusResponse.Error; resp.message = "Name Thai is required."; return(resp); } if (string.IsNullOrEmpty(data.name_eng)) { resp.status = StatusResponse.Error; resp.message = "Name English is required."; return(resp); } if (string.IsNullOrEmpty(data.route_path)) { resp.status = StatusResponse.Error; resp.message = "Route Path is required."; return(resp); } if (string.IsNullOrEmpty(data.icon_name)) { resp.status = StatusResponse.Error; resp.message = "Icon Name is required."; return(resp); } if (string.IsNullOrEmpty(data.func_type)) { resp.status = StatusResponse.Error; resp.message = "Function Type is required."; return(resp); } } catch (Exception ex) { _ILogs.LogError("Validate Function Service: ", ex.Message.ToString(), ex.StackTrace); } return(null); }
public bool SaveFunction(FunctionModel model) { try { if (model.FunctionId == 0) { return(_functionManager.Add(model)); } return(_functionManager.Update(model)); } catch (Exception ex) { throw new TpoBaseException(ex.Message); } }
public ActionResult GetFuncDTable() { FunctionModel model = new FunctionModel(); var SQLQuery = @"SELECT Tbl_FMRes_Function.*, Tbl_FMSector_Sector.SectorTitle, Tbl_FMSector_SubSector.SubSectorTitle, Tbl_FMRes_Department.DeptTitle, Tbl_FMOfficeType.OfficeTypeTitle, Tbl_FMFund_Fund.FundTitle FROM Tbl_FMRes_Function INNER JOIN Tbl_FMRes_Department ON Tbl_FMRes_Function.DeptID = Tbl_FMRes_Department.DeptID INNER JOIN Tbl_FMFund_Fund ON Tbl_FMRes_Department.FundID = Tbl_FMFund_Fund.FundID INNER JOIN Tbl_FMSector_Sector ON Tbl_FMRes_Function.SectorID = Tbl_FMSector_Sector.SectorID LEFT JOIN Tbl_FMSector_SubSector ON Tbl_FMRes_Function.SubSectorID = Tbl_FMSector_SubSector.SubSectorID INNER JOIN Tbl_FMOfficeType ON Tbl_FMRes_Function.OfficeTypeID = Tbl_FMOfficeType.OfficeTypeID"; using (SqlConnection Connection = new SqlConnection(GlobalFunction.ReturnConnectionString())) { Connection.Open(); using (SqlCommand command = new SqlCommand("[dbo].[SP_FMResponsibility]", Connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@SQLStatement", SQLQuery)); SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { model.getFunctionList.Add(new FunctionList() { FunctionID = GlobalFunction.ReturnEmptyInt(dr[0]), //okie FunctionTitle = GlobalFunction.ReturnEmptyString(dr[1]), //okie FunctionAbbrv = GlobalFunction.ReturnEmptyString(dr[2]), //okie FunctionCode = GlobalFunction.ReturnEmptyString(dr[3]), DeptOfficeCodefunc = GlobalFunction.ReturnEmptyString(dr[7]), SectorTitle = GlobalFunction.ReturnEmptyString(dr[9]), SubSectorID = GlobalFunction.ReturnEmptyInt(dr[5]), DeptTitle = GlobalFunction.ReturnEmptyString(dr[11]), OfficeTypeTitle = GlobalFunction.ReturnEmptyString(dr[12]), FundTitle = GlobalFunction.ReturnEmptyString(dr[13]), }); } } Connection.Close(); } return(PartialView("FunctionTab/_TableFunc", model.getFunctionList)); }
private bool canIFindCrossPoint(FunctionModel function1, FunctionModel function2) { var a1 = -function1.x2 / function1.x1; var c1 = function1.c / function1.x1; var a2 = -function2.x2 / function2.x1; var c2 = function2.c / function2.x1; if (a1 - a2 == 0) { return(false); } else { return(true); } }
/// <summary> /// 编辑功能 /// </summary> /// <param name="functionModel"></param> public void EditFunction(FunctionModel functionModel) { var function = _funcDal.GetFunction(functionModel.Id); if (function == null) { throw new UserFriendlyException("查询不到function"); } function.PermissionName = functionModel.FunctionName; function.Level = functionModel.FunctionLevel; function.Sort = functionModel.FunctionSort; function.PermissionUrl = functionModel.PathUrl; function.ParentId = functionModel.ParentID; function.UpdatedTime = DateTime.Now; _funcDal.Update(function); }
public void Insert(Function function) { string memberIds = string.Join(",", function.OwnerMembers.Select(x => x.ID)); FunctionModel model = new FunctionModel { IconClass = function.IconClass, ID = function.ID, Name = function.Name, Sort = function.Sort, Url = function.Url, OwnerMemberIds = memberIds }; NHibernateHelper.CurrentSession.Save(model); NHibernateHelper.CurrentSession.Flush(); }
public object JTableFunctionByApplicationId([FromBody] JTableModelApplicationCustom jTablePara) { //_logger.LogInformation(LoggingEvents.LogDb, "Get list function of Application"); //_actionLog.InsertActionLog("VIBFunction", "Get list function of Application", null, null, "JTable"); int intBeginFor = (jTablePara.CurrentPage - 1) * jTablePara.Length; var query = from vaf in _context.AdAppFunctions join vf in _context.AdFunctions on vaf.FunctionCode equals vf.FunctionCode where vaf.ApplicationCode == jTablePara.Code select new FunctionModel { Id = vaf.AppFunctionId, Title = vf.Title, Code = vaf.FunctionCode, ParentCode = vf.ParentCode, Ord = vf.Ord, Description = vf.Description }; var data = query.OrderBy(x => x.Title).AsNoTracking(); var listFunction = data as IList <FunctionModel> ?? data.ToList(); var result = new List <FunctionModel>(); foreach (var func in listFunction.Where(x => string.IsNullOrEmpty(x.ParentCode)).OrderBy(x => x.Title)) { var listChild = GetFunctionChild(listFunction, func.Code, ". . . "); var function = new FunctionModel(); function.Id = func.Id; function.Title = (listChild.Count > 0 ? "<i class='fa fa-folder-open icon-state-warning'></i> " : "<i class='fa fa-folder text-info'></i> ") + func.Title; function.Code = func.Code; function.ParentCode = func.ParentCode; function.Ord = func.Ord; function.Description = func.Description; result.Add(function); if (listChild.Count > 0) { result = result.Concat(listChild).ToList(); } } var count = result.Count(); var res = jTablePara.Length > 0 ? result.Skip(intBeginFor).Take(jTablePara.Length).ToList() : result.ToList(); var jdata = JTableHelper.JObjectTable(res, jTablePara.Draw, count, "Id", "Title", "Code", "ParentCode", "Ord", "Description"); return(Json(jdata)); }
public override IEnumerable <DynamicNode> GetDynamicNodeCollection(ISiteMapNode nodes) { var function = DataAccessProvider.Function.List(new FunctionParameter { Function = new Function { Owner = 1 } }).Tables [1]; var functionTree = FunctionModel.GenTree(function); var returnValue = new List <DynamicNode>(); var enumerable = (functionTree as Dictionary <string, Function>) ?? functionTree.ToDictionary(data => data.Name); CreateList(returnValue, enumerable, 1, null); return(returnValue); }
public ActionResult Delete(FunctionModel Model) { UserId = USession.User_Id; try { Connection.GDdeleteFunction("N", Model.FunctionId, UserId); Connection.SaveChanges(); return(Json(true, JsonRequestBehavior.AllowGet)); //return RedirectToAction("Index"); } catch (Exception ex) { Errorlog.ErrorManager.LogError(ex); return(View()); } }
public ActionResult Edit(FunctionModel Model) { UserId = USession.User_Id; try { tblFunction TCtable = Connection.tblFunctions.SingleOrDefault(x => x.FunctionId == Model.FunctionId); Connection.GDModifyFunction(Model.FunctionName, Model.FunctionId, UserId); Connection.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { Errorlog.ErrorManager.LogError(ex); return(View()); } }
protected virtual void FunctionClick(FunctionModel model) { originalModel = null; if (currentUser == null && model.NeedLogin) { originalModel = model; MessageBox.Show("请先登录!"); TurnToPage(functionCollection.Count - 1); return; } if (model.Title.Equals("退出系统") && MessageBox.Show("是否退出该系统?", "退出系统", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel) return; TurnToPage(model.Url); }