add projects
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 13s

This commit is contained in:
2026-03-18 15:37:59 +03:00
parent ed55e77e98
commit bf51924adb
158 changed files with 82479 additions and 1 deletions
+23
View File
@@ -0,0 +1,23 @@
using LC_AddCheckToDb.Models;
using Microsoft.EntityFrameworkCore;
namespace LC_AddCheckToDb;
public partial class Db : DbContext
{
public Db() => Database.EnsureCreated();
public virtual DbSet<Error> Error { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
//optionsBuilder.UseNpgsql("Host=172.24.12.201;Port=5432;Database=Notifications;Username=postgres;Password=4NUDZhJ7");
optionsBuilder.UseSqlite("Data Source=C:\\Users\\mastankov\\Desktop\\ForMonitoring\\Soft\\LC_Api\\Error.db");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
+15
View File
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.5" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
</ItemGroup>
</Project>
+24
View File
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LC_AddCheckToDb.Models
{
internal class Cams
{
public string Id { get; set; }
public string Type { get; set; }
public string Ip { get; set; }
public string Access { get; set; }
public string ImgUrl { get; set; }
public string RecPoint { get; set; }
public string ChannelRec { get; set; }
public string SwitchConnect { get; set; }
public string SwitchPort { get; set; }
public string Name { get; set; }
public string Groupe { get; set; }
}
}
+34
View File
@@ -0,0 +1,34 @@
using System.ComponentModel.DataAnnotations;
using System.Reflection.Metadata;
namespace LC_AddCheckToDb.Models
{
public class Error
{
[Key]
public int Id { get; set; }
public typeDev TypeDev { get; set; }
public int? MsgId { get; set; }
public statusDev? Status { get; set; }
public string? Name { get; set; }
public string? Ip { get; set; }
public DateTime? DataError { get; set; }
}
public enum typeDev
{
Unknown = 0,
Camera,
SABRA,
vServer,
Server,
Switch,
DVR,
ARM
}
public enum statusDev
{
Off = 0,
On,
Unknown
}
}
+96
View File
@@ -0,0 +1,96 @@
using LC_AddCheckToDb.Models;
using Microsoft.VisualBasic.FileIO;
namespace LC_AddCheckToDb.Models
{
internal class Program
{
#if DEBUG
private static void Main()
{
string[] args = ["172.24.12.211", "неактивен"];
#else
private static void Main(string[] args)
{
if (args.Length == 0)
return;
#endif
List<Error> _error = new List<Error>();
using (var db = new Db())
{
var status = statusDev.Unknown;
var ip = args[0].Trim();
if (args[1].Trim().Contains("не"))
{
status = 0;
using (TextFieldParser parser = new TextFieldParser("spb_devices.csv"))
{
parser.TextFieldType = FieldType.Delimited;
parser.SetDelimiters(";");
while (!parser.EndOfData)
{
string[] fields = parser.ReadFields();
typeDev _type;
switch (fields[0])
{
case "Camera":
_type = typeDev.Camera;
break;
case "SABRA":
_type = typeDev.SABRA;
break;
case "vServer":
_type = typeDev.vServer;
break;
case "Server":
_type = typeDev.Server;
break;
case "Switch":
_type = typeDev.Switch;
break;
case "DVR":
_type = typeDev.DVR;
break;
case "ARM":
_type = typeDev.ARM;
break;
default:
_type = typeDev.Unknown;
break;
}
var I = new Error()
{
Id = 0,
Status = statusDev.On,
Name = fields[3],
Ip = fields[1],
MsgId = 0,
TypeDev = _type,
DataError = DateTime.Now.ToUniversalTime()
};
_error.Add(I);
}
}
var dev = _error.Where(d => d.Ip == args[0]).First();
dev.Status = status;
db.Error.Add(dev);
db.SaveChanges();
}
else
{
status = statusDev.On;
var dev = db.Error.Where(d => d.Ip == args[0] && d.Status == statusDev.Off).FirstOrDefault();
if (dev != null)
{
dev.Status = status;
db.Error.Update(dev);
db.SaveChanges();
}
}
}
Console.WriteLine("0");
}
}
}