Ver código fonte

推送消息

西昌缴费二期
zhichao lei 4 anos atrás
pai
commit
1b1738847d
7 arquivos alterados com 154 adições e 5 exclusões
  1. +1
    -1
      Learun.Framework.Ultimate V7/Learun.Application.IMServer/App.config
  2. +10
    -0
      Learun.Framework.Ultimate V7/Learun.Application.IMServer/Hubs/Chats.cs
  3. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj
  4. +75
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Views/LR_Content/script/pushmessage.js
  5. +5
    -4
      Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Shared/_Admin.cshtml
  6. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Learun.Application.WebApi.csproj
  7. +61
    -0
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/PushMessageApi.cs

+ 1
- 1
Learun.Framework.Ultimate V7/Learun.Application.IMServer/App.config Ver arquivo

@@ -70,7 +70,7 @@
<!-- 发出邮箱设置邮箱主机 -->
<add key="MailHost" value="smtp.ym.163.com" />
<!-- ================== 6:即时通信参数 ================== -->
<add key="IMUrl" value="http://*:8012" />
<add key="IMUrl" value="http://localhost:8012" />
</appSettings>
<!--日志-->
<log4net>


+ 10
- 0
Learun.Framework.Ultimate V7/Learun.Application.IMServer/Hubs/Chats.cs Ver arquivo

@@ -91,6 +91,16 @@ namespace Learun.Application.IMServer

#endregion


#region 推送消息

public void PushMessage(string msg)
{
Clients.All.broadcastMessage(msg);
}

#endregion

#region 一般公用方法
/// <summary>
/// 获取登录用户Id


+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj Ver arquivo

@@ -3833,6 +3833,7 @@
<Content Include="Views\LR_Content\script\lr-form.js" />
<Content Include="Views\LR_Content\script\lr-iframe-index.js" />
<Content Include="Views\LR_Content\script\lr-bootstrap.js" />
<Content Include="Views\LR_Content\script\pushmessage.js" />
<Content Include="Views\LR_Content\script\lr-im.js" />
<Content Include="Views\LR_Content\script\lr-language - 副本.js" />
<Content Include="Views\LR_Content\script\lr-language.js" />


+ 75
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Views/LR_Content/script/pushmessage.js Ver arquivo

@@ -0,0 +1,75 @@
(function ($, learun) {
"use strict";


learun._im = {
init: function () {
learun._im.registerServer();
learun._im.connect();
}
// 连接服务端
, connect: function () {
var loginInfo = learun.clientdata.get(['userinfo']);
if (loginInfo.imOpen != 'true') {
setTimeout(learun._im.connect, 1000);
}

$.ajax({
url: loginInfo.imUrl + "/hubs",
type: "get",
dataType: "text",
success: function (data) {
eval(data);
//Set the hubs URL for the connection
$.connection.hub.url = loginInfo.imUrl;
$.connection.hub.qs = { "userId": loginInfo.userId };
// Declare a proxy to reference the hub.
learun.imChat = $.connection.ChatsHub;
learun.imChat.client.broadcastMessage = function(message) {
top.layer.open({
type: 1 //此处以iframe举例
, title: '通知'
, area: ['390px', '330px']
, shade: 0
, offset: 'rb'
, maxmin: true
, content: message
, btn: null
, yes: function () {
$(that).click(); //此处只是为了演示,实际使用可以剔除
}
, btn2: function () {
layer.closeAll();
}

, zIndex: layer.zIndex //重点1
, success: function (layero) {
layer.setTop(layero); //重点2
}
});
}
if (!learun.imChat) {
setTimeout(learun._im.connect, 1000);
}
// 连接成功后注册服务器方法
$.connection.hub.start().done(function () {
learun.imChat.server.pushMessage('123123');
});
//断开连接后
$.connection.hub.disconnected(function () {
//
});
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
isLoaded = 0;
},
});
}
};


$(function() {
learun._im.connect();
})

})(jQuery, top.learun);

+ 5
- 4
Learun.Framework.Ultimate V7/Learun.Application.Web/Views/Shared/_Admin.cshtml Ver arquivo

@@ -45,10 +45,10 @@
</div>
</div>
<div class="lr-frame-main" id="lr_frame_main">
<img src="~/Content/images/iframebg.png"/>
<img src="~/Content/images/iframebg.png" />
</div>

<script src="~/Content/bootstrap/bootstrap.min.js"></script>
<script src="~/Content/jquery/plugin/layer/layer.js"></script>
<script src="~/Content/jquery/plugin/jquery.cookie.min.js"></script>
@@ -75,12 +75,13 @@

"/Views/LR_Content/plugin/tree/lr-tree.js",
"/Views/LR_Content/plugin/select/lr-select.js",

"/Views/LR_Content/plugin/workflow/lr-workflow-api.js",
"/Views/LR_Content/plugin/contextmenu/lr-contextmenu.js",
"/Views/LR_Content/script/lr-im.js",
"/Views/LR_Content/script/pushmessage.js",

"/Views/LR_Content/script/lr-admin.js"
)
</body>


+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Learun.Application.WebApi.csproj Ver arquivo

@@ -196,6 +196,7 @@
<Compile Include="Modules\DataSourceNoLoginApi.cs" />
<Compile Include="Modules\AskApi.cs" />
<Compile Include="Modules\EducationalAdministration\LoginUserBindApi.cs" />
<Compile Include="Modules\PushMessageApi.cs" />
<Compile Include="Modules\EvalApi.cs" />
<Compile Include="Modules\EducationalAdministration\R_EnterBuildingApi.cs" />
<Compile Include="Modules\EducationalAdministration\R_EnterSchoolApi.cs" />


+ 61
- 0
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/PushMessageApi.cs Ver arquivo

@@ -0,0 +1,61 @@
using Nancy;
using Learun.Util;
using System.Collections.Generic;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using static Learun.Application.WebApi.Modules.StuInfoFreshApi;
using System;
using System.IO;
using Learun.Application.Base.SystemModule;

namespace Learun.Application.WebApi
{
/// <summary>
/// 版 本 Learun-ADMS-Ultimate V7.0.0 力软敏捷开发框架
/// Copyright (c) 2013-2018 上海力软信息技术有限公司
/// 创 建:超级管理员
/// 日 期:2019-08-19 17:50
/// 描 述:教师注册
/// </summary>

public class PushMessageApi : BaseNoLoginApi
{

/// <summary>
/// 推送消息接口
/// <summary>
public PushMessageApi()
: base("/Learun/adms/pushMessage")
{
Get["/msg"] = PushMessage;
}

private Response PushMessage(dynamic _)
{
string msg = this.Request.Query["msg"].ToString();

if (!string.IsNullOrEmpty(msg))
{
SendHubs.callMethod("pushMessage", msg);
}
return Success("成功");
}

#region 获取数据


#endregion

#region 私有类

/// <summary>
/// 表单实体类
/// <summary>
private class ReqFormEntity
{
public string keyValue { get; set; }
public string strEntity { get; set; }
}
#endregion

}
}

Carregando…
Cancelar
Salvar