public void SendNotice(Model.NoticeModel model, List <Model.NoticeTargetModel> TargetModelList, decimal MerId) { Dictionary <string, string> MerConfig = BLL.StaticBLL.MerConfigCache(MerId, 2000); DAL.NoticeTargetDAL tarDal = new DAL.NoticeTargetDAL(); DAL.NoticeDAL dal = new DAL.NoticeDAL(); dal.Add(model); foreach (Model.NoticeTargetModel TargetModel in TargetModelList) { TargetModel.NoticeId = model.NoticeId; string reJson = RongCloudServer.PublishMessage(MerConfig["RongAppKey"], MerConfig["RongAppSecret"], "messager", TargetModel.TargetId, "RC:TxtMsg", //消息类型 " {\"content\":\"" + model.NoticeContent + "\",\"extra\":" + model.Extra + "}" //消息内容 , model.NoticeTitle); TargetModel.NoticeStatus = 10; //已发送 tarDal.Add(TargetModel); } }
static void Main(string[] args) { String retstr = null; String appKey = "uwd1c0sxdlx91"; String appSecret = "hhetmryhVm"; retstr = RongCloudServer.GetToken(appKey, appSecret, "232424", "xugang", "http://www.qqw21.com/article/UploadPic/2012-11/201211259378560.jpg"); Console.WriteLine("getToken: " + retstr); Console.ReadKey(); retstr = RongCloudServer.JoinGroup(appKey, appSecret, "232424", "group001", "wsw"); Console.WriteLine("joinGroup: " + retstr); Console.ReadKey(); string[] arrId = { "group001", "group002", "group003" }; string[] arrName = { "测试 01", "测试 02", "测试 03" }; retstr = RongCloudServer.syncGroup(appKey, appSecret, "42424", arrId, arrName); Console.WriteLine("syncGroup: " + retstr); Console.ReadKey(); retstr = RongCloudServer.DismissGroup(appKey, appSecret, "42424", "group001"); Console.WriteLine("dismissgroup: " + retstr); Console.ReadKey(); retstr = RongCloudServer.PublishMessage(appKey, appSecret, "2191", "2191", "RC:TxtMsg", "{\"content\":\"c#hello\"}"); Console.WriteLine("PublishMsg: " + retstr); Console.ReadKey(); retstr = RongCloudServer.BroadcastMessage(appKey, appSecret, "2191", "RC:TxtMsg", "{\"content\":\"c#hello\"}"); Console.WriteLine("Broad: " + retstr); Console.ReadKey(); retstr = RongCloudServer.JoinGroup(appKey, appSecret, "423424", "dwef", "dwef"); Console.WriteLine("JoinGroup: " + retstr); Console.ReadKey(); retstr = RongCloudServer.CreateChatroom(appKey, appSecret, arrId, arrName); Console.WriteLine("createChat: " + retstr); Console.ReadKey(); retstr = RongCloudServer.DestroyChatroom(appKey, appSecret, new String[] { "001", "002" }); Console.WriteLine("Destroy: " + retstr); Console.ReadKey(); string[] aaa = { "group002", "group003" }; retstr = RongCloudServer.queryChatroom(appKey, appSecret, aaa); Console.WriteLine("queryChatroom: " + retstr); Console.ReadKey(); Console.WriteLine("接口测试结束!"); Console.ReadKey(); }
public void SendMsgToDevice(List <string> DeviceList, Model.MsgTextModel MsgTextModel, string SendDeviceId, decimal MerId) { Dictionary <string, string> MerConfig = BLL.StaticBLL.MerConfigCache(MerId, 2000); DAL.MsgTextDAL dal = new DAL.MsgTextDAL(); if (MsgTextModel.MsgClassId == 0) { throw new Exception("消息类型(MsgClassId)不能为0"); } dal.Add(MsgTextModel); Model.MsgModel model = new Model.MsgModel(); model.MsgTextId = MsgTextModel.MsgTextId; model.SendDeviceId = SendDeviceId; model.ZoneId = "1"; model.MsgStatusId = 10; string reJson = ""; DAL.MsgDAL MsgDal = new DAL.MsgDAL(); foreach (string DeviceId in DeviceList) { model.TargetDeviceId = DeviceId; SaveMsg(model); StringBuilder s = new StringBuilder(); s.Append(" DECLARE @MsgNum AS INT = (SELECT COUNT(0) FROM DBMSG.dbo.Msg WHERE TargetDeviceId='" + DeviceId + "' AND MsgStatusId=10) "); s.Append(" DECLARE @MsgTypeName AS VARCHAR(50) =(SELECT MsgTypeName FROM DBMSG.dbo.MsgType WHERE MsgTypeId='" + MsgTextModel.MsgType + "') "); s.Append(" UPDATE DBMSG.dbo.Device SET MsgNum=@MsgNum where DeviceId='" + DeviceId + "' "); s.Append(" SELECT @MsgNum as MsgNum, @MsgTypeName as MsgTypeName "); JObject Extra = new JObject(); try { Extra = JObject.Parse(MsgTextModel.Extra); } catch (Exception) { } finally { DataSet ds = CountMsg(DeviceId); //统计消息数量 DataTable dt = ds.Tables[0]; DataRow dr = dt.Rows[0]; Extra["MsgTypeId"] = MsgTextModel.MsgType; Extra["MsgNum"] = int.Parse(dr["MsgNum"].ToString()); // Extra["MsgTypeName"] = dr["MsgTypeName"].ToString(); } reJson = RongCloudServer.PublishMessage(MerConfig["RongAppKey"], MerConfig["RongAppSecret"], SendDeviceId, DeviceId, "RC:TxtMsg", //消息类型 " {\"content\":\"" + MsgTextModel.MsgTitle + "\",\"extra\":" + Extra.ToString() + "}" //消息内容 , ""); } //BLL.WxBLL wxBll = new WxBLL(); //try //{ // wxBll.SendQyTextMsg(DeviceList, MsgTextModel.MsgTitle, 7); //这个地方, 以后必须改为配置,这个7是写死的数字 //} //catch (Exception) //{ // //如果微信推送不成功就算完吧.可能因为网络问题 //} }