Exemple #1
0
        public void ProcessManualEditAttendance(DateTime _dateStart, DateTime _dateEnd)
        {
            List <AttDataManEdit> _attEdit = new List <AttDataManEdit>();
            List <AttData>        _AttData = new List <AttData>();
            AttData _TempAttData           = new AttData();

            using (var ctx = new TAS2013Entities())
            {
                if (_dateStart == _dateEnd)
                {
                    _attEdit = ctx.AttDataManEdits.Where(aa => aa.NewTimeIn == _dateStart).OrderBy(aa => aa.EditDateTime).ToList();
                    _dateEnd = _dateEnd + new TimeSpan(23, 59, 59);
                    //_attEdit = ctx.AttDataManEdits.Where(aa => aa.NewTimeIn >= _dateStart && aa.NewTimeIn <= _dateEnd && (aa.EmpID == 472)).OrderBy(aa => aa.EditDateTime).ToList();
                    _AttData = ctx.AttDatas.Where(aa => aa.AttDate == _dateStart).ToList();
                }
                else
                {
                    _attEdit = ctx.AttDataManEdits.Where(aa => aa.NewTimeIn >= _dateStart && aa.NewTimeOut <= _dateEnd).OrderBy(aa => aa.EditDateTime).ToList();
                    //_attEdit = ctx.AttDataManEdits.Where(aa => aa.NewTimeIn >= _dateStart && (aa.NewTimeOut <= _dateEnd && aa.EmpID == 472)).OrderBy(aa => aa.EditDateTime).ToList();
                    _AttData = ctx.AttDatas.Where(aa => aa.AttDate >= _dateStart && aa.AttDate <= _dateEnd).ToList();
                }


                foreach (var item in _attEdit)
                {
                    _TempAttData          = _AttData.First(aa => aa.EmpDate == item.EmpDate);
                    _TempAttData.TimeIn   = item.NewTimeIn;
                    _TempAttData.TimeOut  = item.NewTimeOut;
                    _TempAttData.DutyCode = item.NewDutyCode;
                    _TempAttData.DutyTime = item.NewDutyTime;
                    switch (_TempAttData.DutyCode)
                    {
                    case "D":
                        _TempAttData.StatusAB    = true;
                        _TempAttData.StatusP     = false;
                        _TempAttData.StatusMN    = true;
                        _TempAttData.StatusDO    = false;
                        _TempAttData.StatusGZ    = false;
                        _TempAttData.StatusLeave = false;
                        _TempAttData.StatusOT    = false;
                        _TempAttData.OTMin       = null;
                        _TempAttData.EarlyIn     = null;
                        _TempAttData.EarlyOut    = null;
                        _TempAttData.LateIn      = null;
                        _TempAttData.LateOut     = null;
                        _TempAttData.WorkMin     = null;
                        _TempAttData.GZOTMin     = null;
                        break;

                    case "G":
                        _TempAttData.StatusAB    = false;
                        _TempAttData.StatusP     = false;
                        _TempAttData.StatusMN    = true;
                        _TempAttData.StatusDO    = false;
                        _TempAttData.StatusGZ    = true;
                        _TempAttData.StatusLeave = false;
                        _TempAttData.StatusOT    = false;
                        _TempAttData.OTMin       = null;
                        _TempAttData.EarlyIn     = null;
                        _TempAttData.EarlyOut    = null;
                        _TempAttData.LateIn      = null;
                        _TempAttData.LateOut     = null;
                        _TempAttData.WorkMin     = null;
                        _TempAttData.GZOTMin     = null;
                        break;

                    case "R":
                        _TempAttData.StatusAB    = false;
                        _TempAttData.StatusP     = false;
                        _TempAttData.StatusMN    = true;
                        _TempAttData.StatusDO    = true;
                        _TempAttData.StatusGZ    = false;
                        _TempAttData.StatusLeave = false;
                        _TempAttData.StatusOT    = false;
                        _TempAttData.OTMin       = null;
                        _TempAttData.EarlyIn     = null;
                        _TempAttData.EarlyOut    = null;
                        _TempAttData.LateIn      = null;
                        _TempAttData.LateOut     = null;
                        _TempAttData.WorkMin     = null;
                        _TempAttData.GZOTMin     = null;
                        break;
                    }
                    if (_TempAttData.TimeIn != null && _TempAttData.TimeOut != null)
                    {
                        //If TimeIn = TimeOut then calculate according to DutyCode
                        if (_TempAttData.TimeIn == _TempAttData.TimeOut)
                        {
                            CalculateInEqualToOut(_TempAttData);
                        }
                        else
                        {
                            if (_TempAttData.DutyTime == new TimeSpan(0, 0, 0))
                            {
                                CalculateOpenShiftTimes(_TempAttData, _TempAttData.Emp.Shift);
                            }
                            else
                            {
                                //if (attendanceRecord.TimeIn.Value.Date.Day == attendanceRecord.TimeOut.Value.Date.Day)
                                //{
                                CalculateShiftTimes(_TempAttData, _TempAttData.Emp.Shift);
                                //}
                                //else
                                //{
                                //    CalculateOpenShiftTimes(attendanceRecord, shift);
                                //}
                            }
                        }

                        //If TimeIn = TimeOut then calculate according to DutyCode
                    }
                    ctx.SaveChanges();
                }
                ctx.Dispose();
            }
            _myHelperClass.WriteToLogFile("ProcessManual Attendance Completed: ");
        }
        public void CopyingPolls()
        {
            int totalcount        = 0;
            int convertedCount    = 0;
            int notConvertedCount = 0;
            List <OldDatabase.OldModel.PollData> _OldPolls = new List <OldDatabase.OldModel.PollData>();
            DateTime _dt  = new DateTime();
            DateTime _st1 = new DateTime();

            _dt  = GlobalSettings._dateTime;
            _st1 = GlobalSettings._dateTime.AddDays(1);
            oldDB.CommandTimeout = 0;
            //_OldPolls = oldDB.PollDatas.Where(aa => aa.EntryDate >= _dt && aa.EmpNo == "000180" ).ToList();
            /////////Second Time and Ownwards
            _OldPolls = oldDB.PollDatas.Where(p => p.Version == -1 && p.EntryDate >= _dt.Date).ToList();
            /////////First Time
            //_OldPolls = oldDB.PollDatas.Where(aa => aa.EntryDate >= _dt && aa.EntryDate <= _st1).ToList();
            totalcount = _OldPolls.Count;
            MyCustomFunctions _myHelperClass = new MyCustomFunctions();

            foreach (var pollsToBeConverted in _OldPolls)
            {
                try
                {
                    if (pollsToBeConverted.EmpNo != "<ERR>")
                    {
                        TASDownloadService.Model.PollData convertedPolls = new TASDownloadService.Model.PollData();
                        //convertedPolls.PollID = Convert.ToInt64(pollsToBeConverted.TranNo);
                        convertedPolls.CardNo  = pollsToBeConverted.CardNo;
                        convertedPolls.EmpID   = Convert.ToInt16(pollsToBeConverted.EmpNo);
                        convertedPolls.RdrDuty = Convert.ToByte(pollsToBeConverted.DutyCode);
                        convertedPolls.EntDate = pollsToBeConverted.EntryDate.Value;
                        convertedPolls.EntTime = pollsToBeConverted.EntryDate.Value + GlobalSettings.ConvertTime(pollsToBeConverted.EntryTime);
                        convertedPolls.RdrID   = (short)pollsToBeConverted.ReaderID;
                        convertedPolls.EmpDate = Convert.ToInt64(pollsToBeConverted.EmpDate).ToString();
                        convertedPolls.Process = false;
                        newDB.PollDatas.AddObject(convertedPolls);
                        if (newDB.SaveChanges() > 0)
                        {
                            convertedCount++;

                            pollsToBeConverted.Version = 1;
                            oldDB.SaveChanges();
                        }
                    }
                }
                catch (Exception ex)
                {
                    notConvertedCount++;
                    string _error = "";
                    if (ex.InnerException.Message != null)
                    {
                        _error = ex.InnerException.Message;
                    }
                    else
                    {
                        _error = ex.Message;
                    }
                    _myHelperClass.WriteToLogFile("Exception at CopyingPoll Function: Total/Converted " + totalcount.ToString() + "/" + convertedCount.ToString() + _error);
                }
            }
            _myHelperClass.WriteToLogFile("Copying Poll Completed: Total/Converted " + totalcount.ToString() + "/" + convertedCount.ToString());
        }
Exemple #3
0
        public bool processPermanentMonthlyAttSingle(DateTime startDate, DateTime endDate, Emp _Emp, List <AttData> _EmpAttData)
        {
            //Get Attendance data of employee according to selected month
            try
            {
                EmpAttData = _EmpAttData;
            }
            catch (Exception ex)
            {
                string _error = "";
                if (ex.InnerException.Message != null)
                {
                    _error = ex.InnerException.Message;
                }
                else
                {
                    _error = ex.Message;
                }
                _myHelperClass.WriteToLogFile("Exception at Contactual Monthly Process: " + _error);
                return(false);
            }
            string EmpMonth = _Emp.EmpID + endDate.Date.Month.ToString();

            //Check for already processed data
            if (context.AttMnDataPers.Where(aa => aa.EmpMonth == EmpMonth).Count() > 0)
            {
                AttMnDataPer _TempAttMn = context.AttMnDataPers.Where(aa => aa.EmpMonth == EmpMonth).FirstOrDefault();
                _attMonth                  = _TempAttMn;
                _attMonth.PreDays          = 0;
                _attMonth.WorkDays         = 0;
                _attMonth.AbDays           = 0;
                _attMonth.LeaveDays        = 0;
                _attMonth.OfficialDutyDays = 0;
                _attMonth.ExpectedWrkTime  = 0;
                _attMonth.GZDays           = 0;
                _attMonth.RestDays         = 0;
                _attMonth.TEarlyIn         = 0;
                _attMonth.TEarlyOut        = 0;
                _attMonth.TGZOT            = 0;
                _attMonth.TLateIn          = 0;
                _attMonth.TLateOut         = 0;
                _attMonth.TNOT             = 0;
                _attMonth.TotalDays        = 0;
                _attMonth.TWorkTime        = 0;
                _attMonth.OT1              = 0;
                _attMonth.OT2              = 0;
                _attMonth.OT3              = 0;
                _attMonth.OT4              = 0;
                _attMonth.OT5              = 0;
                _attMonth.OT6              = 0;
                _attMonth.OT7              = 0;
                _attMonth.OT8              = 0;
                _attMonth.OT9              = 0;
                _attMonth.OT10             = 0;
                _attMonth.OT11             = 0;
                _attMonth.OT12             = 0;
                _attMonth.OT13             = 0;
                _attMonth.OT14             = 0;
                _attMonth.OT15             = 0;
                _attMonth.OT16             = 0;
                _attMonth.OT17             = 0;
                _attMonth.OT18             = 0;
                _attMonth.OT19             = 0;
                _attMonth.OT20             = 0;
                _attMonth.OT21             = 0;
                _attMonth.OT22             = 0;
                _attMonth.OT23             = 0;
                _attMonth.OT24             = 0;
                _attMonth.OT25             = 0;
                _attMonth.OT26             = 0;
                _attMonth.OT27             = 0;
                _attMonth.OT28             = 0;
                _attMonth.OT29             = 0;
                _attMonth.OT30             = 0;
                _attMonth.OT31             = 0;
            }
            TDays       = 0;
            WorkDays    = 0;
            PresentDays = 0;
            AbsentDays  = 0;
            LeaveDays   = 0;
            RestDays    = 0;
            GZDays      = 0;
            EarlyIn     = 0;
            EarlyOut    = 0;
            LateIn      = 0;
            LateOut     = 0;
            WorkTime    = 0;
            NOT         = 0;
            GOT         = 0;
            TDays       = Convert.ToByte((endDate - startDate).Days + 1);
            CalculateMonthlyAttendanceSheet(EmpAttData);
            _attMonth.Period   = endDate.Date.Month.ToString() + endDate.Date.Year.ToString();
            _attMonth.EmpMonth = EmpMonth;
            _attMonth.EmpID    = _Emp.EmpID;
            _attMonth.EmpNo    = _Emp.EmpNo;
            _attMonth.EmpName  = _Emp.EmpName;
            try
            {
                if (context.AttMnDataPers.Where(aa => aa.EmpMonth == EmpMonth).Count() == 0)
                {
                    context.AttMnDataPers.AddObject(_attMonth);
                }
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                string _error = "";
                if (ex.InnerException.Message != null)
                {
                    _error = ex.InnerException.Message;
                }
                else
                {
                    _error = ex.Message;
                }
                _myHelperClass.WriteToLogFile("Exception at Contactual Monthly Process: " + _error);
                return(false);
            }
            return(true);
        }
Exemple #4
0
        public bool processContractualMonthlyAttSingle(DateTime startDate, DateTime endDate, Emp _Emp, List <AttData> _EmpAttData)
        {
            string EmpMonth = _Emp.EmpID + startDate.Date.Month.ToString();

            //Attendance data of employee for selected dates
            try
            {
                EmpAttData = _EmpAttData;
            }
            catch (Exception ex)
            {
                string _error = "";
                if (ex.InnerException.Message != null)
                {
                    _error = ex.InnerException.Message;
                }
                else
                {
                    _error = ex.Message;
                }
                _myHelperClass.WriteToLogFile("Exception at Contactual Monthly Process: " + _error);

                return(false);
            }
            //Check for already processed data
            if (context.AttMnDatas.Where(aa => aa.EmpMonth == EmpMonth).Count() > 0)
            {
                AttMnData _TempAttMn = context.AttMnDatas.Where(aa => aa.EmpMonth == EmpMonth).FirstOrDefault();
                _attMonth      = _TempAttMn;
                _attMonth.OT1  = 0;
                _attMonth.OT2  = 0;
                _attMonth.OT3  = 0;
                _attMonth.OT4  = 0;
                _attMonth.OT5  = 0;
                _attMonth.OT6  = 0;
                _attMonth.OT7  = 0;
                _attMonth.OT8  = 0;
                _attMonth.OT9  = 0;
                _attMonth.OT10 = 0;
                _attMonth.OT11 = 0;
                _attMonth.OT12 = 0;
                _attMonth.OT13 = 0;
                _attMonth.OT14 = 0;
                _attMonth.OT15 = 0;
                _attMonth.OT16 = 0;
                _attMonth.OT17 = 0;
                _attMonth.OT18 = 0;
                _attMonth.OT19 = 0;
                _attMonth.OT20 = 0;
                _attMonth.OT21 = 0;
                _attMonth.OT22 = 0;
                _attMonth.OT23 = 0;
                _attMonth.OT24 = 0;
                _attMonth.OT25 = 0;
                _attMonth.OT26 = 0;
                _attMonth.OT27 = 0;
                _attMonth.OT28 = 0;
                _attMonth.OT29 = 0;
                _attMonth.OT30 = 0;
                _attMonth.OT31 = 0;
                _attMonth.L1   = null;
                _attMonth.L2   = null;
                _attMonth.L3   = null;
                _attMonth.L4   = null;
                _attMonth.L5   = null;
                _attMonth.L6   = null;
                _attMonth.L7   = null;
                _attMonth.L8   = null;
                _attMonth.L9   = null;
                _attMonth.L10  = null;
                _attMonth.L11  = null;
                _attMonth.L12  = null;
                _attMonth.L13  = null;
                _attMonth.L14  = null;
                _attMonth.L15  = null;
                _attMonth.L16  = null;
                _attMonth.L17  = null;
                _attMonth.L18  = null;
                _attMonth.L19  = null;
                _attMonth.L20  = null;
                _attMonth.L21  = null;
                _attMonth.L22  = null;
                _attMonth.L23  = null;
                _attMonth.L24  = null;
                _attMonth.L25  = null;
                _attMonth.L26  = null;
                _attMonth.L27  = null;
                _attMonth.L28  = null;
                _attMonth.L29  = null;
                _attMonth.L30  = null;
                _attMonth.L31  = null;
            }

            TDays = Convert.ToByte((endDate - startDate).Days + 1);
            List <LvData> _lvData = context.LvDatas.Where(aa => aa.AttDate >= startDate && aa.AttDate <= endDate).ToList();

            CalculateMonthlyAttendanceSheet(EmpAttData, _lvData);
            _attMonth.Period   = startDate.Date.Month.ToString() + startDate.Date.Year.ToString();
            _attMonth.EmpMonth = _Emp.EmpID + startDate.Date.Month.ToString();
            _attMonth.EmpNo    = _Emp.EmpNo;
            _attMonth.EmpID    = _Emp.EmpID;
            _attMonth.EmpName  = _Emp.EmpName;
            try
            {
                if (context.AttMnDatas.Where(aa => aa.EmpMonth == EmpMonth).Count() == 0)
                {
                    context.AttMnDatas.AddObject(_attMonth);
                }
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                string _error = "";
                if (ex.InnerException.Message != null)
                {
                    _error = ex.InnerException.Message;
                }
                else
                {
                    _error = ex.Message;
                }
                _myHelperClass.WriteToLogFile("Exception at Contactual Monthly Process 2: " + _error);
                return(false);
            }
            return(true);
        }