|
@@ -9,51 +9,57 @@ us.mysql = require("./mysql.js"); //引用执行存储过程包
|
|
* 用户的链接池集合,以用户id作为搜索键
|
|
* 用户的链接池集合,以用户id作为搜索键
|
|
**/
|
|
**/
|
|
us.connect = {
|
|
us.connect = {
|
|
-//userguid:{pageid : us.userConnect, pageid : us.userConnect}
|
|
|
|
|
|
+ //userguid:{pageid : us.userConnect, pageid : us.userConnect}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 用户的数据集合集合,以用户id作为搜索键
|
|
* 用户的数据集合集合,以用户id作为搜索键
|
|
**/
|
|
**/
|
|
us.user = {
|
|
us.user = {
|
|
-//userId : userInfo //用户连接(请求), 这里可以是http短连接可以使socket长连接
|
|
|
|
|
|
+ //userId : userInfo //用户连接(请求), 这里可以是http短连接可以使socket长连接
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 用户的消息集合,以用户的页面id(登录唯一识别ID)作为搜索键
|
|
* 用户的消息集合,以用户的页面id(登录唯一识别ID)作为搜索键
|
|
**/
|
|
**/
|
|
us.offLineMessage = {
|
|
us.offLineMessage = {
|
|
-//pageId : us.userOffLineMessage
|
|
|
|
|
|
+ //pageId : us.userOffLineMessage
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+us.mindNetwork = {
|
|
|
|
+ // mindid: {
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
|
|
|
|
//文档列表
|
|
//文档列表
|
|
us.word = {
|
|
us.word = {
|
|
-//docId : {
|
|
|
|
-// user : {userId : [pageId, pageId],
|
|
|
|
-// userId : [pageId, pageId]},
|
|
|
|
-// content : docel,
|
|
|
|
-// history : [operand(操作信息对象), operand(操作信息对象)]
|
|
|
|
-// } //群信息结构
|
|
|
|
-//docId : {user : {userId : [pageId, pageId], userId : [pageId, pageId]}, content : docel, history : [operand(操作信息对象), operand(操作信息对象)] } //文档信息结构
|
|
|
|
|
|
+ //docId : {
|
|
|
|
+ // user : {userId : [pageId, pageId],
|
|
|
|
+ // userId : [pageId, pageId]},
|
|
|
|
+ // content : docel,
|
|
|
|
+ // history : [operand(操作信息对象), operand(操作信息对象)]
|
|
|
|
+ // } //群信息结构
|
|
|
|
+ //docId : {user : {userId : [pageId, pageId], userId : [pageId, pageId]}, content : docel, history : [operand(操作信息对象), operand(操作信息对象)] } //文档信息结构
|
|
}
|
|
}
|
|
|
|
|
|
//excel列表
|
|
//excel列表
|
|
us.excel = {
|
|
us.excel = {
|
|
-//excelId : {user : {userId : [pageId, pageId], userId : [pageId, pageId]}, content : docel, history : [operand(操作信息对象), operand(操作信息对象)], name : 文件名 } //群信息结构
|
|
|
|
-//excelId : {user : {userId : [pageId, pageId], userId : [pageId, pageId]}, content : docel, history : [operand(操作信息对象), operand(操作信息对象)], name : 文件名 } //群信息结构
|
|
|
|
|
|
+ //excelId : {user : {userId : [pageId, pageId], userId : [pageId, pageId]}, content : docel, history : [operand(操作信息对象), operand(操作信息对象)], name : 文件名 } //群信息结构
|
|
|
|
+ //excelId : {user : {userId : [pageId, pageId], userId : [pageId, pageId]}, content : docel, history : [operand(操作信息对象), operand(操作信息对象)], name : 文件名 } //群信息结构
|
|
}
|
|
}
|
|
|
|
|
|
//导航文件列表
|
|
//导航文件列表
|
|
us.nav = {
|
|
us.nav = {
|
|
-//fileId : {
|
|
|
|
-// user : {userId : [pageId, pageId], userId : [pageId, pageId]},
|
|
|
|
-// navInfo : {
|
|
|
|
-// logo : '',
|
|
|
|
-// nav : [ {pageId: '', name : ''}, {pageId: '', name : '', child :[ {pageId: '', name : ''} ]} ]
|
|
|
|
-// },
|
|
|
|
-// page : {pageId : pageContent, pageId : pageContent},
|
|
|
|
-// history : [operand(操作信息对象), operand(操作信息对象)]
|
|
|
|
-//} //导航文档数据结构
|
|
|
|
|
|
+ //fileId : {
|
|
|
|
+ // user : {userId : [pageId, pageId], userId : [pageId, pageId]},
|
|
|
|
+ // navInfo : {
|
|
|
|
+ // logo : '',
|
|
|
|
+ // nav : [ {pageId: '', name : ''}, {pageId: '', name : '', child :[ {pageId: '', name : ''} ]} ]
|
|
|
|
+ // },
|
|
|
|
+ // page : {pageId : pageContent, pageId : pageContent},
|
|
|
|
+ // history : [operand(操作信息对象), operand(操作信息对象)]
|
|
|
|
+ //} //导航文档数据结构
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -92,9 +98,10 @@ us.userOffLineMessage = function (type) {
|
|
return {
|
|
return {
|
|
"message": [], //用户的消息数组
|
|
"message": [], //用户的消息数组
|
|
"type": type, //链接的端 pc或者pho
|
|
"type": type, //链接的端 pc或者pho
|
|
- "word": [],
|
|
|
|
- "excel": [],
|
|
|
|
- "nav": []
|
|
|
|
|
|
+ "word": [], //word数据
|
|
|
|
+ "excel": [], //excel数据
|
|
|
|
+ "mindNetwork": [], //思维网格数据
|
|
|
|
+ "nav": [] //导航模式数据
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -149,7 +156,7 @@ us.server = us.http.createServer(function (requset, response) {
|
|
//参数解码 us.parm为全局变量 记录所有参数
|
|
//参数解码 us.parm为全局变量 记录所有参数
|
|
var _userinfo,
|
|
var _userinfo,
|
|
_funname = param[0],
|
|
_funname = param[0],
|
|
- //参数解码 中文处理
|
|
|
|
|
|
+ //参数解码 中文处理
|
|
_param = param.splice(1);
|
|
_param = param.splice(1);
|
|
//执行回调函数
|
|
//执行回调函数
|
|
switch (_funname) {
|
|
switch (_funname) {
|
|
@@ -177,6 +184,10 @@ us.server = us.http.createServer(function (requset, response) {
|
|
case 'getNav':
|
|
case 'getNav':
|
|
us.getNav(response, _param[0], _param[1], _param[2]);
|
|
us.getNav(response, _param[0], _param[1], _param[2]);
|
|
break;
|
|
break;
|
|
|
|
+ //获取文档信息
|
|
|
|
+ case 'getMindNetwork':
|
|
|
|
+ us.getMindNetwork(response, _param[0], _param[1], _param[2]);
|
|
|
|
+ break;
|
|
case 'getNavPageContent':
|
|
case 'getNavPageContent':
|
|
us.getNavPageContent(response, _param[0], _param[1]);
|
|
us.getNavPageContent(response, _param[0], _param[1]);
|
|
break;
|
|
break;
|
|
@@ -469,7 +480,7 @@ us.polling = function (response, userid, pageid, type) {
|
|
if (us.connect[userid]) {
|
|
if (us.connect[userid]) {
|
|
var _userarray = us.connect[userid], //用户连接池,获取制定用户连接的数量,
|
|
var _userarray = us.connect[userid], //用户连接池,获取制定用户连接的数量,
|
|
_messagearray = us.offLineMessage[pageid] //用户离校消息
|
|
_messagearray = us.offLineMessage[pageid] //用户离校消息
|
|
- ;
|
|
|
|
|
|
+ ;
|
|
//获取当前连接的用户,如果获取成功那么直接修改用户的连接
|
|
//获取当前连接的用户,如果获取成功那么直接修改用户的连接
|
|
if (_userarray[pageid]) {
|
|
if (_userarray[pageid]) {
|
|
_userarray[pageid].response = response;
|
|
_userarray[pageid].response = response;
|
|
@@ -502,14 +513,32 @@ us.send = function (response, messageinfo) {
|
|
var i, j,
|
|
var i, j,
|
|
_message,
|
|
_message,
|
|
_messagelist = {},
|
|
_messagelist = {},
|
|
- // _messageall = [],
|
|
|
|
_messageobj = JSON.parse(messageinfo) //获取传入的json对象
|
|
_messageobj = JSON.parse(messageinfo) //获取传入的json对象
|
|
- ;
|
|
|
|
|
|
+ ;
|
|
|
|
|
|
//循环用户的信息处理
|
|
//循环用户的信息处理
|
|
for (i in _messageobj) {
|
|
for (i in _messageobj) {
|
|
switch (i) {
|
|
switch (i) {
|
|
//word信息交互
|
|
//word信息交互
|
|
|
|
+ case "us.mindNetwork":
|
|
|
|
+ _messagearr = _messageobj[i]; //获取word消息
|
|
|
|
+ //得到word所有的用户
|
|
|
|
+ for (j = 0; j < _messagearr.length; j++) {
|
|
|
|
+ //生成发送的消息结构体
|
|
|
|
+ _message = us.message(_messagearr[j].sendId, "us.mindNetwork", _messagearr[j].messageInfo);
|
|
|
|
+ //添加消息列表
|
|
|
|
+ if (_messagelist[_messagearr[j].receiveId]) {
|
|
|
|
+ _messagelist[_messagearr[j].receiveId].push(_message);
|
|
|
|
+ } else {
|
|
|
|
+ _messagelist[_messagearr[j].receiveId] = [_message];
|
|
|
|
+ }
|
|
|
|
+ us.mindNetwork[_message.messageInfo.docId] && us.mindNetwork[_message.messageInfo.docId].history.push(_message);
|
|
|
|
+ us.updatemindNetwork(_message.messageInfo);
|
|
|
|
+ }
|
|
|
|
+ //调用群发函数
|
|
|
|
+ _messagearr[0] && us.broadcast(_messagelist, _messagearr[0].messageInfo.pageId, 'word');
|
|
|
|
+ break;
|
|
|
|
+ //word信息交互
|
|
case "us.word":
|
|
case "us.word":
|
|
_messagearr = _messageobj[i]; //获取word消息
|
|
_messagearr = _messageobj[i]; //获取word消息
|
|
//得到word所有的用户
|
|
//得到word所有的用户
|
|
@@ -574,6 +603,20 @@ us.send = function (response, messageinfo) {
|
|
response.end('send');
|
|
response.end('send');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+* 更新后台Word内容
|
|
|
|
+* @param {object} message 消息信息
|
|
|
|
+*/
|
|
|
|
+us.updatemindNetwork = function (messageInfo) {
|
|
|
|
+ if (us.mindNetwork[messageInfo.docId]) {
|
|
|
|
+ var $ = us.word[messageInfo.docId].content;
|
|
|
|
+ if ($) {
|
|
|
|
+ us.word[messageInfo.docId].content[id] = messageInfo.content;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 更新后台Word内容
|
|
* 更新后台Word内容
|
|
* @param {object} message 消息信息
|
|
* @param {object} message 消息信息
|
|
@@ -1318,18 +1361,18 @@ us.insertHistory = function (docinfo, docid, type) {
|
|
case 'word':
|
|
case 'word':
|
|
var _content = docinfo.content ? docinfo.content('body').html().replace(/'/ig, '\\\'').replace(/"/ig, "\\\"") : "";
|
|
var _content = docinfo.content ? docinfo.content('body').html().replace(/'/ig, '\\\'').replace(/"/ig, "\\\"") : "";
|
|
us.mysql.usselect(['sqlserver.1473.cn', 'UseStudio_Disk', 'SaveFileContent', docid, _content, ''],
|
|
us.mysql.usselect(['sqlserver.1473.cn', 'UseStudio_Disk', 'SaveFileContent', docid, _content, ''],
|
|
- function (ret) { });
|
|
|
|
|
|
+ function (ret) { });
|
|
break;
|
|
break;
|
|
case 'nav':
|
|
case 'nav':
|
|
us.mysql.usselect(['sqlserver.1473.cn', 'UseStudio_Disk', 'SaveFileContent', docid, JSON.stringify(docinfo.navInfo), ''],
|
|
us.mysql.usselect(['sqlserver.1473.cn', 'UseStudio_Disk', 'SaveFileContent', docid, JSON.stringify(docinfo.navInfo), ''],
|
|
- function (ret) {
|
|
|
|
- var _key;
|
|
|
|
- for (_key in docinfo.page) {
|
|
|
|
- //发送保存内容请求
|
|
|
|
- var _content = docinfo.page[_key] ? docinfo.page[_key]('body').html().replace(/'/ig, '\\\'').replace(/"/ig, "\\\"") : "";
|
|
|
|
- us.mysql.usselect(['sqlserver.1473.cn', 'UseStudio_Office', 'SaveNavPageContent', _key, _content], function (ret) { });
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ function (ret) {
|
|
|
|
+ var _key;
|
|
|
|
+ for (_key in docinfo.page) {
|
|
|
|
+ //发送保存内容请求
|
|
|
|
+ var _content = docinfo.page[_key] ? docinfo.page[_key]('body').html().replace(/'/ig, '\\\'').replace(/"/ig, "\\\"") : "";
|
|
|
|
+ us.mysql.usselect(['sqlserver.1473.cn', 'UseStudio_Office', 'SaveNavPageContent', _key, _content], function (ret) { });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1734,6 +1777,46 @@ us.addExcel = function (response, excelinfo) {
|
|
response.end('OK'); //返回到前台
|
|
response.end('OK'); //返回到前台
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+* 获取思维网格数据,转成成数组
|
|
|
|
+*
|
|
|
|
+*/
|
|
|
|
+us.getMindNetwork = function (response, docid, pageid, userid) {
|
|
|
|
+ //判断文档是否已在内层中存在
|
|
|
|
+ if (us.mindNetwork[docid]) {
|
|
|
|
+ //如果存在则直接返回内层的文档
|
|
|
|
+ if (!us.mindNetwork[docid].user[userid]) {
|
|
|
|
+ us.mindNetwork[docid].user[userid] = [pageid];
|
|
|
|
+ } else {
|
|
|
|
+ us.mindNetwork[docid].user[userid].push(pageid);
|
|
|
|
+ }
|
|
|
|
+ us.offLineMessage[pageid].mindNetwork.indexOf(docid) == -1 && us.offLineMessage[pageid].mindNetwork.push(docid); //添加到用户离线消息的连接wrod记录中
|
|
|
|
+ response.end(us.mindNetwork[docid].content('body').html());
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ us.mindNetwork[docid] = {
|
|
|
|
+ user: {},
|
|
|
|
+ history: []
|
|
|
|
+ };
|
|
|
|
+ us.mindNetwork[docid].user[userid] = [pageid];
|
|
|
|
+ if (us.offLineMessage[pageid]) {
|
|
|
|
+ us.offLineMessage[pageid].mindNetwork.indexOf(docid) == -1 && us.offLineMessage[pageid].mindNetwork.push(docid); //添加到用户离线消息的连接wrod记录中
|
|
|
|
+ }
|
|
|
|
+ //如果不存在则去数据库查找
|
|
|
|
+ us.mysql.usselect(['127.0.0.1', 'pbl', 'select_file', docid],
|
|
|
|
+ function (ret) {
|
|
|
|
+ if (ret) {
|
|
|
|
+ us.mindNetwork[docid].content = json.parse(ret); //把思维网格的内容转化成数组
|
|
|
|
+ response.end(ret); //返回文档内容
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ us.mindNetwork[docid].content = []; //创建一个空数组
|
|
|
|
+ response.end(''); //返回文档内容
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 获取文档,并生成DOM
|
|
* 获取文档,并生成DOM
|
|
*
|
|
*
|
|
@@ -1762,17 +1845,17 @@ us.getWord = function (response, docid, pageid, userid) {
|
|
us.offLineMessage[pageid].word.indexOf(docid) == -1 && us.offLineMessage[pageid].word.push(docid); //添加到用户离线消息的连接wrod记录中
|
|
us.offLineMessage[pageid].word.indexOf(docid) == -1 && us.offLineMessage[pageid].word.push(docid); //添加到用户离线消息的连接wrod记录中
|
|
}
|
|
}
|
|
//如果不存在则去数据库查找
|
|
//如果不存在则去数据库查找
|
|
- us.mysql.usselect(['sqlserver.1473.cn', 'UseStudio_Disk', 'GetFileContent', docid],
|
|
|
|
- function (ret) {
|
|
|
|
- if (ret) {
|
|
|
|
- var _office = JSON.parse(ret)[0][0].UsOffice ? JSON.parse(ret)[0][0].UsOffice.replace(/\\'/ig, '\'').replace(/\\"/ig, "\"") : ""; //记录查找内容
|
|
|
|
- us.word[docid].content = us.cheerio.load(_office); //将文档添加到内层中
|
|
|
|
- response.end(_office); //返回文档内容
|
|
|
|
- } else {
|
|
|
|
- us.word[docid].content = us.cheerio.load(''); //将文档添加到内层中
|
|
|
|
- response.end(''); //返回文档内容
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ us.mysql.usselect(['127.0.0.1', 'pbl', 'select_file', docid],
|
|
|
|
+ function (ret) {
|
|
|
|
+ if (ret) {
|
|
|
|
+ var _office = JSON.parse(ret)[0][0].data ? JSON.parse(ret)[0][0].data.replace(/\\'/ig, '\'').replace(/\\"/ig, "\"") : ""; //记录查找内容
|
|
|
|
+ us.word[docid].content = us.cheerio.load(_office); //将文档添加到内层中
|
|
|
|
+ response.end(_office); //返回文档内容
|
|
|
|
+ } else {
|
|
|
|
+ us.word[docid].content = us.cheerio.load(''); //将文档添加到内层中
|
|
|
|
+ response.end(''); //返回文档内容
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|