Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

UPDATE GDIC SET APINAME = StartDate WHERE TABELA = 'HATENDIMENTOBASE' AND COLUNA = 'ABERTURA' -- Data de abertura do atendimento.'
UPDATE GDIC SET APINAME = ScheduleDate WHERE TABELA = 'HATENDIMENTOBASE' AND COLUNA = 'AGENDADOPARA' -- Data de agendamento.'
UPDATE GDIC SET APINAME = PreviousScheduleDate WHERE TABELA = 'HATENDIMENTOBASE' AND COLUNA = 'AGENDADOPARAANTERIOR' -- Data de agendamento anterior.'


3 - Consulta para gerar os campos a serem definidos no Schema.

Com isto alem da definição correta do nome já é gerado o preenchimento de tags de documentação bem como o tipo dos campos conforme definição da propria GDIC RM.

Bloco de código
languagesql
titleSchema JSon
DECLARE @NOMETABELA VARCHAR(MAX) = 'HATENDIMENTOARQUIVOSANEXOS'

SELECT cast( ',"'+GDIC.APINAME+
       '": {"description": "'+GDIC.DESCRICAO+
       '","type": '+
	   case c.name 
	     when 'int' then '"integer", "format": "int32"' 
	     when 'varchar' then '"string", "maxLength": "'+convert(varchar(5),b.length) +'"'
	     when 'decimal' then  '"number", "format":"double"'
		 when 'datetime' then '"string","format": "date-time"'
		 when 'smallint' then '"integer", "format": "int32"'
	     else '"string"' 
	   end+
	   ', "x-totvs": [{ "product": "RM", "field": "' + @NOMETABELA +'.'+GDIC.COLUNA+
	   '", "required": false,"type": '+
	   
	    case c.name 
	     when 'int' then '"integer"' 
	     when 'varchar' then '"varchar", "maxLength": "'+convert(varchar(5),b.length) +'"'
	     when 'decimal' then  '"decimal"'
		 when 'datetime' then '"datetime"'
		 when 'smallint' then '"smallint"'
	     else '"string"' 
	   end+
	   ',"note" : "", "available": true, "canUpdate": true}]}'as VarChar(Max)) campos

 FROM GDIC, SYSOBJECTS A, SYSCOLUMNS B, SYSTYPES C
WHERE GDIC.TABELA = @NOMETABELA
  AND GDIC.APINAME IS NOT NULL 
  AND A.NAME = GDIC.TABELA
  AND B.ID = A.ID
  AND B.NAME = GDIC.COLUNA
  AND C.XUSERTYPE = B.XTYPE

ORDER BY GDIC.COLUNA

Exemplo Resultado:

Bloco de código
languagejs
,"FileCode": {"description": "Código do arquivo","type": "integer", "format": "int32", "x-totvs": [{ "product": "RM", "field": "HATENDIMENTOARQUIVOSANEXOS.CODARQUIVO", "required": false,"type": "integer","note" : "", "available": true, "canUpdate": true}]}
,"AttendantCode": {"description": "Código do atendente","type": "integer", "format": "int32", "x-totvs": [{ "product": "RM", "field": "HATENDIMENTOARQUIVOSANEXOS.CODATENDENTE", "required": false,"type": "integer","note" : "", "available": true, "canUpdate"
,"AttendantInCurrentCode": {"description": "Atendente que alterou","type": "integer", "format": "int32", "x-totvs": [{ "product": "RM", "field": "HATENDIMENTOARQUIVOSANEXOS.CODATENDENTEATUAL", "required": false,"type": "integer","note" : "", "available": t
,"TicketCode": {"description": "Código do atendimento","type": "integer", "format": "int32", "x-totvs": [{ "product": "RM", "field": "HATENDIMENTOARQUIVOSANEXOS.CODATENDIMENTO", "required": false,"type": "integer","note" : "", "available": true, "canUpdate
,"CompanyCode": {"description": "Código da coligada","type": "integer", "format": "int32", "x-totvs": [{ "product": "RM", "field": "HATENDIMENTOARQUIVOSANEXOS.CODCOLIGADA", "required": false,"type": "smallint","note" : "", "available": true, "canUpdate": t
,"CompanyAttendantCurrentCode": {"description": "Coligada do atendente que alterou","type": "integer", "format": "int32", "x-totvs": [{ "product": "RM", "field": "HATENDIMENTOARQUIVOSANEXOS.CODCOLIGADAATENDATUAL", "required": false,"type": "smallint","note
,"CompanyAttendantCode": {"description": "Coligada do atendente","type": "integer", "format": "int32", "x-totvs": [{ "product": "RM", "field": "HATENDIMENTOARQUIVOSANEXOS.CODCOLIGADAATENDENTE", "required": false,"type": "smallint","note" : "", "available":
,"LocationCode": {"description": "Código do local","type": "integer", "format": "int32", "x-totvs": [{ "product": "RM", "field": "HATENDIMENTOARQUIVOSANEXOS.CODLOCAL", "required": false,"type": "integer","note" : "", "available": true, "canUpdate": true}]}
,"LastTicketChangeDate": {"description": "Data alteração","type": "string","format": "date-time", "x-totvs": [{ "product": "RM", "field": "HATENDIMENTOARQUIVOSANEXOS.DATAULTIMAALTERACAO", "required": false,"type": "datetime","note" : "", "available": true,
,"DetailsFile": {"description": "Detalhes do arquivo","type": "string", "maxLength": "255", "x-totvs": [{ "product": "RM", "field": "HATENDIMENTOARQUIVOSANEXOS.DETALHESARQUIVO", "required": false,"type": "varchar", "maxLength": "255","note" : "", "availabl
,"Name": {"description": "Nome do arquivo","type": "string", "maxLength": "255", "x-totvs": [{ "product": "RM", "field": "HATENDIMENTOARQUIVOSANEXOS.NOMEARQUIVO", "required": false,"type": "varchar", "maxLength": "255","note" : "", "available": true, "canU
,"CreatedUserCode": {"description": "Usuário criador do registro","type": "string", "maxLength": "50", "x-totvs": [{ "product": "RM", "field": "HATENDIMENTOARQUIVOSANEXOS.RECCREATEDBY", "required": false,"type": "varchar", "maxLength": "50","note" : "", "a
,"ModifiedDate": {"description": "Data de criação do registro","type": "string","format": "date-time", "x-totvs": [{ "product": "RM", "field": "HATENDIMENTOARQUIVOSANEXOS.RECCREATEDON", "required": false,"type": "datetime","note" : "", "available": true, "
,"ModifiedUserCode": {"description": "Autor da última modificação no registro","type": "string", "maxLength": "50", "x-totvs": [{ "product": "RM", "field": "HATENDIMENTOARQUIVOSANEXOS.RECMODIFIEDBY", "required": false,"type": "varchar", "maxLength": "50","
,"ModifiedDate": {"description": "Data da última modificação no registro","type": "string","format": "date-time", "x-totvs": [{ "product": "RM", "field": "HATENDIMENTOARQUIVOSANEXOS.RECMODIFIEDON", "required": false,"type": "datetime","note" : "", "availab
,"size": {"description": "Tamanho do arquivo","type": "string", "x-totvs": [{ "product": "RM", "field": "HATENDIMENTOARQUIVOSANEXOS.TAMANHOARQUIVO", "required": false,"type": "string","note" : "", "available": true, "canUpdate": true}]}
,"Status": {"description": "Status","type": "string", "maxLength": "20", "x-totvs": [{ "product": "RM", "field": "HATENDIMENTOARQUIVOSANEXOS.TIPOALTERACAO", "required": false,"type": "varchar", "maxLength": "20","note" : "", "available": true, "canUpdate":

4 - Consulta que gera a classe referente ao Schema da API.

Bloco de código
languagesql
SELECT  char(10)+'///'+char(10)+ '/// '+ GDIC.DESCRICAO + ' - '+ GDIC.COLUNA + char(10)+ '///'
        +char(10)+'public '+
	    case c.name 
	     when 'int' then 'int' 
	     when 'varchar' then 'string'
	     when 'decimal' then  'decimal'
		 when 'datetime' then 'DateTime'
		 when 'smallint' then 'short'
	     else '"string"' 
	   end + ' ' + GDIC.APINAME -- concat(Upper(substring (GDIC.APINAME, 1,1)), lower(substring(GDIC.COLUNA, 2,len(GDIC.COLUNA))))
	   + ' { get; set; } ' as prop

 FROM GDIC, SYSOBJECTS A, SYSCOLUMNS B, SYSTYPES C
WHERE GDIC.TABELA = 'HATENDIMENTOBASE' 
  AND GDIC.APINAME IS NOT NULL 
  AND A.NAME = GDIC.TABELA
  AND B.ID = A.ID
  AND B.NAME = GDIC.COLUNA
  AND C.XUSERTYPE = B.XTYPE

ORDER BY GDIC.COLUNA

Exemplo de resultado gerado:

Bloco de código
languagejs
/// <summary>
/// Autor da última modificação no registro - RECMODIFIEDBY
/// </summary>
public string ModifiedUserCode { get; set; } 

/// <summary>
/// Data da última modificação no registro - RECMODIFIEDON
/// </summary>
public DateTime ModifiedDate { get; set; } 

/// <summary>
/// Tamanho do arquivo - TAMANHOARQUIVO
/// </summary>
public string size { get; set; } 

/// <summary>
/// Status - TIPOALTERACAO
/// </summary>
public string Status { get; set; } 

5 - Gerar código de atribuição dos captions do props necessário para API.

SELECT '// '+gdic.coluna, ' , ColProps.ApiName, "'+gdic.apiname+'"); //donotlocalize' FROM GDIC WHERE TABELA = 'HATENDIMENTOARQUIVOSANEXOS' AND APINAME IS NOT NULLExecutar o WinFormativus