智云SRM-WEBAPI(目前客户通用API)
yusijie
2024-09-12 c05f1964fc49bebb9ea64e189400337f8d4f0c42
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Hubs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebAPI.Models;
 
namespace WebAPI
{
    [HubName("chatHub")]
    public class MyHub : Hub
    {
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        public void Send(string title, string message)
        {
            this.InsertMsg(title, message);
            // 调用所有客户端的sendMessage方法
            Clients.All.sendMessage(message);
        }
 
        private void InsertMsg(string title, string message)
        {
            Message msg = new Message();
            msg.Title = title;
            msg.MsgContent = message;
            oCn.BeginTran();
            oCn.RunProc("Insert into Gy_Message " +
                " (Title,MsgContent) " +
                " Values('" + msg.Title + "','" + msg.MsgContent + "')", ref DBUtility.ClsPub.sExeReturnInfo);
            oCn.Commit();
        }
    }
}