Shard samples
Aspectos básicos
Sección titulada «Aspectos básicos»Ejemplo de código sugerido
Sección titulada «Ejemplo de código sugerido»Primero debe crear el objeto webservice:
OKMWebservices ws = OKMWebservicesFactory.newInstance(host);A continuación, debe iniciar sesión mediante el método “login”. Puede acceder al método “login” desde el objeto webservice “ws”, tal y como se muestra a continuación:
ws.login(user, password);Llegados a este punto puede usar todos los métodos de Shard desde la clase “shard”, tal y como se muestra a continuación:
ws.shard.getShards()Métodos
Sección titulada «Métodos»getShards
Sección titulada «getShards»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getShards() | List |
Devuelve una lista con todos los shards. |
Ejemplo:
using System; using System.Collections.Generic;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{ public class Program { static void Main(string[] args) { String host = "http://localhost:8080/openkm"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try { ws.login(user, password); foreach(bean.Shard shard in ws.shard.getShards()) { Console.WriteLine(shard.ToString()); } } catch (Exception e) { System.Console.WriteLine(e.ToString());
} } }}setCurrentShard
Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| setCurrentShard(long shardId) | void | Cambia el shard actual. |
Ejemplo:
using System; using System.Collections.Generic;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{ public class Program { static void Main(string[] args) { String host = "http://localhost:8080/openkm"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try { ws.login(user, password); long shardId = 1; ws.shard.setCurrentShard(shardId); } catch (Exception e) { System.Console.WriteLine(e.ToString());
} } }}changeShard
Sección titulada «changeShard»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| changeShard(String uuid, long shardId) | void | Cambia el shardId del UUID. |
Ejemplo:
using System; using System.Collections.Generic;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{ public class Program { static void Main(string[] args) { String host = "http://localhost:8080/openkm"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try { ws.login(user, password); long shardId = 1; ws.shard.changeShard("e2391b01-ce10-42c7-94a9-b0d6b394048e", shardId); } catch (Exception e) { System.Console.WriteLine(e.ToString());
} } }}