public void GetHandheldComments(IProgress progressUpdate, bool fullSync)
        {
            HandheldCommentsResponse response = null;
                GetHandheldCommentsRequest request = new GetHandheldCommentsRequest();
                request.DaysBack = Config.AppSettings.Ref.ProgramSettings.DaysToKeepHandheldComments;
                request.DaysBackSpecified = true;
                request.RideCredential = _rideCredential;
                request.Request = new RequestArgument();
                if (fullSync)
                {
                    request.Request.RequestType = RequestArgumentRequestTypes.FullSync;
                    request.Request.RequestTypeSpecified = true;
                    request.Request.DateSpecified = false;
                }
                else
                {
                    request.Request.RequestType = RequestArgumentRequestTypes.SyncFromDate;
                    request.Request.RequestTypeSpecified = true;
                    request.Request.Date = Data.DataHolder.Ref.GetSyncDate(DataHolder.SyncTypes.HandheldComments);
                    request.Request.DateSpecified = true;
                }
                try
                {
                    using (RideWCFServiceImplementation client = GetSyncClient())
                    {
                        response = client.GetHandheldComments(request);
                    }

                }
                catch (System.Web.Services.Protocols.SoapException ex)
                {
                    Console.Write(ex.Message);
                }
                catch (Exception ex)
                {
                    Console.Write(ex.Message);
                }
                finally
                {
                    if (response != null && response.Success)
                    {
                        #region Comments
                            progressUpdate.IncrementProgress();
                            if (response.Comments.Length > 0)
                            {
                                progressUpdate.SetStatus("Updating Handheld Comments");
                                if (request.Request.RequestType == RequestArgumentRequestTypes.FullSync)
                                    Data.DataHolder.Ref.ClearHandheldComments(true);
                                else
                                    Data.DataHolder.Ref.ClearHandheldComments(false);
                                foreach (Comment comment in response.Comments)
                                {
                                    Data.DataHolder.Ref.SaveHandheldComment(Converter.Comment(comment));
                                }
                            }
                        #endregion

                        #region Save Last Sync Date
                        if (response.ServerSyncTimeSpecified)
                            Data.DataHolder.Ref.SaveSyncDate(DataHolder.SyncTypes.HandheldComments, response.ServerSyncTime);
                        #endregion
                    }
                }
        }
        public void SyncStaticObjects(IProgress progressUpdate, bool fullSync)
        {
            HandheldStaticSyncResponse response = null;
                HandheldStaticSyncRequest request = new HandheldStaticSyncRequest();
                DateTime syncDate = DateTime.MinValue;
                request.Request = new RequestArgument();
                request.RideCredential = _rideCredential;
                request.HistoricalDays = 0;
                request.HistoricalDaysSpecified = true;
                if (!fullSync)
                    syncDate = Data.DataHolder.Ref.GetSyncDate(DataHolder.SyncTypes.StaticObjects);
                if (syncDate==DateTime.MinValue)
                {
                    request.Request.RequestType = RequestArgumentRequestTypes.FullSync;
                    request.Request.RequestTypeSpecified = true;
                    request.Request.DateSpecified = false;
                }
                else
                {
                    request.Request.RequestType = RequestArgumentRequestTypes.SyncFromDate;
                    request.Request.RequestTypeSpecified = true;
                    request.Request.Date=syncDate;
                    request.Request.DateSpecified = true;
                }
                try
                {
                    using (RideWCFServiceImplementation client = GetSyncClient())
                    {
                        response = client.GetHandheldStaticSync(request);
                    }

                }
                catch (System.Web.Services.Protocols.SoapException ex)
                {
                    Console.Write(ex.Message);
                }
                catch (Exception ex)
                {
                    Console.Write(ex.Message);
                }
                finally
                {
                    if (response != null && response.Success)
                    {
                        #region Save
                            #region Employee Types
                                progressUpdate.IncrementProgress();
                                #region Save
                                    if (response.EmployeeTypes.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Updating Employee Types");
                                        if (request.Request.RequestType == RequestArgumentRequestTypes.FullSync)
                                            Data.DataHolder.Ref.ClearEmployeeTypes();
                                        foreach (EmployeeType employeeType in response.EmployeeTypes)
                                        {
                                            Data.DataHolder.Ref.SaveEmployeeType(Converter.EmployeeType(employeeType));
                                        }
                                    }
                                #endregion
                                #region Delete
                                    if (response.DeletedEmployeeTypes != null && response.DeletedEmployeeTypes.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Deleting Employee Types");
                                        foreach (int employeeType in response.DeletedEmployeeTypes)
                                        {
                                            Data.DataHolder.Ref.DeleteEmployeeType(employeeType);
                                        }
                                    }
                                #endregion
                            #endregion

                            #region Client Types
                                progressUpdate.IncrementProgress();
                                #region Save
                                    if (response.ClientTypes.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Updating Client Types");
                                        if (request.Request.RequestType == RequestArgumentRequestTypes.FullSync)
                                            Data.DataHolder.Ref.ClearClientTypes();
                                        foreach (ClientType clientType in response.ClientTypes)
                                        {
                                            Data.DataHolder.Ref.SaveClientType(Converter.ClientType(clientType));
                                        }
                                    }
                                #endregion
                                #region Delete
                                    if (response.DeletedClientTypes != null && response.DeletedClientTypes.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Deleting Client Types");
                                        foreach (int clientType in response.DeletedClientTypes)
                                        {
                                            Data.DataHolder.Ref.DeleteClientType(clientType);
                                        }
                                    }
                                #endregion
                            #endregion

                            #region Address Types
                                progressUpdate.IncrementProgress();
                                #region Save
                                    if (response.AddressTypes.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Updating Address Types");
                                        if (request.Request.RequestType == RequestArgumentRequestTypes.FullSync)
                                            Data.DataHolder.Ref.ClearAddressTypes();
                                        foreach (AddressType addressType in response.AddressTypes)
                                        {
                                            Data.DataHolder.Ref.SaveAddressType(Converter.AddressType(addressType));
                                        }
                                    }
                                #endregion
                                #region Delete
                                    if (response.DeletedAddressTypes != null && response.DeletedAddressTypes.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Deleting Address Types");
                                        foreach (int addressType in response.DeletedAddressTypes)
                                        {
                                            Data.DataHolder.Ref.DeleteAddressType(addressType);
                                        }
                                    }
                                #endregion
                            #endregion

                            #region Vehicle Types
                                progressUpdate.IncrementProgress();
                                #region Save
                                    if (response.VehicleTypes.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Updating Vehicle Types");
                                        if (request.Request.RequestType == RequestArgumentRequestTypes.FullSync)
                                            Data.DataHolder.Ref.ClearVehicleTypes();
                                        foreach (VehicleType vehicleType in response.VehicleTypes)
                                        {
                                            Data.DataHolder.Ref.SaveVehicleType(Converter.VehicleType(vehicleType));
                                        }
                                    }
                                #endregion
                                #region Delete
                                    if (response.DeletedVehicleTypes != null && response.DeletedVehicleTypes.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Deleting Vehicle Types");
                                        foreach (int vehicleType in response.DeletedVehicleTypes)
                                        {
                                            Data.DataHolder.Ref.DeleteVehicleType(vehicleType);
                                        }
                                    }
                                #endregion
                            #endregion

                            #region No Show Types
                                progressUpdate.IncrementProgress();
                                #region Save
                                    if (response.NoShowTypes.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Updating No Show Types");
                                        if (request.Request.RequestType == RequestArgumentRequestTypes.FullSync)
                                            Data.DataHolder.Ref.ClearNoShowTypes();
                                        foreach (NoShowType noShowType in response.NoShowTypes)
                                        {
                                            Data.DataHolder.Ref.SaveNoShowType(Converter.NoShowType(noShowType));
                                        }
                                    }
                                #endregion
                                #region Delete
                                    if (response.DeletedNoShowTypes != null && response.DeletedNoShowTypes.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Deleting No Show Types");
                                        foreach (int noShowType in response.DeletedNoShowTypes)
                                        {
                                            Data.DataHolder.Ref.DeleteNoShowType(noShowType);
                                        }
                                    }
                                #endregion
                            #endregion

                            #region Employees
                                progressUpdate.IncrementProgress();
                                #region Save
                                    if (response.Employees.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Updating Employees");
                                        if (request.Request.RequestType == RequestArgumentRequestTypes.FullSync)
                                            Data.DataHolder.Ref.ClearEmployees();
                                        foreach (Employee employee in response.Employees)
                                        {
                                            Data.DataHolder.Ref.SaveEmployee(Converter.Employee(employee));
                                        }
                                    }
                                #endregion
                                #region Delete
                                    if (response.DeletedEmployees != null && response.DeletedEmployees.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Deleting Employees");
                                        foreach (int employeeID in response.DeletedEmployees)
                                        {
                                            Data.DataHolder.Ref.DeleteEmployee(employeeID);
                                        }
                                    }
                                #endregion
                            #endregion

                            #region Vehicles
                                progressUpdate.IncrementProgress();
                                #region Save
                                    if (response.Vehicles.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Updating Vehicles");
                                        if (request.Request.RequestType == RequestArgumentRequestTypes.FullSync)
                                            Data.DataHolder.Ref.ClearVehicles();
                                        foreach (Vehicle employee in response.Vehicles)
                                        {
                                            Data.DataHolder.Ref.SaveVehicle(Converter.Vehicle(employee));
                                        }
                                    }
                                #endregion
                                #region Delete
                                    if (response.DeletedVehicles != null && response.DeletedVehicles.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Deleting Vehicles");
                                        foreach (int vehicleID in response.DeletedVehicles)
                                        {
                                            Data.DataHolder.Ref.DeleteVehicle(vehicleID);
                                        }
                                    }
                                #endregion
                            #endregion

                            #region Routes
                                progressUpdate.IncrementProgress();
                                #region Save
                                    if (response.Routes.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Updating Routes");
                                        if (request.Request.RequestType == RequestArgumentRequestTypes.FullSync)
                                            Data.DataHolder.Ref.ClearRoutes();
                                        foreach (Route syncRoute in response.Routes)
                                        {
                                            Ride.Business.Objects.Routes.Route route = Converter.Route(syncRoute);
                                            route.Save();
                                            Data.DataHolder.Ref.SaveRoute(route);
                                            foreach (Ride.Business.Objects.Routes.Stops.RouteStop stop in route.Stops.Active)
                                            {
                                                Data.DataHolder.Ref.SaveRouteStop(route, stop);
                                                foreach (Ride.Business.Objects.Routes.Stops.RouteStopEvent routeStopEvent in stop.StopEvents.Active)
                                                {
                                                    Data.DataHolder.Ref.SaveRouteStopEvent(stop, routeStopEvent);
                                                    foreach (Ride.Business.Objects.Routes.Stops.RouteStopEventAudioFile routeStopEventAudioFile in routeStopEvent.AudioFiles)
                                                    {
                                                        Data.DataHolder.Ref.SaveAudioFile(routeStopEventAudioFile.AudioFile);
                                                        Data.DataHolder.Ref.SaveRouteStopEventAudioFile(routeStopEvent, routeStopEventAudioFile);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                #endregion
                                #region Delete
                                    if (response.DeletedRoutes != null && response.DeletedRoutes.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Deleting Routes");
                                        foreach (int routeID in response.DeletedRoutes)
                                        {
                                            Data.DataHolder.Ref.DeleteRoute(routeID);
                                        }
                                    }
                                    if (response.DeletedRouteStops != null && response.DeletedRouteStops.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Deleting Route Stops");
                                        foreach (int routeStopID in response.DeletedRouteStops)
                                        {
                                            Data.DataHolder.Ref.DeleteRouteStop(routeStopID);
                                        }
                                    }
                                #endregion
                            #endregion

                            #region Tracking Levels
                                progressUpdate.IncrementProgress();
                                #region Save
                                    if (response.TrackingLevels.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Updating Tracking Levels");
                                        if (request.Request.RequestType == RequestArgumentRequestTypes.FullSync)
                                            Data.DataHolder.Ref.ClearTrackingLevels();
                                        foreach (TrackingLevel syncTrackingLevel in response.TrackingLevels)
                                        {
                                            Ride.Business.Objects.Routes.Tracking.TrackingLevel trackingLevel = Converter.TrackingLevel(syncTrackingLevel);
                                            Data.DataHolder.Ref.SaveTrackingLevel(trackingLevel);
                                            foreach (Ride.Business.Objects.Routes.Tracking.RouteTrackingCriteria routeTrackingCriteria in trackingLevel.Criteria.Active)
                                            {
                                                Data.DataHolder.Ref.SaveRouteTrackingCriteria(trackingLevel, routeTrackingCriteria);
                                            }
                                        }
                                    }
                                #endregion
                                #region Delete
                                    if (response.DeletedTrackingLevels != null && response.DeletedTrackingLevels.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Deleting TrackingLevels");
                                        foreach (int trackingLevelID in response.DeletedTrackingLevels)
                                        {
                                            Data.DataHolder.Ref.DeleteTrackingLevel(trackingLevelID);
                                        }
                                    }
                                    if (response.DeletedRouteTrackingCriteria != null && response.DeletedRouteTrackingCriteria.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Deleting Route Tracking Criterias");
                                        foreach (int routeTrackingCriteriaID in response.DeletedRouteTrackingCriteria)
                                        {
                                            Data.DataHolder.Ref.DeleteRouteTrackingCriteria(routeTrackingCriteriaID);
                                        }
                                    }

                                #endregion
                            #endregion

                            #region DVIR Prompts
                                progressUpdate.IncrementProgress();
                                #region Save
                                    if (response.DVIRPrompts.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Updating DVIR Prompts");
                                        if (request.Request.RequestType == RequestArgumentRequestTypes.FullSync)
                                            Data.DataHolder.Ref.ClearDVIRPrompts();
                                        foreach (DVIRPrompt prompt in response.DVIRPrompts)
                                        {
                                            Data.DataHolder.Ref.SaveDVIRPrompt(Converter.DVIRPrompt(prompt));
                                        }
                                    }
                                #endregion
                                #region Delete
                                    if (response.DeletedDVIRPrompts != null && response.DeletedDVIRPrompts.Length > 0)
                                    {
                                        progressUpdate.SetStatus("Deleting DVIR Prompts");
                                        foreach (int dvirPromptID in response.DeletedDVIRPrompts)
                                        {
                                            Data.DataHolder.Ref.DeleteDVIRPrompt(dvirPromptID);
                                        }
                                    }
                                #endregion
                            #endregion
                        #endregion
                        #region Save Last Sync Date
                            if (response.ServerSyncTimeSpecified)
                                Data.DataHolder.Ref.SaveSyncDate(DataHolder.SyncTypes.StaticObjects,response.ServerSyncTime);
                        #endregion
                        RaiseSyncedBusinessTypes();
                        RaiseSyncedVehiclesAndEmployees();
                        RaiseSyncedRouteDefinitions();
                        RaiseSyncedDVIRPrompts();
                    }
                }
        }