public int findProductByName(ref string desc, ref string proData) { if (productName == "") { return(INVALIDLICNAME); } //拼接json数据 StringBuilder jProduct = new StringBuilder(); StringWriter sw = new StringWriter(jProduct); using (JsonWriter writer = new JsonTextWriter(sw)) { writer.Formatting = Formatting.Indented; writer.WriteStartObject(); writer.WritePropertyName("productName"); writer.WriteValue(productName); writer.WriteEndObject(); } //调用公共算法类 algorithm ALG = new algorithm(); string proJsonInfo = jProduct.ToString(); string retJson = ALG.senseCloudRequest(API.ProductList, proJsonInfo, Dev.Appid, Dev.Secret); //解析JSON返回值 JObject jobj = JObject.Parse(retJson); int ret = Convert.ToInt32(jobj["code"].ToString()); desc = jobj["desc"].ToString(); if (ret == 0) { proData = jobj["data"].ToString(); } return(ret); }
public int delProduct(ref string desc) { if (licenseId == 0) { return(INVALIDLICID); } //拼接json数据 StringBuilder jProduct = new StringBuilder(); StringWriter sw = new StringWriter(jProduct); using (JsonWriter writer = new JsonTextWriter(sw)) { writer.Formatting = Formatting.Indented; writer.WriteStartObject(); writer.WritePropertyName("licenseId"); writer.WriteValue(licenseId); writer.WriteEndObject(); } //调用公共算法类 algorithm ALG = new algorithm(); string proJsonInfo = jProduct.ToString(); string retJson = ALG.senseCloudRequest(API.DeleteProduct, proJsonInfo, Dev.Appid, Dev.Secret); //解析JSON返回值 JObject jobj = JObject.Parse(retJson); int ret = Convert.ToInt32(jobj["code"].ToString()); desc = jobj["desc"].ToString(); return(ret); }
public int modifyProduct(ref string desc) { if (licenseId == 0) { return(INVALIDLICID); } if (productName == "" || licenseForm == 0) { return(NSETPRODUCT); } //拼接json数据 StringBuilder jProduct = new StringBuilder(); StringWriter sw = new StringWriter(jProduct); using (JsonWriter writer = new JsonTextWriter(sw)) { writer.Formatting = Formatting.Indented; writer.WriteStartObject(); writer.WritePropertyName("licenseId"); writer.WriteValue(licenseId); if (productName != "") { writer.WritePropertyName("productName"); writer.WriteValue(productName); } writer.WritePropertyName("licenseForm"); writer.WriteStartArray(); if (licenseForm == cloud) { writer.WriteValue(cloud); } else if (licenseForm == slock) { writer.WriteValue(slock); } else if (licenseForm == cldAndSlk) { writer.WriteValue(cloud); writer.WriteValue(slock); } writer.WriteEnd(); if (moduleInfo.Count != 0) { string module = module2Json(); writer.WritePropertyName("modules"); writer.WriteValue(module); } if (raw != "") { writer.WritePropertyName("raw"); writer.WriteValue(raw); } if (pub != "") { writer.WritePropertyName("pub"); writer.WriteValue(pub); } if (rom != "") { writer.WritePropertyName("rom"); writer.WriteValue(rom); } writer.WriteEndObject(); } //调用公共算法类 algorithm ALG = new algorithm(); string proJsonInfo = jProduct.ToString(); string retJson = ALG.senseCloudRequest(API.ModifyProduct, proJsonInfo, Dev.Appid, Dev.Secret); //解析JSON返回值 JObject jobj = JObject.Parse(retJson); int ret = Convert.ToInt32(jobj["code"].ToString()); desc = jobj["desc"].ToString(); return(ret); }