-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(cherry picked from commit 9a7a6ecc3e59179971fd5e47bdc516a583c71861)
- Loading branch information
Rodrigo Cesar
committed
May 20, 2024
1 parent
2da1105
commit f486755
Showing
7 changed files
with
261 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | ||
|
||
name: C# CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
working-directory: ./lib/csharp-models-to-json_test | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: 8.0.x | ||
- name: Restore dependencies | ||
run: dotnet restore | ||
- name: Build | ||
run: dotnet build --no-restore | ||
- name: Test | ||
run: dotnet test --no-build --verbosity normal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | ||
|
||
name: Node.js CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [16.x, 20.x] | ||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
- run: npm ci | ||
- run: npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Runtime.Serialization; | ||
using FG.Sitrad.Common.Enum; | ||
|
||
namespace FG.Sitrad.Model | ||
{ | ||
[DataContract] | ||
[DebuggerDisplay("{AlarmCode}")] | ||
public class AlarmOccurrence : ICloneable | ||
{ | ||
#region Propriedades adicionais | ||
|
||
/// <summary> | ||
/// Utilizado para verificar se é preciso salvar o objeto ao final do processamento de alarmes. | ||
/// </summary> | ||
[IgnoreDataMember] | ||
public bool IsSavePending { get; set; } | ||
|
||
[IgnoreDataMember] | ||
public AlarmInhibitionType PreviousInhibitionType = AlarmInhibitionType.Undefined; | ||
|
||
[IgnoreDataMember] | ||
public AlarmInhibitionType inhibitionType = AlarmInhibitionType.Undefined; | ||
|
||
#endregion | ||
|
||
|
||
|
||
#region Campos do banco de dados | ||
|
||
[DataMember] | ||
public int Id { get; set; } | ||
|
||
[DataMember] | ||
public int InstrumentId { get; set; } | ||
|
||
[DataMember] | ||
public string AlarmCode { get; set; } | ||
|
||
[DataMember] | ||
public string Description { get; set; } | ||
|
||
[DataMember(EmitDefaultValue = false)] | ||
public string Value { get; set; } | ||
|
||
[DataMember] | ||
public DateTime OccurrenceDate { get; set; } | ||
|
||
[DataMember(EmitDefaultValue = false)] | ||
public DateTime? OccurrenceFinalDate { get; set; } | ||
|
||
[DataMember(EmitDefaultValue = false)] | ||
public DateTime? AcknowledgeTime { get; set; } | ||
|
||
[DataMember(EmitDefaultValue = false)] | ||
public int? AcknowledgeUserId { get; set; } | ||
|
||
[DataMember(EmitDefaultValue = false)] | ||
public string AcknowledgeUserName { get; set; } | ||
|
||
[DataMember] | ||
public AlarmInhibitionType InhibitionType | ||
{ | ||
get => inhibitionType; | ||
set | ||
{ | ||
PreviousInhibitionType = inhibitionType; | ||
inhibitionType = value; | ||
} | ||
} | ||
|
||
[DataMember(EmitDefaultValue = false)] | ||
public bool Inhibited { get; set; } | ||
|
||
[IgnoreDataMember] | ||
public DateTime? DelayEndDate { get; set; } | ||
|
||
[DataMember(EmitDefaultValue = false)] | ||
public int? EventLogId { get; set; } | ||
|
||
[DataMember(EmitDefaultValue = false)] | ||
public EventLog EventLog { get; set; } | ||
|
||
[DataMember(EmitDefaultValue = false)] | ||
public int? AcknowledgeEventLogId { get; set; } | ||
|
||
[DataMember(EmitDefaultValue = false)] | ||
public bool OccurringOrUnacknowledged { get; private set; } | ||
|
||
[DataMember(EmitDefaultValue = false)] | ||
public EventLog AcknowledgeEventLog { get; set; } | ||
|
||
[DataMember(EmitDefaultValue = false)] | ||
public Instrument Instrument { get; set; } | ||
|
||
[IgnoreDataMember] | ||
public User AcknowledgeUser { get; set; } | ||
|
||
[DataMember] | ||
public IList<AlarmNotificationType> IgnoredTo { get; set; } | ||
|
||
#endregion | ||
|
||
|
||
|
||
#region IClonable | ||
|
||
public object Clone() | ||
{ | ||
var occurrence = new AlarmOccurrence(); | ||
CloneTo(ref occurrence); | ||
return occurrence; | ||
} | ||
|
||
public void CloneTo(ref AlarmOccurrence alarmOccurrence) | ||
{ | ||
alarmOccurrence.Id = Id; | ||
alarmOccurrence.AlarmCode = AlarmCode; | ||
alarmOccurrence.Description = Description; | ||
alarmOccurrence.Value = Value; | ||
alarmOccurrence.OccurrenceDate = OccurrenceDate; | ||
alarmOccurrence.OccurrenceFinalDate = OccurrenceFinalDate; | ||
alarmOccurrence.AcknowledgeTime = AcknowledgeTime; | ||
alarmOccurrence.InhibitionType = InhibitionType; | ||
alarmOccurrence.Inhibited = Inhibited; | ||
alarmOccurrence.EventLog = EventLog; | ||
alarmOccurrence.EventLogId = EventLogId; | ||
alarmOccurrence.AcknowledgeEventLog = AcknowledgeEventLog; | ||
alarmOccurrence.AcknowledgeEventLogId = AcknowledgeEventLogId; | ||
alarmOccurrence.InstrumentId = InstrumentId; | ||
alarmOccurrence.Instrument = Instrument; | ||
alarmOccurrence.AcknowledgeUser = AcknowledgeUser; | ||
alarmOccurrence.AcknowledgeUserId = AcknowledgeUserId; | ||
alarmOccurrence.AcknowledgeUserName = AcknowledgeUserName; | ||
alarmOccurrence.IgnoredTo = IgnoredTo; | ||
alarmOccurrence.IsSavePending = IsSavePending; | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"include": [ | ||
"test-files/*.cs" | ||
], | ||
"exclude": [ ], | ||
"output": "./test-files/api.d.ts", | ||
"camelCase": false, | ||
"camelCaseEnums": false, | ||
"camelCaseOptions": { | ||
"pascalCase": false, | ||
"preserveConsecutiveUppercase": false, | ||
"locale": "en-US" | ||
}, | ||
"includeComments": true, | ||
"numericEnums": true, | ||
"omitSemicolon": true, | ||
"omitFilePathComment": true, | ||
"stringLiteralTypesInsteadOfEnums": false, | ||
"customTypeTranslations": { | ||
"ProductName": "string", | ||
"ProductNumber": "string", | ||
"byte": "number", | ||
"uint": "number" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const fs = require('fs'); | ||
|
||
const configArg = process.argv.find(x => x.startsWith('--config=')); | ||
|
||
if (!configArg) { | ||
throw Error('No configuration file for `csharp-models-to-typescript` provided.'); | ||
} | ||
|
||
const configPath = configArg.substr('--config='.length); | ||
let config; | ||
|
||
try { | ||
unparsedConfig = fs.readFileSync(configPath, 'utf8'); | ||
} catch (error) { | ||
throw Error(`Configuration file "${configPath}" not found.\n${error.message}`); | ||
} | ||
|
||
try { | ||
config = JSON.parse(unparsedConfig); | ||
} catch (error) { | ||
throw Error(`Configuration file "${configPath}" contains invalid JSON.\n${error.message}`); | ||
} | ||
|
||
const output = config.output || 'types.d.ts'; | ||
|
||
if (!fs.existsSync(output)) | ||
throw Error(`Can't find output file: ${output}`) | ||
|
||
const file = fs.readFileSync(output, 'utf8') | ||
if (file.length === 0) | ||
throw Error(`File '${output}' is empty`) |