Beispiel #1
0
 /// <summary>
 /// 点击绑定
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 private string ClickBDZH(WeChatData data)
 {
     if (CheckIsBind(data.FromUserName))
     {
         return data.ToQuicklyReplayWeChatData("您已经绑定过了!");
     }
     else
     {
         var list = new List<WeChatItemData>()
         {
             new WeChatItemData()
             {
                  Title="绑定帐号",
                  Url=string.Format("{0}WeChat/Bind?weChatUserName={1}", _config.Host, data.FromUserName),
                  PicUrl= string.Format( "{0}Areas/Gps/Content/Images/WeChat/bind.png",_config.Host),
                  Description="点击我绑定"
             }
         };
         return data.ToNewsWeChatData(list);
     }
 }
Beispiel #2
0
        /// <summary>
        /// 取消绑定
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        private string ClickQXBD(WeChatData data)
        {
            if (!CheckIsBind(data.FromUserName))
            {
                return data.ToQuicklyReplayWeChatData("您还没有绑定平台账号!");
            }

            var msg = new WeChatData();
            msg.CreateTime = DateTime.Now.ToFileTime().ToString();
            msg.ToUserName = data.FromUserName;
            msg.FromUserName = data.ToUserName;
            msg.MsgType = "text";
            if (UnBind(data.FromUserName))
            {
                msg.Content = "取消绑定成功!";
            }
            else
            {
                msg.Content = "取消绑定失败!";
            }
            return msg.ToXml();
        }
Beispiel #3
0
        /// <summary>
        /// 事件入口
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        private string ExcuteEvent(WeChatData data)
        {
            if (!data.Event.HasValue()) return string.Empty;

            
            switch (data.Event)
            {
                case "subscribe":
                    //关注事件
                    return data.ToQuicklyReplayWeChatData("您已经成功关注!");
                case "unsubscribe":
                    //取消关注事件
                    break;
                case "SCAN":
                    //扫描带参数二维码事件
                    return data.ToQuicklyReplayWeChatData("您已经成功关注!");
                case "LOCATION":
                    //上报地理位置事件
                    break;
                case "VIEW":
                    //点击菜单跳转链接时的事件推送 
                    break;
                case "CLICK":
                    //点击菜单拉取消息时的事件推送
                    if (data.EventKey.HasValue())
                    {
                        switch (data.EventKey.Replace("_", ""))
                        {
                            case "ClickBDZH":
                                return this.ClickBDZH(data);
                            case "ClickQXBD":
                                return this.ClickQXBD(data);
                            case "ClickDWJK":
                                return this.ClickDWJK(data);
                        }
                    }
                    break;
                default:
                    break;
            }
            return string.Empty;
        }
Beispiel #4
0
        /// <summary>
        /// 定位监控
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        private string ClickDWJK(WeChatData data)
        {
            if (!CheckIsBind(data.FromUserName))
            {
                return data.ToQuicklyReplayWeChatData("您还没有绑定平台账号!");
            }
            else
            {
                var userId = GetUserIdByWeChatUserName(data.FromUserName);
                if (userId == 0)
                {
                    return data.ToQuicklyReplayWeChatData("您还没有绑定平台账号!");
                }

                var devices = _rep.GetList<EDevice>(8, p => p.UserId == userId);
                if (devices.Count == 0)
                {
                    return data.ToQuicklyReplayWeChatData("您还没有添加车辆!");
                }

                var list = devices.Select(p => new WeChatItemData() { Title = p.DeviceName, Url = string.Format("{0}WeChat/CurrentData?deviceId={1}&weChatUserName={2}", _config.Host, p.Id, data.FromUserName) }).ToList();
                list.Insert(0, new WeChatItemData() { Title = "查看车辆位置", Url = "#", PicUrl = string.Format("{0}Areas/Gps/Content/Images/WeChat/position.png", _config.Host) });
                return data.ToNewsWeChatData(list);

            }
        }
Beispiel #5
0
        public string Excute(WeChatConfig config, WeChatData data)
        {
            if (!ModelFacade.WeChat.WeChatModel.CheckIsBind(data.FromUserName))
            {
                return data.ToQuicklyReplayWeChatData("您还没有绑定魔方账号,请您先绑定账号!");
            }

            var msg = new WeChatData();
            msg.CreateTime = DateTime.Now.ToFileTime().ToString();
            msg.ToUserName = data.FromUserName;
            msg.FromUserName = data.ToUserName;
            msg.MsgType = "text";
            if (ModelFacade.WeChat.WeChatModel.UnBind(data.FromUserName))
            {
                msg.Content = "取消绑定成功!";
            }
            else
            {
                msg.Content = "取消绑定失败!";
            }
            return msg.ToXml();
        }
Beispiel #6
0
        public string Excute(WeChatConfig config, WeChatData data)
        {
            if (!ModelFacade.WeChat.WeChatModel.CheckIsBind(data.FromUserName))
            {
                return data.ToQuicklyReplayWeChatData("您还没有绑定魔方账号,请您先绑定账号!");
            }

            var vehicles = ModelFacade.WeChat.WeChatModel.GetDevicesByOpenID(7, data.FromUserName);

            if (vehicles.Count == 0)
            {
                return data.ToQuicklyReplayWeChatData("您还没有关联有车辆!");
            }
            var list = vehicles.Select(p =>
            {

                var isFortify = ModelFacade.WeChat.WeChatModel.CheckDeviceIsFortify(p.VehicleCode);
                var wid = new WeChatItemData()
                {
                    Title = p.LicenceNumber + "(" + (isFortify ? "设防中" : "未设防") + ")",
                    Url = string.Format("{0}WeChat/DeviceFortify?vehicleCode={1}&openID={2}&isFortify={3}", config.Host, p.VehicleCode, data.FromUserName, !isFortify)
                };

                return wid;
            }).ToList();

            list.Add(new WeChatItemData() { Title = "更多车辆", Url = string.Format("{0}WeChat/DeviceMore?openID={1}&type=DeviceFortify", config.Host, data.FromUserName) });
            list.Insert(0, new WeChatItemData() { Title = "设防撤防", PicUrl = string.Format("{0}Content/WeChat/images/fortify.png", config.Host) });
            return data.ToNewsWeChatData(list);
        }
Beispiel #7
0
        public string Excute(WeChatConfig config, WeChatData data)
        {
            if (!ModelFacade.WeChat.WeChatModel.CheckIsBind(data.FromUserName))
            {
                return data.ToQuicklyReplayWeChatData("您还没有绑定魔方账号,请您先绑定账号!");
            }

            var vehicles = ModelFacade.WeChat.WeChatModel.GetDevicesByOpenID(7, data.FromUserName);

            if (vehicles.Count == 0)
            {
                return data.ToQuicklyReplayWeChatData("您还没有关联有车辆!");
            }
            var list = vehicles.Select(p => new WeChatItemData() { Title = p.LicenceNumber, Url = string.Format("{0}WeChat/DeviceReport?vehicleCode={1}&openID={2}", config.Host, p.VehicleCode, data.FromUserName) }).ToList();
            list.Add(new WeChatItemData() { Title = "更多车辆", Url = string.Format("{0}WeChat/DeviceMore?openID={1}&type=DeviceReport", config.Host, data.FromUserName) });
            list.Insert(0, new WeChatItemData() { Title = "查看车辆里程报表", PicUrl = string.Format("{0}Content/WeChat/images/report.png", config.Host) });
            return data.ToNewsWeChatData(list);
        }
Beispiel #8
0
 public string Excute(WeChatConfig config, WeChatData data)
 {
     if (ModelFacade.WeChat.WeChatModel.CheckIsBind(data.FromUserName))
     {
         return data.ToQuicklyReplayWeChatData("您已经绑定过了!");
     }
     else
     {
         var list = new List<WeChatItemData>()
         {
             new WeChatItemData()
             {
                  Title="绑定帐号(魔方)",
                  Url=string.Format("{0}WeChat/DeviceBind?openID={1}", config.Host, data.FromUserName),
                  PicUrl= string.Format( "{0}Content/WeChat/images/bind.png",config.Host),
                  Description="点击我绑定"
             }
         };
         return data.ToNewsWeChatData(list);
     }
 }
Beispiel #9
0
        public string Excute(WeChatConfig config, WeChatData data)
        {

            if (!data.Event.HasValue()) return string.Empty;
            switch (data.Event)
            {
                case "subscribe":
                    //关注事件

                    return data.ToQuicklyReplayWeChatData("您已经成功关注魔方(MOVO)平台!");
                case "unsubscribe":
                    //取消关注事件
                    ModelFacade.WeChat.WeChatModel.UnBind(data.FromUserName);
                    break;
                case "SCAN":
                    //扫描带参数二维码事件
                    return data.ToQuicklyReplayWeChatData("您已经成功关注魔方(MOVO)平台!");
                case "LOCATION":
                    //上报地理位置事件
                    break;
                case "VIEW":
                    //点击菜单跳转链接时的事件推送 
                    break;
                case "CLICK":
                    //点击菜单拉取消息时的事件推送
                    if (data.EventKey.HasValue())
                    {
                        var cmd = CMDManage.GetCMD("On" + data.EventKey.Replace("_", ""));
                        if (cmd != null)
                        {
                            return cmd.Excute(config, data);
                        }
                        else
                        {
                            return string.Empty;
                        }
                    }
                    break;
                default:
                    break;
            }
            return string.Empty;
        }