private void UpdateView(EIBUsersConf conf) { this.lvUsers.Items.Clear(); if (conf == null) { this.btnSaveUsers.Enabled = false; this.btnAddUser.Enabled = false; this.btnDeleteUser.Enabled = false; this.cbReadAllowed.Checked = false; this.cbReadAllowed.Enabled = false; this.cbWriteAllowed.Checked = false; this.cbWriteAllowed.Enabled = false; this.lblSrcMaskVal.Text = "0x0"; this.lblDstMaskVal.Text = "0x0"; return; } foreach (EIBUserConf user in conf.List) { string[] texts = new string[3]; texts[0] = user.Name; texts[1] = user.Ip_address; texts[2] = user.Connected.ToString(); ListViewItem item = new ListViewItem(texts); this.lvUsers.Items.Add(item); item.Tag = user; } this.btnSaveUsers.Enabled = true; this.btnAddUser.Enabled = true; }
private void btnSaveUsers_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; EIBUsersConf conf = new EIBUsersConf(); foreach (ListViewItem item in this.lvUsers.Items) { EIBUserConf user = item.Tag as EIBUserConf; conf.List.Add(user); } bool res = ConsoleAPI.SetUsersList(conf); Cursor.Current = Cursors.Default; }
public static bool SetUsersList(EIBUsersConf users) { //write object into xml form MemoryStream ms = new MemoryStream(); XmlSerializer ser = new XmlSerializer(typeof(EIBUsersConf)); ser.Serialize(ms, users); //get the xml string string content = ASCIIEncoding.ASCII.GetString(ms.ToArray(),0,ms.ToArray().Length); StreamReader sr = GetEIBResponse(ConsoleDefinitions.EIBServerUsersConf.EIB_SERVER_SET_USERS_CONF_CMD, content); if (sr != null && sr.ReadToEnd().Length == 0) { return true; } return false; }