From c3c3278c17ee80eea901877f787cd30634df907b Mon Sep 17 00:00:00 2001 From: YPermitin Date: Sun, 10 May 2020 15:57:47 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=D1=8B=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B1?= =?UTF-8?q?=D0=B0=D0=B7=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20=D0=B2?= =?UTF-8?q?=D1=80=D1=83=D1=87=D0=BD=D1=83=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ля хранения данных журнала регистрации.sql | 156 ++++++++++++++++ ...ля хранения данных журнала регистрации.sql | 167 ++++++++++++++++++ YY.EventLogExportAssistant.sln | 6 + 3 files changed, 329 insertions(+) create mode 100644 Scripts/PostgreSQL. Скрипт создания базы для хранения данных журнала регистрации.sql create mode 100644 Scripts/SQL Server. Скрипт создания базы для хранения данных журнала регистрации.sql diff --git a/Scripts/PostgreSQL. Скрипт создания базы для хранения данных журнала регистрации.sql b/Scripts/PostgreSQL. Скрипт создания базы для хранения данных журнала регистрации.sql new file mode 100644 index 0000000..64f0fd3 --- /dev/null +++ b/Scripts/PostgreSQL. Скрипт создания базы для хранения данных журнала регистрации.sql @@ -0,0 +1,156 @@ +CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" ( + "MigrationId" character varying(150) NOT NULL, + "ProductVersion" character varying(32) NOT NULL, + CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId") +); + +CREATE TABLE "Applications" ( + "InformationSystemId" bigint NOT NULL, + "Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "Name" character varying(250) NULL, + CONSTRAINT "PK_Applications" PRIMARY KEY ("InformationSystemId", "Id") +); + +CREATE TABLE "Computers" ( + "InformationSystemId" bigint NOT NULL, + "Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "Name" character varying(250) NULL, + CONSTRAINT "PK_Computers" PRIMARY KEY ("InformationSystemId", "Id") +); + +CREATE TABLE "Events" ( + "InformationSystemId" bigint NOT NULL, + "Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "Name" character varying(250) NULL, + CONSTRAINT "PK_Events" PRIMARY KEY ("InformationSystemId", "Id") +); + +CREATE TABLE "InformationSystems" ( + "Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "Name" character varying(250) NULL, + "Description" character varying(500) NULL, + CONSTRAINT "PK_InformationSystems" PRIMARY KEY ("Id") +); + +CREATE TABLE "LogFiles" ( + "InformationSystemId" bigint NOT NULL, + "FileName" text NOT NULL, + "CreateDate" timestamp without time zone NOT NULL, + "Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "ModificationDate" timestamp without time zone NOT NULL, + "LastEventNumber" bigint NOT NULL, + "LastCurrentFileReferences" text NULL, + "LastCurrentFileData" text NULL, + "LastStreamPosition" bigint NULL, + CONSTRAINT "PK_LogFiles" PRIMARY KEY ("InformationSystemId", "FileName", "CreateDate", "Id") +); + +CREATE TABLE "Metadata" ( + "InformationSystemId" bigint NOT NULL, + "Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "Uuid" uuid NOT NULL, + "Name" character varying(250) NULL, + CONSTRAINT "PK_Metadata" PRIMARY KEY ("InformationSystemId", "Id") +); + +CREATE TABLE "PrimaryPorts" ( + "InformationSystemId" bigint NOT NULL, + "Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "Name" character varying(250) NULL, + CONSTRAINT "PK_PrimaryPorts" PRIMARY KEY ("InformationSystemId", "Id") +); + +CREATE TABLE "RowsData" ( + "InformationSystemId" bigint NOT NULL, + "Period" timestamp with time zone NOT NULL, + "Id" bigint NOT NULL, + "SeverityId" bigint NULL, + "ConnectId" bigint NULL, + "Session" bigint NULL, + "TransactionStatusId" bigint NULL, + "TransactionDate" timestamp without time zone NULL, + "TransactionId" bigint NULL, + "UserId" bigint NULL, + "ComputerId" bigint NULL, + "ApplicationId" bigint NULL, + "EventId" bigint NULL, + "Comment" text NULL, + "MetadataId" bigint NULL, + "Data" text NULL, + "DataUUID" text NULL, + "DataPresentation" text NULL, + "WorkServerId" bigint NULL, + "PrimaryPortId" bigint NULL, + "SecondaryPortId" bigint NULL, + CONSTRAINT "PK_RowsData" PRIMARY KEY ("InformationSystemId", "Period", "Id") +); + +CREATE TABLE "SecondaryPorts" ( + "InformationSystemId" bigint NOT NULL, + "Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "Name" character varying(250) NULL, + CONSTRAINT "PK_SecondaryPorts" PRIMARY KEY ("InformationSystemId", "Id") +); + +CREATE TABLE "Severities" ( + "InformationSystemId" bigint NOT NULL, + "Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "Name" character varying(250) NULL, + CONSTRAINT "PK_Severities" PRIMARY KEY ("InformationSystemId", "Id") +); + +CREATE TABLE "TransactionStatuses" ( + "InformationSystemId" bigint NOT NULL, + "Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "Name" character varying(250) NULL, + CONSTRAINT "PK_TransactionStatuses" PRIMARY KEY ("InformationSystemId", "Id") +); + +CREATE TABLE "Users" ( + "InformationSystemId" bigint NOT NULL, + "Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "Uuid" uuid NOT NULL, + "Name" character varying(250) NULL, + CONSTRAINT "PK_Users" PRIMARY KEY ("InformationSystemId", "Id") +); + +CREATE TABLE "WorkServers" ( + "InformationSystemId" bigint NOT NULL, + "Id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "Name" character varying(250) NULL, + CONSTRAINT "PK_WorkServers" PRIMARY KEY ("InformationSystemId", "Id") +); + +CREATE UNIQUE INDEX "IX_Applications_InformationSystemId_Id" ON "Applications" ("InformationSystemId", "Id"); + +CREATE UNIQUE INDEX "IX_Computers_InformationSystemId_Id" ON "Computers" ("InformationSystemId", "Id"); + +CREATE UNIQUE INDEX "IX_Events_InformationSystemId_Id" ON "Events" ("InformationSystemId", "Id"); + +CREATE UNIQUE INDEX "IX_InformationSystems_Id" ON "InformationSystems" ("Id"); + +CREATE UNIQUE INDEX "IX_LogFiles_InformationSystemId_FileName_CreateDate_Id" ON "LogFiles" ("InformationSystemId", "FileName", "CreateDate", "Id"); + +CREATE UNIQUE INDEX "IX_Metadata_InformationSystemId_Id" ON "Metadata" ("InformationSystemId", "Id"); + +CREATE UNIQUE INDEX "IX_PrimaryPorts_InformationSystemId_Id" ON "PrimaryPorts" ("InformationSystemId", "Id"); + +CREATE INDEX "IX_RowsData_InformationSystemId_DataUUID" ON "RowsData" ("InformationSystemId", "DataUUID"); + +CREATE UNIQUE INDEX "IX_RowsData_InformationSystemId_Period_Id" ON "RowsData" ("InformationSystemId", "Period", "Id"); + +CREATE INDEX "IX_RowsData_InformationSystemId_UserId_Period" ON "RowsData" ("InformationSystemId", "UserId", "Period"); + +CREATE UNIQUE INDEX "IX_SecondaryPorts_InformationSystemId_Id" ON "SecondaryPorts" ("InformationSystemId", "Id"); + +CREATE UNIQUE INDEX "IX_Severities_InformationSystemId_Id" ON "Severities" ("InformationSystemId", "Id"); + +CREATE UNIQUE INDEX "IX_TransactionStatuses_InformationSystemId_Id" ON "TransactionStatuses" ("InformationSystemId", "Id"); + +CREATE UNIQUE INDEX "IX_Users_InformationSystemId_Id" ON "Users" ("InformationSystemId", "Id"); + +CREATE UNIQUE INDEX "IX_WorkServers_InformationSystemId_Id" ON "WorkServers" ("InformationSystemId", "Id"); + +INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") +VALUES ('20200509202647_Initialization', '3.1.3'); + diff --git a/Scripts/SQL Server. Скрипт создания базы для хранения данных журнала регистрации.sql b/Scripts/SQL Server. Скрипт создания базы для хранения данных журнала регистрации.sql new file mode 100644 index 0000000..91842c3 --- /dev/null +++ b/Scripts/SQL Server. Скрипт создания базы для хранения данных журнала регистрации.sql @@ -0,0 +1,167 @@ +IF OBJECT_ID(N'[__EFMigrationsHistory]') IS NULL +BEGIN + CREATE TABLE [__EFMigrationsHistory] ( + [MigrationId] nvarchar(150) NOT NULL, + [ProductVersion] nvarchar(32) NOT NULL, + CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY ([MigrationId]) + ); +END; + +GO + +CREATE TABLE [Applications] ( + [InformationSystemId] bigint NOT NULL, + [Id] bigint NOT NULL IDENTITY, + [Name] nvarchar(250) NULL, + CONSTRAINT [PK_Applications] PRIMARY KEY ([InformationSystemId], [Id]) +); + +GO + +CREATE TABLE [Computers] ( + [InformationSystemId] bigint NOT NULL, + [Id] bigint NOT NULL IDENTITY, + [Name] nvarchar(250) NULL, + CONSTRAINT [PK_Computers] PRIMARY KEY ([InformationSystemId], [Id]) +); + +GO + +CREATE TABLE [Events] ( + [InformationSystemId] bigint NOT NULL, + [Id] bigint NOT NULL IDENTITY, + [Name] nvarchar(250) NULL, + CONSTRAINT [PK_Events] PRIMARY KEY ([InformationSystemId], [Id]) +); + +GO + +CREATE TABLE [InformationSystems] ( + [Id] bigint NOT NULL IDENTITY, + [Name] nvarchar(250) NULL, + [Description] nvarchar(500) NULL, + CONSTRAINT [PK_InformationSystems] PRIMARY KEY ([Id]) +); + +GO + +CREATE TABLE [LogFiles] ( + [InformationSystemId] bigint NOT NULL, + [FileName] nvarchar(450) NOT NULL, + [CreateDate] datetime2 NOT NULL, + [Id] bigint NOT NULL IDENTITY, + [ModificationDate] datetime2 NOT NULL, + [LastEventNumber] bigint NOT NULL, + [LastCurrentFileReferences] nvarchar(max) NULL, + [LastCurrentFileData] nvarchar(max) NULL, + [LastStreamPosition] bigint NULL, + CONSTRAINT [PK_LogFiles] PRIMARY KEY ([InformationSystemId], [FileName], [CreateDate], [Id]) +); + +GO + +CREATE TABLE [Metadata] ( + [InformationSystemId] bigint NOT NULL, + [Id] bigint NOT NULL IDENTITY, + [Uuid] uniqueidentifier NOT NULL, + [Name] nvarchar(250) NULL, + CONSTRAINT [PK_Metadata] PRIMARY KEY ([InformationSystemId], [Id]) +); + +GO + +CREATE TABLE [PrimaryPorts] ( + [InformationSystemId] bigint NOT NULL, + [Id] bigint NOT NULL IDENTITY, + [Name] nvarchar(250) NULL, + CONSTRAINT [PK_PrimaryPorts] PRIMARY KEY ([InformationSystemId], [Id]) +); + +GO + +CREATE TABLE [RowsData] ( + [InformationSystemId] bigint NOT NULL, + [Period] datetimeoffset NOT NULL, + [Id] bigint NOT NULL, + [SeverityId] bigint NULL, + [ConnectId] bigint NULL, + [Session] bigint NULL, + [TransactionStatusId] bigint NULL, + [TransactionDate] datetime2 NULL, + [TransactionId] bigint NULL, + [UserId] bigint NULL, + [ComputerId] bigint NULL, + [ApplicationId] bigint NULL, + [EventId] bigint NULL, + [Comment] nvarchar(max) NULL, + [MetadataId] bigint NULL, + [Data] nvarchar(max) NULL, + [DataUUID] nvarchar(450) NULL, + [DataPresentation] nvarchar(max) NULL, + [WorkServerId] bigint NULL, + [PrimaryPortId] bigint NULL, + [SecondaryPortId] bigint NULL, + CONSTRAINT [PK_RowsData] PRIMARY KEY ([InformationSystemId], [Period], [Id]) +); + +GO + +CREATE TABLE [SecondaryPorts] ( + [InformationSystemId] bigint NOT NULL, + [Id] bigint NOT NULL IDENTITY, + [Name] nvarchar(250) NULL, + CONSTRAINT [PK_SecondaryPorts] PRIMARY KEY ([InformationSystemId], [Id]) +); + +GO + +CREATE TABLE [Severities] ( + [InformationSystemId] bigint NOT NULL, + [Id] bigint NOT NULL IDENTITY, + [Name] nvarchar(250) NULL, + CONSTRAINT [PK_Severities] PRIMARY KEY ([InformationSystemId], [Id]) +); + +GO + +CREATE TABLE [TransactionStatuses] ( + [InformationSystemId] bigint NOT NULL, + [Id] bigint NOT NULL IDENTITY, + [Name] nvarchar(250) NULL, + CONSTRAINT [PK_TransactionStatuses] PRIMARY KEY ([InformationSystemId], [Id]) +); + +GO + +CREATE TABLE [Users] ( + [InformationSystemId] bigint NOT NULL, + [Id] bigint NOT NULL IDENTITY, + [Uuid] uniqueidentifier NOT NULL, + [Name] nvarchar(250) NULL, + CONSTRAINT [PK_Users] PRIMARY KEY ([InformationSystemId], [Id]) +); + +GO + +CREATE TABLE [WorkServers] ( + [InformationSystemId] bigint NOT NULL, + [Id] bigint NOT NULL IDENTITY, + [Name] nvarchar(250) NULL, + CONSTRAINT [PK_WorkServers] PRIMARY KEY ([InformationSystemId], [Id]) +); + +GO + +CREATE INDEX [IX_RowsData_InformationSystemId_DataUUID] ON [RowsData] ([InformationSystemId], [DataUUID]); + +GO + +CREATE INDEX [IX_RowsData_InformationSystemId_UserId_Period] ON [RowsData] ([InformationSystemId], [UserId], [Period]); + +GO + +INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) +VALUES (N'20200509202130_Initialization', N'3.1.3'); + +GO + diff --git a/YY.EventLogExportAssistant.sln b/YY.EventLogExportAssistant.sln index df6c1ec..8ba3323 100644 --- a/YY.EventLogExportAssistant.sln +++ b/YY.EventLogExportAssistant.sln @@ -40,6 +40,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YY.EventLogExportToSQLServe {2B04B71E-4785-401C-AED7-751A1C0B7DB1} = {2B04B71E-4785-401C-AED7-751A1C0B7DB1} EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scripts", "Scripts", "{AF6C4D18-9F7B-4E44-9531-A191AA6F725E}" + ProjectSection(SolutionItems) = preProject + Scripts\PostgreSQL. Скрипт создания базы для хранения данных журнала регистрации.sql = Scripts\PostgreSQL. Скрипт создания базы для хранения данных журнала регистрации.sql + Scripts\SQL Server. Скрипт создания базы для хранения данных журнала регистрации.sql = Scripts\SQL Server. Скрипт создания базы для хранения данных журнала регистрации.sql + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU