Beispiel #1
0
        //[TestMethod]
        public void ExportData()
        {
            using (var context = new VnrHrmDataContext())
            {
                #region Cat_Export
                List <Cat_Export> listExport = new List <Cat_Export>();
                Cat_Export        _export    = new Cat_Export()
                {
                    Id               = 1,
                    ExportName       = "Test Export",
                    ExportCode       = "Test",
                    ScreenName       = "Test Screen",
                    ObjectName       = "Hre_Profile",
                    IsReadOnly       = true,
                    IsProtected      = true,
                    SheetIndex       = 1,
                    StartColumnIndex = 1,
                    StartRowIndex    = 2,
                    TemplateFile     = "Test Template File",
                    IsGroup          = true
                };
                listExport.Add(_export);
                #endregion

                #region Cat_ExportItem
                List <Cat_ExportItem> listExportItem     = new List <Cat_ExportItem>();
                Cat_ExportItem        _exportItemEntity1 = new Cat_ExportItem()
                {
                    ExportID   = 1,
                    DataField  = "ProfileName",
                    ExcelField = "B"
                };
                Cat_ExportItem _exportItemEntity2 = new Cat_ExportItem()
                {
                    ExportID   = 1,
                    DataField  = "CodeEmp",
                    ExcelField = "C"
                };
                Cat_ExportItem _exportItemEntity3 = new Cat_ExportItem()
                {
                    ExportID   = 1,
                    DataField  = "DateHire",
                    ExcelField = "D"
                };
                listExportItem.Add(_exportItemEntity1);
                listExportItem.Add(_exportItemEntity2);
                listExportItem.Add(_exportItemEntity3);
                #endregion

                context.Cat_ExportItem.Add(_exportItemEntity1);
                context.Cat_ExportItem.Add(_exportItemEntity2);
                context.Cat_ExportItem.Add(_exportItemEntity3);
                context.Cat_Export.Add(_export);
                context.SaveChanges();
            }

            string passwordwrite = "123";
            string passwordread  = "123";

            string filename     = "D:\\New Microsoft Excel Worksheet.xls";
            string templatePath = "D:\\Template";

            #region Datasource
            List <Hre_ProfileEntity> listdataProfile = new List <Hre_ProfileEntity>();
            Hre_ProfileEntity        _Profile1       = new Hre_ProfileEntity()
            {
                ProfileName = "Name1",
                CodeEmp     = "001",
                DateHire    = DateTime.Now
            };
            Hre_ProfileEntity _Profile2 = new Hre_ProfileEntity()
            {
                ProfileName = "Name2",
                CodeEmp     = "002",
                DateHire    = DateTime.Now
            };
            listdataProfile.Add(_Profile1);
            listdataProfile.Add(_Profile2);
            #endregion

            ExportService service = new ExportService();
            service.ExportByTemplate(1, filename, passwordwrite, passwordread, templatePath, null, listdataProfile);
            Process.Start(filename);
        }
        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);
        }
 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())
Beispiel #4
0
        //[TestMethod]
        public void ExportData()
        {
            using (var context = new VnrHrmDataContext())
            {
                #region Cat_Export
                List<Cat_Export> listExport = new List<Cat_Export>();
                Cat_Export _export = new Cat_Export()
                {
                    Id = 1,
                    ExportName = "Test Export",
                    ExportCode = "Test",
                    ScreenName = "Test Screen",
                    ObjectName = "Hre_Profile",
                    IsReadOnly = true,
                    IsProtected = true,
                    SheetIndex = 1,
                    StartColumnIndex = 1,
                    StartRowIndex = 2,
                    TemplateFile = "Test Template File",
                    IsGroup = true
                };
                listExport.Add(_export);
                #endregion

                #region Cat_ExportItem
                List<Cat_ExportItem> listExportItem = new List<Cat_ExportItem>();
                Cat_ExportItem _exportItemEntity1 = new Cat_ExportItem()
                {
                    ExportID = 1,
                    DataField = "ProfileName",
                    ExcelField = "B"
                };
                Cat_ExportItem _exportItemEntity2 = new Cat_ExportItem()
                {
                    ExportID = 1,
                    DataField = "CodeEmp",
                    ExcelField = "C"
                };
                Cat_ExportItem _exportItemEntity3 = new Cat_ExportItem()
                {
                    ExportID = 1,
                    DataField = "DateHire",
                    ExcelField = "D"
                };
                listExportItem.Add(_exportItemEntity1);
                listExportItem.Add(_exportItemEntity2);
                listExportItem.Add(_exportItemEntity3);
                #endregion

                context.Cat_ExportItem.Add(_exportItemEntity1);
                context.Cat_ExportItem.Add(_exportItemEntity2);
                context.Cat_ExportItem.Add(_exportItemEntity3);
                context.Cat_Export.Add(_export);
                context.SaveChanges();
            }

            string passwordwrite = "123";
            string passwordread = "123";

            string filename = "D:\\New Microsoft Excel Worksheet.xls";
            string templatePath = "D:\\Template";

            #region Datasource
            List<Hre_ProfileEntity> listdataProfile = new List<Hre_ProfileEntity>();
            Hre_ProfileEntity _Profile1 = new Hre_ProfileEntity()
            {
                ProfileName = "Name1",
                CodeEmp = "001",
                DateHire = DateTime.Now
            };
            Hre_ProfileEntity _Profile2 = new Hre_ProfileEntity()
            {
                ProfileName = "Name2",
                CodeEmp = "002",
                DateHire = DateTime.Now
            };
            listdataProfile.Add(_Profile1);
            listdataProfile.Add(_Profile2);
            #endregion

            ExportService service = new ExportService();
            service.ExportByTemplate(1, filename, passwordwrite, passwordread, templatePath, null, listdataProfile);
            Process.Start(filename);
        }