예제 #1
0
    private bool IsHave(string num)
    {
        IBeaconDev condition = new IBeaconDev();

        condition.IcMac = num;
        int id = TableOperate <IBeaconDev> .GetCountValue(condition);

        if (id > 0)
        {
            return(true);
        }
        return(false);
    }
예제 #2
0
    private void AddJson(string jsonStr)
    {
        //  jsonStr="{ \"v\" : \"1.1.0.26\", \"mid\" : 851, \"time\" : 1748, \"ip\" : \"192.168.60.19\", \"mac\" : \"B4E62DBE9A01\", \"devices\" : [ \"0x001918FC0532D2BF0201061AFF4C000215FDA50693A4E24FB1AFCFC6EB0764782527121458C5\", \"0x03123B6A1B8AF5BF0201061AFF4C000215B5B182C7EAB14988AA99B5C1517008D900010002C5\" ] }";
        //SaveExLog(jsonStr);
        string mac = "";

        if (jsonStr.IndexOf("devices") > -1)
        {
            JsonData json = JsonMapper.ToObject(jsonStr);
            mac = Convert.ToString(json["mac"]);
            //0x03
            //12 3B 6A 1B 8A F5
            //CA 02 01 06 1A FF 4C 00
            //02 15 B5 B1 82 C7 EA B1 49 88 AA 99 B5 C1 51 70 08 D9 00 01 00 02 C5
            JsonData       list   = json["devices"];
            IBeaconGateWay beacon = gateWay(mac);
            if (beacon != null)
            {
                list = RemoveJson(list);

                double maxdistance = beacon.MaxDistance;//设置的最大距离
                for (int i = 0; i < list.Count; i++)
                {
                    string     blueMac = list[i].ToString().Substring(4, 12);
                    IBeaconDev blue    = Isdev(blueMac);
                    if (blue != null)
                    {
                        if (blue.ID > 0 && blue.UserID > 0)//&&blue.UserID!=0非绑定不做操作
                        {
                            string rssi     = list[i].ToString().Substring(16, 2);
                            int    NowRssi  = toRssi(rssi) - 256;
                            double distance = getDistance(-59, Convert.ToDouble(NowRssi));

                            if (distance <= maxdistance)//在设置的最大距离范围内
                            {
                                SaveExLog(beacon.ID + "---" + mac + "-----" + blueMac + "信号-" + NowRssi + "预估距离-" + distance);
                                StopTime(blue.ID, beacon.ID, blue.UserID);
                            }
                        }
                    }
                }
            }
        }


        // SaveExLog(jsonStr);
    }
예제 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        IBeaconDev condition = new IBeaconDev();
        IBeaconDev value     = new IBeaconDev();
        string     title     = GetstringKey("name");

        if (title != "")
        {
            condition.BeaconMac = "%" + title + "%";
            condition.AddAttach("BeaconMac", "like");
        }
        condition.ExhibitionID = AdminMethod.ExhibitionID;
        m_tableManageList      = TableOperate <IBeaconDev> .SelectByPage(value, condition, "order by  id asc", PageSize, PageIndex, ref Count);

        DataBind();
        name.Value = title;
    }
예제 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string act = "";
        string msg = "";

        if (!string.IsNullOrEmpty(Request["act"]))
        {
            act = Convert.ToString(Request["act"]);

            if (act == "insert")

            {
                string height  = Convert.ToString(RequestString.NoHTML(Request["height"]));
                string weight  = Convert.ToString(RequestString.NoHTML(Request["weight"]));
                string cardNum = Convert.ToString(RequestString.NoHTML(Request["num"]));

                int faceid = Convert.ToInt32(Request["faceid"]);
                if (!string.IsNullOrEmpty(Request["userid"]))
                {
                    int        userid    = Convert.ToInt32(Request["userid"]);
                    IBeaconDev condition = new IBeaconDev();
                    condition.IcMac = cardNum;
                    IBeaconDev dev = TableOperate <IBeaconDev> .GetRowData(condition);

                    if (dev.ID > 0)
                    {
                        condition.UserID = userid;
                        condition.ID     = dev.ID;
                        TableOperate <IBeaconDev> .Update(condition);

                        Userinfo userinfo = new Userinfo();
                        userinfo.ID = userid;
                        Userinfo user = TableOperate <Userinfo> .GetRowData(userinfo);

                        if (user.ID > 0)
                        {
                            userinfo.TradeID = user.TradeID + 1;
                            userinfo.AddTime = DateTime.Now;
                            TableOperate <Userinfo> .Update(userinfo);

                            msg = "{\"state\":\"true\", \"msg\":\"IC卡绑定成功\"}";
                            AddCount();
                        }
                    }
                }
                else
                {
                    IBeaconDev condition = new IBeaconDev();
                    condition.IcMac = cardNum;
                    IBeaconDev dev = TableOperate <IBeaconDev> .GetRowData(condition);

                    if (dev.ID > 0)
                    {
                        Userinfo conditions = new Userinfo();
                        conditions.Name     = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                        conditions.NickName = weight;
                        conditions.Phone    = height;
                        conditions.AddTime  = DateTime.Now;
                        conditions.TradeID  = 1;
                        int userid = TableOperate <Userinfo> .InsertReturnID(conditions);

                        if (userid > 0)
                        {
                            Face face = new Face();
                            face.ID         = faceid;
                            face.UserinfoID = userid;
                            TableOperate <Face> .Update(face);

                            condition.UserID = userid;
                            condition.ID     = dev.ID;
                            TableOperate <IBeaconDev> .Update(condition);

                            msg = "{\"state\":\"true\", \"msg\":\"注册成功\"}";
                            AddCount();
                        }
                        else
                        {
                            msg = "{\"state\":\"false\", \"msg\":\"注册失败\"}";
                        }
                    }
                    else
                    {
                        msg = "{\"state\":\"false\", \"msg\":\"IC卡不存在\"}";
                    }
                }
            }
            else if (act == "check")
            {
                string     cardNum   = Convert.ToString(RequestString.NoHTML(Request["num"]));
                IBeaconDev condition = new IBeaconDev();
                condition.IcMac = cardNum;
                IBeaconDev dev = TableOperate <IBeaconDev> .GetRowData(condition);

                if (dev.ID > 0)
                {
                    if (dev.UserID > 0)
                    {
                        msg = "{\"state\":\"true\", \"msg\":\"该卡已绑定\", \"code\":\"1\"}";
                    }
                    else
                    {
                        msg = "{\"state\":\"true\", \"msg\":\"该卡未绑定\", \"code\":\"0\"}";
                    }
                }
                else
                {
                    msg = "{\"state\":\"false\", \"msg\":\"该卡不存在\", \"code\":\"2\"}";
                }


                //int faceid = Convert.ToInt32(Request["faceid"]);
                //Face face = new Face();
                //face.ID = faceid;
                //Face faces = TableOperate<Face>.GetRowData(face);
                //if (faces.ID > 0 && face.UserinfoID > 0)
                //{
                //    Userinfo conditions = new Userinfo();
                //    conditions.ID = face.UserinfoID;
                //    Userinfo userinfo = TableOperate<Userinfo>.GetRowData(conditions);
                //    if (userinfo.ID > 0)
                //    {
                //        msg = "{\"state\":\"true\", \"ID\":\"" + userinfo.ID + "\", \"height\":\"" + userinfo.Name + "\", \"weight\":\"" + userinfo.NickName + "\", \"msg\":\"查询成功\"}";
                //    }
                //    else
                //    {
                //        msg = "{\"state\":\"false\", \"msg\":\"用户不存在\"}";
                //    }

                //}
                //else
                //{
                //    msg = "{\"state\":\"false\", \"msg\":\"未查询到该用户\"}";
                //}
            }
        }
        Response.Write(msg);
    }
예제 #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string action = GetstringKey("action");

        if (action != "save")
        {
            if (!string.IsNullOrEmpty(this.Request["iD"]))
            {
                int        _iD       = Convert.ToInt32(this.Request["iD"]);
                IBeaconDev condition = new IBeaconDev();
                condition.ID = _iD;
                news         = TableOperate <IBeaconDev> .GetRowData(condition);

                iD.Value = Convert.ToString(news.ID);
            }
            DataBind();
        }
        else
        {
            Result     result         = new Result();
            string     logbrief       = "";
            IBeaconDev newChannelNews = new IBeaconDev();
            newChannelNews.ID = 0;
            newChannelNews.AutoForm(this.Page);

            int _iD;
            if (!string.IsNullOrEmpty(this.Request["iD"]))
            {
                _iD = Convert.ToInt32(this.Request["iD"]);
                TableOperate <IBeaconDev> .Update(newChannelNews);

                result.msg = "编辑成功,等待返回列表";
                //logbrief = "管理员:【" + AdminMethod.AdminFullName + "】在" + DateTime.Now.GetDateTimeFormats('f')[0].ToString() + "编辑了为【" + Title + "】的展区";
            }
            else
            {
                newChannelNews.AddTime      = DateTime.Now;
                newChannelNews.AddID        = AdminMethod.AdminID;
                newChannelNews.ExhibitionID = AdminMethod.ExhibitionID;
                // newChannelNews.OrderID = CloudSQL.GetNowTime();
                _iD = TableOperate <IBeaconDev> .InsertReturnID(newChannelNews);

                result.msg = "添加成功,等待返回列表";
                // logbrief = "管理员:【" + AdminMethod.AdminFullName + "】在" + DateTime.Now.GetDateTimeFormats('f')[0].ToString() + "添加了为【" + Title + "】的展区";
            }

            if (_iD > 0)
            {
                result.isOk = true;
                Lognet.AddLogin(logbrief);
            }
            else
            {
                result.msg = "操作失败";
            }
            Response.ContentType = "text/json";
            Response.Write(new JavaScriptSerializer().Serialize(result));
            Response.End();
        }
        DataBind();
    }