Пример #1
0
        public GetPermissionsResponse GetPermissions(Guid GroupID)
        {
            GetPermissionsResponse response = new GetPermissionsResponse();

            GroupView groupView = new GroupView();

            groupView = _groupRepository.FindBy(GroupID).ConvertToGroupView();

            try
            {
                IEnumerable <PermissionView> permissions = _permissionRepository.FindAll()
                                                           .ConvertToPermissionViews();

                response.PermissionViews = permissions;
                foreach (PermissionView permissionView in response.PermissionViews)
                {
                    bool guaranteed = (from p in groupView.Permissions
                                       where p.PermitKey == permissionView.Key
                                       select p.Guaranteed).FirstOrDefault();
                    // بخاطر اینکه بصورت آجاکسی بتوان ویرایش کرد ناچاریم آیدی گروه را به جای آیدی پرمیشن جا بزنیم
                    permissionView.ID         = groupView.ID;
                    permissionView.Guaranteed = guaranteed;
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return(response);
        }
Пример #2
0
        public GetPermissionsResponse GetPermissions(GetPermissionsRequest request)
        {
            GetPermissionsResponse response = new GetPermissionsResponse();

            EmployeeView employeeView = new EmployeeView();

            employeeView = _employeeRepository.FindBy(request.EmployeeID).ConvertToEmployeeView();

            try
            {
                IEnumerable <PermissionView> permissions = _permissionRepository.FindAll()
                                                           .ConvertToPermissionViews();

                response.PermissionViews = permissions;
                foreach (PermissionView permissionView in response.PermissionViews)
                {
                    bool guaranteed = (from p in employeeView.Permissions
                                       where p.PermitKey == permissionView.Key
                                       select p.Guaranteed).FirstOrDefault();
                    // بخاطر اینکه بصورت آجاکسی بتوان ویرایش کرد ناچاریم آیدی کارمند را به جای آیدی پرمیشن جا بزنیم
                    permissionView.ID         = employeeView.ID;
                    permissionView.Guaranteed = guaranteed;
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return(response);
        }
Пример #3
0
        /**
         * AUTO_GENERATED
         */
        public GetPermissionsResponse GetPermissions(GetPermissionsRequest getPermissionsRequest, string apiUserName)
        {
            string  response = Call("GetPermissions", getPermissionsRequest.ToNVPString(""), apiUserName);
            NVPUtil util     = new NVPUtil();

            return(GetPermissionsResponse.CreateInstance(util.ParseNVPString(response), "", -1));
        }
Пример #4
0
        public async Task <GetPermissionsResponse> GetPermissions()
        {
            var response = new GetPermissionsResponse
            {
                Permissions = await _cache.Permissions()
            };

            return(response);
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        ///<param name="getPermissionsRequest"></param>
        ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param>
        public GetPermissionsResponse GetPermissions(GetPermissionsRequest getPermissionsRequest, ICredential credential)
        {
            IAPICallPreHandler apiCallPreHandler = new PlatformAPICallPreHandler(this.config, getPermissionsRequest.ToNVPString(string.Empty), ServiceName, "GetPermissions", credential);

            ((PlatformAPICallPreHandler)apiCallPreHandler).SDKName    = SDKName;
            ((PlatformAPICallPreHandler)apiCallPreHandler).SDKVersion = SDKVersion;
            ((PlatformAPICallPreHandler)apiCallPreHandler).PortName   = "Permissions";

            NVPUtil util = new NVPUtil();

            return(GetPermissionsResponse.CreateInstance(util.ParseNVPString(Call(apiCallPreHandler)), string.Empty, -1));
        }
Пример #6
0
        public GetPermissionsResponse GetPermissions()
        {
            GetPermissionsResponse response = new GetPermissionsResponse();

            try
            {
                IEnumerable <PermissionView> permissions = _permissionRepository.FindAll()
                                                           .ConvertToPermissionViews();

                response.PermissionViews = permissions;
            }
            catch (Exception ex)
            {
            }

            return(response);
        }
Пример #7
0
        public GetPermissionsResponse Any(GetPermissionsRequest request)
        {
            GetPermissionsResponse resp = new GetPermissionsResponse();

            using (var con = this.TenantDbFactory.ObjectsDB.GetNewConnection())
            {
                con.Open();
                string sql = @"
                SELECT role_name,applicationid,description FROM eb_roles WHERE id = @id;
                SELECT permissionname,obj_id,op_id FROM eb_role2permission WHERE role_id = @id AND eb_del = FALSE;
                SELECT applicationname FROM eb_applications WHERE id IN(SELECT applicationid FROM eb_roles WHERE id = @id);";



                DbParameter[] parameters = { this.TenantDbFactory.ObjectsDB.GetNewParameter("id", System.Data.DbType.Int32, request.id) };

                var           ds = this.TenantDbFactory.ObjectsDB.DoQueries(sql, parameters);
                List <string> _lstPermissions = new List <string>();

                foreach (var dr in ds.Tables[1].Rows)
                {
                    _lstPermissions.Add(dr[0].ToString());
                }

                resp.Permissions = _lstPermissions;
                Dictionary <string, object> result = new Dictionary <string, object>();
                foreach (var dr in ds.Tables[0].Rows)
                {
                    result.Add("rolename", dr[0].ToString());
                    result.Add("applicationid", Convert.ToInt32(dr[1]));
                    result.Add("description", dr[2].ToString());
                }
                foreach (var dr in ds.Tables[2].Rows)
                {
                    result.Add("applicationname", dr[0].ToString());
                }

                resp.Data = result;
            }
            return(resp);
        } // for getting saved permissions
        /**
         * Get user permissions.
         */
        public async Task <APIGatewayProxyResponse> GetUserPermissions(IDataStores dataStores,
                                                                       IDictionary <string, string> requestHeaders)
        {
            Debug.Untested();
            Debug.AssertValid(dataStores);
            Debug.AssertValid(requestHeaders);

            try {
                // Log call
                LoggingHelper.LogMessage($"UserIdentityService::GetUserPermissions()");

                // Get the NoSQL DB client
                AmazonDynamoDBClient dbClient = (AmazonDynamoDBClient)dataStores.GetNoSQLDataStore().GetDBClient();
                Debug.AssertValid(dbClient);

                // Check authenticated endpoint security
                string loggedInUserId = await APIHelper.CheckLoggedIn(dbClient, requestHeaders);

                Debug.AssertID(loggedInUserId);

                // Perform logic
                var permissions = await UserIdentityService_GetUserPermissions_LogicLayer.GetUserPermissions(dbClient, loggedInUserId);

                Debug.AssertValid(permissions);
                GetPermissionsResponse response = new GetPermissionsResponse();
                response.permissions = permissions;
                //??--GetPermissionsResponse response = await UserIdentityService_GetUserPermissions_LogicLayer.GetUserPermissions(dbClient, loggedInUserId);
                //Debug.AssertValid(response);

                // Respond
                return(new APIGatewayProxyResponse {
                    StatusCode = APIHelper.STATUS_CODE_OK,
                    Body = JsonConvert.SerializeObject(response)
                });
            } catch (Exception exception) {
                Debug.Tested();
                return(APIHelper.ResponseFromException(exception));
            }
        }
Пример #9
0
        public GetPermissionsResponse getPermissions(GetPermissionsRequest request)
        {
            GetPermissionsResponse PResponse = null;

            PayLoad = null;

            try
            {
                APIProfile.EndPointAppend = Endpoint + "GetPermissions";
                if (APIProfile.RequestDataformat == "SOAP11")
                {
                    PayLoad = SoapEncoder.Encode(request);
                }
                else if (APIProfile.RequestDataformat == "XML")
                {
                    PayLoad = PayPal.Platform.SDK.XMLEncoder.Encode(request);
                }
                else
                {
                    PayLoad = PayPal.Platform.SDK.JSONSerializer.ToJavaScriptObjectNotation(request);
                }
                res = CallAPI();

                if (APIProfile.RequestDataformat == "JSON")
                {
                    object obj = JSONSerializer.JsonDecode(res.ToString(), typeof(PayPal.Services.Private.Permissions.GetPermissionsResponse));
                    if (obj.GetType() == typeof(PayPal.Services.Private.Permissions.GetPermissionsResponse))
                    {
                        PResponse = (PayPal.Services.Private.Permissions.GetPermissionsResponse)obj;
                    }
                    string name = Enum.GetName(PResponse.responseEnvelope.ack.GetType(), PResponse.responseEnvelope.ack);

                    if (name == "Failure")
                    {
                        this.result = "FAILURE";
                        TransactionException tranactionEx = new TransactionException(PayLoadFromat.JSON, res.ToString());
                        this.lastError = tranactionEx;
                    }
                }

                else if (res.ToString().ToUpper().Replace("<ACK>FAILURE</ACK>", "").Length != res.ToString().Length)
                {
                    this.result = "FAILURE";

                    if (APIProfile.RequestDataformat == "SOAP11")
                    {
                        TransactionException tranactionEx = new TransactionException(PayLoadFromat.SOAP11, res.ToString());
                        this.lastError = tranactionEx;
                    }
                    else if (APIProfile.RequestDataformat == "XML")
                    {
                        TransactionException tranactionEx = new TransactionException(PayLoadFromat.XML, res.ToString());
                        this.lastError = tranactionEx;
                    }
                    else
                    {
                        TransactionException tranactionEx = new TransactionException(PayLoadFromat.JSON, res.ToString());
                        this.lastError = tranactionEx;
                    }
                }
                else
                {
                    if (APIProfile.RequestDataformat == "SOAP11")
                    {
                        PResponse = (PayPal.Services.Private.Permissions.GetPermissionsResponse)SoapEncoder.Decode(res.ToString(), typeof(PayPal.Services.Private.Permissions.GetPermissionsResponse));
                    }
                    else if (APIProfile.RequestDataformat == "XML")
                    {
                        PResponse = (PayPal.Services.Private.Permissions.GetPermissionsResponse)XMLEncoder.Decode(res.ToString(), typeof(PayPal.Services.Private.Permissions.GetPermissionsResponse));
                    }
                    else
                    {
                        object obj = JSONSerializer.JsonDecode(res.ToString(), typeof(PayPal.Services.Private.Permissions.GetPermissionsResponse));
                        if (obj.GetType() == typeof(PayPal.Services.Private.Permissions.GetPermissionsResponse))
                        {
                            PResponse = (PayPal.Services.Private.Permissions.GetPermissionsResponse)obj;
                        }
                    }
                    this.result = "SUCCESS";
                }
            }
            catch (FATALException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new FATALException("Error occurred in Permissions -> GetPermissions method.", ex);
            }
            return(PResponse);
        }