Ejemplo n.º 1
0
        public static CorporationRole CleanUpHangarAccess(this CorporationRole role)
        {
            var resultRole = (int)role;

            //has low remove => needs low access
            if (role.IsAnyRole(CorporationRole.HangarRemove_low))
            {
                resultRole = (resultRole | (int)CorporationRole.HangarAccess_low);
            }

            //has medium remove => needs medium access
            if (role.IsAnyRole(CorporationRole.HangarRemove_medium))
            {
                resultRole = (resultRole | (int)CorporationRole.HangarAccess_medium);
            }

            if (role.IsAnyRole(CorporationRole.HangarRemove_high))
            {
                resultRole = (resultRole | (int)CorporationRole.HangarAccess_high);
            }

            if (role.IsAnyRole(CorporationRole.HangarRemove_secure))
            {
                resultRole = (resultRole | (int)CorporationRole.HangarAccess_secure);
            }

            return((CorporationRole)resultRole);
        }
Ejemplo n.º 2
0
        public bool HasAccess(CorporationRole memberRole, ContainerAccess access)
        {
            //not defined for this container
            if (HangarAccess == CorporationRole.NotDefined)
            {
                return(true);
            }

            //corp lord?
            if (memberRole.IsAnyRole(CorporationRole.CEO, CorporationRole.DeputyCEO))
            {
                return(true);
            }

            //return a single bit: the highest
            var hangarAccess = HangarAccess.GetHighestContainerAccess();

            // let's check the action
            var expectedAccess = (int)memberRole.CleanUpHangarAccess() & (int)hangarAccess;

            if (expectedAccess == 0)
            {
                return(false);
            }

            if (access != ContainerAccess.Delete && access != ContainerAccess.Remove && access != ContainerAccess.List)
            {
                return(true);
            }

            return(memberRole.IsAnyRole(hangarAccess.GetRelatedRemoveAccess()));
        }
 public Character[] LoadCorporationMembersWithAnyRole(long corporationEid, CorporationRole corporationRole)
 {
     return(Db.Query().CommandText("select memberid from corporationmembers where corporationeid=@corpEID and ((role & @roleMask) > 0)")
            .SetParameter("@corpEID", corporationEid)
            .SetParameter("@roleMask", corporationRole)
            .Execute().Select(r => Character.Get(r.GetValue <int>(0))).ToArray());
 }
Ejemplo n.º 4
0
        public void SetMemberRole(Character member, CorporationRole newRole)
        {
            Db.Query().CommandText("update corporationmembers set role = @role where memberid = @memberid and corporationEID = @corporationEID")
            .SetParameter("@role", (int)newRole)
            .SetParameter("@corporationEID", Eid)
            .SetParameter("@memberid", member.Id)
            .ExecuteNonQuery().ThrowIfNotEqual(1, ErrorCodes.SQLUpdateError);

            _members = null;

            Transaction.Current.OnCommited(() =>
            {
                OnMemberRoleUpdated(member, newRole);

                Message.Builder.SetCommand(Commands.CorporationSetMemberRole)
                .WithData(new Dictionary <string, object> {
                    { k.memberID, member.Id }, { k.newRole, (int)newRole }
                })
                .ToCharacters(GetCharacterMembers())
                .Send();


                ZoneManager.Value.Zones.ForEach(z => z.UpdateCorporation(CorporationCommand.ChangeRole, new Dictionary <string, object>
                {
                    { k.characterID, member.Id },
                    { k.role, (int)newRole },
                    { k.corporationEID, Eid }
                }));
            });
        }
Ejemplo n.º 5
0
        public static CorporationRole CleanUpCharacterPBSRoles(this CorporationRole role)
        {
            if (role.HasFlag(CorporationRole.editPBS))
            {
                role.SetRole(CorporationRole.viewPBS);
            }

            return(role);
        }
Ejemplo n.º 6
0
        public void SendByCorporationRole(IMessage message, Corporation corporation, CorporationRole role)
        {
            var mi = new MessageInfo
            {
                message     = message,
                corporation = corporation,
                role        = role
            };

            Enqueue(mi);
        }
Ejemplo n.º 7
0
        public virtual void AddMember(Character member, CorporationRole role, Corporation oldCorporation)
        {
            //update history
            WriteMemberHistory(member, oldCorporation);
            member.CorporationEid = Eid;

            Db.Query().CommandText("update corporationmembers set corporationEID = @corporationEID,role = @role where memberid = @memberid")
            .SetParameter("@corporationEID", Eid)
            .SetParameter("@memberid", member.Id)
            .SetParameter("@role", role)
            .ExecuteNonQuery().ThrowIfEqual(0, ErrorCodes.SQLUpdateError);

            _members = null;
        }
Ejemplo n.º 8
0
        public void WriteRoleHistory(Character issuer, Character member, CorporationRole newrole, CorporationRole oldrole)
        {
            if (newrole == oldrole)
            {
                return;
            }

            Db.Query().CommandText("insert corporationrolehistory (corporationEID,issuerID,memberID,oldrole,newrole) values (@corporationEID,@issuerID,@memberID,@oldrole,@newrole)")
            .SetParameter("@corporationEID", Eid)
            .SetParameter("@issuerID", issuer.Id)
            .SetParameter("@memberID", member.Id)
            .SetParameter("@newrole", (int)newrole)
            .SetParameter("@oldrole", (int)oldrole)
            .ExecuteNonQuery();
        }
        /// <summary>
        /// This command refreshes the corporation production info
        /// Technically corp members with proper roles see their corpmate's production events. start/end/cancel
        /// </summary>
        /// <param name="command"></param>
        private void SendProductionEventToCorporationMembers(Command command)
        {
            if (!useCorporationWallet)
            {
                return;
            }

            var replyDict = new Dictionary <string, object> {
                { k.production, ToDictionary() }
            };

            const CorporationRole roleMask = CorporationRole.CEO | CorporationRole.DeputyCEO | CorporationRole.ProductionManager | CorporationRole.Accountant;

            Message.Builder.SetCommand(command)
            .WithData(replyDict)
            .ToCorporation(character.CorporationEid, roleMask)
            .Send();
        }
        public static void InformProductionEvent(ProductionInProgress productionInProgress, Command command)
        {
            if (!productionInProgress.useCorporationWallet)
            {
                return;
            }

            var replyDict      = new Dictionary <string, object>();
            var productionDict = productionInProgress.ToDictionary();

            replyDict.Add(k.production, productionDict);

            const CorporationRole roleMask = CorporationRole.CEO | CorporationRole.DeputyCEO | CorporationRole.ProductionManager | CorporationRole.Accountant;

            Message.Builder.SetCommand(command)
            .WithData(replyDict)
            .ToCorporation(productionInProgress.character.CorporationEid, roleMask)
            .Send();
        }
Ejemplo n.º 11
0
        public static CorporationRole GetRelatedRemoveAccess(this CorporationRole corporationRole)
        {
            if (corporationRole.IsAnyRole(CorporationRole.HangarAccess_secure))
            {
                return(CorporationRole.HangarRemove_secure);
            }

            if (corporationRole.IsAnyRole(CorporationRole.HangarAccess_high))
            {
                return(CorporationRole.HangarRemove_high);
            }

            if (corporationRole.IsAnyRole(CorporationRole.HangarAccess_medium))
            {
                return(CorporationRole.HangarRemove_medium);
            }

            if (corporationRole.IsAnyRole(CorporationRole.HangarAccess_low))
            {
                return(CorporationRole.HangarRemove_low);
            }

            return(CorporationRole.HangarRemove_low);
        }
Ejemplo n.º 12
0
        public static CorporationRole GetHighestContainerAccess(this CorporationRole corporationRole)
        {
            if (corporationRole.IsAnyRole(CorporationRole.HangarAccess_secure))
            {
                return(CorporationRole.HangarAccess_secure);
            }

            if (corporationRole.IsAnyRole(CorporationRole.HangarAccess_high))
            {
                return(CorporationRole.HangarAccess_high);
            }

            if (corporationRole.IsAnyRole(CorporationRole.HangarAccess_medium))
            {
                return(CorporationRole.HangarAccess_medium);
            }

            if (corporationRole.IsAnyRole(CorporationRole.HangarAccess_low))
            {
                return(CorporationRole.HangarAccess_low);
            }

            return(CorporationRole.HangarAccess_low);
        }
Ejemplo n.º 13
0
        public static bool Is(this CorporationRole role, long value)
        {
            long longRole = (long)role;

            return((value & longRole) == longRole);
        }
Ejemplo n.º 14
0
 public static bool IsAllProbesVisible(CorporationRole role)
 {
     return(role.IsAnyRole(CorporationRole.CEO, CorporationRole.DeputyCEO));
 }
Ejemplo n.º 15
0
        private IEnumerable <Character> GetProximityBoard(long corporationEid)
        {
            const CorporationRole roleMask = CorporationRole.CEO | CorporationRole.DeputyCEO | CorporationRole.Accountant;

            return(CorporationManager.LoadCorporationMembersWithAnyRole(corporationEid, roleMask));
        }
Ejemplo n.º 16
0
 public static bool HasRole(this CorporationRole role, CorporationRole otherRole)
 {
     return((role & otherRole) > 0);
 }
Ejemplo n.º 17
0
        /// <summary>
        /// this must be the quickest way to get the corpEid and role.
        ///
        /// often only these two are needed...
        /// zoneGetBuildings and other requests use this.
        ///
        ///
        /// </summary>
        /// <param name="character"></param>
        /// <param name="corporationEid"></param>
        /// <param name="role"></param>
        /// <returns></returns>
        public static ErrorCodes GetCorporationEidAndRoleFromSql(Character character, out long corporationEid, out CorporationRole role)
        {
            corporationEid = 0;
            role           = CorporationRole.NotDefined;

            var record = Db.Query().CommandText("select corporationEID,role from dbo.getCorporationEidAndRole(@characterID)")
                         .SetParameter("@characterID", character.Id)
                         .ExecuteSingleRow();

            if (record == null)
            {
                return(ErrorCodes.CharacterNotFound);
            }

            corporationEid = record.GetValue <long>(0);
            role           = (CorporationRole)record.GetValue <int>(1);


            return(ErrorCodes.NoError);
        }
Ejemplo n.º 18
0
 public void SetHangarAccess(Character character, CorporationRole corporationRole)
 {
     DynamicProperties.Update(k.hangarAccess, (int)corporationRole);
     AddLogEntry(character, ContainerAccess.SetAccess);
 }
 public static void SetMemberRole(this IChannelManager channelManager, string name, Character member, CorporationRole corporationRole)
 {
     channelManager.SetMemberRole(name, member, GetChannelMemberRoleByCorporationRole(corporationRole));
 }
 private static ChannelMemberRole GetChannelMemberRoleByCorporationRole(CorporationRole corporationRole)
 {
     return(corporationRole.IsAnyRole(CorporationRole.CEO, CorporationRole.DeputyCEO, CorporationRole.HRManager, CorporationRole.PRManager) ?
            ChannelMemberRole.Operator :
            ChannelMemberRole.Undefined);
 }
Ejemplo n.º 21
0
 public static bool IsAnyRole(this CorporationRole role, params CorporationRole[] roles)
 {
     return(roles.Any(r => (role & r) > 0));
 }
Ejemplo n.º 22
0
 public static bool HasAllRoles(this CorporationRole role, params CorporationRole[] roles)
 {
     return(roles.All(r => (role & r) != 0));
 }
Ejemplo n.º 23
0
 public void CheckAccessAndThrowIfFailed(CorporationRole memberRole, ContainerAccess access)
 {
     HasAccess(memberRole, access).ThrowIfFalse(ErrorCodes.InsufficientPrivileges);
 }
 public static void JoinChannel(this IChannelManager channelManager, string name, Character member, CorporationRole corporationRole)
 {
     channelManager.JoinChannel(name, member, GetChannelMemberRoleByCorporationRole(corporationRole), null);
 }
Ejemplo n.º 25
0
 public override void AddMember(Character member, CorporationRole role, Corporation oldCorporation)
 {
     member.AllianceEid = DefaultCorporationDataCache.GetAllianceEidByCorporationEid(Eid);
     base.AddMember(member, role, oldCorporation);
 }
 public override void AddMember(Character member, CorporationRole role, Corporation oldCorporation)
 {
     member.AllianceEid = 0L;
     base.AddMember(member, role, oldCorporation);
 }
Ejemplo n.º 27
0
 public MessageBuilder ToCorporation(Corporation corporation, CorporationRole role)
 {
     return(SetupMessageSender(m => _corporationMessageSender.SendByCorporationRole(m, corporation, role)));
 }
Ejemplo n.º 28
0
        public void HandleRequest(IRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var source    = request.Data.GetOrDefault <long>(k.source);
                var target    = request.Data.GetOrDefault <long>(k.target);
                var character = request.Session.Character;

                source.ThrowIfEqual(target, ErrorCodes.WTFErrorMedicalAttentionSuggested);

                var standingValue = request.Data.GetOrDefault <double>(k.standing);

                var sourceEntity = Entity.Repository.LoadOrThrow(source);
                var targetEntity = Entity.Repository.LoadOrThrow(target);


                //standing can only be set to a characterEID or corporation or alliance
                (!targetEntity.IsCategory(CategoryFlags.cf_player) &&
                 !targetEntity.IsCategory(CategoryFlags.cf_corporation) &&
                 !targetEntity.IsCategory(CategoryFlags.cf_alliance)).ThrowIfTrue(ErrorCodes.AccessDenied);

                if (targetEntity is Corporation)
                {
                    //only private corp
                    targetEntity.ThrowIfNotType <PrivateCorporation>(ErrorCodes.AccessDenied);
                }

                if (targetEntity is Alliance)
                {
                    //only private alliance
                    targetEntity.ThrowIfNotType <PrivateAlliance>(ErrorCodes.AccessDenied);
                }

                //standing can only be set to a characterEID or corporation or alliance
                (!sourceEntity.IsCategory(CategoryFlags.cf_player) &&
                 !sourceEntity.IsCategory(CategoryFlags.cf_corporation) &&
                 !sourceEntity.IsCategory(CategoryFlags.cf_alliance)).ThrowIfTrue(ErrorCodes.AccessDenied);

                var sourceCorporation = sourceEntity as PrivateCorporation;
                if (sourceCorporation != null)
                {
                    //only private corp
                    character.CorporationEid.ThrowIfNotEqual(sourceCorporation.Eid, ErrorCodes.AccessDenied);
                    sourceCorporation.IsAnyRole(character, CorporationRole.CEO, CorporationRole.DeputyCEO, CorporationRole.PRManager).ThrowIfFalse(ErrorCodes.InsufficientPrivileges);
                }

                if (sourceEntity is Alliance)
                {
                    //only private alliance
                    sourceEntity.ThrowIfNotType <PrivateAlliance>(ErrorCodes.AccessDenied);
                }

                //character only to character
                (sourceEntity.IsCategory(CategoryFlags.cf_player) && !targetEntity.IsCategory(CategoryFlags.cf_player)).ThrowIfTrue(ErrorCodes.AccessDenied);

                //corporation only to corporation
                (sourceEntity.IsCategory(CategoryFlags.cf_corporation) && !targetEntity.IsCategory(CategoryFlags.cf_corporation)).ThrowIfTrue(ErrorCodes.AccessDenied);

                //alliance only to alliance
                (sourceEntity.IsCategory(CategoryFlags.cf_alliance) && !targetEntity.IsCategory(CategoryFlags.cf_alliance)).ThrowIfTrue(ErrorCodes.AccessDenied);

                //finally set the standing
                _standingHandler.SetStanding(source, target, standingValue);

                if (sourceCorporation != null)
                {
                    Message.Builder.SetCommand(request.Command)
                    .WithData(new Dictionary <string, object> {
                        { k.result, request.Data }
                    })
                    .ToCorporation(sourceCorporation)
                    .Send();

                    var targetCorporation = targetEntity as PrivateCorporation;
                    if (targetCorporation != null)
                    {
                        var result = new Dictionary <string, object>
                        {
                            { k.sourceEID, source },
                            { k.standing, new Dictionary <string, object>
                              {
                                  { "s1", new Dictionary <string, object>
                                    {
                                        { k.targetEID, target },
                                        { k.standing, standingValue }
                                    } }
                              } }
                        };

                        //inform target corporation members
                        const CorporationRole roleMask = CorporationRole.CEO | CorporationRole.DeputyCEO | CorporationRole.PRManager;

                        Message.Builder.SetCommand(Commands.StandingSetOnMyCorporation)
                        .WithData(result)
                        .WrapToResult()
                        .ToCorporation(targetCorporation, roleMask)
                        .Send();
                    }

                    return;
                }

                Message.Builder.FromRequest(request)
                .WithData(request.Data)
                .WrapToResult()
                .WithEmpty()
                .Send();

                scope.Complete();
            }
        }
Ejemplo n.º 29
0
 public static CorporationRole ClearRole(this CorporationRole currentRole, CorporationRole clearThis)
 {
     return((CorporationRole)((uint)currentRole & ~((uint)clearThis)));
 }
Ejemplo n.º 30
0
 public static CorporationRole SetRole(this CorporationRole currentRole, CorporationRole setThis)
 {
     return(currentRole | setThis);
 }