예제 #1
0
        public ActionResult UpdateSignature(string mainToken, SignatureDto dto)
        {
            var main   = _characterService.GetMainCharacterByToken(mainToken);
            var maskId = main.MaskType == MaskType.Alliance && main.Pilot.Corporation.AllianceId != null ? main.Pilot.Corporation.Alliance.MaskId : main.Pilot.Corporation.MaskId;
            var sig    = _signatureService.GetBySignatureId(dto.Id);

            sig.SignatureId = dto.SignatureId;
            //sig.ExpiryDate = dto.ExpiryDate;
            sig.Name          = dto.Name;
            sig.SignatureType = dto.SignatureType;
            _signatureService.WormholeSigUpdate(dto, sig, maskId);
            return(Ok());
        }
예제 #2
0
 public MailAccount(string address, string name, bool enabled,
                    bool quota_error, MailBox.AuthProblemType auth_error, int id,
                    bool oauth_connection, SignatureDto signature, string email_in_folder)
 {
     Address         = address;
     Name            = name;
     Enabled         = enabled;
     QuotaError      = quota_error;
     AuthError       = auth_error == MailBox.AuthProblemType.TooManyErrors;
     Id              = id;
     OAuthConnection = oauth_connection;
     Signature       = signature;
     EMailInFolder   = email_in_folder;
 }
예제 #3
0
 public AccountInfo(int id, string address, string name, bool enabled,
                    bool quota_error, MailBox.AuthProblemType auth_error, SignatureDto signature, bool oauth_connection,
                    string email_in_folder, bool is_teamlab_mailbox)
 {
     Id               = id;
     Email            = address;
     Name             = name;
     Enabled          = enabled;
     QuotaError       = quota_error;
     AuthError        = auth_error == MailBox.AuthProblemType.TooManyErrors;
     Signature        = signature;
     Aliases          = new List <MailAddressInfo>();
     Groups           = new List <MailAddressInfo>();
     OAuthConnection  = oauth_connection;
     EMailInFolder    = email_in_folder;
     IsTeamlabMailbox = is_teamlab_mailbox;
 }
예제 #4
0
        public ActionResult InsertSignature(string mainToken, SignatureDto dto)
        {
            var main   = _characterService.GetMainCharacterByToken(mainToken);
            var maskId = main.MaskType == MaskType.Alliance && main.Pilot.Corporation.AllianceId != null ? main.Pilot.Corporation.Alliance.MaskId : main.Pilot.Corporation.MaskId;
            var newSig = new Signature
            {
                SignatureId   = dto.SignatureId.ToUpper(),
                ExpiryDate    = dto.ExpiryDate,
                Name          = dto.Name,
                SignatureType = dto.SignatureType,
                MaskId        = maskId,
                SystemId      = dto.SystemId
            };

            _signatureService.Insert(newSig, commit: true);
            _signatureService.WormholeSigUpdate(dto, newSig, maskId);
            return(Ok());
        }
        public IActionResult Edit([FromBody] SignatureDto dto)
        {
            try
            {
                var claims = _repo.Jwt.GetUserClaims(Request.Headers[HeaderNames.Authorization].ToString());

                var user = _repo.User
                           .FindByCondition(c => c.Id == claims.UserId)
                           .First();

                user.Signature = Convert.FromBase64String(dto.Signature);
                _repo.User.Update(user);
                _repo.Save();

                return(Ok());
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
 /// <summary>
 /// Преобразовать подпись из трансферной модели и сохранить файл подписи асинхронно
 /// </summary>
 private async Task <IResultValue <ISignatureFile> > SignatureFileFromDtoAsync(SignatureDto signatureDto, string signatureFolder) =>
 await SignatureFile.GetFilePathByFolder(signatureFolder, signatureDto.PersonId, false).
 Map(signatureFilePath =>
     _fileSystemOperations.SaveFileFromByte(signatureFilePath, signatureDto.SignatureSourceList).
     ResultValueOkAsync(_ => new SignatureFile(signatureDto.PersonId, PersonInformationFromDto(signatureDto.PersonInformation),
                                               signatureFilePath, false)));
 /// <summary>
 /// Преобразовать подпись из трансферной модели и сохранить файл подписи
 /// </summary>
 private IResultValue <ISignatureFile> SignatureFileFromDto(SignatureDto signatureDto, string signatureFolder) =>
 SignatureFile.GetFilePathByFolder(signatureFolder, signatureDto.PersonId, false).
 Map(signatureFilePath =>
     _fileSystemOperations.SaveFileFromByte(signatureFilePath, signatureDto.SignatureSourceList).WaitAndUnwrapException().
     ResultValueOk(_ => new SignatureFile(signatureDto.PersonId, PersonInformationFromDto(signatureDto.PersonInformation),
                                          signatureFilePath, false)));
 /// <summary>
 /// Преобразовать подпись из трансферной модели
 /// </summary>
 private static ISignatureLibrary SignatureLibraryFromDto(SignatureDto signatureDto) =>
 new SignatureLibrary(signatureDto.PersonId, PersonInformationFromDto(signatureDto.PersonInformation));
 /// <summary>
 /// Преобразовать подпись из трансферной модели
 /// </summary>
 private static ISignatureFileData SignatureFileDataFromDto(SignatureDto signatureDto) =>
 new SignatureFileData(signatureDto.PersonId, PersonInformationFromDto(signatureDto.PersonInformation),
                       signatureDto.SignatureSource, false);
예제 #10
0
        public void WormholeSigUpdate(SignatureDto dto, Signature sig, int maskId)
        {
            if (dto.SignatureType == SignatureType.Wormhole)
            {
                sig.MassIndicator = dto.MassIndicator;
                if (sig.TimeRemainingIndicator != dto.TimeRemainingIndicator)
                {
                    switch (dto.TimeRemainingIndicator)
                    {
                    case TimeRemainingIndicator.EoL:
                    {
                        if (sig.ExpiryDate > DateTime.UtcNow.AddHours(4))
                        {
                            sig.ExpiryDate = DateTime.UtcNow.AddHours(4);
                        }
                        break;
                    }

                    case TimeRemainingIndicator.Unset:
                    {
                        var baseHours = 24;
                        if (sig.WormholeType != null)
                        {
                            baseHours = int.Parse(Regex.Replace(sig.WormholeType.Duration, "[^0-9]+", string.Empty));
                        }
                        sig.ExpiryDate = sig.CreationDate.AddHours(baseHours);
                        break;
                    }
                    }
                }
                sig.TimeRemainingIndicator = dto.TimeRemainingIndicator;
                sig.WormholeTypeId         = dto.WormholeTypeId;
                Update(sig, commit: true);
                if (dto.DestinationSystemId.HasValue)
                {
                    if (sig.DestinationId.HasValue && sig.Destination.SystemId != dto.DestinationSystemId)
                    {
                        Delete(sig.DestinationId.Value);
                        sig.DestinationId = null;
                        Update(sig, commit: true);
                    }
                    var desto    = _solarSystemService.GetSystemById(dto.DestinationSystemId.Value);
                    var origin   = _solarSystemService.GetSystemById(dto.SystemId);
                    var destoSig = desto.Signatures.FirstOrDefault(x => x.Id == sig.DestinationId);
                    if (destoSig == null)
                    {
                        destoSig = new Signature
                        {
                            SignatureId    = "???",
                            ExpiryDate     = sig.ExpiryDate,
                            Name           = "",
                            SignatureType  = SignatureType.Wormhole,
                            MaskId         = maskId,
                            WormholeTypeId = GetByTypeName("????").Id
                        };
                        desto.Signatures.Add(destoSig);
                        _routeService.AddAdjacency(sig.SystemId, desto.Id, sig.MaskId,
                                                   desto.Class > 0 || origin.Class > 0 ? 10 :                // J Space Connection = 10
                                                   desto.Security <= 0.45 || origin.Security <= 0.45 ? 100 : // Null/Low sec connection = 100
                                                   1);                                                       // Hisec to Hisec = 1
                        _solarSystemService.UpdateSystem(desto);
                    }
                    if (dto.WormholeType != "K162" && dto.WormholeType != "????")
                    {
                        destoSig.WormholeTypeId = GetByTypeName("K162").Id;
                    }
                    sig.DestinationId               = destoSig.Id;
                    destoSig.DestinationId          = sig.Id;
                    destoSig.MassIndicator          = sig.MassIndicator;
                    destoSig.TimeRemainingIndicator = sig.TimeRemainingIndicator;
                    destoSig.ExpiryDate             = sig.ExpiryDate;
                    _solarSystemService.UpdateSystem(desto);
                }
                else
                {
                    if (sig.DestinationId.HasValue)
                    {
                        Delete(sig.DestinationId.Value);
                        sig.DestinationId = null;
                    }
                }
            }
            else
            {
                if (sig.DestinationId.HasValue)
                {
                    Delete(sig.DestinationId.Value);
                    sig.DestinationId = null;
                }
                sig.WormholeTypeId = null;
            }
            Update(sig, commit: true);
        }
 /// <summary>
 /// Преобразовать идентификатор с подписью в модель базы банных
 /// </summary>
 private static SignatureEntity SignatureFromDto(SignatureDto signatureDto) =>
 new SignatureEntity(signatureDto.PersonId,
                     PersonInformationFromDto(signatureDto.PersonInformation),
                     signatureDto.SignatureSource);