Untitled

 avatar
unknown
plain_text
a year ago
9.3 kB
13
Indexable
putApiTracing() {
    if (this.activeOS == this.listOS.OS390) {
        console.log("entered if");
        this.submitted = true;
        let zosPostObject = {};

        if (this.updatetracingForm.value.quiesce != this.currentTracingNode['quiesced'].toLocaleLowerCase()) {
            if (this.updatetracingForm.value.quiesce == 'on') {
                zosPostObject['quiesceNode'] = '(Q,' + this.currentTracingNode['nodeName'] + ')';
            } else if (this.updatetracingForm.value.quiesce == 'off') {
                zosPostObject['quiesceNode'] = '(R,' + this.currentTracingNode['nodeName'] + ')';
            }
        } else {
            const debugLevel = this.updatetracingForm.value.debugLevel.toUpperCase();
            if (this.headerTabConf.selectedTab == 'partners') {
                if (debugLevel == '00000000') {
                    zosPostObject['nodeNameForTraceOff'] = this.currentTracingNode['nodeName'];
                } else {
                    zosPostObject['nodeNameForTrace'] = this.currentTracingNode['nodeName'] + ',' + debugLevel;
                }
            } else if (this.headerTabConf.selectedTab == 'global') {
                zosPostObject['debugLevel'] = debugLevel;
            } else {
                zosPostObject['debugLevel'] = debugLevel;
                zosPostObject['serverName'] = this.currentTracingNode['nodeName'];
            }
        }

        this.appService.masterWrapper({
            params: {
                'allparameters': zosPostObject,
                'allconfig': this.commonUtilitiesLib.copy({
                    'verbtype': 'put',
                    'apiname': ['TRACING'],
                    'responseformat': { 'format': 'rest' }
                })
            }
        }).subscribe((success: any) => {
            this.zosPartnerFlag = true;
            this.toaster.success(this.translateService.instant('tracing.messages.successmessages'));
            this.getApiTracing();
        });
    } else {
        this.resetErrorFlags();
        console.log("entered else");

        const changedValueObject = Object.keys(this.commonUtilitiesLib.getObjectDirtyKey(this.freshObjectFromGet, this.updatetracingForm.getRawValue()));
        if (changedValueObject.length > 0) {
            const outputFiles = ['PMGRoutputfilename', 'CMGRoutputfilename', 'SMGRoutputfilename', 'SMGRSNodeoutputfilename'];
            let errorFlag = false;
            
            outputFiles.forEach(file => {
                if (this.updatetracingForm.value[file] != null && this.updatetracingForm.value[file].trim() === '') {
                    this.error[`${file.toLowerCase()}Path`] = true;
                    errorFlag = true;
                }
            });

            if (errorFlag) return;

            const allparameters = {};
            if (this.isWindowFlag) {
                allparameters['fileName'] = this.updatetracingForm.value.outputfilename;
                allparameters['maximumFileSize'] = this.updatetracingForm.value.maximumfilesizeText + this.updatetracingForm.value.maximumfilesizedrop;
                allparameters['wrapSetting'] = this.booleanToText(this.wrapSetting);
            } else {
                allparameters['pmgrOutputFile'] = this.checkForQuotes(this.updatetracingForm.value.PMGRoutputfilename);
                allparameters['cmgrOutputFile'] = this.checkForQuotes(this.updatetracingForm.value.CMGRoutputfilename);
                allparameters['fileName'] = this.checkForQuotes(this.updatetracingForm.value.SMGRoutputfilename);
                allparameters['smgrSNodeOutputFile'] = this.checkForQuotes(this.updatetracingForm.value.SMGRSNodeoutputfilename);
            }

            const updateCalls = [];

            if (changedValueObject.includes('processManager') || changedValueObject.includes('PMGRoutputfiledestination') ||
                changedValueObject.includes('outputfiledestination') || changedValueObject.includes('PMGRoutputfilename')) {
                console.log("1st");
                const params = {
                    level: this.updatetracingForm.value.processManager,
                    processManager: 'yes',
                    pmgrOutputFile: allparameters['pmgrOutputFile']
                };
                updateCalls.push(this.updateTracingOnOff(params));
            }

            if (changedValueObject.includes('commandManager') || changedValueObject.includes('CMGRoutputfiledestination') ||
                changedValueObject.includes('CMGRoutputfilename')) {
                console.log("2nd");
                const params = {
                    level: this.updatetracingForm.value.commandManager,
                    commandManager: 'yes',
                    cmgrOutputFile: allparameters['cmgrOutputFile']
                };
                updateCalls.push(this.updateTracingOnOff(params));
            }

            if (changedValueObject.includes('communicationResponse')) {
                console.log("3rd");
                const params = {
                    level: this.updatetracingForm.value.communicationResponse,
                    communicationResponse: 'yes'
                };
                updateCalls.push(this.updateTracingOnOff(params));
            }

            if (this.isWindowFlag) {
                if (this.updatetracingForm.value.sessionManager !== 'off') {
                    console.log("4th");
                    updateCalls.push(this.updateTracing({
                        sessionManager: this.updatetracingForm.value.sessionManager
                    }));
                } else {
                    console.log("5th");
                    updateCalls.push(this.updateTracingOnOff({
                        level: this.updatetracingForm.value.sessionManager,
                        sessionManager: 'yes'
                    }));
                }

                if (changedValueObject.includes('mainTrace')) {
                    console.log("6th");
                    const params = {
                        mainTrace: 'yes',
                        level: this.updatetracingForm.value.mainTrace
                    };
                    updateCalls.push(this.updateTracingOnOff(params));
                }

                if (changedValueObject.includes('statTrace') || changedValueObject.includes('outputfiledestination')) {
                    console.log("7th");
                    const params = {
                        statTrace: 'yes',
                        level: this.updatetracingForm.value.statTrace
                    };
                    updateCalls.push(this.updateTracingOnOff(params));
                }

                if (changedValueObject.includes('wrapSetting') || changedValueObject.includes('maximumfilesizeText') ||
                    changedValueObject.includes('maximumfilesizedrop') || changedValueObject.includes('outputfilename') ||
                    changedValueObject.includes('generateConfigReport')) {
                    console.log("8th");
                    updateCalls.push(this.updateTracing({
                        wrapSetting: allparameters['wrapSetting'],
                        maximumFileSize: allparameters['maximumFileSize'],
                        fileName: allparameters['fileName'],
                        configurationReport: this.generateConfigReport
                    }));
                }
            } else {
                console.log("9th");
                updateCalls.push(this.updateTracingOnOff({
                    level: this.updatetracingForm.value.sessionManager,
                    sessionManager: 'yes',
                    sessionManagerNode: 'pnode',
                    fileName: allparameters['fileName']
                }));

                if (changedValueObject.includes('sessionManagerSNode') || changedValueObject.includes('SMGRSNodeoutputfilename')) {
                    console.log("10th");
                    updateCalls.push(this.updateTracingOnOff({
                        level: this.updatetracingForm.value.sessionManagerSNode,
                        sessionManagerSNode: 'yes',
                        sessionManager: 'yes',
                        sessionManagerNode: 'snode',
                        smgrSNodeOutputFile: allparameters['smgrSNodeOutputFile']
                    }));
                }
            }

            Promise.all(updateCalls).then(() => {
                if (this.arrayObjConfig.length > 0) {
                    console.log("11th");
                    this.appCommonService.syncApiCall(this.arrayObjConfig, () => {
                        this.getApiTracing();
                    });
                }
                if (this.arrayObj.length > 0) {
                    console.log("12th");
                    this.appCommonService.syncApiCall(this.arrayObj, () => {
                        this.toaster.success(this.translateService.instant('tracing.messages.successmessages'));
                        this.updatetracingForm.reset();
                        this.getApiTracing();
                    });
                }
            });
        }
    }
}
Editor is loading...
Leave a Comment