示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var isCentralAdmin = SPContext.Current.Site.WebApplication.IsAdministrationWebApplication;

            if (!isCentralAdmin)
            {
                SPUtility.HandleAccessDenied(new InvalidOperationException());
            }

            var idStr = Request.QueryString["id"];

            if (idStr.IsNullOrEmpty())
            {
                // If there is only one proxy, redirect to it
                var proxies = MCServiceUtility.GetApplicationProxies().ToArray();
                if (proxies.Any())
                {
                    Response.Redirect(string.Format("manageappproxy.aspx?id={0}", proxies.First().Id), true);
                    return;
                }
                SPUtility.HandleAccessDenied(new InvalidOperationException());
                return;
            }

            var id    = new Guid(idStr);
            var proxy = MCServiceUtility.GetApplicationProxyById(id);

            InitPage(proxy);
        }
        protected void ValidateUniqueName(object sender, ServerValidateEventArgs e)
        {
            ArgumentValidator.IsNotNull(e, "e");

            var name = this.txtServiceApplicationProxyName.Text.Trim();

            var applicationProxyByName = MCServiceUtility.GetApplicationProxyByName(name);

            e.IsValid = (applicationProxyByName == null || applicationProxyByName.Id == ServiceAppProxyId);
        }
        private void UpdateServiceAppProxy()
        {
            Log.Info(LogCategory.ServiceApplication, "Update MyCorp Service Application Proxy");
            using (var operation = new SPLongOperation(this))
            {
                operation.Begin();
                try
                {
                    if (SPFarm.Local == null)
                    {
                        throw new NullReferenceException("SPFarm.Local");
                    }

                    var service = MCServiceUtility.GetLocalService(true);

                    // Retrieve the service applicaton
                    var serviceApplicationProxy = MCServiceUtility.GetApplicationProxyById(ServiceAppProxyId);
                    if (serviceApplicationProxy == null)
                    {
                        throw new SPException("Unable to find application proxy to edit");
                    }

                    var newName      = this.txtServiceApplicationProxyName.Text.Trim();
                    var newProxyName = newName.Replace(" Proxy", "") + " Proxy";

                    serviceApplicationProxy.Name                 = newProxyName;
                    serviceApplicationProxy.CloseTimeout         = TimeSpan.FromSeconds(Convert.ToDouble(txtCloseChannelTimeout.Text));
                    serviceApplicationProxy.OpenTimeout          = TimeSpan.FromSeconds(Convert.ToDouble(txtOpenChannelTimeout.Text));
                    serviceApplicationProxy.ReceiveTimeout       = TimeSpan.FromSeconds(Convert.ToDouble(txtReceiveChannelTimeout.Text));
                    serviceApplicationProxy.SendTimeout          = TimeSpan.FromSeconds(Convert.ToDouble(txtSendChannelTimeout.Text));
                    serviceApplicationProxy.MaximumExecutionTime = Convert.ToUInt32(txtMaximumExecutionTime.Text);
                    serviceApplicationProxy.Update();
                }
                catch (Exception ex)
                {
                    Log.ErrorFormat(LogCategory.ServiceApplication, "Updating service application proxy error: {0}", ex.Message);
                    Log.Exception(LogCategory.ServiceApplication, ex);
                    throw new SPException("Failed to update service applicaton proxy", ex);
                }
            }
        }