Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
vov4uk committed Jun 1, 2024
1 parent 727d182 commit 6c7a070
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 110 deletions.
Binary file modified HikConsole.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 27 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
| What | Badge|
| ---- | ---- |
| Build | [![Build Status](https://dev.azure.com/khmelovskyi/HikConsole/_apis/build/status/vov4uk.HikConsole?branchName=master)](https://dev.azure.com/khmelovskyi/HikConsole/_build/latest?definitionId=1&branchName=master)|
| Latest | [![GitHub (pre-)release](https://img.shields.io/github/v/release/vov4uk/HikConsole?include_prereleases)](https://github.com/vov4uk/HikConsole/releases)|
| Total| [![Github Releases](https://img.shields.io/github/downloads/vov4uk/HikConsole/total)](https://github.com/vov4uk/HikConsole/releases)|
| Sonar | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=vov4uk_HikConsole&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=vov4uk_HikConsole)|

# Hik.Client
* HikPhotoClient - Download photo files from Hikvision IP cameras.
* HikVideoClient - Download video files from Hikvision IP cameras.
* YiClient - Download files from Xiaomi YI cameras. Connect to camera over FTP, and download files.
* RSyncClient - Download and delete files from FTP server

# HikWeb
* Download photo/video files from Hikvision IP cameras.
# HikWeb - key features
* Download photo/video files from Hikvision & Dahua IP cameras.
* Download files from FTP/Yi camera
* Migrate files from one folder to another. Move and rename.
* Remove old files if low of space.
Expand All @@ -21,5 +13,30 @@
* Web UI to view status and statistics.
* Simple search and video playback (h264 supported)
* Job execution based on cron string.
* Logging options :
* SEQ
* Text file
* Console

# Implemented Job Types
* PhotoDownloaderJob
* Only HikVision IP cameras supported
* VideoDownloaderJob
* HikVision IP Camera
* Dahua IP Camera
* FTP Server (YI Home camera with [custom firmware](https://github.com/TheCrypt0/yi-hack-v4))
* FilesCollectorJob
* Move files from one folder to another
* GarbageCollectorJob
* Remove files older than n days
* Remove oldest files if less than n% of free space
________________________________________________________________________

* start from console
```
Hik.Web.exe --console
```

* start as windows server -> [click here](https://github.com/vov4uk/HikConsole/blob/master/src/Hik.Web/Build/install.bat)

![Alt text](HikConsole.png?raw=true "Output example")
2 changes: 1 addition & 1 deletion Tests/Hik.Web.Tests/Pages/TriggerModelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public async Task OnPostAsync_CreateNewTrigger_RedirectToConfigPage(string class

[Theory]
[InlineData("GarbageCollectorJob", "{\r\n \"RetentionPeriodDays\": -1,\r\n \"FreeSpacePercentage\": 0.0,\r\n \"Triggers\": [],\r\n \"FileExtention\": null,\r\n \"JobTimeoutMinutes\": 29,\r\n \"DestinationFolder\": null\r\n}")]
[InlineData("FilesCollectorJob", "{\r\n \"SourceFolder\": null,\r\n \"AbnormalFilesCount\": 0,\r\n \"FileNamePattern\": null,\r\n \"FileNameDateTimeFormat\": null,\r\n \"SkipLast\": 0,\r\n \"AllowedFileExtentions\": \"*.*;\",\r\n \"JobTimeoutMinutes\": 29,\r\n \"DestinationFolder\": null\r\n}")]
[InlineData("FilesCollectorJob", "{\r\n \"SourceFolder\": null,\r\n \"AbnormalFilesCount\": 0,\r\n \"FileNamePattern\": null,\r\n \"FileNameDateTimeFormat\": null,\r\n \"SkipLast\": 0,\r\n \"AllowedFileExtentions\": \".jpg;\",\r\n \"JobTimeoutMinutes\": 29,\r\n \"DestinationFolder\": null\r\n}")]
[InlineData("VideoDownloaderJob", "{\r\n \"ProcessingPeriodHours\": 0,\r\n \"Camera\": null,\r\n \"ClientType\": 0,\r\n \"SyncTime\": true,\r\n \"SyncTimeDeltaSeconds\": 5,\r\n \"RemotePath\": null,\r\n \"SaveFilesToRootFolder\": false,\r\n \"JobTimeoutMinutes\": 29,\r\n \"DestinationFolder\": null\r\n}")]
[InlineData("PhotoDownloaderJob", "{\r\n \"ProcessingPeriodHours\": 0,\r\n \"Camera\": null,\r\n \"ClientType\": 0,\r\n \"SyncTime\": true,\r\n \"SyncTimeDeltaSeconds\": 5,\r\n \"RemotePath\": null,\r\n \"SaveFilesToRootFolder\": false,\r\n \"JobTimeoutMinutes\": 29,\r\n \"DestinationFolder\": null\r\n}")]
public void OnGetConfigJson_ClassNameExist_ReturnConfig(string className, string expexted)
Expand Down
207 changes: 118 additions & 89 deletions src/Hik.DataAccess/db.dgml

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions src/Hik.Web/Build/install.bat
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
sc create Hik.Web binPath=C:\v4\Hik.Web.exe
sc failure Hik.Web actions= restart/60000/restart/60000/""/60000 reset= 86400
sc start Hik.Web
sc config Hik.Web start=auto


sc create DetectPeople binPath=C:\Detector\DetectPeople.Service.exe
sc failure DetectPeople actions= restart/60000/restart/60000/""/60000 reset= 86400
sc start DetectPeople
sc config DetectPeople start=auto
sc config Hik.Web start=auto
5 changes: 4 additions & 1 deletion src/Job/Email/EmailHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ static EmailHelper()
if (!Debugger.IsAttached)
{
string configPath = System.IO.Path.Combine(Environment.CurrentDirectory, "email.json");
Settings = Extensions.HikConfigExtensions.GetConfig<EmailConfig>(System.IO.File.ReadAllText(configPath));
if (System.IO.File.Exists(configPath))
{
Settings = Extensions.HikConfigExtensions.GetConfig<EmailConfig>(System.IO.File.ReadAllText(configPath));
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/Job/Extensions/HikConfigExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ public static T GetConfig<T>(string json)
{
if (!string.IsNullOrEmpty(json))
{
return JsonConvert.DeserializeObject<T>(json);
try
{
return JsonConvert.DeserializeObject<T>(json);
}
catch (Exception)
{
}
}
return default(T);
}
Expand Down
1 change: 0 additions & 1 deletion src/JobHost/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Hik.DataAccess;
using Hik.DTO.Config;
using Job;
using Job.Email;
using Microsoft.Extensions.Configuration;
using Serilog;
using System;
Expand Down

0 comments on commit 6c7a070

Please sign in to comment.