public IrcNotification (DBNotification notification)
			: base (notification)
		{
			/* Connect to server and join channels */

			using (DB db = new DB ()) {
				using (IDbCommand cmd = db.CreateCommand ()) {
					cmd.CommandText = "SELECT * FROM IrcIdentity WHERE id = @id;";
					DB.CreateParameter (cmd, "id", notification.ircidentity_id.Value);
					using (IDataReader reader = cmd.ExecuteReader ()) {
						if (!reader.Read ())
							throw new ApplicationException (string.Format ("Could not find the irc identity {0}", notification.ircidentity_id.Value));
						identity = new DBIrcIdentity (reader);
					}
				}
			}
		}
		public WebServiceResponse EditIdentity (WebServiceLogin login, DBIrcIdentity irc_identity, DBEmailIdentity email_identity)
		{
			WebServiceResponse response = new WebServiceResponse ();

			using (DB db = new DB ()) {
				VerifyUserInRole (db, login, Roles.Administrator);

				if (irc_identity != null) {
					irc_identity.Save (db);
				}
				if (email_identity != null) {
					email_identity.Save (db);
				}
			}

			return response;
		}
	protected void lnkIrcAdd_Click (object sender, EventArgs e)
	{
		WebServiceResponse response;

		DBIrcIdentity irc_identity = new DBIrcIdentity ();
		irc_identity.name = txtIrcName.Text;
		irc_identity.nicks = txtIrcNicks.Text;
		irc_identity.servers = txtIrcServers.Text;
		irc_identity.join_channels = chkJoinChannels.Checked;
		irc_identity.use_ssl = chkUseSsl.Checked;
		irc_identity.channels = txtIrcChannels.Text;
		irc_identity.password = txtPassword.Text ?? string.Empty;

		try {
			if (string.IsNullOrEmpty (irc_identity.name))
				throw new ValidationException ("You need to specify the name of the irc identity");
			if (string.IsNullOrEmpty (irc_identity.nicks))
				throw new ValidationException ("You need to specify the nick names to use for the irc identity");
			if (string.IsNullOrEmpty (irc_identity.servers))
				throw new ValidationException ("You need to specify the servers to use for the irc identity");
			if (string.IsNullOrEmpty (irc_identity.channels))
				throw new ValidationException ("You need to specify the channels to join for the irc identity");
		} catch(ValidationException ex) {
			lblMessage.Text = ex.Message;
			return;
		}

		response = Utils.LocalWebService.EditIdentity (Master.WebServiceLogin, irc_identity, null);

		if (response.Exception != null) {
			lblMessage.Text = response.Exception.Message;
		} else {
			Response.Redirect ("Identities.aspx", false);
		}
	}
Esempio n. 4
0
	protected void lnkIrcAdd_Click (object sender, EventArgs e)
	{
		WebServiceResponse response;

		try {
			DBIrcIdentity irc_identity = new DBIrcIdentity ();
			irc_identity.name = txtIrcName.Text;
			irc_identity.nicks = txtIrcNicks.Text;
			irc_identity.servers = txtIrcServers.Text;
			irc_identity.channels = txtIrcChannels.Text;

			if (string.IsNullOrEmpty (irc_identity.name))
				throw new Exception ("You need to specify the name of the irc identity");
			if (string.IsNullOrEmpty (irc_identity.nicks))
				throw new Exception ("You need to specify the nick names to use for the irc identity");
			if (string.IsNullOrEmpty (irc_identity.servers))
				throw new Exception ("You need to specify the servers to use for the irc identity");
			if (string.IsNullOrEmpty (irc_identity.channels))
				throw new Exception ("You need to specify the channels to join for the irc identity");

			response = Master.WebService.EditIdentity (Master.WebServiceLogin, irc_identity, null);

			if (response.Exception != null) {
				lblMessage.Text = response.Exception.Message;
			} else {
				Response.Redirect ("Identities.aspx", false);
			}
		} catch (Exception ex) {
			lblMessage.Text = ex.Message;
		}
	}