/// <summary> /// 生产 /// </summary> /// <param name="userId"></param> /// <param name="seckillArticleId">秒杀商品id</param> /// <returns> /// 1:下单成功、 /// 0:下单失败 /// </returns> public int PushRedis(String userId, string seckillArticleId) { ModelQueueParam modelQueue = new ModelQueueParam(); modelQueue.userId = userId; modelQueue.seckillArticleId = seckillArticleId; //总值模式 lock (lockRedis) { //使用redis存储库存 int stockNum = (int)_redisdb.StringGet(seckillArticleId); if (stockNum > 0) { modelQueue.goodQuantity = stockNum; //此处是为了证明插入顺序和消费顺序一致 stockNum--; _redisdb.StringSet(seckillArticleId, stockNum); //进行生产-可以下单 #region 使用reids队列进行储存 var jsonStr = JsonHelp.ToJsonString(modelQueue); _redisdb.ListLeftPush("stock-y", jsonStr); #endregion return(1); } else { //库存已使用完成 return(0); } } }
/// <summary> /// 生产 /// </summary> /// <param name="userId"></param> /// <param name="seckillArticleId"></param> /// <returns> /// 1:下单成功、 /// 0:下单失败 /// </returns> public int PushRedis(String userId, string seckillArticleId) { ModelQueueParam modelQueue = new ModelQueueParam(); modelQueue.userId = userId; modelQueue.seckillArticleId = seckillArticleId; //总值模式 lock (lockRedis) { if (GlobalParam.queueStockrNum > 0) { modelQueue.goodQuantity = GlobalParam.queueStockrNum; GlobalParam.queueStockrNum--; //进行生产-可以下单 #region 使用reids队列进行储存 var jsonStr = JsonHelp.ToJsonString(modelQueue); _redisdb.ListLeftPush("order-key", jsonStr); #endregion return(1); } else { //库存已使用完成 return(0); } } }
/// <summary> /// 删除人脸 delface /// </summary> /// <param name="person_id">待删除人脸的个体身份id</param> /// <param name="face_ids">删除人脸id的列表</param> /// <returns>返回的结果,JSON字符串,字段参见API文档</returns> public static string delface(string person_id, List <string> face_ids) { string expired = Utility.UnixTime(EXPIRED_SECONDS); string methodName = "youtu/api/delface"; StringBuilder postData = new StringBuilder(); string pars = "\"app_id\":\"{0}\",\"person_id\":\"{1}\",\"face_ids\":{2}"; pars = string.Format(pars, Conf.Instance().APPID, person_id, JsonHelp <string[]> .ToJsonString(face_ids.ToArray())); postData.Append("{"); postData.Append(pars); postData.Append("}"); string result = Http.HttpPost(methodName, postData.ToString(), Auth.appSign(expired, Conf.Instance().USER_ID)); return(result); }
/// <summary> /// 个体创建 newpersonurl /// </summary> /// <param name="url">图片的url</param> /// <param name="person_id">新建的个体id,用户指定,需要保证app_id下的唯一性</param> /// <param name="person_name">姓名</param> /// <param name="group_ids">新建的个体存放的组id,可以指定多个组id,用户指定(组默认创建)</param> /// <param name="person_tag">备注信息,用户自解释字段</param> /// <returns>返回的结果,JSON字符串,字段参见API文档</returns> public static string newpersonurl(string url, string person_id, string person_name, List <string> group_ids, string person_tag) { string expired = Utility.UnixTime(EXPIRED_SECONDS); string methodName = "youtu/api/newperson"; StringBuilder postData = new StringBuilder(); string pars = "\"app_id\":\"{0}\",\"url\":\"{1}\",\"group_ids\":{2},\"person_id\":\"{3}\",\"person_name\":\"{4}\",\"tag\":\"{5}\""; pars = string.Format(pars, Conf.Instance().APPID, url, JsonHelp <string[]> .ToJsonString(group_ids.ToArray()), person_id, person_name, person_tag); postData.Append("{"); postData.Append(pars); postData.Append("}"); string result = Http.HttpPost(methodName, postData.ToString(), Auth.appSign(expired, Conf.Instance().USER_ID)); return(result); }
/// <summary> /// 多人脸检索 multifaceidentify /// </summary> /// <param name="image_path">待识别图片路径</param> /// <param name="group_id">识别的组id</param> /// <param name="group_ids">个体存放的组id,可以指定多个组id</param> /// <returns>返回的结果,JSON字符串,字段参见API文档</returns> public static string multifaceidentify(string image_path, string group_id, List <string> group_ids, int topn = 5, int min_size = 40) { string expired = Utility.UnixTime(EXPIRED_SECONDS); string methodName = "youtu/api/multifaceidentify"; StringBuilder postData = new StringBuilder(); string pars = "\"app_id\":\"{0}\",\"group_id\":\"{1}\",\"group_ids\":{2},\"image\":\"{3}\",\"topn\":{4},\"min_size\":{5}"; pars = string.Format(pars, Conf.Instance().APPID, group_id, JsonHelp <string[]> .ToJsonString(group_ids.ToArray()), Utility.ImgBase64(image_path), topn, min_size); postData.Append("{"); postData.Append(pars); postData.Append("}"); string result = Http.HttpPost(methodName, postData.ToString(), Auth.appSign(expired, Conf.Instance().USER_ID)); return(result); }
/// <summary> /// 增加人脸 addface /// </summary> /// <param name="person_id">新增人脸的个体身份id</param> /// <param name="url_arr">待增加的包含人脸的url,可加入多个(包体大小<2m)</param> /// <param name="facetag">人脸备注信息,用户自解释字段</param> /// <returns>返回的结果,JSON字符串,字段参见API文档</returns> public static string addfaceurl(string person_id, List <string> url_arr, string facetag = "") { List <string> faceImgBase64List = new List <string>(); string expired = Utility.UnixTime(EXPIRED_SECONDS); string methodName = "youtu/api/addface"; StringBuilder postData = new StringBuilder(); string pars = "\"app_id\":\"{0}\",\"urls\":{1},\"person_id\":\"{2}\",\"tag\":\"{3}\""; pars = string.Format(pars, Conf.Instance().APPID, JsonHelp <string[]> .ToJsonString(url_arr.ToArray()), person_id, facetag); postData.Append("{"); postData.Append(pars); postData.Append("}"); string result = Http.HttpPost(methodName, postData.ToString(), Auth.appSign(expired, Conf.Instance().USER_ID)); return(result); }