Code: Select all
FUNCTION OPTIONS(*DIRECT)
BEGIN_COM ROLE(*EXTENDS £PRIM_FORM) CLIENTHEIGHT(194) CLIENTWIDTH(704) LEFT(556) TOP(265) WIDTH(720) HEIGHT(233) LAYOUTMANAGER(£LayoutMain)
DEFINE_COM CLASS(£PRIM_APPL.ICOMMONDIALOGFILEOPEN) NAME(£DialogFile1) REFERENCE(*DYNAMIC)
DEFINE_COM CLASS(£PRIM_APPL.ICOMMONDIALOGFILEOPEN) NAME(£DialogFile2) REFERENCE(*DYNAMIC)
DEFINE_COM CLASS(£PRIM_TBLO) NAME(£LayoutMain)
DEFINE_COM CLASS(£PRIM_TBLO.Column) NAME(£LayoutMainColumn1) DISPLAYPOSITION(1) PARENT(£LayoutMain)
DEFINE_COM CLASS(£PRIM_TBLO.Column) NAME(£LayoutMainColumn2) DISPLAYPOSITION(2) PARENT(£LayoutMain) UNITS(Pixels) WIDTH(128)
DEFINE_COM CLASS(£PRIM_TBLO.Row) NAME(£LayoutMainRow1) DISPLAYPOSITION(1) PARENT(£LayoutMain) HEIGHT(64) UNITS(Pixels)
DEFINE_COM CLASS(£PRIM_TBLO.Row) NAME(£LayoutMainRow2) DISPLAYPOSITION(2) PARENT(£LayoutMain) HEIGHT(64) UNITS(Pixels)
DEFINE_COM CLASS(£PRIM_TBLO.Row) NAME(£LayoutMainRow3) DISPLAYPOSITION(3) PARENT(£LayoutMain)
DEFINE_COM CLASS(£PRIM_TBLO.Item) NAME(£LayoutMainItem1) MANAGE(£Path1) PARENT(£LayoutMain) ROW(£LayoutMainRow1) SIZING(FitToWidth) COLUMN(£LayoutMainColumn1)
DEFINE_COM CLASS(£PRIM_TBLO.Item) NAME(£LayoutMainItem2) MANAGE(£Path2) PARENT(£LayoutMain) ROW(£LayoutMainRow2) SIZING(FitToWidth) COLUMN(£LayoutMainColumn1)
DEFINE_COM CLASS(£PRIM_TBLO.Item) NAME(£LayoutMainItem3) MANAGE(£Button1) PARENT(£LayoutMain) ROW(£LayoutMainRow1) SIZING(None) COLUMN(£LayoutMainColumn2) ALIGNMENT(CenterLeft)
DEFINE_COM CLASS(£PRIM_TBLO.Item) NAME(£LayoutMainItem4) MANAGE(£Button2) PARENT(£LayoutMain) ROW(£LayoutMainRow2) SIZING(None) COLUMN(£LayoutMainColumn2) ALIGNMENT(CenterLeft)
DEFINE_COM CLASS(£PRIM_TBLO.Item) NAME(£LayoutMainItem5) MANAGE(£Button3) PARENT(£LayoutMain) ROW(£LayoutMainRow3) SIZING(None) ALIGNMENT(TopLeft) COLUMN(£LayoutMainColumn1)
DEFINE_COM CLASS(£R_PATH.Visual) NAME(£Path1) COMPONENTVERSION(1) DISPLAYPOSITION(1) HEIGHT(21) PARENT(£COM_OWNER) TABPOSITION(1) TOP(22) USEPICKLIST(False) WIDTH(576)
DEFINE_COM CLASS(£R_PATH.Visual) NAME(£Path2) COMPONENTVERSION(1) DISPLAYPOSITION(2) HEIGHT(21) PARENT(£COM_OWNER) TABPOSITION(2) TOP(86) USEPICKLIST(False) WIDTH(576)
DEFINE_COM CLASS(£PRIM_PHBN) NAME(£Button1) CAPTION('File1') DISPLAYPOSITION(3) LEFT(576) PARENT(£COM_OWNER) TABPOSITION(3) TOP(20)
DEFINE_COM CLASS(£PRIM_PHBN) NAME(£Button2) DISPLAYPOSITION(4) LEFT(576) PARENT(£COM_OWNER) TABPOSITION(4) TOP(84) CAPTION('File2')
DEFINE_COM CLASS(£PRIM_PHBN) NAME(£Button3) DISPLAYPOSITION(5) LEFT(0) PARENT(£COM_OWNER) TABPOSITION(5) TOP(128) CAPTION('Compare')
MTHROUTINE NAME(um_HashFile)
DEFINE_MAP FOR(*INPUT) CLASS(£PRIM_ALPH) NAME(£p_Path)
DEFINE_MAP FOR(*RESULT) CLASS(£PRIM_ALPH) NAME(£p_Result)
DEFINE_COM CLASS(£XPRIM_Binary) NAME(£File)
DEFINE_COM CLASS(£XPRIM_Crypto_Hash) NAME(£Hash)
DEFINE_COM CLASS(£XPRIM_Binary) NAME(£CryptoResult)
DEFINE_COM CLASS(£XPRIM_ErrorInfo) NAME(£Error)
£p_Result := ""
£File.FromFile PATH(£p_Path) ERRORINFO(£Error)
IF (£Error.ok)
£Hash.UseSHA256
£Hash.Compute INPUT(£File) RESULT(£CryptoResult)
£p_Result := £CryptoResult.AsBase64String
ENDIF
ENDROUTINE
EVTROUTINE HANDLING(£Button1.Click)
£DialogFile1 <= £SYS_APPLN.CreateFileOPenDialog
£DialogFile1.Title := "Seleziona il primo file"
£DialogFile1.Show FORMOWNER(£COM_OWNER) OKPRESSED(£STD_BOOL)
IF (£STD_BOOL.AsBoolean)
£Path1 := £DialogFile1.File
ENDIF
ENDROUTINE
EVTROUTINE HANDLING(£Button2.Click)
£DialogFile2 <= £SYS_APPLN.CreateFileOPenDialog
£DialogFile2.Title := "Seleziona il secondo file"
£DialogFile2.Show FORMOWNER(£COM_OWNER) OKPRESSED(£STD_BOOL)
IF (£STD_BOOL.AsBoolean)
£Path2 := £DialogFile2.File
ENDIF
ENDROUTINE
EVTROUTINE HANDLING(£Button3.Click)
IF (£COM_OWNER.um_HashFile( £Path1 ) = £COM_OWNER.um_HashFile( £Path2 ))
£RETCODA := "OK"
ELSE
£RETCODA := "ER"
ENDIF
USE BUILTIN(OV_MESSAGE_BOX) WITH_ARGS(£RETCODA)
ENDROUTINE
END_COM