Заработала синхронизация с панели

This commit is contained in:
Фролов 2021-04-30 17:35:35 +05:00
parent fce20a2a10
commit 7d8974a8e5
25 changed files with 6021 additions and 96 deletions

View File

@ -9,6 +9,7 @@ namespace AsbCloudApp.Data
{ {
//[JsonPropertyName("date")] //[JsonPropertyName("date")]
public DateTime Date { get; set; } public DateTime Date { get; set; }
/// <summary> /// <summary>
/// Режим работы САУБ: /// Режим работы САУБ:
/// 0 - "РУЧНОЙ" /// 0 - "РУЧНОЙ"

View File

@ -1,6 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Text;
namespace AsbCloudApp.Data namespace AsbCloudApp.Data
{ {
@ -24,17 +22,17 @@ namespace AsbCloudApp.Data
/// Кол-во записей пропущеных с начала таблицы в запросе от api /// Кол-во записей пропущеных с начала таблицы в запросе от api
/// </summary> /// </summary>
public int Skip { get; set; } public int Skip { get; set; }
/// <summary> /// <summary>
/// Кол-во записей в запросе от api /// Кол-во записей в запросе от api
/// </summary> /// </summary>
public int Take { get; set; } public int Take { get; set; }
/// <summary> /// <summary>
/// Кол-во записей всего в таблице /// Кол-во записей всего в таблице
/// </summary> /// </summary>
public int Count { get; set; } public int Count { get; set; }
/// <summary> /// <summary>
/// Данные /// Данные
/// </summary> /// </summary>

View File

@ -1,9 +0,0 @@
namespace AsbCloudApp.Data
{
public class TelemetryDto<T>
{
public string HmiVersion { get; set; }
public T Payload { get; set; }
}
}

View File

@ -4,11 +4,12 @@ namespace AsbCloudApp.Data
{ {
public class TelemetryInfoDto public class TelemetryInfoDto
{ {
public DateTime Date { get; set; } public DateTime DrillingStartDate { get; set; }
public string TimeZoneId { get; set; } public string TimeZoneId { get; set; }
public double TimeZoneOffsetTotalHours { get; set; } public double TimeZoneOffsetTotalHours { get; set; }
public string Caption { get; set; } public string Well { get; set; }
public string Cluster { get; set; } public string Cluster { get; set; }
public string Customer { get; set; }
public string Deposit { get; set; } public string Deposit { get; set; }
public string HmiVersion { get; set; } public string HmiVersion { get; set; }
public string PlcVersion { get; set; } public string PlcVersion { get; set; }

View File

@ -8,15 +8,9 @@ namespace AsbCloudApp.Data
public class TelemetryMessageDto public class TelemetryMessageDto
{ {
public int Id { get; set; } public int Id { get; set; }
public DateTime Date { get; set; } public DateTime Date { get; set; }
public int IdEvent { get; set; } public int IdEvent { get; set; }
public int? State { get; set; }
public int? IdTelemetryUser { get; set; } public int? IdTelemetryUser { get; set; }
public string Arg0 { get; set; } public string Arg0 { get; set; }
public string Arg1 { get; set; } public string Arg1 { get; set; }
public string Arg2 { get; set; } public string Arg2 { get; set; }

View File

@ -26,9 +26,6 @@ namespace AsbCloudDb.Model
[Column("date", TypeName = "timestamp with time zone")] [Column("date", TypeName = "timestamp with time zone")]
public DateTime Date { get; set; } public DateTime Date { get; set; }
[Column("state"), Comment("1 - сработало событие. 0 - событие пропало.")]
public int? State { get; set; }
[Column("arg0"), Comment("Аргумент №0 для вставки в шаблон сообщения")] [Column("arg0"), Comment("Аргумент №0 для вставки в шаблон сообщения")]
[StringLength(255)] [StringLength(255)]
public string Arg0 { get; set; } public string Arg0 { get; set; }

View File

@ -1,16 +1,15 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
namespace AsbCloudDb.Model namespace AsbCloudDb.Model
{ {
public class TelemetryInfo public class TelemetryInfo
{ {
public DateTime Date { get; set; } public DateTime DrillingStartDate { get; set; }
public string TimeZoneId { get; set; } public string TimeZoneId { get; set; }
public double TimeZoneOffsetTotalHours { get; set; } public double TimeZoneOffsetTotalHours { get; set; }
public string Caption { get; set; } public string Well { get; set; }
public string Cluster { get; set; } public string Cluster { get; set; }
public string Customer { get; set; }
public string Deposit { get; set; } public string Deposit { get; set; }
public string HmiVersion { get; set; } public string HmiVersion { get; set; }
public string PlcVersion { get; set; } public string PlcVersion { get; set; }

View File

@ -48,7 +48,6 @@ namespace AsbCloudInfrastructure.Services
var messages = from m in db.Messages var messages = from m in db.Messages
where m.IdTelemetry == telemetry.Id where m.IdTelemetry == telemetry.Id
&& m.State == 1
select m; select m;
if ((categoryids != default) && (categoryids.Count() > 0)) if ((categoryids != default) && (categoryids.Count() > 0))
@ -63,7 +62,7 @@ namespace AsbCloudInfrastructure.Services
messages = messages.Where(m => eventIds.Contains(m.IdEvent)); messages = messages.Where(m => eventIds.Contains(m.IdEvent));
} }
var result = new PaginationContainer<MessageDto>() { Skip = skip, Take = take}; var result = new PaginationContainer<MessageDto>() { Skip = skip, Take = take };
messages = messages.OrderByDescending(m => m.Date); messages = messages.OrderByDescending(m => m.Date);
@ -117,6 +116,7 @@ namespace AsbCloudInfrastructure.Services
foreach (var dto in dtos) foreach (var dto in dtos)
{ {
var entity = mapper.Map<Message>(dto); var entity = mapper.Map<Message>(dto);
entity.Id = 0;
entity.IdTelemetry = telemetryId; entity.IdTelemetry = telemetryId;
db.Messages.Add(entity); db.Messages.Add(entity);
} }

View File

@ -24,7 +24,7 @@ namespace AsbCloudInfrastructure.Services
public int? GetWellIdByTelemetryUid(string uid) public int? GetWellIdByTelemetryUid(string uid)
=> GetWellByTelemetryUid(uid)?.Id; => GetWellByTelemetryUid(uid)?.Id;
public void UpdateInfo(string uid, TelemetryInfoDto info) public void UpdateInfo(string uid, TelemetryInfoDto info)
{ {
var telemetry = GetOrCreateTelemetryByUid(uid); var telemetry = GetOrCreateTelemetryByUid(uid);

View File

@ -1,7 +1,6 @@
using AsbCloudApp.Data; using AsbCloudApp.Data;
using AsbCloudApp.Services; using AsbCloudApp.Services;
using AsbCloudDb.Model; using AsbCloudDb.Model;
using AutoMapper;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -34,7 +34,7 @@ namespace AsbCloudWebApi.Controllers
[HttpGet] [HttpGet]
[Route("{wellId}/data")] [Route("{wellId}/data")]
[ProducesResponseType(typeof(IEnumerable<DataSaubBaseDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<DataSaubBaseDto>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult Get(int wellId, DateTime begin = default, int intervalSec = 600, int approxPointsCount = 1024) public IActionResult GetData(int wellId, DateTime begin = default, int intervalSec = 600, int approxPointsCount = 1024)
{ {
if (begin == default) if (begin == default)
begin = DateTime.Now.AddSeconds(-intervalSec); begin = DateTime.Now.AddSeconds(-intervalSec);

View File

@ -30,7 +30,7 @@ namespace AsbCloudWebApi.Controllers
[HttpGet] [HttpGet]
[Route("{wellId}/message")] [Route("{wellId}/message")]
[ProducesResponseType(typeof(PaginationContainer<MessageDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(PaginationContainer<MessageDto>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult Get(int wellId, [FromQuery] IEnumerable<int> categoryids = default, DateTime begin = default, DateTime end = default, int skip = 0, int take = 32) public IActionResult GetMessage(int wellId, int skip = 0, int take = 32, [FromQuery] IEnumerable<int> categoryids = default, DateTime begin = default, DateTime end = default)
{ {
if (take > 1024) if (take > 1024)
return BadRequest("limit mast be less then 1024"); return BadRequest("limit mast be less then 1024");

View File

@ -24,11 +24,11 @@ namespace AsbCloudWebApi.Controllers
private readonly IHubContext<TelemetryHub> telemetryHubContext; private readonly IHubContext<TelemetryHub> telemetryHubContext;
public TelemetryController( public TelemetryController(
ITelemetryService telemetryService, ITelemetryService telemetryService,
IDataService DataService, IDataService DataService,
IMessageService messageService, IMessageService messageService,
IEventService eventService, IEventService eventService,
ITelemetryUserService telemetryUserService, ITelemetryUserService telemetryUserService,
IHubContext<TelemetryHub> telemetryHubContext) IHubContext<TelemetryHub> telemetryHubContext)
{ {
this.DataService = DataService; this.DataService = DataService;
@ -47,7 +47,7 @@ namespace AsbCloudWebApi.Controllers
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("{uid}/info")] [Route("{uid}/info")]
public IActionResult Info(string uid, [FromBody] TelemetryInfoDto info) public IActionResult PostInfo(string uid, [FromBody] TelemetryInfoDto info)
{ {
telemetryService.UpdateInfo(uid, info); telemetryService.UpdateInfo(uid, info);
return Ok(); return Ok();
@ -61,7 +61,7 @@ namespace AsbCloudWebApi.Controllers
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("{uid}/data")] [Route("{uid}/data")]
public IActionResult Data(string uid, [FromBody] IEnumerable<DataSaubBaseDto> dtos) public IActionResult PostData(string uid, [FromBody] IEnumerable<DataSaubBaseDto> dtos)
{ {
var wellId = telemetryService.GetWellIdByTelemetryUid(uid); var wellId = telemetryService.GetWellIdByTelemetryUid(uid);
DataService.UpdateData(uid, dtos); DataService.UpdateData(uid, dtos);
@ -80,7 +80,7 @@ namespace AsbCloudWebApi.Controllers
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("{uid}/message")] [Route("{uid}/message")]
public IActionResult Message(string uid, [FromBody] IEnumerable<TelemetryMessageDto> dtos) public IActionResult PostMessages(string uid, [FromBody] IEnumerable<TelemetryMessageDto> dtos)
{ {
var wellId = telemetryService.GetWellIdByTelemetryUid(uid); var wellId = telemetryService.GetWellIdByTelemetryUid(uid);
messageService.Insert(uid, dtos); messageService.Insert(uid, dtos);
@ -99,7 +99,7 @@ namespace AsbCloudWebApi.Controllers
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("{uid}/event")] [Route("{uid}/event")]
public IActionResult Events(string uid, [FromBody] List<EventDto> events) public IActionResult PostEvents(string uid, [FromBody] List<EventDto> events)
{ {
eventService.Upsert(uid, events); eventService.Upsert(uid, events);
return Ok(); return Ok();
@ -113,10 +113,37 @@ namespace AsbCloudWebApi.Controllers
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("{uid}/user")] [Route("{uid}/user")]
public IActionResult Users(string uid, [FromBody] List<TelemetryUserDto> users) public IActionResult PostUsers(string uid, [FromBody] List<TelemetryUserDto> users)
{ {
telemetryUserService.Upsert(uid, users); telemetryUserService.Upsert(uid, users);
return Ok(); return Ok();
} }
/// <summary>
/// Загрузка архива (sqlite3).
/// <example>
/// var fileName = @"C:\temp\default.sqlite3";
/// var fileStream = System.IO.File.OpenRead(fileName);
/// var file = new FileParameter(fileStream, System.IO.Path.GetFileName(fileName));
/// cli.ApiTelemetryDbAsync("1", new List&lt;FileParameter&gt; { file }).Wait();
/// </example>
/// </summary>
/// <param name="uid"></param>
/// <param name="files"></param>
/// <returns></returns>
//[HttpPost]
//[Route("{uid}/db")]
//public IActionResult PostDb(string uid, IFormFileCollection files)
//{
// foreach (var file in files)
// {
// var fileName = string.IsNullOrEmpty(file.FileName)
// ? System.IO.Path.GetTempFileName()
// : file.FileName;
// using (var stream = System.IO.File.Create(fileName))
// file.CopyTo(stream);
// }
// return Ok();
//}
} }
} }

View File

@ -20,7 +20,7 @@ namespace AsbCloudWebApi.Controllers
[HttpGet] [HttpGet]
[ProducesResponseType(typeof(IEnumerable<WellDto>), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<WellDto>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult Get() public IActionResult GetWells()
{ {
var claimIdCustomer = User.FindFirst("IdCustomer"); var claimIdCustomer = User.FindFirst("IdCustomer");

View File

@ -0,0 +1,162 @@
{
"ProviderId": "Unchase.OpenAPI.ConnectedService",
"Version": "1.5.20.0",
"GettingStartedDocument": {
"Uri": "https://github.com/unchase/Unchase.OpenAPI.Connectedservice/"
},
"ExtendedData": {
"ServiceName": "OpenAPIService",
"GeneratedFileName": "OpenAPI",
"Endpoint": "https://localhost:5001/swagger/v1/swagger.json",
"GeneratedFileNamePrefix": null,
"GenerateCSharpClient": true,
"GenerateTypeScriptClient": false,
"GenerateCSharpController": false,
"OpenApiToCSharpClientCommand": {
"ClientBaseClass": null,
"ConfigurationClass": null,
"GenerateClientClasses": true,
"GenerateClientInterfaces": false,
"ClientBaseInterface": null,
"InjectHttpClient": true,
"DisposeHttpClient": true,
"ProtectedMethods": [],
"GenerateExceptionClasses": true,
"ExceptionClass": "ApiException",
"WrapDtoExceptions": true,
"UseHttpClientCreationMethod": false,
"HttpClientType": "System.Net.Http.HttpClient",
"UseHttpRequestMessageCreationMethod": false,
"UseBaseUrl": true,
"GenerateBaseUrlProperty": true,
"GenerateSyncMethods": false,
"GeneratePrepareRequestAndProcessResponseAsAsyncMethods": false,
"ExposeJsonSerializerSettings": false,
"ClientClassAccessModifier": "public",
"TypeAccessModifier": "public",
"GenerateContractsOutput": false,
"ContractsNamespace": null,
"ContractsOutputFilePath": null,
"ParameterDateTimeFormat": "s",
"ParameterDateFormat": "yyyy-MM-dd",
"GenerateUpdateJsonSerializerSettingsMethod": true,
"UseRequestAndResponseSerializationSettings": false,
"SerializeTypeInformation": false,
"QueryNullValue": "",
"ClassName": "{controller}Client",
"OperationGenerationMode": 1,
"AdditionalNamespaceUsages": [],
"AdditionalContractNamespaceUsages": [],
"GenerateOptionalParameters": false,
"GenerateJsonMethods": false,
"EnforceFlagEnums": false,
"ParameterArrayType": "System.Collections.Generic.IEnumerable",
"ParameterDictionaryType": "System.Collections.Generic.IDictionary",
"ResponseArrayType": "System.Collections.Generic.ICollection",
"ResponseDictionaryType": "System.Collections.Generic.IDictionary",
"WrapResponses": false,
"WrapResponseMethods": [],
"GenerateResponseClasses": true,
"ResponseClass": "SwaggerResponse",
"Namespace": "ConsoleApp1.OpenAPIService",
"RequiredPropertiesMustBeDefined": true,
"DateType": "System.DateTimeOffset",
"JsonConverters": null,
"AnyType": "object",
"DateTimeType": "System.DateTimeOffset",
"TimeType": "System.TimeSpan",
"TimeSpanType": "System.TimeSpan",
"ArrayType": "System.Collections.Generic.ICollection",
"ArrayInstanceType": "System.Collections.ObjectModel.Collection",
"DictionaryType": "System.Collections.Generic.IDictionary",
"DictionaryInstanceType": "System.Collections.Generic.Dictionary",
"ArrayBaseType": "System.Collections.ObjectModel.Collection",
"DictionaryBaseType": "System.Collections.Generic.Dictionary",
"ClassStyle": 0,
"JsonLibrary": 0,
"GenerateDefaultValues": true,
"GenerateDataAnnotations": true,
"ExcludedTypeNames": [],
"ExcludedParameterNames": [],
"HandleReferences": false,
"GenerateImmutableArrayProperties": false,
"GenerateImmutableDictionaryProperties": false,
"JsonSerializerSettingsTransformationMethod": null,
"InlineNamedArrays": false,
"InlineNamedDictionaries": false,
"InlineNamedTuples": true,
"InlineNamedAny": false,
"GenerateDtoTypes": true,
"GenerateOptionalPropertiesAsNullable": false,
"GenerateNullableReferenceTypes": false,
"TemplateDirectory": null,
"TypeNameGeneratorType": null,
"PropertyNameGeneratorType": null,
"EnumNameGeneratorType": null,
"ServiceHost": null,
"ServiceSchemes": null,
"output": "OpenAPI.cs",
"newLineBehavior": 0
},
"ExcludeTypeNamesLater": true,
"OpenApiToTypeScriptClientCommand": null,
"OpenApiToCSharpControllerCommand": null,
"Variables": null,
"Runtime": 0,
"CopySpecification": false,
"OpenGeneratedFilesOnComplete": false,
"UseRelativePath": false,
"ConvertFromOdata": false,
"OpenApiConvertSettings": {
"ServiceRoot": "http://localhost",
"Version": {
"Major": 1,
"Minor": 0,
"Build": 1,
"Revision": -1,
"MajorRevision": -1,
"MinorRevision": -1
},
"EnableKeyAsSegment": null,
"EnableUnqualifiedCall": false,
"EnableOperationPath": true,
"EnableOperationImportPath": true,
"EnableNavigationPropertyPath": true,
"TagDepth": 4,
"PrefixEntityTypeNameBeforeKey": false,
"OpenApiSpecVersion": 1,
"EnableOperationId": true,
"EnableUriEscapeFunctionCall": false,
"VerifyEdmModel": false,
"IEEE754Compatible": false,
"TopExample": 50,
"EnablePagination": false,
"PageableOperationName": "listMore",
"EnableDiscriminatorValue": false,
"EnableDerivedTypesReferencesForResponses": false,
"EnableDerivedTypesReferencesForRequestBody": false,
"PathPrefix": "OData",
"RoutePathPrefixProvider": {
"PathPrefix": "OData",
"Parameters": null
},
"ShowLinks": false,
"ShowSchemaExamples": false,
"RequireDerivedTypesConstraintForBoundOperations": false,
"ShowRootPath": false,
"ShowMsDosGroupPath": true,
"PathProvider": null
},
"OpenApiSpecVersion": 0,
"UseNetworkCredentials": false,
"NetworkCredentialsUserName": null,
"NetworkCredentialsPassword": null,
"NetworkCredentialsDomain": null,
"WebProxyUri": null,
"UseWebProxy": false,
"UseWebProxyCredentials": false,
"WebProxyNetworkCredentialsUserName": null,
"WebProxyNetworkCredentialsPassword": null,
"WebProxyNetworkCredentialsDomain": null
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,99 @@
{
"runtime": "NetCore21",
"defaultVariables": null,
"documentGenerator": {
"fromDocument": {
"url": "https://localhost:5001/swagger/v1/swagger.json",
"output": "OpenAPI.nswag.json",
"newLineBehavior": "Auto"
}
},
"codeGenerators": {
"openApiToCSharpClient": {
"clientBaseClass": null,
"configurationClass": null,
"generateClientClasses": true,
"generateClientInterfaces": false,
"clientBaseInterface": null,
"injectHttpClient": true,
"disposeHttpClient": true,
"protectedMethods": [],
"generateExceptionClasses": true,
"exceptionClass": "ApiException",
"wrapDtoExceptions": true,
"useHttpClientCreationMethod": false,
"httpClientType": "System.Net.Http.HttpClient",
"useHttpRequestMessageCreationMethod": false,
"useBaseUrl": true,
"generateBaseUrlProperty": true,
"generateSyncMethods": false,
"generatePrepareRequestAndProcessResponseAsAsyncMethods": false,
"exposeJsonSerializerSettings": false,
"clientClassAccessModifier": "public",
"typeAccessModifier": "public",
"generateContractsOutput": false,
"contractsNamespace": null,
"contractsOutputFilePath": null,
"parameterDateTimeFormat": "s",
"parameterDateFormat": "yyyy-MM-dd",
"generateUpdateJsonSerializerSettingsMethod": true,
"useRequestAndResponseSerializationSettings": false,
"serializeTypeInformation": false,
"queryNullValue": "",
"className": "{controller}Client",
"operationGenerationMode": "MultipleClientsFromPathSegments",
"additionalNamespaceUsages": [],
"additionalContractNamespaceUsages": [],
"generateOptionalParameters": false,
"generateJsonMethods": false,
"enforceFlagEnums": false,
"parameterArrayType": "System.Collections.Generic.IEnumerable",
"parameterDictionaryType": "System.Collections.Generic.IDictionary",
"responseArrayType": "System.Collections.Generic.ICollection",
"responseDictionaryType": "System.Collections.Generic.IDictionary",
"wrapResponses": false,
"wrapResponseMethods": [],
"generateResponseClasses": true,
"responseClass": "SwaggerResponse",
"namespace": "ConsoleApp1.OpenAPIService",
"requiredPropertiesMustBeDefined": true,
"dateType": "System.DateTimeOffset",
"jsonConverters": null,
"anyType": "object",
"dateTimeType": "System.DateTimeOffset",
"timeType": "System.TimeSpan",
"timeSpanType": "System.TimeSpan",
"arrayType": "System.Collections.Generic.ICollection",
"arrayInstanceType": "System.Collections.ObjectModel.Collection",
"dictionaryType": "System.Collections.Generic.IDictionary",
"dictionaryInstanceType": "System.Collections.Generic.Dictionary",
"arrayBaseType": "System.Collections.ObjectModel.Collection",
"dictionaryBaseType": "System.Collections.Generic.Dictionary",
"classStyle": "Poco",
"jsonLibrary": "NewtonsoftJson",
"generateDefaultValues": true,
"generateDataAnnotations": true,
"excludedTypeNames": [],
"excludedParameterNames": [],
"handleReferences": false,
"generateImmutableArrayProperties": false,
"generateImmutableDictionaryProperties": false,
"jsonSerializerSettingsTransformationMethod": null,
"inlineNamedArrays": false,
"inlineNamedDictionaries": false,
"inlineNamedTuples": true,
"inlineNamedAny": false,
"generateDtoTypes": true,
"generateOptionalPropertiesAsNullable": false,
"generateNullableReferenceTypes": false,
"templateDirectory": null,
"typeNameGeneratorType": null,
"propertyNameGeneratorType": null,
"enumNameGeneratorType": null,
"serviceHost": null,
"serviceSchemes": null,
"output": "OpenAPI.cs",
"newLineBehavior": "Auto"
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,9 @@
<PackageReference Include="AutoMapper" Version="10.1.1" /> <PackageReference Include="AutoMapper" Version="10.1.1" />
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" /> <PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="5.0.5" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="5.0.5" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -17,4 +20,8 @@
<ProjectReference Include="..\AsbCloudInfrastructure\AsbCloudInfrastructure.csproj" /> <ProjectReference Include="..\AsbCloudInfrastructure\AsbCloudInfrastructure.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services" />
</ItemGroup>
</Project> </Project>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,99 @@
{
"runtime": "NetCore21",
"defaultVariables": null,
"documentGenerator": {
"fromDocument": {
"url": "https://localhost:5001/swagger/v1/swagger.json",
"output": "AsbCloudApi.nswag.json",
"newLineBehavior": "Auto"
}
},
"codeGenerators": {
"openApiToCSharpClient": {
"clientBaseClass": null,
"configurationClass": null,
"generateClientClasses": true,
"generateClientInterfaces": false,
"clientBaseInterface": null,
"injectHttpClient": true,
"disposeHttpClient": true,
"protectedMethods": [],
"generateExceptionClasses": true,
"exceptionClass": "ApiException",
"wrapDtoExceptions": true,
"useHttpClientCreationMethod": false,
"httpClientType": "System.Net.Http.HttpClient",
"useHttpRequestMessageCreationMethod": false,
"useBaseUrl": true,
"generateBaseUrlProperty": true,
"generateSyncMethods": false,
"generatePrepareRequestAndProcessResponseAsAsyncMethods": false,
"exposeJsonSerializerSettings": false,
"clientClassAccessModifier": "public",
"typeAccessModifier": "public",
"generateContractsOutput": false,
"contractsNamespace": null,
"contractsOutputFilePath": null,
"parameterDateTimeFormat": "s",
"parameterDateFormat": "yyyy-MM-dd",
"generateUpdateJsonSerializerSettingsMethod": true,
"useRequestAndResponseSerializationSettings": false,
"serializeTypeInformation": false,
"queryNullValue": "",
"className": "{controller}Client",
"operationGenerationMode": "SingleClientFromPathSegments",
"additionalNamespaceUsages": [],
"additionalContractNamespaceUsages": [],
"generateOptionalParameters": false,
"generateJsonMethods": false,
"enforceFlagEnums": false,
"parameterArrayType": "System.Collections.Generic.IEnumerable",
"parameterDictionaryType": "System.Collections.Generic.IDictionary",
"responseArrayType": "System.Collections.Generic.ICollection",
"responseDictionaryType": "System.Collections.Generic.IDictionary",
"wrapResponses": false,
"wrapResponseMethods": [],
"generateResponseClasses": true,
"responseClass": "SwaggerResponse",
"namespace": "SyncDicts.AsbCloudApi",
"requiredPropertiesMustBeDefined": true,
"dateType": "System.DateTimeOffset",
"jsonConverters": null,
"anyType": "object",
"dateTimeType": "System.DateTimeOffset",
"timeType": "System.TimeSpan",
"timeSpanType": "System.TimeSpan",
"arrayType": "System.Collections.Generic.ICollection",
"arrayInstanceType": "System.Collections.ObjectModel.Collection",
"dictionaryType": "System.Collections.Generic.IDictionary",
"dictionaryInstanceType": "System.Collections.Generic.Dictionary",
"arrayBaseType": "System.Collections.ObjectModel.Collection",
"dictionaryBaseType": "System.Collections.Generic.Dictionary",
"classStyle": "Poco",
"jsonLibrary": "SystemTextJson",
"generateDefaultValues": true,
"generateDataAnnotations": true,
"excludedTypeNames": [],
"excludedParameterNames": [],
"handleReferences": false,
"generateImmutableArrayProperties": false,
"generateImmutableDictionaryProperties": false,
"jsonSerializerSettingsTransformationMethod": null,
"inlineNamedArrays": false,
"inlineNamedDictionaries": false,
"inlineNamedTuples": true,
"inlineNamedAny": false,
"generateDtoTypes": true,
"generateOptionalPropertiesAsNullable": false,
"generateNullableReferenceTypes": false,
"templateDirectory": null,
"typeNameGeneratorType": null,
"propertyNameGeneratorType": null,
"enumNameGeneratorType": null,
"serviceHost": null,
"serviceSchemes": null,
"output": "AsbCloudApi.cs",
"newLineBehavior": "Auto"
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,162 @@
{
"ProviderId": "Unchase.OpenAPI.ConnectedService",
"Version": "1.5.20.0",
"GettingStartedDocument": {
"Uri": "https://github.com/unchase/Unchase.OpenAPI.Connectedservice/"
},
"ExtendedData": {
"ServiceName": "AsbCloudApi",
"GeneratedFileName": "AsbCloudApi",
"Endpoint": "https://localhost:5001/swagger/v1/swagger.json",
"GeneratedFileNamePrefix": null,
"GenerateCSharpClient": true,
"GenerateTypeScriptClient": false,
"GenerateCSharpController": false,
"OpenApiToCSharpClientCommand": {
"ClientBaseClass": null,
"ConfigurationClass": null,
"GenerateClientClasses": true,
"GenerateClientInterfaces": false,
"ClientBaseInterface": null,
"InjectHttpClient": true,
"DisposeHttpClient": true,
"ProtectedMethods": [],
"GenerateExceptionClasses": true,
"ExceptionClass": "ApiException",
"WrapDtoExceptions": true,
"UseHttpClientCreationMethod": false,
"HttpClientType": "System.Net.Http.HttpClient",
"UseHttpRequestMessageCreationMethod": false,
"UseBaseUrl": true,
"GenerateBaseUrlProperty": true,
"GenerateSyncMethods": false,
"GeneratePrepareRequestAndProcessResponseAsAsyncMethods": false,
"ExposeJsonSerializerSettings": false,
"ClientClassAccessModifier": "public",
"TypeAccessModifier": "public",
"GenerateContractsOutput": false,
"ContractsNamespace": null,
"ContractsOutputFilePath": null,
"ParameterDateTimeFormat": "s",
"ParameterDateFormat": "yyyy-MM-dd",
"GenerateUpdateJsonSerializerSettingsMethod": true,
"UseRequestAndResponseSerializationSettings": false,
"SerializeTypeInformation": false,
"QueryNullValue": "",
"ClassName": "{controller}Client",
"OperationGenerationMode": 5,
"AdditionalNamespaceUsages": [],
"AdditionalContractNamespaceUsages": [],
"GenerateOptionalParameters": false,
"GenerateJsonMethods": false,
"EnforceFlagEnums": false,
"ParameterArrayType": "System.Collections.Generic.IEnumerable",
"ParameterDictionaryType": "System.Collections.Generic.IDictionary",
"ResponseArrayType": "System.Collections.Generic.ICollection",
"ResponseDictionaryType": "System.Collections.Generic.IDictionary",
"WrapResponses": false,
"WrapResponseMethods": [],
"GenerateResponseClasses": true,
"ResponseClass": "SwaggerResponse",
"Namespace": "SyncDicts.AsbCloudApi",
"RequiredPropertiesMustBeDefined": true,
"DateType": "System.DateTimeOffset",
"JsonConverters": null,
"AnyType": "object",
"DateTimeType": "System.DateTimeOffset",
"TimeType": "System.TimeSpan",
"TimeSpanType": "System.TimeSpan",
"ArrayType": "System.Collections.Generic.ICollection",
"ArrayInstanceType": "System.Collections.ObjectModel.Collection",
"DictionaryType": "System.Collections.Generic.IDictionary",
"DictionaryInstanceType": "System.Collections.Generic.Dictionary",
"ArrayBaseType": "System.Collections.ObjectModel.Collection",
"DictionaryBaseType": "System.Collections.Generic.Dictionary",
"ClassStyle": 0,
"JsonLibrary": 1,
"GenerateDefaultValues": true,
"GenerateDataAnnotations": true,
"ExcludedTypeNames": [],
"ExcludedParameterNames": [],
"HandleReferences": false,
"GenerateImmutableArrayProperties": false,
"GenerateImmutableDictionaryProperties": false,
"JsonSerializerSettingsTransformationMethod": null,
"InlineNamedArrays": false,
"InlineNamedDictionaries": false,
"InlineNamedTuples": true,
"InlineNamedAny": false,
"GenerateDtoTypes": true,
"GenerateOptionalPropertiesAsNullable": false,
"GenerateNullableReferenceTypes": false,
"TemplateDirectory": null,
"TypeNameGeneratorType": null,
"PropertyNameGeneratorType": null,
"EnumNameGeneratorType": null,
"ServiceHost": null,
"ServiceSchemes": null,
"output": "AsbCloudApi.cs",
"newLineBehavior": 0
},
"ExcludeTypeNamesLater": false,
"OpenApiToTypeScriptClientCommand": null,
"OpenApiToCSharpControllerCommand": null,
"Variables": null,
"Runtime": 0,
"CopySpecification": false,
"OpenGeneratedFilesOnComplete": false,
"UseRelativePath": false,
"ConvertFromOdata": false,
"OpenApiConvertSettings": {
"ServiceRoot": "http://localhost",
"Version": {
"Major": 1,
"Minor": 0,
"Build": 1,
"Revision": -1,
"MajorRevision": -1,
"MinorRevision": -1
},
"EnableKeyAsSegment": null,
"EnableUnqualifiedCall": false,
"EnableOperationPath": true,
"EnableOperationImportPath": true,
"EnableNavigationPropertyPath": true,
"TagDepth": 4,
"PrefixEntityTypeNameBeforeKey": false,
"OpenApiSpecVersion": 1,
"EnableOperationId": true,
"EnableUriEscapeFunctionCall": false,
"VerifyEdmModel": false,
"IEEE754Compatible": false,
"TopExample": 50,
"EnablePagination": false,
"PageableOperationName": "listMore",
"EnableDiscriminatorValue": false,
"EnableDerivedTypesReferencesForResponses": false,
"EnableDerivedTypesReferencesForRequestBody": false,
"PathPrefix": "OData",
"RoutePathPrefixProvider": {
"PathPrefix": "OData",
"Parameters": null
},
"ShowLinks": false,
"ShowSchemaExamples": false,
"RequireDerivedTypesConstraintForBoundOperations": false,
"ShowRootPath": false,
"ShowMsDosGroupPath": true,
"PathProvider": null
},
"OpenApiSpecVersion": 0,
"UseNetworkCredentials": false,
"NetworkCredentialsUserName": null,
"NetworkCredentialsPassword": null,
"NetworkCredentialsDomain": null,
"WebProxyUri": null,
"UseWebProxy": false,
"UseWebProxyCredentials": false,
"WebProxyNetworkCredentialsUserName": null,
"WebProxyNetworkCredentialsPassword": null,
"WebProxyNetworkCredentialsDomain": null
}
}

View File

@ -1,7 +1,5 @@
using AsbCloudApp.Data; using SyncDicts.AsbCloudApi;
using AsbSaubDbModel.V3; using System.Collections.Generic;
using System;
using System.Linq;
using System.Net; using System.Net;
using System.Text; using System.Text;
using System.Text.Json; using System.Text.Json;
@ -16,59 +14,69 @@ namespace SyncDicts
/// <param name="args"></param> /// <param name="args"></param>
static void Main(/*string[] args*/) static void Main(/*string[] args*/)
{ {
bool res; //bool res;
var context = new ArchiveDbContext(@"c:\temp\default.sqlite3"); //var context = new ArchiveDbContext(@"c:\temp\default.sqlite3");
// sync Events //// sync Events
var events = context.EventsDictionary.ToList() //var events = context.EventsDictionary.ToList()
.Select(e => new EventDto // .Select(e => new EventDto
{ // {
EventType = e.EventType, // EventType = e.EventType,
Id = e.Id, // Id = e.Id,
IdCategory = e.CategoryId, // IdCategory = e.CategoryId,
IdSound = e.SoundId, // IdSound = e.SoundId,
Message = e.MessageTemplate, // Message = e.MessageTemplate,
Tag = e.Tag, // Tag = e.Tag,
}); // });
var info = new TelemetryInfoDto //var info = new TelemetryInfoDto
{ //{
Caption = "скв 32", // Caption = "скв 111",
Deposit = "мр 2", // Deposit = "мр 111",
Cluster = "куст 22", // Cluster = "куст 111",
TimeZoneId = TimeZoneInfo.Local.Id, // TimeZoneId = TimeZoneInfo.Local.Id,
TimeZoneOffsetTotalHours = TimeZoneInfo.Local.BaseUtcOffset.TotalHours, // TimeZoneOffsetTotalHours = TimeZoneInfo.Local.BaseUtcOffset.TotalHours,
Date = DateTime.Now, // Date = DateTime.Now,
}; //};
var users = context.Users.ToList() //var users = context.Users.ToList()
.Select(u => new TelemetryUserDto // .Select(u => new TelemetryUserDto
{ // {
Id = u.Id, // Id = u.Id,
Level = u.Level, // Level = u.Level,
Name = u.Name, // Name = u.Name,
Patronymic = u.Patronymic, // Patronymic = u.Patronymic,
Surname = u.Surname, // Surname = u.Surname,
}); // });
var messages = context.Messages.Take(1024).ToList() //var messages = context.Messages.Take(1024).ToList()
.Select(m => new TelemetryMessageDto // .Select(m => new TelemetryMessageDto
{ // {
Id = m.Id, // Id = m.Id,
Date = DateTime.UnixEpoch.AddSeconds(m.TimeStamp), // Date = DateTime.UnixEpoch.AddSeconds(m.TimeStamp),
IdEvent = m.EventItemId, // IdEvent = m.EventItemId,
IdTelemetryUser = m.UserId, // IdTelemetryUser = m.UserId,
State = m.State, // State = m.State,
Arg0 = m.Arg0, // Arg0 = m.Arg0,
Arg1 = m.Arg1, // Arg1 = m.Arg1,
Arg2 = m.Arg2, // Arg2 = m.Arg2,
Arg3 = m.Arg3, // Arg3 = m.Arg3,
}); // });
var cli = new AsbCloudApi.Client("https://localhost:5001/", new System.Net.Http.HttpClient());
var fileName = @"C:\temp\default.sqlite3";
var fileStream = System.IO.File.OpenRead(fileName);
var file = new FileParameter(fileStream, System.IO.Path.GetFileName(fileName));
cli.ApiTelemetryDbAsync("1", new List<FileParameter> { file }).Wait();
//var cli = new swaggerClient("https://localhost:5001/", new System.Net.Http.HttpClient());
//cli.InfoAsync("aaa",info).Wait();
//res = Send("http://127.0.0.1:5000/api/telemetry/asdasd/event", events); //res = Send("http://127.0.0.1:5000/api/telemetry/asdasd/event", events);
//res = Send("http://127.0.0.1:5000/api/telemetry/asdasd/info", info); //res = Send("http://127.0.0.1:5000/api/telemetry/asdasd/info", info);
//res = Send("http://127.0.0.1:5000/api/telemetry/asdasd/user", users); //res = Send("http://127.0.0.1:5000/api/telemetry/asdasd/user", users);
res = Send("http://127.0.0.1:5000/api/telemetry/asdasd/message", messages); //res = Send("http://127.0.0.1:5000/api/telemetry/asdasd/message", messages);
} }
private static bool Send<T>(string url, T obj) private static bool Send<T>(string url, T obj)

View File

@ -8,6 +8,17 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.5" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.5" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.5" />
<PackageReference Include="Microsoft.Extensions.ApiDescription.Client" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NSwag.ApiDescription.Client" Version="13.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -20,4 +31,8 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services" />
</ItemGroup>
</Project> </Project>