@things-factory/integration-sftp 4.3.40 → 4.3.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -19,7 +19,7 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
|
19
19
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.SftpMutation = void 0;
|
|
22
|
+
exports.getCustomerBizplace = exports.processSftp = exports.SftpMutation = void 0;
|
|
23
23
|
require("../../sftp-s3");
|
|
24
24
|
const type_graphql_1 = require("type-graphql");
|
|
25
25
|
const typeorm_1 = require("typeorm");
|
|
@@ -82,90 +82,40 @@ let SftpMutation = class SftpMutation {
|
|
|
82
82
|
}
|
|
83
83
|
async syncSftpOrders(customerDomainId, context) {
|
|
84
84
|
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
85
|
-
var e_1, _a;
|
|
86
85
|
const customerDomain = await tx.getRepository(shell_1.Domain).findOne(customerDomainId);
|
|
87
|
-
const customerBizplace = await tx
|
|
88
|
-
where: { domain: customerDomain }
|
|
89
|
-
});
|
|
90
|
-
const customerBizplaceId = customerBizplace.id;
|
|
86
|
+
const customerBizplace = await getCustomerBizplace(customerDomainId, tx);
|
|
91
87
|
const sftpUsers = await tx.getRepository(sftp_1.Sftp).find({
|
|
92
88
|
where: { domain: customerDomain, status: 'ACTIVE' },
|
|
93
89
|
relations: ['fulfillmentCenter']
|
|
94
90
|
});
|
|
95
91
|
for (var i = 0; i < sftpUsers.length; i++) {
|
|
96
92
|
const sftpUser = sftpUsers[i];
|
|
97
|
-
|
|
98
|
-
const isDevelopment = sftpUser.isDevelopment;
|
|
99
|
-
const folderPath = sftpUser.folderPath;
|
|
100
|
-
const folderType = isDevelopment ? 'dev' : 'prd';
|
|
101
|
-
let initialDataPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.SUBMITDATAPATH}/`;
|
|
102
|
-
const results = await (0, util_1.getPermittedDirectories)({ path: initialDataPath }, context);
|
|
103
|
-
const filesDirectories = results.filter(result => result.Size > 0);
|
|
104
|
-
try {
|
|
105
|
-
for (var filesDirectories_1 = (e_1 = void 0, __asyncValues(filesDirectories)), filesDirectories_1_1; filesDirectories_1_1 = await filesDirectories_1.next(), !filesDirectories_1_1.done;) {
|
|
106
|
-
let fileDirectory = filesDirectories_1_1.value;
|
|
107
|
-
let dataPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.SUBMITDATAPATH}/`;
|
|
108
|
-
let successPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.SUCCESSDATAPATH}/`;
|
|
109
|
-
let failedPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.FAILEDDATAPATH}/`;
|
|
110
|
-
const fileKey = fileDirectory.Key;
|
|
111
|
-
const lastSlashIdx = fileKey.lastIndexOf('/');
|
|
112
|
-
const fileString = fileKey.substring(lastSlashIdx + 1, fileKey.length);
|
|
113
|
-
try {
|
|
114
|
-
const sftp = sftpUser;
|
|
115
|
-
let result = await controllers_1.SftpAPI.getOutboundOrder(sftp, { folderPath, folderType, fileKey: fileString });
|
|
116
|
-
let isAccept = result.isAccept;
|
|
117
|
-
if (isAccept) {
|
|
118
|
-
delete result.isAccept;
|
|
119
|
-
if (result) {
|
|
120
|
-
let { items: releaseOrders } = await integration_fulfillment_1.FulfillmentAPI.getOutboundOrders(fulfilmentCenter, {
|
|
121
|
-
customerBizplaceId,
|
|
122
|
-
refNo: result.refNo
|
|
123
|
-
});
|
|
124
|
-
if (releaseOrders) {
|
|
125
|
-
result.collectionOrderNo = result.collectionOrderNo + ' - ' + (releaseOrders.length + 1);
|
|
126
|
-
}
|
|
127
|
-
result.requiredDraft = false;
|
|
128
|
-
const releaseOrder = await integration_fulfillment_1.FulfillmentAPI.createOutboundOrder(fulfilmentCenter, {
|
|
129
|
-
customerBizplaceId,
|
|
130
|
-
releaseOrder: result
|
|
131
|
-
});
|
|
132
|
-
if (releaseOrder) {
|
|
133
|
-
let movePaths = {
|
|
134
|
-
source: (dataPath += fileString),
|
|
135
|
-
destination: (successPath += fileString)
|
|
136
|
-
};
|
|
137
|
-
await sftp_const_1.SFTPFILESTORAGE.moveFile(movePaths);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
let movePaths = {
|
|
143
|
-
source: (dataPath += fileString),
|
|
144
|
-
destination: (failedPath += fileString)
|
|
145
|
-
};
|
|
146
|
-
await sftp_const_1.SFTPFILESTORAGE.moveFile(movePaths);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
catch (e) {
|
|
150
|
-
let movePaths = {
|
|
151
|
-
source: (dataPath += fileString),
|
|
152
|
-
destination: (failedPath += fileString)
|
|
153
|
-
};
|
|
154
|
-
await sftp_const_1.SFTPFILESTORAGE.moveFile(movePaths);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
159
|
-
finally {
|
|
160
|
-
try {
|
|
161
|
-
if (filesDirectories_1_1 && !filesDirectories_1_1.done && (_a = filesDirectories_1.return)) await _a.call(filesDirectories_1);
|
|
162
|
-
}
|
|
163
|
-
finally { if (e_1) throw e_1.error; }
|
|
164
|
-
}
|
|
93
|
+
processSftp(sftpUser, context, customerBizplace.id);
|
|
165
94
|
}
|
|
166
95
|
});
|
|
167
96
|
return true;
|
|
168
97
|
}
|
|
98
|
+
async syncAllSftpOrders(context) {
|
|
99
|
+
try {
|
|
100
|
+
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
101
|
+
const sftps = await tx
|
|
102
|
+
.getRepository(sftp_1.Sftp)
|
|
103
|
+
.createQueryBuilder('s')
|
|
104
|
+
.where('s.status = :status', { status: 'ACTIVE' })
|
|
105
|
+
.getMany();
|
|
106
|
+
if (sftps.length === 0)
|
|
107
|
+
return;
|
|
108
|
+
for (const sftp of sftps) {
|
|
109
|
+
const customerBizplace = await getCustomerBizplace(sftp.domainId, tx);
|
|
110
|
+
await processSftp(sftp, context, customerBizplace.id);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
console.log(e);
|
|
116
|
+
}
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
169
119
|
};
|
|
170
120
|
__decorate([
|
|
171
121
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
@@ -221,8 +171,96 @@ __decorate([
|
|
|
221
171
|
__metadata("design:paramtypes", [String, Object]),
|
|
222
172
|
__metadata("design:returntype", Promise)
|
|
223
173
|
], SftpMutation.prototype, "syncSftpOrders", null);
|
|
174
|
+
__decorate([
|
|
175
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
176
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'Calls syncSftpOrders for all domain Ids' }),
|
|
177
|
+
__param(0, (0, type_graphql_1.Ctx)()),
|
|
178
|
+
__metadata("design:type", Function),
|
|
179
|
+
__metadata("design:paramtypes", [Object]),
|
|
180
|
+
__metadata("design:returntype", Promise)
|
|
181
|
+
], SftpMutation.prototype, "syncAllSftpOrders", null);
|
|
224
182
|
SftpMutation = __decorate([
|
|
225
183
|
(0, type_graphql_1.Resolver)(sftp_1.Sftp)
|
|
226
184
|
], SftpMutation);
|
|
227
185
|
exports.SftpMutation = SftpMutation;
|
|
186
|
+
async function processSftp(sftpUser, context, customerBizplaceId) {
|
|
187
|
+
var e_1, _a;
|
|
188
|
+
const fulfilmentCenter = sftpUser.fulfillmentCenter;
|
|
189
|
+
const isDevelopment = sftpUser.isDevelopment;
|
|
190
|
+
const folderPath = sftpUser.folderPath;
|
|
191
|
+
const folderType = isDevelopment ? 'dev' : 'prd';
|
|
192
|
+
let initialDataPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.SUBMITDATAPATH}/`;
|
|
193
|
+
const results = await (0, util_1.getPermittedDirectories)({ path: initialDataPath }, context);
|
|
194
|
+
const filesDirectories = results.filter(result => result.Size > 0);
|
|
195
|
+
try {
|
|
196
|
+
for (var filesDirectories_1 = __asyncValues(filesDirectories), filesDirectories_1_1; filesDirectories_1_1 = await filesDirectories_1.next(), !filesDirectories_1_1.done;) {
|
|
197
|
+
let fileDirectory = filesDirectories_1_1.value;
|
|
198
|
+
let dataPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.SUBMITDATAPATH}/`;
|
|
199
|
+
let successPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.SUCCESSDATAPATH}/`;
|
|
200
|
+
let failedPath = `${sftpUser.folderPath}/${folderType}${sftp_const_1.FAILEDDATAPATH}/`;
|
|
201
|
+
const fileKey = fileDirectory.Key;
|
|
202
|
+
const lastSlashIdx = fileKey.lastIndexOf('/');
|
|
203
|
+
const fileString = fileKey.substring(lastSlashIdx + 1, fileKey.length);
|
|
204
|
+
try {
|
|
205
|
+
const sftp = sftpUser;
|
|
206
|
+
let result = await controllers_1.SftpAPI.getOutboundOrder(sftp, { folderPath, folderType, fileKey: fileString });
|
|
207
|
+
let isAccept = result.isAccept;
|
|
208
|
+
if (isAccept) {
|
|
209
|
+
delete result.isAccept;
|
|
210
|
+
if (result) {
|
|
211
|
+
let { items: releaseOrders } = await integration_fulfillment_1.FulfillmentAPI.getOutboundOrders(fulfilmentCenter, {
|
|
212
|
+
customerBizplaceId,
|
|
213
|
+
refNo: result.refNo
|
|
214
|
+
});
|
|
215
|
+
if (releaseOrders) {
|
|
216
|
+
result.collectionOrderNo = result.collectionOrderNo + ' - ' + (releaseOrders.length + 1);
|
|
217
|
+
}
|
|
218
|
+
result.requiredDraft = false;
|
|
219
|
+
const releaseOrder = await integration_fulfillment_1.FulfillmentAPI.createOutboundOrder(fulfilmentCenter, {
|
|
220
|
+
customerBizplaceId,
|
|
221
|
+
releaseOrder: result
|
|
222
|
+
});
|
|
223
|
+
if (releaseOrder) {
|
|
224
|
+
let movePaths = {
|
|
225
|
+
source: (dataPath += fileString),
|
|
226
|
+
destination: (successPath += fileString)
|
|
227
|
+
};
|
|
228
|
+
await sftp_const_1.SFTPFILESTORAGE.moveFile(movePaths);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
let movePaths = {
|
|
234
|
+
source: (dataPath += fileString),
|
|
235
|
+
destination: (failedPath += fileString)
|
|
236
|
+
};
|
|
237
|
+
await sftp_const_1.SFTPFILESTORAGE.moveFile(movePaths);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
catch (e) {
|
|
241
|
+
let movePaths = {
|
|
242
|
+
source: (dataPath += fileString),
|
|
243
|
+
destination: (failedPath += fileString)
|
|
244
|
+
};
|
|
245
|
+
await sftp_const_1.SFTPFILESTORAGE.moveFile(movePaths);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
250
|
+
finally {
|
|
251
|
+
try {
|
|
252
|
+
if (filesDirectories_1_1 && !filesDirectories_1_1.done && (_a = filesDirectories_1.return)) await _a.call(filesDirectories_1);
|
|
253
|
+
}
|
|
254
|
+
finally { if (e_1) throw e_1.error; }
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
exports.processSftp = processSftp;
|
|
258
|
+
async function getCustomerBizplace(customerDomainId, tx) {
|
|
259
|
+
const customerDomain = await tx.getRepository(shell_1.Domain).findOne(customerDomainId);
|
|
260
|
+
const customerBizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({
|
|
261
|
+
where: { domain: customerDomain }
|
|
262
|
+
});
|
|
263
|
+
return customerBizplace;
|
|
264
|
+
}
|
|
265
|
+
exports.getCustomerBizplace = getCustomerBizplace;
|
|
228
266
|
//# sourceMappingURL=sftp-mutation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sftp-mutation.js","sour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AAQ,IAAI,UAAU,CAAC;oBAChC,WAAW,EAAE,CAAC,UAAU,IAAI,UAAU,CAAC;iBACxC,CAAA;gBACD,MAAM,4BAAe,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;aAC1C;SACF;;;;;;;;;AACH,CAAC;AA/DD,kCA+DC;AAEM,KAAK,UAAU,mBAAmB,CAAC,gBAAgB,EAAE,EAAE;IAC5D,MAAM,cAAc,GAAW,MAAM,EAAE,CAAC,aAAa,CAAC,cAAM,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAEvF,MAAM,gBAAgB,GAAa,MAAM,EAAE,CAAC,aAAa,CAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC;QAC1E,KAAK,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE;KAClC,CAAC,CAAA;IAEF,OAAO,gBAAgB,CAAA;AACzB,CAAC;AARD,kDAQC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/integration-sftp",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.47",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@things-factory/auth-base": "^4.3.
|
|
28
|
-
"@things-factory/biz-base": "^4.3.
|
|
29
|
-
"@things-factory/env": "^4.3.
|
|
30
|
-
"@things-factory/integration-fulfillment": "^4.3.
|
|
31
|
-
"@things-factory/shell": "^4.3.
|
|
27
|
+
"@things-factory/auth-base": "^4.3.47",
|
|
28
|
+
"@things-factory/biz-base": "^4.3.47",
|
|
29
|
+
"@things-factory/env": "^4.3.47",
|
|
30
|
+
"@things-factory/integration-fulfillment": "^4.3.47",
|
|
31
|
+
"@things-factory/shell": "^4.3.47",
|
|
32
32
|
"aws-sdk": "^2.960.0",
|
|
33
33
|
"xml-js": "^1.6.11"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "2abf3aa51954ef43fde410c44e854495422e6612"
|
|
36
36
|
}
|
|
@@ -121,11 +121,7 @@ export class SftpMutation {
|
|
|
121
121
|
await getConnection().transaction(async (tx: EntityManager) => {
|
|
122
122
|
const customerDomain: Domain = await tx.getRepository(Domain).findOne(customerDomainId)
|
|
123
123
|
|
|
124
|
-
const customerBizplace: Bizplace = await tx
|
|
125
|
-
where: { domain: customerDomain }
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
const customerBizplaceId: string = customerBizplace.id
|
|
124
|
+
const customerBizplace: Bizplace = await getCustomerBizplace(customerDomainId, tx)
|
|
129
125
|
|
|
130
126
|
const sftpUsers: Sftp[] = await tx.getRepository(Sftp).find({
|
|
131
127
|
where: { domain: customerDomain, status: 'ACTIVE' },
|
|
@@ -134,72 +130,108 @@ export class SftpMutation {
|
|
|
134
130
|
|
|
135
131
|
for (var i = 0; i < sftpUsers.length; i++) {
|
|
136
132
|
const sftpUser: Sftp = sftpUsers[i]
|
|
133
|
+
processSftp(sftpUser, context, customerBizplace.id)
|
|
134
|
+
}
|
|
135
|
+
})
|
|
137
136
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
137
|
+
return true
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@Directive('@transaction')
|
|
141
|
+
@Mutation(returns => Boolean, { description: 'Calls syncSftpOrders for all domain Ids' })
|
|
142
|
+
async syncAllSftpOrders(@Ctx() context: any): Promise<Boolean> {
|
|
143
|
+
try {
|
|
144
|
+
await getConnection().transaction(async tx => {
|
|
145
|
+
const sftps = await tx
|
|
146
|
+
.getRepository(Sftp)
|
|
147
|
+
.createQueryBuilder('s')
|
|
148
|
+
.where('s.status = :status', { status: 'ACTIVE' })
|
|
149
|
+
.getMany()
|
|
150
|
+
|
|
151
|
+
if (sftps.length === 0) return
|
|
152
|
+
for (const sftp of sftps) {
|
|
153
|
+
const customerBizplace = await getCustomerBizplace(sftp.domainId, tx)
|
|
154
|
+
await processSftp(sftp, context, customerBizplace.id)
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
} catch (e) {
|
|
158
|
+
console.log(e)
|
|
159
|
+
}
|
|
160
|
+
return true
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export async function processSftp(sftpUser, context, customerBizplaceId) {
|
|
165
|
+
const fulfilmentCenter: FulFillmentCenter = sftpUser.fulfillmentCenter
|
|
166
|
+
const isDevelopment: boolean = sftpUser.isDevelopment
|
|
167
|
+
const folderPath: string = sftpUser.folderPath
|
|
168
|
+
const folderType: string = isDevelopment ? 'dev' : 'prd'
|
|
169
|
+
let initialDataPath: string = `${sftpUser.folderPath}/${folderType}${SUBMITDATAPATH}/`
|
|
170
|
+
const results: any[] = await getPermittedDirectories({ path: initialDataPath }, context)
|
|
171
|
+
const filesDirectories: any[] = results.filter(result => result.Size > 0)
|
|
172
|
+
|
|
173
|
+
for await (let fileDirectory of filesDirectories) {
|
|
174
|
+
let dataPath: string = `${sftpUser.folderPath}/${folderType}${SUBMITDATAPATH}/`
|
|
175
|
+
let successPath: string = `${sftpUser.folderPath}/${folderType}${SUCCESSDATAPATH}/`
|
|
176
|
+
let failedPath: string = `${sftpUser.folderPath}/${folderType}${FAILEDDATAPATH}/`
|
|
177
|
+
const fileKey: string = fileDirectory.Key
|
|
178
|
+
const lastSlashIdx = fileKey.lastIndexOf('/')
|
|
179
|
+
const fileString: string = fileKey.substring(lastSlashIdx + 1, fileKey.length)
|
|
180
|
+
try {
|
|
181
|
+
const sftp: any = sftpUser
|
|
182
|
+
let result: any = await SftpAPI.getOutboundOrder(sftp, { folderPath, folderType, fileKey: fileString })
|
|
183
|
+
let isAccept: boolean = result.isAccept
|
|
184
|
+
|
|
185
|
+
if (isAccept) {
|
|
186
|
+
delete result.isAccept
|
|
187
|
+
if (result) {
|
|
188
|
+
let { items: releaseOrders }: any = await FulfillmentAPI.getOutboundOrders(fulfilmentCenter, {
|
|
189
|
+
customerBizplaceId,
|
|
190
|
+
refNo: result.refNo
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
if (releaseOrders) {
|
|
194
|
+
result.collectionOrderNo = result.collectionOrderNo + ' - ' + (releaseOrders.length + 1)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
result.requiredDraft = false
|
|
198
|
+
|
|
199
|
+
const releaseOrder: any = await FulfillmentAPI.createOutboundOrder(fulfilmentCenter, {
|
|
200
|
+
customerBizplaceId,
|
|
201
|
+
releaseOrder: result
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
if (releaseOrder) {
|
|
193
205
|
let movePaths = {
|
|
194
206
|
source: (dataPath += fileString),
|
|
195
|
-
destination: (
|
|
207
|
+
destination: (successPath += fileString)
|
|
196
208
|
}
|
|
197
209
|
await SFTPFILESTORAGE.moveFile(movePaths)
|
|
198
210
|
}
|
|
199
211
|
}
|
|
212
|
+
} else {
|
|
213
|
+
let movePaths = {
|
|
214
|
+
source: (dataPath += fileString),
|
|
215
|
+
destination: (failedPath += fileString)
|
|
216
|
+
}
|
|
217
|
+
await SFTPFILESTORAGE.moveFile(movePaths)
|
|
200
218
|
}
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
|
|
219
|
+
} catch (e) {
|
|
220
|
+
let movePaths = {
|
|
221
|
+
source: (dataPath += fileString),
|
|
222
|
+
destination: (failedPath += fileString)
|
|
223
|
+
}
|
|
224
|
+
await SFTPFILESTORAGE.moveFile(movePaths)
|
|
225
|
+
}
|
|
204
226
|
}
|
|
205
227
|
}
|
|
228
|
+
|
|
229
|
+
export async function getCustomerBizplace(customerDomainId, tx): Promise<Bizplace> {
|
|
230
|
+
const customerDomain: Domain = await tx.getRepository(Domain).findOne(customerDomainId)
|
|
231
|
+
|
|
232
|
+
const customerBizplace: Bizplace = await tx.getRepository(Bizplace).findOne({
|
|
233
|
+
where: { domain: customerDomain }
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
return customerBizplace
|
|
237
|
+
}
|