public void HandleRequest(IRequest request) { var character = request.Session.Character; var result = CorporationDocumentHelper.GetMyDocumentsToDictionary(character); Message.Builder.FromRequest(request).WithData(result).Send(); }
public void HandleRequest(IRequest request) { using (var scope = Db.CreateTransaction()) { var character = request.Session.Character; var documentId = request.Data.GetOrDefault<int>(k.ID); var targetCharacter = Character.Get(request.Data.GetOrDefault<int>(k.target)); character.GetPrivateCorporationOrThrow(); character.IsFriend(targetCharacter).ThrowIfFalse(ErrorCodes.CharacterIsNotAFriend); CorporationDocument corporationDocument; CorporationDocumentHelper.CheckOwnerAccess(documentId, character, out corporationDocument).ThrowIfError(); //check amount and stuff CorporationDocumentHelper.OnDocumentTransfer(corporationDocument, targetCharacter).ThrowIfError(); corporationDocument._ownerCharacter = targetCharacter; corporationDocument.UpdateOwnerToSql().ThrowIfError(); //unregister document and all viewer character CorporationDocumentHelper.DeleteViewerByDocumentId(documentId); var targetResult = CorporationDocumentHelper.GetMyDocumentsToDictionary(targetCharacter); var senderResult = CorporationDocumentHelper.GetMyDocumentsToDictionary( character); Message.Builder.FromRequest(request).WithData(senderResult).Send(); Message.Builder.SetCommand(request.Command).WithData(targetResult).ToCharacter(targetCharacter).Send(); scope.Complete(); } }
public void HandleRequest(IRequest request) { using (var scope = Db.CreateTransaction()) { var character = request.Session.Character; var documentId = request.Data.GetOrDefault <int>(k.ID); var registeredList = request.Data.GetOrDefault <int[]>(k.members); var writeMembers = request.Data.GetOrDefault <int[]>(k.writeAccess); var finalRegisteredList = registeredList.Distinct().Where(d => d != character.Id).ToArray(); var finalWriteMembers = finalRegisteredList.Intersect(writeMembers).Distinct().ToArray(); CorporationDocumentHelper.CheckOwnerAccess(documentId, character, out var corporationDocument).ThrowIfError(); finalRegisteredList.Length.ThrowIfGreater(CorporationDocument.MAX_REGISTERED_MEMBERS, ErrorCodes.MaximumAllowedRegistrationExceeded); corporationDocument.SetRegistration(finalRegisteredList, finalWriteMembers); var result = new Dictionary <string, object> { { k.ID, documentId }, { k.registered, finalRegisteredList }, { k.writeAccess, finalWriteMembers } }; Message.Builder.FromRequest(request).WithData(result).Send(); scope.Complete(); } }
public void HandleRequest(IRequest request) { using (var scope = Db.CreateTransaction()) { var character = request.Session.Character; var documentId = request.Data.GetOrDefault <int>(k.ID); CorporationDocumentHelper.CheckOwnerAccess(documentId, character, out var corporationDocument).ThrowIfError(); corporationDocument.Delete().ThrowIfError(); corporationDocument.DeleteAllRegistered(); var registered = CorporationDocumentHelper.GetRegisteredCharactersFromDocument(documentId).ToList(); //beleaddoljuk azt is aki letorolte, meg mindenkit aki epp nezi if (!registered.Contains(character)) { registered.Add(character); } CorporationDocumentHelper.DeleteViewerByDocumentId(documentId); var result = CorporationDocumentHelper.GetMyDocumentsToDictionary(character); Message.Builder.SetCommand(request.Command).WithData(result).ToCharacters(registered).Send(); scope.Complete(); } }
public void HandleRequest(IRequest request) { using (var scope = Db.CreateTransaction()) { var character = request.Session.Character; var documentId = request.Data.GetOrDefault <int>(k.ID); var bodyStr = request.Data.GetOrDefault <string>(k.body); var version = request.Data.GetOrDefault <int>(k.version); CorporationDocument corporationDocument; CorporationDocumentHelper.CheckRegisteredAccess(documentId, character, out corporationDocument, true).ThrowIfError(); version.ThrowIfLess(corporationDocument.version, ErrorCodes.DocumentVersionOld); corporationDocument.SetBody(bodyStr); corporationDocument.WriteBody().ThrowIfError(); var result = CorporationDocumentHelper.GenerateResultFromDocuments(new[] { corporationDocument }); //itt terjesztunk var registered = new List <Character> { corporationDocument._ownerCharacter }; registered.AddRange(CorporationDocumentHelper.GetRegisteredCharactersFromDocument(documentId)); Message.Builder.SetCommand(Commands.CorporationDocumentUpdateBody).WithData(result).ToCharacters(registered).Send(); scope.Complete(); } }
public void HandleRequest(IRequest request) { var character = request.Session.Character; var documentId = request.Data.GetOrDefault <int>(k.ID); CorporationDocumentHelper.UnRegisterCharacterFromDocument(documentId, character); #if DEBUG Message.Builder.FromRequest(request).WithOk().Send(); #endif }
private void OnCharacterDeselected(Character character) { Logger.Info($"Character deselected /M\\ character:{character}"); var m = Message.Builder.SetCommand(Commands.CharacterDeselect).WithOk(); SendMessage(m); character.GetSocial().SendOnlineStateToFriends(false); CorporationDocumentHelper.RemoveFromAllDocuments(character); CharacterDeselected?.Invoke(this, character); }
public void HandleRequest(IRequest request) { var character = request.Session.Character; var documentId = request.Data.GetOrDefault <int>(k.ID); CorporationDocument corporationDocument; CorporationDocumentHelper.CheckRegisteredAccess(documentId, character, out corporationDocument).ThrowIfError(); CorporationDocumentHelper.RegisterCharacterToDocument(documentId, character); #if DEBUG Message.Builder.FromRequest(request).WithOk().Send(); #endif }
public void HandleRequest(IRequest request) { using (var scope = Db.CreateTransaction()) { var character = request.Session.Character; var documentType = (CorporationDocumentType)request.Data.GetOrDefault <int>(k.type); var body = request.Data.GetOrDefault <string>(k.body); var registered = request.Data.GetOrDefault <int[]>(k.members); var writeAccess = request.Data.GetOrDefault <int[]>(k.writeAccess); var useCorporationWallet = request.Data.GetOrDefault <int>(k.useCorporationWallet) == 1; int[] finalRegistered = null; int[] finalWriteAccess = null; if (registered != null) { finalRegistered = registered.Where(d => d != character.Id).Distinct().ToArray(); if (writeAccess != null) { finalWriteAccess = finalRegistered.Intersect(writeAccess).Where(d => d != character.Id).ToArray(); } } documentType.ThrowIfEqual(CorporationDocumentType.terraformProject, ErrorCodes.InvalidDocumentType); CorporationDocumentHelper.GetDocumentConfig(documentType, out var documentConfig).ThrowIfError(); documentConfig.OnCreate(character, useCorporationWallet).ThrowIfError(); DateTime?validUntil = null; if (documentConfig.IsRentable) { validUntil = DateTime.Now.AddDays(documentConfig.rentPeriodDays); } CorporationDocument.CreateNewToSql(character, documentType, validUntil, body, out var corporationDocument).ThrowIfError(); corporationDocument.SetRegistration(finalRegistered, finalWriteAccess); var result = new Dictionary <string, object> { { k.document, corporationDocument.ToDictionary() } }; Message.Builder.FromRequest(request).WithData(result).Send(); scope.Complete(); } }
public void HandleRequest(IRequest request) { var character = request.Session.Character; var documentId = request.Data.GetOrDefault <int>(k.ID); CorporationDocumentHelper.CheckOwnerAccess(documentId, character, out var corporationDocument).ThrowIfError(); var result = new Dictionary <string, object> { { k.ID, documentId }, { k.members, corporationDocument.GetRegisteredDictionary() } }; Message.Builder.FromRequest(request).WithData(result).Send(); }
public void HandleRequest(IRequest request) { using (var scope = Db.CreateTransaction()) { var character = request.Session.Character; var documentId = request.Data.GetOrDefault <int>(k.ID); var useCorporationWallet = request.Data.GetOrDefault <int>(k.useCorporationWallet) == 1; CorporationDocument corporationDocument; CorporationDocumentHelper.CheckOwnerAccess(documentId, character, out corporationDocument).ThrowIfError(); corporationDocument.Rent(character, useCorporationWallet).ThrowIfError(); var result = CorporationDocumentHelper.GenerateResultFromDocuments(new[] { corporationDocument }); Message.Builder.FromRequest(request).WithData(result).Send(); scope.Complete(); } }
public void HandleRequest(IRequest request) { var character = request.Session.Character; var documentIds = request.Data.GetOrDefault <int[]>(k.ID); documentIds.Length.ThrowIfLessOrEqual(0, ErrorCodes.WTFErrorMedicalAttentionSuggested); var documents = new List <CorporationDocument>(); foreach (var documentId in documentIds) { if (CorporationDocumentHelper.CheckRegisteredAccess(documentId, character, out var corporationDocument) != ErrorCodes.NoError) { continue; } corporationDocument.ReadBody(); documents.Add(corporationDocument); } var result = CorporationDocumentHelper.GenerateResultFromDocuments(documents); Message.Builder.FromRequest(request).WithData(result).Send(); }