Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async function processAccounts(accounts) {
- for (const account of accounts) {
- console.log('PROCESSING ACCOUNT', account.CODICE);
- let addGroupMsg;
- let setPropMsg;
- const folder = await that.findFolderByCode(account.CODICE);
- if (folder) {
- console.log('FOLDER FOUND!');
- if (account.RAGIONE_SOCIALE !== that.getName(folder.path)) {
- console.log('RENAME FOLDER!');
- await that.rename(folder.uuid, account.RAGIONE_SOCIALE);
- } else {
- console.log('FOLDER NAME OK!');
- }
- const props = await that.getFolderProps(folder.uuid);
- if (props &&
- props.every(prop =>
- account[that.FOLDER_PROP_MAPPING[prop.name]] === prop.value)) {
- console.log('FOLDER PROPS OK!');
- } else {
- console.log('SET FOLDER PROPS!');
- [addGroupMsg, setPropMsg] = await that.setFolderProps(folder.uuid, account);
- if (addGroupMsg === '' && setPropMsg === '') {
- console.log('PROPS SET OK!');
- } else {
- console.log('PROPS SET ERROR!', addGroupMsg, setPropMsg);
- }
- }
- } else {
- console.log('FOLDER NOT FOUND!');
- const newFolder = await that.createFolder(account.RAGIONE_SOCIALE);
- if (newFolder) {
- console.log('FOLDER CREATED!');
- [addGroupMsg, setPropMsg] = await that.setFolderProps(newFolder.uuid, account);
- if (addGroupMsg === '' && setPropMsg === '') {
- console.log('PROPS SET OK!');
- } else {
- console.log('PROPS SET ERROR!', addGroupMsg, setPropMsg);
- }
- } else {
- console.log('FOLDER CREATION ERROR!');
- }
- }
- }
- }
- processAccounts(result.recordset).then(() => resolve());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement