Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. async function processAccounts(accounts) {
  2. for (const account of accounts) {
  3. console.log('PROCESSING ACCOUNT', account.CODICE);
  4. let addGroupMsg;
  5. let setPropMsg;
  6. const folder = await that.findFolderByCode(account.CODICE);
  7. if (folder) {
  8. console.log('FOLDER FOUND!');
  9.  
  10. if (account.RAGIONE_SOCIALE !== that.getName(folder.path)) {
  11. console.log('RENAME FOLDER!');
  12. await that.rename(folder.uuid, account.RAGIONE_SOCIALE);
  13. } else {
  14. console.log('FOLDER NAME OK!');
  15. }
  16.  
  17. const props = await that.getFolderProps(folder.uuid);
  18.  
  19. if (props &&
  20. props.every(prop =>
  21. account[that.FOLDER_PROP_MAPPING[prop.name]] === prop.value)) {
  22. console.log('FOLDER PROPS OK!');
  23. } else {
  24. console.log('SET FOLDER PROPS!');
  25. [addGroupMsg, setPropMsg] = await that.setFolderProps(folder.uuid, account);
  26. if (addGroupMsg === '' && setPropMsg === '') {
  27. console.log('PROPS SET OK!');
  28. } else {
  29. console.log('PROPS SET ERROR!', addGroupMsg, setPropMsg);
  30. }
  31. }
  32. } else {
  33. console.log('FOLDER NOT FOUND!');
  34. const newFolder = await that.createFolder(account.RAGIONE_SOCIALE);
  35. if (newFolder) {
  36. console.log('FOLDER CREATED!');
  37. [addGroupMsg, setPropMsg] = await that.setFolderProps(newFolder.uuid, account);
  38. if (addGroupMsg === '' && setPropMsg === '') {
  39. console.log('PROPS SET OK!');
  40. } else {
  41. console.log('PROPS SET ERROR!', addGroupMsg, setPropMsg);
  42. }
  43. } else {
  44. console.log('FOLDER CREATION ERROR!');
  45. }
  46. }
  47. }
  48. }
  49.  
  50. processAccounts(result.recordset).then(() => resolve());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement