public void NUnit_TAMScanLog_Domain_GetById()
        {
            string status = string.Empty;
            Att_TAMScanLogServices service = new Att_TAMScanLogServices();
            var model = new Att_TAMScanLog { Id = 1 };
            var result = service.GetById<Att_TAMScanLogEntity>(model.Id, ref status);
            NUnit.Framework.Assert.IsNotNull(result);
            Console.Write("SearchResult: " + result.Id
                + " | " + result.CardCode

                );
        }
 public void NUnit_TAMScanLog_Domain_Edit()
 {
     Att_TAMScanLogServices service = new Att_TAMScanLogServices();
     var model = new Att_TAMScanLog
     {
         Id = 1
     };
     string result = service.Edit(model);
     if (result != string.Empty)
     {
         Console.WriteLine("Process Success >>> Update >>> " + model.Id
                 + " | " + model.CardCode
                 );
     }
 }
Esempio n. 3
0
        public void NUnit_TAMScanLog_Domain_Remove()
        {
            Att_TAMScanLogServices service = new Att_TAMScanLogServices();
            int rs    = 0;
            var model = new Att_TAMScanLog {
                Id = 1
            };
            string result = service.Remove <Att_TAMScanLogEntity>(model.Id);

            if (result != string.Empty)
            {
                rs += 1;
                Console.WriteLine("Process Success >>> Remove >>> " + model.Id);
            }
        }
Esempio n. 4
0
        public void NUnit_TAMScanLog_Domain_GetById()
        {
            string status = string.Empty;
            Att_TAMScanLogServices service = new Att_TAMScanLogServices();
            var model = new Att_TAMScanLog {
                Id = 1
            };
            var result = service.GetById <Att_TAMScanLogEntity>(model.Id, ref status);

            NUnit.Framework.Assert.IsNotNull(result);
            Console.Write("SearchResult: " + result.Id
                          + " | " + result.CardCode

                          );
        }
Esempio n. 5
0
        public void NUnit_TAMScanLog_Domain_Edit()
        {
            Att_TAMScanLogServices service = new Att_TAMScanLogServices();
            var model = new Att_TAMScanLog
            {
                Id = 1
            };
            string result = service.Edit(model);

            if (result != string.Empty)
            {
                Console.WriteLine("Process Success >>> Update >>> " + model.Id
                                  + " | " + model.CardCode
                                  );
            }
        }
 public void NUnit_TAMScanLog_Domain_Add()
 {
     Att_TAMScanLogServices service = new Att_TAMScanLogServices();
     string result = string.Empty;
     int countSC = 0;
     for (int i = 1; i <= 10; i++)
     {
         var model = new Att_TAMScanLog
         {
             Comment = "Comment : " + 1
         };
         result = service.Add(model);
         if (result != string.Empty)
         {
             countSC += 1;
             Console.WriteLine("Process Success >>> Create >>> " + model.Id
                 );
         }
     }
     Console.WriteLine("Total success record: " + countSC);
 }
Esempio n. 7
0
        public void NUnit_TAMScanLog_Domain_Add()
        {
            Att_TAMScanLogServices service = new Att_TAMScanLogServices();
            string result  = string.Empty;
            int    countSC = 0;

            for (int i = 1; i <= 10; i++)
            {
                var model = new Att_TAMScanLog
                {
                    Comment = "Comment : " + 1
                };
                result = service.Add(model);
                if (result != string.Empty)
                {
                    countSC += 1;
                    Console.WriteLine("Process Success >>> Create >>> " + model.Id
                                      );
                }
            }
            Console.WriteLine("Total success record: " + countSC);
        }
Esempio n. 8
0
        private Att_TAMScanLog ConvertToRecord(Att_TAMScanLog tam, List <Hre_ProfileEntity> listProfile,
                                               List <Hre_CardHistoryEntity> listCardHistory, DateTime from, DateTime to)
        {
            if (tam.CardCode == null && tam.CodeEmp == null)
            {
                return(null);
            }

            string CardCode = tam.CardCode.GetString().Trim();
            string CodeEmp  = tam.CodeEmp.GetString().Trim();

            if (!string.IsNullOrWhiteSpace(CodeEmp))
            {
                var profile = listProfile.Where(d => d.CodeEmp == CodeEmp).FirstOrDefault();

                if (profile != null)
                {
                    tam.ProfileID = profile.ID;
                    return(tam);
                }
            }
            else
            {
                DateTime dateMin = DateTime.MinValue;
                Boolean  check   = false;

                foreach (var profile in listProfile)
                {
                    if (!string.IsNullOrWhiteSpace(CardCode))
                    {
                        var lstCardHistoryByProfile = GetCardCodeByProfile(listCardHistory, profile, from, to);
                        lstCardHistoryByProfile = lstCardHistoryByProfile.OrderBy(card => card.DateEffect).ToList();

                        foreach (var item in lstCardHistoryByProfile)
                        {
                            //ma cham cong History truoc do cua nhan vien khac. Quet the chi lay toi ngay hieu luc cua nhan vien do thoi
                            var cardHistoryByCard = listCardHistory.Where(card => card.DateEffect > item.DateEffect && card.CardCode != null &&
                                                                          card.CardCode.ToString().Trim() == item.CardCode).OrderBy(card => card.DateEffect).FirstOrDefault();

                            //Kiem tra khong duoc lay qua ngay hieu luc cua nhan vien khac cung su dung ma the do.
                            if (item.DateEffect.HasValue && item.DateEffect >= dateMin && item.DateEffect <= tam.TimeLog &&
                                CardCode == item.CardCode.ToString().Trim() && (cardHistoryByCard == null ||
                                                                                tam.TimeLog < cardHistoryByCard.DateEffect))
                            {
                                dateMin       = item.DateEffect.Value;
                                tam.ProfileID = profile.ID;
                                check         = true;
                                break;
                            }
                        }
                    }

                    if (check)
                    {
                        break;
                    }
                }

                if (check)
                {
                    return(tam);
                }
            }

            return(null);
        }
Esempio n. 9
0
        public List <Att_TAMScanLog> SaveTAMLog(DataTable table, DateTime dateFrom,
                                                DateTime dateTo, Guid userID, List <Guid> listProfileID, bool filterByCodeEmp)
        {
            using (var context = new VnrHrmDataContext())
            {
                IUnitOfWork unitOfWork = new UnitOfWork(context);

                if (table.Columns.Count == 2)
                {
                    table.Columns.Add();
                    table.Columns.Add();
                }
                else if (table.Columns.Count == 3)
                {
                    table.Columns.Add();
                }

                DataRow[] rows = new DataRow[table.Rows.Count];
                table.Rows.CopyTo(rows, 0);

                string waitStatus = ProfileStatusSyn.E_WAITING.ToString();
                List <Att_TAMScanLog> listTAMScanLog = new List <Att_TAMScanLog>();

                var profileQueryable = unitOfWork.CreateQueryable <Hre_Profile>(userID, pro => (pro.StatusSyn == null ||
                                                                                                pro.StatusSyn != waitStatus) && (pro.DateQuit == null || pro.DateQuit.Value > dateFrom));

                var cardHistoryQueryable = unitOfWork.CreateQueryable <Hre_CardHistory>(userID);

                if (listProfileID != null && listProfileID.Count() > 0)
                {
                    profileQueryable     = profileQueryable.Where(pro => listProfileID.Contains(pro.ID));
                    cardHistoryQueryable = cardHistoryQueryable.Where(pro => pro.ProfileID.HasValue && listProfileID.Contains(pro.ProfileID.Value));
                }
                else
                {
                    cardHistoryQueryable = cardHistoryQueryable.Where(cr => cr.Hre_Profile != null &&
                                                                      (!cr.Hre_Profile.IsDelete.HasValue || cr.Hre_Profile.IsDelete == false));
                }

                var listAllProfile = profileQueryable.Select(d =>
                                                             new Hre_ProfileEntity
                {
                    ID      = d.ID,
                    CodeEmp = d.CodeEmp
                }).ToList <Hre_ProfileEntity>();

                var listAllCardHistory = cardHistoryQueryable.Select(d =>
                                                                     new Hre_CardHistoryEntity
                {
                    ID         = d.ID,
                    ProfileID  = d.ProfileID,
                    CardCode   = d.CardCode,
                    DateEffect = d.DateEffect
                }).ToList <Hre_CardHistoryEntity>();

                for (int i = 0; i < rows.Length; i++)
                {
                    DataRow row      = rows[i];
                    string  cardCode = row[0].ToString();
                    cardCode = cardCode.ToUpper().Trim();

                    Att_TAMScanLog tam = new Att_TAMScanLog();

                    if (filterByCodeEmp)
                    {
                        tam.CodeEmp = cardCode;
                        tam.Comment = "Hệ thống cũ";
                    }
                    else
                    {
                        tam.CardCode = cardCode;
                    }

                    tam.TimeLog   = Convert.ToDateTime(row[1].ToString().Trim());
                    tam.Type      = row[2].ToString().Trim();
                    tam.MachineNo = row[3].ToString().Trim();
                    tam.Status    = TAMScanStatus.E_LOADED.ToString();
                    List <Hre_ProfileEntity> listProfileByCode = null;

                    if (!string.IsNullOrWhiteSpace(tam.CardCode))
                    {
                        var listCardHistoryByCode = listAllCardHistory.Where(ch => ch.CardCode != null &&
                                                                             ch.CardCode.ToString().ToUpper().Trim() == cardCode).ToList();

                        if (listCardHistoryByCode.Count() <= 0)
                        {
                            listProfileByCode = listAllProfile.Where(d => d.CodeAttendance != null &&
                                                                     d.CodeAttendance.ToString().ToUpper().Trim() == cardCode).ToList();
                        }
                        else
                        {
                            var listProfileIDByCode = listCardHistoryByCode.Select(d => d.ProfileID).ToList();
                            listProfileByCode = listAllProfile.Where(d => listProfileIDByCode.Contains(d.ID)).ToList();
                        }
                    }
                    else if (!string.IsNullOrWhiteSpace(tam.CodeEmp))
                    {
                        listProfileByCode = listAllProfile.Where(d => d.CodeEmp != null &&
                                                                 d.CodeEmp.ToString().ToUpper().Trim() == cardCode).ToList();
                    }

                    if (listProfileByCode != null && listProfileByCode.Count > 0)
                    {
                        var dateStart = tam.TimeLog.HasValue ? tam.TimeLog.Value.Date : dateFrom;
                        var dateEnd   = tam.TimeLog.HasValue ? tam.TimeLog.Value.Date.AddDays(1) : dateTo;
                        var rec       = ConvertToRecord(tam, listProfileByCode, listAllCardHistory, dateStart, dateEnd);

                        if (rec != null)
                        {
                            listTAMScanLog.Add(rec);
                        }
                    }
                }

                DeleteTAMLog(unitOfWork, dateFrom, dateTo, listTAMScanLog, userID);
                unitOfWork.AddObject(listTAMScanLog.ToArray());
                unitOfWork.SaveChanges(userID);
                return(listTAMScanLog);
            }
        }
Esempio n. 10
0
 public void NUnit_WorkDay_Domain_SummaryInOut()
 {
     #region listShift
     using (var contextCategory = new VnrHrmDataContext())
     {
         List <Cat_Shift> listShift = new List <Cat_Shift>();
         Cat_Shift        _shift    = new Cat_Shift()
         {
             Id         = 1,
             ShiftName  = "Ca Test",
             InTime     = DateTime.Parse("01-09-14 08:00:00"),
             CoOut      = 9,
             CoBreakIn  = 4,
             CoBreakOut = 5,
         };
         listShift.Add(_shift);
         contextCategory.Cat_Shift.Add(_shift);
         contextCategory.SaveChanges();
     }
     #endregion
     #region listRoster
     using (var contextAtt = new VnrHrmDataContext())
     {
         List <Att_Roster> listRoster = new List <Att_Roster>();
         Att_Roster        _roster    = new Att_Roster()
         {
             ProfileID       = 1,
             RosterGroupName = "Nhom 1",
             Type            = "E_DEFAULT",
             Status          = "",
             DateEnd         = DateTime.Parse("01-03-2014"),
             DateStart       = DateTime.Parse("01-02-2014"),
             MonShiftID      = 1,
             TueShiftID      = 1,
             WedShiftID      = 1,
             ThuShiftID      = 1,
             FriShiftID      = 1,
             SatShiftID      = 1,
             SunShiftID      = 1
         };
         listRoster.Add(_roster);
         contextAtt.Att_Roster.Add(_roster);
         contextAtt.SaveChanges();
         #endregion
         #region listTamScanLog
         List <Att_TAMScanLog> listTamScanLog = new List <Att_TAMScanLog>();
         Att_TAMScanLog        _tamScanLog1   = new Att_TAMScanLog()
         {
             CardCode = "123",
             TimeLog  = DateTime.Parse("01-02-2014 08:00:00"),
             SrcType  = "E_IN",
             Type     = ""
         };
         Att_TAMScanLog _tamScanLog2 = new Att_TAMScanLog()
         {
             CardCode = "123",
             TimeLog  = DateTime.Parse("01-02-2014 17:00:00"),
             SrcType  = "E_OUT",
             Type     = ""
         };
         Att_TAMScanLog _tamScanLog3 = new Att_TAMScanLog()
         {
             CardCode = "123",
             TimeLog  = DateTime.Parse("02-02-2014 08:00:00"),
             SrcType  = "E_IN",
             Type     = ""
         };
         Att_TAMScanLog _tamScanLog4 = new Att_TAMScanLog()
         {
             CardCode = "123",
             TimeLog  = DateTime.Parse("02-02-2014 17:00:00"),
             SrcType  = "E_OUT",
             Type     = ""
         };
         listTamScanLog.Add(_tamScanLog1);
         listTamScanLog.Add(_tamScanLog2);
         listTamScanLog.Add(_tamScanLog3);
         listTamScanLog.Add(_tamScanLog4);
         contextAtt.Att_TAMScanLog.Add(_tamScanLog1);
         contextAtt.Att_TAMScanLog.Add(_tamScanLog2);
         contextAtt.Att_TAMScanLog.Add(_tamScanLog3);
         contextAtt.Att_TAMScanLog.Add(_tamScanLog4);
         contextAtt.SaveChanges();
     }
     #endregion
     # region CardHistory
     using (var contextHr = new VnrHrmDataContext())
 public void NUnit_TAMScanLog_Domain_Remove()
 {
     Att_TAMScanLogServices service = new Att_TAMScanLogServices();
     int rs = 0;
     var model = new Att_TAMScanLog { Id = 1 };
     string result = service.Remove<Att_TAMScanLogEntity>(model.Id);
     if (result != string.Empty)
     {
         rs += 1;
         Console.WriteLine("Process Success >>> Remove >>> " + model.Id);
     }
 }
Esempio n. 12
0
        public void NUnit_WorkDay_Domain_SummaryInOut()
        {
            #region listShift
            using (var contextCategory = new VnrHrmDataContext())
            {
                List<Cat_Shift> listShift = new List<Cat_Shift>();
                Cat_Shift _shift = new Cat_Shift()
                {
                    Id = 1,
                    ShiftName = "Ca Test",
                    InTime = DateTime.Parse("01-09-14 08:00:00"),
                    CoOut = 9,
                    CoBreakIn = 4,
                    CoBreakOut = 5,
                };
                listShift.Add(_shift);
                contextCategory.Cat_Shift.Add(_shift);
                contextCategory.SaveChanges();
            }
            #endregion
            #region listRoster
            using (var contextAtt = new VnrHrmDataContext())
            {
                List<Att_Roster> listRoster = new List<Att_Roster>();
                Att_Roster _roster = new Att_Roster()
                {
                    ProfileID = 1,
                    RosterGroupName = "Nhom 1",
                    Type = "E_DEFAULT",
                    Status = "",
                    DateEnd = DateTime.Parse("01-03-2014"),
                    DateStart = DateTime.Parse("01-02-2014"),
                    MonShiftID = 1,
                    TueShiftID = 1,
                    WedShiftID = 1,
                    ThuShiftID = 1,
                    FriShiftID = 1,
                    SatShiftID = 1,
                    SunShiftID = 1
                };
                listRoster.Add(_roster);
                contextAtt.Att_Roster.Add(_roster);
                contextAtt.SaveChanges();
                #endregion
                #region listTamScanLog
                List<Att_TAMScanLog> listTamScanLog = new List<Att_TAMScanLog>();
                Att_TAMScanLog _tamScanLog1 = new Att_TAMScanLog()
                {
                    CardCode = "123",
                    TimeLog = DateTime.Parse("01-02-2014 08:00:00"),
                    SrcType = "E_IN",
                    Type = ""
                };
                Att_TAMScanLog _tamScanLog2 = new Att_TAMScanLog()
                {
                    CardCode = "123",
                    TimeLog = DateTime.Parse("01-02-2014 17:00:00"),
                    SrcType = "E_OUT",
                    Type = ""
                };
                Att_TAMScanLog _tamScanLog3 = new Att_TAMScanLog()
                {
                    CardCode = "123",
                    TimeLog = DateTime.Parse("02-02-2014 08:00:00"),
                    SrcType = "E_IN",
                    Type = ""
                };
                Att_TAMScanLog _tamScanLog4 = new Att_TAMScanLog()
                {
                    CardCode = "123",
                    TimeLog = DateTime.Parse("02-02-2014 17:00:00"),
                    SrcType = "E_OUT",
                    Type = ""
                };
                listTamScanLog.Add(_tamScanLog1);
                listTamScanLog.Add(_tamScanLog2);
                listTamScanLog.Add(_tamScanLog3);
                listTamScanLog.Add(_tamScanLog4);
                contextAtt.Att_TAMScanLog.Add(_tamScanLog1);
                contextAtt.Att_TAMScanLog.Add(_tamScanLog2);
                contextAtt.Att_TAMScanLog.Add(_tamScanLog3);
                contextAtt.Att_TAMScanLog.Add(_tamScanLog4);
                contextAtt.SaveChanges();
            }
            #endregion
            # region CardHistory
            using (var contextHr = new VnrHrmDataContext())
            {
                List<Hre_CardHistory> listcardhistory = new List<Hre_CardHistory>();
                Hre_CardHistory cardhistory = new Hre_CardHistory()
                {
                    ProfileID = 1,
                    CardCode = "123",
                    DateEffect = DateTime.Parse("01-01-2014")
                };
                listcardhistory.Add(cardhistory);
                contextHr.Hre_CardHistory.Add(cardhistory);
                contextHr.SaveChanges();
            }
            #endregion
            DateTime dateFrom = DateTime.Parse("01-02-2014");
            DateTime dateTo = DateTime.Parse("01-03-2014");

            List<int> listSelectedProfileID = new List<int>(){1,2};

            Att_WorkDayServices service = new Att_WorkDayServices();
            //List<Att_WorkDayEntity> ListInOut = service.SummaryInOut(dateFrom, dateTo, listSelectedProfileID);
        }