Пример #1
0
        public bool SetRelationship(DeviceApply_Data_Device_Identifiers deviceIdentifier, long[] pageIds, ShakeAroundBindType type)
        {
            WxJsonResult wxJsonResult = ShakeAroundApi.BindPage(_accessToken, deviceIdentifier, pageIds, type, ShakeAroundAppendType.新增, 10000);

            if (wxJsonResult.errcode != ReturnCode.请求成功)
            {
                throw new Exception(wxJsonResult.errmsg);
            }
            return(true);
        }
Пример #2
0
        public bool SetRelationship(DeviceApply_Data_Device_Identifiers deviceIdentifier, long[] pageIds, ShakeAroundBindType type)
        {
            var result = ShakeAroundApi.BindPage(this._accessToken, deviceIdentifier, pageIds, type, ShakeAroundAppendType.新增);

            if (result.errcode != 0)
            {
                throw new Exception(result.errmsg);
            }
            return(true);
        }
Пример #3
0
        /// <summary>
        /// 以设备为维度的数据统计接口
        /// </summary>
        /// <param name="deviceIdentifier">指定页面的设备ID</param>
        /// 设备编号,若填了UUID、major、minor,即可不填设备编号,二者选其一
        /// UUID、major、minor,三个信息需填写完成,若填了设备编辑,即可不填此信息,二者选其一
        /// <param name="beginDate">起始日期时间戳,最长时间跨度为30天</param>
        /// <param name="endDate">结束日期时间戳,最长时间跨度为30天</param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public StatisticsResultJson StatisticsByDevice(DeviceApply_Data_Device_Identifiers deviceIdentifier, long beginDate, long endDate, int timeOut = Config.TIME_OUT)
        {
            var accessToken = _api.GetAccessToken();
            var url         = string.Format("https://api.weixin.qq.com/shakearound/statistics/device?access_token={0}", accessToken);
            var data        = new
            {
                device_identifier = deviceIdentifier,
                begin_date        = beginDate,
                end_date          = endDate
            };

            return(Post <StatisticsResultJson>(url, data, timeOut));
        }
Пример #4
0
        public List <long> GetPageids(DeviceModel model)
        {
            DeviceApply_Data_Device_Identifiers d = new DeviceApply_Data_Device_Identifiers();

            d.device_id = long.Parse(model.device_id);
            d.major     = long.Parse(model.major);
            d.minor     = long.Parse(model.minor);
            d.uuid      = model.uuid;

            var result = ShakeAroundApi.SearchPagesByDeviceId(this._accessToken, 1, d);

            return(result.data.relations.Select(p => p.page_id).ToList());
        }
Пример #5
0
        /// <summary>
        /// 配置设备与页面的关联关系
        /// 配置设备与页面的关联关系。支持建立或解除关联关系,也支持新增页面或覆盖页面等操作。配置完成后,在此设备的信号范围内,即可摇出关联的页面信息。若设备配置多个页面,则随机出现页面信息。一个设备最多可配置30个关联页面。
        /// </summary>
        /// <param name="deviceIdentifier"></param>
        /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
        /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息
        /// <param name="pageIds"></param>
        /// <param name="bindType">关联操作标志位, 0为解除关联关系,1为建立关联关系</param>
        /// <param name="appendType">新增操作标志位, 0为覆盖,1为新增</param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public JsonResult BindPage(DeviceApply_Data_Device_Identifiers deviceIdentifier, long[] pageIds, int bindType, int appendType, int timeOut = Config.TIME_OUT)
        {
            var accessToken = _api.GetAccessToken();
            var url         = string.Format("https://api.weixin.qq.com/shakearound/device/bindpage?access_token={0}", accessToken);
            var data        = new
            {
                device_identifier = deviceIdentifier,
                page_ids          = pageIds,
                bind   = (int)bindType,
                append = (int)appendType
            };

            return(Post <JsonResult>(url, data, timeOut));
        }
Пример #6
0
        public void DeviceByIdTest()
        {
            var accessToken = AccessTokenContainer.GetToken(_appId);

            DeviceApply_Data_Device_Identifiers d = new DeviceApply_Data_Device_Identifiers();

            d.device_id = 1015959;
            var result = ShakeAroundApi.SearchDeviceById(accessToken, new List <DeviceApply_Data_Device_Identifiers>
            {
                d
            });

            Assert.IsNotNull(result);
            Assert.AreEqual(result.errcode, ReturnCode.请求成功);
        }
Пример #7
0
        public List <long> GetPageids(DeviceModel model)
        {
            DeviceApply_Data_Device_Identifiers deviceApplyDataDeviceIdentifier = new DeviceApply_Data_Device_Identifiers()
            {
                device_id = long.Parse(model.device_id),
                major     = long.Parse(model.major),
                minor     = long.Parse(model.minor),
                uuid      = model.uuid
            };
            RelationResult relationResult = ShakeAroundApi.SearchPagesByDeviceId(_accessToken, 1, deviceApplyDataDeviceIdentifier, 10000);

            return((
                       from p in relationResult.data.relations
                       select p.page_id).ToList());
        }
Пример #8
0
        public void Delete(HttpContext context)
        {
            string      text = context.Request.Form["ids"];
            long        num  = context.Request["page_id"].ToLong(0);
            IList <int> list = new List <int>();

            string[] array = text.Split(',');
            foreach (string text2 in array)
            {
                if (!string.IsNullOrEmpty(text2))
                {
                    list.Add(text2.ToInt(0));
                }
            }
            if (string.IsNullOrEmpty(text))
            {
                throw new HidistroAshxException("请选择您要删除的设备");
            }
            bool   flag  = false;
            string text3 = text;
            int    num2  = 0;

            while (num2 < text3.Length)
            {
                char c = text3[num2];
                DeviceApply_Data_Device_Identifiers deviceApply_Data_Device_Identifiers = new DeviceApply_Data_Device_Identifiers();
                deviceApply_Data_Device_Identifiers.device_id = c;
                long[] pageIds = new long[1]
                {
                    num
                };
                WxJsonResult wxJsonResult = WXStoreHelper.BindPage(deviceApply_Data_Device_Identifiers, pageIds, ShakeAroundBindType.解除关联关系, ShakeAroundAppendType.覆盖);
                if (wxJsonResult.errcode.Equals(ReturnCode.请求成功))
                {
                    flag = true;
                    num2++;
                    continue;
                }
                flag = false;
                break;
            }
            if (flag)
            {
                base.ReturnSuccessResult(context, "删除成功!", 0, true);
                return;
            }
            throw new HidistroAshxException("删除失败");
        }
Пример #9
0
        public ActionResult BindRelationship(BindRelationshipModel model)
        {
            var devModel = this._iShakeAroundService.GetDeviceById(model.id);
            DeviceApply_Data_Device_Identifiers identifiers = new DeviceApply_Data_Device_Identifiers();

            identifiers.device_id = long.Parse(devModel.device_id);
            identifiers.major     = long.Parse(devModel.major);
            identifiers.uuid      = devModel.uuid;
            identifiers.minor     = long.Parse(devModel.minor);
            bool result = this._iShakeAroundService.SetRelationship(identifiers, model.pageids.Split(',').Select(p => long.Parse(p)).ToArray(), Senparc.Weixin.MP.ShakeAroundBindType.建立关联关系);

            return(Json(new
            {
                success = result
            }));
        }
Пример #10
0
        public ActionResult RemoveRelationship(RemoveRelationshipModel model)
        {
            var devModel = this._iShakeAroundService.GetDeviceById(model.id);
            DeviceApply_Data_Device_Identifiers identifiers = new DeviceApply_Data_Device_Identifiers();

            identifiers.device_id = long.Parse(devModel.device_id);
            identifiers.major     = long.Parse(devModel.major);
            identifiers.uuid      = devModel.uuid;
            identifiers.minor     = long.Parse(devModel.minor);
            bool result = this._iShakeAroundService.SetRelationship(identifiers, new long[] { model.pageid }, Senparc.Weixin.MP.ShakeAroundBindType.解除关联关系);

            return(Json(new
            {
                success = result
            }));
        }
Пример #11
0
        /// <summary>
        /// 配置设备与页面的关联关系
        /// 配置设备与页面的关联关系。支持建立或解除关联关系,也支持新增页面或覆盖页面等操作。配置完成后,在此设备的信号范围内,即可摇出关联的页面信息。若设备配置多个页面,则随机出现页面信息。一个设备最多可配置30个关联页面。
        /// </summary>
        /// <param name="accessTokenOrAppId"></param>
        /// <param name="deviceIdentifier"></param>
        /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
        /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息
        /// <param name="pageIds"></param>
        /// <param name="bindType">关联操作标志位, 0为解除关联关系,1为建立关联关系</param>
        /// <param name="appendType">新增操作标志位, 0为覆盖,1为新增</param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static WxJsonResult BindPage(string accessTokenOrAppId, DeviceApply_Data_Device_Identifiers deviceIdentifier, long[] pageIds, ShakeAroundBindType bindType, ShakeAroundAppendType appendType, int timeOut = Config.TIME_OUT)
        {
            return(ApiHandlerWapper.TryCommonApi(accessToken =>
            {
                var url = string.Format("https://api.weixin.qq.com/shakearound/device/bindpage?access_token={0}", accessToken);

                var data = new
                {
                    device_identifier = deviceIdentifier,
                    page_ids = pageIds,
                    bind = (int)bindType,
                    append = (int)appendType
                };

                return CommonJsonSend.Send <WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
            }, accessTokenOrAppId));
        }
        public ActionResult RemoveRelationship(RemoveRelationshipModel model)
        {
            DeviceModel deviceById = _saService.GetDeviceById(model.id);
            DeviceApply_Data_Device_Identifiers deviceApplyDataDeviceIdentifier = new DeviceApply_Data_Device_Identifiers()
            {
                device_id = long.Parse(deviceById.device_id),
                major     = long.Parse(deviceById.major),
                uuid      = deviceById.uuid,
                minor     = long.Parse(deviceById.minor)
            };
            IShakeAroundService shakeAroundService = _saService;

            long[] numArray = new long[] { model.pageid };
            bool   flag     = shakeAroundService.SetRelationship(deviceApplyDataDeviceIdentifier, numArray, ShakeAroundBindType.解除关联关系);

            return(Json(new { success = flag }));
        }
Пример #13
0
        /// <summary>
        /// 以设备为维度的数据统计接口
        /// </summary>
        /// <param name="accessTokenOrAppId">调用接口凭证</param>
        /// <param name="deviceIdentifier">指定页面的设备ID</param>
        /// 设备编号,若填了UUID、major、minor,即可不填设备编号,二者选其一
        /// UUID、major、minor,三个信息需填写完成,若填了设备编辑,即可不填此信息,二者选其一
        /// <param name="beginDate">起始日期时间戳,最长时间跨度为30天</param>
        /// <param name="endDate">结束日期时间戳,最长时间跨度为30天</param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static StatisticsResultJson StatisticsByDevice(string accessTokenOrAppId,
                                                              DeviceApply_Data_Device_Identifiers deviceIdentifier, long beginDate, long endDate,
                                                              int timeOut = Config.TIME_OUT)
        {
            return(ApiHandlerWapper.TryCommonApi(accessToken =>
            {
                var url = string.Format("https://api.weixin.qq.com/shakearound/statistics/device?access_token={0}", accessToken.AsUrlData());

                var data = new
                {
                    device_identifier = deviceIdentifier,
                    begin_date = beginDate,
                    end_date = endDate
                };

                return CommonJsonSend.Send <StatisticsResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
            }, accessTokenOrAppId));
        }
Пример #14
0
        public List <long> GetPageids(DeviceSearch_Data_Devices model)
        {
            DeviceApply_Data_Device_Identifiers deviceApplyDataDeviceIdentifier = new DeviceApply_Data_Device_Identifiers()
            {
                device_id = model.device_id,
                major     = model.major,
                minor     = model.minor,
                uuid      = model.uuid
            };
            List <DeviceApply_Data_Device_Identifiers> filters = new List <DeviceApply_Data_Device_Identifiers>()
            {
                deviceApplyDataDeviceIdentifier
            };
            var relationResult = Senparc.Weixin.MP.AdvancedAPIs.ShakeAroundApi.SearchDeviceById(_accessToken, filters, 10000);

            return((
                       from p in relationResult.data.devices
                       select p.device_id).ToList());
        }
Пример #15
0
        public DeviceModel GetDeviceById(long id)
        {
            DeviceApply_Data_Device_Identifiers d = new DeviceApply_Data_Device_Identifiers();

            d.device_id = id;
            var result = ShakeAroundApi.SearchDeviceById(this._accessToken, new List <DeviceApply_Data_Device_Identifiers>
            {
                d
            });

            if (result.errcode != 0)
            {
                throw new Exception(result.errmsg);
            }
            if (result.data.devices.Count > 0)
            {
                return(result.data.devices[0]);
            }
            return(null);
        }
        public ActionResult BindRelationship(BindRelationshipModel model)
        {
            DeviceModel deviceById = _saService.GetDeviceById(model.id);
            DeviceApply_Data_Device_Identifiers deviceApplyDataDeviceIdentifier = new DeviceApply_Data_Device_Identifiers()
            {
                device_id = long.Parse(deviceById.device_id),
                major     = long.Parse(deviceById.major),
                uuid      = deviceById.uuid,
                minor     = long.Parse(deviceById.minor)
            };
            IShakeAroundService shakeAroundService = _saService;
            DeviceApply_Data_Device_Identifiers deviceApplyDataDeviceIdentifier1 = deviceApplyDataDeviceIdentifier;
            string str = model.pageids;

            char[] chrArray = new char[] { ',' };
            bool   flag     = shakeAroundService.SetRelationship(deviceApplyDataDeviceIdentifier1, (
                                                                     from p in str.Split(chrArray)
                                                                     select long.Parse(p)).ToArray(), ShakeAroundBindType.建立关联关系);

            return(Json(new { success = flag }));
        }
Пример #17
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string text = base.Request.Form["CheckBoxGroup"];

            if (string.IsNullOrEmpty(text))
            {
                this.ShowMsg("请选择一台设备!", false);
            }
            else
            {
                List <long> devices = new List <long>();
                text.Split(',').ForEach(delegate(string c)
                {
                    devices.Add(c.ToLong(0));
                });
                bool flag = true;
                foreach (long item in devices)
                {
                    DeviceApply_Data_Device_Identifiers deviceApply_Data_Device_Identifiers = new DeviceApply_Data_Device_Identifiers();
                    deviceApply_Data_Device_Identifiers.device_id = item;
                    long[] pageIds = new long[1]
                    {
                        this.page_id
                    };
                    WxJsonResult wxJsonResult = WXStoreHelper.BindPage(deviceApply_Data_Device_Identifiers, pageIds, ShakeAroundBindType.建立关联关系, ShakeAroundAppendType.新增);
                    if (!wxJsonResult.errcode.Equals(ReturnCode.请求成功))
                    {
                        flag = false;
                    }
                }
                if (flag)
                {
                    base.CloseWindow(null);
                }
                else
                {
                    this.ShowMsg("选择的设备没有配置成功!", false);
                }
            }
        }
Пример #18
0
        public DeviceModel GetDeviceById(long id)
        {
            DeviceApply_Data_Device_Identifiers deviceApplyDataDeviceIdentifier = new DeviceApply_Data_Device_Identifiers()
            {
                device_id = id
            };
            string str = _accessToken;
            List <DeviceApply_Data_Device_Identifiers> deviceApplyDataDeviceIdentifiers = new List <DeviceApply_Data_Device_Identifiers>()
            {
                deviceApplyDataDeviceIdentifier
            };
            DeviceListResultJson deviceListResultJson = ShakeAroundApi.SearchDeviceById(str, deviceApplyDataDeviceIdentifiers, 10000);

            if (deviceListResultJson.errcode != ReturnCode.请求成功)
            {
                throw new Exception(deviceListResultJson.errmsg);
            }
            if (deviceListResultJson.data.devices.Count <= 0)
            {
                return(null);
            }
            return(deviceListResultJson.data.devices[0]);
        }
Пример #19
0
        /// <summary>
        ///  查询设备的关联关系
        /// </summary>
        /// <param name="accessTokenOrAppId"></param>
        /// <param name="deviceIdentifier">指定的设备</param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static RelationSearchResultJson RelationSearch(string accessTokenOrAppId, DeviceApply_Data_Device_Identifiers deviceIdentifier, int timeOut = Config.TIME_OUT)
        {
            return(ApiHandlerWapper.TryCommonApi(accessToken =>
            {
                var url = string.Format("https://api.weixin.qq.com/shakearound/relation/search?access_token={0}", accessToken.AsUrlData());

                var data = new
                {
                    type = 1,
                    device_identifier = deviceIdentifier
                };

                return CommonJsonSend.Send <RelationSearchResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
            }, accessTokenOrAppId));
        }
Пример #20
0
        /// <summary>
        /// 从分组中移除设备
        /// </summary>
        /// <param name="accessTokenOrAppId">调用接口凭证</param>
        /// <param name="groupId">分组唯一标识,全局唯一</param>
        /// <param name="deviceIdentifier">分组列表的起始索引值</param>

        /// <returns></returns>
        public static RegisterResultJson GroupDeleteDevice(string accessTokenOrAppId, string groupId, DeviceApply_Data_Device_Identifiers deviceIdentifier, int timeOut = Config.TIME_OUT)
        {
            return(ApiHandlerWapper.TryCommonApi(accessToken =>
            {
                var url = string.Format("https://api.weixin.qq.com/shakearound/device/group/deletedevice?access_token={0}", accessToken.AsUrlData());
                var data = new object();
                if (!deviceIdentifier.device_id.HasValue)
                {
                    data = new
                    {
                        group_id = groupId,
                        uuid = deviceIdentifier.uuid,
                        major = deviceIdentifier.major,
                        minor = deviceIdentifier.minor
                    };
                }
                else
                {
                    data = new
                    {
                        group_id = groupId,
                        device_id = deviceIdentifier.device_id.Value
                    };
                }


                return CommonJsonSend.Send <RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
            }, accessTokenOrAppId));
        }
Пример #21
0
        /// <summary>
        /// 添加设备到分组
        /// </summary>
        /// <param name="accessTokenOrAppId">调用接口凭证</param>
        /// <param name="groupId">分组唯一标识,全局唯一</param>
        /// <param name="deviceIdentifier">分组列表的起始索引值</param>

        /// <returns></returns>
        public static RegisterResultJson GroupGetAdddevice(string accessTokenOrAppId, string groupId, DeviceApply_Data_Device_Identifiers deviceIdentifier, int timeOut = Config.TIME_OUT)
        {
            return(ApiHandlerWapper.TryCommonApi(accessToken =>
            {
                var url = string.Format("https://api.weixin.qq.com/shakearound/device/group/adddevice?access_token={0}", accessToken.AsUrlData());
                object data = null;
                if (string.IsNullOrEmpty(((long)deviceIdentifier.device_id).ToString()))
                {
                    data = new
                    {
                        group_id = groupId,
                        uuid = deviceIdentifier.uuid,
                        major = deviceIdentifier.major,
                        minor = deviceIdentifier.minor
                    };
                }
                else
                {
                    data = new
                    {
                        group_id = groupId,
                        device_id = deviceIdentifier.device_id
                    };
                }

                return CommonJsonSend.Send <RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
            }, accessTokenOrAppId));
        }
Пример #22
0
 public static StatisticsResultJson StatisticsByDevice(DeviceApply_Data_Device_Identifiers deviceIdentifier, long beginDate, long endDate)
 {
     return(ShakeAroundApi.StatisticsByDevice(WXStoreHelper.siteSettings.WeixinAppId, deviceIdentifier, beginDate, endDate, 10000));
 }
Пример #23
0
 public static WxJsonResult BindPage(DeviceApply_Data_Device_Identifiers deviceIdentifier, long[] pageIds, ShakeAroundBindType bindType, ShakeAroundAppendType appendType)
 {
     return(ShakeAroundApi.BindPage(WXStoreHelper.siteSettings.WeixinAppId, deviceIdentifier, pageIds, bindType, appendType, 10000));
 }