コード例 #1
0
        private static void InsertWorkingTimes(int i)
        {
            var whContext    = new HR1Entities();
            var verpsContext = new VERPSEntities();

            var doorTimes = from b in whContext.vwWorkingTimes
                            where b.RecYear == 2016 && b.RecMonth == 11 && b.RecDay == i
                            select b;


            var empTimes = from b in verpsContext.hrWorkingHours
                           where b.RecYear.Equals(2016) && b.RecMonth.Equals(11) && b.RecDay.Equals(i)
                           select b;


            foreach (var doorTime in doorTimes)
            {
                foreach (var empTime in empTimes)
                {
                    if (doorTime.CardID == empTime.AccessCardID && doorTime.RecYear == empTime.RecYear && doorTime.RecMonth == empTime.RecMonth && doorTime.RecDay == empTime.RecDay)
                    {
                        empTime.EntryTime    = doorTime.EntryTime;
                        empTime.ExitTime     = doorTime.ExitTime;
                        empTime.TotalHours   = doorTime.WorkingHours;
                        empTime.TotalMinutes = doorTime.WorkingMinutes;
                        empTime.Modified     = DateTimeOffset.Now;
                        //empTime.DayOfWeek = "Sunday";
                    }
                }
            }



            verpsContext.SaveChanges();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var whContext1    = new HR1Entities();
            var verpsContext1 = new VERPSEntities();



            DataAccess.DataTable dt = DataAccess.DataTable.New.ReadCsv(@"C:\Users\mehme\Documents\doors.csv");

            DataSet ds = new DataSet();

            System.Data.DataTable dt2 = new System.Data.DataTable();


            foreach (Row row in dt.Rows)
            {
                if (row["Card ID"].ToString().Trim() != "DA45A9BF000000" && 1 == 2)
                {
                    DoorsRawData drd = new DoorsRawData();

                    drd.Eventdatetime        = DateTime.Parse(row["Event date/time"]);
                    drd.EventdatetimeUTC     = DateTime.Parse(row["Event date/time UTC"]);
                    drd.OperationID          = Int16.Parse(row["Operation ID"]);
                    drd.Isexit               = Int16.Parse(row["Is exit"]);
                    drd.Operationdescription = row["Operation description"];
                    drd.Usertype             = Int16.Parse(row["User type"]);
                    drd.Username             = row["User name"];
                    drd.UserExtID            = row["User ExtID"];
                    drd.UserGPF1             = row["User GPF1"];
                    drd.UserGPF2             = row["User GPF2"];
                    drd.UserGPF3             = row["User GPF3"];
                    drd.UserGPF4             = row["User GPF4"];
                    drd.UserGPF5             = row["User GPF5"];
                    drd.Cardserialnumber     = row["Card serial number"];
                    drd.CardID               = row["Card ID"];
                    drd.Doorname             = row["Door name"];
                    drd.DoorExtID            = row["Door ExtID"];
                    drd.DoorGPF1             = row["Door GPF1"];
                    drd.DoorGPF2             = row["Door GPF2"];

                    //whContext.DoorsRawDatas.Add(drd);
                }
            }

            //whContext.SaveChanges();

            for (int i = 1; i < 32; i++)
            {
                InsertWorkingTimes(i);
            }



            var           reader = new StreamReader(File.OpenRead(@"C:\Users\mehme\Documents\doors.csv"));
            List <string> listA  = new List <string>();
            List <string> listB  = new List <string>();

            while (!reader.EndOfStream)
            {
                var line   = reader.ReadLine();
                var values = line.Split('"');

                listA.Add(values[0]);
                listB.Add(values[1]);
            }
        }