/// <summary> /// 规格同步 /// </summary> /// <param name="obj"></param> public void SpecificationSynchronize(object obj) { try { string sql = @" select S_specID,S_AssetID_FK,S_AssetModuleID_FK,S_specN,S_specToken from T_RTIOT_specifications where S_ISUSE='1' and S_UpdateFlag='1' and S_TenantID='" + tenantid + "'"; DataTable dt = DbHelperSQL.Query(sql).Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { if (sm.getCategoryAsset(dt.Rows[i]["S_AssetModuleID_FK"].ToString().Trim(), dt.Rows[i]["S_AssetID_FK"].ToString().Trim()) != "") { string ret = sm.getDeviceSpecificationByToken(dt.Rows[i]["S_specToken"].ToString().Trim()); if (!string.IsNullOrEmpty(ret)) { sm.updateDeviceSpecification(dt.Rows[i]["S_AssetID_FK"].ToString().Trim(), dt.Rows[i]["S_AssetModuleID_FK"].ToString().Trim(), dt.Rows[i]["S_specN"].ToString().Trim(), dt.Rows[i]["S_specToken"].ToString().Trim()); } else { Specifications s = JsonConvert.DeserializeObject <Specifications>(sm.createDeviceSpecification(dt.Rows[i]["S_AssetID_FK"].ToString().Trim(), dt.Rows[i]["S_AssetModuleID_FK"].ToString().Trim(), dt.Rows[i]["S_specN"].ToString().Trim(), Guid.NewGuid().ToString("N"))); sm.UpdateToken("T_RTIOT_specifications", "S_specToken='" + s.token + "'", "S_specID='" + dt.Rows[i]["S_specID"].ToString().Trim() + "'"); } sm.UpdateFlag("T_RTIOT_specifications", "S_specID='" + dt.Rows[i]["S_specID"].ToString().Trim() + "'"); } } } catch (Exception e) { logger.Error("SpecificationSynchronize异常:" + e.Message); } }
public string updateDeviceSpecification(string assetId, string assetModuleId, string name, string token) { Specifications specifications = new Specifications(); specifications.assetId = assetId; specifications.assetModuleId = assetModuleId; specifications.name = name; specifications.token = token; specifications.containerPolicy = "Standalone"; string data = JsonConvert.SerializeObject(specifications); string ret = gp.HttpPut("http://" + httpurl + "/sitewhere/api/specifications/" + token, data, tenanttoken); return(ret); }
public string createDeviceSpecification(string assetId, string assetModuleId, string name, string token) { token = string.IsNullOrEmpty(token) ? Guid.NewGuid().ToString(): token; Specifications specifications = new Specifications(); specifications.assetId = assetId; specifications.assetModuleId = assetModuleId; specifications.name = name; specifications.token = token; specifications.containerPolicy = "Standalone"; string data = JsonConvert.SerializeObject(specifications); string ret = gp.HttpPost("http://" + httpurl + "/sitewhere/api/specifications", data, tenanttoken); return(ret); }