Commit inicial: fuentes MBS ERP (Genero 6) + .gitignore + docs/SETUP_PC_MBS.md
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -0,0 +1,16 @@
|
||||
@rem
|
||||
@rem FOURJS_START_COPYRIGHT(U,2000)
|
||||
@rem Property of Four Js*
|
||||
@rem (c) Copyright Four Js 2000, 2021. All Rights Reserved.
|
||||
@rem * Trademark of Four Js Development Tools Europe Ltd
|
||||
@rem in the United States and elsewhere
|
||||
@rem
|
||||
@rem Four Js and its suppliers do not warrant or guarantee that these samples
|
||||
@rem are accurate and suitable for your purposes. Their inclusion is purely for
|
||||
@rem information purposes only.
|
||||
@rem FOURJS_END_COPYRIGHT
|
||||
@rem
|
||||
|
||||
fglcomp calculatorServer.4gl
|
||||
fglform server.per
|
||||
call fgllink -o CalculatorServer.42r calculatorServer.42m
|
||||
@@ -0,0 +1,290 @@
|
||||
#
|
||||
# FOURJS_START_COPYRIGHT(U,2000)
|
||||
# Property of Four Js*
|
||||
# (c) Copyright Four Js 2000, 2021. All Rights Reserved.
|
||||
# * Trademark of Four Js Development Tools Europe Ltd
|
||||
# in the United States and elsewhere
|
||||
#
|
||||
# Four Js and its suppliers do not warrant or guarantee that these samples
|
||||
# are accurate and suitable for your purposes. Their inclusion is purely for
|
||||
# information purposes only.
|
||||
# FOURJS_END_COPYRIGHT
|
||||
#
|
||||
|
||||
IMPORT com
|
||||
|
||||
#
|
||||
# USER GLOBALS VARIABLES
|
||||
#
|
||||
|
||||
GLOBALS
|
||||
DEFINE
|
||||
add_in RECORD
|
||||
a INTEGER,
|
||||
b INTEGER
|
||||
END RECORD,
|
||||
add_out RECORD
|
||||
r INTEGER
|
||||
END RECORD
|
||||
|
||||
DEFINE
|
||||
subtract_in RECORD
|
||||
a INTEGER,
|
||||
b INTEGER
|
||||
END RECORD,
|
||||
subtract_out RECORD
|
||||
r INTEGER
|
||||
END RECORD
|
||||
|
||||
DEFINE
|
||||
multiply_in RECORD
|
||||
a INTEGER,
|
||||
b INTEGER
|
||||
END RECORD,
|
||||
multiply_out RECORD
|
||||
r INTEGER
|
||||
END RECORD
|
||||
|
||||
DEFINE
|
||||
divide_in RECORD
|
||||
a INTEGER,
|
||||
b INTEGER
|
||||
END RECORD,
|
||||
divide_out RECORD
|
||||
quotient INTEGER,
|
||||
remainder INTEGER
|
||||
END RECORD
|
||||
|
||||
DEFINE
|
||||
divide_by_zero String ATTRIBUTES (XMLName="DividedByZero")
|
||||
|
||||
END GLOBALS
|
||||
|
||||
DEFINE serverURL STRING
|
||||
DEFINE screen BOOLEAN
|
||||
|
||||
&define display_status(status) \
|
||||
IF NOT screen THEN \
|
||||
DISPLAY status \
|
||||
ELSE \
|
||||
DISPLAY status TO MSG \
|
||||
MENU ON idle 1 EXIT MENU ON ACTION close EXIT PROGRAM END MENU \
|
||||
END IF
|
||||
|
||||
#
|
||||
# MAIN
|
||||
#
|
||||
MAIN
|
||||
DEFINE ret INTEGER
|
||||
|
||||
DEFER INTERRUPT
|
||||
|
||||
LET screen = false
|
||||
#
|
||||
# Check arguments
|
||||
#
|
||||
IF num_args() = 2 and arg_val(1) = "-W" THEN
|
||||
LET serverURL = arg_val(2)
|
||||
CALL CreateCalculatorService(true)
|
||||
EXIT PROGRAM
|
||||
ELSE
|
||||
IF num_args() = 2 and arg_val(1) = "-S" THEN
|
||||
LET screen = true
|
||||
CALL fgl_setenv("FGLAPPSERVER",arg_val(2))
|
||||
CLOSE WINDOW SCREEN
|
||||
OPEN WINDOW w WITH FORM "server" ATTRIBUTES(TEXT = "Calculator service", STYLE="naked")
|
||||
display_status("Calculator service startup")
|
||||
ELSE
|
||||
IF num_args() <> 0 THEN
|
||||
CALL exitHelp()
|
||||
EXIT PROGRAM
|
||||
END IF
|
||||
END IF
|
||||
END IF
|
||||
|
||||
#
|
||||
# Create Calculator service
|
||||
#
|
||||
CALL CreateCalculatorService(false)
|
||||
|
||||
#
|
||||
# Start the server
|
||||
#
|
||||
display_status("Starting server...")
|
||||
#
|
||||
# Starts the server on the port number specified by the FGLAPPSERVER environment variable
|
||||
# (EX: FGLAPPSERVER=8090)
|
||||
#
|
||||
CALL com.WebServiceEngine.Start()
|
||||
display_status("The server is listening.")
|
||||
|
||||
IF screen THEN
|
||||
MENU
|
||||
ON idle 1
|
||||
LET ret = com.WebServiceEngine.ProcessServices(1)
|
||||
CASE ret
|
||||
WHEN 0
|
||||
DISPLAY "Request processed." TO msg
|
||||
WHEN -1
|
||||
DISPLAY "No request..." TO msg
|
||||
WHEN -2
|
||||
DISPLAY "Disconnected from application server." TO msg
|
||||
EXIT PROGRAM # The Application server has closed the connection
|
||||
WHEN -3
|
||||
DISPLAY "Client Connection lost." TO msg
|
||||
WHEN -4
|
||||
DISPLAY "Server interrupted with Ctrl-C." TO msg
|
||||
WHEN -9
|
||||
DISPLAY "Unsupported operation." TO msg
|
||||
WHEN -10
|
||||
DISPLAY "Internal server error." TO msg
|
||||
OTHERWISE
|
||||
DISPLAY "Unexpected server error " || status || "." TO msg
|
||||
EXIT MENU
|
||||
END CASE
|
||||
ON ACTION close
|
||||
EXIT program
|
||||
END MENU
|
||||
ELSE
|
||||
WHILE TRUE
|
||||
LET ret = com.WebServiceEngine.ProcessServices(-1)
|
||||
CASE ret
|
||||
WHEN 0
|
||||
DISPLAY "Request processed."
|
||||
WHEN -1
|
||||
DISPLAY "Timeout reached."
|
||||
WHEN -2
|
||||
DISPLAY "Disconnected from application server."
|
||||
EXIT PROGRAM # The Application server has closed the connection
|
||||
WHEN -3
|
||||
DISPLAY "Client Connection lost."
|
||||
WHEN -4
|
||||
DISPLAY "Server interrupted with Ctrl-C."
|
||||
WHEN -9
|
||||
DISPLAY "Unsupported operation."
|
||||
WHEN -10
|
||||
DISPLAY "Internal server error."
|
||||
OTHERWISE
|
||||
DISPLAY "Unexpected server error " || status || "."
|
||||
EXIT WHILE
|
||||
END CASE
|
||||
IF int_flag<>0 THEN
|
||||
LET int_flag=0
|
||||
EXIT WHILE
|
||||
END IF
|
||||
END WHILE
|
||||
DISPLAY "Server stopped"
|
||||
END IF
|
||||
END MAIN
|
||||
|
||||
#
|
||||
# Create Calculator RPC/Literal service
|
||||
#
|
||||
FUNCTION CreateCalculatorService(generateWSDL)
|
||||
DEFINE serv com.WebService # WebService
|
||||
DEFINE op com.WebOperation # Operation of a WebService
|
||||
DEFINE serviceNS STRING
|
||||
DEFINE generateWSDL SMALLINT
|
||||
DEFINE ret INTEGER
|
||||
|
||||
LET serviceNS = "http://tempuri.org/"
|
||||
|
||||
TRY
|
||||
|
||||
#
|
||||
# Create Calculator Web Service
|
||||
#
|
||||
LET serv = com.WebService.CreateWebService("Calculator",serviceNS)
|
||||
CALL serv.setFeature("Soap1.1",TRUE)
|
||||
CALL serv.setFeature("Soap1.2",TRUE)
|
||||
|
||||
#
|
||||
# Create a Soap Fault
|
||||
#
|
||||
CALL serv.createFault(divide_by_zero,FALSE)
|
||||
|
||||
#
|
||||
# Publish the functions
|
||||
#
|
||||
|
||||
# Add
|
||||
LET op = com.WebOperation.CreateRPCStyle("add","Add",add_in,add_out)
|
||||
CALL serv.publishOperation(op,NULL)
|
||||
|
||||
# Subtract
|
||||
LET op = com.WebOperation.CreateRPCStyle("subtract","Subtract",subtract_in,subtract_out)
|
||||
CALL serv.publishOperation(op,NULL)
|
||||
|
||||
# Multiply
|
||||
LET op = com.WebOperation.CreateRPCStyle("multiply","Multiply",multiply_in,multiply_out)
|
||||
CALL serv.publishOperation(op,NULL)
|
||||
|
||||
# Divide
|
||||
LET op = com.WebOperation.CreateRPCStyle("divide","Divide",divide_in,divide_out)
|
||||
CALL op.addFault(divide_by_zero, NULL)
|
||||
CALL serv.publishOperation(op,NULL)
|
||||
|
||||
IF generateWSDL THEN
|
||||
#
|
||||
# Generate WSDL
|
||||
#
|
||||
LET ret = serv.saveWSDL(serverURL)
|
||||
IF ret=0 THEN
|
||||
DISPLAY "WSDL saved"
|
||||
ELSE
|
||||
DISPLAY "ERROR: Unable to save WSDL"
|
||||
END IF
|
||||
ELSE
|
||||
#
|
||||
# Register service
|
||||
#
|
||||
CALL com.WebServiceEngine.RegisterService(serv)
|
||||
display_status("Calculator Service registered")
|
||||
END IF
|
||||
|
||||
CATCH
|
||||
display_status("Unable to create 'Calculator' Web Service :"||STATUS)
|
||||
EXIT PROGRAM
|
||||
END TRY
|
||||
|
||||
END FUNCTION
|
||||
|
||||
|
||||
|
||||
FUNCTION exitHelp()
|
||||
DISPLAY "Usage: "
|
||||
DISPLAY " ", arg_val(0)
|
||||
DISPLAY " Start the server on port defined by FGLAPPSERVER"
|
||||
DISPLAY " ", arg_val(0), " -W serverurl"
|
||||
DISPLAY " Generate the WSDL file for the given url"
|
||||
DISPLAY " ", arg_val(0), " -S port"
|
||||
DISPLAY " Start service in graphical mode and on given port"
|
||||
EXIT PROGRAM
|
||||
END FUNCTION
|
||||
|
||||
|
||||
#
|
||||
# USER PUBLIC FUNCTIONS
|
||||
#
|
||||
|
||||
FUNCTION add()
|
||||
LET add_out.r = add_in.a + add_in.b
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION subtract()
|
||||
LET subtract_out.r = subtract_in.a - subtract_in.b
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION multiply()
|
||||
LET multiply_out.r = multiply_in.a * multiply_in.b
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION divide()
|
||||
IF divide_in.b != 0 THEN
|
||||
LET divide_out.quotient = divide_in.a / divide_in.b
|
||||
LET divide_out.remainder = divide_in.a MOD divide_in.b
|
||||
ELSE # Handle divided by zero
|
||||
LET divide_by_zero = "Cannot divide "||divide_in.a||" by zero"
|
||||
CALL com.WebServiceEngine.SetFaultDetail(divide_by_zero) # Throw error
|
||||
END IF
|
||||
END FUNCTION
|
||||
@@ -0,0 +1,15 @@
|
||||
@rem
|
||||
@rem FOURJS_START_COPYRIGHT(U,2000)
|
||||
@rem Property of Four Js*
|
||||
@rem (c) Copyright Four Js 2000, 2021. All Rights Reserved.
|
||||
@rem * Trademark of Four Js Development Tools Europe Ltd
|
||||
@rem in the United States and elsewhere
|
||||
@rem
|
||||
@rem Four Js and its suppliers do not warrant or guarantee that these samples
|
||||
@rem are accurate and suitable for your purposes. Their inclusion is purely for
|
||||
@rem information purposes only.
|
||||
@rem FOURJS_END_COPYRIGHT
|
||||
@rem
|
||||
|
||||
SET FGLAPPSERVER=8090
|
||||
fglrun CalculatorServer.42r
|
||||
@@ -0,0 +1,36 @@
|
||||
--
|
||||
-- FOURJS_START_COPYRIGHT(U,2000)
|
||||
-- Property of Four Js*
|
||||
-- (c) Copyright Four Js 2000, 2021. All Rights Reserved.
|
||||
-- * Trademark of Four Js Development Tools Europe Ltd
|
||||
-- in the United States and elsewhere
|
||||
--
|
||||
-- Four Js and its suppliers do not warrant or guarantee that these samples
|
||||
-- are accurate and suitable for your purposes. Their inclusion is purely for
|
||||
-- information purposes only.
|
||||
-- FOURJS_END_COPYRIGHT
|
||||
--
|
||||
|
||||
SCHEMA FORMONLY
|
||||
|
||||
|
||||
LAYOUT
|
||||
GROUP ( TEXT = "Status")
|
||||
GRID
|
||||
{
|
||||
[msg ]
|
||||
[ ]
|
||||
[ ]
|
||||
|
||||
}
|
||||
END
|
||||
END
|
||||
|
||||
END -- layout
|
||||
|
||||
|
||||
ATTRIBUTES
|
||||
TEXTEDIT msg=formonly.msg, NOENTRY, STRETCH=X,SCROLLBARS=NONE,TITLE="Message",COLOR=RED;
|
||||
END
|
||||
|
||||
|
||||
Reference in New Issue
Block a user