/// <summary> /// Writes a value in znode /// </summary> public void Write() { _path = GetPath(_input1); try { var stat = Zk.Exists(_path, false); if (stat == null) { Zk.Create(_path, Encoding.Default.GetBytes(_input2), Ids.OPEN_ACL_UNSAFE, CreateMode.Persistent); AppendLineShow(String.Format("Znode {0} does not exist! Creating one..", _input1)); } else { Zk.SetData(_path, Encoding.Default.GetBytes(_input2), -1); AppendLineShow(String.Format("{0} set value {1}", _input1, _input2)); } } catch (KeeperException e) { AppendLineShow(string.Format("Znode {0} isn't valid!", _input1)); } catch (InvalidOperationException e) { AppendLineShow(string.Format("Znode {0} isn't valid!", _input1)); } catch (ArgumentNullException e) { AppendLineShow("Insert in textboxes!"); } }
public Stat SetData(string path, byte[] data, int version) { Stat returnBytes = null; try { returnBytes = Zk.SetData(path, data, version); } catch (Exception e) { log.Error(String.Format("An error occured while trying to set data. Exception: {0}", e.ToString())); } return(returnBytes); }