1. JavaScript / Говнокод #12277

    +156

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    this.start = function() {
    		// Инициализирует парсинг выгрузки из Агента Плюс.
    		if (this.open()) {
    			this.catalogs = this.getTags("catalogs", true)[0].childs;
    			this.subdocuments = this.getTags("documents", true)[1].childs;
    			this.guids = this.document.childs[0].childs[0].childs;
    			this.sellhistory = this.getCatalog("ИсторияПродаж").childs[0].childs;
    			this.sellpoints = this.getCatalog("ТорговыеТочки").childs[0].childs;
    			this.contragents = this.getCatalog("Контрагенты").childs[1].childs;
    			this.deals = this.getCatalog("Договоры").childs[0].childs;
    			this.nomenclature = this.getCatalog("Номенклатура").childs;
    			this.measure = this.getCatalog("ЕдиницыИзмерения").childs[0].childs;
    			this.route = this.getDocument("Маршрут").childs[0].childs[0].childs[0].childs[0]
    			this.names = {deals: [], catalog: [], nomenclature: [], measure: [], contragents: [], sellpoints: []};
    			this.info = {deals: [], catalog: [], nomenclature: [], measure: [], contragents: [], sellpoints: []};
    			this.hash = {deals: {}, nomenclature: {}, consts: {}, contragents: {}, sellpoints: [], measure: {}};
    			for (var i = 0; i < this.catalogs.length; i++) {
    				this.names.catalog.push(this.catalogs[i].attrib.Comment.replace(/Справочник\./g, ""));
    				this.info.catalog.push(this.catalogs[i].attrib);
    			}
    			for (var i = 0; i < this.nomenclature[1].childs.length; i++) {
    				this.names.nomenclature.push(this.nomenclature[1].childs[i].attrib.Name);
    				this.info.nomenclature.push(this.nomenclature[1].childs[i].attrib);
    				this.hash.nomenclature[this.nomenclature[1].childs[i].attrib.GUID] = this.nomenclature[1].childs[i].attrib;
    			}
    			for (var i = 0; i < this.deals.length; i++) {
    				this.names.deals.push(this.deals[i].attrib.Name);
    				this.info.deals.push(this.deals[i].attrib);
    				this.hash.deals[this.deals[i].attrib.GUID] = this.deals[i].attrib;
    			}
    			for (var i = 0; i < this.measure.length; i++) {
    				this.names.measure.push(this.measure[i].attrib.Name);
    				this.info.measure.push(this.measure[i].attrib);
    				this.hash.measure[this.measure[i].attrib.GUID] = this.measure[i].attrib;
    			}
    			for (var i = 0; i < this.contragents.length; i++) {
    				this.names.contragents.push(this.contragents[i].attrib.Name);
    				this.info.contragents.push(this.contragents[i].attrib);
    				this.hash.contragents[this.contragents[i].attrib.GUID] = this.contragents[i].attrib;
    			}
    			for (var i = 0; i < this.sellpoints.length; i++) {
    				this.names.sellpoints.push(this.sellpoints[i].attrib.Name);
    				this.info.sellpoints.push(this.sellpoints[i].attrib);
    				this.hash.sellpoints[this.sellpoints[i].attrib.GUID] = this.sellpoints[i].attrib;
    			}
    			for (var i = 0; i < this.guids.length; i++) {
    				this.hash.consts[this.guids[i].attrib.GUID] = this.guids[i].attrib.VALUE;
    			}
    			
    			this.dynamic.routes = new Array();
    			for (var i = 0; i < this.route.childs.length; i++) {
    				var sp = this.getSPointByGUID(this.route.childs[i].attrib.A02);
    				var adr = sp.Name;
    				var ca = this.getCAgentByGUID(this.route.childs[i].attrib.A01);
    				var ptypeguid = this.hash.deals[ca.A08].A06;
    				var cagent = ca.Name;
    				var dealguid = ca.A08;
    				var exists = false;
    				for (var j = 0; j < this.dynamic.routes.length; j++) if (this.dynamic.routes[j].address.trim().toLowerCase() == adr.trim().toLowerCase()) exists = exists || true;
    				if (!exists) this.dynamic.routes.push({ptypeguid: ptypeguid, spointguid: sp.GUID, address: adr, dealguid: dealguid, cagent: cagent, cagentguid: ca.GUID, datestamp: this.convRouteDate(this.route.childs[i].attrib.A03)});
    			}
    		} else return;
    	};

    Маленькая часть нашего скрипта для работы с 1С - Node.JS - WebClient.

    Запостил: Govnisti_Diavol, 12 Декабря 2012

    Комментарии (9) RSS

    Добавить комментарий