Skip to content

Commit 16058db

Browse files
...
1 parent 6b8e14f commit 16058db

File tree

3 files changed

+47
-13
lines changed

3 files changed

+47
-13
lines changed

Diff for: src/services/ContractTemplate.coffee

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class ContractTemplate
2222
clause = new Clause(template)
2323
clause.setData testLatePenaltyInput
2424
n1 = clause.generateText()
25-
console.log n1
2625
n1
2726

2827
module.exports = ContractTemplate

Diff for: src/services/SetupClient.coffee

+46-12
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ class SetupClient
3434
workerId = @getWorkerId()
3535
await @sendTestWorkEvent workerId, serverIp, serverPort
3636

37-
# Deploy a ContractPen contract to an Accord Project folder structure
37+
program.usage('testwork2 <server ip address> <server port>').command('testwork2 <server ip address> <server port>').action (serverIp, serverPort, cmd) =>
38+
console.log 'send test work event'
39+
workerId = @getWorkerId()
40+
await @sendTestWorkEvent2 workerId, serverIp, serverPort
41+
42+
# ?
3843
program.usage('template <input json file> <directory of project>').command('template <input json file> <directory of project>').action (inputJsonFile, directory, cmd) =>
3944
console.log 'template ' + inputJsonFile + ' directory ' + directory
4045
await @templateProcess inputJsonFile, directory
@@ -125,7 +130,25 @@ class SetupClient
125130
return
126131

127132

128-
#request.post "http://#{serverId}:#{port}/api/submitTask", { json: true }, (err, res, body) ->
133+
sendTestWorkEvent2: (workerId, serverId, port) ->
134+
workData =
135+
fromWorkerId: workerId
136+
targetWorkerId: null
137+
sendResultToWorkerId: null
138+
command: 'template'
139+
params: ['test_template.json', 'C:\\home\\projects\\accord\\cicero-template-library\\src\\helloworld']
140+
141+
request.post {
142+
url: "http://#{serverId}:#{port}/api/submitTask"
143+
body: workData
144+
json: true
145+
}, (error, response, body) ->
146+
if error
147+
return console.error('failed to send work test event:', error)
148+
console.log 'Upload successful! Server responded with:', body
149+
return
150+
151+
#request.post "http://#{serverId}:#{port}/api/submitTask", { json: true }, (err, res, body) ->
129152
# if err
130153
# return console.log(err)
131154
# console.log body
@@ -139,7 +162,7 @@ class SetupClient
139162
if (command == 'execute')
140163
result = @execute params[0], params[1], params[2], params[3]
141164
if (command == 'template')
142-
result = @template params[0], params[1]
165+
result = await @templateProcess params[0], params[1]
143166
if (command == 'export')
144167
result = @export params[0], params[1]
145168
if (command == 'exportmulti')
@@ -154,16 +177,27 @@ class SetupClient
154177
job = JSON.parse(job)
155178
console.log 'job command ' + job.command
156179
result = @commandSwitcher job.command, job.params
157-
console.log 'execute job called from the server'
158-
# If the directory exists then we say success
159-
workerId = @getWorkerId()
160-
socket.send 'finishedJob',
161-
workerId: @getWorkerId()
162-
job: job
163-
result:
164-
job: job
180+
result.then (r) =>
181+
console.log 'execute job called from the server and finished'
182+
console.log r
183+
184+
# The result depends on the command
185+
# deploy: If the folder exists
186+
# execute: The result
187+
# template: The result is the text of the template result
188+
# export: The second parameter is the json file to return
189+
# exportMulti: The second parameter is the json file to return
190+
191+
# If the directory exists then we say success
192+
workerId = @getWorkerId()
193+
socket.send 'finishedJob',
165194
workerId: @getWorkerId()
166-
workerId: workerId
195+
job: job
196+
result:
197+
job: job
198+
workerId: @getWorkerId()
199+
workerId: workerId
200+
returnResultFromFunctionExecution: r
167201
return
168202

169203
# When the server is connected we send back to the server that we are ready to accept commands

Diff for: test_work2.bat

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
call run testwork2 localhost 3050

0 commit comments

Comments
 (0)