Exemplo n.º 1
0
        public bool SentSuccess(string empId, SentType sentType)
        {
            bool result = false;

            try
            {
                using (var connection = new MySqlConnection(connString))
                {
                    var item  = connection.Query <StudentSentMessage>(MySqlDbQuery.SentSuccess(), new { emp_id = empId }).ToList();
                    var model = new StudentSentMessage();

                    if (sentType == SentType.Entry)
                    {
                        var entryStartTime = GlobalConfig.AppSettings("entryStartTime").Split(':');
                        var entryEndTime   = GlobalConfig.AppSettings("entryEndTime").Split(':');

                        var timeStart = new TimeSpan(int.Parse(entryStartTime[0]), int.Parse(entryStartTime[1]), int.Parse(entryStartTime[2]));
                        var timeEnd   = new TimeSpan(int.Parse(entryEndTime[0]), int.Parse(entryEndTime[1]), int.Parse(entryEndTime[2]));

                        model = item.GetStudentSentMessage(timeStart, timeEnd).FirstOrDefault();
                    }
                    else if (sentType == SentType.Exit)
                    {
                        var exitStartTime = GlobalConfig.AppSettings("exitStartTime").Split(':');
                        var exitEndTime   = GlobalConfig.AppSettings("exitEndTime").Split(':');

                        var timeStart = new TimeSpan(int.Parse(exitStartTime[0]), int.Parse(exitStartTime[1]), int.Parse(exitStartTime[2]));
                        var timeEnd   = new TimeSpan(int.Parse(exitEndTime[0]), int.Parse(exitEndTime[1]), int.Parse(exitEndTime[2]));

                        model = item.GetStudentSentMessage(timeStart, timeEnd).FirstOrDefault();
                    }
                    if (model != null)
                    {
                        result = true;
                    }
                }
            }
            catch (Exception ex)
            {
                SaveExceptionLog(ex);
                result = false;
            }

            return(result);
        }