consolidate all repos to one for archive

This commit is contained in:
2025-01-28 13:46:42 +01:00
commit a6610fbc7a
5350 changed files with 2705721 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

View File

@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

View File

@@ -0,0 +1,363 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

View File

@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33627.172
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Process_raw_camera_data", "Process_raw_camera_data\Process_raw_camera_data.csproj", "{27589C28-0F5A-4281-B02B-057ABCA97406}"
EndProject
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{91A3BAF3-C2FD-4D0C-8D97-90FFB4804E92}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{27589C28-0F5A-4281-B02B-057ABCA97406}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{27589C28-0F5A-4281-B02B-057ABCA97406}.Debug|Any CPU.Build.0 = Debug|Any CPU
{27589C28-0F5A-4281-B02B-057ABCA97406}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27589C28-0F5A-4281-B02B-057ABCA97406}.Release|Any CPU.Build.0 = Release|Any CPU
{91A3BAF3-C2FD-4D0C-8D97-90FFB4804E92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91A3BAF3-C2FD-4D0C-8D97-90FFB4804E92}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91A3BAF3-C2FD-4D0C-8D97-90FFB4804E92}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91A3BAF3-C2FD-4D0C-8D97-90FFB4804E92}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6E4C5048-946F-4208-9C6C-28099DD8D976}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,20 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["Process_raw_camera_data/Process_raw_camera_data.csproj", "Process_raw_camera_data/"]
RUN dotnet restore "Process_raw_camera_data/Process_raw_camera_data.csproj"
COPY . .
WORKDIR "/src/Process_raw_camera_data"
RUN dotnet build "Process_raw_camera_data.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Process_raw_camera_data.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Process_raw_camera_data.dll"]

View File

@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk;Microsoft.NET.Sdk.Publish">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,262 @@
using System.Timers;
using Timer = System.Timers.Timer;
using System.Text.Json;
using System.Text;
namespace Process_raw_camera_data
{
public class Root
{
public string? _id { get; set; }
public int location_id { get; set; }
public int camera_id { get; set; }
public DateTime date { get; set; }
public int car_count { get; set; }
public int hour { get; set; }
}
public class HourlyData
{
public int location_id { get; set; }
public DateTime date { get; set; }
public int car_count { get; set; }
public int hour { get; set; }
public int day { get; set; }
public int month { get; set; }
public int year { get; set; }
}
public class DailyData
{
public int location_id { get; set; }
public DateTime date { get; set; }
public int car_count { get; set; }
public int day { get; set; }
public int month { get; set; }
public int year { get; set; }
}
class Program
{
private static readonly HttpClient client = new HttpClient();
static Timer? hourTimer;
static Timer? dayTimer;
static DateTime hour = DateTime.Now;
static DateTime day = DateTime.Now;
#if DEBUG
static readonly string getHours = "http://localhost/api/data/year/{0}/month/{1}/day/{2}/location/{3}";
static readonly string sendDay = "http://localhost/api/dailyData";
static readonly string rawData = "http://localhost/api/rawCameraData";
static readonly string sendHour = "http://localhost/api/hourlyData";
static readonly string web = "http://localhost:3000";
#else
static readonly string getHours = "http://petrovv.com/api/data/year/{0}/month/{1}/day/{2}/location/{3}";
static readonly string sendDay = "http://petrovv.com/api/dailyData";
static readonly string rawData = "http://petrovv.com/api/rawCameraData";
static readonly string sendHour = "http://petrovv.com/api/hourlyData";
static readonly string web = "http://petrovv.com";
#endif
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Console.WriteLine(web);
// Create a timer with a 5 second interval.
hourTimer = new Timer(TimeSpan.FromHours(1).TotalMilliseconds);
hourTimer.Elapsed += OnHourEvent;
dayTimer = new Timer(TimeSpan.FromDays(1).TotalMilliseconds);
dayTimer.Elapsed += OnDayEvent;
while (DateTime.Now.Minute != 1)
{
Thread.Sleep(1000);
}
Console.WriteLine("HourTimerStart");
hour = DateTime.Now;
hour = hour.AddHours(-1);
hourTimer.Start();
OnHourEvent(null, null);
while (DateTime.Now.Hour != 1)
{
Thread.Sleep(1000);
}
Console.WriteLine("DayTimerStart");
day = DateTime.Now;
day = day.AddDays(-1);
dayTimer.Start();
OnDayEvent(null, null);
//OnTimedEvent();
// Stop Main from exiting
Console.ReadLine();
dayTimer.Stop();
dayTimer.Dispose();
hourTimer.Stop();
hourTimer.Dispose();
return;
}
private static async void OnDayEvent(object? sender, ElapsedEventArgs e)
{
Console.WriteLine("DayStart: " + day.Day);
for (int i = 0; i < 249; i++)
{
string url = String.Format(getHours, day.Year, day.Month, day.Day, i);
using HttpResponseMessage responseMessage = await client.GetAsync(url);
if (!responseMessage.IsSuccessStatusCode) return;
string response = await responseMessage.Content.ReadAsStringAsync();
//Console.WriteLine(response);
List<HourlyData>? hourlyData = JsonSerializer.Deserialize<List<HourlyData>>(response);
if (hourlyData == null)
{
Console.WriteLine("No data");
return;
}
int count = 0;
for (int j = 0; j < hourlyData.Count; j++)
{
count += hourlyData[j].car_count;
}
DateTime now = new(day.Year, day.Month, day.Day, 0, 0, 0);
DailyData processed = new()
{
location_id = i,
date = now,
car_count = count,
day = now.Day,
month = now.Month,
year = now.Year
};
string json = JsonSerializer.Serialize(processed);
var content = new StringContent(json, Encoding.UTF8, "application/json");
using HttpResponseMessage responseMessage2 = await client.PostAsync(sendDay, content);
if (!responseMessage2.IsSuccessStatusCode)
{
Console.WriteLine($"Error: {json}");
}
}
day = day.AddDays(1);
Console.WriteLine("Done");
}
private static async void OnHourEvent(object? sender, ElapsedEventArgs e)
{
Console.WriteLine("HourStart: " + hour.Hour);
int currentHour = hour.Hour;
using HttpResponseMessage responseMessage = await client.GetAsync(rawData);
if (!responseMessage.IsSuccessStatusCode) return;
string response = await responseMessage.Content.ReadAsStringAsync();
//Console.WriteLine(response);
List<Root>? rawCameraData = JsonSerializer.Deserialize<List<Root>>(response);
if (rawCameraData == null)
{
Console.WriteLine("No data");
return;
}
List<List<Root>> Locations = new();
for (int j = 0; j < 250; j++) Locations.Add(new List<Root>());
foreach (Root item in rawCameraData)
Locations[item.location_id].Add(item);
for (int i = 0; i < 249; i++)
{
List<List<Root>> Hour = new();
for (int j = 0; j < 24; j++)
Hour.Add(new List<Root>());
int maxCameras = 0;
foreach (Root item in Locations[i])
{
Hour[item.date.Hour].Add(item);
if(item.camera_id > maxCameras) maxCameras = item.camera_id;
}
maxCameras++;
int sum = 0;
foreach (Root item in Hour[hour.Hour])
{
sum += item.car_count;
}
sum /= maxCameras;
DateTime now = new(hour.Year, hour.Month, hour.Day, hour.Hour, 0, 0);
HourlyData processed = new()
{
location_id = i,
date = now,
car_count = sum,
hour = now.Hour,
day = now.Day,
month = now.Month,
year = now.Year
};
//send to api to save
string json = JsonSerializer.Serialize(processed);
var content = new StringContent(json, Encoding.UTF8, "application/json");
using HttpResponseMessage responseMessage2 = await client.PostAsync(sendHour, content);
if (!responseMessage2.IsSuccessStatusCode)
{
Console.WriteLine($"Error: {json}");
}
}
//send delete request to api
string deleteUrl = rawData + "/delete/" + currentHour;
using HttpResponseMessage responseMessage3 = await client.DeleteAsync(deleteUrl);
if (!responseMessage3.IsSuccessStatusCode)
{
Console.WriteLine($"Error: {deleteUrl}");
};
hour = hour.AddHours(1);
Console.WriteLine("Done");
}
}
}

View File

@@ -0,0 +1,10 @@
{
"profiles": {
"Process_raw_camera_data": {
"commandName": "Project"
},
"Docker": {
"commandName": "Docker"
}
}
}

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
<PropertyGroup Label="Globals">
<ProjectVersion>2.1</ProjectVersion>
<DockerTargetOS>Linux</DockerTargetOS>
<ProjectGuid>91a3baf3-c2fd-4d0c-8d97-90ffb4804e92</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<None Include="docker-compose.override.yml">
<DependentUpon>docker-compose.yml</DependentUpon>
</None>
<None Include="docker-compose.yml" />
<None Include=".dockerignore" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1 @@
version: '3.4'

View File

@@ -0,0 +1,8 @@
version: '3.4'
services:
process_raw_camera_data:
image: ${DOCKER_REGISTRY-}processrawcameradata
build:
context: .
dockerfile: Process_raw_camera_data/Dockerfile

View File

@@ -0,0 +1,11 @@
{
"profiles": {
"Docker Compose": {
"commandName": "DockerCompose",
"commandVersion": "1.0",
"serviceActions": {
"process_raw_camera_data": "StartDebugging"
}
}
}
}