public override string ToString()
        {
            StringBuilder sb = new StringBuilder("{");

            sb.Append(ZoneId.ToString() + ",");
            sb.Append(UserRoleId.ToString() + ",");
            sb.Append(ReadAccess.ToString() + ",");
            sb.Append(WriteAccess.ToString() + "}");
            return(sb.ToString());
        }
示例#2
0
        protected override void ExecuteWorkflowLogic()
        {
            var target = ConvertToEntityReference(Record.Get(Context.ExecutionContext));

            #region Build Sharing Mask

            var rights = AccessRights.None;

            if (ReadAccess.Get(Context.ExecutionContext))
            {
                rights |= AccessRights.ReadAccess;
            }

            if (WriteAccess.Get(Context.ExecutionContext))
            {
                rights |= AccessRights.WriteAccess;
            }

            if (DeleteAccess.Get(Context.ExecutionContext))
            {
                rights |= AccessRights.DeleteAccess;
            }

            if (AppendAccess.Get(Context.ExecutionContext))
            {
                rights |= AccessRights.AppendAccess;
            }

            if (AppendToAccess.Get(Context.ExecutionContext))
            {
                rights |= AccessRights.AppendToAccess;
            }

            if (AssignAccess.Get(Context.ExecutionContext))
            {
                rights |= AccessRights.AssignAccess;
            }

            if (ShareAccess.Get(Context.ExecutionContext))
            {
                rights |= AccessRights.ShareAccess;
            }

            #endregion Build Sharing Mask

            Context.SystemService.Execute(new ModifyAccessRequest()
            {
                PrincipalAccess = new PrincipalAccess()
                {
                    AccessMask = rights,
                    Principal  = User.Get(Context.ExecutionContext)
                },
                Target = target
            });
        }
示例#3
0
        private FileStream openDbfFileStream(WriteAccess writeAccess)
        {
            FilePermissions @params = ShapeFileProvider.GetPermissions(writeAccess);

            return(new FileStream(_filename,
                                  @params.FileMode,
                                  @params.FileAccess,
                                  @params.FileShare,
                                  4096,
                                  FileOptions.None));
        }
示例#4
0
        public bool IsWritableBy(User?user)
        {
            if (!WriteAccess.IsAccessibleTo(user?.ComputeAccessLevel(), user?.Id, OwnerId))
            {
                return(false);
            }

            // Special files aren't writable by anyone, but special folders are writable
            if (Ftype == FileType.File)
            {
                return(!Special);
            }

            return(true);
        }
示例#5
0
        /// <summary>
        /// Opens the <see cref="DbaseFile"/> on the file name
        /// specified in the constructor,
        /// with a value determining if the file is locked for
        /// exclusive read access or not.
        /// </summary>
        /// <exception cref="ObjectDisposedException">
        /// Thrown when the method is called
        /// and Object has been disposed.
        /// </exception>
        internal void Open(WriteAccess writeAccess)
        {
            checkState();

            // TODO: implement asynchronous access
            _dbaseFileStream = openDbfFileStream(writeAccess);

            _isOpen = true;

            syncReadHeader(DataStream);

            _reader = new DbaseReader(this);
            if (writeAccess != WriteAccess.ReadOnly)
            {
                _writer = new DbaseWriter(this);
            }
            // TODO: NullBinaryWriter
        }
示例#6
0
 private FileStream openDbfFileStream(WriteAccess writeAccess)
 {
     FilePermissions @params = ShapeFileProvider.GetPermissions(writeAccess);
     return new FileStream(_filename,
                           @params.FileMode,
                           @params.FileAccess,
                           @params.FileShare,
                           4096,
                           FileOptions.None);
 }
示例#7
0
        /// <summary>
        /// Opens the <see cref="DbaseFile"/> on the file name
        /// specified in the constructor, 
        /// with a value determining if the file is locked for 
        /// exclusive read access or not.
        /// </summary>
        /// <exception cref="ObjectDisposedException">
        /// Thrown when the method is called 
        /// and Object has been disposed.
        /// </exception>
        internal void Open(WriteAccess writeAccess)
        {
            checkState();

            // TODO: implement asynchronous access
            _dbaseFileStream = openDbfFileStream(writeAccess);

            _isOpen = true;

            syncReadHeader(DataStream);            
            
            _reader = new DbaseReader(this);
            if (writeAccess != WriteAccess.ReadOnly)
                _writer = new DbaseWriter(this);
            // TODO: NullBinaryWriter
        }
示例#8
0
        protected override void ExecuteWorkflowLogic()
        {
            var target      = ConvertToEntityReference(Record.Get(Context.ExecutionContext));
            var principal   = Principal;
            var readAccess  = ReadAccess.Get(Context.ExecutionContext);
            var writeAccess = WriteAccess.Get(Context.ExecutionContext);

            //Let's retrieve attributes first
            var retrieveEntityRequest = new RetrieveEntityRequest()
            {
                LogicalName           = target.LogicalName,
                EntityFilters         = EntityFilters.Attributes,
                RetrieveAsIfPublished = true
            };

            var retrieveEntityResponse = (RetrieveEntityResponse)Context.SystemService.Execute(retrieveEntityRequest);

            var fields = Fields.Get(Context.ExecutionContext).ToLowerInvariant().Split(',').ToArray();

            foreach (var field in fields)
            {
                var crmAttribute =
                    retrieveEntityResponse.EntityMetadata.Attributes.FirstOrDefault(a => a.LogicalName == field);

                if (crmAttribute?.IsSecured == null)
                {
                    throw new InvalidPluginExecutionException($"{field} attribute is not available in {target.LogicalName} entity");
                }

                if (!crmAttribute.IsSecured.Value)
                {
                    throw new InvalidPluginExecutionException($"{field} attribute is not secured");
                }

                var queryPOAA = new QueryByAttribute("principalobjectattributeaccess")
                {
                    ColumnSet = new ColumnSet("readaccess", "updateaccess")
                };
                queryPOAA.AddAttributeValue("attributeid", crmAttribute.MetadataId.Value);
                queryPOAA.AddAttributeValue("objectid", target.Id);
                queryPOAA.AddAttributeValue("principalid", principal.Id);

                var poaa = Context.SystemService.RetrieveMultiple(queryPOAA).Entities.FirstOrDefault();

                if (poaa != null)
                {
                    if (readAccess || writeAccess)
                    {
                        poaa["readaccess"]   = readAccess;
                        poaa["updateaccess"] = writeAccess;
                        Context.SystemService.Update(poaa);
                    }
                    else
                    {
                        Context.SystemService.Delete("principalobjectattributeaccess", poaa.Id);
                    }
                }
                else if (readAccess || writeAccess)
                {
                    poaa = new Entity("principalobjectattributeaccess")
                    {
                        ["attributeid"]  = crmAttribute.MetadataId.Value,
                        ["objectid"]     = target,
                        ["readaccess"]   = readAccess,
                        ["updateaccess"] = writeAccess,
                        ["principalid"]  = principal
                    };

                    Context.SystemService.Create(poaa);
                }
            }
        }