Esempio n. 1
0
        /// <summary>
        /// Post the specified request.
        /// </summary>
        /// <param name="request">Request.</param>
        public object Post(WpsJobAddGroupRequestTep request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.AdminOnly);

            try {
                context.Open();
                context.LogInfo(this, string.Format("/job/wps/{{jobId}}/group POST jobId='{0}',Id='{1}'", request.JobId, request.Id));
                WpsJob wps = WpsJob.FromIdentifier(context, request.JobId);

                var        gids = wps.GetAuthorizedGroupIds();
                List <int> ids  = gids != null?gids.ToList() : new List <int>();

                List <Group> groups = new List <Group>();
                foreach (int id in ids)
                {
                    groups.Add(Group.FromId(context, id));
                }

                foreach (Group grp in groups)
                {
                    if (grp.Id == request.Id)
                    {
                        return(new WebResponseBool(false));
                    }
                }
                wps.GrantPermissionsToGroups(new int[] { request.Id });

                context.Close();
            } catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }
            return(new WebResponseBool(true));
        }
Esempio n. 2
0
        /// <summary>
        /// Get the specified request.
        /// </summary>
        /// <param name="request">Request.</param>
        public object Get(WpsJobGetGroupsRequestTep request)
        {
            List <WebGroup> result = new List <WebGroup>();

            var context = TepWebContext.GetWebContext(PagePrivileges.AdminOnly);

            try {
                context.Open();
                context.LogInfo(this, string.Format("/job/wps/{{jobId}}/group GET jobId='{0}'", request.JobId));

                WpsJob job = WpsJob.FromIdentifier(context, request.JobId);

                var        gids = job.GetAuthorizedGroupIds();
                List <int> ids  = gids != null?gids.ToList() : new List <int>();

                List <Group> groups = new List <Group>();
                foreach (int id in ids)
                {
                    groups.Add(Group.FromId(context, id));
                }

                foreach (Group grp in groups)
                {
                    result.Add(new WebGroup(grp));
                }

                context.Close();
            } catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }
            return(result);
        }