예제 #1
0
        public bool Synchronize_Passings(hardcardserver.SyncService ss)
        {
            bool result = true;

            List<hardcardserver.Passing> passingsPushList = new List<hardcardserver.Passing>();
            DateTime lastSync;
            try
            {
                /*Get the last synchronized timestamp*/
                lastSync = GetLastSynchronized();

                /*Get customer records to be syncrhonized to the server*/
                IEnumerable<Passing> pfound =
                    from p in _hardcardContext.Passings
                    where (DateTime.Compare(p.LastUpdated.Value, lastSync) > 0)
                    select p;

                foreach (var plocal in pfound)
                {
                    hardcardserver.Passing newPassing = new hardcardserver.Passing();
                    /*TODO: is there a better way to manage this assigment, maybe an
                     overloaded operator*/

                    newPassing.PassingID = plocal.Id;
                    newPassing.RFID = plocal.RFID;
                    newPassing.PassngTime = plocal.PassingTime;
                    newPassing.RaceTime = plocal.RaceTime;
                    newPassing.SessionID = (long)plocal.SessionId;
                    passingsPushList.Add(newPassing);
                }
                result = ss.SynchronizePassingsDataWithClient(lastSync, passingsPushList.ToArray());
                LogSynchronization();
            }
            catch (Exception ex)
            {
                StatusText = "Syncrhonization of Competitors failed with error: " + ex.Message;
                System.Console.WriteLine(ex.Message);
                return false;
            }

            return true;
        }