/// <summary> /// Gets the list of tags contained in the map /// </summary> /// <param name="map_loc"></param> /// <returns></returns> List <tag_info> Get_Tag_list(string map_loc) { List <tag_info> ret = new List <tag_info>(); StreamReader map_stream = new StreamReader(map_loc); int table_off = DATA_READ.ReadINT_LE(0x10, map_stream); int table_size = DATA_READ.ReadINT_LE(0x14, map_stream); int file_table_offset = DATA_READ.ReadINT_LE(0x2D0, map_stream); int table_start = table_off + 0xC * DATA_READ.ReadINT_LE(table_off + 4, map_stream) + 0x20; int path_start = 0; for (int i = 0; ; i++) { int tag_table_REF = table_start + 0x10 * i; if (tag_table_REF > table_size + table_start) { break; } string type = DATA_READ.ReadTAG_TYPE(tag_table_REF, map_stream); int datum_index = DATA_READ.ReadINT_LE(tag_table_REF + 4, map_stream); string path = DATA_READ.ReadSTRING(file_table_offset + path_start, map_stream); if (datum_index != -1) { tag_info temp = new tag_info(); temp.datum_index = datum_index; temp.type = type; temp.file_loc = path; ret.Add(temp); //ugh! is basically the last tag if (type.CompareTo("ugh!") == 0) { break; } path_start += path.Length + 1; } } map_stream.Close(); return(ret); }
//Tag点修改/新增 public IActionResult UpdateTagInfo(tag_info tag_Info) { string tagInfoUrl = url + "api/v1/configuration/public/tag"; int id = tag_Info.id; //新增 if (id == 0) { string tagInfoPostData = "{{" + "\"id\":{0}," + "\"description\":\"{1}\"," + "\"tag_type_sub_id\":{2}," + "\"machine_id\":{3}," + "\"name\":\"{4}\"" + "}}"; tagInfoPostData = string.Format(tagInfoPostData, id, tag_Info.description, tag_Info.tag_type_sub_id, tag_Info.machine_id, tag_Info.name); string tagInfoPostResult = PostUrl(tagInfoUrl, tagInfoPostData); JObject joMachinePost = (JObject)JsonConvert.DeserializeObject(tagInfoPostResult); if (Convert.ToInt32(joMachinePost["code"]) == 200) { return(Json("Success")); } else { return(Json("Fail")); } } else {//修改 string tagInfoPutData = "{{" + "\"id\":{0}," + "\"description\":\"{1}\"," + "\"tag_type_sub_id\":{2}," + "\"machine_id\":{3}," + "\"name\":\"{4}\"" + "}}"; tagInfoPutData = string.Format(tagInfoPutData, id, tag_Info.description, tag_Info.tag_type_sub_id, tag_Info.machine_id, tag_Info.name); string tagInfoPutResult = PutUrl(tagInfoUrl, tagInfoPutData); JObject joMachinePut = (JObject)JsonConvert.DeserializeObject(tagInfoPutResult); if (Convert.ToInt32(joMachinePut["code"]) == 200) { return(Json("Success")); } else { return(Json("Fail")); } } }
//Tag点修改/新增 public IActionResult UpdateTagInfo(tag_info tag_Info) { string myurls = url + "api/v1/configuration/public/tag_type_sub"; var typeList = CommonHelper <tag_type_sub> .Get(myurls, HttpContext); var list = typeList.FirstOrDefault(p => p.name_cn == tag_Info.namecn); tag_Info.tag_type_sub_id = list.id; string tagInfoUrl = url + "api/v1/configuration/public/tag"; int id = tag_Info.id; //新增 if (id == 0) { var tagInfoPostData = JsonConvert.SerializeObject(tag_Info); string tagInfoPostResult = PostUrl(tagInfoUrl, tagInfoPostData); JObject joMachinePost = (JObject)JsonConvert.DeserializeObject(tagInfoPostResult); if (Convert.ToInt32(joMachinePost["code"]) == 200) { return(Json("Success")); } else { return(Json("Fail")); } } else {//修改 var tagInfoPutData = JsonConvert.SerializeObject(tag_Info); string tagInfoPutResult = PutUrl(tagInfoUrl, tagInfoPutData); JObject joMachinePut = (JObject)JsonConvert.DeserializeObject(tagInfoPutResult); if (Convert.ToInt32(joMachinePut["code"]) == 200) { return(Json("Success")); } else { return(Json("Fail")); } } }