// Methods
 protected override void AddAccessResultToCache(ISecurable entity, Account account, AccessRight accessRight, AccessResult accessResult, PropagationType propagationType)
 {
     if (accessRight.Name != "adoption:change")
     {
         base.AddAccessResultToCache(entity, account, accessRight, accessResult, propagationType);
     }
 }
 public static void free_access_result(AccessResult p0)
 {
     storj_uplinkPINVOKE.free_access_result(AccessResult.getCPtr(p0));
     if (storj_uplinkPINVOKE.SWIGPendingException.Pending)
     {
         throw storj_uplinkPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Beispiel #3
0
        private async Task <Outcome <string, string[]> > GetRawSecretAsync()
        {
            AccessResult <string> result =
                await Access.Function <string, Task <string> >(secretName => Task.FromResult("secretValue"))
                .EvalAsync("secretName");

            return(result);
        }
        bool SendRawMapCore(Level oldLevel, Level level)
        {
            if (level.blocks == null)
            {
                return(false);
            }
            bool success = true;

            useCheckpointSpawn  = false;
            lastCheckpointIndex = -1;

            AFKCooldown = DateTime.UtcNow.AddSeconds(2);
            SendMapMotd();
            AccessResult access = level.BuildAccess.Check(this);

            AllowBuild = access == AccessResult.Whitelisted || access == AccessResult.Allowed;

            try {
                Send(Packet.LevelInitalise());

                if (hasBlockDefs)
                {
                    if (oldLevel != null && oldLevel != level)
                    {
                        RemoveOldLevelCustomBlocks(oldLevel);
                    }
                    BlockDefinition.SendLevelCustomBlocks(this);

                    if (Supports(CpeExt.InventoryOrder))
                    {
                        BlockDefinition.SendLevelInventoryOrder(this);
                    }
                }

                using (LevelChunkStream s = new LevelChunkStream(this))
                    LevelChunkStream.CompressMap(this, s);

                // Force players to read the MOTD (clamped to 3 seconds at most)
                if (level.Config.LoadDelay > 0)
                {
                    System.Threading.Thread.Sleep(level.Config.LoadDelay);
                }

                byte[] buffer = Packet.LevelFinalise(level.Width, level.Height, level.Length);
                Send(buffer);
                Loading = false;

                OnJoinedLevelEvent.Call(this, oldLevel, level);
            } catch (Exception ex) {
                success = false;
                PlayerActions.ChangeMap(this, Server.mainLevel);
                SendMessage("There was an error sending the map data, you have been sent to the main level.");
                Logger.LogError(ex);
            } finally {
                Server.DoGC();
            }
            return(success);
        }
        protected override void AddAccessResultToCache(ISecurable entity, Account account, AccessRight accessRight, AccessResult accessResult, PropagationType propagationType)
        {
            if (accessRight.Name == BucketRights.MakeABucket)
            {
                return;
            }

            base.AddAccessResultToCache(entity, account, accessRight, accessResult, propagationType);
        }
Beispiel #6
0
        public void ShouldCallGetAccess(User account, AccessRight accessRight, AccessResult accessResult)
        {
            // arrange
            this.provider.LocalProvider.Value = this.localProvider;
            this.localProvider.GetAccess(this.entity, account, accessRight).Returns(accessResult);

            // act & assert
            this.provider.GetAccess(this.entity, account, accessRight).Should().BeSameAs(accessResult);
        }
        public static AccessResult access_share2(Access p0, Permission p1)
        {
            AccessResult ret = new AccessResult(storj_uplinkPINVOKE.access_share2(Access.getCPtr(p0), Permission.getCPtr(p1)), true);

            if (storj_uplinkPINVOKE.SWIGPendingException.Pending)
            {
                throw storj_uplinkPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public static AccessResult config_request_access_with_passphrase(Config p0, string p1, string p2, string p3)
        {
            AccessResult ret = new AccessResult(storj_uplinkPINVOKE.config_request_access_with_passphrase(Config.getCPtr(p0), p1, p2, p3), true);

            if (storj_uplinkPINVOKE.SWIGPendingException.Pending)
            {
                throw storj_uplinkPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public override AccessResult GetAccess(Field field, Account account, AccessRight accessRight)
        {
            AccessResult result = null;

            if (ShouldCheckDesignRights(field, accessRight))
            {
                result = GetLayoutFieldAccess(field, account);
            }

            return(result ?? base.GetAccess(field, account, accessRight));
        }
 protected override void AddAccessResultToCache(ISecurable entity, Account account, AccessRight accessRight, AccessResult accessResult, PropagationType propagationType)
 {
     //
     //Do not cache the access result because the result depends
     //on the value that is currently set on the item.
     if (accessRight.Name == BucketRights.AddComments)
     {
         return;
     }
     base.AddAccessResultToCache(entity, account, accessRight, accessResult, propagationType);
 }
Beispiel #11
0
        public async Task <IActionResult> Get([FromQuery] Transfer.Compra.Get data)
        {
            try
            {
                AccessResult <IEnumerable <Compra> > result = await Compras.GetAll();

                if (!result.IsValid)
                {
                    return(BadRequest(result.Fault));
                }

                IEnumerable <Compra> products = result.Result;
                if (data.Usuario != null)
                {
                    products = products.Where(x => x.ReservaNavigation.Usuario == data.Usuario);
                }
                if (data.Estado != null)
                {
                    products = products.Where(x => x.Estado == data.Estado);
                }
                if (data.Producto != null)
                {
                    products = products.Where(x => x.ReservaNavigation.ReservaStock.Any(y => y.Producto == data.Producto));
                }

                return(Ok(products.Select(x => new
                {
                    id = x.Id,
                    estado = x.Estado,
                    reserva = new
                    {
                        id = x.ReservaNavigation.Id,
                        usuario = x.ReservaNavigation.Usuario,
                        reservas = x.ReservaNavigation.ReservaStock.Select(y => new
                        {
                            cantidad = y.Cantidad,
                            producto = y.Producto
                        })
                    }
                })));
            }
            catch (ArgumentNullException)
            {
                return(BadRequest(new AccessFault("Solicitud incompleta o inválida")));
            }
            catch (Exception e)
            {
                return(BadRequest(new AccessFault($"Error no controlado: {e.GetType()}")));
            }
        }
        protected override AccessResult GetAccessCore(ISecurable oEntity, Account oAccount, AccessRight oAccessRight)
        {
            Item oItem;
            GenAuthorizationHelper oGenAuthorizationHelper;
            AccessResult           oItemAccessResult;
            AccessExplanation      oItemAccessExplanation;
            string sAccessExplanationText;

            oItemAccessResult = null;
            //Validates that internal tasks have access to sitecore content
            //Specially required for sitecore events Sitecore:Item:Write (Sitecore Cache Update Event)
            //This is needed because we bypass Sitecore Authorization with the Custom Authorization process for GFWM
            if (Sitecore.Context.IsBackgroundThread)
            {
                oItemAccessExplanation = new AccessExplanation(string.Format("{0} access right granted for Internal Task", oAccessRight.Name), new object[0]);

                oItemAccessResult = new AccessResult(AccessPermission.Allow, oItemAccessExplanation);
            }
            else
            {
                switch (oAccessRight.Name)
                {
                case "item:read":
                    oGenAuthorizationHelper = ItemHelper as GenAuthorizationHelper;
                    if (oGenAuthorizationHelper != null)
                    {
                        oItem             = oEntity as Item;
                        oItemAccessResult = oGenAuthorizationHelper.GetAccess(oItem, oAccount, oAccessRight);
                    }

                    break;

                case "field:read":
                case "language:read":
                case "site:enter":
                    oItemAccessExplanation = new AccessExplanation(string.Format("{0} acces right granted", oAccessRight.Name), new object[0]);
                    oItemAccessResult      = new AccessResult(AccessPermission.Allow, oItemAccessExplanation);
                    break;

                default:
                    sAccessExplanationText = string.Format("Access right {0} is unavailable in the web layer", oAccessRight.Name);
                    oItemAccessExplanation = new AccessExplanation(sAccessExplanationText, new object[0]);
                    oItemAccessResult      = new AccessResult(AccessPermission.Deny, oItemAccessExplanation);
                    Sitecore.Diagnostics.Log.Debug(sAccessExplanationText, this);
                    break;
                }
            }

            return(oItemAccessResult);
        }
 public void init()
 {
     accessResult                = null;
     detectBarcode               = null;
     commandComplete             = null;
     changedActionState          = null;
     onAsReaderTriggerKeyEvent   = null;
     onAsReaderLeftModeKeyEvent  = null;
     onAsReaderRightModeKeyEvent = null;
     readerInitialized           = null;
     updateDeviceState           = null;
     readTag = null;
     onAsReaderGUNDisconnected = null;
 }
Beispiel #14
0
        public void Test1 <T>()
        {
            // Specification before the actual check of the base-uri.
            Spec <Uri> spec =
                Spec.Of <Uri>("uri")
                .NotNull("uri should not be 'null'")
                .Equal(uri => uri.Scheme, Uri.UriSchemeHttps, "@scheme should be 'https' scheme");

            ValidationResult <Uri> validationResult = spec.Validate(new Uri("http://localhost", UriKind.Relative));

            // Demonstration purposes, generic type could be anything.
            IObservable <T> obs = null;

            // Access controlled function with validation, revocation, limited amount of evaluations and time-based availability.
            Access <Uri, Uri> access =
                Access.OnlyUriFromBase(new Uri("https://localhost:9090/"))
                .Satisfy(spec)
                .Once()
                .DuringHours(9, 17)
                .RevokedWhen(obs);

            // Somewhere else...
            AccessResult <Uri> result = access.Eval(new Uri("http://localhost:9090/path"));

            if (result.TryGetValue(out Uri output))
            {
                // use the now correct 'output'
            }

            int           unknown   = 5;
            Untrust <int> untrusted = unknown;

            ValidationResult <NonZeroInt> nonZeroIntValidationResult =
                Spec.Of <int>()
                .GreaterThan(0, "should not be zero")
                .CreateModel(untrusted, i => new NonZeroInt(i));

            Outcome <EbmsString, IDictionary <string, string[]> > ebmsStringResult = EbmsString.Create("mycustomid");

            var int100 = Valid <int> .Create(9, x => x > 0 && x < 100, "should be between 1-100");

            Outcome <EbmsString, Exception> deserialize = Json.Deserialize <EbmsString>(new Valid <JObject>());

            deserialize.Do(ex => throw ex);

            var nonEmptyResult = NonEmptyEnumerable <string> .Create(new[] { "test1", "test2", "test3" });

            var uniqueResult = UniqueEnumerable <int> .Create(new[] { 1, 2, 3 });
        }
Beispiel #15
0
        static string FormatMap(Player p, Level lvl)
        {
            bool canVisit = Player.IsSuper(p);

            if (!canVisit)
            {
                AccessResult access = lvl.VisitAccess.Check(p);
                canVisit = access == AccessResult.Allowed || access == AccessResult.Whitelisted;
            }

            string physics = " [" + lvl.physics + "]";
            string visit   = canVisit ? "" : " &c[no]";

            return(lvl.ColoredName + physics + visit);
        }
Beispiel #16
0
        bool CheckRank(Player p)
        {
            if (p.ZoneSpam <= DateTime.UtcNow)
            {
                BuildAccess.CheckDetailed(p);
                p.ZoneSpam = DateTime.UtcNow.AddSeconds(2);
            }
            if (p.level == this)
            {
                return(p.AllowBuild);
            }

            AccessResult access = BuildAccess.Check(p);

            return(access == AccessResult.Whitelisted || access == AccessResult.Allowed);
        }
Beispiel #17
0
        public async Task <IActionResult> PutById([FromRoute] Int32 id, [FromBody] Transfer.Producto.PutById data)
        {
            try
            {
                AccessResult <Producto> result = await Productos.Get(id);

                if (!result.IsValid && result.Result == null)
                {
                    return(NotFound());
                }

                result = await Productos.Put(new Producto
                {
                    Id             = id,
                    Nombre         = data.Nombre,
                    Descripcion    = data.Descripcion,
                    MaximoSemanal  = data.MaximoSemanal,
                    NecesitaReceta = data.NecesitaReceta ? "1" : "0",
                    PesoGr         = data.PesoGr,
                    Tipo           = data.Tipo,
                    PrecioUnidad   = data.PrecioUnidad,
                    Stock          = data.Stock,
                    Laboratorio    = data.Laboratorio
                });

                if (!result.IsValid)
                {
                    return(BadRequest(result.Fault));
                }

                Producto item = result.Result;
                return(Ok(new
                {
                    id = item.Id,
                    nombre = item.Nombre,
                    modificacion = DateTime.UtcNow.ToString()
                }));
            }
            catch (ArgumentNullException)
            {
                return(BadRequest(new AccessFault("Solicitud incompleta o inválida")));
            }
            catch (Exception e)
            {
                return(BadRequest(new AccessFault($"Error no controlado: {e.GetType()}")));
            }
        }
Beispiel #18
0
        public async Task <IActionResult> Autenticacion([FromBody] Transfer.Usuario.Autenticacion data)
        {
            try
            {
                AccessResult <BearerUser> result = await Usuarios.Authenticate(data.Rut, data.Password);

                return(!result.IsValid ? BadRequest(result.Fault) : (IActionResult)Ok(result.Result));
            }
            catch (ArgumentNullException)
            {
                return(BadRequest(new AccessFault("Solicitud incompleta o inválida")));
            }
            catch (Exception e)
            {
                return(BadRequest(new AccessFault($"Error no controlado: {e.GetType()}")));
            }
        }
Beispiel #19
0
        private String GetTitle(TransactionObject transactionObject, String profileId, ListViewItem item)
        {
            AccessResult <String> titleResult = m_RemoteAccessClient.ServiceProxy.GetTitle(transactionObject, profileId, false);

            AccessResult <String> originalTitleResult = m_RemoteAccessClient.ServiceProxy.GetOriginalTitle(transactionObject, profileId, false);

            item.Text = titleResult.Result;

            if (String.IsNullOrEmpty(originalTitleResult.Result) == false)
            {
                item.Text += " (" + originalTitleResult.Result + ")";
            }

            item.Tag = profileId;

            return(titleResult.Result);
        }
Beispiel #20
0
        public bool CheckDetailed(Player p, bool ignoreRankPerm = false)
        {
            AccessResult result = Check(p);

            if (result == AccessResult.Allowed)
            {
                return(true);
            }
            if (result == AccessResult.Whitelisted)
            {
                return(true);
            }
            if (result == AccessResult.AboveMaxRank && ignoreRankPerm)
            {
                return(true);
            }
            if (result == AccessResult.BelowMinRank && ignoreRankPerm)
            {
                return(true);
            }

            if (result == AccessResult.Blacklisted)
            {
                Player.Message(p, "You are blacklisted from {0} {1}", ActionIng, ColoredName);
                return(false);
            }

            string whitelist = "";

            if (Whitelisted.Count > 0)
            {
                whitelist = "(and " + Whitelisted.Join(pl => PlayerInfo.GetColoredName(p, pl)) + "%S) ";
            }

            if (result == AccessResult.BelowMinRank)
            {
                Player.Message(p, "Only {2}%S+ {3}may {0} {1}",
                               Action, ColoredName, Group.GetColoredName(Min), whitelist);
            }
            else if (result == AccessResult.AboveMaxRank)
            {
                Player.Message(p, "Only {2} %Sand below {3}may{0} {1}",
                               Action, ColoredName, Group.GetColoredName(Max), whitelist);
            }
            return(false);
        }
Beispiel #21
0
        void UpdateAllowBuild()
        {
            if (IsVisit)
            {
                return;
            }
            Player[] players = PlayerInfo.Online.Items;
            foreach (Player p in players)
            {
                if (p.level != lvl)
                {
                    continue;
                }

                AccessResult access = Check(p);
                p.AllowBuild = access == AccessResult.Whitelisted || access == AccessResult.Allowed;
            }
        }
Beispiel #22
0
        public async Task <IActionResult> PatchById([FromRoute] Int32 id, [FromBody] Transfer.Compra.PatchById data)
        {
            try
            {
                AccessResult <Compra> result = await Compras.Get(id);

                if (!result.IsValid && result.Result == null)
                {
                    return(NotFound());
                }

                Compra item = result.Result;

                if (User.IsInRole("Usuario") &&
                    (item.ReservaNavigation.Usuario != User.Identity.Name ||
                     data.Estado != 2))
                {
                    return(Forbid());
                }

                result = await Compras.Patch(id, data.Estado);

                if (!result.IsValid)
                {
                    return(BadRequest(result.Fault));
                }

                item = result.Result;
                return(Ok(new
                {
                    id = item.Id,
                    reserva = item.Reserva,
                    modificacion = DateTime.UtcNow.ToString()
                }));
            }
            catch (ArgumentNullException)
            {
                return(BadRequest(new AccessFault("Solicitud incompleta o inválida")));
            }
            catch (Exception e)
            {
                return(BadRequest(new AccessFault($"Error no controlado: {e.GetType()}")));
            }
        }
Beispiel #23
0
        public async Task <IActionResult> Post([FromBody] Transfer.Producto.Post data)
        {
            Producto item;

            try
            {
                item = new Producto
                {
                    Nombre         = data.Nombre,
                    Descripcion    = data.Descripcion,
                    MaximoSemanal  = data.MaximoSemanal,
                    NecesitaReceta = data.NecesitaReceta ? "1" : "0",
                    PesoGr         = data.PesoGr,
                    Tipo           = data.Tipo,
                    PrecioUnidad   = data.PrecioUnidad,
                    Stock          = data.Stock ?? 0,
                    Laboratorio    = data.Laboratorio
                };

                AccessResult <Producto> result = await Productos.Post(item);

                if (!result.IsValid)
                {
                    return(BadRequest(result.Fault));
                }

                item = result.Result;
                return(CreatedAtAction(nameof(GetById), new { id = item.Id }, new
                {
                    id = item.Id,
                    nombre = item.Nombre,
                    creacion = DateTime.UtcNow.ToString()
                }));
            }
            catch (ArgumentNullException)
            {
                return(BadRequest(new AccessFault("Datos incompletos o inválidos")));
            }
            catch (Exception e)
            {
                return(BadRequest(new AccessFault($"Error no controlado: {e.GetType()}")));
            }
        }
Beispiel #24
0
        public async Task <IActionResult> Post([FromBody] Transfer.Usuario.Post data)
        {
            Usuario user;

            try
            {
                user = new Usuario
                {
                    Rut             = data.Rut,
                    Password        = data.Password,
                    Nombre          = data.Nombre,
                    Email           = data.Email,
                    FechaNacimiento = data.FechaNacimiento,
                    Rol             = data.Rol.Value
                };

                AccessResult <Usuario> result = await Usuarios.Post(user);

                if (!result.IsValid)
                {
                    return(BadRequest(result.Fault));
                }

                user = result.Result;
                return(CreatedAtAction(nameof(GetByRut), new { rut = user.Rut }, new
                {
                    rut = user.Rut,
                    nombre = user.Nombre,
                    email = user.Email,
                    rol = user.Rol,
                    creacion = DateTime.UtcNow.ToString()
                }));
            }
            catch (ArgumentNullException)
            {
                return(BadRequest(new AccessFault("Datos incompletos o inválidos")));
            }
            catch (Exception e)
            {
                return(BadRequest(new AccessFault($"Error no controlado: {e.GetType()}")));
            }
        }
Beispiel #25
0
        static bool CheckVisitPerm(Player p, Player target, bool confirmed)
        {
            AccessResult result = p.level.VisitAccess.Check(target.name, target.Rank);

            if (result == AccessResult.Allowed)
            {
                return(true);
            }
            if (result == AccessResult.Whitelisted)
            {
                return(true);
            }
            if (result == AccessResult.AboveMaxRank && confirmed)
            {
                return(true);
            }
            if (result == AccessResult.BelowMinRank && confirmed)
            {
                return(true);
            }

            if (result == AccessResult.Blacklisted)
            {
                p.Message("{0} &Sis blacklisted from visiting this map.", p.FormatNick(target));
                return(false);
            }
            else if (result == AccessResult.BelowMinRank)
            {
                p.Message("Only {0}&S+ may normally visit this map. {1}&S is ranked {2}",
                          Group.GetColoredName(p.level.VisitAccess.Min),
                          p.FormatNick(target), target.group.ColoredName);
            }
            else if (result == AccessResult.AboveMaxRank)
            {
                p.Message("Only {0}&S and below may normally visit this map. {1}&S is ranked {2}",
                          Group.GetColoredName(p.level.VisitAccess.Max),
                          p.FormatNick(target), target.group.ColoredName);
            }

            p.Message("If you still want to summon them, type &T/Summon {0} confirm", target.name);
            return(false);
        }
Beispiel #26
0
        static bool CheckVisitPerm(Player p, Player who, bool confirmed)
        {
            AccessResult result = p.level.VisitAccess.Check(who);

            if (result == AccessResult.Allowed)
            {
                return(true);
            }
            if (result == AccessResult.Whitelisted)
            {
                return(true);
            }
            if (result == AccessResult.AboveMaxRank && confirmed)
            {
                return(true);
            }
            if (result == AccessResult.BelowMinRank && confirmed)
            {
                return(true);
            }

            if (result == AccessResult.Blacklisted)
            {
                Player.Message(p, "{0} %Sis blacklisted from visiting this map.", who.ColoredName);
                return(false);
            }
            else if (result == AccessResult.BelowMinRank)
            {
                Player.Message(p, "Only {0}%S+ may normally visit this map. {1}%S is ranked {2}",
                               Group.GetColoredName(p.level.VisitAccess.Min),
                               who.ColoredName, who.group.ColoredName);
            }
            else if (result == AccessResult.AboveMaxRank)
            {
                Player.Message(p, "Only {0}%S and below may normally visit this map. {1}%S is ranked {2}",
                               Group.GetColoredName(p.level.VisitAccess.Max),
                               who.ColoredName, who.group.ColoredName);
            }

            Player.Message(p, "If you still want to summon them, type %T/Summon {0} confirm", who.name);
            return(false);
        }
Beispiel #27
0
        public async Task <IActionResult> Get([FromQuery] Transfer.Usuario.Get data)
        {
            try
            {
                AccessResult <IEnumerable <Usuario> > result = await Usuarios.GetAll();

                if (!result.IsValid)
                {
                    return(BadRequest(result.Fault));
                }

                IEnumerable <Usuario> users = result.Result;
                if (data.Rol != null)
                {
                    users = users.Where(x => x.Rol == data.Rol);
                }
                if (data.Cantidad != null)
                {
                    users = users.Take(data.Cantidad.Value);
                }

                return(Ok(users.Select(x => new
                {
                    rut = x.Rut,
                    nombre = x.Nombre,
                    email = x.Email,
                    fecha_nacimiento = x.FechaNacimiento,
                    rol = x.Rol
                })));
            }
            catch (ArgumentNullException)
            {
                return(BadRequest(new AccessFault("Solicitud incompleta o inválida")));
            }
            catch (Exception e)
            {
                return(BadRequest(new AccessFault($"Error no controlado: {e.GetType()}")));
            }
        }
Beispiel #28
0
        public async Task <IActionResult> Post([FromBody] Transfer.Reserva.Post data)
        {
            try
            {
                var item = new Reserva {
                    Usuario = data.Usuario
                };

                var reservas = new List <ReservaStock>(data.Reservas.Select(x => new ReservaStock()
                {
                    Producto = x.Producto,
                    Cantidad = x.Cantidad
                }));

                AccessResult <Reserva> result = await Reservas.Post(item, reservas);

                if (!result.IsValid)
                {
                    return(BadRequest(result.Fault));
                }

                item = result.Result;
                return(CreatedAtAction(nameof(GetById), new { id = item.Id }, new
                {
                    id = item.Id,
                    usuario = item.Usuario,
                    reservas = item.ReservaStock.Select(y => new { cantidad = y.Cantidad, producto = y.Producto }),
                    creacion = DateTime.UtcNow.ToString()
                }));
            }
            catch (ArgumentNullException)
            {
                return(BadRequest(new AccessFault("Datos incompletos o inválidos")));
            }
            catch (Exception e)
            {
                return(BadRequest(new AccessFault($"Error no controlado: {e.GetType()}")));
            }
        }
Beispiel #29
0
        public async Task <IActionResult> GetById([FromRoute] Int32 id)
        {
            try
            {
                AccessResult <Compra> result = await Compras.Get(id);

                if (!result.IsValid && result.Result == null)
                {
                    return(NotFound());
                }

                Compra item = result.Result;
                return(User.IsInRole("Usuario") && item.ReservaNavigation.Usuario != User.Identity.Name
                                        ? Forbid()
                                        : (IActionResult)Ok(new
                {
                    id = item.Id,
                    estado = item.Estado,
                    reserva = new
                    {
                        id = item.ReservaNavigation.Id,
                        usuario = item.ReservaNavigation.Usuario,
                        reservas = item.ReservaNavigation.ReservaStock.Select(y => new
                        {
                            cantidad = y.Cantidad,
                            producto = y.Producto
                        })
                    }
                }));
            }
            catch (ArgumentNullException)
            {
                return(BadRequest(new AccessFault("Solicitud incompleta o inválida")));
            }
            catch (Exception e)
            {
                return(BadRequest(new AccessFault($"Error no controlado: {e.GetType()}")));
            }
        }
Beispiel #30
0
        public bool CheckDetailed(Player p, LevelPermission plRank)
        {
            AccessResult access = Check(p.name, plRank);

            if (access == AccessResult.Allowed)
            {
                return(true);
            }
            if (access == AccessResult.Whitelisted)
            {
                return(true);
            }

            if (access == AccessResult.Blacklisted)
            {
                p.Message("You are blacklisted from {0} {1}", ActionIng, ColoredName);
                return(false);
            }

            string whitelist = "";

            if (Whitelisted.Count > 0)
            {
                whitelist = "(and " + Whitelisted.Join(pl => p.FormatNick(pl)) + "%S) ";
            }

            if (access == AccessResult.BelowMinRank)
            {
                p.Message("Only {2}%S+ {3}may {0} {1}",
                          Action, ColoredName, Group.GetColoredName(Min), whitelist);
            }
            else if (access == AccessResult.AboveMaxRank)
            {
                p.Message("Only {2} %Sand below {3}may {0} {1}",
                          Action, ColoredName, Group.GetColoredName(Max), whitelist);
            }
            return(false);
        }
Beispiel #31
0
        public async Task <IActionResult> PutByRut([FromRoute] String rut, [FromBody] Transfer.Usuario.PutByRut data)
        {
            try
            {
                AccessResult <Usuario> result = await Usuarios.Put(new Usuario
                {
                    Rut             = rut,
                    Email           = data.Email,
                    FechaNacimiento = data.FechaNacimiento,
                    Rol             = data.Rol.Value,
                    Password        = data.Password
                });

                if (!result.IsValid)
                {
                    return(BadRequest(result.Fault));
                }

                Usuario user = result.Result;
                return(Ok(new
                {
                    rut = user.Rut,
                    nombre = user.Nombre,
                    email = user.Email,
                    fecha_nacimiento = user.FechaNacimiento,
                    rol = user.Rol,
                    modificacion = DateTime.UtcNow.ToString()
                }));
            }
            catch (ArgumentNullException)
            {
                return(BadRequest(new AccessFault("Solicitud incompleta o inválida")));
            }
            catch (Exception e)
            {
                return(BadRequest(new AccessFault($"Error no controlado: {e.GetType()}")));
            }
        }
Beispiel #32
0
        private void OnTimer1Tick(Object sender
                                  , EventArgs e)
        {
            Timer.Stop();

            if (m_ChangeNotificationObject != null)
            {
                TransactionObject transactionObject = m_RemoteAccessClient.ServiceProxy.BeginTransaction();

                AccessResult <List <String> > changedProfiles = m_RemoteAccessClient.ServiceProxy.PollChangedProfiles(transactionObject, m_ChangeNotificationObject, false);

                if (changedProfiles.Result.Count > 0)
                {
                    for (Int32 i = 0; i < ProfileIdListView.Items.Count; i++)
                    {
                        ListViewItem item = ProfileIdListView.Items[i];

                        String profileId = item.Tag.ToString();

                        if (changedProfiles.Result.Contains(profileId))
                        {
                            String title = GetTitle(transactionObject, profileId, item);

                            if ((ProfileIdListView.SelectedIndices.Count == 1) &&
                                (ProfileIdListView.SelectedIndices[0] == i))
                            {
                                TitleTextBox.Text = title;
                            }
                        }
                    }
                }

                m_RemoteAccessClient.ServiceProxy.CommitTransaction(transactionObject);
            }

            Timer.Start();
        }
Beispiel #33
0
        /// <summary> Changes the rank of the given player from the old to the new rank. </summary>
        internal static void ChangeRank(string name, Group oldRank, Group newRank,
                                        Player who, bool saveToNewRank = true)
        {
            Server.reviewlist.Remove(name);
            oldRank.Players.Remove(name);
            oldRank.Players.Save();

            if (saveToNewRank)
            {
                newRank.Players.Add(name);
                newRank.Players.Save();
            }
            if (who == null)
            {
                return;
            }

            Entities.DespawnEntities(who, false);
            string dbCol = PlayerData.FindDBColor(who);

            if (dbCol.Length == 0)
            {
                who.color = newRank.Color;
            }

            who.group = newRank;
            AccessResult access = who.level.BuildAccess.Check(who);

            who.AllowBuild = access == AccessResult.Whitelisted || access == AccessResult.Allowed;

            who.SetPrefix();
            who.Send(Packet.UserType(who));
            who.SendCurrentBlockPermissions();
            Entities.SpawnEntities(who, false);
            CheckBlockBindings(who);
        }