public List <Mandrillaccount> GetAllMandrillData(int count)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SocioBoardInvitationMailSenderSessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             //Proceed action to get Archive messages
             // And return list of archive messages.
             try
             {
                 List <Mandrillaccount> alsdata = session.CreateQuery("from Mandrillaccount")
                                                  .SetFirstResult(count)
                                                  .SetMaxResults(11)
                                                  .List <Mandrillaccount>()
                                                  .ToList <Mandrillaccount>();
                 return(alsdata);
             }
             catch (Exception ex)
             {
                 Console.Write(ex.StackTrace);
                 return(null);
             }
         } //End using transaction
     }     //Using using session
 }
示例#2
0
 public List <User> GetAllExpiredUser()
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SocioBoardInvitationMailSenderSessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             //Proceed action to get Archive messages
             // And return list of archive messages.
             try
             {
                 List <User> alsdata = session.CreateQuery("from User")
                                       .List <User>()
                                       .ToList <User>()
                                       .Where(e => e.ExpiryDate.Date == DateTime.Now.Date)
                                       .ToList <User>();
                 return(alsdata);
             }
             catch (Exception ex)
             {
                 Console.Write(ex.StackTrace);
                 return(null);
             }
         } //End using transaction
     }     //Using using session
 }
 public bool IsEmailExist(string Emailid)
 {
     try
     {
         //Creates a database connection and opens up a session
         using (NHibernate.ISession session = SocioBoardInvitationMailSenderSessionFactory.GetNewSession())
         {
             //After Session creation, start Transaction.
             using (NHibernate.ITransaction transaction = session.BeginTransaction())
             {
                 NHibernate.IQuery query = session.CreateQuery("from  Invitation u where u.FriendEmail = : email");
                 query.SetParameter("email", Emailid);
                 var result = query.UniqueResult();
                 if (result == null)
                 {
                     return(false);
                 }
                 else
                 {
                     return(true);
                 }
             } //End Using trasaction
         }     //End Using session
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         return(false);
     }
 }
 public void UpdateOpenandClicks(string Sent, string Opens, string Clicks, string email)
 {
     using (NHibernate.ISession session = SocioBoardInvitationMailSenderSessionFactory.GetNewSession())
     {
         //Begin session trasaction and opens up.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 int i = session.CreateQuery("Update Mandrillaccount set Sent =:sent, Opens =: opens, Clicks =: clicks where UserName =:email")
                         .SetParameter("email", email)
                         .SetParameter("opens", Opens)
                         .SetParameter("clicks", Clicks)
                         .SetParameter("sent", Sent)
                         .ExecuteUpdate();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 // return 0;
             }
         } //End Trasaction
     }     //End session
 }
 public List <Mantaemail> getAllCompanyDataNew(int count)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SocioBoardInvitationMailSenderSessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             //Proceed action to get Archive messages
             // And return list of archive messages.
             try
             {
                 List <Mantaemail> alsdata = session.CreateQuery("from Mantaemail where Status = 1 and Bounce = 0 and Spam = 0 and IsInvalid=0")
                                             .SetFirstResult(count)
                                             .SetMaxResults(10000)
                                             .List <Mantaemail>()
                                             .ToList <Mantaemail>();
                 return(alsdata);
             }
             catch (Exception ex)
             {
                 Console.Write(ex.StackTrace);
                 return(null);
             }
         } //End using transaction
     }     //Using using session
 }
 public void UpdateStatusBulk(List <int> ids)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SocioBoardInvitationMailSenderSessionFactory.GetNewSession())
     {
         //Begin session trasaction and opens up.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 string str = "Update Mantaemail set Status =1 where Id IN(";
                 foreach (int id in ids)
                 {
                     str += id + ",";
                 }
                 str  = str.Substring(0, str.Length - 1);
                 str += ")";
                 int i = session.CreateQuery(str)
                         .ExecuteUpdate();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 // return 0;
             }
         } //End Trasaction
     }     //End session
 }
 public void UpdateSpamBulk(List <string> emails)
 {
     using (NHibernate.ISession session = SocioBoardInvitationMailSenderSessionFactory.GetNewSession())
     {
         //Begin session trasaction and opens up.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 string str = "Update Mantaemail set Spam =1 where Email IN(";
                 foreach (string email in emails)
                 {
                     str += "'" + email + "',";
                 }
                 str  = str.Substring(0, str.Length - 1);
                 str += ")";
                 int i = session.CreateQuery(str)
                         .ExecuteUpdate();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
             }
         } //End Trasaction
     }     //End session
 }
 public void Add(Invitation invitation)
 {
     try
     {
         //Creates a database connection and opens up a session
         using (NHibernate.ISession session = SocioBoardInvitationMailSenderSessionFactory.GetNewSession())
         {
             //After Session creation, start Transaction.
             using (NHibernate.ITransaction transaction = session.BeginTransaction())
             {
                 //Proceed action to save data.
                 session.Save(invitation);
                 transaction.Commit();
             } //End Using trasaction
         }     //End Using session
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
     }
 }
 public int GetTodayMailCount()
 {
     try
     {
         //Creates a database connection and opens up a session
         using (NHibernate.ISession session = SocioBoardInvitationMailSenderSessionFactory.GetNewSession())
         {
             //After Session creation, start Transaction.
             using (NHibernate.ITransaction transaction = session.BeginTransaction())
             {
                 List <Invitation> maildata = session.CreateQuery("from Invitation")
                                              .List <Invitation>().ToList <Invitation>().Where(d => d.MandrillSendDate.Date == DateTime.Now.Date).ToList <Invitation>();
                 return(maildata.Count);
             } //End Using trasaction
         }     //End Using session
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         return(0);
     }
 }
 public void UpdateSpam(string email)
 {
     using (NHibernate.ISession session = SocioBoardInvitationMailSenderSessionFactory.GetNewSession())
     {
         //Begin session trasaction and opens up.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 session.CreateQuery("Update Mantaemail set Spam =1 where Email =:Email")
                 .SetParameter("Email", email)
                 .ExecuteUpdate();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 // return 0;
             }
         } //End Trasaction
     }     //End session
 }
 public void UpdateStatus(int id)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SocioBoardInvitationMailSenderSessionFactory.GetNewSession())
     {
         //Begin session trasaction and opens up.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 session.CreateQuery("Update Mantaemail set Status =1 where Id =:id")
                 .SetParameter("id", id)
                 .ExecuteUpdate();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 // return 0;
             }
         } //End Trasaction
     }     //End session
 }