Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 0be1a6d

Browse files
committed
closes #90, closes #88; Added enable/disable to local files and local transactions
Signed-off-by: JeffinSiby <[email protected]>
1 parent e92e653 commit 0be1a6d

9 files changed

+527
-6
lines changed

package.json

+36
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,22 @@
129129
"command": "cics-extension-for-zowe.disableProgram",
130130
"title": "Disable Program"
131131
},
132+
{
133+
"command": "cics-extension-for-zowe.enableTransaction",
134+
"title": "Enable Transaction"
135+
},
136+
{
137+
"command": "cics-extension-for-zowe.disableTransaction",
138+
"title": "Disable Transaction"
139+
},
140+
{
141+
"command": "cics-extension-for-zowe.enableLocalFile",
142+
"title": "Enable Local File"
143+
},
144+
{
145+
"command": "cics-extension-for-zowe.disableLocalFile",
146+
"title": "Disable Local File"
147+
},
132148
{
133149
"command": "cics-extension-for-zowe.phaseInCommand",
134150
"title": "Phase In",
@@ -254,6 +270,26 @@
254270
"command": "cics-extension-for-zowe.disableProgram",
255271
"group": ""
256272
},
273+
{
274+
"when": "view == cics-view && viewItem =~ /^cicstransaction.disabled.*/",
275+
"command": "cics-extension-for-zowe.enableTransaction",
276+
"group": ""
277+
},
278+
{
279+
"when": "view == cics-view && viewItem =~ /^cicstransaction.enabled.*/",
280+
"command": "cics-extension-for-zowe.disableTransaction",
281+
"group": ""
282+
},
283+
{
284+
"when": "view == cics-view && viewItem =~ /^cicslocalfile.disabled.*/",
285+
"command": "cics-extension-for-zowe.enableLocalFile",
286+
"group": ""
287+
},
288+
{
289+
"when": "view == cics-view && viewItem =~ /^cicslocalfile.enabled.*/",
290+
"command": "cics-extension-for-zowe.disableLocalFile",
291+
"group": ""
292+
},
257293
{
258294
"when": "view == cics-view && viewItem =~ /^cicssession.*/",
259295
"command": "cics-extension-for-zowe.removeSession",
+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/*
2+
* This program and the accompanying materials are made available under the terms of the
3+
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
4+
* https://www.eclipse.org/legal/epl-v20.html
5+
*
6+
* SPDX-License-Identifier: EPL-2.0
7+
*
8+
* Copyright Contributors to the Zowe Project.
9+
*
10+
*/
11+
12+
import {
13+
CicsCmciConstants,
14+
CicsCmciRestClient,
15+
ICMCIApiResponse,
16+
} from "@zowe/cics-for-zowe-cli";
17+
import { AbstractSession } from "@zowe/imperative";
18+
import { commands, ProgressLocation, TreeView, window } from "vscode";
19+
import { CICSRegionTree } from "../trees/CICSRegionTree";
20+
import { CICSTree } from "../trees/CICSTree";
21+
22+
export function getDisableLocalFileCommand(tree: CICSTree, treeview: TreeView<any>) {
23+
return commands.registerCommand(
24+
"cics-extension-for-zowe.disableLocalFile",
25+
async (node) => {
26+
if (node) {
27+
try {
28+
let selectedNodes = treeview.selection;
29+
let parentRegions: CICSRegionTree[] = [];
30+
31+
window.withProgress({
32+
title: 'Disable',
33+
location: ProgressLocation.Notification,
34+
cancellable: true
35+
}, async (progress, token) => {
36+
token.onCancellationRequested(() => {
37+
console.log("Cancelling the Disable");
38+
});
39+
for (const index in selectedNodes) {
40+
progress.report({
41+
message: `Disabling ${parseInt(index) + 1} of ${selectedNodes.length}`,
42+
increment: (parseInt(index) / selectedNodes.length) * 100,
43+
});
44+
try {
45+
const currentNode = selectedNodes[parseInt(index)];
46+
await disableLocalFile(
47+
currentNode.parentRegion.parentSession.session,
48+
{
49+
name: currentNode.localFile.file,
50+
regionName: currentNode.parentRegion.label,
51+
cicsPlex: currentNode.parentRegion.parentPlex ? currentNode.parentRegion.parentPlex.plexName : undefined,
52+
}
53+
);
54+
if (!parentRegions.includes(currentNode.parentRegion)) {
55+
parentRegions.push(currentNode.parentRegion);
56+
}
57+
} catch (err) {
58+
// @ts-ignore
59+
window.showErrorMessage(err);
60+
}
61+
}
62+
for (const parentRegion of parentRegions) {
63+
const programTree = parentRegion.children!.filter((child: any) => child.contextValue.includes("cicstreelocalfile."))[0];
64+
await programTree.loadContents();
65+
}
66+
tree._onDidChangeTreeData.fire(undefined);
67+
});
68+
} catch (err) {
69+
// @ts-ignore
70+
window.showErrorMessage(err);
71+
}
72+
} else {
73+
window.showErrorMessage("No CICS local file selected");
74+
}
75+
}
76+
);
77+
}
78+
79+
async function disableLocalFile(
80+
session: AbstractSession,
81+
parms: { name: string; regionName: string; cicsPlex: string; }
82+
): Promise<ICMCIApiResponse> {
83+
const requestBody: any = {
84+
request: {
85+
action: {
86+
$: {
87+
name: "DISABLE"
88+
},
89+
parameter: {
90+
$: {
91+
name: "BUSY",
92+
value: "WAIT"
93+
}
94+
}
95+
},
96+
97+
}
98+
99+
};
100+
101+
102+
103+
const cicsPlex = parms.cicsPlex === undefined ? "" : parms.cicsPlex + "/";
104+
const cmciResource =
105+
"/" +
106+
CicsCmciConstants.CICS_SYSTEM_MANAGEMENT +
107+
"/" +
108+
"CICSLocalFile" + //CicsCmciConstants.CICS_CMCI_EXTERNAL_RESOURCES[3]
109+
"/" +
110+
cicsPlex +
111+
parms.regionName +
112+
"?CRITERIA=(FILE=" +
113+
parms.name +
114+
")" ;//+
115+
//"&PARAMETER=('BUSY(WAIT).')";
116+
117+
return await CicsCmciRestClient.putExpectParsedXml(
118+
session,
119+
cmciResource,
120+
[],
121+
requestBody
122+
);
123+
}
+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/*
2+
* This program and the accompanying materials are made available under the terms of the
3+
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
4+
* https://www.eclipse.org/legal/epl-v20.html
5+
*
6+
* SPDX-License-Identifier: EPL-2.0
7+
*
8+
* Copyright Contributors to the Zowe Project.
9+
*
10+
*/
11+
12+
import {
13+
CicsCmciConstants,
14+
CicsCmciRestClient,
15+
ICMCIApiResponse,
16+
} from "@zowe/cics-for-zowe-cli";
17+
import { AbstractSession, couldNotInstantiateCommandHandler } from "@zowe/imperative";
18+
import { commands, ProgressLocation, TreeView, window } from "vscode";
19+
import { CICSRegionTree } from "../trees/CICSRegionTree";
20+
import { CICSTree } from "../trees/CICSTree";
21+
22+
export function getDisableTransactionCommand(tree: CICSTree, treeview: TreeView<any>) {
23+
return commands.registerCommand(
24+
"cics-extension-for-zowe.disableTransaction",
25+
async (node) => {
26+
if (node) {
27+
try {
28+
let selectedNodes = treeview.selection;
29+
let parentRegions: CICSRegionTree[] = [];
30+
31+
window.withProgress({
32+
title: 'Disable',
33+
location: ProgressLocation.Notification,
34+
cancellable: true
35+
}, async (progress, token) => {
36+
token.onCancellationRequested(() => {
37+
console.log("Cancelling the Disable");
38+
});
39+
for (const index in selectedNodes) {
40+
progress.report({
41+
message: `Disabling ${parseInt(index) + 1} of ${selectedNodes.length}`,
42+
increment: (parseInt(index) / selectedNodes.length) * 100,
43+
});
44+
try {
45+
const currentNode = selectedNodes[parseInt(index)];
46+
await disableTransaction(
47+
currentNode.parentRegion.parentSession.session,
48+
{
49+
name: currentNode.transaction.tranid,
50+
regionName: currentNode.parentRegion.label,
51+
cicsPlex: currentNode.parentRegion.parentPlex ? currentNode.parentRegion.parentPlex.plexName : undefined,
52+
}
53+
);
54+
if (!parentRegions.includes(currentNode.parentRegion)) {
55+
parentRegions.push(currentNode.parentRegion);
56+
}
57+
} catch (err) {
58+
const mMessageArr = err.mMessage.replaceAll(' ', '').split("\n");
59+
let resp;
60+
let resp2;
61+
let respAlt;
62+
let eibfnAlt;
63+
for (const val of mMessageArr) {
64+
const values = val.split(":");
65+
if (values[0] === "resp"){
66+
resp = values[1];
67+
} else if (values[0] === "resp2"){
68+
resp2 = values[1];
69+
} else if (values[0] === "resp_alt"){
70+
respAlt = values[1];
71+
} else if (values[0] === "eibfn_alt"){
72+
eibfnAlt = values[1];
73+
}
74+
}
75+
window.showErrorMessage(`Perform DISABLE on Transaction "${selectedNodes[parseInt(index)].transaction.tranid}" failed: EXEC CICS command (${eibfnAlt}) RESP(${respAlt}) RESP2(${resp2})`);
76+
}
77+
}
78+
for (const parentRegion of parentRegions) {
79+
const programTree = parentRegion.children!.filter((child: any) => child.contextValue.includes("cicstreetransaction."))[0];
80+
await programTree.loadContents();
81+
}
82+
tree._onDidChangeTreeData.fire(undefined);
83+
});
84+
} catch (err) {
85+
// @ts-ignore
86+
window.showErrorMessage(err);
87+
}
88+
} else {
89+
window.showErrorMessage("No CICS transaction selected");
90+
}
91+
}
92+
);
93+
}
94+
95+
async function disableTransaction(
96+
session: AbstractSession,
97+
parms: { name: string; regionName: string; cicsPlex: string; }
98+
): Promise<ICMCIApiResponse> {
99+
const requestBody: any = {
100+
request: {
101+
action: {
102+
$: {
103+
name: "DISABLE",
104+
},
105+
},
106+
},
107+
};
108+
109+
const cicsPlex = parms.cicsPlex === undefined ? "" : parms.cicsPlex + "/";
110+
const cmciResource =
111+
"/" +
112+
CicsCmciConstants.CICS_SYSTEM_MANAGEMENT +
113+
"/" +
114+
CicsCmciConstants.CICS_LOCAL_TRANSACTION +
115+
"/" +
116+
cicsPlex +
117+
parms.regionName +
118+
"?CRITERIA=(TRANID=" +
119+
parms.name +
120+
")";
121+
return await CicsCmciRestClient.putExpectParsedXml(
122+
session,
123+
cmciResource,
124+
[],
125+
requestBody
126+
);
127+
}

0 commit comments

Comments
 (0)