# GeViScope Configuration Reader

A C# console application that reads configuration from a GeViScope server and exports it to JSON format.

## Features

- ✅ Connects to GeViScope server using the official SDK
- ✅ Reads entire configuration tree from server
- ✅ Exports configuration to human-readable JSON
- ✅ Shows summary of media channels and users
- ✅ No binary file parsing required!

## Prerequisites

- Windows (x86/x64)
- .NET Framework 4.8 or later
- GeViScope SDK installed (included DLLs in project)
- GeViScope server running (can be local or remote)

## Usage

### Basic Usage (Local Server)

```bash
GeViScopeConfigReader.exe
```

Default connection:
- Server: `localhost`
- Username: `sysadmin`
- Password: `masterkey`
- Output: `geviScope_config.json`

### Custom Server

```bash
GeViScopeConfigReader.exe <hostname> <username> <password> <output-file>
```

Example:
```bash
GeViScopeConfigReader.exe 192.168.1.100 admin mypassword my_config.json
```

## Output Format

The tool exports configuration to JSON in a hierarchical structure:

```json
{
  "System": {
    "MediaChannels": {
      "0000": {
        "Name": "Camera 1",
        "Enabled": true,
        "GlobalNumber": 1,
        "VideoFormat": "H.264"
      }
    },
    "Users": {
      "SysAdmin": {
        "Name": "System Administrator",
        "Enabled": true,
        "Password": "abe6db4c9f5484fae8d79f2e868a673c"
      }
    }
  }
}
```

## Building

```bash
cd C:\DEV\COPILOT\geutebruck-api\GeViScopeConfigReader
dotnet build
```

Or open in Visual Studio and build.

## What This Solves

**Problem**: The `.set` configuration files are in a proprietary binary format that's difficult to parse.

**Solution**: Use the GeViScope SDK to read configuration directly from the server in a structured format, then export to JSON.

**Benefits**:
- No reverse-engineering needed
- Official supported API
- Human-readable output
- Easy to modify and use programmatically

## Example: Reading User Information

The exported JSON makes it easy to access configuration:

```csharp
var config = JObject.Parse(File.ReadAllText("geviScope_config.json"));

// Get all users
var users = config["System"]["Users"];

foreach (var user in users)
{
    Console.WriteLine($"User: {user["Name"]}");
    Console.WriteLine($"Enabled: {user["Enabled"]}");
}
```

## Modifying Configuration

To write configuration back to the server:

```csharp
// 1. Read current config
GscRegistry registry = server.CreateRegistry();
registry.ReadNodes(...);

// 2. Find node to modify
GscRegNode userNode = registry.FindNode("/System/Users/MyUser");

// 3. Modify values
userNode.WriteBoolean("Enabled", false);
userNode.WriteWideString("Name", "New Name");

// 4. Write back to server
GscRegistryWriteRequest[] writeRequests = new GscRegistryWriteRequest[1];
writeRequests[0] = new GscRegistryWriteRequest("/System/Users/MyUser", 0);
registry.WriteNodes(writeRequests, true);  // true = save permanently
```

## API Documentation

See the GeViScope SDK documentation for detailed API reference:
- `C:\Program Files (x86)\GeViScopeSDK\Documentation\`
- Or: `C:\DEV\COPILOT\SOURCES\GeViScope_SDK_text\`

Key classes:
- `GscServer` - Server connection
- `GscRegistry` - Configuration registry
- `GscRegNode` - Individual configuration node
- `GscRegVariant` - Configuration value

## Troubleshooting

### "Failed to connect to server"

- Verify GeViScope server is running
- Check hostname/IP address
- Verify username and password
- Ensure firewall allows connection

### "Failed to create registry accessor"

- Server may not support registry API
- Try updating GeViScope server to latest version

### DLL not found errors

- Ensure GeViScope SDK is installed
- Check that DLL paths in .csproj are correct
- SDK should be at: `C:\Program Files (x86)\GeViScopeSDK\`

## Related Tools

- **GeViSetConfigWriter** (coming soon) - Write configuration to server
- **GeViSoftDBReader** (coming soon) - Read GeViSoft database directly

## License

This tool uses the Geutebruck GeViScope SDK. Refer to your GeViScope license agreement.
