Beispiel #1
0
        //添加家庭
        public string createHomeInfo(string familyName)
        {
            Dictionary <string, string> setRet = new Dictionary <string, string>();
            Dictionary <string, string> ret    = new Dictionary <string, string>();

            setRet.Add("appKey", appKey);
            setRet.Add("appSecret", appSecret);
            setRet.Add("username", accountOpening);
            setRet.Add("familyName", familyName);
            string getPostInfo = LigerRM.Common.WebRequestHelper.WebRequestPoster.JsonHttpPost(createHomeUrl, JSONHelper.ToJson(setRet), "parameters");

            LogManager.WriteLog("Get:" + getPostInfo);
            Dictionary <string, object> returnInfo = new Dictionary <string, object>();

            returnInfo = JSONHelper.FromJson <Dictionary <string, object> >(getPostInfo);
            if (returnInfo["success"].ToString() == "True")
            {
                ret.Add("ret", "0");
            }
            else
            {
                ret.Add("ret", "1");
            }
            ret.Add("msg", returnInfo["msg"].ToString());
            AddLockNewLog(familyName, "添加家庭", returnInfo["msg"].ToString());   //增加新锁的log请求返回日志
            return(JSONHelper.ToJson(ret));
        }
        public int Update(string person, string Role)
        {
            T_PERSON user   = JSONHelper.FromJson <T_PERSON>(person);
            int      result = 0;

            try
            {
                var list = personRoleVM.GetListAll().Where(x => x.S_PERSONID == user.S_ID).ToList();
                if (list != null && list.Count > 0)
                {
                    list.ForEach(x => personRoleVM.Delete(x));
                }

                if (!string.IsNullOrEmpty(Role))
                {
                    var arr = Role.Split(',');
                    foreach (var item in arr)
                    {
                        T_Person_Role _personRole = new T_Person_Role();
                        _personRole.S_Id         = Common.Utilities.UniqueNumber.GuidNumber();
                        _personRole.S_PERSONID   = user.S_POLICENUM;
                        _personRole.S_ROLE_ID    = item;
                        _personRole.D_UPDATETIME = DateTime.Now;
                        personRoleVM.Add(_personRole);
                    }
                }
                result = userVM.Update(user);
                result = 1;
            }
            catch (Exception ex)
            {
            }
            return(result);
        }
        public int PersonAdd(string person, string Role)
        {
            T_PERSON user   = JSONHelper.FromJson <T_PERSON>(person);
            int      result = 0;

            try
            {
                if (!string.IsNullOrEmpty(Role))
                {
                    var arr = Role.Split(',');
                    foreach (var item in arr)
                    {
                        T_Person_Role _personRole = new T_Person_Role();
                        _personRole.S_Id         = Common.Utilities.UniqueNumber.GuidNumber();
                        _personRole.S_PERSONID   = user.S_POLICENUM;
                        _personRole.S_ROLE_ID    = item;
                        _personRole.D_UPDATETIME = DateTime.Now;
                        personRoleVM.Add(_personRole);
                    }
                }
                result = userVM.Add(user);
                result = 1;
            }
            catch (Exception ex)
            {
            }
            return(result);
        }
Beispiel #4
0
        //删除家庭
        //familyName   新锁Id
        public string deleteFamily(string familyName)
        {
            Dictionary <string, string> setRet = new Dictionary <string, string>();
            Dictionary <string, string> ret    = new Dictionary <string, string>();

            setRet.Add("appKey", appKey);
            setRet.Add("appSecret", appSecret);
            setRet.Add("username", accountOpening);
            setRet.Add("familyName", getDeviceID(familyName, "DeviceID"));
            string getPostInfo = LigerRM.Common.WebRequestHelper.WebRequestPoster.JsonHttpPost(delFamilyUrl, JSONHelper.ToJson(setRet), "parameters");
            Dictionary <string, object> returnInfo = new Dictionary <string, object>();

            returnInfo = JSONHelper.FromJson <Dictionary <string, object> >(getPostInfo);
            if (returnInfo["success"].ToString() == "True")
            {
                ret.Add("ret", "0");
            }
            else
            {
                ret.Add("ret", "1");
            }
            ret.Add("msg", returnInfo["msg"].ToString());
            AddLockNewLog(getDeviceID(familyName, "DeviceID"), "删除家庭", returnInfo["msg"].ToString());   //增加新锁的log请求返回日志
            return(JSONHelper.ToJson(ret));
        }
        public string NewOpenDoor(string newLockId, string userId)
        {
            if (!authentication.ValideLockUser())
            {
                return("{'headerError'}");
            }
            NewLockManager managerNew       = new NewLockManager();
            Dictionary <string, string> ret = new Dictionary <string, string>();
            //传值校验
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("newLockId", newLockId);
            dic.Add("UserId", userId);
            string returnFiled = managerNew.checkIsNullFild(dic);

            if (returnFiled != string.Empty)
            {
                ret.Add("ret", "1");
                ret.Add("msg", "字段" + returnFiled + "不允许为空!");
                return(JSONHelper.ToJson(ret));
            }
            //判断是否授权
            if (managerNew.GetIsEnterprise(userId) == "2")
            {
                ret.Add("ret", "1");
                ret.Add("msg", "我公司暂无给贵公司授权,请核对再操做!");
                return(JSONHelper.ToJson(ret));
            }
            //判断接口是否授权
            if (!managerNew.GetIsInterfacePermissions("9", userId))
            {
                ret.Add("ret", "1");
                ret.Add("msg", "我公司暂无给贵公司授权该接口,请核对再操做!");
                return(JSONHelper.ToJson(ret));
            }
            string lockId = managerNew.getDeviceID(newLockId, "DeviceID");

            if (lockId == string.Empty)
            {
                ret.Add("ret", "1");
                ret.Add("msg", "未获取该家庭锁信息!");
                return(JSONHelper.ToJson(ret));
            }
            //开锁
            string open = managerNew.openDoorSDK(lockId, userId);
            Dictionary <string, object> returnInfo = new Dictionary <string, object>();

            returnInfo = JSONHelper.FromJson <Dictionary <string, object> >(open);
            if (returnInfo["ret"].ToString() == "0")
            {
                ret.Add("ret", "0");
            }
            else
            {
                ret.Add("ret", "1");
            }
            ret.Add("msg", returnInfo["msg"].ToString());
            return(JSONHelper.ToJson(ret));
        }
Beispiel #6
0
    /// <summary>
    /// 获取POST过来通知消息,并以“参数名=参数值”的形式组成字典
    /// </summary>
    /// <returns>request回来的信息组成的数组</returns>
    public SortedDictionary <string, string> GetRequestPost()
    {
        string reqStr = readReqStr();

        SortedDictionary <string, string> sArray = JSONHelper.FromJson <SortedDictionary <string, string> >(reqStr);

        return(sArray);
    }
Beispiel #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            System.IO.Stream postData = Request.InputStream;
            //StreamReader sRead = new StreamReader(postData);
            string postContent = Request.Params["json"];
            //sRead.Close();
            Dictionary <string, string> retDic = new Dictionary <string, string>();
            string       sql       = string.Empty;
            string       statucode = "0";
            string       reason    = "";
            FileStream   fs        = new FileStream(Server.MapPath("~") + "\\AiTianJin\\Log.txt", FileMode.Append);
            StreamWriter sw        = new StreamWriter(fs);
            sw.WriteLine(DateTime.Now.ToString() + " " + postContent);
            try
            {
                //postContent = "{\"res\":[{\"vipm_sn\":\"020059200\",\"intraday_electricity\":\"5.31\",\"electricity_electricity\":\"43.81\",\"wipm_state\":1,\"current_power\":\"95.50\",\"timeflag\":\"2017-12-11 16:17:11\",\"current_electricity\":\"70.02\"}]}";
                //Response.Write(postContent);
                Dictionary <string, ElectricMeter[]> ret1 = JSONHelper.FromJson <Dictionary <string, ElectricMeter[]> >(postContent);
                //{
                //    “vipm_sn”: "020059200",
                //    “intraday_ electricity”: "5.31",
                //    "electricity_ electricity": "43.81",
                //    "wipm_state": 1 ,
                //    "current_power": "95.50" ,
                //    "timeflag": "2017-12-11 16:17:11" ,
                //    "current_electricity": "70.02" ,
                //}
                foreach (ElectricMeter b in ret1["res"])
                {
                    sql = "insert into Electric_Meter_Date values ('" + Guid.NewGuid().ToString() + "','" + b.vipm_sn + "','" + b.intraday_electricity + "','" + b.electricity_electricity + "','" + b.wipm_state + "','" + b.current_power + "','" + DateTime.Parse(b.timeflag).ToString() + "','" + b.current_electricity + "','" + DateTime.Now.ToString() + "')";
                    MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql));
                }
            }
            catch (Exception ex)
            {
                statucode = "201";
                reason    = ex.Message;
                sw.WriteLine(DateTime.Now.ToString() + " " + ex.Message);
            }


            ////开始写入
            //sw.WriteLine(DateTime.Now.ToString() + " " + Request.Headers["ResourceId"] + " " + postContent);

            //清空缓冲区
            sw.Flush();
            //关闭流
            sw.Close();
            fs.Close();

            Dictionary <string, string> ret = new Dictionary <string, string>();
            ret.Add("resutcode", statucode);
            ret.Add("reason", reason);
            Response.Write(JSONHelper.ToJson(ret));
        }
    }
Beispiel #8
0
    protected void GetEnviromentData()
    {
        string url = "https://free-api.heweather.com/s6/air/now?location=auto_ip&key=0ee001fdc5c7401d82d9f683a93fb881";
        string ret = LigerRM.Common.WebRequestHelper.WebRequestPoster.Post(url);

        EnvObject r = JSONHelper.FromJson <EnvObject>(ret);

        ENV_DATA = r.HeWeather6[0].air_now_city.pm25 + "," + r.HeWeather6[0].air_now_city.pm10;
    }
Beispiel #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string postContent = Request.Params["parameters"];
            Dictionary <string, string> ret = new Dictionary <string, string>();
            string sql       = string.Empty;
            string statucode = "000";
            string reason    = "request success";
            ////打印
            FileStream   fs = new FileStream(Server.MapPath("~") + "\\EvenHeardLock\\LockIdPassCallbackLog.txt", FileMode.Append);
            StreamWriter sw = new StreamWriter(fs);
            sw.WriteLine(DateTime.Now.ToString() + "接收到参数" + postContent);
            try
            {
                //string postContent = "{\"res\":[{\"ret\":\"true\",\"StartDate\":\"1520920855\",\"EndDate\":\"1520920855\",\"pwd\":\"888888\",\"userId\":\"17702285600\"}]}";
                Dictionary <string, PassCallBack[]> retCallBack = JSONHelper.FromJson <Dictionary <string, PassCallBack[]> >(postContent);
                foreach (PassCallBack b in retCallBack["res"])
                {
                    sql = "select * from v_RentPass_view where UserId='" + b.userId + "'and StartDate='" + GetDateTime(b.StartDate) + "' and EndDate='" + GetDateTime(b.EndDate) + "' and Password='******'";
                    DataTable dt = MySQLHelper.ExecuteDataset(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)).Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        sql = "update Rent_lock_User_Password set IsAdd='" + b.ret + "' where PassId='" + dt.Rows[0]["ID"].ToString() + "'";
                        MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql));
                    }
                    else
                    {
                        statucode = "201";
                        reason    = "暂无密码信息";
                    }
                }
            }
            catch (Exception ex)
            {
                statucode = "201";
                reason    = ex.Message;
            }
            sw.WriteLine(DateTime.Now.ToString() + "数据返回:" + reason);
            //清空缓冲区
            sw.Flush();
            //关闭流
            sw.Close();
            fs.Close();


            ret.Add("resutcode", statucode);
            ret.Add("reason", reason);
            Response.Write(JSONHelper.ToJson(ret));
        }
    }
Beispiel #10
0
        public async Task <TrainingStatus> GetTrainingStatus()
        {
            var groupId = Configuration["PersonGroupId"];

            var url = Configuration["CognitiveFacesUri"] + $"/persongroups/{groupId}/training";

            var key = Configuration["CognitiveFacesKey"];

            var response = await CognitiveServicesHttpClient.HttpGet(url, key);

            var responseBytes = await response.Content.ReadAsStringAsync();

            return(JSONHelper.FromJson <TrainingStatus>(responseBytes));
        }
Beispiel #11
0
 public Liders[] GetLidersFromJson(string URL)
 {
     using (WebClient WebClient = new WebClient())
     {
         try
         {
             return(JSONHelper.FromJson <Liders>(JSONHelper.FixJson(WebClient.DownloadString(URL))));
         }
         catch
         {
             return(null);
         }
     }
 }
Beispiel #12
0
    void Start()
    {
        string dataAsJSON = File.ReadAllText("Assets/JSON/Characters.json");

        characterArray = JSONHelper.FromJson <Character>(dataAsJSON);
        int personID = bartender.convoPersonID;

        dataAsJSON       = File.ReadAllText("Assets/JSON/Dialogue" + personID + ".json");
        dialogueArray    = JSONHelper.FromJson <Dialogue>(dataAsJSON);
        currentCharacter = characterArray[personID];
        text.ChangeText(currentCharacter.Name);
        LoadConvoPic();
        RunDialogue();
    }
Beispiel #13
0
        /// <summary>
        /// 删除密码和IC卡
        /// </summary>
        /// <param name="aarId"></param>
        /// <returns></returns>
        public string ClearPasswordToLock(string aarId)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();
            RentAttribute a  = new RentAttribute(int.Parse(aarId));
            DataTable     dt = MySQLHelper.ExecuteDataset(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand("select * from Rent_Locks where rentno='" + a.RentNo + "'")).Tables[0];

            if (dt.Rows.Count > 0)
            {
                string returnStr1 = string.Empty;
                if (dt.Rows[0]["DeviceType"].ToString() == "1") //新锁
                {
                    NewLockManager managerNew = new NewLockManager();
                    //清空临时卡
                    string iCCard = managerNew.delAction(a.RRAContactTel, "临时卡片", a.RRAStartDate.ToString(), a.RRAEndDate.ToString(), dt.Rows[0]["DeviceID"].ToString(), "1");
                    //清空临时密码
                    string password = managerNew.delAction(a.RRAContactTel, "临时密码", a.RRAStartDate.ToString(), a.RRAEndDate.ToString(), dt.Rows[0]["DeviceID"].ToString(), "1");
                    Dictionary <string, object> retIC = new Dictionary <string, object>();
                    retIC = JSONHelper.FromJson <Dictionary <string, object> >(iCCard);
                    Dictionary <string, object> retPass = new Dictionary <string, object>();
                    retPass = JSONHelper.FromJson <Dictionary <string, object> >(password);
                    if (retIC["ret"].ToString() == "1" || retPass["ret"].ToString() == "1")
                    {
                        returnStr1 = "ICCard:" + retIC["msg"].ToString() + "Pass:"******"msg"].ToString();
                    }
                }
                else  //旧锁
                {
                    string sql = "select * from Rent_Locks_ICCards where LockID='" + dt.Rows[0]["DeviceID"].ToString() + "' and StartDate='" + a.RRAStartDate.ToString("yyyy-MM-dd HH:mm:ss") + "' and EndDate='" + a.RRAEndDate.ToString("yyyy-MM-dd HH:mm:ss") + "'";

                    LockManager manager = new LockManager();
                    DataTable   dt1     = MySQLHelper.ExecuteDataset(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)).Tables[0];
                    foreach (DataRow row in dt1.Rows)
                    {
                        string returnStr = manager.UpdatePassengerInfoToDevice(dt.Rows[0]["DeviceID"].ToString(), row["ICCard"].ToString(), "", "", "", a.RRAStartDate.ToString("yyyyMMddHHmm").Substring(2, 10), a.RRAEndDate.ToString("yyyyMMddHHmm").Substring(2, 10), "2");
                    }

                    returnStr1 = manager.UpdatePassengerInfoToDevice(dt.Rows[0]["DeviceID"].ToString(), "", "", "", a.RRANationName, a.RRAStartDate.ToString("yyyyMMddHHmm").Substring(2, 10), a.RRAEndDate.ToString("yyyyMMddHHmm").Substring(2, 10), "4");
                }

                dic.Add("ret", "0");
                dic.Add("msg", returnStr1);
            }
            else
            {
                dic.Add("ret", "1");
                dic.Add("msg", "未发现智能锁信息,无法添加密码");
            }
            return(JSONHelper.ToJson(dic));
        }
    /// <summary>
    /// Converts a Json Path to a List of Nodes
    /// </summary>
    /// <param name="json"></param>
    /// <returns></returns>
    private List <Node> PathFromJSON(string json)
    {
        List <Node> path = new List <Node>();

        int[] pathArray;

        pathArray = JSONHelper.FromJson <int>(json);

        foreach (int f in pathArray)
        {
            path.Add(Nodes[f]);
        }

        return(path);
    }
        public async Task <VerifySpeakerResponse> VerifySpeaker(VerifySpeaker model)
        {
            var url = $"{Configuration["AudioAnalyticsAPI"]}verify?verificationProfileId={model.Id}";

            var key = Configuration["AudioAnalyticsKey"];

            using (var inputStream = model.Audio.OpenReadStream())
            {
                var response = await CognitiveServicesHttpClient.HttpPostAudio(inputStream, url, key);

                var responseBytes = await response.Content.ReadAsStringAsync();

                return(JSONHelper.FromJson <VerifySpeakerResponse>(responseBytes));
            }
        }
        public async Task <IdentificationStatus> PollIdentifySpeaker(string url)
        {
            var key = Configuration["AudioAnalyticsKey"];

            var response = await CognitiveServicesHttpClient.HttpGet(url, key);

            var responseBytes = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                var result = JSONHelper.FromJson <IdentificationStatus>(responseBytes);

                return(result);
            }

            throw new Exception($"Failed request : { responseBytes } ");
        }
Beispiel #17
0
        public async Task <PersonGroups[]> GetPersonGroups()
        {
            var url = Configuration["CognitiveFacesUri"] + $"/persongroups";

            var key = Configuration["CognitiveFacesKey"];

            var response = await CognitiveServicesHttpClient.HttpGet(url, key);

            var responseBytes = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                return(JSONHelper.FromJson <PersonGroups[]>(responseBytes));
            }

            throw new Exception($"Failed request : { responseBytes } ");
        }
        public static async Task Run(
            [QueueTrigger("Handwriting")] string item,
            [Table("images")] CloudTable cloudTable,
            TraceWriter log)
        {
            log.Info("Start");

            var handwritingRequest = JSONHelper.FromJson <HandwritingRequest>(item);

            var cogKey = ConfigurationManager.AppSettings["CognitiveVisionKey"];

            var client = new HttpClient();

            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", cogKey);

            var i         = 0;
            var succeeded = false;

            do
            {
                System.Threading.Thread.Sleep(1000);

                var response = await client.GetAsync(handwritingRequest.OperationLocation);

                var contentString = await response.Content.ReadAsStringAsync();

                var result = JSONHelper.FromJson <Handwriting>(contentString);

                succeeded = result.Status == "Succeeded";

                log.Info(result.Status);

                if (succeeded)
                {
                    await cloudTable.Update(handwritingRequest.Key, contentString, (image, text) =>
                    {
                        image.Handwriting = text;
                    });
                }

                i++;
            }while (i < 5 && !succeeded);

            log.Info("Finish");
        }
Beispiel #19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            System.IO.Stream postData    = Request.InputStream;
            StreamReader     sRead       = new StreamReader(postData);
            string           postContent = sRead.ReadToEnd();
            sRead.Close();
            Dictionary <string, string> ret = new Dictionary <string, string>();
            string sql       = string.Empty;
            string statucode = "000";
            string reason    = "request success";
            //////打印
            FileStream   fs = new FileStream(Server.MapPath("~") + "\\EvenHeardLock\\LockReturnLog.txt", FileMode.Append);
            StreamWriter sw = new StreamWriter(fs);
            sw.WriteLine(DateTime.Now.ToString() + "接收到参数" + postContent);
            try
            {
                //postContent = "{\"res\":[{\"ret\":\"true\",\"StartDate\":\"\",\"EndDate\":\"\",\"uuid\":\"-34b634a4\",\"userId\":\"11111\"}]}";
                Dictionary <string, LockReturnBak[]> retCallBack = JSONHelper.FromJson <Dictionary <string, LockReturnBak[]> >(postContent);
                foreach (LockReturnBak b in retCallBack["res"])
                {
                    sql = "insert into Rent_Locks_ReturnLog values ('" + Guid.NewGuid().ToString() + "','" + b.userId + "','" + b.devId + "','" + b.pwd + "','" + 1 + "','" + GetDateTime(b.openTime) + "','" + DateTime.Now.ToString() + "','" + b.openType + "', '')";
                    MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql));
                }
            }
            catch (Exception ex)
            {
                statucode = "201";
                reason    = ex.Message;
                sw.WriteLine(DateTime.Now.ToString() + " " + ex.Message);
            }

            //清空缓冲区
            sw.Flush();
            //关闭流
            sw.Close();
            fs.Close();


            ret.Add("resutcode", statucode);
            ret.Add("reason", reason);
            Response.Write(JSONHelper.ToJson(ret));
        }
    }
Beispiel #20
0
    protected void GetWeatherData()
    {
        string url = "https://free-api.heweather.com/s6/weather/forecast?location=auto_ip&key=0ee001fdc5c7401d82d9f683a93fb881";
        string ret = LigerRM.Common.WebRequestHelper.WebRequestPoster.Post(url);

        RootObject r = JSONHelper.FromJson <RootObject>(ret);

        for (int i = 0; i < r.HeWeather6[0].daily_forecast.Count; i++)
        {
            WEATHER_CATEGORIES += DateTime.Parse(r.HeWeather6[0].daily_forecast[i].date).ToString("MM-dd") + ",";
            WEATHER_DATA       += r.HeWeather6[0].daily_forecast[i].tmp_max + ",";
        }
        if (!string.IsNullOrEmpty(WEATHER_CATEGORIES))
        {
            WEATHER_CATEGORIES = WEATHER_CATEGORIES.Substring(0, WEATHER_CATEGORIES.Length - 1);
            WEATHER_DATA       = WEATHER_DATA.Substring(0, WEATHER_DATA.Length - 1);
        }
    }
        public async Task <EnrollmentStatus> CheckEnrollmentStatus(Guid id)
        {
            var url = $"{ Configuration["AudioAnalyticsAPI"] }identificationProfiles/{ id }";

            var key = Configuration["AudioAnalyticsKey"];

            var response = await CognitiveServicesHttpClient.HttpGet(url, key);

            var responseBytes = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                var result = JSONHelper.FromJson <EnrollmentStatus>(responseBytes);

                return(result);
            }

            throw new Exception($"Failed request : { responseBytes } ");
        }
Beispiel #22
0
        private string IOLET_URL = "http://219.150.56.148:8089/api/iolets";   //"http://218.17.103.142:8094//api/iolets";

        public bool LoginMotorPlatform()
        {
            string json = "{\"apid\":\"TJ_TIANTAJ_PS\",\"poa\":{\"uri\":\"http://10.10.108.1:8081/MotorManage/Motor_Notify_Url.aspx\", \"token\":\"TJ_TIANTAJ_PS\"}}";
            Dictionary <string, string> kv = new Dictionary <string, string>();

            kv.Add("ResourceId", "login");
            kv.Add("RequestId", "EBA1000S");
            string retStr = LigerRM.Common.WebRequestHelper.WebRequestPoster.PostJson(LOGIN_URL, json, kv);
            Dictionary <string, object> ret = JSONHelper.FromJson <Dictionary <string, object> >(retStr);

            if (ret["rsc"].ToString() == "200")
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public async Task <EnrollmentPhrases[]> GetVerificationPhrases(string locale)
        {
            var url = $"{Configuration["AudioAnalyticsAPI"]}verificationPhrases?locale={locale}";

            var key = Configuration["AudioAnalyticsKey"];

            var response = await CognitiveServicesHttpClient.HttpGet(url, key);

            var responseBytes = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                var result = JSONHelper.FromJson <EnrollmentPhrases[]>(responseBytes);

                return(result);
            }

            return(new EnrollmentPhrases[] { });
        }
Beispiel #24
0
        public async Task <IQueryable <FaceVerificationProfile> > GetPersons()
        {
            var groupId = Configuration["PersonGroupId"];

            var url = Configuration["CognitiveFacesUri"] + $"/persongroups/{groupId}/persons";

            var key = Configuration["CognitiveFacesKey"];

            var response = await CognitiveServicesHttpClient.HttpGet(url, key);

            var responseBytes = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                return(JSONHelper.FromJson <List <FaceVerificationProfile> >(responseBytes).AsQueryable());
            }

            throw new Exception($"Failed request : {responseBytes} ");
        }
Beispiel #25
0
        //冻结锁和解冻锁
        //type 0 冻结锁   1 解冻锁
        public string freezeAndUnfreezeLock(string familyName, string type)
        {
            Dictionary <string, string> ret    = new Dictionary <string, string>();
            Dictionary <string, string> setRet = new Dictionary <string, string>();

            setRet.Add("appKey", appKey);
            setRet.Add("appSecret", appSecret);
            setRet.Add("familyName", familyName);
            setRet.Add("username", accountOpening);
            string url    = string.Empty;
            string menu   = string.Empty;
            string status = string.Empty;

            if (type == "1")
            {
                url    = unfreezeLockUrl;
                menu   = "解冻锁";
                status = "0";
            }
            else
            {
                url    = freezeLockUrl;
                menu   = "冻结锁";
                status = "3";
            }
            string getPostInfo = LigerRM.Common.WebRequestHelper.WebRequestPoster.JsonHttpPost(url, JSONHelper.ToJson(setRet), "parameters");  //调用远程
            Dictionary <string, object> returnInfo = new Dictionary <string, object>();

            returnInfo = JSONHelper.FromJson <Dictionary <string, object> >(getPostInfo);
            if (returnInfo["success"].ToString() == "True")
            {
                ret.Add("ret", "0");
                string sql = "update Rent_Locks set status='" + status + "' where DeviceID='" + familyName + "'";
                MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql));
            }
            else
            {
                ret.Add("ret", "1");
            }
            ret.Add("msg", returnInfo["msg"].ToString());
            AddLockNewLog(familyName, menu, returnInfo["msg"].ToString());   //增加新锁的log请求返回日志
            return(JSONHelper.ToJson(ret));
        }
Beispiel #26
0
    public string CreateWithdrawalsLog(string jsonRequest)
    {
        string jsonRequestInfo = Encrypt.AESDecode(jsonRequest);

        if (string.Empty == jsonRequestInfo) //aes校验
        {
            Dictionary <string, string> retJson = new Dictionary <string, string>();
            retJson.Add("ret", "1");
            retJson.Add("msg", "request json false");
            return(JSONHelper.ToJson(retJson));
        }
        Dictionary <string, object> retRequest = new Dictionary <string, object>();

        retRequest = JSONHelper.FromJson <Dictionary <string, object> >(jsonRequestInfo);
        //插入log数据
        string sql = "insert into CF_User_Withdrawals_Log values ('" + Guid.NewGuid().ToString() + "','" + retRequest["idCard"].ToString() + "','" + retRequest["no_order"].ToString() + "','" + retRequest["oid_partner"].ToString() + "','" + retRequest["oid_paybill"].ToString() + "','" + retRequest["ret_code"].ToString() + "','" + retRequest["ret_msg"].ToString() + "','" + retRequest["sign"].ToString() + "','" + retRequest["sign_type"].ToString() + "','" + 0 + "','" + retRequest["fee"].ToString() + "','" + DateTime.Now.ToString() + "')";

        MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql));
        return("111");
    }
Beispiel #27
0
 public static AjaxResult UnFreezeLock(string ID, string LockType)
 {
     if (LockType == "1") //新锁
     {
         NewLockManager managerNew = new NewLockManager();
         string         returnDate = managerNew.freezeAndUnfreezeLock(ID, "1");
         Dictionary <string, object> returnInfo = new Dictionary <string, object>();
         returnInfo = JSONHelper.FromJson <Dictionary <string, object> >(returnDate);
         if (returnInfo["ret"].ToString() == "1")
         {
             return(AjaxResult.Error(returnInfo["msg"].ToString()));
         }
     }
     else
     {
         LockManager manager = new LockManager();
         manager.UnFreezeLock(ID);
     }
     return(AjaxResult.Success());
 }
Beispiel #28
0
    /// <summary>
    /// Deserializes data
    /// </summary>
    /// <param name="json">Json data</param>
    private void Deserialise(string json)
    {
        List <PrefabSet> Prefabs = new List <PrefabSet>();

        //Deserialise data
        LevelObjects = JSONHelper.FromJson <LevelObject>(json);
        // Loop through data and check if we have the item with that name in prefabset
        foreach (var item in LevelObjects)
        {
            if (!Prefabs.Any(i => i.name == item.shape))
            {
                Prefabs.Add(new PrefabSet()
                {
                    name  = item.shape,
                    scale = 1.0f,
                });
            }
        }

        PrefabObjects = Prefabs.ToArray();
    }
        public async Task DeleteProfiles()
        {
            var url = $"{Configuration["AudioAnalyticsAPI"]}verificationProfiles/";

            var key = Configuration["AudioAnalyticsKey"];

            var response = await CognitiveServicesHttpClient.HttpGet(url, key);

            var responseBytes = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                var enrollments = JSONHelper.FromJson <EnrollmentStatus[]>(responseBytes);

                foreach (var enrollment in enrollments)
                {
                    var profileUrl = url + enrollment.VerificationProfileId;

                    var r = await CognitiveServicesHttpClient.HttpDelete(profileUrl, key);
                }
            }
        }
Beispiel #30
0
 //开锁操做
 public static AjaxResult UnLockDevice(string ID, string LockType)
 {
     if (LockType == "1")  //新锁
     {
         NewLockManager managerNew = new NewLockManager();
         string         ret        = managerNew.openDoor(ID);
         Dictionary <string, object> returnInfo = new Dictionary <string, object>();
         returnInfo = JSONHelper.FromJson <Dictionary <string, object> >(ret);
         if (returnInfo["ret"].ToString() == "0")
         {
             return(AjaxResult.Success());
         }
         else
         {
             return(AjaxResult.Error("开锁失败!"));
         }
     }
     else
     {
         LockManager manager = new LockManager();
         string      ret     = manager.UnLockDevice(ID);
         if (ret.Substring(0, 1) == "0")
         {
             return(AjaxResult.Success());
         }
         else if (ret.Substring(0, 1) == "1")
         {
             return(AjaxResult.Error("已执行开锁操作,但未成功!"));
         }
         else if (ret.Substring(0, 1) == "2")
         {
             return(AjaxResult.Error("开锁超时!"));
         }
         else
         {
             return(AjaxResult.Error("开锁失败!"));
         }
     }
 }