示例#1
0
 public PermissionService()
 {
     userService     = new UserService();
     roleService     = new RoleService();
     functionService = new FunctionService();
     menuService     = new MenuService();
 }
        static async Task <StorageCredentials> ObtainStorageCredentials(StoragePermissionType permissionType)
        {
            var cacheKey = permissionType.ToString();

            if (Barrel.Current.Exists(cacheKey) && !Barrel.Current.IsExpired(cacheKey))
            {
                return(new StorageCredentials(Barrel.Current.Get <string>(cacheKey)));
            }

            string storageToken = null;

            switch (permissionType)
            {
            case StoragePermissionType.List:
                storageToken = await FunctionService.GetContainerListSasToken().ConfigureAwait(false);

                break;

            case StoragePermissionType.Read:
                storageToken = await FunctionService.GetContainerReadSASToken().ConfigureAwait(false);

                break;

            case StoragePermissionType.Write:
                storageToken = await FunctionService.GetContainerWriteSasToken().ConfigureAwait(false);

                break;
            }

            return(storageToken == null ? null : StuffCredentialsInBarrel(storageToken, cacheKey));
        }
示例#3
0
        private void InitialDataPopupFunction()
        {
            var cmd = new FunctionService();

            gridSelectFunction.DataSource = cmd.GetALL();
            gridSelectFunction.DataBind();
        }
示例#4
0
        /// <summary>
        /// Get All Function
        /// </summary>
        /// <param name="groupID"></param>
        /// <returns></returns>
        public static List <Function> GetFunctionList()
        {
            SerializeObjectFactory sof = new SerializeObjectFactory();
            FunctionService        fs  = new FunctionService();
            string funListStr          = fs.GetFunctionList();

            object o = sof.DesializeFromBase64(funListStr);

            List <Function> list = (List <Function>)o;

            return(list);
            //List<Function> FunctionListAll = new List<Function>();

            //using (DataTable table = SqlHelper.ExecuteDataset(SqlHelper.SqlCon_QJVRMS, CommandType.StoredProcedure, "Function_GetFunction").Tables[0])
            //{
            //    foreach (DataRow row in table.Rows)
            //    {
            //        Function f = new Function();
            //        f.description = row["Description"].ToString();
            //        f.functionName = row["FunctionName"].ToString();
            //        f.urlPath = row["UrlPath"].ToString();
            //        f.functionID = row["FunctionId"].ToString();
            //        f.orderFlag = int.Parse(row["orderFlag"].ToString());
            //        FunctionListAll.Add(f);
            //    }
            //}

            //return FunctionListAll;
        }
示例#5
0
 //todo quand impl: update une fonction ne peut pas changer son nombre d'args
 public FunctionNode(FunctionService functionService, string id, FunctionId?parentId)
     : base(id, NodeType.Function, 1)
 {
     _functionService = functionService;
     Id        = new FunctionId(id);
     _parentId = parentId;
 }
        public async Task UpdateAsync_GivenNewUntakenName_ReturnsUpdatedFunction()
        {
            // Arrange
            var functionRepository    = Substitute.For <IFunctionRepository>();
            var permissionRepository  = Substitute.For <IPermissionRepository>();
            var applicationRepository = Substitute.For <IApplicationRepository>();
            var subRealmRepository    = Substitute.For <ISubRealmRepository>();

            mockedFunctionSubmitModel.Name += "_changed_name";

            applicationRepository.GetByIdAsync(mockedFunctionModel.Application.Id)
            .Returns(mockedFunctionModel.Application);
            permissionRepository.GetByIdWithApplicationAsync(mockedFunctionModel.FunctionPermissions[0].PermissionId)
            .Returns(mockedFunctionModel.FunctionPermissions[0].Permission);
            functionRepository.GetByIdAsync(mockedFunctionModel.Id).Returns(mockedFunctionModel);
            functionRepository.UpdateAsync(Arg.Any <FunctionModel>()).Returns(mockedFunctionModel);

            var functionService = new FunctionService(functionRepository, permissionRepository, applicationRepository, subRealmRepository, mapper);

            // Act
            var functionResource = await functionService.UpdateAsync(mockedFunctionSubmitModel, Guid.NewGuid());

            // Assert
            Assert.NotNull(functionResource);
            Assert.True(functionResource.Name == mockedFunctionSubmitModel.Name, $"Function Resource name: '{functionResource.Name}' not the expected value: '{mockedFunctionSubmitModel.Name}'");
            Assert.True(functionResource.ApplicationId == mockedFunctionSubmitModel.ApplicationId, $"Function Resource name: '{functionResource.ApplicationId}' not the expected value: '{mockedFunctionSubmitModel.ApplicationId}'");
            Assert.True(functionResource.Permissions.Count == mockedFunctionSubmitModel.Permissions.Count, $"Function Resource Permission Count: '{functionResource.Permissions.Count}' not the expected value: '{mockedFunctionSubmitModel.Permissions.Count}'");
        }
        public async Task GetListAsync_Executed_ReturnsList()
        {
            // Arrange
            var functionRepository    = Substitute.For <IFunctionRepository>();
            var permissionRepository  = Substitute.For <IPermissionRepository>();
            var applicationRepository = Substitute.For <IApplicationRepository>();
            var subRealmRepository    = Substitute.For <ISubRealmRepository>();

            functionRepository.GetListAsync().Returns(
                new List <FunctionModel>()
            {
                mockedFunctionModel,
                mockedFunctionModel
            });

            var functionService = new FunctionService(functionRepository, permissionRepository, applicationRepository, subRealmRepository, mapper);

            // Act
            var functionList = await functionService.GetListAsync();

            // Assert
            Assert.True(functionList.Count == 2, "Expected list count is 2");
            Assert.True(functionList[0].Name == mockedFunctionModel.Name, $"Expected applicationFunction name: '{functionList[0].Name}' does not equal expected value: '{mockedFunctionModel.Name}'");
            Assert.True(functionList[0].Uuid == mockedFunctionModel.Id, $"Expected applicationFunction UUID: '{functionList[0].Uuid}' does not equal expected value: '{mockedFunctionModel.Id}'");
        }
        public async Task UpdateAsync_GivenNewTakenName_ThrowsItemNotProcessableException()
        {
            // Arrange
            var functionRepository    = Substitute.For <IFunctionRepository>();
            var permissionRepository  = Substitute.For <IPermissionRepository>();
            var applicationRepository = Substitute.For <IApplicationRepository>();
            var subRealmRepository    = Substitute.For <ISubRealmRepository>();

            mockedFunctionSubmitModel.Name += "_changed_name";

            applicationRepository.GetByIdAsync(mockedFunctionModel.Application.Id)
            .Returns(mockedFunctionModel.Application);
            permissionRepository.GetByIdWithApplicationAsync(mockedFunctionModel.FunctionPermissions[0].PermissionId)
            .Returns(mockedFunctionModel.FunctionPermissions[0].Permission);
            functionRepository.GetByIdAsync(mockedFunctionModel.Id).Returns(mockedFunctionModel);
            functionRepository.GetByNameAsync(mockedFunctionSubmitModel.Name).Returns(mockedFunctionModel);
            functionRepository.UpdateAsync(Arg.Any <FunctionModel>()).Returns(mockedFunctionModel);

            var functionService = new FunctionService(functionRepository, permissionRepository, applicationRepository, subRealmRepository, mapper);

            // Act
            Exception caughEx = null;

            try
            {
                var functionResource = await functionService.UpdateAsync(mockedFunctionSubmitModel, Guid.NewGuid());
            }
            catch (Exception ex)
            {
                caughEx = ex;
            }

            // Assert
            Assert.True(caughEx is ItemNotProcessableException, "New taken name must throw an ItemNotProcessableException");
        }
        public ActionResult Delete(string menuId)
        {
            IFunctionService svc = new FunctionService();
            var model            = svc.Delete(menuId);

            return(RedirectToAction("Index"));
        }
        public async Task CreateAsync_GivenUnfindablePermission_ThrowsItemNotFoundException()
        {
            // Arrange
            var functionRepository    = Substitute.For <IFunctionRepository>();
            var permissionRepository  = Substitute.For <IPermissionRepository>();
            var applicationRepository = Substitute.For <IApplicationRepository>();
            var subRealmRepository    = Substitute.For <ISubRealmRepository>();

            applicationRepository.GetByIdAsync(mockedFunctionModel.Application.Id)
            .Returns(mockedFunctionModel.Application);

            var functionService = new FunctionService(functionRepository, permissionRepository, applicationRepository, subRealmRepository, mapper);

            // Act
            Exception caughEx = null;

            try
            {
                var functionResource = await functionService.CreateAsync(mockedFunctionSubmitModel, Guid.NewGuid());
            }
            catch (Exception ex)
            {
                caughEx = ex;
            }

            // Assert
            Assert.True(caughEx is ItemNotFoundException, "Unfindable Permissions must throw an ItemNotFoundException.");
        }
        public async Task DeleteAsync_GivenFindableGuid_ExecutesSuccessfully()
        {
            // Arrange
            var functionRepository    = Substitute.For <IFunctionRepository>();
            var permissionRepository  = Substitute.For <IPermissionRepository>();
            var applicationRepository = Substitute.For <IApplicationRepository>();
            var subRealmRepository    = Substitute.For <ISubRealmRepository>();

            functionRepository.GetByIdAsync(mockedFunctionModel.Id).Returns(mockedFunctionModel);

            var functionService = new FunctionService(functionRepository, permissionRepository, applicationRepository, subRealmRepository, mapper);

            // Act
            Exception caughEx = null;

            try
            {
                await functionService.DeleteAsync(mockedFunctionModel.Id);
            }
            catch (Exception ex)
            {
                caughEx = ex;
            }

            // Assert
            Assert.True(caughEx is null, "Delete on a findable GUID must execute successfully.");
        }
        public async Task DeleteAsync_GivenUnfindableGuid_ThrowsItemNotFoundException()
        {
            // Arrange
            var functionRepository    = Substitute.For <IFunctionRepository>();
            var permissionRepository  = Substitute.For <IPermissionRepository>();
            var applicationRepository = Substitute.For <IApplicationRepository>();
            var subRealmRepository    = Substitute.For <ISubRealmRepository>();

            var functionService = new FunctionService(functionRepository, permissionRepository, applicationRepository, subRealmRepository, mapper);

            // Act
            Exception caughEx = null;

            try
            {
                await functionService.DeleteAsync(mockedFunctionModel.Id);
            }
            catch (Exception ex)
            {
                caughEx = ex;
            }

            // Assert
            Assert.True(caughEx is ItemNotFoundException, "Delete on a findable GUID must throw an ItemNotFoundException.");
        }
        // GET: Vendor
        public ActionResult Index()
        {
            IFunctionService svc = new FunctionService();
            var model            = svc.GetAll();

            return(View("~/Views/Master/Function/Index.cshtml", model));
        }
示例#14
0
        /// <summary>
        /// 获取拥有的function
        /// </summary>
        /// <param name="operId"></param>
        /// <param name="method"></param>
        /// <returns></returns>
        public static DataTable GetOwnFunction(IOperator oper, OperatorMethod method)
        {
//            SecurityObjectType objType = SecurityObjectType.Function;

//            string sql = @"select f.functionId,f.FunctionName from accessControlList a,FunctionList f where
//                            a.operatorId=@operId and a.OperatorMethod=@operMethod and a.ObjectType=@objType and a.ObjectId=f.FunctionId";

//            SqlParameter[] Parameters = new SqlParameter[3];


//            Parameters[0] = new SqlParameter("@operId", SqlDbType.UniqueIdentifier);
//            Parameters[1] = new SqlParameter("@operMethod", SqlDbType.TinyInt);
//            Parameters[2] = new SqlParameter("@objType", SqlDbType.TinyInt);


//            Parameters[0].Value = oper.OperatorId;
//            Parameters[1].Value = (int)method;
//            Parameters[2].Value = (int)objType;

//            return SqlHelper.ExecuteDataset(SqlHelper.SqlCon_QJVRMS, CommandType.Text, sql, Parameters).Tables[0];

            FunctionService fs = new FunctionService();

            return(fs.GetOwnFunction(oper.OperatorId, (int)method));
        }
        public async Task CreateAsync_GivenUnlinkedPermissionAndApplication_ThrowsItemNotProcessableException()
        {
            // Arrange
            var functionRepository    = Substitute.For <IFunctionRepository>();
            var permissionRepository  = Substitute.For <IPermissionRepository>();
            var applicationRepository = Substitute.For <IApplicationRepository>();
            var subRealmRepository    = Substitute.For <ISubRealmRepository>();

            // Change ApplicationId to break link between the permission and Application
            mockedFunctionModel.FunctionPermissions[0].Permission.ApplicationFunctionPermissions[0].ApplicationFunction.Application.Id = Guid.NewGuid();

            applicationRepository.GetByIdAsync(Arg.Any <Guid>())
            .Returns(mockedFunctionModel.Application);
            permissionRepository.GetByIdWithApplicationAsync(mockedFunctionModel.FunctionPermissions[0].PermissionId)
            .Returns(mockedFunctionModel.FunctionPermissions[0].Permission);
            functionRepository.CreateAsync(Arg.Any <FunctionModel>()).Returns(mockedFunctionModel);

            var functionService = new FunctionService(functionRepository, permissionRepository, applicationRepository, subRealmRepository, mapper);

            // Act
            Exception caughEx = null;

            try
            {
                var functionResource = await functionService.CreateAsync(mockedFunctionSubmitModel, Guid.NewGuid());
            }
            catch (Exception ex)
            {
                caughEx = ex;
            }

            // Assert
            Assert.True(caughEx is ItemNotProcessableException, "Unlinked permissions and applications must throw an ItemNotProcessableException.");
        }
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="employeeService"></param>
 /// <param name="functionService"></param>
 /// <param name="menuService"></param>
 /// <param name="roleService"></param>
 public SystemController(EmployeeService employeeService, FunctionService functionService, MenuService menuService, RoleService roleService)
 {
     _EmployeeService = employeeService;
     _FunctionService = functionService;
     _MenuService     = menuService;
     _RoleService     = roleService;
 }
        public async Task CreateAsync_GivenAlreadyUsedName_ThrowsItemNotProcessableException()
        {
            var functionRepository    = Substitute.For <IFunctionRepository>();
            var permissionRepository  = Substitute.For <IPermissionRepository>();
            var applicationRepository = Substitute.For <IApplicationRepository>();
            var subRealmRepository    = Substitute.For <ISubRealmRepository>();

            applicationRepository.GetByIdAsync(mockedFunctionModel.Application.Id)
            .Returns(mockedFunctionModel.Application);
            permissionRepository.GetByIdWithApplicationAsync(mockedFunctionModel.FunctionPermissions[0].PermissionId)
            .Returns(mockedFunctionModel.FunctionPermissions[0].Permission);
            functionRepository.GetByIdAsync(mockedFunctionModel.Id).Returns(mockedFunctionModel);
            functionRepository.GetByNameAsync(mockedFunctionSubmitModel.Name).Returns(mockedFunctionModel);
            functionRepository.CreateAsync(Arg.Any <FunctionModel>()).Returns(mockedFunctionModel);

            var functionService = new FunctionService(functionRepository, permissionRepository, applicationRepository, subRealmRepository, mapper);

            // Act
            Exception caughEx = null;

            try
            {
                var functionResource = await functionService.CreateAsync(mockedFunctionSubmitModel, Guid.NewGuid());
            }
            catch (Exception ex)
            {
                caughEx = ex;
            }

            // Assert
            Assert.True(caughEx is ItemNotProcessableException, "Attempted create with an already used name must throw an ItemNotProcessableException.");
        }
 public CadastroVoluntario()
 {
     InitializeComponent();
     ConfigurarCombobox();
     voluntaryService = new VoluntaryService();
     cityService      = new CityService();
     functionService  = new FunctionService();
 }
示例#19
0
        /// <summary>
        /// 获取所有Function列表
        /// </summary>
        /// <returns></returns>
        public static DataTable GetFunctionTableList()
        {
            //string sql = " select * from functionList order by orderFlag asc";
            //return SqlHelper.ExecuteDataset(SqlHelper.SqlCon_QJVRMS, CommandType.Text, sql).Tables[0];

            FunctionService fs = new FunctionService();

            return(fs.GetFunctionTableList());
        }
        public ActionResult Edit(string menuId)
        {
            this.ViewBag.menuId = GetModul();

            IFunctionService svc = new FunctionService();
            var model            = svc.Getdata(menuId);

            return(View("~/Views/Master/Function/Edit.cshtml", model));
        }
        protected static SelectList GetModul()
        {
            IFunctionService svc = new FunctionService();
            var data             = svc.GetModul();

            SelectList selectList = new SelectList(data, "ParentID", "Text");

            return(selectList);
        }
示例#22
0
        public IList <Function> GetTopFunctionList()
        {
            SerializeObjectFactory sof       = new SerializeObjectFactory();
            FunctionService        fs        = new FunctionService();
            string           topFunctionList = fs.GetTopFunctionList();
            object           o    = sof.DesializeFromBase64(topFunctionList);
            IList <Function> list = (IList <Function>)o;

            return(list);
        }
示例#23
0
        /// <summary>
        /// 根据FunctionID删除某项用途
        /// </summary>
        /// <param name="groupID"></param>
        /// <returns></returns>
        public static bool DeleteFunctionByFunctionID(Guid FunctionID)
        {
            //SqlParameter[] Parameters = new SqlParameter[1];

            //Parameters[0] = new SqlParameter("@FunctionId", SqlDbType.UniqueIdentifier);
            //Parameters[0].Value = new Guid(FunctionID);

            //int result = SqlHelper.ExecuteNonQuery(SqlHelper.SqlCon_QJVRMS, CommandType.StoredProcedure, "Function_DeleteFunction", Parameters);
            //return result == 1;
            FunctionService fs = new FunctionService();

            return(fs.DeleteFunctionByFunctionID(FunctionID));
        }
示例#24
0
        public static bool  GetUserFunctionRight(Guid userID)
        {
            //SqlParameter[] Parameters = new SqlParameter[1];
            //Parameters[0] = new SqlParameter("@UserId", SqlDbType.VarChar);
            //Parameters[0].Value = userID;

            //string sql = "select count(*) from dbo.AccessControlList where OperatorId in (select RoleId from dbo.Users_InRoles where UserId=@UserId) and ObjectId in (select FunctionId from  FunctionList)";
            //string strCount = SqlHelper.ExecuteScalar(SqlHelper.SqlCon_QJVRMS, CommandType.Text, sql, Parameters).ToString();
            //return strCount == "0" ? false : true;
            FunctionService fs = new FunctionService();

            return(fs.GetUserFunctionRight(userID));
        }
 public ActionResult Edit(string menuId, Master_Menu model)
 {
     try
     {
         IFunctionService svc = new FunctionService();
         var result           = svc.Edit(menuId, model);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         general.AddLogError("Function Edit", ex.Message, ex.StackTrace);
         return(View("~/Views/Master/Function/Index.cshtml"));
     }
 }
示例#26
0
        public string DoFunction(string comand)
        {
            List <Comand> comands = new List <Comand>();

            comand.Split('\n').ToList().ForEach(cmd => comands.Add(new Comand(cmd)));
            IFunctionService service = new FunctionService();
            MethodInfo       method  = service.GetType().GetMethod(comand);

            if (method == null)
            {
                return("Такого метода нет");
            }
            return(method.Invoke(service, null).ToString());
        }
示例#27
0
        public async Task GetById_GivenGuid_ReturnsFunctionResource()
        {
            var functionRepository    = Substitute.For <IFunctionRepository>();
            var permissionRepository  = Substitute.For <IPermissionRepository>();
            var applicationRepository = Substitute.For <IApplicationRepository>();

            functionRepository.GetByIdAsync(guid).Returns(mockedFunctionModel);

            var functionService  = new FunctionService(functionRepository, permissionRepository, applicationRepository, mapper);
            var functionResource = await functionService.GetByIdAsync(guid);

            Assert.True(functionResource.Name == "Test function name", $"Function Resource name: '{functionResource.Name}' not the expected value: 'Test Function name'");
            Assert.True(functionResource.Uuid == guid, $"Function Resource UUId: '{functionResource.Uuid}' not the expected value: '{guid}'");
        }
        public void MultiGetFunctionExecutionWithFilter()
        {
            const int expectedFilteredCount = 34;

            using (var cluster = new Cluster(output, CreateTestCaseDirectoryName(), 1, 1))
            {
                Assert.True(cluster.Start());
                Assert.Equal(0, cluster.Gfsh.deploy()
                             .withJar(Config.JavaobjectJarPath)
                             .execute());
                Assert.Equal(0, cluster.Gfsh.create().region()
                             .withName("testRegion1")
                             .withType("PARTITION")
                             .execute());

                var cache  = cluster.CreateCache();
                var region = cache.CreateRegionFactory(RegionShortcut.PROXY)
                             .SetPoolName("default")
                             .Create <object, object>("testRegion1");

                for (var i = 0; i < 230; i++)
                {
                    region["KEY--" + i] = "VALUE--" + i;
                }

                const bool args = true;

                var oddKeyFilter = new object[17];
                var j            = 0;
                for (var i = 0; i < 34; i++)
                {
                    if (i % 2 == 0)
                    {
                        continue;
                    }
                    oddKeyFilter[j] = "KEY--" + i;
                    j++;
                }

                var exc = FunctionService <List <object> > .OnRegion(region);

                var rc = exc.WithArgs(args).WithFilter(oddKeyFilter).Execute("MultiGetFunction");
                var executeFunctionResult = rc.GetResult();
                var resultList            = executeFunctionResult.SelectMany(item => item).ToList();

                Assert.Equal(expectedFilteredCount, resultList.Count);
            }
        }
示例#29
0
        protected void btnAddFunction_Click(object sender, EventArgs e)
        {
            var cmdFunc = new FunctionService();
            List <ROLE_FUNCTION> list = new List <ROLE_FUNCTION>();

            for (int i = 0; i < gridSelectFunction.Rows.Count; i++)
            {
                if (((CheckBox)gridSelectFunction.Rows[i].Cells[0].FindControl("check")).Checked)
                {
                    if (ViewState["RoleId"] != null && DataSouceRoleFunction.Where(x => x.FUNCTION_ID == Convert.ToInt32(gridSelectFunction.DataKeys[i].Value.ToString())).FirstOrDefault() == null)
                    {
                        ROLE_FUNCTION obj = new ROLE_FUNCTION();
                        obj.Action             = ActionEnum.Create;
                        obj.ROLE_ID            = Convert.ToInt32(ViewState["RoleId"].ToString());
                        obj.FUNCTION_ID        = Convert.ToInt32(gridSelectFunction.DataKeys[i].Value.ToString());
                        obj.CREATE_DATE        = DateTime.Now;
                        obj.CREATE_EMPLOYEE_ID = 0;
                        obj.UPDATE_DATE        = DateTime.Now;
                        obj.UPDATE_EMPLOYEE_ID = 0;
                        obj.SYE_DEL            = true;
                        list.Add(obj);
                    }
                    else if (DataSouceNewRoleFunction.Where(x => x.FUNCTION_ID == Convert.ToInt32(gridSelectFunction.DataKeys[i].Value.ToString())).FirstOrDefault() == null)
                    {
                        ROLE_FUNCTION obj = new ROLE_FUNCTION();
                        obj.Action             = ActionEnum.Create;
                        obj.ROLE_ID            = 0;
                        obj.FUNCTION_ID        = Convert.ToInt32(gridSelectFunction.DataKeys[i].Value.ToString());
                        obj.CREATE_DATE        = DateTime.Now;
                        obj.CREATE_EMPLOYEE_ID = 0;
                        obj.UPDATE_DATE        = DateTime.Now;
                        obj.UPDATE_EMPLOYEE_ID = 0;
                        obj.SYE_DEL            = true;
                        DataSouceNewRoleFunction.Add(obj);
                    }
                }
            }

            if (list.Count > 0)
            {
                var cmd = new RoleFunctionService(list);
                cmd.AddList();
            }

            InitialDataPopup();
            this.popup.Show();
        }
 public ActionResult Add(Master_Menu model)
 {
     try
     {
         IFunctionService svc = new FunctionService();
         model.MenuID = FunctionService.GenerateID();
         var result = svc.Add(model);
         this.AddNotification("Your Data Has Been Successfully Saved. ", NotificationType.SUCCESS);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         general.AddLogError("Function Add", ex.Message, ex.StackTrace);
         this.AddNotification("ID exist", NotificationType.ERROR);
         return(View("~/Views/Master/Function/Add.cshtml"));
     }
 }
 //临时
 public void update()
 {
     var f = new FunctionService();
     var role = new RoleTypeService();
     if (f.FindAll().Count > 21) return;
     var ro = new RoleAuthorityService();
     f.Insert(new function()
     {
         Meno = "淘汰任务",
         Name = "EliminateTask"
     });
     f.Insert(new function()
     {
         Name = "DeadTask",
         Meno = "死亡任务"
     });
     f.Insert(new function()
     {
         Name = "EliminateInfo",
         Meno = "淘汰信息管理"
     });
     f.Insert(new function()
     {
         Name = "DeadInfo",
         Meno = "死亡信息管理"
     });
     var roletype = new RoleTypeService();
     roletype.Insert(new role_type() {
      Name="淘汰生猪负责员"
     });
     roletype.Insert(new role_type()
     {
         Name = "死亡生猪处理员"
     });
     foreach (var a in role.FindAll())
     {
         for (int i = 20; i < 24; i++)
             ro.Insert(new role_authority()
             {
                 FunctionId = i,
                 RoleTypeId = a.Id,
                 Check = true
             });
     }
 }
示例#32
0
        static HostViewModelLocator()
        {
            var customResources = new View.CustomResources();

            customResources.InitializeComponent();

            var commentFactory = new ElementFactory(CustomElementTypeIds.Comment, "Custom", "Comment",
                context => new CommentViewModel(context), typeof(CommentViewModel));

            var functionService = new FunctionService(GetFunctions, GetFunction);

            var factories = new IElementFactory[]
            {
                commentFactory,
            };

            //Create the plugin
            var plugin = new VplPlugin(
                "Host",
                factories,
                new[] { customResources },
                services: new[] { functionService });

            var plugin1 = new VplPlugin("Alert",
                new IElementFactory[]
                {
                    new ElementFactory(new Guid("FBB6804C-B90C-4A88-B28B-8B733C1A9F0D"), "Interaction", "Alert", context => new Alert(context), typeof(Alert)),
                });

            var plugins = SystemPluginFactory.CreateAllPlugins()
                .ToList();

            plugins.Add(plugin);
            plugins.Add(plugin1);

            VplService = new VplService(plugins);
        }