Пример #1
0
        private void SendEmailToReceiver(string receiverKey, string receiverEmail, tbl_SR_allocation tbl_SR_allocation)
        {
            DBModel db          = new DBModel();
            string  senderfname = db.tbl_senderinfo.Where(x => x.sender_id == tbl_SR_allocation.sender_id).Select(x => x.sender_fname).FirstOrDefault();
            string  senderlname = db.tbl_senderinfo.Where(x => x.sender_id == tbl_SR_allocation.sender_id).Select(x => x.sender_lname).FirstOrDefault();
            string  senderemail = db.tbl_senderinfo.Where(x => x.sender_id == tbl_SR_allocation.sender_id).Select(x => x.sender_email).FirstOrDefault();
            string  filename    = db.tbl_datakey.Where(x => x.tbldatakey_id == tbl_SR_allocation.tbldatakey_id).Select(x => x.datafilename).FirstOrDefault();
            string  semail      = Convert.ToString(ConfigurationManager.AppSettings["semailaddr"]);
            string  spass       = Convert.ToString(ConfigurationManager.AppSettings["epassword"]);
            var     sEmail      = new MailAddress(semail, "Sender");
            var     reEmail     = new MailAddress(receiverEmail, "Receiver");
            var     password    = spass;
            var     sub         = "New file available for download";
            var     body        = "Hello, New file is ready to download. The first name of sender is- " + senderfname + ", last name - " + senderlname + ", email - " + senderemail + ", File name - " + filename + " and receiver key - " + receiverKey + ". Please use this information to download the file. Thank you.";
            var     smtp        = new SmtpClient
            {
                Host                  = "smtp.gmail.com",
                Port                  = 587,
                EnableSsl             = true,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(sEmail.Address, password)
            };

            using (var mess = new MailMessage(sEmail.Address, "*****@*****.**")
            {
                Subject = sub,
                Body = body
            })
            {
                smtp.Send(mess);
            }
        }
Пример #2
0
        internal void SaveSRAllocation(tbl_SR_allocation tbl_SR_allocation)
        {
            DBOperations dbo = new DBOperations();
            DBModel      db  = new DBModel();
            ReceiverInfo r   = new ReceiverInfo();
            ReadFile     rf  = new ReadFile();

            r.datakeyid = Convert.ToString(tbl_SR_allocation.tbldatakey_id);
            r.senderid  = Convert.ToString(tbl_SR_allocation.sender_id);
            tbl_receiverinfo receiverInfo = db.tbl_receiverinfo.Where(x => x.receiver_id == tbl_SR_allocation.receiver_id).FirstOrDefault();

            r.receiverEmail = receiverInfo.receiver_email;
            r.receiverName  = receiverInfo.receiver_name;
            int    tempn       = rf.GenerateN(r);
            int    n           = rf.ValidateTempN(tempn, tbl_SR_allocation.tbldatakey_id);
            string senderattr  = db.tbl_senderinfo.Where(x => x.sender_id == tbl_SR_allocation.sender_id).Select(x => x.sender_attribute).FirstOrDefault().ToString();
            string receiverKey = rf.GenerateReceiverKey(n, senderattr);

            tbl_SR_allocation.receiver_key = receiverKey;
            dbo.SaveReceiverKeyOnServer(tbl_SR_allocation);
            SendEmailToReceiver(receiverKey, r.receiverEmail, tbl_SR_allocation);
        }
Пример #3
0
 public void SaveReceiverKeyOnServer(tbl_SR_allocation objSR)
 {
     db.tbl_SR_allocation.Add(objSR);
     db.SaveChanges();
 }