markus / MarkusLogview / MARKUS_LOGVIEW / Scripts / signalR.js @ 315ae55e
이력 | 보기 | 이력해설 | 다운로드 (16.4 KB)
1 |
(function () { |
---|---|
2 |
|
3 |
//MarkusHub
|
4 |
// doftech url
|
5 |
$.connection.hub.url = "http://cloud.devdoftech.co.kr:5100/signalr/js"; |
6 |
|
7 |
// hyosung url
|
8 |
//$.connection.hub.url = "http://10.11.252.3:9875/signalr/js";
|
9 |
|
10 |
var markusNotificationHub = $.connection.MarkusHub; |
11 |
|
12 |
$.extend(markusNotificationHub.client, {
|
13 |
// [ Convert ]
|
14 |
// Insert
|
15 |
BroadcastConvertTableInserted: function (item, projStatus) { |
16 |
|
17 |
var projectTable = $("#ProjectList").DataTable(); |
18 |
var selectedProjectNO = !!projectTable.row('.selected').data() ? projectTable.row('.selected').data()[0] : null; |
19 |
|
20 |
if (selectedProjectNO === item["PROJECT_NO"]) { |
21 |
TableAddData(GLOBAL_REQUEST_NAME.Convert, item, projStatus); |
22 |
} |
23 |
|
24 |
}, |
25 |
// Change
|
26 |
BroadcastConvertTableChanged: function (data, projStatus) { |
27 |
updateConvertTable(data, projStatus); |
28 |
$.connection.MarkusHub.server.GetProjectList(data.PROJECT_NO, GLOBAL_REQUEST_NAME.Convert);
|
29 |
}, |
30 |
// Delete
|
31 |
BroadcastConvertTableDeleted: function (data) { |
32 |
deleteConvertTable(data); |
33 |
$.connection.MarkusHub.server.GetProjectList(data.PROJECT_NO, GLOBAL_REQUEST_NAME.Convert);
|
34 |
}, |
35 |
// [ Merge ]
|
36 |
// Insert
|
37 |
BroadcastMergeTableInserted: function (item, projStatus) { |
38 |
|
39 |
var projectTable = $("#ProjectList").DataTable(); |
40 |
var selectedProjectNO = !!projectTable.row('.selected').data() ? projectTable.row('.selected').data()[0] : null; |
41 |
|
42 |
if (selectedProjectNO === item["PROJECT_NO"]) { |
43 |
TableAddData(GLOBAL_REQUEST_NAME.Merge, item, projStatus); |
44 |
} |
45 |
|
46 |
}, |
47 |
// Change
|
48 |
BroadcastMergeTableChanged: function (data, projStatus) { |
49 |
updateMergeTable(data, projStatus); |
50 |
$.connection.MarkusHub.server.GetProjectList(data.PROJECT_NO, GLOBAL_REQUEST_NAME.Merge);
|
51 |
}, |
52 |
// Delete
|
53 |
BroadcastMergeTableDeleted: function (data) { |
54 |
deleteMergeTable(data); |
55 |
$.connection.MarkusHub.server.GetProjectList(data.PROJECT_NO, GLOBAL_REQUEST_NAME.Merge);
|
56 |
} |
57 |
|
58 |
}); |
59 |
|
60 |
$.connection.hub.start({ transport: 'longPolling' }) |
61 |
.done(function () {
|
62 |
$.connection.hub.logging = true; |
63 |
console.log("connection hub id :" + $.connection.hub.id); |
64 |
console.log("Connected, transport = " + $.connection.hub.transport.name); |
65 |
//$.connection.MarkusHub.server.announce("connected!!!");
|
66 |
}) |
67 |
.fail(function () {
|
68 |
console.log("failed");
|
69 |
}); |
70 |
|
71 |
|
72 |
$.connection.MarkusHub.client.UpdateProjectList = function (data, type) { |
73 |
|
74 |
if (location.pathname.toLowerCase().indexOf(type.replace("Document", "")) != -1) { |
75 |
updateProjectTable(data[0]);
|
76 |
} |
77 |
|
78 |
}; |
79 |
|
80 |
var tryingToReconnect = false; |
81 |
|
82 |
$.connection.hub.reconnecting(function () { |
83 |
tryingToReconnect = true;
|
84 |
console.log("[ Makrus Hub reconnecting ]");
|
85 |
}); |
86 |
|
87 |
$.connection.hub.reconnected(function () { |
88 |
tryingToReconnect = false;
|
89 |
console.log("[ Makrus Hub reconnected ]");
|
90 |
}); |
91 |
|
92 |
$.connection.hub.disconnected(function () { |
93 |
|
94 |
if ($.connection.hub.lastError) { |
95 |
console.log("Disconnected. Reason: " + $.connection.hub.lastError.message); |
96 |
} |
97 |
|
98 |
$.connection.hub.start({ transport: 'longPolling' }) |
99 |
.done(function () {
|
100 |
|
101 |
console.log("Disconnected !! reconnection hub id :" + $.connection.hub.id); |
102 |
console.log("Connected, transport = " + $.connection.hub.transport.name); |
103 |
|
104 |
}) |
105 |
.fail(function () {
|
106 |
console.log("failed");
|
107 |
}); |
108 |
|
109 |
}); |
110 |
|
111 |
//클라이언트 느리거나 자주 삭제 연결을 검색 하는 경우 발생 합니다.
|
112 |
$.connection.hub.connectionSlow(function () { |
113 |
console.log('We are currently experiencing difficulties with the connection.')
|
114 |
}); |
115 |
|
116 |
})(); |
117 |
|
118 |
var TableAddData = function (type, addData, projStat) { |
119 |
|
120 |
var addRow = null; |
121 |
var targetTable = null; |
122 |
|
123 |
if (type == GLOBAL_REQUEST_NAME.Convert) {
|
124 |
|
125 |
targetTable = $("#ConvertList").DataTable(); |
126 |
|
127 |
} else if (type == GLOBAL_REQUEST_NAME.Merge) { |
128 |
|
129 |
targetTable = $("#MergePdfList").DataTable(); |
130 |
|
131 |
} |
132 |
|
133 |
targetTable.ajax.reload(); |
134 |
|
135 |
} |
136 |
|
137 |
var updateProjectTable = function (projData) { |
138 |
|
139 |
var projectListTable = $("#ProjectList").DataTable(); |
140 |
|
141 |
for (var idx = 0; idx < projectListTable.rows().count(); idx++) { |
142 |
|
143 |
var thisRow = projectListTable.row(idx);
|
144 |
var rowData = thisRow.data();
|
145 |
|
146 |
if (rowData[0] === projData["ProjectNO"]) { |
147 |
|
148 |
rowData[STATUS_DEFAULT_INDEX.add] = projData["Insert"];
|
149 |
rowData[STATUS_DEFAULT_INDEX.wait] = projData["Wait"];
|
150 |
rowData[STATUS_DEFAULT_INDEX.process] = projData["Crop"];
|
151 |
rowData[STATUS_DEFAULT_INDEX.success] = projData["Success"];
|
152 |
rowData[STATUS_DEFAULT_INDEX.error] = projData["Error"];
|
153 |
rowData[STATUS_DEFAULT_INDEX.entrie] = projData["Entire"];
|
154 |
|
155 |
thisRow.data(rowData).draw(false);
|
156 |
//convTable.draw(false);
|
157 |
|
158 |
break;
|
159 |
|
160 |
} |
161 |
|
162 |
}; |
163 |
} |
164 |
|
165 |
var updateConvertTable = function (convData, status) { |
166 |
|
167 |
var changeData = convData;
|
168 |
var convTable = $("#ConvertList").DataTable(); |
169 |
|
170 |
for (var i = 0; i < convTable.rows().count(); i++) { |
171 |
|
172 |
var targetRow = convTable.row(i);
|
173 |
//var rowData = targetRow.data();
|
174 |
var dataCells = $(targetRow.node()).find("td"); |
175 |
|
176 |
if (targetRow.data()["ID"] == changeData["ID"]) { |
177 |
|
178 |
// 변경될 데이터
|
179 |
var COLUMN_FIX_NO = initConverDocumentColumn();
|
180 |
|
181 |
for (var item in COLUMN_FIX_NO) { |
182 |
|
183 |
var fixCol = COLUMN_FIX_NO[item];
|
184 |
var cellData = $(dataCells[fixCol.index]).text() |
185 |
|
186 |
switch (fixCol.key) {
|
187 |
case COLUMN_FIX_NO.totalPage.key:
|
188 |
|
189 |
if (cellData != changeData[fixCol.key]) {
|
190 |
convTable.row(i).column(fixCol.index).cell($(dataCells[fixCol.index])).data(changeData[fixCol.key]);
|
191 |
} |
192 |
|
193 |
break;
|
194 |
|
195 |
case COLUMN_FIX_NO.createdDate.key:
|
196 |
|
197 |
var viewCreatedDate = viewDate(changeData[fixCol.key]);
|
198 |
if (cellData != viewCreatedDate) {
|
199 |
convTable.row(i).column(fixCol.index).cell($(dataCells[fixCol.index])).data(viewCreatedDate);
|
200 |
} |
201 |
break;
|
202 |
|
203 |
case COLUMN_FIX_NO.currentPage.key:
|
204 |
|
205 |
var targetNode = $(convTable.row(i).column(fixCol.index).cell($(dataCells[fixCol.index])).node()) |
206 |
var targetNodeData = parseInt(convTable.row(i).column(fixCol.index).cell($(dataCells[fixCol.index])).data()) |
207 |
|
208 |
if (targetNodeData !== changeData[fixCol.key]) {
|
209 |
targetNode.addClass("update-row");
|
210 |
} else {
|
211 |
targetNode.removeClass("update-row");
|
212 |
} |
213 |
|
214 |
convTable.row(i).column(fixCol.index).cell($(dataCells[fixCol.index])).data(changeData[fixCol.key]);
|
215 |
|
216 |
break;
|
217 |
case COLUMN_FIX_NO.startDateTime.key:
|
218 |
|
219 |
var viewStartDate = viewDate(changeData[fixCol.key]);
|
220 |
if (cellData != viewStartDate) {
|
221 |
convTable.row(i).column(fixCol.index).cell($(dataCells[fixCol.index])).data(viewStartDate);
|
222 |
} |
223 |
|
224 |
break;
|
225 |
case COLUMN_FIX_NO.endDateTime.key:
|
226 |
|
227 |
var viewEndDate = viewDate(changeData[fixCol.key]);
|
228 |
if (cellData != viewEndDate) {
|
229 |
convTable.row(i).column(fixCol.index).cell($(dataCells[fixCol.index])).data(viewEndDate);
|
230 |
} |
231 |
|
232 |
break;
|
233 |
case COLUMN_FIX_NO.converTime.key:
|
234 |
|
235 |
var viewConvertDate = calcDate(changeData[COLUMN_FIX_NO.startDateTime.key], changeData[COLUMN_FIX_NO.endDateTime.key]);
|
236 |
if (cellData != viewConvertDate) {
|
237 |
convTable.row(i).column(fixCol.index).cell($(dataCells[fixCol.index])).data(viewConvertDate);
|
238 |
} |
239 |
|
240 |
break;
|
241 |
case COLUMN_FIX_NO.status.key:
|
242 |
|
243 |
var statConvert = pdfStatusConvert(changeData[COLUMN_FIX_NO.status.key], status)
|
244 |
|
245 |
// 성공 상태로 바뀌면 Convert URL , Viewinfo Data 를 가져와야 한다.
|
246 |
if (cellData != statConvert) {
|
247 |
|
248 |
convTable.row(i).column(fixCol.index).cell($(dataCells[fixCol.index])).data(statConvert);
|
249 |
|
250 |
if (changeData[COLUMN_FIX_NO.status.key] == COMPLETE_FIX_NO) {
|
251 |
completeConverting(changeData, dataCells); |
252 |
} |
253 |
|
254 |
} |
255 |
break;
|
256 |
|
257 |
} |
258 |
|
259 |
} |
260 |
|
261 |
return false; |
262 |
|
263 |
} |
264 |
} |
265 |
|
266 |
} |
267 |
|
268 |
var completeConverting = function (completeData, element) { |
269 |
|
270 |
$.ajax({
|
271 |
url: "/api/convert/complete", |
272 |
type: "POST", |
273 |
headers: transportHeader(),
|
274 |
data: completeData,
|
275 |
success: function (ret) { |
276 |
|
277 |
var colNum = initConverDocumentColumn();
|
278 |
var convertTable = $("#ConvertList").DataTable(); |
279 |
var tableData = convertTable.rows().data();
|
280 |
|
281 |
for (var i = 0; i < tableData.length; i++) { |
282 |
|
283 |
var delData = tableData[i];
|
284 |
|
285 |
if (delData[0] == ret["ID"]) { |
286 |
|
287 |
// view info
|
288 |
$(convertTable.row(i).column(colNum.viewInfo.index).cell($(element[colNum.viewInfo.index])).node()).children().attr("href", "kcom://" + ret["ViewInfo"]).text("View"); |
289 |
// document url
|
290 |
$(convertTable.row(i).column(colNum.convertURL.index).cell($(element[colNum.convertURL.index])).node()).children().attr("href", ret["ConvertURL"]).text("PDF"); |
291 |
|
292 |
} |
293 |
} |
294 |
|
295 |
} |
296 |
}) |
297 |
} |
298 |
|
299 |
var deleteConvertTable = function (data) { |
300 |
|
301 |
var convertTable = $("#ConvertList").DataTable(); |
302 |
var tableData = convertTable.rows().data();
|
303 |
convertTable.row("#" + data["ID"]).remove().draw(false); |
304 |
|
305 |
} |
306 |
|
307 |
|
308 |
var updateMergeTable = function (mergeData, status) { |
309 |
|
310 |
var MergeTable = $("#MergePdfList").DataTable(); |
311 |
var changeData = mergeData;
|
312 |
// change type 3 : update
|
313 |
for (var i = 0; i < MergeTable.rows().count(); i++) { |
314 |
|
315 |
var targetRow = MergeTable.row(i);
|
316 |
//var rowData = targetRow.data();
|
317 |
var dataCells = $(targetRow.node()).find("td"); |
318 |
var rowData = targetRow.data();
|
319 |
|
320 |
if (rowData["ID"] == changeData["ID"]) { |
321 |
|
322 |
// 변경될 데이터
|
323 |
|
324 |
var COLUMN_FIX_NO = initFinalDocumentColumn();
|
325 |
|
326 |
for (var item in COLUMN_FIX_NO) { |
327 |
|
328 |
var fixCol = COLUMN_FIX_NO[item];
|
329 |
var cellData = $(dataCells[fixCol.index]).text() |
330 |
|
331 |
switch (fixCol.key) {
|
332 |
case COLUMN_FIX_NO.totalPage.key:
|
333 |
|
334 |
if (cellData != changeData[fixCol.key]) {
|
335 |
MergeTable.row(i).column(fixCol.index).cell($(dataCells[fixCol.index])).data(changeData[fixCol.key]);
|
336 |
} |
337 |
|
338 |
|
339 |
break;
|
340 |
|
341 |
case COLUMN_FIX_NO.createdDate.key:
|
342 |
|
343 |
var viewCreatedDate = viewDate(changeData[fixCol.key]);
|
344 |
if (cellData != viewCreatedDate) {
|
345 |
MergeTable.row(i).column(fixCol.index).cell($(dataCells[fixCol.index])).data(viewCreatedDate);
|
346 |
} |
347 |
|
348 |
|
349 |
break;
|
350 |
|
351 |
case COLUMN_FIX_NO.currentPage.key:
|
352 |
|
353 |
var targetNode = $(MergeTable.row(i).column(fixCol.index).cell($(dataCells[fixCol.index])).node()) |
354 |
var targetNodeData = parseInt(MergeTable.row(i).column(fixCol.index).cell($(dataCells[fixCol.index])).data()) |
355 |
|
356 |
if (targetNodeData !== changeData[fixCol.key]) {
|
357 |
targetNode.addClass("update-row");
|
358 |
} else {
|
359 |
targetNode.removeClass("update-row");
|
360 |
} |
361 |
|
362 |
MergeTable.row(i).column(fixCol.index).cell($(dataCells[fixCol.index])).data(changeData[fixCol.key]);
|
363 |
|
364 |
break;
|
365 |
case COLUMN_FIX_NO.startDateTime.key:
|
366 |
|
367 |
var viewStartDate = viewDate(changeData[fixCol.key]);
|
368 |
if (cellData != viewStartDate) {
|
369 |
MergeTable.row(i).column(fixCol.index).cell($(dataCells[fixCol.index])).data(viewStartDate);
|
370 |
} |
371 |
|
372 |
|
373 |
break;
|
374 |
case COLUMN_FIX_NO.endDateTime.key:
|
375 |
|
376 |
var viewEndDate = viewDate(changeData[fixCol.key]);
|
377 |
if (cellData != viewEndDate) {
|
378 |
MergeTable.row(i).column(fixCol.index).cell($(dataCells[fixCol.index])).data(viewEndDate);
|
379 |
} |
380 |
|
381 |
|
382 |
break;
|
383 |
case COLUMN_FIX_NO.converTime.key:
|
384 |
|
385 |
var viewConvertDate = calcDate(changeData[COLUMN_FIX_NO.startDateTime.key], changeData[COLUMN_FIX_NO.endDateTime.key]);
|
386 |
if (cellData != viewConvertDate) {
|
387 |
MergeTable.row(i).column(fixCol.index).cell($(dataCells[fixCol.index])).data(viewConvertDate);
|
388 |
} |
389 |
|
390 |
|
391 |
break;
|
392 |
case COLUMN_FIX_NO.status.key:
|
393 |
|
394 |
var statConvert = pdfStatusConvert(changeData[COLUMN_FIX_NO.status.key], status)
|
395 |
if (cellData != statConvert) {
|
396 |
|
397 |
MergeTable.row(i).column(fixCol.index).cell($(dataCells[fixCol.index])).data(statConvert);
|
398 |
|
399 |
if (changeData[COLUMN_FIX_NO.status.key] == COMPLETE_FIX_NO) {
|
400 |
completeMerge(changeData, dataCells); |
401 |
} |
402 |
|
403 |
} |
404 |
|
405 |
break;
|
406 |
|
407 |
} |
408 |
|
409 |
} |
410 |
|
411 |
return false; |
412 |
|
413 |
} |
414 |
|
415 |
} |
416 |
} |
417 |
|
418 |
var completeMerge = function (completeData, element) { |
419 |
|
420 |
$.ajax({
|
421 |
url: "/api/merge/complete", |
422 |
type: "POST", |
423 |
headers: transportHeader(),
|
424 |
data: completeData,
|
425 |
success: function (ret) { |
426 |
|
427 |
var colNum = initFinalDocumentColumn();
|
428 |
var MergeTable = $("#MergePdfList").DataTable(); |
429 |
var tableData = MergeTable.rows().data();
|
430 |
|
431 |
for (var i = 0; i < tableData.length; i++) { |
432 |
|
433 |
var delData = tableData[i];
|
434 |
|
435 |
if (delData[0] == ret["ID"]) { |
436 |
|
437 |
// view info
|
438 |
$(MergeTable.row(i).column(colNum.viewInfo.index).cell($(element[colNum.viewInfo.index])).node()).children().attr("href", "kcom://" + ret["ViewInfo"]).text("View"); |
439 |
// document url
|
440 |
$(MergeTable.row(i).column(colNum.finalDocumentURL.index).cell($(element[colNum.finalDocumentURL.index])).node()).children().attr("href", ret["MergeURL"]).text("PDF"); |
441 |
} |
442 |
} |
443 |
|
444 |
} |
445 |
|
446 |
}) |
447 |
|
448 |
} |
449 |
|
450 |
var deleteMergeTable = function (data) { |
451 |
|
452 |
var MergeTable = $("#MergePdfList").DataTable(); |
453 |
var tableData = MergeTable.rows().data();
|
454 |
MergeTable.row("#" + data["ID"]).remove().draw(false); |
455 |
} |
456 |
|
457 |
var deleteDocument_Complete = function () { |
458 |
|
459 |
var notify = $.notify({ |
460 |
// options
|
461 |
icon: 'glyphicon glyphicon-warning-sign', |
462 |
message: 'Hello World' |
463 |
}, { |
464 |
// settings
|
465 |
type: 'success', |
466 |
allow_dismiss: false, |
467 |
newest_on_top: true, |
468 |
offset: 25, |
469 |
delay: 2000, |
470 |
animate: {
|
471 |
enter: 'animated fadeInDown', |
472 |
exit: 'animated fadeOutUp' |
473 |
}, |
474 |
placement: {
|
475 |
from: "top", |
476 |
align: "right" |
477 |
}, |
478 |
spacing: 10, |
479 |
icon_type: 'class', |
480 |
mouse_over: null, |
481 |
}); |
482 |
|
483 |
//notify.update("message", "test");
|
484 |
|
485 |
} |
486 |
|
487 |
|
488 |
var pdfStatusConvert = function (docStatus, list) { |
489 |
var statusNo = parseInt(docStatus);
|
490 |
for (var i = 0; i < list.length; i++) { |
491 |
if (parseInt(list[i].Value) === statusNo) {
|
492 |
return list[i].Property
|
493 |
} |
494 |
} |
495 |
} |