using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace Repository { /// ///

Displays the list of archive subscribers and allows archive subscribing/unsubscribing.
/// Calls RepoSubs.

/// Methods created or modified: ///

Copyright (c) 2002 Alexis Grandemange
/// Mail: alexis.grandemange@pagebox.net

///
This program is free software; you can redistribute it and/or
	/// modify it under the terms of the GNU Lesser General Public
	/// License as published by the Free Software Foundation; version
	/// 2.1 of the License.
	/// This library is distributed in the hope that it will be useful,
	/// but WITHOUT ANY WARRANTY; without even the implied warranty of
	/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	/// GNU Lesser General Public License for more details.
	/// A copy of the GNU Lesser General Public License lesser.txt should be
	/// included in the distribution.
///
public class asubscriber : System.Web.UI.Page { protected System.Web.UI.WebControls.HyperLink logo; protected System.Web.UI.WebControls.Label SubscriberLab; protected System.Web.UI.WebControls.TextBox URLTB; protected System.Web.UI.WebControls.Button BtnSub; protected System.Web.UI.WebControls.Button BtnUnsub; protected System.Web.UI.WebControls.Button BtnForce; protected System.Web.UI.WebControls.Button BtnRefresh; protected System.Web.UI.WebControls.Label LabStatus; protected System.Web.UI.WebControls.DataGrid subscriberDB; protected System.Web.UI.WebControls.HyperLink Support; public asubscriber() { Page.Init += new System.EventHandler(Page_Init); } /// /// Called on Page load event. /// Builds a array of subscribers and binds it to subscriberDB (DataGrid). /// private void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) bind(); } /// /// Builds a array of subscribers and binds it to subscriberDB (DataGrid). /// private void bind() { ArrayList al = new ArrayList(); IDictionaryEnumerator ide = Global.subRep.asubscribers.GetEnumerator(); while(ide.MoveNext()) { Subscriber sub = (Subscriber)ide.Value; string states = ""; if (sub.archs.Count > 0) { states = ""; IDictionaryEnumerator subIde = sub.archs.GetEnumerator(); while(subIde.MoveNext()) { string val = (string)subIde.Value; char[] sep = { ' ' }; string[] fields = val.Split(sep); val = fields[0] + ""); } states += "
"; for (int i = 1; i < fields.Length; ++i) val += (" " + fields[i]); states += ("
" + val + "
"; } al.Add(new SubscriberEntry((string)ide.Key, states)); } subscriberDB.DataSource = al; subscriberDB.DataBind(); } /// /// Called on subscribe event. Subscribe a PageBox. /// public void Form1_subscribe(object sender, EventArgs e) { if (URLTB.Text.Length > 0) { LabStatus.Text = Global.subRep.asubscribe(URLTB.Text); Log.write(User.Identity.Name, Request.ServerVariables["REMOTE_HOST"], "asubscribe(" + URLTB.Text + ") returned " + LabStatus.Text); bind(); } } /// /// Called on unsubscribe event. Unsubscribe a PageBox. /// public void Form1_unsubscribe(object sender, EventArgs e) { if (URLTB.Text.Length > 0) { string host = Request.ServerVariables["REMOTE_HOST"]; LabStatus.Text = Global.subRep.unasubscribe(User.Identity.Name, host, URLTB.Text, false); Log.write(User.Identity.Name, host, "unasubscribe(" + URLTB.Text + ") returned " + LabStatus.Text); bind(); } } /// /// Called on force event. Unsubscribe a PageBox. /// public void Form1_force(object sender, EventArgs e) { if (URLTB.Text.Length > 0) { string host = Request.ServerVariables["REMOTE_HOST"]; LabStatus.Text = Global.subRep.unasubscribe(User.Identity.Name, host, URLTB.Text, true); Log.write(User.Identity.Name, host, "aforce(" + URLTB.Text + ") returned " + LabStatus.Text); bind(); } } /// /// Called on refresh event. Refresh subscriber display. /// public void Form1_refresh(object sender, EventArgs e) { LabStatus.Text = ""; bind(); } private void Page_Init(object sender, EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); } #region Web Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.subscriberDB.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.SubscriberDB_handle); this.Load += new System.EventHandler(this.Page_Load); } #endregion /// /// Called on unsubscribe event. Unsubscribe a PageBox. /// private void SubscriberDB_handle(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { int sel = e.Item.ItemIndex; if (sel != -1) { string sub = (string)subscriberDB.DataKeys[sel]; Button b = (Button)e.CommandSource; string host = Request.ServerVariables["REMOTE_HOST"]; if (b.CommandName.Equals("unsubscribe")) { LabStatus.Text = Global.subRep.unasubscribe(User.Identity.Name, host, sub, false); Log.write(User.Identity.Name, host, "unasubscribe(" + URLTB.Text + ") returned " + LabStatus.Text); } else if (b.CommandName.Equals("force")) { LabStatus.Text = Global.subRep.unasubscribe(User.Identity.Name, host, sub, true); Log.write(User.Identity.Name, host, "aforce(" + URLTB.Text + ") returned " + LabStatus.Text); } bind(); } } } }