示例#1
0
 /// <summary>
 /// Save account information to file
 /// </summary>
 /// <param name="Account"></param>
 /// <returns></returns>
 public bool Save(Account Account)
 {
     return(PlainTextData.SaveTo(CommonConstant.REMOTE_LOCKER_DATA, ';',
                                 Account.Username,
                                 Account.Password,
                                 Account.IdentifyCode
                                 ));
 }
 public override Task <EncryptedData> Encrypt(PlainTextData request, ServerCallContext context)
 {
     return(Task.FromResult(new EncryptedData
     {
         UserName = encryptionService.Encrypt(request.UserName, keyToken, ivToken),
         Password = encryptionService.Encrypt(request.Password, keyToken, ivToken)
     }));
 }
示例#3
0
        public void Export(IAssetExportEnvironment env)
        {
            // Determine input and output path
            PlainTextData input      = env.Input as PlainTextData;
            string        outputPath = env.AddOutputPath(input.Name + SourceFileExtPrimary);

            // Take the input Resource's pixel data and save it at the specified location
            BaseAssetImporter.Export(input, outputPath);
        }
        public static PlainTextData FeedbackMessage(string userEmail, string userName, string feedback)
        {
            var messageData = new PlainTextData
            {
                Sender  = EmailSender,
                Subject = "New Feedback",
                Text    = "User " + userName + " (" + userEmail + ") " + "Has Left new feedback - " + feedback
            };

            return(messageData);
        }
示例#5
0
        /// <summary>
        /// Fetch account data from file
        /// </summary>
        /// <returns></returns>
        public Account Fetch()
        {
            String[] data = PlainTextData.FetchFrom(CommonConstant.REMOTE_LOCKER_DATA, ';');

            Account account = new Account();

            account.Username     = data[0];
            account.Password     = data[1];
            account.IdentifyCode = data[2];

            return(account);
        }
示例#6
0
 public static void InitData()
 {
     if (!File.Exists(CommonConstant.REMOTE_LOCKER_DATA))
     {
         PlainTextData.SaveTo(
             CommonConstant.REMOTE_LOCKER_DATA, ';',
             "admin",
             "admin",
             Md5Sha1Encrypt.MD5Hashing("RemoteLocker.Default.IdentifyCode")
             );
     }
 }
        public static PlainTextData CreateProjectMessage(IProjectData model)
        {
            var message = new PlainTextData
            {
                Sender = EmailSender,
                Text   = "New Project was created. Project name - " + model.Name + ", Project author - " + model.AuthorFullName +
                         ", Project Link - https://streams.lykke.com/Project/ProjectDetails/" + model.Id,
                Subject = "New Project Created!"
            };

            return(message);
        }
        private async Task SendWhitelistEmail(string clientId, string asset, string address, string tag)
        {
            var clientAccountTask = _clientAccountService.ClientAccountInformation.GetByIdAsync(clientId);
            var pdTask            = _personalDataService.GetAsync(clientId);

            await Task.WhenAll(clientAccountTask, pdTask);

            var clientAccount = clientAccountTask.Result;
            var pd            = pdTask.Result;

            var template = await _templateFormatter.FormatAsync("AddressWhitelistedTemplate", clientAccount.PartnerId,
                                                                "EN", new { FullName = pd.FullName, Asset = asset, Address = address, Tag = tag ?? "---", Year = DateTime.UtcNow.Year });

            var msgData = new PlainTextData
            {
                Sender  = pd.Email,
                Subject = template.Subject,
                Text    = template.HtmlBody
            };

            await _emailSender.SendEmailAsync(clientAccount.PartnerId, pd.Email, msgData);
        }
示例#9
0
        // private async Task<bool> IsCardHolderNameValid(string clientId, CreditCardModel card)
        // {
        //     var personalData = await _personalDataService.GetAsync(clientId);
        //     return IsNameSimilar(card.CardHolder, personalData.FirstName, personalData.LastName);
        // }

        // private static bool IsNameSimilar(string cardHolderName, string firstName, string lastName)
        // {
        //     return Compare(cardHolderName.ToLower(), $"{firstName} {lastName}".ToLowerInvariant())
        //            || Compare(cardHolderName.ToLower(), $"{lastName} {firstName}".ToLowerInvariant());
        // }

        // private static bool Compare(string expected, string actual)
        // {
        //     const double allowedSimilarity = 0.8;
        //     var metric = new SimMetrics.Net.Metric.Levenstein();
        //     var v = metric.GetSimilarity(expected, actual);
        //     return v > allowedSimilarity;
        // }

        private async Task SendAntiFraudNotificationAsync(IPaymentTransaction transaction)
        {
            if (string.IsNullOrEmpty(_antifraudNotificationEmail))
            {
                return;
            }

            var clientAccount = await _clientAccountClient.ClientAccountInformation.GetByIdAsync(transaction.ClientId);

            string text = $"New deposit request (transactionId = {transaction.TransactionId}), please review";

            var msgData = new PlainTextData
            {
                Subject = "Review deposit request",
                Text    = text
            };

            await Task.WhenAll(
                _emailSender.SendEmailAsync(clientAccount.PartnerId, _antifraudNotificationEmail, msgData),
                _telegramBot.SendTextMessageAsync(_chatId, text)
                );
        }
        private async Task SendNotificationAsync(TierUpgradeRequestChangedEvent evt, ICommandSender commandSender)
        {
            var clientAccTask    = _clientAccountClient.ClientAccountInformation.GetByIdAsync(evt.ClientId);
            var personalDataTask = _personalDataService.GetAsync(evt.ClientId);
            var pushSettingsTask = _clientAccountClient.ClientSettings.GetPushNotificationAsync(evt.ClientId);

            await Task.WhenAll(clientAccTask, personalDataTask, pushSettingsTask);

            var  clientAcc    = clientAccTask.Result;
            var  personalData = personalDataTask.Result;
            var  pushSettings = pushSettingsTask.Result;
            bool pushEnabled  = pushSettings.Enabled && !string.IsNullOrEmpty(clientAcc.NotificationsId);

            Task <EmailMessage> emailTemplateTask = Task.FromResult <EmailMessage>(null);
            Task <EmailMessage> pushTemplateTask  = Task.FromResult <EmailMessage>(null);
            string type = string.Empty;

            try
            {
                switch (evt.NewStatus)
                {
                case KycStatus.Ok:
                    var tierInfo = await _tiersService.GetClientTierInfoAsync(evt.ClientId, clientAcc.Tier, personalData.CountryFromPOA);

                    bool   noAmountTemplate = tierInfo.CurrentTier.MaxLimit == 0;
                    string upgradeTemplate  =
                        tierInfo.CurrentTier.Tier == AccountTier.Advanced
                                ? "TierUpgradedToProTemplate"
                                : "TierUpgradedTemplate";

                    emailTemplateTask = _templateFormatter.FormatAsync(noAmountTemplate ? "TierUpgradedNoAmountTemplate" : upgradeTemplate, clientAcc.PartnerId,
                                                                       "EN", new
                    {
                        Tier   = evt.Tier.ToString(),
                        Year   = DateTime.UtcNow.Year,
                        Amount = $"{tierInfo.CurrentTier.MaxLimit} {tierInfo.CurrentTier.Asset}",
                        //TODO: remove when TierUpgradedTemplate will be updated (@[UpgradeText] removed)
                        UpgradeText = string.Empty
                    });

                    if (pushEnabled)
                    {
                        pushTemplateTask = _templateFormatter.FormatAsync(noAmountTemplate ? "PushTierUpgradedNoAmountTemplate" : "PushTierUpgradedTemplate", clientAcc.PartnerId, "EN",
                                                                          new { Tier = evt.Tier.ToString(), Amount = $"{tierInfo.CurrentTier.MaxLimit} {tierInfo.CurrentTier.Asset}" });
                    }

                    type = NotificationType.TierUpgraded.ToString();
                    break;

                case KycStatus.NeedToFillData:
                    var documents = await _kycDocumentsService.GetCurrentDocumentsAsync(evt.ClientId);

                    var declinedDocuments = documents
                                            .Where(item => item.Status.Name == CheckDocumentPorcess.DeclinedState.Name)
                                            .ToArray();

                    if (declinedDocuments.Length > 0)
                    {
                        string documentsAsHtml = GetDocumentsInfo(declinedDocuments);
                        emailTemplateTask = _templateFormatter.FormatAsync("DeclinedDocumentsTemplate", clientAcc.PartnerId,
                                                                           "EN", new { FullName = personalData.FullName, DocumentsAsHtml = documentsAsHtml, Year = DateTime.UtcNow.Year });
                    }

                    if (pushEnabled)
                    {
                        pushTemplateTask = _templateFormatter.FormatAsync("PushKycNeedDocumentsTemplate", clientAcc.PartnerId, "EN", new { });
                    }

                    type = NotificationType.KycNeedToFillDocuments.ToString();
                    break;

                case KycStatus.Rejected:
                    emailTemplateTask = _templateFormatter.FormatAsync("TierUpgradeRejectedTemplate", clientAcc.PartnerId,
                                                                       "EN", new { FullName = personalData.FullName, Tier = evt.Tier.ToString(), Year = DateTime.UtcNow.Year });
                    break;
                }
            }
            finally
            {
                await Task.WhenAll(emailTemplateTask, pushTemplateTask);

                var sendEmailTask = Task.CompletedTask;

                if (emailTemplateTask.Result != null)
                {
                    var msgData = new PlainTextData
                    {
                        Sender  = personalData.Email,
                        Subject = emailTemplateTask.Result.Subject,
                        Text    = emailTemplateTask.Result.HtmlBody
                    };

                    sendEmailTask = _emailSender.SendEmailAsync(clientAcc.PartnerId, personalData.Email, msgData);
                }

                if (pushEnabled && pushTemplateTask.Result != null)
                {
                    commandSender.SendCommand(new TextNotificationCommand
                    {
                        NotificationIds = new[] { clientAcc.NotificationsId },
                        Type            = type,
                        Message         = pushTemplateTask.Result.Subject
                    }, PushNotificationsBoundedContext.Name);
                }

                await sendEmailTask;
            }
        }