Example #1
0
        public void InsertAttendance(SqlDataReader sqlData, AttendanceDTO dto, StreamPlayerControl streamPlayerControl)
        {
            var today = DateTime.Now;

            SqlDataReader sqlData2 = new AttendanceQuery().SelectWithIdnumberAndToday(dto.ATTENDANCE_IDNUMBER, today.ToString("yyyy-MM-dd"));

            // 오늘 이미 출근 기록이 있을 경우
            if (sqlData2.HasRows)
            {
                SharedPreference.Instance.DBM.SqlConn.Close();
                MessageBox.Show("오늘은 이미 출근 처리가 되어있습니다.");
            }
            else
            {
                try
                {
                    if (streamPlayerControl.IsPlaying)
                    {
                        var picture = streamPlayerControl.GetCurrentFrame();
                        var image   = new BitmapToBitmapImageConverter().Convert(picture, null, null, null);
                        var popup   = new CapturePopup();
                        //(popup.DataContext as CapturePopupViewModel).Message = "정상적으로 출근처리 되었습니다.\n즐거운 하루 되세요!";
                        //(popup.DataContext as CapturePopupViewModel).Image = image as BitmapImage;
                        if (WindowHelper.CreatePopup(popup, "출근", true) == true)
                        {
                            try
                            {
                                sqlData2.Close();
                                SharedPreference.Instance.DBM.SqlConn.Close();
                                new AttendanceQuery().Insert(dto);

                                TodayAttendanceList.Insert(0, new AttendanceModel(dto));

                                Defines.STAFF_PATH = Defines.CAPTURE_PATH + @"\Staff\" + SharedPreference.Instance.SelectedStaff.STAFF_NameAndIdnumber + @"\";
                                if (!Directory.Exists(Defines.STAFF_PATH))
                                {
                                    Directory.CreateDirectory(Defines.STAFF_PATH);
                                }
                                picture.Save(Defines.STAFF_PATH + today.ToString("yyyyMMdd") + "_Attendance_" + dto.ATTENDANCE_IDNUMBER + ".bmp");

                                try
                                {
                                    AttendanceLogDTO logDto = new AttendanceLogDTO()
                                    {
                                        ATTENDANCE_LOG_ADMIN       = "출근",
                                        ATTENDANCE_LOG_IDNUMBER    = SharedPreference.Instance.SelectedStaff.STAFF_IDNUMBER,
                                        ATTENDANCE_LOG_BUSINESSDAY = DateTime.Now.ToString("yyyy-MM-dd"),
                                        ATTENDANCE_LOG_WHAT        = "출근",
                                        ATTENDANCE_LOG_LOG         = "출근 시간: " + DateTime.Now.ToString("HH:mm:ss"),
                                        ATTENDANCE_LOG_REASON      = "당일 출근 기록",
                                        ATTENDANCE_LOG_UPDATE_DATE = DateTime.Now.ToString("yyyy-MM-dd")
                                    };

                                    new AttendanceLogQuery().Insert(logDto);
                                }
                                catch (Exception e)
                                {
                                    SharedPreference.Instance.DBM.SqlConn.Close();
                                    MessageBox.Show("기록을 남기는데 실패하셨습니다. 관리자에게 문의하세요.\n에러내용 : " + e.Message);
                                }
                            }
                            catch (Exception e)
                            {
                                sqlData2.Close();
                                SharedPreference.Instance.DBM.SqlConn.Close();
                                MessageBox.Show("출근 실패하셨습니다. 관리자에게 문의하세요.\n에러내용 : " + e.Message);
                            }
                        }
                    }
                    else
                    {
                        sqlData2.Close();
                        SharedPreference.Instance.DBM.SqlConn.Close();
                        MessageBox.Show("캠이 정상 작동중이지 않습니다. 관리자에게 문의하세요.");
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("출근 실패하셨습니다. 관리자에게 문의하세요.\n에러내용 : " + e.Message);
                }
            }
        }
Example #2
0
        public void InsertAttendance(AttendanceDTO dto)
        {
            var today = DateTime.Now;

            SqlDataReader sqlData2 = new AttendanceQuery().SelectWithIdnumberAndToday(dto.ATTENDANCE_IDNUMBER, today.ToString("yyyy-MM-dd"));

            // 오늘 이미 출근 기록이 있을 경우
            if (sqlData2.HasRows)
            {
                SharedPreference.Instance.DBM.SqlConn.Close();
                MessageBox.Show("오늘은 이미 출근 처리가 되어있습니다.");
            }
            else
            {
                try
                {
                    Defines.STAFF_PATH = Defines.CAPTURE_PATH + @"\Staff\" + SharedPreference.Instance.SelectedStaff.STAFF_NameAndIdnumber + @"\";
                    if (!Directory.Exists(Defines.STAFF_PATH))
                    {
                        Directory.CreateDirectory(Defines.STAFF_PATH);
                    }

                    CaptureScreen(Defines.STAFF_PATH + today.ToString("yyyyMMddHHmmss") + "_Attendance_" + dto.ATTENDANCE_IDNUMBER + ".png");

                    var popup = new object();
                    var time  = new TimeSpan(8, 30, 00);

                    if (DateTime.Now.DayOfWeek.ToString() == "Monday")
                    {
                        time = new TimeSpan(8, 00, 00);
                    }

                    sqlData2.Close();
                    SharedPreference.Instance.DBM.SqlConn.Close();

                    if (DateTime.Now.TimeOfDay > time)
                    {
                        popup = new LatePopup();
                        if (WindowHelper.CreatePopup(popup as LatePopup, "지각", true) == true)
                        {
                            Attendance(dto);
                        }
                    }
                    else
                    {
                        popup = new AttendancePopup();
                        if (WindowHelper.CreatePopup(popup as AttendancePopup, "출근", true) == true)
                        {
                            Attendance(dto);
                        }
                    }
                    //(popup.DataContext as CapturePopupViewModel).Message = "정상적으로 출근처리 되었습니다.\n즐거운 하루 되세요!";
                    ////(popup.DataContext as CapturePopupViewModel).Image = bitmap as BitmapImage;
                    //(popup.DataContext as CapturePopupViewModel).Image = image as BitmapImage;
                }
                catch (Exception e)
                {
                    sqlData2.Close();
                    SharedPreference.Instance.DBM.SqlConn.Close();
                    MessageBox.Show("출근 실패하셨습니다. 관리자에게 문의하세요.\n에러내용 : " + e.Message);
                }
            }
        }