Exemplo n.º 1
0
        private static void UpdatePeople(int pId)
        {
            var    doorsDb = new DOORSEntities();
            var    verpsDb = new VERPSEntities();
            string vUser   = Properties.Settings.Default.vUser;
            string vPass   = Properties.Settings.Default.vPass;
            string vUri    = Properties.Settings.Default.vUri;

            System.Uri myUri = new Uri(vUri);
            VERPSServiceReference.ApplicationData vsr = new VERPSServiceReference.ApplicationData(myUri);
            vsr.Credentials = new NetworkCredential(vUser, vPass, "adm");

            try
            {
                var person = vsr.hrPeople.Where(p => p.Id == pId).SingleOrDefault();
                if (person != null)
                {
                    person.AccessCardID = DateTime.Now.ToString();
                    vsr.UpdateObject(person);
                    Console.WriteLine("OK");
                }
                else
                {
                    Console.WriteLine("YOK!");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("CART!");
            }

            vsr.SaveChanges();

            Console.WriteLine("DONE!");
        }
Exemplo n.º 2
0
        private static void CalcWorkingTimes(DateTime opDate)
        {
            var    doorsDb = new DOORSEntities();
            var    verpsDb = new VERPSEntities();
            string vUser   = Properties.Settings.Default.vUser;
            string vPass   = Properties.Settings.Default.vPass;
            string vUri    = Properties.Settings.Default.vUri;

            System.Uri myUri = new Uri(vUri);
            VERPSServiceReference.ApplicationData vsr = new VERPSServiceReference.ApplicationData(myUri);
            vsr.Credentials = new NetworkCredential(vUser, vPass, "adm");

            int i = 0;
            int j = 0;

            var doorTimes = from d in doorsDb.vwDoorTimes
                            where d.EventDay == opDate
                            select d;

            //////var empTimes = from b in verpsDb.hrWorkingHours
            //////               where b.WorkingDate.Equals(opDate)
            //////               select b;

            foreach (var doorT in doorTimes)
            {
                //////foreach (var empTime in empTimes)
                //////{
                //////    if (doorT.UserExtID == empTime.DoorSysID && doorT.EventDay == empTime.WorkingDate)
                //////    {
                //////        empTime.EntryTime = doorT.EntryTime;
                //////        empTime.ExitTime = doorT.ExitTime;
                //////        empTime.Modified = DateTimeOffset.Now;
                //////    }
                //////}

                string ssss = doorT.UserExtID;
                try
                {
                    //if (ssss == "44B14BDB7D23454CADA5C2FDE8168D80")
                    //{
                    //    string sssssss = "0";
                    //}

                    var doorTime = vsr.hrWorkingHours.Where(p => p.DoorSysID == doorT.UserExtID && p.WorkingDate == doorT.EventDay).SingleOrDefault();
                    if (doorTime != null)
                    {
                        doorTime.EntryTime = doorT.EntryTime;
                        doorTime.ExitTime  = doorT.ExitTime;

                        DateTime startTime = (DateTime)doorT.EntryTime;
                        DateTime endTime   = (DateTime)doorT.ExitTime;
                        TimeSpan timeSpan  = endTime.Subtract(startTime);

                        int workedMinute   = (timeSpan.Hours * 60) + timeSpan.Minutes;
                        int assignedMinute = (int)doorTime.AssignedWorkingHour * 60;
                        int minuteDiff     = workedMinute - assignedMinute;

                        doorTime.TotalHours   = timeSpan.Hours;
                        doorTime.TotalMinutes = timeSpan.Minutes;
                        doorTime.HourDiff     = minuteDiff / 60;
                        doorTime.MinuteDiff   = minuteDiff % 60;

                        if (workedMinute >= 480)
                        {
                            doorTime.TotalHours   = 8;
                            doorTime.TotalMinutes = 0;
                        }


                        vsr.UpdateObject(doorTime);
                        j += 1;
                    }
                }
                catch (Exception ex)
                {
                }

                i += 1;
            }

            vsr.SaveChanges();
            //////verpsDb.SaveChanges();

            Console.WriteLine(i);
            Console.WriteLine(j);
            Console.WriteLine("DONE!");
        }
Exemplo n.º 3
0
        private static void ParseAndLoadData(DateTime opDate)
        {
            var doorsDb = new DOORSEntities();

            DataAccess.DataTable dt;


            string fileName = @"\\10.10.5.6\DoorExportFiles\DoorsNightlyRawDataProcessed";

            fileName = fileName + opDate.Year.ToString() + get2Digit(opDate.Month.ToString()) + get2Digit(opDate.Day.ToString());

            //Console.WriteLine(fileName);
            //Console.ReadLine();

            try
            {
                dt = DataAccess.DataTable.New.ReadCsv(fileName);
            }
            catch (Exception)
            {
                dt = null;
            }

            int i = 0;
            int j = 0;
            int k = 0;

            if (dt != null)
            {
                foreach (Row row in dt.Rows)
                {
                    //DateTime aaaaa = DateTime.Parse(row.Values[0]);

                    if (row["Event date/time"].Trim() != "" && row["User ExtID"].Trim() != "")
                    {
                        try
                        {
                            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"];

                            doorsDb.DoorsRawDatas.Add(drd);
                            i += 1;
                        }
                        catch (Exception ex)
                        {
                            j += 1;
                        }
                    }
                    else
                    {
                        k += 1;
                    }
                }
            }

            doorsDb.SaveChanges();

            dt = null;
            doorsDb.Dispose();

            Console.WriteLine(i);
            Console.WriteLine(j);
            Console.WriteLine(k);

            Console.WriteLine("DONE!");
        }