示例#1
0
        private void CreateWpsJobs()
        {
            WpsProcessOffering process = CreateProcess(false);
            var usr1    = User.FromUsername(context, "testusr1");
            var usr2    = User.FromUsername(context, "testusr2");
            var usr3    = User.FromUsername(context, "testusr3");
            var usr4    = User.FromUsername(context, "testusr4");
            var domain  = Domain.FromIdentifier(context, "myDomainTest");
            var domain2 = Domain.FromIdentifier(context, "otherDomainTest");

            //Create one wpsjob public for usr1 --- all should see it
            WpsJob job = CreateWpsJob("public-job-usr1", process, usr1);

            job.Store();
            job.GrantGlobalPermissions();

            //Create one wpsjob with domain where usr1 is member
            job        = CreateWpsJob("domain1-job-usr2", process, usr2);
            job.Domain = domain;
            job.Store();

            //Create one wpsjob with domain where usr1 is not member
            job        = CreateWpsJob("domain2-job-usr3", process, usr3);
            job.Domain = domain2;
            job.Store();

            //Create one wpsjob public for usr2 --- all should see it
            job = CreateWpsJob("public-job-usr2", process, usr2);
            job.Store();
            job.GrantGlobalPermissions();

            //Create one wpsjob restricted for usr1
            job = CreateWpsJob("restricted-job-usr1-2", process, usr1);
            job.Store();
            job.GrantPermissionsToUsers(new int[] { usr2.Id });

            //Create one wpsjob restricted for usr2
            job = CreateWpsJob("restricted-job-usr2-1", process, usr2);
            job.Store();
            job.GrantPermissionsToUsers(new int[] { usr1.Id });

            //Create one wpsjob restricted for usr2
            job = CreateWpsJob("restricted-job-usr2-3", process, usr2);
            job.Store();
            job.GrantPermissionsToUsers(new int[] { usr3.Id });

            //Create one wpsjob private for usr1
            job = CreateWpsJob("private-job-usr1", process, usr1);
            job.Store();

            //Create one wpsjob private for usr2
            job = CreateWpsJob("private-job-usr2", process, usr2);
            job.Store();

            //Create one wpsjob private for usr3
            job = CreateWpsJob("private-job-usr3", process, usr3);
            job.Store();

            //Create one wpsjob private for usr4
            job = CreateWpsJob("private-job-usr4", process, usr4);
            job.Store();
        }