Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revision Both sides next revision
en:pro:remoteapi:codesamples:update_item [06/03/2013 15:33]
127.0.0.1 external edit
en:pro:remoteapi:codesamples:update_item [06/03/2013 16:00]
zuve
Line 1: Line 1:
 {{indexmenu_n>​4}} {{indexmenu_n>​4}}
-====== ​Созданиередактирование и удаление элементов ​======+====== ​Creatingediting and deleting items ======
  
-Рассмотрим работу с элементами на примере созданияредактирования и удаления объекта. Принципы создания и удаления других элементов аналогичны рассмотренным нижеа редактирование зависит от конкретного типа элемента.+Let's see how standard operations with items such as creatingeditingand deleting are performed in Wialon. As an example we'll take a unit. Manipulations with items of other types are similar to ones described below except editing which differs according to item type.
  
-===== Создание объекта ​===== +===== Creating unit ===== 
- +Let's create a unit with name "​ips_unit"​ and device type "Wialon IPS" ​(list of available device types you can get using request ​[[../​apiref/​core/​get_hw_types|get_hw_types]]). To do this, we'll need the request ​[[../​apiref/​core/​create_unit|core/​create_unit]]:​
-Создадим объект типа ​Wialon IPS (список доступных типов оборудования можно получить запрсом ​[[../​apiref/​core/​get_hw_types|get_hw_types]]) ​с именем "​ips_unit"​ при помощи запроса ​[[../​apiref/​core/​create_unit|core/​create_unit]]:​+
 <​code>​ <​code>​
 <​your_wialon_pro_address>/​ajax.html?​svc=core/​create_unit&​ <​your_wialon_pro_address>/​ajax.html?​svc=core/​create_unit&​
Line 16: Line 15:
 </​code>​ </​code>​
  
-Результат выполнения:+Response:
 <code javascript>​ <code javascript>​
 { {
Line 53: Line 52:
 </​code>​ </​code>​
  
-Чтобы проверитьчто объект действительно создался,​ выполним ​[[../​apiref/​core/​search_items|поиск]] объектов,​ название которых строго равно //​ips_unit//​:+To check that the unit has indeed been createdperform a [[../​apiref/​core/​search_items|search]] by name:
 <​code>​ <​code>​
 <​your_wialon_pro_address>/​ajax.html?​svc=core/​search_items&​ <​your_wialon_pro_address>/​ajax.html?​svc=core/​search_items&​
Line 70: Line 69:
 </​code>​ </​code>​
  
-Результат выполнения:+Response:
 <code javascript>​ <code javascript>​
 { {
Line 90: Line 89:
 } }
 </​code>​ </​code>​
-Поиск вернул результатследовательно объект был создан. +The response is not emptyso we can conclude that the unit has been created successfully.
- +
-===== Редактирование объекта =====+
  
-В качестве примера редактирования изменим у созданного объекта значение счетчика пробега.+===== Editing unit ===== 
 +Now we are going to edit the value of the mileage counter of the new unitTo watch the changes, let's first make the request about the initial value of this counter. To see counter values in the resulting JSON, use the flag 0x00000800:
  
-Для того чтобы отследить изменение,​ выполним поисковый запрос и проверим начальное состояние счетчика. Для того чтобы результирующий JSON содержал значение счетчика,​ в запросе нужно установить флаг 0x00000800: 
 <​code>​ <​code>​
 <​your_wialon_pro_address>/​ajax.html?​svc=core/​search_item&​ <​your_wialon_pro_address>/​ajax.html?​svc=core/​search_item&​
Line 104: Line 101:
  }&​sid=<​your_sid>​  }&​sid=<​your_sid>​
 </​code>​ </​code>​
-Результат выполнения:+Response:
 <code javascript>​ <code javascript>​
 { {
Line 120: Line 117:
 } }
 </​code>​ </​code>​
-Значение счетчика отображено в поле **"cnm"** и перед редактированием его значение равно ​0.+Mileage counter value is placed in the field //cnm// and it is 0.
  
-Изменим значение счетчика пробега при помощи запроса ​[[../​apiref/​unit/​update_mileage_counter|unit/​update_mileage_counter]]:​+To change the value of the counter, use the request ​[[../​apiref/​unit/​update_mileage_counter|unit/​update_mileage_counter]]:​
 <​code>​ <​code>​
 <​your_wialon_pro_address>/​ajax.html?​svc=unit/​update_mileage_counter&​ <​your_wialon_pro_address>/​ajax.html?​svc=unit/​update_mileage_counter&​
Line 130: Line 127:
  }&​sid=<​your_sid>​  }&​sid=<​your_sid>​
 </​code>​ </​code>​
-Результат выполнения:+Response:
 <code javascript>​ <code javascript>​
 { {
Line 137: Line 134:
 </​code>​ </​code>​
  
-Проверим выполнение редактирования поиском объекта. ​+Now let's check the result of editing using a search request: ​
 <​code>​ <​code>​
 <​your_wialon_pro_address>/​ajax.html?​svc=core/​search_item&​ <​your_wialon_pro_address>/​ajax.html?​svc=core/​search_item&​
Line 145: Line 142:
  }&​sid=<​your_sid>​  }&​sid=<​your_sid>​
 </​code>​ </​code>​
-Результат выполнения:+Response:
 <code javascript>​ <code javascript>​
 { {
Line 161: Line 158:
 } }
 </​code>​ </​code>​
-Теперь значение поля **"cnm"** равно ​456, следовательно редактирование прошло успешно.+We see that the value in //cnm// field has changed and it is 456 nowso the editing operation has been successful.
  
-===== Удаление объекта ​===== +===== Deleting unit ===== 
-Удалить объект можно запросом ​[[../​apiref/​item/​delete_item|core/​delete_item]]:​+You can delete an item using the request ​[[../​apiref/​item/​delete_item|core/​delete_item]]:​
 <​code>​ <​code>​
 <​your_wialon_pro_address>/​ajax.html?​svc=item/​delete_item&​ <​your_wialon_pro_address>/​ajax.html?​svc=item/​delete_item&​
Line 171: Line 168:
  }&​sid=<​your_sid>​  }&​sid=<​your_sid>​
 </​code>​ </​code>​
-Результат выполнения:+Response:
 <code javascript>​ <code javascript>​
 { {
Line 178: Line 175:
 </​code>​ </​code>​
  
-Проверить удаление можно выполнив поисковый запрос:+Make a search by ID to make sure that that the operation has been successful:
 <​code>​ <​code>​
 <​your_wialon_pro_address>/​ajax.html?​svc=core/​search_item&​ <​your_wialon_pro_address>/​ajax.html?​svc=core/​search_item&​
Line 186: Line 183:
  }&​sid=<​your_sid>​  }&​sid=<​your_sid>​
 </​code>​ </​code>​
-Результат выполнения:+Response:
 <code javascript>​ <code javascript>​
 { {
Follow us on Facebook Gurtam Wialon Twitter Gurtam Wialon info@gurtam.com   |   Copyright © 2002-2024 Gurtam