private void UpdateProfileEventFromEdits()
        {
            foreach (ProfileRecordFormatted prf in m_EditScreen.m_RecordList)
            {
                if (prf.Profile == "-DELETED-")
                {
                    m_ProfileEventList[prf.IndexID].Badge1 = "[DELETED]";
                }
                else
                {
                    m_ProfileEventList[prf.IndexID].StartTime = prf.StartView.Replace(":", "");
                    m_ProfileEventList[prf.IndexID].EndTime   = prf.EndView.Replace(":", "");
                }
            }
            for (int Count = 0; Count < m_ProfileEventList.Count; Count++)
            {
                if (m_ProfileEventList[Count].Badge1 == "[DELETED]")
                {
                    m_ProfileEventList.RemoveAt(Count);
                    Count--;
                }
            }

            DataAccess.UpdateProfileRecordTable(m_ProfileEventList, DataTrack.GetTimeStamp().Substring(0, 8));
        }
Exemple #2
0
        public static NameValueCollection GetRawFileSendValues(string UseCompanyID, string UseWebFolder, string UseProbeName)
        {
            NameValueCollection result = new NameValueCollection();

            result.Add("CompanyID", UseCompanyID);
            result.Add("folder", UseWebFolder);
            result.Add("fname", string.Format("{0}_DATA_{1}.RAW", DataTrack.GetTimeStamp(), UseProbeName));
            result.Add("action", "upload");



            return(result);
        }
        private void Edit_Clicked(object sender, EventArgs e)
        {
            m_EditScreen = new PersonalEditPage();
            //pass profilerecord list
            //for(int _index=0; _index<m_ProfileEventList.Count; _index++)
            //reversing, so that early events are on top
            for (int _index = m_ProfileEventList.Count - 1; _index >= 0; _index--)
            {
                string _profile = "";
                if (m_ProfileEventList[_index].EmployeeID == m_ActiveEmployee.Misc)
                {
                    if (m_ProfileEventList[_index].Badge1 == "[BREAK]" || m_ProfileEventList[_index].Badge1 == "[LUNCH]")
                    {
                        if (m_ProfileEventList[_index].Badge1 == "[BREAK]")
                        {
                            _profile = "Break Event";
                        }
                        else
                        {
                            _profile = "Lunch Event";
                        }
                    }
                    else
                    {
                        for (int Count = 1; Count <= 12; Count++)
                        {
                            if (m_ProfileEventList[_index].GetBadgeAt(Count) != "")
                            {
                                BadgeType bt = m_BadgeList.Where(b => b.BadgeID == m_ProfileEventList[_index].GetBadgeAt(Count)).First();
                                if (bt.Description != "")
                                {
                                    _profile += bt.Description + ", ";
                                }
                            }
                        }  //end profile loop
                    }
                    m_EditScreen.m_RecordList.Add(new ProfileRecordFormatted()
                    {
                        IndexID = _index,
                        Profile = _profile,

                        StartView = DataTrack.GetLongDisplayTime(m_ProfileEventList[_index].StartTime),
                        EndView   = DataTrack.GetLongDisplayTime(m_ProfileEventList[_index].EndTime)
                    });
                }
            }
            Navigation.PushAsync(m_EditScreen);
        }
        private void Break_Clicked(object sender, EventArgs e)
        {
            //flag in or out from lunch
            //set start time or end time
            //send scan to data

            if (m_IsLunch)
            {
                return;
            }

            if (!m_IsBreak)
            {
                m_IsBreak       = true;
                txtBreakIn.Text = DataTrack.GetDisplayTime(DataTrack.GetTimeStamp().Substring(8));
                DataAccess.AddRecord("BRKBEG");

                //leave activity
                m_ProfileEventList[0].EndTime = DataTrack.GetTimeStamp().Substring(8);

                m_ProfileEventList.Insert(0, new ProfileRecord()
                {
                    EmployeeID = m_ActiveEmployee.Misc, EmployeeBadge = m_ActiveEmployee.BadgeID, FileDate = DataTrack.GetTimeStamp().Substring(0, 8), OriginTime = DataTrack.GetTimeStamp()
                });
                m_ProfileEventList[0].SetBadgeAt(1, "[BREAK]");

                m_ProfileEventList[0].StartTime = DataTrack.GetTimeStamp().Substring(8);
            }
            else
            {
                m_IsBreak        = false;
                txtBreakOut.Text = DataTrack.GetDisplayTime(DataTrack.GetTimeStamp().Substring(8));
                DataAccess.AddRecord("BRKEND");

                //end break
                m_ProfileEventList[0].EndTime = DataTrack.GetTimeStamp().Substring(8);

                //restart profile, set new start time and profile to active profile
                m_ProfileEventList.Insert(0, UpdateProfile(new ProfileRecord()
                {
                    EmployeeID = m_ActiveEmployee.Misc, EmployeeBadge = m_ActiveEmployee.BadgeID, FileDate = DataTrack.GetTimeStamp().Substring(0, 8), OriginTime = DataTrack.GetTimeStamp()
                }));
                m_ProfileEventList[0].StartTime = DataTrack.GetTimeStamp().Substring(8);
            }
            DataAccess.UpdateProfileRecordTable(m_ProfileEventList, DataTrack.GetTimeStamp().Substring(0, 8));
            DataAccess.AddRecord(m_ActiveEmployee.BadgeID);
        }
        private void Scan_Clicked(object sender, EventArgs e)
        {
            //set logged in
            //set start time or end time
            //send scan to data
            if (m_IsBreak || m_IsLunch)
            {
                return;
            }


            if (m_ProfileEventList.Count == 0)
            {
                m_ProfileEventList.Add(UpdateProfile(new ProfileRecord()
                {
                    EmployeeID = m_ActiveEmployee.Misc, EmployeeBadge = m_ActiveEmployee.BadgeID, FileDate = DataTrack.GetTimeStamp().Substring(0, 8), OriginTime = DataTrack.GetTimeStamp()
                }));
            }
            else if (!m_IsLoggedIn && txtScanIn.Text == "--:--")
            {
                m_ProfileEventList.Insert(0, UpdateProfile(new ProfileRecord()
                {
                    EmployeeID = m_ActiveEmployee.Misc, EmployeeBadge = m_ActiveEmployee.BadgeID, FileDate = DataTrack.GetTimeStamp().Substring(0, 8), OriginTime = DataTrack.GetTimeStamp()
                }));
            }


            if (!m_IsLoggedIn && txtScanIn.Text == "--:--")
            {
                //start time
                txtScanIn.Text = DataTrack.GetDisplayTime(DataTrack.GetTimeStamp().Substring(8));
                m_IsLoggedIn   = true;

                m_ProfileEventList[0].StartTime = DataTrack.GetTimeStamp().Substring(8);
            }
            else
            {
                // will always extend logout time if start time exists
                txtScanOut.Text = DataTrack.GetDisplayTime(DataTrack.GetTimeStamp().Substring(8));
                m_IsLoggedIn    = false;
                m_ProfileEventList[0].EndTime = DataTrack.GetTimeStamp().Substring(8);
                DataAccess.AddRecord("SGLOUT");
            }
            DataAccess.AddRecord(m_ActiveEmployee.BadgeID);
            DataAccess.UpdateProfileRecordTable(m_ProfileEventList, DataTrack.GetTimeStamp().Substring(0, 8));
            SetScreen(); //update in case we're logging in
        }
Exemple #6
0
        public static List <RawDataRecord> GetPendingData()
        {
            List <ProfileRecord> _events = GetPendingRecords();
            List <RawDataRecord> resultList = new List <RawDataRecord>();
            int           Count, Count2;
            RawDataRecord rc;
            string        LastDayFile    = "0000000";
            string        LastEmployee   = "";
            string        LastProfile    = "";
            string        CurrentProfile = "";
            bool          bIsSpecialEvent;
            bool          bStartTimeSet;

            bool bSaveStart, bSaveEnd;

            for (Count = 0; Count < _events.Count; Count++)
            {
                if (_events[Count].Badge1 != "[BREAK]" && _events[Count].Badge1 != "[LUNCH]")
                {
                    //leave alone if break or lunch event, to pass through to next event
                    CurrentProfile  = "";
                    bIsSpecialEvent = false;
                    for (Count2 = 0; Count2 < 12; Count2++)
                    {
                        CurrentProfile += _events[Count].GetBadgeAt(Count2 + 1);
                    }
                }
                else
                {
                    bIsSpecialEvent = true;
                }



                if (LastEmployee != _events[Count].EmployeeID || LastDayFile != _events[Count].FileDate)
                {
                    LastProfile   = ""; //reset profile
                    bStartTimeSet = false;
                }

                if (CurrentProfile != LastProfile)
                {
                    //save profile
                    for (Count2 = 0; Count2 < 12; Count2++)
                    {
                        if (_events[Count].GetBadgeAt(Count2 + 1) == "")
                        {
                            break;
                        }
                        else
                        {
                            rc = new RawDataRecord();

                            rc.Flags     = "";
                            rc.TimeStamp = DataTrack.GetDateTimeFromTimeStamp(_events[Count].FileDate + _events[Count].StartTime).AddSeconds(-2);
                            rc.ScanValue = _events[Count].GetBadgeAt(Count2 + 1);
                            resultList.Add(rc);
                        }
                    }
                }

                //if is last event of day for employee AND start time has already been done, only endtime
                //if is special event, both times
                //if first event, always start time

                //check file/emp resets
                bSaveStart = false;
                bSaveEnd   = false;

                if (Count == _events.Count - 1)
                {
                    //last event of the list
                    bSaveStart = false;
                    bSaveEnd   = true;
                    if (_events.Count == 1)
                    {
                        bSaveStart = true;
                    }
                }
                else if (Count == 0)
                {
                    //very first event
                    bSaveStart = true;
                    bSaveEnd   = false;
                    if (_events.Count == 1)
                    {
                        bSaveEnd = true;
                    }
                }
                else if (_events[Count + 1].EmployeeID != _events[Count].EmployeeID || _events[Count + 1].FileDate != _events[Count].FileDate)
                {
                    //last event for employee/day
                    bSaveStart = false;
                    bSaveEnd   = true;
                }
                else if (bIsSpecialEvent)
                {
                    //break/lunch always save
                    bSaveStart = true;
                    bSaveEnd   = true;
                }
                else if (CurrentProfile != LastProfile)
                {
                    //profile change, need start time again
                    //if profile hasnt changed, and are just returning from break/lunch, dont need start time
                    bSaveStart = true;
                    bSaveEnd   = false;
                }
                else if (_events[Count - 1].EmployeeID != _events[Count].EmployeeID || _events[Count - 1].FileDate != _events[Count].FileDate)
                {
                    //if first scan for this employee/day
                    bSaveStart = true;
                    bSaveEnd   = false;
                }


                if (bSaveStart)
                {
                    if (_events[Count].Badge1 == "[BREAK]" || _events[Count].Badge1 == "[LUNCH]")
                    {
                        rc           = new RawDataRecord();
                        rc.Flags     = "";
                        rc.TimeStamp = DataTrack.GetDateTimeFromTimeStamp(_events[Count].FileDate + _events[Count].StartTime);
                        rc.ScanValue = _events[Count].Badge1 == "[BREAK]" ? "SBREAK" : "SLUNCH";
                        resultList.Add(rc);
                    }
                    rc = new RawDataRecord();

                    rc.Flags     = "";
                    rc.TimeStamp = DataTrack.GetDateTimeFromTimeStamp(_events[Count].FileDate + _events[Count].StartTime);
                    rc.ScanValue = _events[Count].EmployeeBadge;
                    resultList.Add(rc);
                }
                if (bSaveEnd)
                {
                    if (_events[Count].Badge1 == "[BREAK]" || _events[Count].Badge1 == "[LUNCH]")
                    {
                        rc           = new RawDataRecord();
                        rc.Flags     = "";
                        rc.TimeStamp = DataTrack.GetDateTimeFromTimeStamp(_events[Count].FileDate + _events[Count].EndTime);
                        rc.ScanValue = _events[Count].Badge1 == "[BREAK]" ? "EBREAK" : "ELUNCH";
                        resultList.Add(rc);
                    }
                    rc = new RawDataRecord();

                    rc.Flags     = "";
                    rc.TimeStamp = DataTrack.GetDateTimeFromTimeStamp(_events[Count].FileDate + _events[Count].EndTime);
                    rc.ScanValue = _events[Count].EmployeeBadge;
                    resultList.Add(rc);
                }

                LastProfile  = CurrentProfile;
                LastEmployee = _events[Count].EmployeeID;
                LastDayFile  = _events[Count].FileDate;
            }

            return(resultList);
        }
Exemple #7
0
        public void Sync_Clicked(object sender, EventArgs e)
        {
            bool bBadgeReceived   = false;
            bool bProfileReceived = false;
            //send data
            //get badge.def
            //get profile.def

            //List<RawDataRecord> RawList = DataAccess.GetRecordTable(false);
            List <RawDataRecord> RawList = DataAccess.GetPendingData();
            string RawData = DataTrack.GetRawFileHeader(m_Options.ProbeName);

            for (int Count = 0; Count < RawList.Count; Count++)
            {
                RawData += string.Format("{0}0 HH {1,-12}{2}\r\n", DataTrack.GetTimeStamp(RawList[Count].TimeStamp), RawList[Count].ScanValue, RawList[Count].Flags);
            }
            RawData += string.Format("T 000\r\n");
            RawData += string.Format("S {0}\r\n", AccountInfo.GetDeviceID());


            NameValueCollection RawValues = WebInteraction.GetRawFileSendValues(m_Options.CompanyID, m_Options.WebFolder, m_Options.ProbeName);

            RawValues.Add("filedata", RawData);
            RawValues.Add("FileLen", RawData.Length.ToString());

            string result = WebInteraction.SendHttpPostValues(WebInteraction.m_FileSyncURL, RawValues);

            if (result.IndexOf("<adsdelimiter>") >= 0)
            {
                result += "<adsdelimiter>";
                string Temp = result.Substring(0, result.IndexOf("<adsdelimiter>"));
                result = result.Substring(result.IndexOf("<adsdelimiter>") + 14);
                if (Temp == RawValues["fname"])
                {
                    Temp = result.Substring(0, result.IndexOf("<adsdelimiter>"));
                    if (Temp == RawValues["FileLen"])
                    {
                        //DataAccess.UpdateRecordTable();


                        //DataAccess.UpdateProfileRecordStatus();
                    }
                }
            }


            NameValueCollection UseMe = WebInteraction.GenerateDefFileRequest(m_Options.CompanyID, m_Options.WebFolder, "BADGE.DEF");

            result = WebInteraction.SendHttpPostValues(WebInteraction.m_FileSyncURL, UseMe);
            if (result != "")
            {
                //process badge.def
                FileInteraction.WriteCompleteFile("DEF", "BADGE.DEF", result);
                bBadgeReceived = true;
            }



            UseMe  = WebInteraction.GenerateDefFileRequest(m_Options.CompanyID, m_Options.WebFolder, "PROFILE.DEF");
            result = WebInteraction.SendHttpPostValues(WebInteraction.m_FileSyncURL, UseMe);
            if (result != "")
            {
                //process badge.def
                FileInteraction.WriteCompleteFile("DEF", "PROFILE.DEF", result);
                bProfileReceived = true;
            }

            if (bBadgeReceived)
            {
                DataTrack.LoadBadgesFromFile();
            }
            if (bProfileReceived)
            {
                DataTrack.LoadProfileLevelsFromFile();
            }
        }
        private void LoadProfileEventList()
        {
            m_EmployeeFound = false;
            m_IsLoggedIn    = false;
            m_IsLunch       = false;
            m_IsBreak       = false;
            //load event list for today
            //set active profile
            m_ProfileEventList = DataAccess.GetProfileTable(DataTrack.GetTimeStamp().Substring(0, 8));

            if (m_ProfileEventList.Count > 0)
            {
                //set active profile
                //get employee from top profile
                BadgeType bt = new BadgeType();
                bt = m_BadgeList.Where(s => s.Type1 == "Employee" && s.Misc == m_ProfileEventList[0].EmployeeID).First();
                m_ActiveEmployee = bt;

                txtEmployee.Text     = bt.BadgeID;
                lblEmployeeName.Text = string.Format("{0} ({1})", m_ActiveEmployee.Description, m_ActiveEmployee.Misc);
                m_EmployeeFound      = true;
                bool bProfileFound = false;


                if (m_ProfileEventList[0].Badge1 == "[LUNCH]")
                {
                    if (m_ProfileEventList[0].EndTime == "")
                    {
                        m_IsLunch = true;
                    }
                }
                else if (m_ProfileEventList[0].Badge1 == "[BREAK]")
                {
                    if (m_ProfileEventList[0].EndTime == "")
                    {
                        m_IsBreak = true;
                    }
                }
                else if (m_ProfileEventList[0].StartTime != "")
                {
                    m_IsLoggedIn = true;
                }

                for (int Count = 0; Count < m_ProfileEventList.Count; Count++)
                {
                    if (m_ProfileEventList[Count].Badge1 != "[BREAK]" && m_ProfileEventList[Count].Badge1 != "[LUNCH]")
                    {
                        if (!bProfileFound)
                        {
                            //set active profile
                            for (int Count2 = 0; Count2 < 12; Count2++)
                            {
                                //if (m_ProfileEventList[Count].GetBadgeAt(Count2 + 1) != "")
                                if (m_BadgeList.Where(s => s.BadgeID == m_ProfileEventList[Count].GetBadgeAt(Count2 + 1)).Count() > 0)
                                {
                                    m_ActiveProfile[Count2] = m_BadgeList.Where(s => s.BadgeID == m_ProfileEventList[Count].GetBadgeAt(Count2 + 1)).First();
                                }
                                else
                                {
                                    m_ActiveProfile[Count2] = new BadgeType();
                                }
                            }
                            if (m_ProfileEventList[Count].EndTime != "")
                            {
                                txtScanOut.Text = DataTrack.GetDisplayTime(m_ProfileEventList[Count].EndTime);
                            }
                        }
                        if (m_ProfileEventList[Count].StartTime != "")
                        {
                            txtScanIn.Text = DataTrack.GetDisplayTime(m_ProfileEventList[Count].StartTime);
                        }



                        bProfileFound = true;
                    }
                    else if (m_ProfileEventList[Count].Badge1 == "[BREAK]")
                    {
                        if (m_ProfileEventList[Count].EndTime != "")
                        {
                            txtBreakOut.Text = DataTrack.GetDisplayTime(m_ProfileEventList[Count].EndTime);
                        }


                        if (m_ProfileEventList[Count].StartTime != "")
                        {
                            txtBreakIn.Text = DataTrack.GetDisplayTime(m_ProfileEventList[Count].StartTime);
                        }
                    }
                    else if (m_ProfileEventList[Count].Badge1 == "[LUNCH]")
                    {
                        if (m_ProfileEventList[Count].EndTime != "")
                        {
                            txtLunchOut.Text = DataTrack.GetDisplayTime(m_ProfileEventList[Count].EndTime);
                        }


                        if (m_ProfileEventList[Count].StartTime != "")
                        {
                            txtLunchIn.Text = DataTrack.GetDisplayTime(m_ProfileEventList[Count].StartTime);
                        }
                    }
                }

                if (bProfileFound)
                {
                    UpdateActiveProfileText();
                    cmdEdit.IsEnabled = true;
                }
            }
        }