/// <summary> /// Edit constructor. /// </summary> /// <param name="virtualServer">Virtual server.</param> /// <param name="filter">Filter to update.</param> public wfrm_Filters_Filter(VirtualServer virtualServer,Filter filter) { m_pVirtualServer = virtualServer; m_pFilter = filter; InitUI(); m_pEnabled.Checked = filter.Enabled; m_pDescription.Text = filter.Description; m_pAssembly.Text = filter.AssemblyName; m_pClass.Text = filter.Class; }
/// <summary> /// Removes specified filter from virtual server. /// </summary> /// <param name="filter">Filter to remove.</param> public void Remove(Filter filter) { /* DeleteFilter <virtualServerID> "<filterID>" Responses: +OK -ERR <errorText> */ string id = Guid.NewGuid().ToString(); // Call TCP DeleteFilter m_pVirtualServer.Server.Socket.WriteLine("DeleteFilter " + m_pVirtualServer.VirtualServerID + " " + TextUtils.QuoteString(filter.ID)); string response = m_pVirtualServer.Server.Socket.ReadLine(); if(!response.ToUpper().StartsWith("+OK")){ throw new Exception(response); } m_pFilters.Remove(filter); }
/// <summary> /// Adds new filter to virtual server. /// </summary> /// <param name="enabled">Specifies if filter is enabled.</param> /// <param name="description">Filter description.</param> /// <param name="assembly">Filter assembly.</param> /// <param name="filterClass">Filter class.</param> /// <returns></returns> public Filter Add(bool enabled,string description,string assembly,string filterClass) { /* AddFilter <virtualServerID> "<filterID>" <cost> "<description>" "<assembly>" "<filterClass>" <enabled> Responses: +OK -ERR <errorText> */ string id = Guid.NewGuid().ToString(); long cost = DateTime.Now.Ticks; // Call TCP AddFilter m_pVirtualServer.Server.Socket.WriteLine("AddFilter " + m_pVirtualServer.VirtualServerID + " " + TextUtils.QuoteString(id) + " " + cost + " " + TextUtils.QuoteString(description) + " " + TextUtils.QuoteString(assembly) + " " + TextUtils.QuoteString(filterClass) + " " + enabled ); string response = m_pVirtualServer.Server.Socket.ReadLine(); if(!response.ToUpper().StartsWith("+OK")){ throw new Exception(response); } Filter filter = new Filter(m_pVirtualServer,this,id,cost,enabled,description,assembly,filterClass); m_pFilters.Add(filter); return filter; }
private void m_pOk_Click(object sender, EventArgs e) { if(m_pFilter == null){ m_pFilter = m_pVirtualServer.Filters.Add( m_pEnabled.Checked, m_pDescription.Text, m_pAssembly.Text, m_pClass.Text ); } else{ m_pFilter.Enabled = m_pEnabled.Checked; m_pFilter.Description = m_pDescription.Text; m_pFilter.AssemblyName = m_pAssembly.Text; m_pFilter.Class = m_pClass.Text; m_pFilter.Commit(); } this.DialogResult = DialogResult.OK; }