コード例 #1
0
        //private void btnOkEmail_Click(object sender, EventArgs e)
        //{
        //	using (SQLiteConnection connection = SqlConnectionFactory.GetSQLiteConnectionWithLock())
        //	{
        //		DateTime dt = MainActivity.GetLocalTime();
        //		connection.Insert(new EmailAddresses()
        //		{
        //			Date = dt,
        //			IsValid = true,
        //			EmailType = true,
        //			Email = txtNewEmail.Text
        //		});
        //		EmailAddresses ea = connection.Table<EmailAddresses>().Last();
        //		lblOutEmail.Text = $"OK => {ea.ToString()}";
        //	}
        //}

        private void btnOk_Click(object sender, EventArgs e)
        {
            using (SQLiteConnection connection = SqlConnectionFactory.GetSQLiteConnectionWithLock())
            {
                DateTime dt = MainActivity.GetLocalTime();
                connection.Insert(new FromPassword()
                {
                    Date    = dt,
                    IsValid = true,
                    Pass    = pass1.Text,
                });
                FromPassword ea = connection.Table <FromPassword>().Last();
                lblOut.Text = $"OK => {ea.ToString()}";
            }
        }
コード例 #2
0
ファイル: BuildCommand.cs プロジェクト: nordseth/Nibbler
        private AuthenticationHandler CreateFromRegistryAuthHandler(ILogger registryLogger, DockerConfigCredentials dockerConfigCredentials, bool sameAsTo)
        {
            var fromRegAuthHandler = new AuthenticationHandler(
                ImageHelper.GetRegistryName(GetFromImage()),
                dockerConfigCredentials,
                registryLogger);

            if (FromUsername.HasValue() && FromPassword.HasValue())
            {
                fromRegAuthHandler.SetCredentials(FromUsername.Value(), FromPassword.Value());
            }
#pragma warning disable CS0612 // Type or member is obsolete
            else if (sameAsTo && Username.HasValue() && Password.HasValue())
            {
                fromRegAuthHandler.SetCredentials(Username.Value(), Password.Value());
            }
#pragma warning restore CS0612 // Type or member is obsolete

            return(fromRegAuthHandler);
        }
コード例 #3
0
        //const string server = "smtp.office365.com";
        //const string myEmailAddress = "*****@*****.**";
        //const string myEmailAddress = "*****@*****.**";
        //const string myPassword = "******";
        //string[] toEmails = {"*****@*****.**" };GetString(Resource.String.delete));
        //static string toEmail =
        //FindViewById<CheckBox>(Resource.Id.IsReal).Checked ? FindViewById<ImageButton>(Resource.Id.clockInButton);
        //"*****@*****.**", "*****@*****.**" ;/*Resource.String.to_email_address*/
        #endregion


        public static string SendEmail(string message, bool IsOut, bool IsReal, Func <int, string> GetString)
        {
            using (SQLiteConnection connection = SqlConnectionFactory.GetSQLiteConnectionWithLock())
            {
                string output = string.Empty;
                var    mapp   = connection.TableMappings;
                foreach (TableMapping tm in mapp)
                {
                    Log.Debug("MAPPING", tm.ToString());
                }
                EmailAddresses toEmailReal = connection.Table <EmailAddresses>().Where(x => x.EmailType == 1).Last();

                EmailAddresses myEmailAddress = connection.Table <EmailAddresses>().Where(x => x.EmailType == 2).Last();
                EmailAddresses myBCCAddress   = connection.Table <EmailAddresses>().Where(x => x.EmailType == 3).Last();
                string         server         = GetString(Resource.String.server);

                FromPassword fromPassword = connection.Table <FromPassword>().Last();

                SmtpClient client = new SmtpClient();
                client.Port                  = 587;
                client.Host                  = server;
                client.EnableSsl             = true;
                client.Timeout               = 120000;
                client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                client.UseDefaultCredentials = false;
                client.Credentials           = new System.Net.NetworkCredential(myEmailAddress.Email, fromPassword.Pass);
                MailAddressCollection to = new MailAddressCollection();

                MailMessage mm = new MailMessage();
                mm.From = new MailAddress(myEmailAddress.Email);
                if (myBCCAddress != null)
                {
                    mm.Bcc.Add(myBCCAddress.Email);
                }
                if (IsReal)
                {
                    mm.To.Add(toEmailReal.Email);
                    output = "REAL to " + toEmailReal.Email;
                }
                else
                {
                    mm.To.Add(myEmailAddress.Email);
                    output = "TEST to " + myEmailAddress.Email;
                }
                if (IsOut)
                {
                    mm.Subject = "Clock out";
                }
                else
                {
                    mm.Subject = "Clock in";
                }
                output         += " " + mm.Subject;
                mm.Body         = string.Empty;// message;
                mm.BodyEncoding = UTF8Encoding.UTF8;
                mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

                try
                {
                    client.Send(mm);
                    return(output);
                }
                catch (Exception ex)
                {
                    output += "ERROR | " + ex.Message + " Make sure you go to Change Emails and set values!";
                    return(output);
                }
            }
        }//end mail
コード例 #4
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     using (SQLiteConnection connection = SqlConnectionFactory.GetSQLiteConnectionWithLock())
     {
         DateTime dt = MainActivity.GetLocalTime();
         if (!string.IsNullOrWhiteSpace(txtToNewEmail.Text))
         {
             connection.Insert(new EmailAddresses()
             {
                 Date      = dt,
                 IsValid   = true,
                 EmailType = 1,
                 Email     = txtToNewEmail.Text
             });
             EmailAddresses newto = connection.Table <EmailAddresses>().Where(x => x.EmailType == 1).Last();
             lblOutEmail.Text += $"OK TO=> {newto.ToString()}\n";
         }
         if (!string.IsNullOrWhiteSpace(txtFromNewEmail.Text))
         {
             connection.Insert(new EmailAddresses()
             {
                 Date      = dt,
                 IsValid   = true,
                 EmailType = 2,
                 Email     = txtFromNewEmail.Text
             });
             EmailAddresses newfrom = connection.Table <EmailAddresses>().Where(x => x.EmailType == 2).Last();
             lblOutEmail.Text += $"OK FROM=> {newfrom.ToString()}\n";
         }
         if (!string.IsNullOrWhiteSpace(txtBCCNewEmail.Text))
         {
             connection.Insert(new EmailAddresses()
             {
                 Date      = dt,
                 IsValid   = true,
                 EmailType = 3,
                 Email     = txtBCCNewEmail.Text
             });
             EmailAddresses newbcc = connection.Table <EmailAddresses>().Where(x => x.EmailType == 3).Last();
             lblOutEmail.Text += $"OK BCC=> {newbcc.ToString()}\n";
         }
         if (!string.IsNullOrWhiteSpace(pass1.Text))
         {
             connection.Insert(new FromPassword()
             {
                 Date    = dt,
                 IsValid = true,
                 Pass    = pass1.Text,
             });
             FromPassword ea = connection.Table <FromPassword>().Last();
             lblOut.Text = $"OK pw=> {ea.ToString()}";
         }
         if (!string.IsNullOrWhiteSpace(txtRate.Text))
         {
             connection.Insert(new HourlyRate()
             {
                 Date    = dt,
                 IsValid = true,
                 Rate    = (float)Convert.ToDouble(txtRate.Text),
             });
             HourlyRate ea = connection.Table <HourlyRate>().Last();
             lblOut.Text = $"OK Hourlyrate=> {ea.ToString()}";
         }
         if (!string.IsNullOrWhiteSpace(txtServer.Text))
         {
             connection.Insert(new ServerOut()
             {
                 Date    = dt,
                 IsValid = true,
                 Server  = txtServer.Text,
             });
             ServerOut ea = connection.Table <ServerOut>().Last();
             lblOut.Text = $"OK Server=> {ea.ToString()}";
         }
         else if (connection.Table <ServerOut>().Count() == 0)
         {
             connection.Insert(new ServerOut()
             {
                 Date    = dt,
                 IsValid = true,
                 Server  = "smtp.office365.com",
             });
             ServerOut ea = connection.Table <ServerOut>().Last();
             lblOut.Text = $"OK Server=> {ea.ToString()}";
         }
     }
 }