예제 #1
0
        /// <summary>
        /// 加密数据
        /// </summary>
        /// <param name="loackname"></param>
        /// <param name="loackmac"></param>
        /// <param name="checkvalue"></param>
        /// <returns></returns>
        public bool EncrptyData(string loackname, string loackmac, out string checkvalue)
        {
            checkvalue = string.Empty;
            string readEncdata = loackname + "," + loackmac + "," + FingerPrint.Value().ToString();

            try
            {
                checkvalue = this.Encrypt3Des(readEncdata, MasterKey, CipherMode.CBC);

                if (checkvalue == "")
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 2,对外接口:查看已经搜索到的所有BLE设备
        /// </summary>
        /// <returns></returns>
        public string ViewDevice()
        {
            List <outParam> outdata = new List <outParam>();

            //string outParam = string.Empty;
            if (EventClass.GetInstance()._processFlags == 1)
            {
                RecordLog.GetInstance().WriteLog(Level.Info, "查找结束");
            }
            if (EventClass.GetInstance()._deviceAddress.Count <= 0)
            {
                return("");
            }
            RecordDeviceInfo.GetInstance().DeletDeviceInfoFile();

            string lastmac  = string.Empty;
            string lastTemp = string.Empty;
            int    status   = 0;
            int    ret      = OpenAppDo.GetInstance().judelkconnect(out status);

            if (ret == 0)
            {
                if (status != 0)
                {
                    RecordLog.GetInstance().WriteLog(Level.Info, "发现已经存在蓝牙信息");
                    List <string> outStrList = EventClass.GetInstance().knowsLock;
                    foreach (string splitparam in EventClass.GetInstance()._deviceAddress)
                    {
                        foreach (string lockInfo in outStrList)
                        {
                            if (lockInfo.Split(',')[1].ToString().Equals(splitparam.Split('|')[1].ToString()))
                            {
                                //mac相同才会显示
                                outParam temp = new outParam()
                                {
                                    Name    = lockInfo.Split(',')[0].ToString(),
                                    Mac     = lockInfo.Split(',')[1].ToString(),
                                    SetTime = lockInfo.Split(',')[2].ToString(),
                                };
                                outdata.Add(temp);
                                if (lastmac == lockInfo.Split(',')[1].ToString())
                                {
                                    continue;
                                }
                                lastmac = temp.Mac;
                                //判断上次地址和当前地址是否一致
                                EventClass.GetInstance()._dicdeviceAddress.Add(splitparam.Split('|')[0].ToString(), splitparam.Split('|')[1].ToString());
                                RecordDeviceInfo.GetInstance().WriteLocalInfo(splitparam.Split('|')[0].ToString(), splitparam.Split('|')[1].ToString(), FingerPrint.Value().ToString());
                            }
                        }
                    }
                    EventClass.GetInstance().knowsLock.Clear();
                }
                else
                {
                    foreach (string splitparam in EventClass.GetInstance()._deviceAddress)
                    {
                        //记录本次地址 start
                        string msg = string.Empty;
                        if (lastTemp != splitparam.Split('|')[1].ToString())
                        {
                            RedvelopRecord.GetInstance().RegeditDoorSetting(out msg, splitparam.Split('|')[1].ToString());
                            lastTemp = splitparam.Split('|')[1].ToString();
                        }
                        //记录本次地址 end
                        EventClass.GetInstance()._dicdeviceAddress.Add(splitparam.Split('|')[0].ToString(), splitparam.Split('|')[1].ToString());
                        RecordDeviceInfo.GetInstance().WriteLocalInfo(splitparam.Split('|')[0].ToString(), splitparam.Split('|')[1].ToString(), FingerPrint.Value().ToString());
                        outParam temp = new outParam()
                        {
                            Name    = "",
                            Mac     = splitparam.Split('|')[1].ToString(),
                            SetTime = "",
                        };
                        outdata.Add(temp);
                    }
                }
            }
            //[{"Name":"前门","Mac":"0CAE7DAB5F72","SetTime":"2018-10-16 03:00:45"}]
            string json = JsonConvert.SerializeObject(outdata);

            return(json);
        }