Skip to content

Conversation

@FantasyTeddy
Copy link
Contributor

No description provided.

J005t67 and others added 30 commits April 26, 2025 22:37
Split IPanelPresenter before it becomes too big.
…ies-to-core

Make SharedFieldProperties part of ApplicationModel
…viewmodels

Add MediumDistance view and viewmodel to display distances in meters or feet
…dels-to-streamers-deps

# Conflicts:
#	SourceCode/AgOpenGPS.Core/ViewModels/ApplicationViewModel.cs
#	SourceCode/AgOpenGPS.Core/ViewModels/StartNewFieldViewModels/CreateFromExistingFieldViewModel.cs
#	SourceCode/AgOpenGPS.Core/ViewModels/StartNewFieldViewModels/SelectFieldViewModel.cs
#	SourceCode/AgOpenGPS.Core/ViewModels/StartNewFieldViewModels/SelectNearFieldViewModel.cs
#	SourceCode/AgOpenGPS.Core/ViewModels/StartNewFieldViewModels/StartNewFieldViewModel.cs
Don't double-zip the build output
…dels-to-streamers-deps

# Conflicts:
#	SourceCode/AgOpenGPS.Core/ViewModels/ApplicationViewModel.cs
#	SourceCode/AgOpenGPS.Core/ViewModels/SelectFieldViewModels/CreateFromExistingFieldViewModel.cs
#	SourceCode/AgOpenGPS.Core/ViewModels/SelectFieldViewModels/SelectFieldMenuViewModel.cs
#	SourceCode/AgOpenGPS.Core/ViewModels/SelectFieldViewModels/SelectFieldViewModel.cs
#	SourceCode/AgOpenGPS.Core/ViewModels/SelectFieldViewModels/SelectNearFieldViewModel.cs
Rename 'Load Flags' and 'Save Flags' to 'Import Flags' and 'Export Flags'
…ttings

Invalidate AB line / curve when settings loaded
…ers-deps

Remove dependencies from Field and Fields and FieldDescription to streamers
…e saved back. This is more inline with AOG Configuration
AgIO auto-saves changes to XML file
* Initial API connection for AgShare

* Parse data to json, Upload method added,

When closing the field, after the ISOXML is generated, it will also push to the cloud

* change auth method to identity.

* Added GeoJSON for Boundarys

* Added Guidance Lines to API

* Updated to Core definitions

* Move AgShareApi to AgOpenGPS.Core

* Add proper designer file for AgShare form

* Move AgShare upload into its own method

* Remove 'LangVersion' latest

* Remove unneeded references

* Use empty string as default for API key

* Some formatting

* Rename AgShare settings form

* Make server configurable

* Set AgShare HttpClient properties directly

* Update to New methods

* Redoing AgShare methods, Forms, initial Download Form

* Completed Download Method

* clean FieldInfoDTO to isPublic only

* Better handling of Fieldparser

* Working GuidanceLine Import

* Full redo of AgShare Implementation

* fix geodir

* Visual redesign of FormJob with AgShare and Auto-Upload Bool

---------

Co-authored-by: FantasyTeddy <[email protected]>
richardklasens and others added 27 commits October 15, 2025 19:48
* Scale articulated hitch heading adjustment

* remove unused stuff
This solves created spikes in boundary line when driving a new boundary and jumps in GNSS occurs during driving under a tree or something.
This method is also called when a existing field is loaded.
Maybe it needs regeneration of Curves/BoundaryCurves
* This fixes issues with FormJob, distnace and flag issue in OpenGL (#1001)

* Fix Job Opener

* Add Distance for FormDrivePicker

* Fix OpenGL LeftmouseClick issue

* set right form in checkstate for flag selection

* Reviews to do async await instead of task

* Do not create AgOpenGPS directory inside zip (#1004)

* Add global.json

* Do not create AgOpenGPS directory inside zip

* Improves application shutdown process (#1008)

* Fix: Critical Shutdown Data Loss & Race Conditions

Resolved critical bug where Field Boundary and Tracks were not saved during shutdown,
causing data loss when reopening fields.

## Root Cause Analysis

**User-Reported Bug**: Field Boundary and Tracks not saved on shutdown

**Investigation revealed multiple critical issues**:
1. Silent exceptions in FileSaveEverythingBeforeClosingField - save failures unreported
2. Race condition: BeginInvoke with async Task created "fire-and-forget" pattern
3. Missing Log.FileSaveSystemEvents() calls
4. Form dispose race with async operations
5. No exception handling around critical save operations

## Fixes Applied

### FormGPS.cs - Shutdown Flow

**1. Fixed async void FormClosing** (Lines 594-652)
- Changed from BeginInvoke fire-and-forget to proper async void
- Added comprehensive try/catch/finally with Application.Exit() fallback
- User now sees errors instead of silent failures
- Proper exception logging to system log

**2. Fixed ShowSavingFormAndShutdown** (Lines 655-786)
- Removed using statement race condition
- Manual form dispose in finally block ensures cleanup
- Added try/catch around FileSaveEverythingBeforeClosingField
- User prompt on save failure: "Continue shutdown anyway? (data may be lost)"
- Can cancel shutdown if critical save fails
- FinishShutdown always called in finally (even on errors)

**3. Added Log.FileSaveSystemEvents()** (Lines 725, 753)
- Was missing in both isJobStarted branches
- Now called alongside Settings.Default.Save()
- Ensures system events are logged before exit

**4. Fixed AgShare Upload Duplication**
- No longer starts new upload in ShowSavingFormAndShutdown
- Just waits for upload already started in FileSaveEverythingBeforeClosingField
- Prevents double upload of same data

### Controls.Designer.cs - FileSaveEverythingBeforeClosingField

**Individual Exception Handling** (Lines 658-680)
```csharp
await Task.Run(() =>
{
    try { FileSaveBoundary(); }
    catch (Exception ex) { Log.EventWriter($"CRITICAL: Boundary save failed: {ex}"); throw; }

    try { FileSaveSections(); }
    catch (Exception ex) { Log.EventWriter($"CRITICAL: Sections save failed: {ex}"); throw; }

    try { FileSaveContour(); }
    catch (Exception ex) { Log.EventWriter($"CRITICAL: Contour save failed: {ex}"); throw; }

    try { FileSaveTracks(); }
    catch (Exception ex) { Log.EventWriter($"CRITICAL: Tracks save failed: {ex}"); throw; }

    try { ExportFieldAs_KML(); }
    catch (Exception ex) { Log.EventWriter($"WARNING: KML export failed: {ex}"); }

    try { ExportFieldAs_ISOXMLv4(); }
    catch (Exception ex) { Log.EventWriter($"WARNING: ISOXML export failed: {ex}"); }
});
```

**Why This Fixes the Bug**:
- Previous code had no exception handling in Task.Run
- If FileSaveBoundary() or FileSaveTracks() threw exception, it failed **silently**
- User saw "Field saved" message but data was NOT actually saved
- Now exceptions are logged with CRITICAL/WARNING severity
- Critical save failures propagate up to ShowSavingFormAndShutdown
- User is prompted and can cancel shutdown to investigate

## Testing Impact

**Before Fix**:
- User closes app → sees "Saving..." → app closes
- Reopens field → Boundary and Tracks missing
- No error message, no log entry
- **Data loss!**

**After Fix**:
- User closes app → sees "Saving..."
- If save fails → Error dialog: "Field data save failed: [reason]. Continue shutdown anyway?"
- User can choose NO → shutdown cancelled, can investigate
- All failures logged with CRITICAL severity in system log
- **No silent data loss!**

## Files Modified

- **FormGPS.cs**: Shutdown handling with proper async exception handling
- **Controls.Designer.cs**: Individual save operation exception handling

## Build Status

✅ Build succeeded - 0 errors, 0 warnings

## References

Based on user bug report: "Field Boundary en Tracks niet opgeslagen bij afsluiten"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Improves shutdown field saving and AgShare handling

Refactors the shutdown sequence to improve reliability during field saving and AgShare upload.

- Moves field saving before settings saving to ensure data integrity.
- Starts AgShare upload during the field saving process.
- Adds more robust error handling and status reporting for AgShare upload failures during shutdown.
- Prevents resetting AgShare upload state and snapshot during shutdown to allow the shutdown flow to correctly check this flag.

* Adds application closing log

Adds a log entry when the application is closing.

Also, ensures settings are saved.

* Fix shutdown sequence for better reliability

Reviews from Codex

* Saves system events periodically

Saves system events to a file periodically.

This ensures that important system events are captured in case of
a crash or unexpected shutdown. Improves data retention and debugging
capabilities.

---------

Co-authored-by: Claude <[email protected]>

* Fix MaxSteer Bar to 255 (#1010)

* Fix Opening field to quick if program is initializing (#1011)

* Fixes AB and Curve line tool offset and guidelines + section timer at 10hz (#1015)

* Do section control at 10 hz, show actual frame time.

* Remove bbcounter

* Fix offset for abLine guidelines

* Tool offset with guidelines fixed

* Fix formatting on curve and line classes

---------

Co-authored-by: BrianTee <[email protected]>

* Improves AgShare field download process (#1016)

* Improves AgShare field download process

Adds validation and error handling to the AgShare field download process to ensure data integrity and provide better feedback to the user.

Includes checks for null or invalid field data, coordinate ranges, and boundary/AB line availability.  Also provides more detailed logging and handles potential exceptions during download and parsing.

Adds a "Failed" counter to the bulk download process and displays it to the user.

* fix null downloadpreview

* Address review comments from FantasyTeddy and J005t67

- Move ValidateFieldDto logic into AgShareFieldParser.Parse method
- Add log statement when field is skipped in DownloadAllAsync
- Add log statements for skipped invalid coordinates
- Show skipped count conditionally like failed count
- Add curly braces around single-line if statement
- Create separate IsValidCoordinate function to avoid code duplication

* Review

Reviews @FantasyTeddy

* Fix Worked Tracks Skipper (#1013)

Fixes #936

* Put back visual closing without field open

---------

Co-authored-by: Matthias Baer <[email protected]>
Co-authored-by: Claude <[email protected]>
Co-authored-by: BrianTee <[email protected]>
…AlwaysCm

#1019 Havester front hitch unit label always cm
…ncorrect-image-in-config

Correct config image for hitch of articulated
…too-many

Bugfix/1026 one guideline too many and 1025 half of extra guide lines do not show green foreground color.
Rephrase 'Delete For Sure' -> 'Are you sure you want to delete?'
Improves track copying and conversion process.

Ensures copied tracks are correctly converted between
coordinate systems by saving current track changes,
reloading them to include recent edits, and clearing track
references before loading new ones.

Normalizes track headings and resets worked tracks for new
fields, also makes copied tracks visible by default. Recalculates
headings for curve points using GeoDir to ensure accuracy
during conversion.

Refactor track copying: separate business logic from UI

- Create stateless TrackCopier class with conversion logic
- Move all coordinate conversion code to TrackCopier
- Replace custom FieldInfo with FieldDescription from Core
- FormCopyTracks now only handles UI interactions
- Improves testability and maintainability

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Rename "Copy Tracks" to "Import Tracks" (more accurate terminology)
- Remove unused field variables (availableTracks, availableFields as class members)
- Use DirectoryInfo directly instead of FieldDescription wrapper
- Simplify field comparison using field name only (not full path)
- Use early return pattern for validation checks
- Make ConvertTracks() private (only CopyTracksToField() is public API)
- Keep form open after import to allow multiple imports
- Count fields/tracks using Items.Count/Controls.Count directly
After importing tracks, the track index (trk.idx) was set to -1. When the user
clicked the cycle backwards button, the index would decrement to -2, causing an
ArgumentOutOfRangeException when trying to access trk.gArr[-2].

The fix sets the index to the first visible track after import, ensuring it's
always in a valid range when tracks are present.
@FantasyTeddy FantasyTeddy merged commit 31c9241 into master Nov 19, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.