Example #1
0
 /// <summary>
 /// create role
 /// </summary>
 /// <param name="role"></param>
 public void CreateRole(Role role)
 {
     try
     {
         db.Role.Add(role);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         MethodBase site = MethodBase.GetCurrentMethod();
         string     url  = HttpContext.Current.Request.Url.AbsoluteUri;// request.Url.AbsoluteUri;
         exceptionLogsRepositery.InsertException(ex, url, site.Name);
     }
 }
Example #2
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public List <TimerSetting> ReadAllTimerSetting()
 {
     try
     {
         timerSettingsList = db.TimerSetting.ToList();
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         MethodBase site = MethodBase.GetCurrentMethod();
         string     url  = HttpContext.Current.Request.Url.AbsoluteUri;// request.Url.AbsoluteUri;
         _ExceptionLogsRepositeryObject.InsertException(ex, url, site.Name);
     }
     return(timerSettingsList);
 }
Example #3
0
        //===================================================Method to Send Reminder Email //Insert reminder email details in email Queue  =========================================================================
        /// <summary>
        /// Method to Send Reminder Email //Insert reminder email details in email Queue
        /// </summary>
        public static void SendReminderEmail()
        {
            ExceptionLogsRepositery exceptionLogsRepositery     = new ExceptionLogsRepositery();
            UsersRepositery         _UsersRepositeryObject      = new UsersRepositery();
            EmailQueueRepositery    _EmailQueueRepositeryObject = new EmailQueueRepositery();
            EmailLogsRepositery     _EmailLogsRepositeryObject  = new EmailLogsRepositery();
            TaskRepositery          _TaskRepositertyObject      = new TaskRepositery();

            List <Users>     usersList             = new List <Users>();
            List <EmailLogs> emailLogsList         = new List <EmailLogs>();
            List <Task>      taskList              = new List <Task>();
            List <EmailLogs> emailLogsListReminder = new List <EmailLogs>();
            string           hostname              = Dns.GetHostName();

            try
            {
                //get all users detail int usersList
                usersList = _UsersRepositeryObject.GetAllUsers();

                //Remove admin details
                usersList.RemoveAll(x => x.RoleId == 1);

                //get detail of user who have submitted there task today from task table
                taskList = _TaskRepositertyObject.GetTaskDetailOfTodaySubmittedTask();

                //list of user who have not submitted there task today //remove the user who have submitted there task
                usersList.RemoveAll(x => taskList.Exists(i => x.Id == i.EmployeeId));

                string logo = "ftp://[email protected]/Content/Image/Logo.jpg";
                if (usersList.Count > 0)
                {
                    //insert email detail into email Queue
                    foreach (Users item in usersList)
                    {
                        _EmailQueueRepositeryObject.InsertEmailDeatailsInEmailQueue("*****@*****.**", item.Email, "Task Reminder", "<html>Dear Employee,<br/><br/><br/>You have not submitted your today's task detail. Don't forget to submit your task.<br/><br/><b>Thanks & regards<br/><br/><img width=196 height=153 src=" + "http://demo8.clanstech.com/Content/Image/logo.jpg" + "><br/><br/></b><br/><br><address><b>Adderss:</b><br/>G-282 , Sector-63<br/>   Noida -201301 ,<br/>Gautam Buddh Nagar<br/>U.P, India<br><br><b>Website: </b><a href=" + "https://clanstech.com" + ">www.clanstech.com</a><br/><b>Phone:</b> <phone>+91-7042.615.658</phone><br/><b>Maps: </b><a href=" + "https://www.google.com/maps/place/Clanstech+%7C+Providing+Online+Presence/@28.614499,77.3887193,17z/data=!3m1!4b1!4m5!3m4!1s0x390cef928e84423b:0xde8604eb59d84354!8m2!3d28.614499!4d77.390908" + ">Google Maps</a></address></html>");
                        Console.WriteLine("Email details inserting to Email Queue : " + item.Email);
                    }
                }
            }
            catch (Exception ex)
            {
                string     error = ex.Message;
                MethodBase site  = MethodBase.GetCurrentMethod();
                //HttpRequest request = HttpContext.Current.Request;
                string url = "";// request.Url.AbsoluteUri;
                Console.WriteLine("Exception occurred in inserting into email queue for reminder");
                Console.WriteLine("Message : " + ex.Message);
                Console.WriteLine("StackTrace : " + ex.StackTrace);
                Console.WriteLine("Data : " + ex.Data);
                Console.WriteLine("Source : " + ex.Source);
                Console.WriteLine("Method" + site.Name.ToString());
                exceptionLogsRepositery.InsertException(ex, url, site.Name);
            }
        }
 // //insert into emailqueue table
 /// </summary>
 /// <param name="from"></param>
 /// <param name="to"></param>
 /// <param name="subject"></param>
 /// <param name="body"></param>
 public void InsertEmailDeatailsInEmailQueue(string from, string to, string subject, string body)
 {
     try
     {
         EmailQueue NewemailQueue = new EmailQueue();
         NewemailQueue.FromAddress = from;
         NewemailQueue.ToAddress   = to;
         NewemailQueue.Subject     = subject;
         NewemailQueue.Body        = body;
         NewemailQueue.CreatedOn   = DateTime.Now;
         NewemailQueue.ModifiedOn  = DateTime.Now;
         db.EmailQueue.Add(NewemailQueue);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         MethodBase site = MethodBase.GetCurrentMethod();
         string     url  = "";// HttpContext.Current.Request.Url.AbsoluteUri;// request.Url.AbsoluteUri;
         exceptionLogsRepositery.InsertException(ex, url, site.Name);
     }
 }
        public ActionResult CreateUser([Bind(Include = "Id,Name,Phone,Email,Password,RoleId,CreatedOn,ModifiedOn,DeletedOn,IsDeleted,EmployeeId")] Users users)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //validate if user all ready registered
                    Users sucess = _UsersRepositeryObject.GetUserDetailUsingEmailAndEmployeeId(users.Email, users.EmployeeId);
                    if (sucess == null)
                    {
                        users.CreatedOn  = DateTime.Now;
                        users.ModifiedOn = DateTime.Now;
                        //To get the hash password
                        string password     = users.Password;
                        string hashPassword = _HashPasswordObject.GetHashPassword(users.Password);
                        users.Password = hashPassword;
                        _UsersRepositeryObject.CreateUser(users);
                        //Send Email to emplyee //With login credentials for task tracker
                        _EmailQueueRepositeryObject.InsertEmailDeatailsInEmailQueue("*****@*****.**", users.Email, "Task Tracker Login Credentials", "<html>Dear " + users.Name + ",<br/><br/><br/>Your account for Task Tracker has been created. Please submit your task details befor leaving the office.<br/><br/><b>Login Id: </b>" + users.Email + "<br/><b>Password: </b>" + password + "<br/><br/><br/>Thanks & regards<br/><br/><img width=196 height=153 src=" + "http://" + Request.Url.Authority + "/Content/Image/logo.jpg" + "></b><br/><br><address><b>Adderss:</b><br/>G-282 , Sector-63<br/>   Noida -201301 ,<br/>Gautam Buddh Nagar<br/>U.P, India<br><br><b>Website: </b><a href=" + "https://clanstech.com" + ">www.clanstech.com</a><br/><b>Phone:</b> <phone>+91-7042.615.658</phone><br/><b>Maps: </b><a href=" + "https://www.google.com/maps/place/Clanstech+%7C+Providing+Online+Presence/@28.614499,77.3887193,17z/data=!3m1!4b1!4m5!3m4!1s0x390cef928e84423b:0xde8604eb59d84354!8m2!3d28.614499!4d77.390908" + ">Google Maps</a></address></html>");
                        TempData["Message"] = "Employee Created Successfully";
                        return(RedirectToAction("UserIndex"));
                    }
                    else
                    {
                        TempData["Message"] = "Error : User All ready registered : Try Again";
                        return(RedirectToAction("CreateUser"));
                    }
                }
            }
            catch (Exception ex)
            {
                MethodBase site = MethodBase.GetCurrentMethod();
                string     url  = Request.Url.ToString();
                _ExceptionLogsRepositeryObject.InsertException(ex, url, site.Name);
            }


            ViewBag.RoleId = new SelectList(db.Role, "Id", "Type", users.RoleId);
            return(View(users));
        }
 /// <summary>
 /// to insert details in attachement
 /// </summary>
 /// <param name="fileName"></param>
 /// <param name="path"></param>
 /// <param name="extension"></param>
 /// <param name="taskId"></param>
 public void AddAttachment(string fileName, string path, string extension, int taskId)
 {
     try
     {
         attachment.FileName  = fileName;
         attachment.Path      = path;
         attachment.Extension = extension;
         attachment.TaskId    = taskId;
         db.Attachment.Add(attachment);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         MethodBase site = MethodBase.GetCurrentMethod();
         string     url  = HttpContext.Current.Request.Url.AbsoluteUri;// request.Url.AbsoluteUri;
         exrepositery.InsertException(ex, url, site.Name);
     }
 }
        /// <summary>
        ////Insert email log details into EmailLogTable
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <param name="smtp"></param>
        /// <param name="ipAddress"></param>
        /// <param name="status"></param>
        public void InsertEmaillogs(string from, string to, string subject, string body, string smtp, string ipAddress, string status)
        {
            try
            {
                emailLogs.FromAddress = from;
                emailLogs.ToAddress   = to;
                emailLogs.Subject     = subject;
                emailLogs.Body        = body;
                emailLogs.Smtp        = smtp;
                emailLogs.IpAddress   = ipAddress;
                emailLogs.Status      = status;

                db.EmailLogs.Add(emailLogs);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                MethodBase site = MethodBase.GetCurrentMethod();
                string     url  = "";// HttpContext.Current.Request.Url.AbsoluteUri;// request.Url.AbsoluteUri;
                exceptionLogsRepositery.InsertException(ex, url, site.Name);
            }
        }
Example #8
0
 /// <summary>
 ////Get all users detail
 /// </summary>
 /// <returns></returns>
 public List <Users> GetAllUsers()
 {
     try
     {
         usersList = db.Users.Where(x => x.IsDeleted == false).ToList();
     }
     catch (Exception ex)
     {
         MethodBase site = MethodBase.GetCurrentMethod();
         string     url  = "";// HttpContext.Current.Request.Url.AbsoluteUri;// request.Url.AbsoluteUri;
         exrepo.InsertException(ex, url, site.Name);
     }
     return(usersList);
 }
Example #9
0
        //======================================================================================To send the email from email queue data=====================================================================
        /// <summary>
        /// To send the email from email queue data
        /// </summary>
        public static void SendEmailFromQueue()
        {
            Console.WriteLine("SendEmailFromQueue()");
            try
            {
                EmailQueueRepositery _EmailQueueRepositeryObject = new EmailQueueRepositery();
                EmailLogsRepositery  _EmailLogsRepositeryObject  = new EmailLogsRepositery();
                Email       _EmailObject = new Email();
                EmailQueue  item         = new EmailQueue();
                string      hostname     = Dns.GetHostName();
                IPAddress[] iPAddress    = Dns.GetHostAddresses(hostname);
                string      ip           = iPAddress[1].ToString();
                int         success      = 0;


                Console.WriteLine("Send email from email queue is executing...");
                //read emails details from emailqueue
                item = _EmailQueueRepositeryObject.GetTopEmailQueueDetail();

                if (item != null)    //emailQueueList.Count() != 0
                {
                    //set deleted is 1 in emailqueue
                    //_EmailQueueRepositeryObject.UpdateIsDeletedTrue(item);

                    //read tries from EmailQueue table
                    //int tries = _EmailQueueRepositeryObject.GetTries(item);
                    int tries = 0;

                    while (tries <= 5)
                    {
                        //send email
                        success = _EmailObject.SendEmail(item.FromAddress, item.ToAddress, item.Subject, item.Body);

                        if (success == 1)
                        {
                            //insert email details into emaillogs status as success
                            _EmailLogsRepositeryObject.InsertEmaillogs(item.FromAddress, item.ToAddress, item.Subject, item.Body, "mail.clanstech.com", ip, "Success");
                            //delete email detail from email queue
                            _EmailQueueRepositeryObject.DeletedFromEmailQueue(item);
                            Console.WriteLine("Email sent successfull to : " + item.ToAddress);
                            break;
                        }
                        else
                        {
                            //set deleted is 0 in emailqueue
                            //_EmailQueueRepositeryObject.UpdateIsDeletedFalse(item);
                            //increment tries into emailqueue
                            _EmailQueueRepositeryObject.IncrementTries(item);
                            Console.WriteLine("Email sending fail to : " + item.ToAddress);
                        }
                        //read tries from EmailQueue table
                        tries = _EmailQueueRepositeryObject.GetTries(item);
                        Console.WriteLine("Incrementing try");
                    }
                    if (tries >= 6)
                    {
                        //insert email details into emaillogs status as fail
                        _EmailLogsRepositeryObject.InsertEmaillogs(item.FromAddress, item.ToAddress, item.Subject, item.Body, "mail.clanstech.com", ip, "Fail");
                        //delete email detail from email queue
                        _EmailQueueRepositeryObject.DeletedFromEmailQueue(item);
                        Console.WriteLine("Email sending  fail to : " + item.ToAddress);
                    }
                }
                else
                {
                    Console.WriteLine("Email Queue is empty...");
                }
            }
            catch (Exception ex)
            {
                try
                {
                    ExceptionLogsRepositery _ExceptionLogsRepositeryObject = new ExceptionLogsRepositery();
                    MethodBase site = MethodBase.GetCurrentMethod();
                    string     url  = "";// Request.Url.ToString();
                    _ExceptionLogsRepositeryObject.InsertException(ex, url, site.Name);
                }
                catch (Exception exnew)
                {
                    Console.WriteLine("****Parent");
                    Console.WriteLine("Message : " + ex.Message);
                    Console.WriteLine("StackTrace : " + ex.StackTrace);
                    Console.WriteLine("Data : " + ex.Data);
                    Console.WriteLine("Source : " + ex.Source);
                    Console.WriteLine("****Child");
                    Console.WriteLine("Message : " + exnew.Message.ToString());
                    Console.WriteLine("StackTrace : " + exnew.StackTrace);
                    Console.WriteLine("Data : " + exnew.Data);
                    Console.WriteLine("Source : " + exnew.Source);
                }
            }
        }
Example #10
0
        public ActionResult CreateTask([Bind(Include = "Id,Title,Description,DateTime,EmployeeId,CreatedOn,ModifiedOn,DeletedOn,IsDeleted")] Task task, HttpPostedFileBase[] files)
        {
            int  taskId;
            bool success;

            try
            {
                if (ModelState.IsValid)
                {
                    task.EmployeeId = Convert.ToInt32(Session["UserId"]);
                    //Check if employee submnitted Today's task
                    success = _TaskRepositeryObject.CheckTodayTaskByEmployeeId(task.EmployeeId);
                    if (success == true)
                    {
                        TempData["Message"] = "Multiple task can't be submitted for a day.";
                        return(RedirectToAction("EmployeeDashboard", "Home"));
                    }
                    taskId = _TaskRepositeryObject.CreateTask(task);

                    //for file upload

                    if (files[0] != null)
                    {
                        foreach (HttpPostedFileBase file in files)
                        {
                            string fileName = Path.GetFileName(file.FileName);
                            //System.Web.Hosting.HostingEnvironment.MapPath("~/SignatureImages/");
                            //server.MapPath();
                            string path = Path.Combine(HostingEnvironment.MapPath("~/UploadedFile"), fileName);
                            //string path = Path.Combine("ftp://[email protected]/UploadedFile", fileName);
                            string extension = Path.GetExtension(path);
                            file.SaveAs(path);

                            //inserting attachement details into attachment table
                            _AttachmentRepositeryObject.AddAttachment(fileName, path, extension, taskId);
                        }

                        //Mail to Employee
                        //Insert email details into emailQueue table
                        string email = Convert.ToString(Session["UserEmail"]);
                        _EmailQueueRepositeryObject.InsertEmailDeatailsInEmailQueue("*****@*****.**", email, "Task Submitted Successfully", "<html>Dear " + Session["UserName"] + ",<br/><br/><br> You have successfully submitted today's task status.<br/><br/><b>Title: </b>" + task.Title + "<br/><b>Description: </b>" + task.Description + "<br><br/><br>Thanks & regards<br/><br/><img width=196 height=153 src=" + "http://" + Request.Url.Authority + "/Content/Image/Logo.jpg" + "></b><br/><br><address><b>Adderss:</b><br/>G-282 , Sector-63<br/>   Noida -201301 ,<br/>Gautam Buddh Nagar<br/>U.P, India<br><br><b>Website: </b><a href=" + "https://clanstech.com" + ">www.clanstech.com</a><br/><b>Phone:</b> <phone>+91-7042.615.658</phone><br/><b>Maps: </b><a href=" + "https://www.google.com/maps/place/Clanstech+%7C+Providing+Online+Presence/@28.614499,77.3887193,17z/data=!3m1!4b1!4m5!3m4!1s0x390cef928e84423b:0xde8604eb59d84354!8m2!3d28.614499!4d77.390908" + ">Google Maps</a></address></html>");

                        if (Session["MentorEmail"] != null)
                        {
                            //Mail to Employee Mentor
                            string mentorEmail = Convert.ToString(Session["MentorEmail"]);
                            //Insert email details into emailQueue table
                            _EmailQueueRepositeryObject.InsertEmailDeatailsInEmailQueue("*****@*****.**", mentorEmail, "Trainee Task Update", "<html>Dear Mentor,<br/><br/><br/> Your trainee have successfully submitted today's task status.<br/><br/><br/><b>Trainee Name: </b>" + Session["UserName"] + "< br/><b>Title: </b>" + task.Title + "<br/><b>Description: </b>" + task.Description + "<br/><br/><br/>Thanks & regards<br/><br/><img width=196 height=153 src=" + "http://" + Request.Url.Authority + "/Content/Image/Logo.jpg" + "></b><br/><br><address><b>Adderss:</b><br/>G-282 , Sector-63<br/>   Noida -201301 ,<br/>Gautam Buddh Nagar<br/>U.P, India<br><br><b>Website: </b><a href=" + "https://clanstech.com" + ">www.clanstech.com</a><br/><b>Phone:</b> <phone>+91-7042.615.658</phone><br/><b>Maps: </b><a href=" + "https://www.google.com/maps/place/Clanstech+%7C+Providing+Online+Presence/@28.614499,77.3887193,17z/data=!3m1!4b1!4m5!3m4!1s0x390cef928e84423b:0xde8604eb59d84354!8m2!3d28.614499!4d77.390908" + ">Google Maps</a></address></html>");
                        }
                        ////Mail to Admin
                        //string adminEmail = "*****@*****.**";
                        //////Insert email details into emailQueue table
                        //emailQueueRepositeryObj.InsertEmailDeatailsInEmailQueue("*****@*****.**", adminEmail, "Task", "Dear Admin,<br/> Your Employee have successfully submitted today's task status.<br/>Employee Name:" + Session["UserName"] + "< br/>Title:" + task.Title + "<br/>Description:" + task.Description + "<br>Thanks & Regards.");
                    }
                    else
                    {
                        // Mail to Employee
                        string email = Convert.ToString(Session["UserEmail"]);
                        //Insert email details into emailQueue table
                        _EmailQueueRepositeryObject.InsertEmailDeatailsInEmailQueue("*****@*****.**", email, "Task Submitted Successfully", "<html>Dear " + Session["UserName"] + ",<br/><br/><br/> You have successfully submitted today's task status.<br/><br/><b>Title: </b>" + task.Title + "<br/><b>Description: </b>" + task.Description + "<br/><br/><br/>Thanks & regards<br/><br/><img width=196 height=153 src=" + "http://" + Request.Url.Authority + "/Content/Image/Logo.jpg" + "></b><br/><br><address><b>Adderss:</b><br/>G-282 , Sector-63<br/>   Noida -201301 ,<br/>Gautam Buddh Nagar<br/>U.P, India<br><br><b>Website: </b><a href=" + "https://clanstech.com" + ">www.clanstech.com</a><br/><b>Phone:</b> <phone>+91-7042.615.658</phone><br/><b>Maps: </b><a href=" + "https://www.google.com/maps/place/Clanstech+%7C+Providing+Online+Presence/@28.614499,77.3887193,17z/data=!3m1!4b1!4m5!3m4!1s0x390cef928e84423b:0xde8604eb59d84354!8m2!3d28.614499!4d77.390908" + ">Google Maps</a></address></html>");

                        if (Session["MentorEmail"] != null)
                        {
                            //Mail to Employee Mentor
                            string mentorEmail = Convert.ToString(Session["MentorEmail"]);
                            //Insert email details into emailQueue table
                            _EmailQueueRepositeryObject.InsertEmailDeatailsInEmailQueue("*****@*****.**", mentorEmail, "Trainee Task Update", "<html>Dear Mentor,<br/><br/><br/> Your trainee have successfully submitted today's task status.<br/><br/><b>Trainee Name: </b>" + Session["UserName"] + "<br/><b>Title: </b>" + task.Title + "<br/><b>Description: </b>" + task.Description + "<br/><br/><br/>Thanks & regards<br/><br/><img width=196 height=153 src=" + "http://" + Request.Url.Authority + "/Content/Image/Logo.jpg" + "></b><br/><br><address><b>Adderss:</b><br/>G-282 , Sector-63<br/>   Noida -201301 ,<br/>Gautam Buddh Nagar<br/>U.P, India<br><br><b>Website: </b><a href=" + "https://clanstech.com" + ">www.clanstech.com</a><br/><b>Phone:</b> <phone>+91-7042.615.658</phone><br/><b>Maps: </b><a href=" + "https://www.google.com/maps/place/Clanstech+%7C+Providing+Online+Presence/@28.614499,77.3887193,17z/data=!3m1!4b1!4m5!3m4!1s0x390cef928e84423b:0xde8604eb59d84354!8m2!3d28.614499!4d77.390908" + ">Google Maps</a></address></html>");
                        }
                        ////Mail to Admin
                        ////Insert email details into emailQueue table
                        //string adminEmail = "*****@*****.**";
                        //emailQueueRepositeryObj.InsertEmailDeatailsInEmailQueue("*****@*****.**", adminEmail, "Task", "Dear Admin,<br/> Your Employee have successfully submitted today's task status.<br/>Employee Name:" + Session["UserName"] + "<br/>Title:" + task.Title + "<br/>Description:" + task.Description + "< br>Thanks & Regards.");
                    }

                    if (Convert.ToInt32(Session["RoleId"]) == 4)
                    {
                        TempData["Message"] = "Task submitted successfullly";
                        return(RedirectToAction("Index", "Tasks"));
                    }
                    else
                    {
                        TempData["Message"] = "Task submitted successfullly";
                        return(RedirectToAction("EmployeeDashboard", "Home"));
                    }
                }
            }
            catch (Exception ex)
            {
                MethodBase site = MethodBase.GetCurrentMethod();
                string     url  = Request.Url.ToString();
                _ExceptionLogsRepositeryObject.InsertException(ex, url, site.Name);
            }

            //ViewBag.EmployeeId = new SelectList(db.Users, "Id", "Name", task.EmployeeId);
            return(View(task));
        }
Example #11
0
        //To send the email from email queue data
        public static void SendEmailFromQueue()
        {
            EmailQueueRepositery    _EmailQueueRepositeryObject    = new EmailQueueRepositery();
            EmailLogsRepositery     _EmailLogsRepositeryObject     = new EmailLogsRepositery();
            ExceptionLogsRepositery _ExceptionLogsRepositeryObject = new ExceptionLogsRepositery();
            Email      _EmailObject = new Email();
            EmailQueue item         = new EmailQueue();
            string     hostname     = Dns.GetHostName();

            IPAddress[] iPAddress = Dns.GetHostAddresses(hostname);
            string      ip        = iPAddress[1].ToString();
            int         success   = 0;

            try
            {
                //read emails details from emailqueue
                item = _EmailQueueRepositeryObject.GetTopEmailQueueDetail();

                if (item != null)    //emailQueueList.Count() != 0
                {
                    //set deleted is 1 in emailqueue
                    //_EmailQueueRepositeryObject.UpdateIsDeletedTrue(item);

                    //read tries from EmailQueue table
                    //int tries = _EmailQueueRepositeryObject.GetTries(item);
                    int tries = 0;

                    while (tries <= 5)
                    {
                        //send email
                        success = _EmailObject.SendEmail(item.FromAddress, item.ToAddress, item.Subject, item.Body);

                        if (success == 1)
                        {
                            //insert email details into emaillogs status as success
                            _EmailLogsRepositeryObject.InsertEmaillogs(item.FromAddress, item.ToAddress, item.Subject, item.Body, "mail.clanstech.com", ip, "Success");
                            //delete email detail from email queue
                            _EmailQueueRepositeryObject.DeletedFromEmailQueue(item);
                            break;
                        }
                        else
                        {
                            //set deleted is 0 in emailqueue
                            //_EmailQueueRepositeryObject.UpdateIsDeletedFalse(item);
                            //increment tries into emailqueue
                            _EmailQueueRepositeryObject.IncrementTries(item);
                        }
                        //read tries from EmailQueue table
                        tries = _EmailQueueRepositeryObject.GetTries(item);
                    }
                    if (tries > 6)
                    {
                        //insert email details into emaillogs status as fail
                        _EmailLogsRepositeryObject.InsertEmaillogs(item.FromAddress, item.ToAddress, item.Subject, item.Body, "mail.clanstech.com", ip, "Fail");
                        //delete email detail from email queue
                        _EmailQueueRepositeryObject.DeletedFromEmailQueue(item);
                    }
                }
            }
            catch (Exception ex)
            {
                MethodBase site = MethodBase.GetCurrentMethod();
                string     url  = "";// Request.Url.ToString();
                _ExceptionLogsRepositeryObject.InsertException(ex, url, site.Name);
            }
        }
Example #12
0
        public ActionResult Login(Login login)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string email = login.Email;
                    Users  us    = _UsersRepositeryObject.GetUserDetailUsingEmail(email);//email
                    if (us == null || us.IsDeleted == true)
                    {
                        TempData["Message"] = "Your account deleted or does not exist:Please contact to admin";
                        return(RedirectToAction("Login"));
                    }
                    //hashing of password
                    login.Password = _HashPasswordObject.GetHashPassword(login.Password);

                    if (login.Email == us.Email && login.Password == us.Password)
                    {
                        role = _RoleRepositeryObject.GetRoleDetailUsingRoleId(us.RoleId);

                        if (role.Type == "Admin")//need to change after project completion and all table truncate
                        {
                            Session["AdminId"]   = us.Id;
                            Session["UserId"]    = us.Id;
                            Session["UserName"]  = us.Name;
                            Session["UserEmail"] = us.Email;
                            Session["RoleId"]    = us.RoleId;

                            return(RedirectToAction("AdminDashboard", "Home", new { area = "Admin" }));
                        }
                        else
                        {
                            Session["UserId"]    = us.Id;
                            Session["UserName"]  = us.Name;
                            Session["UserEmail"] = us.Email;
                            Session["RoleId"]    = us.RoleId;

                            Mentor mentor = _MentorRepositeryObject.GetMentorDetailsUsingEmployeeId(us.Id);

                            if (mentor != null)
                            {
                                Users user1 = _UsersRepositeryObject.GetUsersDetailUsingId(mentor.EmployeeMentorId);
                                Session["MentorEmail"] = user1.Email;
                            }



                            return(RedirectToAction("EmployeeDashboard", "Home", new { area = "Employee" }));
                        }
                    }
                    else
                    {
                        TempData["Message"] = "Invalid Credentials:Please Try Again";
                        return(RedirectToAction("Login"));
                    }
                }
            }
            catch (Exception ex)
            {
                MethodBase site = MethodBase.GetCurrentMethod();
                string     url  = Request.Url.ToString();
                _ExceptionLogsRepositeryObject.InsertException(ex, url, site.Name);
            }

            return(View("Login"));
        }
 public void EditMentor(Mentor mentor)
 {
     try
     {
         db.Entry(mentor).State = EntityState.Modified;
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         MethodBase site = MethodBase.GetCurrentMethod();
         string     url  = HttpContext.Current.Request.Url.AbsoluteUri;// request.Url.AbsoluteUri;
         exceptionLogsRepositery.InsertException(ex, url, site.Name);
     }
 }
 /// <summary>
 ////Get all task submitted by an employee using employeeId
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public List <Task> GetAllTaskByEmployeeId(int id)
 {
     try
     {
         taskList = db.Task.Where(x => x.EmployeeId == id && x.IsDeleted == false).OrderByDescending(x => x.CreatedOn).ToList();
     }
     catch (Exception ex)
     {
         MethodBase site = MethodBase.GetCurrentMethod();
         string     url  = HttpContext.Current.Request.Url.AbsoluteUri;// request.Url.AbsoluteUri;
         exrepo.InsertException(ex, url, site.Name);
     }
     return(taskList);
 }