Commit 02666472 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

fix bug #28735

Переподключение при разрыве соединения
1) Проверяем файл на сборку. Если она началась, то останавливаем.
2) Если сборка уже завершилась, то отправляем пользователю уведомление о невозможности редактировать дальше
3) Далее проверяем время последнего сохранения и lock-и пользователя. Если кто-то уже успел сохранить или заблокировать объекты, то мы не можем дальше редактировать.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@61464 954022d7-b5bf-4e40-9824-e11837661b57
parent 039d4ce2
...@@ -272,7 +272,7 @@ ...@@ -272,7 +272,7 @@
this.saveLockCallbackErrorTimeOutId = null; this.saveLockCallbackErrorTimeOutId = null;
this.saveCallbackErrorTimeOutId = null; this.saveCallbackErrorTimeOutId = null;
this._id = null; this._id = null;
this._indexuser = -1; this._indexUser = -1;
// Если пользователей больше 1, то совместно редактируем // Если пользователей больше 1, то совместно редактируем
this.isCoAuthoring = false; this.isCoAuthoring = false;
// Мы сами отключились от совместного редактирования // Мы сами отключились от совместного редактирования
...@@ -311,6 +311,7 @@ ...@@ -311,6 +311,7 @@
this.ownedLockBlocks = []; this.ownedLockBlocks = [];
this.sockjs_url = null; this.sockjs_url = null;
this.sockjs = null; this.sockjs = null;
this.editorType = -1;
this._isExcel = false; this._isExcel = false;
this._isPresentation = false; this._isPresentation = false;
this._isAuth = false; this._isAuth = false;
...@@ -329,9 +330,9 @@ ...@@ -329,9 +330,9 @@
DocsCoApi.prototype.get_state = function () { DocsCoApi.prototype.get_state = function () {
return this._state; return this._state;
}; };
DocsCoApi.prototype.get_indexUser = function () { DocsCoApi.prototype.get_indexUser = function () {
return this._indexuser; return this._indexUser;
}; };
DocsCoApi.prototype.getSessionId = function () { DocsCoApi.prototype.getSessionId = function () {
...@@ -353,7 +354,7 @@ ...@@ -353,7 +354,7 @@
var isLock = false; var isLock = false;
var idLockInArray = null; var idLockInArray = null;
for (; i < lengthArray; ++i) { for (; i < lengthArray; ++i) {
idLockInArray = (this._isExcel) ? arrayBlockId[i].guid : (this._isPresentation) ? arrayBlockId[i]["guid"] : arrayBlockId[i]; idLockInArray = (this._isExcel || this._isPresentation) ? arrayBlockId[i]['guid'] : arrayBlockId[i];
if (this._locks[idLockInArray] && 0 !== this._locks[idLockInArray].state) { if (this._locks[idLockInArray] && 0 !== this._locks[idLockInArray].state) {
isLock = true; isLock = true;
break; break;
...@@ -362,11 +363,11 @@ ...@@ -362,11 +363,11 @@
if (0 === lengthArray) if (0 === lengthArray)
isLock = true; isLock = true;
idLockInArray = (this._isExcel) ? arrayBlockId[0].guid : (this._isPresentation) ? arrayBlockId[0]["guid"] : arrayBlockId[0]; idLockInArray = (this._isExcel || this._isPresentation) ? arrayBlockId[0]['guid'] : arrayBlockId[0];
if (!isLock) { if (!isLock) {
//Ask //Ask
this._locks[idLockInArray] = {"state": 1};//1-asked for block this._locks[idLockInArray] = {'state': 1};//1-asked for block
if (callback && _.isFunction(callback)) { if (callback && _.isFunction(callback)) {
this._lockCallbacks[idLockInArray] = callback; this._lockCallbacks[idLockInArray] = callback;
var lockCalbacks = this._lockCallbacks; var lockCalbacks = this._lockCallbacks;
...@@ -375,22 +376,17 @@ ...@@ -375,22 +376,17 @@
window.setTimeout(function () { window.setTimeout(function () {
if (lockCalbacks.hasOwnProperty(idLockInArray)) { if (lockCalbacks.hasOwnProperty(idLockInArray)) {
//Not signaled already //Not signaled already
callback({error: "Timed out"}); callback({error: 'Timed out'});
delete lockCalbacks[idLockInArray]; delete lockCalbacks[idLockInArray];
} }
}, this.errorTimeOut); }, this.errorTimeOut);
} }
if (this._isExcel) this._send({"type": 'getLock', 'editorType': this.editorType, 'block': arrayBlockId});
this._send({"type": "getLockRange", "block": arrayBlockId});
else if (this._isPresentation)
this._send({"type": "getLockPresentation", "block": arrayBlockId});
else
this._send({"type": "getLock", "block": arrayBlockId});
} else { } else {
// Вернем ошибку, т.к. залочены элементы // Вернем ошибку, т.к. залочены элементы
window.setTimeout(function () { window.setTimeout(function () {
if (callback && _.isFunction(callback)) { if (callback && _.isFunction(callback)) {
callback({error: idLockInArray + "-lock"}); callback({error: idLockInArray + '-lock'});
} }
}, 100); }, 100);
} }
...@@ -528,9 +524,8 @@ ...@@ -528,9 +524,8 @@
}; };
DocsCoApi.prototype._onMessages = function (data) { DocsCoApi.prototype._onMessages = function (data) {
if (data["messages"] && this.onMessage) { if (data["messages"] && this.onMessage)
this.onMessage(data["messages"]); this.onMessage(data["messages"]);
}
}; };
DocsCoApi.prototype._onGetLock = function (data) { DocsCoApi.prototype._onGetLock = function (data) {
...@@ -538,8 +533,8 @@ ...@@ -538,8 +533,8 @@
for (var key in data["locks"]) { for (var key in data["locks"]) {
if (data["locks"].hasOwnProperty(key)) { if (data["locks"].hasOwnProperty(key)) {
var lock = data["locks"][key], var lock = data["locks"][key],
blockTmp = (this._isExcel) ? lock["block"]["guid"] : (this._isPresentation) ? lock["block"]["guid"] : key, blockTmp = (this._isExcel || this._isPresentation) ? lock["block"]["guid"] : key,
blockValue = (this._isExcel) ? lock["block"] : (this._isPresentation) ? lock["block"] : key; blockValue = (this._isExcel || this._isPresentation) ? lock["block"] : key;
if (lock !== null) { if (lock !== null) {
var changed = true; var changed = true;
if (this._locks[blockTmp] && 1 !== this._locks[blockTmp].state /*asked for it*/) { if (this._locks[blockTmp] && 1 !== this._locks[blockTmp].state /*asked for it*/) {
...@@ -581,7 +576,7 @@ ...@@ -581,7 +576,7 @@
for (var block in data["locks"]) { for (var block in data["locks"]) {
if (data["locks"].hasOwnProperty(block)) { if (data["locks"].hasOwnProperty(block)) {
var lock = data["locks"][block], var lock = data["locks"][block],
blockTmp = (this._isExcel) ? lock["block"]["guid"] : (this._isPresentation) ? lock["block"]["guid"] : lock["block"]; blockTmp = (this._isExcel || this._isPresentation) ? lock["block"]["guid"] : lock["block"];
if (lock !== null) { if (lock !== null) {
this._locks[blockTmp] = {"state":0, "user":lock["user"], "time":lock["time"], "changes":lock["changes"], "block":lock["block"]}; this._locks[blockTmp] = {"state":0, "user":lock["user"], "time":lock["time"], "changes":lock["changes"], "block":lock["block"]};
if (this.onLocksReleased) { if (this.onLocksReleased) {
...@@ -603,7 +598,7 @@ ...@@ -603,7 +598,7 @@
for (var block in data["locks"]) { for (var block in data["locks"]) {
if (data["locks"].hasOwnProperty(block)) { if (data["locks"].hasOwnProperty(block)) {
var lock = data["locks"][block], var lock = data["locks"][block],
blockTmp = (this._isExcel) ? lock["block"]["guid"] : (this._isPresentation) ? lock["block"]["guid"] : lock["block"]; blockTmp = (this._isExcel || this._isPresentation) ? lock["block"]["guid"] : lock["block"];
if (lock !== null) { if (lock !== null) {
this._locks[blockTmp] = {"state":0, "user":lock["user"], "time":lock["time"], "changes":lock["changes"], "block":lock["block"]}; this._locks[blockTmp] = {"state":0, "user":lock["user"], "time":lock["time"], "changes":lock["changes"], "block":lock["block"]};
if (this.onLocksReleased) { if (this.onLocksReleased) {
...@@ -667,18 +662,6 @@ ...@@ -667,18 +662,6 @@
this.onUnSaveLock(); this.onUnSaveLock();
}; };
DocsCoApi.prototype._checkSaveChangesInDisconnect = function (allServerChanges) {
if (0 < allServerChanges.length) {
var change = allServerChanges[allServerChanges.length - 1];
var changesOneUser = change['change'];
if (changesOneUser) {
if (change['user'] !== this._userId)
return this.lastOtherSaveTime !== change['time'];
}
}
return false;
};
DocsCoApi.prototype._updateChanges = function (allServerChanges, changesIndex, bFirstLoad) { DocsCoApi.prototype._updateChanges = function (allServerChanges, changesIndex, bFirstLoad) {
if (this.onSaveChanges) { if (this.onSaveChanges) {
this.changesIndex = changesIndex; this.changesIndex = changesIndex;
...@@ -805,14 +788,14 @@ ...@@ -805,14 +788,14 @@
DocsCoApi.prototype._onAuth = function (data) { DocsCoApi.prototype._onAuth = function (data) {
if (true === this._isAuth) { if (true === this._isAuth) {
// Мы уже авторизовывались, это просто reconnect и нужно проверить не было ли изменений пока не было сети this._state = 2; // Authorized
if (this._checkSaveChangesInDisconnect(data['changes'] || [])) { // Мы уже авторизовывались, нужно обновить пользователей (т.к. пользователи могли входить и выходить пока у нас не было соединения)
// делаем drop this._onAuthParticipantsChanged(data['participants']);
this._onDrop();
} else { //if (this.ownedLockBlocks && this.ownedLockBlocks.length > 0) {
// Нужно обновить пользователей (т.к. пользователи могли входить и выходить пока у нас не было соединения) // this._onPreviousLocks(data["locks"], this.ownedLockBlocks);
this._onAuthParticipantsChanged(data['participants']); //}
} this._onGetLock(data);
return; return;
} }
if (data['result'] === 1) { if (data['result'] === 1) {
...@@ -825,18 +808,12 @@ ...@@ -825,18 +808,12 @@
this._onAuthParticipantsChanged(data['participants']); this._onAuthParticipantsChanged(data['participants']);
this._onSetIndexUser(this._indexuser = data['indexUser']); this._onSetIndexUser(this._indexUser = data['indexUser']);
this._userId = this._user.asc_getId() + this._indexuser; this._userId = this._user.asc_getId() + this._indexUser;
this._onMessages(data);
this._onGetLock(data);
if (data["messages"] && this.onMessage) {
this._onMessages(data);
}
if (data["locks"]) {
if (this.ownedLockBlocks && this.ownedLockBlocks.length > 0) {
this._onPreviousLocks(data["locks"], this.ownedLockBlocks);
}
this._onGetLock(data);
}
// Применения изменений пользователя // Применения изменений пользователя
if (window['AscApplyChanges'] && window['AscChanges']) { if (window['AscApplyChanges'] && window['AscChanges']) {
var userOfflineChanges = window['AscChanges'], changeOneUser; var userOfflineChanges = window['AscChanges'], changeOneUser;
...@@ -868,6 +845,7 @@ ...@@ -868,6 +845,7 @@
this._initCallback = callback; this._initCallback = callback;
this.ownedLockBlocks = []; this.ownedLockBlocks = [];
this.sockjs_url = this._url + '/doc/'+docid+'/c'; this.sockjs_url = this._url + '/doc/'+docid+'/c';
this.editorType = editorType;
this._isExcel = c_oEditorId.Spreadsheet === editorType; this._isExcel = c_oEditorId.Spreadsheet === editorType;
this._isPresentation = c_oEditorId.Presentation === editorType; this._isPresentation = c_oEditorId.Presentation === editorType;
this._isAuth = false; this._isAuth = false;
...@@ -894,13 +872,11 @@ ...@@ -894,13 +872,11 @@
if (t._locks) { if (t._locks) {
t.ownedLockBlocks = []; t.ownedLockBlocks = [];
//If we already have locks //If we already have locks
for (var block in t._locks) { for (var block in t._locks) if (t._locks.hasOwnProperty(block)) {
if (t._locks.hasOwnProperty(block)) { var lock = t._locks[block];
var lock = t._locks[block]; if (lock["state"] === 2) {
if (lock["state"] === 2) { //Our lock.
//Our lock. t.ownedLockBlocks.push(lock["blockValue"]);
t.ownedLockBlocks.push(lock["block"]);
}
} }
} }
t._locks = {}; t._locks = {};
...@@ -912,10 +888,13 @@ ...@@ -912,10 +888,13 @@
'documentCallbackUrl' : t._documentCallbackUrl, 'documentCallbackUrl' : t._documentCallbackUrl,
'token' : t._token, 'token' : t._token,
'user' : { 'user' : {
'id' : t._user.asc_getId(), 'id' : t._user.asc_getId(),
'name' : t._user.asc_getUserName() 'name' : t._user.asc_getUserName(),
'indexUser' : t._indexUser
}, },
'locks' : t.ownedLockBlocks, 'editorType': t.editorType,
'lastOtherSaveTime' : t.lastOtherSaveTime,
'block' : t.ownedLockBlocks,
'sessionId' : t._id, 'sessionId' : t._id,
'server' : window.location.protocol + '//' + window.location.host + g_sMainServiceLocalUrl, 'server' : window.location.protocol + '//' + window.location.host + g_sMainServiceLocalUrl,
'documentFormatSave' : t._documentFormatSave, 'documentFormatSave' : t._documentFormatSave,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment