fix (Happy Chuseok)

This commit is contained in:
Namhyeon Go 2024-09-17 22:22:46 +09:00
parent 775ffb924d
commit 9cdd9e85ed
4 changed files with 31 additions and 21 deletions

View File

@ -77,11 +77,12 @@ namespace WelsonJS.Service
{
clamAvConenctionString = this.parent.GetSettingsFileHandler().Read("CLAMAV_HOST", "Service");
}
catch (Exception)
catch (Exception ex)
{
clamAvConenctionString = "tcp://127.0.0.1:3310";
this.parent.Log($"Failed to read the address because of {ex.Message}. Set default: {clamAvConenctionString}");
}
Task.Run(ConnectToClamAv);
ConnectToClamAv().Start();
}
public void Start()
@ -208,7 +209,7 @@ namespace WelsonJS.Service
}
catch (Exception ex)
{
parent.Log($"Error processing event: {ex.Message}");
parent.Log($"Failed to process the event bacause of {ex.Message}.");
}
}
else
@ -229,11 +230,11 @@ namespace WelsonJS.Service
// Get ClamAV engine and virus database version
VersionResult result = await clamAvClient.GetVersionAsync().ConfigureAwait(false);
parent.Log($"ClamAV version - {result.ProgramVersion} , virus database version {result.VirusDbVersion}");
parent.Log($"ClamAV version {result.ProgramVersion}, Virus database version {result.VirusDbVersion}");
}
catch (Exception ex)
{
parent.Log($"Could not reach to ClamAV service: {clamAvConenctionString}, {ex.Message}");
parent.Log($"Failed to read the address because of {ex.Message}. {clamAvConenctionString}");
clamAvClient = null;
}
}

View File

@ -36,7 +36,7 @@ namespace WelsonJS.Service
catch (Exception ex)
{
serverAddress = "http://localhost:50051";
_parent.Log($"Failed to read the host address. {ex.Message} Use default value: {serverAddress}");
_parent.Log($"Failed to read the address because of {ex.Message}. Set default: {serverAddress}");
}
var httpClientHandler = new HttpClientHandler();

View File

@ -368,15 +368,19 @@ public class ScreenMatch
}
Point matchPosition = FindTemplate(_mainImage, (Bitmap)image.Clone(), out double maxCorrelation);
string text = "";
if (String.IsNullOrEmpty(sampleOnly) || (!String.IsNullOrEmpty(sampleOnly) && sampleOnly == filename))
{
text = InspectSample((Bitmap)mainImage.Clone(), matchPosition.X, matchPosition.Y, imageWidth, imageHeight, sampleWidth, sampleHeight);
}
if (matchPosition != Point.Empty)
{
string text = "";
if (String.IsNullOrEmpty(sampleOnly) || (!String.IsNullOrEmpty(sampleOnly) && sampleOnly == filename))
{
text = InspectSample((Bitmap)mainImage.Clone(), matchPosition, imageWidth, imageHeight, sampleWidth, sampleHeight);
}
else
{
parent.Log("Skipped inspect the image sample.");
}
results.Add(new ScreenMatchResult
{
FileName = image.Tag.ToString(),
@ -402,19 +406,24 @@ public class ScreenMatch
return results;
}
public string InspectSample(Bitmap bitmap, int x, int y, int a, int b, int w, int h)
public string InspectSample(Bitmap bitmap, Point matchPosition, int a, int b, int w, int h)
{
if (bitmap == null)
{
throw new ArgumentNullException(nameof(bitmap), "Bitmap cannot be null.");
}
if (matchPosition == null || matchPosition == Point.Empty)
{
throw new ArgumentNullException("matchPosition cannot be empty.");
}
// initial text
string text = "";
// Adjust coordinates
x = x + (a / 2);
y = y + (b / 2);
// Adjust coordinates
int x = matchPosition.X + (a / 2);
int y = matchPosition.Y + (b / 2);
// Set range of crop image
int cropX = Math.Max((x - w / 2) + sampleAdjustX, 0);

View File

@ -11,15 +11,15 @@ NONFREE_STRICT=false
DISABLE_HEARTBEAT=true
DISABLE_SCREEN_TIME=true
DISABLE_FILE_MONITOR=true
; example: window or screen
; window or screen
SCREEN_TIME_MODE=screen
; example: backward,save,sample_ocr,sample_clipboard,sample_width=128,sample_height=128,sample_adjust_x=0,sample_adjust_y=0,sample_only=,process_name=notepad.exe
; backward,save,sample_ocr,sample_clipboard,sample_width=128,sample_height=128,sample_adjust_x=0,sample_adjust_y=0,sample_only=,process_name=notepad.exe
SCREEN_TIME_PARAMS=
; Heartbeat service with gRPC
; default: http://localhost:50051
GRPC_HOST=http://localhost:50051
; TODO: WelsonJS event data export to Elasticsearch (or OpenSearch)
ES_HOST=http://localhost:9200
ES_USER=elastic
ES_PASSWORD=changeme
; TODO: Programmable anti-virus feature with ClamAV (Works on File Event Monitor)
; default: tcp://127.0.0.1:3310
CLAMAV_HOST=tcp://127.0.0.1:3310