コード例 #1
0
        private void Kontrol()
        {
            List <Cattle> cattles = cattleDAL.GetAll().Where(x => x.Inseminations.Count() > 0 && x.Inseminations.Last().Result == true && (DateTime.Now.Subtract(x.Inseminations.Last().Date).Days == 45)).ToList();

            foreach (var item in cattles)
            {
                try
                {
                    string[] tokens  = new string[tokenDAL.GetAll().Where(x => x.RanchID == item.RanchID).Count()];
                    int      counter = 0;
                    foreach (var item2 in tokenDAL.GetAll().Where(x => x.RanchID == item.RanchID))
                    {
                        tokens[counter] = item2.DeviceToken;
                        counter++;
                    }
                    string title = item.EarringNumber + " Küpeli Hayvanı Bilgilendirme : ";
                    string body  = item.Name + " isimli hayvanın tohumlanma günü 45 gün olmuştur.Kontrol ettiriniz !!!";
                    var    push  = PushNotificationLogic.SendPushNotification(tokens, title, body, new { action = "Mühendis Bey Süt", userId = 5 });

                    SmtpClient sc = new SmtpClient("smtp.muhendisbeysut.com");
                    sc.Port                  = 587;
                    sc.EnableSsl             = false;
                    sc.UseDefaultCredentials = false;
                    sc.Credentials           = new NetworkCredential("*****@*****.**", "SIFRE");
                    sc.TargetName            = "STARTTLS/smtp.muhendisbeysut.com";
                    MailMessage mail = new MailMessage();
                    mail.From = new MailAddress("*****@*****.**", "ÇiftlikApp Bilgilendirme");
                    mail.To.Add(item.Ranch.Email);
                    mail.Subject    = title;
                    mail.IsBodyHtml = true;
                    mail.Body       = body;
                    sc.Send(mail);
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
コード例 #2
0
 public int RegisterToken(string Token, int ID)
 {
     if (tokenDAL.GetAll().Where(x => x.DeviceToken == Token).Count() == 0)
     {
         Token token = new Token();
         token.DeviceToken = Token;
         token.RanchID     = ID;
         tokenDAL.Add(token);
         return(token.ID);
     }
     else
     {
         return(0);
     }
 }