Ejemplo n.º 1
0
        protected void Add_Click(object sender, EventArgs e)
        {
            string message = null;
            int success = ConfigUtility.CLUSTER_UPDATE_FAIL_PERSISTED;
            HostListenEndPointInstance newConnection = new HostListenEndPointInstance();
            string serviceFriendlyName = RadioButtonListHosts.SelectedItem.Text;
            ConnectedServices thisCS = connections.ConnectedServices.Find(delegate(ConnectedServices csExist) { return csExist.ServiceFriendlyName == serviceFriendlyName; });
            Uri testuri = null;
            if (thisCS.ServiceType == ConfigUtility.HOST_TYPE_GENERIC_CONNECTED_SERVICE)
            {

                try
                {
                    testuri = new Uri(ServiceHostAddress.Text);
                }
                catch
                {
                    testuri = null;
                    Message.Text = "<br/><span style=\"color:Maroon;font-size:13px;font-weight:normal;font-family:Verdana;\">The connection point cannot be added becuase you have specified an invalid URI (endpoint address).  For Generic services, make sure you properly specify the full endpoint to the service; for Primary services, you just need to supply a server name/IP address, since the URI will be built from information already stored in the configuration database.</span>";
                }
            }
            else
                testuri = new Uri("http://localhost");
            if (testuri != null)
            {
                newConnection.ConnectedServiceID = thisCS.ConnectedServiceID;
                newConnection.ConnectedConfigServiceID = thisCS.ConnectedConfigServiceID;
                newConnection.VHostID = thisCS.VHostID;
                newConnection.RemoteAddress = ServiceHostAddress.Text.Trim().ToLower();
                if (thisCS.ServiceType == ConfigUtility.HOST_TYPE_CONNECTED_SERVICE)
                {
                    string[] splitString = newConnection.RemoteAddress.Split(new char[] { '/' });
                    if (splitString.Length > 1)
                    {
                        newConnection.RemoteAddress = splitString[2];
                    }
                    splitString = newConnection.RemoteAddress.Split(new char[] { ':' });
                    newConnection.RemoteAddress = splitString[0].ToLower();
                    ServiceHostAddress.Text = newConnection.RemoteAddress.ToLower();
                }
                newConnection.HostNameIdentifier = connections.ConnectedServices[RadioButtonListHosts.SelectedIndex].HostNameIdentifier;
                newConnection.Configuration = connections.ConnectedServices[RadioButtonListHosts.SelectedIndex].ClientConfiguration;
                newConnection.ServiceType = connections.ConnectedServices[RadioButtonListHosts.SelectedIndex].ServiceType;
                newConnection.ServiceImplementationClassName = connections.ConnectedServices[RadioButtonListHosts.SelectedIndex].ServiceImplementationClassName;
                newConnection.ServiceContract = connections.ConnectedServices[RadioButtonListHosts.SelectedIndex].ServiceContract;
                newConnection.ServiceFriendlyName = connections.ConnectedServices[RadioButtonListHosts.SelectedIndex].ServiceFriendlyName;
                newConnection.HostedServiceID = connections.ConnectedServices[RadioButtonListHosts.SelectedIndex].HostedServiceID;
                try
                {
                    traversePath = DynamicTraversePath.getTraversePath(hostNameIdentifier, configName, ref configProxy, address, binding, user);
                    List<ServiceConfigurationData> compositeConfigData = configProxy.getServiceConfiguration(hostNameIdentifier, configName, ConfigUtility.CONFIG_LEVEL_BASIC, false, traversePath, user);
                    ConnectedConfigServices thisConfig = compositeConfigData[0].ConnectedConfigServices.Find(delegate(ConnectedConfigServices ccsExist) { return ccsExist.ConnectedConfigServiceID == newConnection.ConnectedConfigServiceID; });
                    if (thisConfig == null)
                        throw new Exception("Cannot find Configuration Service for this Connected Service Defininition in this Client's configuration database.  This entry is created when creating the Connected Service definition; and should never be manually deleted.");
                    newConnection.ConfigServiceImplementationClassName = thisConfig.ServiceImplementationClassName;
                    success = configProxy.receiveConnectionPoint(hostNameIdentifier, configName, newConnection, newConnection, true, null, ConfigUtility.ADD_CONNECTION, traversePath, user);
                }
                catch (Exception ee)
                {
                    message = "<br/><span style=\"color:Maroon;font-size:13px;font-weight:normal;font-family:Verdana;\">receiveConnectionPoint exception. Exception is: " + ee.ToString();
                    Message.Text = Message.Text + "<br/>The Exception is: " + message + "</span>";
                }
                if (success == ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS)
                {
                    Message.Text = "<br/><span style=\"color:#1B9427;font-size:13px;font-weight:normal;font-family:Verdana;\">The connection point was sucessfully added.</span>";
                }
                else
                {
                    switch (success)
                    {
                        case ConfigUtility.CLUSTER_UPDATE_FAIL_PERSISTED:
                            {
                                message = ConfigSettings.EXCEPTION_MESSAGE_FAIL_PERSISTED + message + ". Make sure the remote service is running at the server/ip address specified.";
                                break;
                            }

                        case ConfigUtility.CLUSTER_UPDATE_FAIL_VALIDATION:
                            {
                                message = ConfigSettings.EXCEPTION_MESSAGE_FAIL_VALIDATION + message;
                                break;
                            }

                        case ConfigUtility.CLUSTER_UPDATE_FAIL_AUTHENTICATION:
                            {
                                message = ConfigSettings.EXCEPTION_MESSAGE_FAIL_AUTHORIZATION + message;
                                break;
                            }

                        case ConfigUtility.CLUSTER_UPDATE_FAIL_REMOTE:
                            {
                                message = ConfigSettings.EXCEPTION_MESSAGE_FAIL_REMOTE_UPDATE;
                                break;
                            }

                        default:
                            {
                                message = ConfigSettings.EXCEPTION_MESSAGE_FAIL_REMOTE_PEER + success.ToString();
                                break;
                            }
                    }
                    Message.Text = "<br/><span style=\"color:Maroon;font-size:13px;font-weight:normal;font-family:Verdana;\">" + message + "</span>";
                }
            }
        }
        protected void Purge_Click(object sender, EventArgs e)
        {
            string actiontext = "";
            actiontext = "purged";
            Purge.Enabled = false;
            int success = ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS;
            string eMessage = null;
            HostListenEndPointInstance connPurge = new HostListenEndPointInstance();
            connPurge.HostNameIdentifier = purgeHostName;
            connPurge.ConfigServiceImplementationClassName = purgeConfigName;
            if (client != "true")
                connPurge.ServiceType = ConfigUtility.HOST_TYPE_CONNECTED_SERVICE;
            else
                connPurge.ServiceType = ConfigUtility.HOST_TYPE_CONNECTED_CLIENT_CONFIG;
            try
            {
                traversePath = DynamicTraversePath.getTraversePath(hostNameIdentifier, configName, ref configProxy, address, binding, user);
                success = configProxy.receiveConnectionPoint(hostNameIdentifier, configName, connPurge, connPurge, true, null, action, traversePath, user);
            }
            catch (Exception ee)
            {
                try
                {
                    EventLog EventLog1 = new EventLog("Application");
                    EventLog1.Source = ConfigSettings.EVENT_LOG;
                    eMessage = "<br/>receiveConnectionPoint exception from remote service.<br/>Exception is: " + ee.ToString();
                    EventLog1.WriteEntry(eMessage, EventLogEntryType.Error);
                }
                catch
                {
                }
            }
            if (success == ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS)
            {
                Message.Text = "<br/><span style=\"color:PaleGreen \">The connection points were sucessfully " + actiontext + ".</span>";
            }
            else
            {
                string message = null;
                switch (success)
                {
                    case ConfigUtility.CLUSTER_UPDATE_FAIL_PERSISTED:
                        {
                            message = ConfigSettings.EXCEPTION_MESSAGE_FAIL_PERSISTED;
                            break;
                        }

                    case ConfigUtility.CLUSTER_UPDATE_FAIL_VALIDATION:
                        {
                            message = ConfigSettings.EXCEPTION_MESSAGE_FAIL_VALIDATION;
                            break;
                        }

                    case ConfigUtility.CLUSTER_UPDATE_FAIL_AUTHENTICATION:
                        {
                            message = ConfigSettings.EXCEPTION_MESSAGE_FAIL_AUTHORIZATION;
                            break;
                        }
                    case ConfigUtility.CLUSTER_UPDATE_FAIL_REMOTE:
                        {
                            message = ConfigSettings.EXCEPTION_MESSAGE_FAIL_REMOTE_UPDATE;
                            break;
                        }
                    default:
                        {
                            message = ConfigSettings.EXCEPTION_MESSAGE_FAIL_REMOTE_PEER + success.ToString();
                            break;
                        }
                }
                Message.Text = "<br/><span style=\"color:Maroon\">" + message + "</span>";
                Purge.Enabled = true;
            }
        }