public void Delete(VolunteerCEO volunteerCEO) { var res = Db.Query().CommandText("delete corporationceotakeover where corporationeid=@corporationEID") .SetParameter("@corporationEID", volunteerCEO.corporation.Eid) .ExecuteNonQuery(); if (res == 0) { throw new PerpetuumException(ErrorCodes.SQLDeleteError); } }
public VolunteerCEO AddVolunteer(Corporation corporation, Character character) { var volunteerCEO = new VolunteerCEO { character = character, expiry = Expiry, corporation = corporation }; _volunteerCEORepository.Insert(volunteerCEO); return(volunteerCEO); }
private VolunteerCEO CreateVolunteerCEOFromRecord(IDataRecord record) { var corporationEid = record.GetValue <long>("corporationeid"); var v = new VolunteerCEO { character = Character.Get(record.GetValue <int>("characterid")), expiry = record.GetValue <DateTime>("expiry"), corporation = (Corporation)_entityRepository.Load(corporationEid) }; return(v); }
public void Insert(VolunteerCEO volunteerCEO) { var res = Db.Query().CommandText("insert corporationceotakeover (corporationeid,characterid,expiry) values (@corporationEID, @characterID,@expiry)") .SetParameter("@characterID", volunteerCEO.character.Id) .SetParameter("@corporationEID", volunteerCEO.corporation.Eid) .SetParameter("@expiry", volunteerCEO.expiry) .ExecuteNonQuery(); if (res == 0) { throw new PerpetuumException(ErrorCodes.SQLInsertError); } }
public void TakeOverCeoRole(VolunteerCEO volunteerCEO) { Logger.Info($"takeover for {volunteerCEO}"); var corporation = volunteerCEO.character.GetPrivateCorporationOrThrow(); using (var scope = Db.CreateTransaction()) { try { if (corporation.Eid != volunteerCEO.corporation.Eid) { return; } var volunteerCharacter = volunteerCEO.character; var role = corporation.GetMemberRole(volunteerCharacter); var oldRole = role; var currentCEO = corporation.CEO; if (currentCEO == volunteerCEO.character || !role.HasFlag(CorporationRole.DeputyCEO) || role.HasFlag(CorporationRole.CEO)) { return; } //check member count again, possible downgrade could've happened var desiredCEOMaxMembers = corporation.GetMaxmemberByCharacter(volunteerCharacter); if (corporation.Members.Length > desiredCEOMaxMembers) { return; } role = role.SetRole(CorporationRole.CEO); role = role.ClearRole(CorporationRole.DeputyCEO); corporation.SetMemberRole(volunteerCharacter, role); corporation.WriteRoleHistory(volunteerCEO.character, volunteerCEO.character, role, oldRole); _channelManager.SetMemberRole(corporation.ChannelName, volunteerCEO.character, role); //old ceo var currentCeoRole = corporation.GetMemberRole(currentCEO); var oldCurrentCeoRole = currentCeoRole; currentCeoRole = currentCeoRole.ClearRole(CorporationRole.CEO); currentCeoRole = currentCeoRole.SetRole(CorporationRole.DeputyCEO); corporation.SetMemberRole(currentCEO, currentCeoRole); corporation.WriteRoleHistory(currentCEO, currentCEO, currentCeoRole, oldCurrentCeoRole); _channelManager.SetMemberRole(corporation.ChannelName, currentCEO, currentCeoRole); CorporationData.RemoveFromCache(corporation.Eid); Logger.Info($"{volunteerCharacter} took over CEO for {currentCEO} at corporationeid:{corporation.Eid}"); _volunteerCEORepository.Delete(volunteerCEO); //ok inform Transaction.Current.OnCompleted(c => { SendVolunteerStatusToMembers(volunteerCEO); }); scope.Complete(); } catch (Exception ex) { Logger.Exception(ex); } } }
public void ClearVolunteer(VolunteerCEO volunteerCEO) { _volunteerCEORepository.Delete(volunteerCEO); }
public void SendVolunteerStatusToMembers(VolunteerCEO volunteerCEO) { Message.Builder.SetCommand(Commands.CorporationCeoTakeOverStatus).WithData(volunteerCEO.ToDictionary()).ToCharacters(volunteerCEO.corporation.GetCharacterMembers()).Send(); }
public void Update(VolunteerCEO item) { throw new NotImplementedException(); }