示例#1
0
        public async Task <bool> MfAssistAf()
        {
            ReportAction();
            if (Profile.ManualFocusAF)
            {
                return(await Try(async() =>
                {
                    try
                    {
                        await http.Get <BaseRequestResult>("?mode=camcmd&value=oneshot_af");
                        return true;
                    }
                    catch (LumixException ex)
                    {
                        if (ex.Error == LumixError.ErrorParam)
                        {
                            Profile.ManualFocusAF = false;
                            ProfileUpdated?.Invoke();
                            return false;
                        }
                        throw;
                    }
                }));
            }

            return(false);
        }
        void HandleEvents(AuthenticationResult result)
        {
            if (result.Code != AuthenticationResultCode.Success)
            {
                ProfileUpdateFailed?.Invoke(this, result.ErrorMessage);
                return;
            }

            ProfileUpdated?.Invoke(this, null);
        }
        private void SendProfileUpdatedMail(string email, string recipient)
        {
            ProfileUpdated updated = new ProfileUpdated()
            {
                ToEmail  = email,
                UserName = recipient,
                Today    = DateTime.Today.ToString("dd/MM/yyyy HH:mm:ss")
            };

            _mailService.SendProfileUpdated(updated);
        }
示例#4
0
        public async Task SendProfileUpdated(ProfileUpdated request)
        {
            string       FilePath = Directory.GetCurrentDirectory() + "\\Templates\\ProfileUpdated.html";
            StreamReader str      = new StreamReader(FilePath);
            string       MailText = str.ReadToEnd();

            str.Close();
            MailText = MailText.Replace("[username]", request.UserName).Replace("[email]", request.ToEmail).Replace("[today]", request.Today);
            var email = new MimeMessage();

            email.Sender = MailboxAddress.Parse(_mailSettings.Mail);
            email.To.Add(MailboxAddress.Parse(request.ToEmail));
            email.Subject = $"Profile Updated";
            var builder = new BodyBuilder();

            builder.HtmlBody = MailText;
            email.Body       = builder.ToMessageBody();
            using var smtp   = new SmtpClient();
            smtp.Connect(_mailSettings.Host, _mailSettings.Port, SecureSocketOptions.StartTls);
            smtp.Authenticate(_mailSettings.Mail, _mailSettings.Password);
            await smtp.SendAsync(email);

            smtp.Disconnect(true);
        }