Example #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack)
     {
         SessionInfo info = new SessionInfo();
         if (!info.getSessionData(IsPostBack, out address, out user, out binding, out hostNameIdentifier, out configName, out hoster, out version, out platform, out hostedID))
             home(false);
         hostNameIdentifier = (string)ViewState["name"];
         configName = (string)ViewState["configname"];
         version = (string)ViewState["version"];
         platform = (string)ViewState["platform"];
         hoster = (string)ViewState["hoster"];
     }
     else
     {
         Input.getHostData(IsPostBack, ViewState, out userid, out address, out user, out binding, out hostNameIdentifier, out configName, out version, out platform, out hoster, false);
         ViewState["name"] = hostNameIdentifier;
         ViewState["configname"] = configName;
         ViewState["version"] = version;
         ViewState["platform"] = platform;
         ViewState["hoster"] = hoster;
     }
     LabelReq.Text = "Measured Page Requests";
     LabelReqDay.Text = "Measured Page Requests Per Day";
     UTC.Text = DateTime.Now.ToUniversalTime().ToString("f") + " (UTC)";
     NodeRepeater.ItemDataBound += new RepeaterItemEventHandler(NodeRepeater_ItemDataBound);
     List<ServiceNode> myNodeMap = null;
     traversePath = DynamicTraversePath.getTraversePath(hostNameIdentifier, configName, ref configProxy, address, binding, user);
     if (traversePath != null && traversePath.Count > 0)
     {
         if (traversePath[traversePath.Count - 1].MyNode.Status == ConfigSettings.MESSAGE_OFFLINE)
         {
             myNodeMap = new List<ServiceNode>();
             myNodeMap.Add(traversePath[traversePath.Count - 1].MyNode);
             if (traversePath[traversePath.Count - 1].PeerNodes != null)
                 myNodeMap.AddRange(traversePath[traversePath.Count - 1].PeerNodes);
         }
     }
     VirtualHost myVhost=null;
     if (myNodeMap == null)
     {
         myVhost = configProxy.getServiceNodeMap(hostNameIdentifier, configName, traversePath, user);
         if (myVhost == null)
             return;
         myNodeMap = myVhost.ServiceNodes;
     }
     VNODETotalReqs.Text = " (" + myVhost.TotalRequests.ToString() + ")";
     VNODETotalReqsPerDay.Text = " (" + myVhost.RequestsPerDay.ToString() + ")";
     TopNode.PostBackUrl = ConfigSettings.PAGE_NODES;
     ServiceVersion.Text = version;
     ServicePlatform.Text = platform;
     ServiceHoster.Text = hoster;
     TopNodeName.Text = hostNameIdentifier;
     NodeRepeater.DataSource = myNodeMap;
     NodeRepeater.DataBind();
     ReturnLabel.Text = "<a class=\"Return\" href=\"" + ConfigSettings.PAGE_NODES + "\">Return to Home Page</a>";
     GetImageButton.runtimePoweredBy(platform, RuntimePlatform);
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     Page.Form.DefaultFocus = ViewTypeHosts.ClientID;
     SessionInfo info = new SessionInfo();
     info.getSessionData(IsPostBack,out address, out user, out binding, out hostNameIdentifier, out configName, out hoster, out version, out platform, out hostedID);
     if (!(Request["version"] == "drilldown"))
         Input.getHostData(IsPostBack, ViewState, out userid, out address, out user, out binding, out hostNameIdentifier, out configName, out version, out platform, out hoster, false);
     else
     {
         hostNameIdentifier = Request["name"];
         configName = Request["cfgSvc"];
     }
     MSMQ.Visible = false;
     ConnectionRepeater.ItemDataBound += new RepeaterItemEventHandler(ConnectionRepeater_ItemDataBound);
     viewTheType = (string)Request["viewType"];
     if (viewTheType == null || viewTheType == "")
         viewTheType = ConfigUtility.HOST_TYPE_CONNECTED_SERVICE.ToString();
     viewType = Convert.ToInt32(viewTheType);
     switch (viewType)
     {
         case ConfigUtility.HOST_TYPE_CONNECTED_SERVICE:
             {
                 ViewTypeHosts.CssClass = "LoginButton";
                 ViewTypeClients.CssClass = "LoginButtonNonSelected";
                 AddConnection.Enabled = true;
                 break;
             }
         case ConfigUtility.HOST_TYPE_CONNECTED_CLIENT_CONFIG:
             {
                 ViewTypeClients.CssClass = "LoginButton";
                 ViewTypeHosts.CssClass = "LoginButtonNonSelected";
                 AddConnection.Enabled = false;
                 break;
             }
     }
     getData();
     postback = "?name=" + hostNameIdentifier + "&cfgSvc=" + configName + "&version=" + version + "&platform=" + platform + "&hoster=" + hoster;
     ConnectionRepeater.DataBind();
     TopNode.PostBackUrl = ConfigSettings.PAGE_NODES;
     ServiceVersion.Text = version;
     ServicePlatform.Text = platform;
     ServiceHoster.Text = hoster;
     TopNodeName.Text = hostNameIdentifier;
     ReturnLabel.Text = "<a class=\"Return\" href=\"" + ConfigSettings.PAGE_NODES + postback + "\">Return to Home Page</a>";
     ViewTypeHosts.PostBackUrl = ConfigSettings.PAGE_CONNECTIONS + postback + "&viewType=" + ConfigUtility.HOST_TYPE_CONNECTED_SERVICE.ToString();
     ViewTypeClients.PostBackUrl = ConfigSettings.PAGE_CONNECTIONS + postback + "&viewType=" + ConfigUtility.HOST_TYPE_CONNECTED_CLIENT_CONFIG.ToString();
     AddConnection.PostBackUrl = ConfigSettings.PAGE_ADD_CONNECTION + postback;
     GetImageButton.runtimePoweredBy(platform, RuntimePlatform);
 }
Example #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     string hostedID = null;
     Page.Form.DefaultFocus = SoaMapButton.ClientID;
     Input.getHostData(IsPostBack, ViewState, out userid, out address, out user, out binding,out hostNameIdentifier, out configName, out theVersion, out thePlatform, out theHoster, true);
     if (IsPostBack)
     {
         SessionInfo info = new SessionInfo();
         info.getSessionData(false, out address, out user, out binding, out hostNameIdentifier, out configName, out theHoster, out theVersion, out thePlatform, out hostedID);
     }
     InProcessRepeater.ItemDataBound += new RepeaterItemEventHandler(InProcessRepeater_ItemDataBound);
     CompositeServicesRepeater.ItemDataBound += new RepeaterItemEventHandler(CompositeServicesRepeater_ItemDataBound);
     List<ServiceConfigurationData> blankData = new List<ServiceConfigurationData>();
     ServiceConfigurationData blankItem = new ServiceConfigurationData();
     blankItem.ServiceHost = "-";
     blankItem.ServiceContract = "-";
     blankItem.Status = "-";
     blankData.Add(blankItem);
     int level;
     string levelString = (string)Request["level"];
     if (levelString == null)
         level = ConfigUtility.CONFIG_LEVEL_BASIC;
     else
     {
         level = Convert.ToInt32(levelString);
     }
     TopNode.PostBackUrl = ConfigSettings.PAGE_NODES;
     string action = Request["action"];
     if (action != "navigate")
     {
         traversePath = DynamicTraversePath.getTraversePath(hostNameIdentifier, configName, ref configProxy, address, binding, user);
         compositeServiceData = configProxy.getServiceConfiguration(hostNameIdentifier, configName, level, true, traversePath, user);
         if (compositeServiceData != null)
         {
             if (compositeServiceData.Count > 0 && compositeServiceData[0] != null)
             {
                 string postback = "?name=" + compositeServiceData[0].ServiceHost + "&cfgSvc=" + compositeServiceData[0].ConfigServiceImplementationClassName + "&version=" + compositeServiceData[0].ServiceVersion + "&platform=" + compositeServiceData[0].RunTimePlatform + "&hoster=" + compositeServiceData[0].ServiceHoster;
                 Hosted.PostBackUrl = ConfigSettings.PAGE_VHOSTS + postback;
                 Connected.PostBackUrl = ConfigSettings.PAGE_CONNECTED_SERVICES + postback;
                 Connections.PostBackUrl = ConfigSettings.PAGE_CONNECTIONS + postback;
                 Logs.PostBackUrl = ConfigSettings.PAGE_AUDIT + postback;
                 Users.PostBackUrl = ConfigSettings.PAGE_USERS + postback;
                 InProcessRepeater.DataSource = compositeServiceData;
                 InProcessRepeater.DataBind();
                 TopNodeName.Text = hostNameIdentifier;
                 ServiceVersion.Text = theVersion;
                 ServiceHoster.Text = "" + theHoster;
                 ServicePlatform.Text = "" + thePlatform;
                 GetImageButton.runtimePoweredBy(thePlatform, RuntimePlatform);
                 if (compositeServiceData[0].ConnectedServiceConfigurationData != null && compositeServiceData[0].ConnectedServiceConfigurationData.Count > 0)
                 {
                     CompositeServicesRepeater.DataSource = compositeServiceData[0].ConnectedServiceConfigurationData;
                 }
                 else
                 {
                     CompositeServicesRepeater.DataSource = blankData;
                 }
                 CompositeServicesRepeater.DataBind();
             }
             else
                 Response.Redirect(ConfigSettings.PAGE_NODES,true);
         }
         else
         {
             Response.Redirect(ConfigSettings.PAGE_LOGOUT,true);
         }
     }
 }
        protected void AutoGenButton_Click(object sender, EventArgs e)
        {
            if (TextBoxConfigLoginAddress.Text == null || TextBoxConfigLoginAddress.Text == "")
            {
                LabelGetServices.ForeColor = System.Drawing.Color.Maroon;
                LabelGetServices.Text = "Please enter an address to the remote Configuration Service.";
                return;
            }
            try
            {
                Uri testConfigUri = new Uri(TextBoxConfigLoginAddress.Text);
            }
            catch (Exception)
            {
                LabelGetServices.ForeColor = System.Drawing.Color.Maroon;
                LabelGetServices.Text = "Please enter a valid address.  The address you entered is not a valid URI; no connection was attempted.";
                return;
            }
            string addressSes = null;
            string IDSes = null;
            ServiceUsers csUserSes = null;
            string confignameSes = null;
            string hosterSes = null;
            string versionSes = null;
            string platformSes = null;
            string clientSession = null;
            string nameSes = null;
            SessionInfo info = new SessionInfo();
            info.getSessionData(false, out addressSes, out csUserSes, out clientSession, out nameSes, out confignameSes, out hosterSes, out versionSes, out platformSes, out IDSes);
            address = addressSes;
            string currentbinding = clientSession;
            user = csUserSes;
            if (address == null || user == null)
                Response.Redirect(FormsAuthentication.LoginUrl,true);
            traversePath = DynamicTraversePath.getTraversePath(hostNameIdentifier, configName, ref configProxy, address, currentbinding, user);
            DropDownListServiceName.Items.Clear();
            string addressConfig = TextBoxConfigLoginAddress.Text.Trim();
            ClientInformation theClient = clients.Find(delegate(ClientInformation ciExist) { return ciExist.ElementName.Equals(DropDownListConfigClient.SelectedValue); });
            BindingInformation binding = bindings.Find(delegate(BindingInformation bindingItem) { return bindingItem.BindingConfigurationName.Equals(theClient.BindingConfiguration); });
            string selectedBinding = theClient.ElementName;
            if (binding != null && binding.BindingType != null)
            {
                switch (binding.BindingType)
                {
                    case ConfigUtility.BASIC_HTTP_BINDING:
                        {
                            if (!addressConfig.ToLower().StartsWith("http"))
                            {

                                LabelGetServices.ForeColor = System.Drawing.Color.Maroon;
                                LabelGetServices.Text = "You have selected an <b>Http</b> binding: Please enter a valid http address.";
                                return;
                            }
                            break;
                        }
                    case ConfigUtility.WS_HTTP_BINDING:
                        {
                            goto case ConfigUtility.BASIC_HTTP_BINDING;
                        }

                    case ConfigUtility.WS_2007_HTTP_BINDING:
                        {
                            goto case ConfigUtility.BASIC_HTTP_BINDING;
                        }



                    case ConfigUtility.NET_TCP_BINDING:
                        {
                            if (!addressConfig.ToLower().StartsWith("net.tcp"))
                            {
                                LabelGetServices.ForeColor = System.Drawing.Color.Maroon;
                                LabelGetServices.Text = "You have selected a <b>Tcp</b> binding: Please enter a valid tcp address in form of net.tcp://";
                                return;
                            }
                            break;
                        }
                }
            }
            ServiceUsers configUser = new ServiceUsers();
            configUser = user;
            csusername= TextBoxConfigLoginUserId.Text.ToLower().Trim();
            cspassword = TextBoxConfigLoginPassword.Text.Trim();
            ServiceConfigurationClient newConfigProxy = null;
            try
            {
                newConfigProxy = new ServiceConfigurationClient(currentbinding, address, configUser);
                configServices = newConfigProxy.getMyConfigServiceDetails(hostNameIdentifier, configName, traversePath, addressConfig, selectedBinding,csusername,cspassword, configUser);
                if (configServices != null)
                {
                    if (configServices.Count == 0)
                    {
                        LabelGetServices.Text = "The remote host is currently not returning any Configuration Service Hosts to connect to.";
                        LabelGetServices.ForeColor = System.Drawing.Color.Maroon;
                        return;
                    }
                    LabelGetServices.Text = "<span style=\"font-size:1.2em;color:palegreen\">Connected!</span>";
                    ViewState["configServices"] = configServices;
                }
                else
                {
                    LabelGetServices.Text = "Service refused to supply information. Check userid/password and try again.";
                    LabelGetServices.ForeColor = System.Drawing.Color.Maroon;
                    return;
                }
                HostNameID.Text = configServices[0].HostNameIdentifier;
                TextBoxConfigLoginUserId.Text = configServices[0].InitialCSUserID;
                TextBoxConfigLoginPassword.Text = configServices[0].InitialCSPassword;
                TextBoxConfigLoginPassword.Attributes.Add("value", configServices[0].InitialCSPassword);
                string hsContractSelected = null;
                List<ConnectedServices> csList = compositeServiceData[0].ConnectedServices;
                for (int i = 0; i < configServices[0].PrimaryHostedServices.Count; i++)
                {
                    if (configServices[0].PrimaryHostedServices[i].ServiceType == ConfigUtility.HOST_TYPE_PRIMARY || configServices[0].PrimaryHostedServices[i].ServiceType == ConfigUtility.HOST_TYPE_GENERIC)
                    {
                        ConnectedServices csCheck = csList.Find(delegate(ConnectedServices csExist) { return csExist.ServiceFriendlyName.Equals(configServices[0].PrimaryHostedServices[i].FriendlyName); });
                        if (csCheck == null)
                        {
                            if (hsContractSelected == null)
                                hsContractSelected = configServices[0].PrimaryHostedServices[i].FriendlyName;
                            DropDownListServiceName.Items.Add(new ListItem(configServices[0].PrimaryHostedServices[i].FriendlyName, configServices[0].PrimaryHostedServices[i].FriendlyName));
                        }
                        else
                        {
                            UpdateMessage.Text = "There are services you already have established definitions for, and these have been removed from the available list!";
                            UpdateMessage.ForeColor = System.Drawing.ColorTranslator.FromHtml("#FFFF99");
                        }
                    }
                }
                if (DropDownListServiceName.Items.Count > 0)
                {
                    DropDownListServiceName.SelectedIndex = 0;
                    string serviceName = DropDownListServiceName.SelectedValue;
                    hsSelected = configServices[0].PrimaryHostedServices.Find(delegate(HostedServices hsExist) { return hsExist.FriendlyName.Equals(DropDownListServiceName.Items[0].Text); });
                    TextBoxOnlineMethod.Text = hsSelected.OnlineMethod;
                    TextBoxOnlineParms.Text = hsSelected.OnlineParms;
                    DropDownListServiceName.SelectedValue = hsContractSelected;
                    DropDownListServiceName.Text = hsContractSelected;
                    DropDownListServiceName.Enabled = true;
                    Add.Enabled = true;
                    LabelContract.Text = hsSelected.ServiceContract;
                    LabelServiceFriendlyName.Text = hsSelected.FriendlyName;
                    try
                    {
                        DropDownListPrimaryContract.SelectedValue = hsSelected.ServiceContract;
                    }
                    catch { }
                    LabelSvcBindingType.Text = hsSelected.BindingType;
                    LabelPort.Text = hsSelected.Port;
                    LabelUseHttps.Text = hsSelected.UseHttps.ToString();
                    LabelVPath.Text = hsSelected.VirtualPath;
                    SecurityMode.Text = hsSelected.SecurityMode;
                    DropDownListPrimaryClients.Items.Clear();
                    string thisHssecurityMode = hsSelected.SecurityMode;
                    string thisHsBindingType = hsSelected.BindingType;
                    for (int i = 0; i < clients.Count; i++)
                    {
                        if (DropDownListPrimaryContract.SelectedValue.Equals(clients[i].Contract))
                        {
                            BindingInformation theClientBinding = bindings.Find(delegate(BindingInformation biExist) { return biExist.BindingConfigurationName.Equals(clients[i].BindingConfiguration); });
                            if (theClientBinding != null)
                            {
                                string tsSecMode = null;
                                if (thisService == null)
                                    tsSecMode = "unknown";
                                else
                                    tsSecMode = thisService.SecurityMode;
                                if (theClientBinding.BindingType.Equals(thisHsBindingType) || thisHsBindingType.ToLower().Contains("custom"))
                                {
                                    if (theClientBinding.SecurityMode.Equals(tsSecMode) || tsSecMode.Equals("unknown"))
                                    {
                                        if (!clients[i].ElementName.ToLower().Contains("host") && !clients[i].ElementName.ToLower().Contains("client_configsvc") && !clients[i].ElementName.ToLower().Contains("client_nodesvc"))
                                        {
                                            DropDownListPrimaryClients.Items.Add(new ListItem(clients[i].ElementName, clients[i].ElementName));
                                            DropDownListPrimaryClients.SelectedValue = clients[i].ElementName;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    theClient = clients.Find(delegate(ClientInformation ciExist) { return ciExist.ElementName.Equals(DropDownListPrimaryClients.SelectedValue); });
                    if (theClient != null)
                    {
                        BindingInformation theSelectedBinding = bindings.Find(delegate(BindingInformation biExist) { return biExist.BindingConfigurationName.Equals(theClient.BindingConfiguration); });
                        if (theSelectedBinding != null)
                        {
                            LabelBindingTypePrimary.Text = theSelectedBinding.BindingType;
                        }
                        LabelIntroService.Text = "<div style=\"font-size:.9em;color:#FFFF99;padding-bottom:10px\">These are the available service endpoints by friendly names as assigned by the Service Hoster. Each has its own binding requirements " +
                            "(network scheme, security, encoding, etc.). Please select the desired service from this list. Client configurations and bindings can be generated by svcutil.exe, " + 
                            "named to Configuration Service standards, and inserted into this application's configuration file to appear in this page as selectable. You will also need to supply the service contract " +
                            "your client uses in your startup call per the StockTrader example and the documentation.<br/>";
                        Add.Enabled = true;
                    }
                    else
                    {
                        LabelIntroService.Text = "Please change the selected Primary Hosted Service, or the Client Contract.  The current combination yields no valid client configuration to connect with. The check was performed against binding type, and security mode. You may need to add and appropriate client definition to your config file.";
                        Add.Enabled = false;
                        LabelIntroService.ForeColor = System.Drawing.ColorTranslator.FromHtml("#FFFF99");
                    }
                }
                else
                {
                    DropDownListServiceName.Enabled = false;
                    Add.Enabled = false;
                    LabelIntroService.Text = "Either this host does not expose services via the Config Service (try as a Generic Service); or you already have established definitions for all available services this virtual host exposes.";
                    LabelIntroService.ForeColor = System.Drawing.Color.Maroon;
                }
                LabelIntroPrimary.Text = "Please Select the Primary Service";
            }
            catch (Exception eConfig)
            {
                LabelGetServices.ForeColor = System.Drawing.Color.Maroon;
                LabelGetServices.Text = "Cannot Connect!<br/><br/>Please make sure the address to the remote configuration service endpoint is correct and you have chosen the appropriate client configuration/binding.  For example" +
                    " if specifying https, you must choose a client configuration using https/transport security.<br/>" +
                    "Full connect exception is: <br/>" + ConfigUtility.reMapExceptionForDisplay(eConfig.ToString());
                if (eConfig.InnerException != null)
                    LabelGetServices.Text = LabelGetServices.Text + "<br/> Inner Exception is:<br/>" + eConfig.InnerException.ToString();
                return;
            }
            generateClicked = "true";
            ViewState["generateClicked"] = generateClicked;
            ConnectedPanel.Visible = true;
            panelConnectedService1.Visible = true;
            panelConnectedService2.Visible = false;
        }
        private void successPersisted(string supplmentmessage, ServiceUsers updateUser)
        {
            if (supplmentmessage == null)
                supplmentmessage = "<span style=\"color:PaleGreen \">The user was sucessfully " + actiontext + ".</span>";
            else
                supplmentmessage = "<span style=\"color:Maroon\">" + supplmentmessage + ".</span>";
            SessionInfo info = new SessionInfo();
            string hostnameSession = null;
            string confignameSession = null;
            info.getHostNameConfigName(out hostnameSession, out confignameSession);
            if (oldUser != null && oldUser.UserKey == user.UserKey && (hostnameSession.Equals(hostNameIdentifier) && confignameSession.Equals(configName)))
            {
                string addressSes = null;
                string IDSes = null;
                ServiceUsers csUserSes = null;
                string confignameSes = null;
                string hosterSes = null;
                string versionSes = null;
                string platformSes = null;
                string clientSession = null;
                string nameSes = null;
                info.getSessionData(false, out addressSes, out csUserSes, out clientSession, out nameSes, out confignameSes, out hosterSes, out versionSes, out platformSes, out IDSes);
                HttpCookie cookie = info.setSessionData(addressSes, updateUser, clientSession, nameSes, confignameSes, hosterSes, versionSes, platformSes,IDSes);
                Response.Cookies.Remove(cookie.Name);
                Response.Cookies.Add(cookie);
                user = updateUser;
            }
            userList = configProxy.getServiceUsers(hostNameIdentifier, configName, traversePath, user);
            if (userList == null)
                Response.Redirect(ConfigSettings.PAGE_NODES, true);
            if (action.Equals(ConfigUtility.ADD_USER))
                thisUser = userList.Find(delegate(ServiceUsers userExist) { return userExist.UserId.ToLower().Equals(updateUser.UserId.ToLower()) && userExist.LocalUser == updateUser.LocalUser && userExist.Password.Equals(updateUser.Password); });
            else
                if (action.Equals(ConfigUtility.UPDATE_USER))
                    thisUser = userList.Find(delegate(ServiceUsers userExist) { return userExist.UserKey == thisUser.UserKey; });
            UpdateMessage.Text = supplmentmessage;
            if (action == ConfigUtility.REMOVE_USER && !oldUser.LocalUser)
                UpdateMessage.Text = UpdateMessage.Text + "<br>Note that all Connected Service Definitions and corresponding active Connection Point instances associated with the Connected Service user have also been removed from the configuration database.";
            ViewState["thisUser"] = thisUser;
            ViewState["oldUser"] = thisUser;
            ViewState["identify"] = thisUser.UserKey.ToString();
            if (action.Equals(ConfigUtility.ADD_USER))
            {
                Add.Enabled = false;
                Update.Enabled = true;
                Delete.Enabled = true;
            }
            if (action.Equals(ConfigUtility.REMOVE_USER))
            {
                Add.Enabled = false;
                Update.Enabled = false;
                Delete.Enabled = false;
            }
            ViewState["userList"] = userList;
            action = ConfigUtility.UPDATE_USER;
            ViewState["action"] = action;
            ViewState["CompositeServiceData"] = null;

        }