Пример #1
0
        public Domain.Socioboard.Domain.NewsLetter getAllNewsLetterDetailsbyId(Guid nlid)
        {
            //Creates a database connection and opens up a session
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                //After Session creation, start Transaction.
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    try
                    {
                        //Proceed action, to get news details by id.
                        NHibernate.IQuery query = session.CreateQuery("from NewsLetter where Id=:adsid");

                        query.SetParameter("adsid", nlid);
                        Domain.Socioboard.Domain.NewsLetter grou = (Domain.Socioboard.Domain.NewsLetter)query.UniqueResult();
                        return(grou);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        return(null);
                    }
                } //End Transaction
            }     //End Session
        }
Пример #2
0
        public ActionResult SendAddNewsLatter(string Subject, string NewsBody, string SendDate, string UserIds) 
        {

            DateTime dt = Convert.ToDateTime(SendDate).Date;
            string[] UsersId = UserIds.Split(',');
            string mailsender = null;
            string returnmsg = null;
            foreach (var item in UsersId)
            {
                Api.User.User ApiObjUser=new Api.User.User();
                Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(ApiObjUser.getUsersById(item.ToString()), typeof(Domain.Socioboard.Domain.User)));
                Domain.Socioboard.Domain.NewsLetter ObjNewsLatter = new NewsLetter();
                if (dt == DateTime.Now.Date)
                {

                    try
                    {
                        Api.MailSender.MailSender ApiObjMailForNewsLtr = new Api.MailSender.MailSender();
                        mailsender = ApiObjMailForNewsLtr.SendAddNewsLatterMail(objUser.EmailId.ToString(), NewsBody, Subject);
                        ObjNewsLatter.Id = Guid.NewGuid();
                        ObjNewsLatter.Subject = Subject;
                        ObjNewsLatter.NewsLetterBody = NewsBody;
                        ObjNewsLatter.SendDate = DateTime.Parse(SendDate);
                        ObjNewsLatter.SendStatus = true;
                        ObjNewsLatter.UserId = Guid.Parse(item.ToString());
                        ObjNewsLatter.EntryDate = DateTime.Now;
                        string Objltr=new JavaScriptSerializer().Serialize(ObjNewsLatter);
                        Api.NewsLetter.NewsLetter objApiNewsltr = new Api.NewsLetter.NewsLetter();
                        returnmsg = (string)(new JavaScriptSerializer().Deserialize(objApiNewsltr.AddNewsLatter(Objltr), typeof(string)));

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                }
                else {
                    ObjNewsLatter.Id = Guid.NewGuid();
                    ObjNewsLatter.Subject = Subject;
                    ObjNewsLatter.NewsLetterBody = NewsBody;
                    ObjNewsLatter.SendDate = DateTime.Parse(SendDate);
                    ObjNewsLatter.SendStatus = false;
                    ObjNewsLatter.UserId = Guid.Parse(item.ToString());
                    ObjNewsLatter.EntryDate = DateTime.Now;
                    string Objltr = new JavaScriptSerializer().Serialize(ObjNewsLatter);
                    Api.NewsLetter.NewsLetter objApiNewsltr = new Api.NewsLetter.NewsLetter();
                    returnmsg = (string)(new JavaScriptSerializer().Deserialize(objApiNewsltr.AddNewsLatter(Objltr),typeof(string)));
                }    
            }
            

            return Content(returnmsg);
        }
Пример #3
0
 public string AddNewsLatter(string ObjNewsLatter)
 {
     try
     {
         Domain.Socioboard.Domain.NewsLetter objnewsLatter = (Domain.Socioboard.Domain.NewsLetter)(new JavaScriptSerializer().Deserialize(ObjNewsLatter, typeof(Domain.Socioboard.Domain.NewsLetter)));
         objNewsLetterRepository.AddNewsLetter(objnewsLatter);
         return("Success");
     }
     catch (Exception ex)
     {
         return("Something went wrong!");
     }
 }
Пример #4
0
 /// <AddNewsLetter>
 /// Add News Letter
 /// </AddNewsLetter>
 /// <param name="nl">Set Values in a NewsLetter Class Property and Pass the Object of NewsLetter Class.(Domein.NewsLetter)</param>
 public void AddNewsLetter(Domain.Socioboard.Domain.NewsLetter nl)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             //Proceed action, to save data.
             session.Save(nl);
             transaction.Commit();
         } //End Transaction
     }     //End Session
 }
Пример #5
0
 public string AddNewsLatter(string ObjNewsLatter)
 {
     try
     {
         Domain.Socioboard.Domain.NewsLetter objnewsLatter = (Domain.Socioboard.Domain.NewsLetter)(new JavaScriptSerializer().Deserialize(ObjNewsLatter, typeof(Domain.Socioboard.Domain.NewsLetter)));
         ObjNewsLetterRepository.AddNewsLetter(objnewsLatter);
         return(new JavaScriptSerializer().Serialize("Success"));
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error : " + ex.StackTrace);
         return(new JavaScriptSerializer().Serialize("Something went wrong!"));
     }
 }
Пример #6
0
        //[WebMethod]
        //[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
        public string SendNewsLetter(string body, string Subject, string userid,string NewsLetterId, string email, string name)
        {
            
            UserRepository objUserRepository = new UserRepository();
            Domain.Socioboard.Domain.User objUser = new Domain.Socioboard.Domain.User();
            objNewsLetter = new Domain.Socioboard.Domain.NewsLetter();
            string res = string.Empty;
            string ret = string.Empty;
            try
            {


                string from = ConfigurationManager.AppSettings["fromemail"];
                string tomail = ConfigurationManager.AppSettings["tomail"];
                string username = ConfigurationManager.AppSettings["Mandrillusername"];
                string host = ConfigurationManager.AppSettings["Mandrillhost"];
                string port = ConfigurationManager.AppSettings["Mandrillport"];
                string pass = ConfigurationManager.AppSettings["Mandrillpassword"];


                //string sss = ConfigurationSettings.AppSettings["host"];
                objUser = objUserRepository.getUsersById(Guid.Parse(userid));

                GlobusMailLib.MailHelper objMailHelper = new GlobusMailLib.MailHelper();

                ret = objMailHelper.SendMailByMandrill(host, Convert.ToInt32(port), from, "", objUser.EmailId, string.Empty, string.Empty, Subject, body, username, pass);
                //NewsLetterRepository objNewsLetterRepository = new NewsLetterRepository();

                if (ret.Contains("Success"))
                {
                    objNewsLetter.Id = Guid.Parse(NewsLetterId);
                    objNewsLetter.SendStatus = true;
                    objNewsLetterRepository.UpdateNewsLetter(objNewsLetter);
                }
                //return ret;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.StackTrace);
            }
            return ret;
        }
Пример #7
0
        //[WebMethod]
        //[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
        public string SendNewsLetter(string body, string Subject, string userid, string NewsLetterId, string email, string name)
        {
            UserRepository objUserRepository = new UserRepository();

            Domain.Socioboard.Domain.User objUser = new Domain.Socioboard.Domain.User();
            objNewsLetter = new Domain.Socioboard.Domain.NewsLetter();
            string res = string.Empty;
            string ret = string.Empty;

            try
            {
                string from     = ConfigurationManager.AppSettings["fromemail"];
                string tomail   = ConfigurationManager.AppSettings["tomail"];
                string username = ConfigurationManager.AppSettings["Mandrillusername"];
                string host     = ConfigurationManager.AppSettings["Mandrillhost"];
                string port     = ConfigurationManager.AppSettings["Mandrillport"];
                string pass     = ConfigurationManager.AppSettings["Mandrillpassword"];


                //string sss = ConfigurationSettings.AppSettings["host"];
                objUser = objUserRepository.getUsersById(Guid.Parse(userid));

                GlobusMailLib.MailHelper objMailHelper = new GlobusMailLib.MailHelper();

                ret = objMailHelper.SendMailByMandrill(host, Convert.ToInt32(port), from, "", objUser.EmailId, string.Empty, string.Empty, Subject, body, username, pass);
                //NewsLetterRepository objNewsLetterRepository = new NewsLetterRepository();

                if (ret.Contains("Success"))
                {
                    objNewsLetter.Id         = Guid.Parse(NewsLetterId);
                    objNewsLetter.SendStatus = true;
                    objNewsLetterRepository.UpdateNewsLetter(objNewsLetter);
                }
                //return ret;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.StackTrace);
            }
            return(ret);
        }
Пример #8
0
        public string GetAllNewsLetters()
        {
            MailSender _MailSender = new MailSender();

            //List<NewsLetter> = ObjNewsLetterRepository.getAllNewsLetter();
            try
            {
                List <Domain.Socioboard.Domain.NewsLetter> lstNewsLetter = new List <Domain.Socioboard.Domain.NewsLetter>();
                lstNewsLetter = objNewsLetterRepository.getAllNewsLetters();
                if (lstNewsLetter.Count == 0)
                {
                    return("No record found");
                }
                foreach (Domain.Socioboard.Domain.NewsLetter item in lstNewsLetter)
                {
                    //string ret = string.Empty;
                    try
                    {
                        objNewsLetter = new Domain.Socioboard.Domain.NewsLetter();
                        string ret = _MailSender.SendAddNewsLatterMail(item.Email, item.NewsLetterBody, item.Subject);
                        if (ret == "Success")
                        {
                            objNewsLetter.Id         = item.Id;
                            objNewsLetter.SendStatus = true;
                            objNewsLetterRepository.UpdateNewsLetter(objNewsLetter);
                        }
                        //SendMail(item);
                        //SendNewsLetter(item.NewsLetterBody, item.Subject, item.UserId.ToString(), item.Id.ToString());
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error : " + ex.StackTrace);
                    }
                }
                return("New Latter Sent successfully");
            }
            catch (Exception ex)
            {
                return("Please try Again");
            }
        }
Пример #9
0
        /// <UpdateNewsLetter>
        /// Update News Letter
        /// </summary>
        /// <param name="nl">Set Values in a NewsLetter Class Property and Pass the Object of NewsLetter Class.(Domein.NewsLetter)</param>
        public void UpdateNewsLetter(Domain.Socioboard.Domain.NewsLetter nl)
        {
            //Creates a database connection and opens up a session
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                //After Session creation, start Transaction.
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    try
                    {
                        //Proceed action, to update existing news.
                        //  session.CreateQuery("Update NewsLetter set SendStatus =1 where UserId = :UserId,SendDate = :SendDate and Id= :adsid")
                        //  int i = session.CreateQuery("Update NewsLetter set SendStatus ='1' where Id = :id")
                        //      .SetParameter("id",nl.Id)
                        //     // .SetParameter("uid", nl.UserId)
                        //      //.SetParameter("SendDate", nl.SendDate)
                        //      //.SetParameter("nid", nl.Id)
                        //      .ExecuteUpdate();
                        //transaction.Commit();

                        //  List<NewsLetter> alst = session.CreateQuery("from NewsLetter where Id ="+nl.Id+ " ")
                        ////.SetParameter("id", nl.Id)
                        //.List<NewsLetter>()
                        //.ToList<NewsLetter>();



                        int i = session.CreateQuery("Update NewsLetter set SendStatus ='1' where Id = :id")
                                .SetParameter("id", nl.UserId)
                                .ExecuteUpdate();
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        // return 0;
                    }
                } //End Transaction
            }     //End Session
        }
Пример #10
0
 public string GetAllNewsLetters()
 {
     MailSender _MailSender=new MailSender();
     //List<NewsLetter> = ObjNewsLetterRepository.getAllNewsLetter();
     try
     {
         List<Domain.Socioboard.Domain.NewsLetter> lstNewsLetter = new List<Domain.Socioboard.Domain.NewsLetter>();
         lstNewsLetter = objNewsLetterRepository.getAllNewsLetters();
         if(lstNewsLetter.Count == 0)
         {
             return "No record found";
         }
         foreach (Domain.Socioboard.Domain.NewsLetter item in lstNewsLetter)
         {
             //string ret = string.Empty;
             try
             {
                 objNewsLetter=new Domain.Socioboard.Domain.NewsLetter();
                 string ret = _MailSender.SendAddNewsLatterMail(item.Email, item.NewsLetterBody, item.Subject);
                 if(ret=="Success")
                 {
                     objNewsLetter.Id = item.Id;
                     objNewsLetter.SendStatus = true;
                     objNewsLetterRepository.UpdateNewsLetter(objNewsLetter);
                 }
                 //SendMail(item);
                 //SendNewsLetter(item.NewsLetterBody, item.Subject, item.UserId.ToString(), item.Id.ToString());
             }
             catch (Exception ex)
             {
                 Console.WriteLine("Error : " + ex.StackTrace);
             }
         }
         return "New Latter Sent successfully";
     }
     catch (Exception ex)
     {
         return "Please try Again";
     }      
 }
Пример #11
0
 /// <UpdateNewsLetter>
 /// Update News Letter
 /// </summary>
 /// <param name="nl">Set Values in a NewsLetter Class Property and Pass the Object of NewsLetter Class.(Domein.NewsLetter)</param>
 public void UpdateNewsLetter(Domain.Socioboard.Domain.NewsLetter nl)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 int i = session.CreateQuery("Update NewsLetter set SendStatus =:SendStatus where Id = :id")
                         .SetParameter("id", nl.UserId)
                         .SetParameter("SendStatus", true)
                         .ExecuteUpdate();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
             }
         } //End Transaction
     }     //End Session
 }
Пример #12
0
 /// <getNewsLetterDetails>
 /// Get news letter details by news boy
 /// </summary>
 /// <param name="nlDetail">Message(Body) of new latter</param>
 /// <returns></returns>
 public Domain.Socioboard.Domain.NewsLetter getNewsLetterDetails(string nlDetail)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 //Proceed action, to get news detail by new body.
                 NHibernate.IQuery query = session.CreateQuery("from NewsLetter where NewsLetterBody=:nlDetail");
                 query.SetParameter("nlDetail", nlDetail);
                 Domain.Socioboard.Domain.NewsLetter grou = query.UniqueResult <Domain.Socioboard.Domain.NewsLetter>();
                 return(grou);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return(null);
             }
         } //End Transaction
     }     //End Session
 }
        public ActionResult SendAddNewsLatter(string Subject, string NewsBody, string SendDate, string UserIds, string UserEmails, string UserNames) 
        {
            if (Session["User"] != null)
            {
                Domain.Socioboard.Domain.User _User = (Domain.Socioboard.Domain.User)Session["User"];
                if (_User.UserType != "SuperAdmin")
                {
                    return RedirectToAction("Index", "Index");
                }
            }
            else
            {
                return RedirectToAction("Index", "Index");
            }
            DateTime dt = Convert.ToDateTime(SendDate).Date;
            string[] UsersId = UserIds.Split(',');
            string[] UserEmail = UserEmails.Split(',');
            string[] UserName = UserNames.Split(','); 
            //string mailsender = null;
            string returnmsg = string.Empty;
            int i = 0;
            foreach (var item in UsersId)
            {
                Api.User.User ApiObjUser=new Api.User.User();
                //Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(ApiObjUser.getUsersById(item.ToString(), Session["access_token"].ToString()), typeof(Domain.Socioboard.Domain.User)));
                Domain.Socioboard.Domain.NewsLetter objNewsLatter = new NewsLetter();
                //if (dt == DateTime.Now.Date)
                //{

                //    try
                //    {
                //        Api.MailSender.MailSender ApiObjMailForNewsLtr = new Api.MailSender.MailSender();
                //        mailsender = ApiObjMailForNewsLtr.SendAddNewsLatterMail(objUser.EmailId.ToString(), NewsBody, Subject);
                //        ObjNewsLatter.Id = Guid.NewGuid();
                //        ObjNewsLatter.Subject = Subject;
                //        ObjNewsLatter.NewsLetterBody = NewsBody;
                //        ObjNewsLatter.SendDate = DateTime.Parse(SendDate);
                //        ObjNewsLatter.SendStatus = true;
                //        ObjNewsLatter.UserId = Guid.Parse(item.ToString());
                //        ObjNewsLatter.EntryDate = DateTime.Now;
                //        string Objltr=new JavaScriptSerializer().Serialize(ObjNewsLatter);
                //        Api.NewsLetter.NewsLetter objApiNewsltr = new Api.NewsLetter.NewsLetter();
                //        returnmsg = (string)(new JavaScriptSerializer().Deserialize(objApiNewsltr.AddNewsLatter(Objltr), typeof(string)));

                //    }
                //    catch (Exception ex)
                //    {
                //        Console.WriteLine(ex.StackTrace);
                //    }
                //}
                //else {
                    objNewsLatter.Id = Guid.NewGuid();
                    objNewsLatter.Subject = Subject;
                    objNewsLatter.NewsLetterBody = NewsBody;
                    objNewsLatter.SendDate = DateTime.Parse(SendDate);
                    objNewsLatter.SendStatus = false;
                    objNewsLatter.UserId = Guid.Parse(item.ToString());
                    objNewsLatter.Email = UserEmail[i];
                    objNewsLatter.Name=UserName[i];
                    objNewsLatter.EntryDate = DateTime.Now;
                    string objltr = new JavaScriptSerializer().Serialize(objNewsLatter);
                    Api.NewsLetter.NewsLetter objApiNewsltr = new Api.NewsLetter.NewsLetter();
                    returnmsg = objApiNewsltr.AddNewsLatter(objltr);
                //}   
                    i++;
            }
            

            return Content(returnmsg);
        }