-
Notifications
You must be signed in to change notification settings - Fork 1
/
diff-1c-cf.js
112 lines (92 loc) · 3.36 KB
/
diff-1c-cf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//Čńďđŕâü, íŕ ďđŕâčëüíűé ďóňü.
var pathTo1C = "c:\\Program Files (x86)\\1cv82\\8.2.19.73\\bin\\1cv8.exe";
var FSO = WScript.CreateObject("Scripting.FileSystemObject")
var ScriptFile = FSO.GetFile(WScript.ScriptFullName)
ScriptDir = FSO.GetParentFolderName(ScriptFile)
var pathToBase = ScriptDir+"\\ibService"
var pathToV8reader = ScriptDir+"\\V8Reader.epf"
objArgs = WScript.Arguments;
num = objArgs.length;
if (num < 2)
{
WScript.Echo("Usage: [CScript | WScript] diff-doc.js base.doc new.doc");
WScript.Quit(1);
}
sBaseDoc = objArgs(0).replace(/\//g, '\\');
sNewDoc = objArgs(1).replace(/\//g, '\\');
sBaseDoc = sBaseDoc.replace(/\"/g, '');
sNewDoc = sNewDoc.replace(/\//g, '\\');
var WshShell = WScript.CreateObject ("WScript.Shell");
WScript.Echo (WshShell.CurrentDirectory);
WScript.Echo("File " + sBaseDoc + " ");
WScript.Echo("File " + sNewDoc + " ");
objScript = new ActiveXObject("Scripting.FileSystemObject");
if ( ! objScript.FileExists(sBaseDoc))
{
//sBaseDoc = objScript.GetAbsolutePathName(WshShell.CurrentDirectory + sBaseDoc)
//WScript.Echo("File " + sBaseDoc + " ");
//if ( ! objScript.FileExists(sBaseDoc))
//{
WScript.Echo("File " + sBaseDoc + " does not exist. Cannot compare the documents.");
WScript.Quit(1);
//}
}
if ( ! objScript.FileExists(sNewDoc))
{
//sNewDoc = objScript.GetAbsolutePathName(WshShell.CurrentDirectory + sNewDoc) //".\\"
//WScript.Echo("File " + sNewDoc + " ");
//if ( ! objScript.FileExists(sNewDoc))
//{
WScript.Echo("File " + sNewDoc + " does not exist. Cannot compare the documents.");
WScript.Quit(1);
//}
}
//Ňĺďĺđü çŕďčřĺě ďóňč ę ôŕéëŕě âî âńďîěîăŕňĺëüíűé ôŕéë.
var tfolder, tfile, tname, fname, TemporaryFolder = 2;
var file1 = objScript.GetFile(sBaseDoc);
var file2 = objScript.GetFile(sNewDoc);
WScript.Echo("file1.Name =" + file1.Name);
WScript.Echo("file2.Name =" + file2.Name);
tfolder = objScript.GetSpecialFolder(TemporaryFolder);
var Name2 = file2.Name;
if (file1.Name==file2.Name) {
tname = objScript.GetTempName();
Name2 = tname.replace(".", "") +"_"+ Name2
WScript.Echo("Name2 =" + Name2);
}
var NewsBaseDoc = objScript.buildPath(tfolder, file1.Name);
var NewsNewDoc = objScript.buildPath(tfolder, Name2);
WScript.Echo("NewsBaseDoc =" + NewsBaseDoc);
if (NewsBaseDoc != sBaseDoc) {
if (objScript.FileExists(NewsBaseDoc))
objScript.DeleteFile(NewsBaseDoc, true);
objScript.CopyFile(sBaseDoc, NewsBaseDoc);
}
WScript.Echo("NewsNewDoc =" + NewsNewDoc);
if (NewsNewDoc != sNewDoc) {
if (objScript.FileExists(NewsNewDoc))
objScript.DeleteFile(NewsNewDoc, true);
objScript.CopyFile(sNewDoc, NewsNewDoc);
}
tname = objScript.GetTempName();
tempfile = tfolder.CreateTextFile(tname,true,true);
tempfile.writeline(NewsBaseDoc);
tempfile.writeline(NewsNewDoc);
tempfile.close();
var WshShell = new ActiveXObject("WScript.Shell");
var cmd = '"'+pathTo1C+'" enterprise /F"'+pathToBase+'" /C"diff;'+objScript.GetAbsolutePathName(objScript.BuildPath(tfolder.path, tname))+';shutdownAfterClose" /Execute"'+pathToV8reader+'"' ;
WScript.Echo("cmd = " + cmd);
err = WshShell.Run(cmd, 1, true);//2
//var i = 0;
//while (i < 50) {
// i=i+1;
// //WScript.Echo(oExec.Status);
// WScript.sleep(100);
//}
//WScript.sleep(100 * 50);
if (objScript.FileExists(NewsBaseDoc))
objScript.DeleteFile(NewsBaseDoc, true);
if (objScript.FileExists(NewsNewDoc))
objScript.DeleteFile(NewsNewDoc, true);
file1 = null;
file2 = null;