// // Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. // The ASF licenses this file to You under the Apache License, Version 2.0 // (the "License"); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // using System; using System.Web.UI.WebControls; using Trade.ConfigClient; using Trade.ConfigServiceDataContract; using Trade.StockTraderWebApplicationSettings; namespace Trade.Web { public partial class ConfigurationAdd : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { this.ServiceType.SelectedValue = Request.QueryString["type"]; } } protected void AddButton_Click(object sender, EventArgs e) { Page.Validate(); if (Page.IsValid) { try { ConfigServiceClient configClient = new ConfigServiceClient(); ServiceLocation newOps = new ServiceLocation(); newOps.ServiceName = this.ServiceName.Text; newOps.ServiceURL = this.NewURL.Text; newOps.Sec = this.IsSec.Checked; //update the service location configClient.SetServiceLocation(newOps); Response.Redirect(Settings.PAGE_CONFIGURATION_ADVANCED); } catch { throw; } } } protected void ServiceNameValidator_ServerValidate(object source, ServerValidateEventArgs e) { string validEnding = ""; if (this.ServiceType.SelectedValue == "BS") validEnding = "_BS"; else validEnding = "_OPS"; validEnding += this.IsSec.Checked ? "SEC" : ""; // Validate Ending if (!this.ServiceName.Text.EndsWith(validEnding)) { this.ServiceNameValidator.ErrorMessage = "Must end in " + validEnding; e.IsValid = false; } } protected void CancelButton_Click(object sender, EventArgs e) { Response.Redirect(Settings.PAGE_CONFIGURATION_ADVANCED, true); } } }