Commit eee2fdf2 authored by Alexey.Golubev's avatar Alexey.Golubev Committed by Alexander.Trofimov

Логика трека вынесена в отдельный файл. Добавлено трекание по сессиям....

Логика трека вынесена в отдельный файл. Добавлено трекание по сессиям. обновлены скрипты для сборки.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@51198 954022d7-b5bf-4e40-9824-e11837661b57
parent 1b011f7f
......@@ -35,6 +35,7 @@
"../Word/Drawing/AllFonts.js",
"../Excel/model/DrawingObjects/GlobalLoaders.js",
"../Common/FontsFreeType/FontExport.js",
"../Common/trackFile.js",
"../Excel/apiDefines.js",
"../Excel/offlinedocs/test-workbook9/Editor.js",
"../Excel/offlinedocs/empty-workbook.js",
......
(
/**
* @param {window} window
* @param {undefined} undefined
*/
function(window, undefined)
{
var asc = window["Asc"] ? window["Asc"] : (window["Asc"] = {});
// tracking type by license type
var c_TrackingType = {
TT_USER_COUNT: 0, // by user count
TT_ACTIVE_CONNECTION: 1, // by active connections
TT_TIME_USAGE: 2, // by time of editing
TT_DOCUMENT_SESSION: 3 // by document editing session count
};
function CTrackFile(obj)
{
if ( !(this instanceof CTrackFile) ) {return new CTrackFile(obj);}
this.trackingType = c_TrackingType.TT_USER_COUNT;
this.licenseId = null;
this.trackingUrl = g_sTrackingServiceLocalUrl;
this.isPeriodicalyTracking = false;
this.isAliveTrackingOnly = false;
this.isTrackDone = false;
if(undefined != obj && null != obj)
{
if(undefined != obj.licenseId && null != obj.licenseId)
this.licenseId = obj.licenseId;
if(undefined != obj.trackingType && null != obj.trackingType)
this.trackingType = obj.trackingType;
if(undefined != obj.trackingUrl && null != obj.trackingUrl)
this.trackingUrl = obj.trackingUrl;
}
if(c_TrackingType.TT_ACTIVE_CONNECTION == this.trackingType)
this.isPeriodicalyTracking = true;
if(c_TrackingType.TT_DOCUMENT_SESSION == this.trackingType)
this.isAliveTrackingOnly = true;
this.sendTrackFunc = null;
this.isDocumentModifiedFunc = null;
this.trackingInterval = 300 * 1000;
this.docId = null;
this.userId = null;
}
CTrackFile.prototype = {
constructor: CTrackFile,
Start: function()
{
var oThis = this;
if(oThis.isPeriodicalyTracking || !oThis.isTrackDone)
{
var _OnTrackingTimer = function(){
oThis.Start();
};
var _OnSendTrack = function(){
setTimeout(_OnTrackingTimer, oThis.trackingInterval);
};
if(oThis.isAliveTrackingOnly && !oThis._isAlive())
{
_OnSendTrack();
}
else
{
oThis.isTrackDone = true;
oThis._sendTrack(_OnSendTrack);
}
}
},
Stop: function()
{},
setInterval: function(inverval)
{
this.trackingInterval = inverval * 1000;
},
setDocId: function(docId)
{
this.docId = docId;
},
setUserId: function(userId)
{
this.userId = userId;
},
setTrackFunc: function(func)
{
if(undefined != func)
this.sendTrackFunc = func;
},
setIsDocumentModifiedFunc: function(func)
{
if(undefined != func)
this.isDocumentModifiedFunc = func;
},
_isAlive: function()
{
var bAlive = false;
if( null != this.isDocumentModifiedFunc)
bAlive = this.isDocumentModifiedFunc();
return bAlive;
},
_sendTrack: function(callback)
{
var rData = {
"docId": this.docId,
"clientId": this.userId,
"isAlive": this._isAlive()? 1: 0
};
if(this.sendTrackFunc != null)
this.sendTrackFunc(callback, this.trackingUrl, JSON.stringify(rData));
}
};
asc.CTrackFile = CTrackFile;
}
)(window, undefined);
\ No newline at end of file
......@@ -51,7 +51,9 @@
<script type="text/javascript" src="../Word/Drawing/Externals.js"></script>
<script type="text/javascript" src="../Word/Drawing/Metafile.js"></script>
<script type="text/javascript" src="../Word/Drawing/AllFonts.js"></script>
<script type="text/javascript" src="../Common/trackFile.js"></script>
<script type="text/javascript" src="apiDefines.js"></script>
<script type="text/javascript" src="utils/utils.js"></script>
......
......@@ -16,6 +16,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
var asc_CAdjustPrint = asc.asc_CAdjustPrint;
var asc_user = asc.asc_CUser;
var asc_CAscEditorPermissions = asc.asc_CAscEditorPermissions;
var asc_CTrackFile = asc.CTrackFile;
var prot;
......@@ -145,8 +146,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
// Использовать ли обрезанные шрифты
this.isUseEmbeddedCutFonts = ("true" == ASC_DOCS_API_USE_EMBEDDED_FONTS.toLowerCase());
this.isTrackingEnable = false;
this.TrackingInterval = 300 * 1000;
this.TrackFile = null;
var oThis = this;
if ("undefined" != typeof(FileReader) && "undefined" != typeof(FormData)) {
......@@ -882,11 +882,11 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
dataType: "text"});
},
_asc_sendTrack: function (callback, rdata) {
_asc_sendTrack: function (callback, url, rdata) {
var oThis = this;
asc_ajax({
type: 'POST',
url: g_sTrackingServiceLocalUrl,
url: url,
data: rdata,
error: function(jqXHR, textStatus, errorThrown){
var result = {returnCode: c_oAscError.Level.Critical, val:c_oAscError.ID.Unknown};
......@@ -1248,38 +1248,22 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.handlers.trigger("asc_onGetEditorPermissions", oEditorPermissions);
if(undefined != oSettings['isTrackingEnable'] &&
null != oSettings['isTrackingEnable'])
this.isTrackingEnable = oSettings['isTrackingEnable'];
if(undefined != oSettings['TrackingInterval'] &&
null != oSettings['TrackingInterval'])
this.TrackingInterval = oSettings['TrackingInterval'] * 1000;
this._startTracking();
}
},
//Посылаем трек, и инициализируем таймер для его последующей отправки.
_startTracking: function() {
var oThis = this;
if(oThis.isTrackingEnable){
var rData = {
"docId": oThis.DocInfo.Id,
"clientId": oThis.DocInfo.UserId,
"isAlive": oThis.asc_isDocumentModified()? 1: 0
};
var _OnTrackingTimer = function(){
oThis._startTracking();
};
var _OnSendTrack = function(){
setTimeout(_OnTrackingTimer, oThis.TrackingInterval);
};
if(undefined != oSettings['trackingInfo'] &&
null != oSettings['trackingInfo'])
{
this.TrackFile = new asc_CTrackFile(oSettings['trackingInfo']);
this.TrackFile.setDocId(this.DocInfo.Id);
this.TrackFile.setUserId(this.DocInfo.UserId);
this.TrackFile.setTrackFunc(this._asc_sendTrack);
this.TrackFile.setIsDocumentModifiedFunc(this.asc_isDocumentModified);
oThis._asc_sendTrack(_OnSendTrack, JSON.stringify(rData));
if(undefined != oSettings['TrackingInterval'] &&
null != oSettings['TrackingInterval'])
this.TrackFile.setInterval(oSettings['TrackingInterval']);
this.TrackFile.Start();
}
}
},
......
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