예제 #1
0
        //Clear all the data
        public void Unload()
        {
            SelectedServiceUsers.Clear();
            ServiceUsers.Clear();

            isLoaded = false;
        }
예제 #2
0
        /// <summary>
        /// Return which service users are in a rota period
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public IEnumerable <ServiceUser> ServiceUsersInRotaPeriod(DateTime date)
        {
            DateTime rotaPeriodStart = DateCalculations.GetStartOfRotaPeriod(date);
            DateTime rotaPeriodEnd   = DateCalculations.GetEndOfRotaPeriod(date);

            return(ServiceUsers.Where(s => s.ServiceEnds > rotaPeriodStart && s.ServiceBegins < rotaPeriodEnd));
        }
예제 #3
0
        /// <summary>
        /// Create a new service users. Automatically addes to the manager.
        /// </summary>
        /// <returns></returns>
        public ServiceUser NewServiceUser()
        {
            ServiceUser user = new ServiceUser();

            ServiceUsers.Add(user);

            return(user);
        }
예제 #4
0
 public LogIn(ServiceUsers servUsers, ServiceBilete sb, ServiceClienti sc, ServiceSpectacole ss)
 {
     this.servClienti    = sc;
     this.servSpectacole = ss;
     this.servBilete     = sb;
     this.service        = servUsers;
     InitializeComponent();
 }
예제 #5
0
        /// <summary>
        /// Load the key workers
        /// this is called when the service users are loaded.
        /// </summary>
        public List <OldConstructable> LoadKeyWorkers()
        {
            List <OldConstructable> list = new List <OldConstructable>();

            //load the key workers in here
            string query = "SELECT idServiceUser, idWorker FROM tbl_KeyWorkers ORDER BY idServiceUser";

            DataTable dt = Common.Database.ExecuteDatabaseQuery(query, null, false);

            ServiceUser sUser  = null;
            Worker      worker = null;

            foreach (DataRow row in dt.Rows)
            {
                //first try and get service user
                if (sUser == null || sUser.id != Convert.ToInt32(row[0]))
                {
                    sUser = ServiceUsers.SingleOrDefault(s => s.id == Convert.ToInt32(row[0]));
                }

                if (sUser == null)
                {
                    continue;
                }

                //now try and get worker
                if (worker == null || worker.id != Convert.ToInt32(row[1]))
                {
                    worker = WorkerManager.Instance.Workers.SingleOrDefault(w => w.id == Convert.ToInt32(row[1]));
                }

                if (worker == null)
                {
                    continue;
                }

                //set the key people
                sUser.KeyWorkers.Add(worker);
                worker.KeyServiceUsers.Add(sUser);

                if (!list.Contains(worker))
                {
                    list.Add(worker);
                }

                if (!list.Contains(sUser))
                {
                    list.Add(sUser);
                }
            }

            return(list);
        }
 private ConfigurationKeyValues refreshBSL(out ConfigurationKeyValues thisOldbusinessServiceKey, string fieldName, ServiceUsers csUser)
 {
     Trade.StockTraderWebApplicationConfigurationImplementation.ConfigurationService configService = new ConfigurationService();
     List<TraverseNode> traversePath;
     ConfigurationKeyValues businessServiceKey = new ConfigurationKeyValues();
     businessServiceKey.ConfigurationKeyFieldName = fieldName;
     businessServiceKey.OriginatingConfigServiceName = StockTraderUtility.BUSINESS_SERVICES_CONFIG;
     traversePath = configService.getTraversePath(null, Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER, StockTraderUtility.BUSINESS_SERVICES_CONFIG, csUser);
     businessServiceKey = configService.getServiceConfigurationKey(Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER, StockTraderUtility.BUSINESS_SERVICES_CONFIG, businessServiceKey.ConfigurationKeyFieldName, traversePath, csUser);
     thisOldbusinessServiceKey = businessServiceKey;
     return businessServiceKey;
 }
예제 #7
0
        /// <summary>
        /// 加载服务用户
        /// </summary>
        private void LoadServiceUsers()
        {
            string filePath = HttpContext.Current.Server.MapPath("~/App_Data/ServiceUsers.xml");

            if (File.Exists(filePath))
            {
                XmlSerializer xs = new XmlSerializer(typeof(ServiceUsers));
                using (StreamReader sr = new StreamReader(filePath))
                {
                    mServiceUsers = xs.Deserialize(sr) as ServiceUsers;
                }
            }
        }
예제 #8
0
        static void Main()
        {
            Console.WriteLine("Configuration Settings for Festival {0}", GetConnectionStringByName("Festival"));
            IDictionary <string, string> props = new SortedList <string, string>();

            props.Add("ConnectionString", GetConnectionStringByName("Festival"));

            UsersRepo usersRepo = new UsersRepo(props);

            BileteRepo     bileteRepo     = new BileteRepo(props);
            ClientiRepo    ClientiRepo    = new ClientiRepo(props);
            SpectacoleRepo SpectacoleRepo = new SpectacoleRepo(props);

            ServiceUsers      servUsers   = new ServiceUsers(usersRepo);
            ServiceClienti    servClienti = new ServiceClienti(ClientiRepo);
            ServiceSpectacole servSpec    = new ServiceSpectacole(SpectacoleRepo);
            ServiceBilete     servBilete  = new ServiceBilete(bileteRepo, servClienti, servSpec);


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new LogIn(servUsers, servBilete, servClienti, servSpec));
        }
 /// <summary>
 /// Refreshes the Config of the OPS when running in-process with BSL.
 /// </summary>
 /// <param name="key"></param>
 /// <param name="configService"></param>
 /// <param name="csUser"></param>
 /// <returns>Int success code.</returns>
 public int refreshOPSConfig(ConfigurationKeyValues key, ConfigurationService configService, bool notifyNodes, ServiceUsers csUser)
 {
     int returnCode= ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS;
     string value = key.ConfigurationKeyValue;
     string targetHostID = null;
     if (ConfigUtility.onAzure)
         targetHostID = Trade.Utility.StockTraderUtility.ORDER_PROCESSOR_SERVICE_AZURE;
     else
         targetHostID = Trade.Utility.StockTraderUtility.ORDER_PROCESSOR_SERVICE_SELFHOST;
     List<TraverseNode> traversePath = configService.getTraversePath(null, targetHostID, StockTraderUtility.ORDER_PROCESSOR_SERVICE_CONFIG, csUser);
     key = configService.getServiceConfigurationKey(targetHostID, StockTraderUtility.ORDER_PROCESSOR_SERVICE_CONFIG, key.ConfigurationKeyFieldName, traversePath, csUser);
     if (key != null)
     {
         key.ConfigurationKeyValue = value;
         traversePath = configService.getTraversePath(null, targetHostID, StockTraderUtility.ORDER_PROCESSOR_SERVICE_CONFIG, csUser);
         if (traversePath!=null || Trade.BusinessServiceConfigurationSettings.Settings.ORDER_PROCESSING_MODE.Equals(StockTraderUtility.OPS_INPROCESS))
             returnCode = configService.receiveConfigurationKey(targetHostID, StockTraderUtility.ORDER_PROCESSOR_SERVICE_CONFIG, key, key, notifyNodes, ConfigUtility.UPDATE_KEY_VALUE, traversePath, csUser);
     }
     return returnCode;
 }
        /// <summary>
        /// Overrides the base method, performs app-specific logic on specific app-specific setting changes.  For BSL,
        /// there are few app specific routines we need to run when OPS-specific app settings are changed in the repository.
        /// MAKE SURE TO CALL THE BASE checkChangedSetting method FIRST!
        /// </summary>
        /// <param name="settingsInstance">Instance of this host's Settings class.</param>
        /// <param name="updatedConfigurationKey">The key that has been updated.</param>
        /// <param name="block">True to block on any multi-threaded calls, typically the node receiving via
        /// Config Service endpoint blocks, nodes receiving via Node Service do not, if any threads are spun up.</param>
        /// <returns>bool as success code.</returns>
        public override bool checkChangedSetting(object settingsInstance, ConfigurationKeyValues updatedConfigurationKey, bool block, ServiceUsers csUser)
        {
            bool success = false;
            success = base.checkChangedSetting(settingsInstance, updatedConfigurationKey, block, csUser); 
            if (success)
            {
                switch (updatedConfigurationKey.ConfigurationKeyFieldName)
                {

                    case "ORDER_PROCESSING_MODE":
                        {
                            setOrderMode(updatedConfigurationKey.ConfigurationKeyValue);
                            ConfigUtility.invokeGenericConsoleMethod("PostInitProcedure", new object[] { Settings.ORDER_PROCESSING_MODE });
                            ConfigurationKeyValues orderServiceKey = new ConfigurationKeyValues();
                            switch (Settings.ORDER_PROCESSING_MODE)
                            {
                                case StockTraderUtility.OPS_INPROCESS:
                                    {
                                        InitConfigInProcessOrderService.initConfigOrderProcessService(ConfigUtility.masterServiceWebHostSyncObject, true);
                                        break;
                                    }

                                    //********************* Self Host OPS
                                case StockTraderUtility.OPS_SELF_HOST_MSMQ:
                                    {
                                        if (block)
                                        {
                                            orderServiceKey.ConfigurationKeyFieldName = "REFRESHCONFIG";
                                            orderServiceKey.ConfigurationKeyValue = "RefreshConfig";
                                            orderServiceKey.OriginatingConfigServiceName = "Trade.OrderProcessorHostConfigurationImplementation.ConfigurationService";
                                            refreshOPSConfig(orderServiceKey, new ConfigurationService(), block,csUser);
                                        }
                                        break;
                                    }
                               
                                case StockTraderUtility.OPS_SELF_HOST_TCP:
                                    {
                                        goto case StockTraderUtility.OPS_SELF_HOST_MSMQ;
                                    }

                                case StockTraderUtility.OPS_SELF_HOST_HTTP:
                                    {
                                        goto case StockTraderUtility.OPS_SELF_HOST_MSMQ;
                                    }

                                case StockTraderUtility.OPS_SELF_HOST_TCP_TMSEC_CLIENTCERT:
                                    {
                                        goto case StockTraderUtility.OPS_SELF_HOST_MSMQ;
                                    }

                                case StockTraderUtility.OPS_SELF_HOST_TCP_TMSEC_USERNAME:
                                    {
                                        goto case StockTraderUtility.OPS_SELF_HOST_MSMQ;
                                    }

                                case StockTraderUtility.OPS_SELF_HOST_HTTP_TMSEC_CLIENTCERT:
                                    {
                                        goto case StockTraderUtility.OPS_SELF_HOST_MSMQ;
                                    }

                                case StockTraderUtility.OPS_SELF_HOST_HTTP_TMSEC_USERNAME:
                                    {
                                        goto case StockTraderUtility.OPS_SELF_HOST_MSMQ;
                                    }

                                case StockTraderUtility.OPS_SOAP:
                                    {
                                        goto case StockTraderUtility.OPS_SELF_HOST_MSMQ;
                                    }

                            }

                            success = true;
                            break;
                        }

                    case "DAL":
                        {
                            buildConnString();
                            if (block)
                            {
                                ConfigurationKeyValues orderServiceKey = new ConfigurationKeyValues();
                                orderServiceKey.ConfigurationKeyFieldName = "DAL";
                                orderServiceKey.ConfigurationKeyValue = updatedConfigurationKey.ConfigurationKeyValue;
                                orderServiceKey.OriginatingConfigServiceName = "Trade.OrderProcessorHostConfigurationImplementation.ConfigurationService";
                                refreshOPSConfig(orderServiceKey, new ConfigurationService(), block, csUser);
                            }
                            break;
                        }

                    case "DBServer":
                        {
                            buildConnString();
                            if (block)
                            {
                                ConfigurationKeyValues orderServiceKey = new ConfigurationKeyValues();
                                orderServiceKey.ConfigurationKeyFieldName = "DBServer";
                                orderServiceKey.ConfigurationKeyValue = updatedConfigurationKey.ConfigurationKeyValue;
                                orderServiceKey.OriginatingConfigServiceName = "Trade.OrderProcessorHostConfigurationImplementation.ConfigurationService";
                                refreshOPSConfig(orderServiceKey, new ConfigurationService(), block, csUser);
                            }
                            break;
                        }

                    case "Database":
                        {
                            buildConnString();
                            if (block)
                            {
                                ConfigurationKeyValues orderServiceKey = new ConfigurationKeyValues();
                                orderServiceKey.ConfigurationKeyFieldName = "Database";
                                orderServiceKey.ConfigurationKeyValue = updatedConfigurationKey.ConfigurationKeyValue;
                                orderServiceKey.OriginatingConfigServiceName = "Trade.OrderProcessorHostConfigurationImplementation.ConfigurationService";
                                refreshOPSConfig(orderServiceKey, new ConfigurationService(),block, csUser);
                            }
                            break;
                        }

                    case "UserID":
                        {
                            buildConnString();
                            break;
                        }

                    case "Password":
                        {
                            buildConnString();
                            break;
                        }

                    case "ENABLE_GLOBAL_SYSTEM_DOT_TRANSACTIONS_CONFIGSTRING":
                        {
                            Settings.setTxModel();
                            break;
                        }

                    default:
                        {
                            success = true;
                            break;
                        }
                }
            }
            return success;
        }
 /// <summary>
 /// Not part of service contract; special for BSL to return a single requested specific configurationkey 
 /// from Order Processor Service when running OPS in-process.
 /// </summary>
 /// <param name="targetHostNameIdentifier"></param>
 /// <param name="targetConfigServiceNameIdentifier"></param>
 /// <param name="settingsClassFieldName"></param>
 /// <param name="traversePath"></param>
 /// <param name="csUser"></param>
 /// <returns></returns>
 private ConfigurationKeyValues callOPSConfigKeyLocal(string targetHostNameIdentifier, string targetConfigServiceNameIdentifier, string settingsClassFieldName, List<TraverseNode> traversePath, ServiceUsers csUser)
 {
     Trade.OrderProcessorHostConfigurationImplementation.ConfigurationService OPSConfig = new Trade.OrderProcessorHostConfigurationImplementation.ConfigurationService();
     return OPSConfig.getServiceConfigurationKey(targetHostNameIdentifier,targetConfigServiceNameIdentifier,settingsClassFieldName,traversePath,csUser);
 }
        /// <summary>
        /// This is a very key service operation that really makes eveything work fast, across 3 dimensions:
        /// x-horizontal connected services, y-layers deep, virtualized across z-virtual clustered hosts within a given service domain.  It
        /// will be the preceeding call to almost all other Config Service calls, to get the fastest path to a target 
        /// connected Config Service host on the network.
        /// </summary>
        /// <param name="queriedNodeList">This list is used to prevent circular references in a connected tree of nodes from being queried, and creating a race condition.</param>
        /// <param name="targetHostNameIdentifier">The name of the target host we are seeking, as specified in the target's HOST_NAME_IDENTIFIER settings key.</param>
        /// <param name="targetConfigServiceNameIdentifier">The fully qualified name of the Configuration Service implementation class for the host we are seeking, used in
        /// conjunction with targetHostNameIdentifier to uniquely identify a target host.</param>
        /// <param name="csUser">The user requesting the path.</param>
        /// <returns>A network traverse path consisting of a List of TraverseNode types.</returns>
        public override List<TraverseNode> getTraversePath(List<TraverseNode> queriedNodeList, string targetHostNameIdentifier, string targetConfigServiceNameIdentifier, ServiceUsers csUser)
        {
            switch (Trade.BusinessServiceConfigurationSettings.Settings.ORDER_PROCESSING_MODE)
            {
                case StockTraderUtility.OPS_INPROCESS:
                    {
                        if (targetHostNameIdentifier.Equals(StockTraderUtility.ORDER_PROCESSOR_SERVICE_SELFHOST))
                        {
                            ServiceConfigHelper configHelper = new ServiceConfigHelper(settingsInstance);
                            TraverseNode myNode = null;
                            List<TraverseNode> thisPath = new List<TraverseNode>();
                            try
                            {
                                if (!(configHelper.setServiceRights(ref csUser, ConfigUtility.CONFIG_CONNECTED_SERVICE_RIGHTS)>=ConfigUtility.CONFIG_CONNECTED_SERVICE_RIGHTS))
                                    return null;
                                ConfigUtility.writeConfigConsoleMessage("\nRequest for traverse path received. Target Service Host: " + targetHostNameIdentifier + " hosting target ConfigService: " + targetConfigServiceNameIdentifier + ".\n", EventLogEntryType.Information, true, settingsInstance);
                                string HOST_NAME_IDENTIFIER = (string)ConfigUtility.reflectGetField(settingsInstance, "HOST_NAME_IDENTIFIER");
                                string CONFIG_SERVICENAME_IDENTIFIER = (string)ConfigUtility.reflectGetField(settingsInstance, "CONFIG_SERVICENAME_IDENTIFIER");
                                int NODE_ACTIVE_ID = (int)ConfigUtility.reflectGetField(settingsInstance, "NODE_ACTIVE_ID");
                                //This logic is used to ensure we construct a valid endpoint based on whether our config service
                                //is using an external load balancer such as Windows Network Load Balancing or hardware load-balancer.  This
                                //would typically be the case for any service exposed to the Internet cloud where clients could be coming from
                                //anywhere and we thus need to virtualize our Internet DNS name--or even intranet DNS name.
                                List<HostedServices> hostedServices = (List<HostedServices>)ConfigUtility.reflectGetField(settingsInstance, "hostedServices");
                                //We may have this service listening on lots of different endpoints.
                                //We need to map the correct Service Endpoint (which implies a binding) to the incoming client request using this WCF property
                                //on the operation context.  However note this is contained in the traversepath (TraverseNode) data structure,
                                //but given new design not currently used within Config Service/ConfigWeb as we dynamically figure out a new valid path on subsequent requests
                                //(given valid paths might change within seconds from original request).
                                //However, returning the correct information here may be important for those extending Config Service, as the
                                //addresses will be valid addresses given incoming request all the way up the stack from the original request.  Those that want could
                                //override this method any choose not to return *any* actual endpoint information for services this service connects to.
                                //Just a choice; independent of security which should always be set on the WCF binding itself (wsHttp or netTcp for ConfigService)
                                //, which, if set  with digital certs, InfoCard, Windows Auth (Kerberos) would be really locked down to identity of caller at the 
                                //transport and/or message level to begin with (meaning we would never be at this point in code if the client was not valid!).
                                string currentRequestEndpoint = OperationContext.Current.EndpointDispatcher.EndpointAddress.ToString();
                                List<HostListenEndPointInstance> myConfigEndpoints = (List<HostListenEndPointInstance>)ConfigUtility.reflectGetField(settingsInstance, "hostConfigListenEndpoints");
                                if (ConfigUtility.onAzure)
                                {
                                    Uri myUri = new Uri(currentRequestEndpoint);
                                    string myHostMachine = myUri.Host;
                                    string path = myUri.AbsolutePath.ToLower();
                                    ConfigUtility.writeConfigConsoleMessage("\n*** currentRequestPath: " + path, EventLogEntryType.Information, true, settingsInstance);
                                    HostListenEndPointInstance theConfigEndpoint = myConfigEndpoints.Find(delegate(HostListenEndPointInstance hExist)
                                    {
                                        Uri uri = new Uri(hExist.RemoteAddress);
                                        return uri.AbsolutePath.ToLower().Equals(path) && uri.Scheme.Equals(myUri.Scheme);
                                    }
                                    );
                                    if (theConfigEndpoint != null)
                                    {
                                        HostedServices thisService = hostedServices.Find(delegate(HostedServices hsExist)
                                        {
                                            return hsExist.HostedServiceID == theConfigEndpoint.HostedServiceID;
                                        }
                                        );
                                        string myName = ServiceConfigHelper.getHostNameForServiceHosting(thisService, settingsInstance);
                                        currentRequestEndpoint = currentRequestEndpoint.Replace(myHostMachine, myName);
                                    }
                                }

                                HostListenEndPointInstance myEp = ServiceConfigHelper.currentRequestFindMatchingListenEndpoint(currentRequestEndpoint, myConfigEndpoints);
                                if (myConfigEndpoints!=null && myConfigEndpoints.Count>0)
                                    ConfigUtility.writeConfigConsoleMessage("\n*** currentRequestEndpoint: " + currentRequestEndpoint + " myConfigEndpoints[0].RemoteAddress: " + myConfigEndpoints[0].RemoteAddress, EventLogEntryType.Information, true, settingsInstance);
                                if (myEp == null)
                                {
                                    ConfigUtility.writeConfigConsoleMessage("myEp is null, returning null path", EventLogEntryType.Information, true, settingsInstance);
                                    return null;
                                }
                                //If we are already in the path, then return null now.  This prevents circular service references within the tree from causing a race
                                //condition.  TODO is to add information about the reference so it shows up in physical maps within ConfigWeb, for now
                                //we will just return null and prevent a race condition.
                                if (queriedNodeList == null)
                                    queriedNodeList = new List<TraverseNode>();
                                TraverseNode me = queriedNodeList.Find(delegate(TraverseNode tn) { return (tn.MyNode.HostNameIdentifier.Equals(HOST_NAME_IDENTIFIER) && tn.MyNode.ConfigServiceImplementationClassName.Equals(CONFIG_SERVICENAME_IDENTIFIER)); });
                                if (me != null)
                                    return null;
                                //Note this does not populate peer nodes such that if using external load balancer, actual physical nodes remain 
                                //hidden behind the virtualized endpoint and are not returned.
                                myNode = new TraverseNode(new ServiceNode(NODE_ACTIVE_ID, myEp.RemoteAddress, ConfigSettings.MESSAGE_ONLINE, myEp.ActiveSince, HOST_NAME_IDENTIFIER, null, CONFIG_SERVICENAME_IDENTIFIER), null);
                                myNode.MyInProcNode = myNode.MyNode;
                                myNode.OSName = OSInfo.Name;
                                queriedNodeList.Add(myNode);
                                thisPath.Add(myNode);
                            }
                            catch (Exception e)
                            {
                                ServiceConfigHelper.logServiceOperationException(csUser, e.ToString(), settingsInstance);
                                throw;
                            }
                            return thisPath;
                        }
                        else
                            return base.getTraversePath(queriedNodeList, targetHostNameIdentifier, targetConfigServiceNameIdentifier, csUser);
                    }
                default:
                    {
                        List<TraverseNode> returnList = base.getTraversePath(queriedNodeList, targetHostNameIdentifier, targetConfigServiceNameIdentifier, csUser);
                        return returnList;
                    }
            }
        }
예제 #13
0
        private void processUpdate()
        {
            if (userList == null)
            {
                UpdateMessage.Text = "<br/><span style=\"color:Maroon\">" + ConfigSettings.EXCEPTION_MESSAGE_FAIL_AUTHORIZATION + "</span>";
                return;
            }

            if (action != ConfigUtility.REMOVE_USER)
                Page.Validate();
            else
                Page.Validate("User");
            ServiceUsers found = userList.Find(delegate(ServiceUsers userexist) { return userexist.UserId.ToLower().Equals(TextBoxUserName.Text.ToLower()); });
            if (found != null && action == ConfigUtility.ADD_USER)
            {
                UpdateMessage.Text = "<br/><span style=\"color:Maroon\">User Id already exists!</span>";
                return;
            }
            int success = ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS;
            if (IsValid)
            {
                ServiceUsers updateUser = new ServiceUsers();
                updateUser.Rights = Convert.ToInt32(RadioButtonListRights.SelectedValue);
                updateUser.UserId = TextBoxUserName.Text;
                updateUser.Password = TextBoxPassword.Text;
                updateUser.UserKey = thisUser.UserKey;
                updateUser.ConnectedConfigServiceID = thisUser.ConnectedConfigServiceID;
                if (RadioButtonListLocalUser.SelectedIndex == 0)
                    updateUser.LocalUser = true;
                else
                    updateUser.LocalUser = false;
                traversePath = DynamicTraversePath.getTraversePath(hostNameIdentifier, configName, ref configProxy,  address, binding, user);
                success = configProxy.receiveUser(hostNameIdentifier, configName, updateUser, oldUser, true, action, traversePath, user);
                if (success == ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS)
                {
                    successPersisted(null, updateUser);
                }
                else
                {
                    string message = null;
                    switch (success)
                    {
                        case ConfigUtility.CLUSTER_UPDATE_FAIL_PERSISTED:
                            {
                                message = ConfigSettings.EXCEPTION_MESSAGE_FAIL_PERSISTED;
                                UpdateMessage.Text = "<br/><span style=\"color:Maroon\">" + message + "</span>";
                                oldUser = (ServiceUsers)ViewState["oldUser"];
                                thisUser = oldUser;
                                ViewState["thisUser"] = oldUser;
                                break;
                            }

                        case ConfigUtility.CLUSTER_UPDATE_FAIL_VALIDATION:
                            {
                                message = ConfigSettings.EXCEPTION_MESSAGE_FAIL_VALIDATION;
                                UpdateMessage.Text = "<br/><span style=\"color:Maroon\">" + message + "</span>";
                                oldUser = (ServiceUsers)ViewState["oldUser"];
                                thisUser = oldUser;
                                ViewState["thisUser"] = oldUser;
                                break;
                            }

                        case ConfigUtility.CLUSTER_UPDATE_FAIL_AUTHENTICATION:
                            {
                                message = ConfigSettings.EXCEPTION_MESSAGE_FAIL_AUTHORIZATION;
                                UpdateMessage.Text = "<br/><span style=\"color:Maroon\">" + message + "</span>";
                                oldUser = (ServiceUsers)ViewState["oldUser"];
                                thisUser = oldUser;
                                ViewState["thisUser"] = oldUser;
                                break;
                            }

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

                        default:
                            {
                                successPersisted(ConfigSettings.EXCEPTION_MESSAGE_FAIL_REMOTE_PEER + success.ToString(), updateUser);
                                break;
                            }
                    }
                }
            }
        }
        /// <summary>
        /// Will return the Primary and Generic Service Connection Points from the ConnectedServiceInstances table in the configuration database. 
        /// </summary>
        /// <param name="targetHostNameIdentifier">The name of the target host we are seeking, as specified in the target's HOST_NAME_IDENTIFIER settings key.</param>
        /// <param name="targetConfigServiceName">The fully qualified name of the Configuration Service implementation class for the host we are seeking, used in
        /// conjunction with targetHostNameIdentifier to uniquely identify a target host.</param>
        /// <param name="connectionPointTypes">The type of connection points to retrieve.</param>
        /// <param name="checkStatus">If true, a satus flag will be set indicating online status of the endpoint.</param>
        /// <param name="traversePath">Network path to the target host.</param>
        /// <param name="csUser">User to authenticate.</param>
        /// <returns>ConnectionPoints instance which is a linked list type.</returns>
        public override ConnectionPoints getConnectionPoints(string targetHostNameIdentifier, string targetConfigServiceName, List<int> connectionPointTypes, bool checkStatus, List<TraverseNode> traversePath, ServiceUsers csUser)
        {
            ServiceConfigHelper configHelper = new ServiceConfigHelper(settingsInstance);
            ConnectionPoints returnConnectionPoints = null;
            try
            {
                if (!(configHelper.setServiceRights(ref csUser, ConfigUtility.CONFIG_DEMO_ADMIN_RIGHTS) >= ConfigUtility.CONFIG_DEMO_ADMIN_RIGHTS))
                    return null;
                ConfigUtility.writeConfigConsoleMessage("\nRequest for Connection Points received.\n", EventLogEntryType.Information, true, settingsInstance);
                if (traversePath == null || traversePath.Count <= 1 || traversePath[0] == null)
                {
                    bool SHARESERVICECONFIGURATIONDATA = (bool)ConfigUtility.reflectGetField(settingsInstance, "SHARESERVICECONFIGURATIONDATA");
                    if (!SHARESERVICECONFIGURATIONDATA)
                    {
                        List<ServiceUsers> thisServiceUsers = (List<ServiceUsers>)ConfigUtility.reflectGetField(settingsInstance, "thisServiceUsers");
                        ServiceUsers userLocalAdmin = thisServiceUsers.Find(delegate(ServiceUsers userExist) { return csUser.UserId.ToLower().Equals("localadmin") && userExist.Password.Equals(csUser.Password) && csUser.Rights == ConfigUtility.CONFIG_ADMIN_RIGHTS; });
                        if (userLocalAdmin == null)
                            return null;
                    }
                    returnConnectionPoints = configHelper.getMyConnectionPoints(connectionPointTypes);
                    string HOST_NAME_IDENTIFIER = (string)ConfigUtility.reflectGetField(settingsInstance, "HOST_NAME_IDENTIFIER");
                    string CONFIG_SERVICENAME_IDENTIFIER = (string)ConfigUtility.reflectGetField(settingsInstance, "CONFIG_SERVICENAME_IDENTIFIER");
                    bool GETCONNECTEDSERVICES = (bool)ConfigUtility.reflectGetField(settingsInstance, "CONFIGSHOWCONNECTEDSERVICES");
                    returnConnectionPoints.HostNameIdentifier = HOST_NAME_IDENTIFIER;
                    List<HostListenEndPointInstance> checkOnlineList = new List<HostListenEndPointInstance>();
                    for (int i = 0; i < returnConnectionPoints.MyConnectionPoints.Count; i++)
                    {
                        switch (Trade.BusinessServiceConfigurationSettings.Settings.ORDER_PROCESSING_MODE)
                        {
                            case StockTraderUtility.OPS_INPROCESS:
                                {
                                    break;
                                }

                            case StockTraderUtility.OPS_AZURE_HTTP_TMSEC_CLIENTCERT:
                                {
                                    if (returnConnectionPoints.MyConnectionPoints[i].ServiceFriendlyName.Equals(StockTraderUtility.OPS_AZURE_HTTP_TMSEC_CLIENTCERT))
                                        returnConnectionPoints.MyConnectionPoints[i].InUse = true;
                                    break;
                                }
                                        
                            case StockTraderUtility.OPS_AZURE_HTTP_TMSEC_USERNAME:
                                {
                                    if (returnConnectionPoints.MyConnectionPoints[i].ServiceFriendlyName.Equals(StockTraderUtility.OPS_AZURE_HTTP_TMSEC_USERNAME))
                                        returnConnectionPoints.MyConnectionPoints[i].InUse = true;
                                    break;
                                }

                            case StockTraderUtility.OPS_AZURE_TCP_TMSEC_CLIENTCERT:
                                {
                                    if (returnConnectionPoints.MyConnectionPoints[i].ServiceFriendlyName.Equals(StockTraderUtility.OPS_AZURE_TCP_TMSEC_CLIENTCERT))
                                        returnConnectionPoints.MyConnectionPoints[i].InUse = true;
                                    break;
                                }

                                case StockTraderUtility.OPS_AZURE_TCP_TMSEC_USERNAME:
                                {
                                    if (returnConnectionPoints.MyConnectionPoints[i].ServiceFriendlyName.Equals(StockTraderUtility.OPS_AZURE_TCP_TMSEC_USERNAME))
                                        returnConnectionPoints.MyConnectionPoints[i].InUse = true;
                                    break;
                                }
                                       
                            case StockTraderUtility.OPS_SELF_HOST_HTTP:
                                {
                                    if (returnConnectionPoints.MyConnectionPoints[i].ServiceFriendlyName.Equals(StockTraderUtility.OPS_SELF_HOST_HTTP))
                                        returnConnectionPoints.MyConnectionPoints[i].InUse = true;
                                    break;
                                }

                                case StockTraderUtility.OPS_SELF_HOST_HTTP_TMSEC_CLIENTCERT:
                                {
                                    if (returnConnectionPoints.MyConnectionPoints[i].ServiceFriendlyName.Equals(StockTraderUtility.OPS_SELF_HOST_HTTP_TMSEC_CLIENTCERT))
                                        returnConnectionPoints.MyConnectionPoints[i].InUse = true;
                                    break;
                                }

                                case StockTraderUtility.OPS_SELF_HOST_HTTP_TMSEC_USERNAME:
                                {
                                    if (returnConnectionPoints.MyConnectionPoints[i].ServiceFriendlyName.Equals(StockTraderUtility.OPS_SELF_HOST_HTTP_TMSEC_USERNAME))
                                        returnConnectionPoints.MyConnectionPoints[i].InUse = true;
                                    break;
                                }


                                case StockTraderUtility.OPS_SELF_HOST_MSMQ:
                                {
                                    if (returnConnectionPoints.MyConnectionPoints[i].ServiceFriendlyName.Equals(StockTraderUtility.OPS_SELF_HOST_MSMQ))
                                        returnConnectionPoints.MyConnectionPoints[i].InUse = true;
                                    break;
                                }
                                case StockTraderUtility.OPS_SELF_HOST_TCP:
                                {
                                    if (returnConnectionPoints.MyConnectionPoints[i].ServiceFriendlyName.Equals(StockTraderUtility.OPS_SELF_HOST_TCP))
                                        returnConnectionPoints.MyConnectionPoints[i].InUse = true;
                                    break;
                                }

                                case StockTraderUtility.OPS_SELF_HOST_TCP_TMSEC_CLIENTCERT:
                                {
                                    if (returnConnectionPoints.MyConnectionPoints[i].ServiceFriendlyName.Equals(StockTraderUtility.OPS_SELF_HOST_TCP_TMSEC_CLIENTCERT))
                                        returnConnectionPoints.MyConnectionPoints[i].InUse = true;
                                    break;
                                }

                                case StockTraderUtility.OPS_SELF_HOST_TCP_TMSEC_USERNAME:
                                {
                                    if (returnConnectionPoints.MyConnectionPoints[i].ServiceFriendlyName.Equals(StockTraderUtility.OPS_SELF_HOST_TCP_TMSEC_USERNAME))
                                        returnConnectionPoints.MyConnectionPoints[i].InUse = true;
                                    break;
                                }

                                case StockTraderUtility.OPS_SOAP:
                                {
                                    if (returnConnectionPoints.MyConnectionPoints[i].ServiceFriendlyName.Equals(StockTraderUtility.OPS_SOAP))
                                        returnConnectionPoints.MyConnectionPoints[i].InUse = true;
                                    break;
                                }
                                      
                        }
                        if (checkStatus)
                        {
                            checkOnlineList.Add(returnConnectionPoints.MyConnectionPoints[i]);
                        }
                    }
                    if (checkOnlineList.Count > 0)
                    {
                        RemoteNotifications remoteNotify = new RemoteNotifications(settingsInstance);
                        //This call will set online offline status for each; all are checked concurrently on background threads;
                        //Master thread joined to ensure all are done before returning.
                        remoteNotify.checkConnectionPointOnlineStatus(checkOnlineList, false);
                    }
                }
                else
                {
                    if (traversePath != null && traversePath.Count > 1)
                    {
                        ConfigUtility.writeConfigConsoleMessage("-----> Forwarding Request to Remote Connected Service: " + traversePath[traversePath.Count - 1].MyNode.Address + "\n", EventLogEntryType.Information, true, settingsInstance);
                        RemoteNotifications remoteNotify = new RemoteNotifications(settingsInstance);
                        returnConnectionPoints = remoteNotify.getRemoteConnectionPoints(targetHostNameIdentifier, targetConfigServiceName, connectionPointTypes, checkStatus, traversePath, csUser);
                    }
                }
            }
            catch (Exception e)
            {
                ServiceConfigHelper.logServiceOperationException(csUser, e.ToString(), settingsInstance);
                throw;
            }
            return returnConnectionPoints;
        }
        /// <summary>
        /// This method returns the composite configuration data for a service--the primary method
        /// used to collect and display the data for a series of connected services making up a composite 
        /// application. 
        /// </summary>
        /// <param name="targetHostNameIdentifier">The name of the target host we are seeking, as specified in the target's HOST_NAME_IDENTIFIER settings key.</param>
        /// <param name="targetConfigServiceName">The fully qualified name of the Configuration Service implementation class for the host we are seeking, used in
        /// conjunction with targetHostNameIdentifier to uniquely identify a target host.</param>
        /// <param name="configurationLevel">The config key level to return.</param>
        /// <param name="probeDeeper">If true, one layer deeper in the connected services tree will be probed as well.</param>
        /// <param name="traversePath">The network traverse path to the target.</param>
        /// <param name="csUser">User to authenticate.</param>
        /// <returns>Linked List of ServiceConfigurationData.</returns>
        public override List<ServiceConfigurationData> getServiceConfiguration(string targetHostNameIdentifier, string targetConfigServiceName, int configurationLevel, bool probeDeeper, List<TraverseNode> traversePath, ServiceUsers csUser)
        {
            ServiceConfigHelper configHelper = new ServiceConfigHelper(settingsInstance);
            object opsSettings = new Trade.OrderProcessorServiceConfigurationSettings.Settings();
            List<ServiceConfigurationData> returnCompositeConfigurationData = null;
            try
            {
                if (!(configHelper.setServiceRights(ref csUser, ConfigUtility.CONFIG_CONNECTED_SERVICE_RIGHTS) >= ConfigUtility.CONFIG_CONNECTED_SERVICE_RIGHTS))
                {
                    returnCompositeConfigurationData = new List<ServiceConfigurationData>();
                    return returnCompositeConfigurationData;
                }
                if (traversePath == null || traversePath.Count <= 1 || traversePath[0] == null)
                {
                    //Step 1:  Get list of all currently configured connected services.  We need to adjust this list based on
                    //the OrderMode setting, since we do not want to query for and return connected data for the Order Processor Service
                    //if we are not running Order Processing remotely. 
                    List<ConnectedServices> retrieveConnectedServiceList = new List<ConnectedServices>();
                    if (Trade.BusinessServiceConfigurationSettings.Settings.connectedServices != null && Trade.BusinessServiceConfigurationSettings.Settings.connectedServices.Count > 0)
                        retrieveConnectedServiceList.AddRange(Trade.BusinessServiceConfigurationSettings.Settings.connectedServices);

                    //Step 2: Here we will remove the Order Processor Service if we are not running in a remote mode. 
                    switch (Trade.BusinessServiceConfigurationSettings.Settings.ORDER_PROCESSING_MODE)
                    {
                        case StockTraderUtility.OPS_INPROCESS:
                            {
                                //In this case, we want no Business Service connections--so remove by contract name.
                                retrieveConnectedServiceList.RemoveAll(delegate(ConnectedServices cs) { return (cs.ServiceContract.Equals(Trade.BusinessServiceConfigurationSettings.Settings.OPS_CLIENT_CONNECTED_SERVICE_CONTRACT)); });
                                break;
                            }

                        default:
                            {
                                break;
                            }
                    }
                    returnCompositeConfigurationData = configHelper.getMyServiceConfiguration(targetHostNameIdentifier, targetConfigServiceName, configurationLevel, csUser, retrieveConnectedServiceList, probeDeeper);
                    //Now another special case for the Business Services app: it can run OPS Services in-process.  In this case,
                    //we will add data for OPS Services by invoking the config service in-process, and pointing to the OPS self-host repository.
                    if (BusinessServiceConfigurationSettings.Settings.ORDER_PROCESSING_MODE == StockTraderUtility.OPS_INPROCESS)
                    {
                        List<ServiceConfigurationData> opsConfigData = null;
                        Trade.OrderProcessorHostConfigurationImplementation.ConfigurationService opsServiceConfig = new Trade.OrderProcessorHostConfigurationImplementation.ConfigurationService();
                        if (ConfigUtility.onAzure)
                            opsConfigData = opsServiceConfig.getServiceConfiguration(StockTraderUtility.ORDER_PROCESSOR_SERVICE_AZURE, StockTraderUtility.ORDER_PROCESSOR_SERVICE_CONFIG, configurationLevel, false, traversePath, csUser);
                        else
                            opsConfigData = opsServiceConfig.getServiceConfiguration(StockTraderUtility.ORDER_PROCESSOR_SERVICE_SELFHOST, StockTraderUtility.ORDER_PROCESSOR_SERVICE_CONFIG, configurationLevel, false, traversePath, csUser);
                        if (opsConfigData != null)
                        {
                            for (int i = 0; i < opsConfigData.Count; i++)
                            {
                                opsConfigData[i].InProcessHost = Trade.BusinessServiceConfigurationSettings.Settings.HOST_NAME_IDENTIFIER;
                            }
                            returnCompositeConfigurationData.AddRange(opsConfigData);
                        }
                    }
                }
                else
                {
                    if (traversePath != null && traversePath.Count > 1)
                    {
                        ConfigUtility.writeConfigConsoleMessage("-----> Forwarding Request to Remote Connected Service: " + traversePath[traversePath.Count - 1].MyNode.Address + "\n", EventLogEntryType.Information, true, settingsInstance);
                        RemoteNotifications remoteNotify = new RemoteNotifications(settingsInstance);
                        returnCompositeConfigurationData = remoteNotify.getRemoteServiceConfiguration(targetHostNameIdentifier, targetConfigServiceName, configurationLevel, probeDeeper, traversePath, csUser, false, null);
                    }
                }
            }
            catch (Exception e)
            {
                ServiceConfigHelper.logServiceOperationException(csUser, e.ToString(), settingsInstance);
                throw;
            }
            return returnCompositeConfigurationData;
        }
        /// <summary>
        /// This method retrieves a specific configuration key from a configuration database for a service host.
        /// </summary>
        /// <param name="targetHostNameIdentifier">The name of the target host we are seeking, as specified in the target's HOST_NAME_IDENTIFIER settings key.</param>
        /// <param name="targetConfigServiceName">The fully qualified name of the Configuration Service implementation class for the host we are seeking, used in
        /// conjunction with targetHostNameIdentifier to uniquely identify a target host.</param>
        /// <param name="settingsClassFieldName">The field name which is the primary key in the ConfigurationKeys table.</param>
        /// <param name="traversePath">Network path to target host.</param>
        /// <param name="csUser">User to authenticate.</param>
        /// <returns>A configuration key in form of data contract class ConfigurationKeyValues.</returns>
        public override ConfigurationKeyValues getServiceConfigurationKey(string targetHostNameIdentifier, string targetConfigServiceNameIdentifier, string settingsClassFieldName, List<TraverseNode> traversePath, ServiceUsers csUser)
        {
            ServiceConfigHelper configHelper = new ServiceConfigHelper(settingsInstance);
            object opsSettings = new Trade.OrderProcessorServiceConfigurationSettings.Settings();
            ConfigurationKeyValues returnkey = null;
            try
            {
                if (!(configHelper.setServiceRights(ref csUser, ConfigUtility.CONFIG_ADMIN_RIGHTS)>=ConfigUtility.CONFIG_ADMIN_RIGHTS))
                    return null;
                ConfigUtility.writeConfigConsoleMessage("\nRequest for configuration key received.\n", EventLogEntryType.Information, true, settingsInstance);
                if (traversePath == null || traversePath.Count <= 1 || traversePath[0] == null)
                {
                    bool SHARESERVICECONFIGURATIONDATA = (bool)ConfigUtility.reflectGetField(settingsInstance, "SHARESERVICECONFIGURATIONDATA");
                    if (!SHARESERVICECONFIGURATIONDATA)
                    {
                        List<ServiceUsers> thisServiceUsers = (List<ServiceUsers>)ConfigUtility.reflectGetField(settingsInstance, "thisServiceUsers");
                        ServiceUsers userLocalAdmin = thisServiceUsers.Find(delegate(ServiceUsers userExist) { return csUser.UserId.ToLower().Equals("localadmin") && userExist.Password.Equals(csUser.Password) && csUser.Rights == ConfigUtility.CONFIG_ADMIN_RIGHTS; });
                        if (userLocalAdmin == null)
                            return null;
                    }
                    if (BusinessServiceConfigurationSettings.Settings.ORDER_PROCESSING_MODE == StockTraderUtility.OPS_INPROCESS)
                    {
                        switch (targetHostNameIdentifier)
                        {
                            case StockTraderUtility.ORDER_PROCESSOR_SERVICE_SELFHOST:
                                {
                                    returnkey = callOPSConfigKeyLocal(targetHostNameIdentifier, targetConfigServiceNameIdentifier, settingsClassFieldName, traversePath, csUser);
                                    break;
                                }

                            case StockTraderUtility.ORDER_PROCESSOR_SERVICE_AZURE:
                                {
                                    goto case StockTraderUtility.ORDER_PROCESSOR_SERVICE_SELFHOST;
                                }

                            default:
                                {
                                    returnkey = configHelper.getServiceConfigurationKey(settingsClassFieldName);
                                    break;
                                }
                        }
                    }
                    else
                    {
                        returnkey = configHelper.getServiceConfigurationKey(settingsClassFieldName);
                    }
                }
                else
                {
                    if (traversePath != null && traversePath.Count > 1)
                    {
                        ConfigUtility.writeConfigConsoleMessage("-----> Forwarding Request to Remote Connected Service: " + traversePath[traversePath.Count - 1].MyNode.Address + "\n", EventLogEntryType.Information, true, settingsInstance);
                        RemoteNotifications remoteNotify = new RemoteNotifications(settingsInstance);
                        returnkey = remoteNotify.getRemoteServiceKey(targetHostNameIdentifier, targetConfigServiceNameIdentifier, settingsClassFieldName, traversePath, csUser);
                    }
                }
            }
            catch (Exception e)
            {
                ServiceConfigHelper.logServiceOperationException(csUser, e.ToString(), settingsInstance);
                throw;
            }
            return returnkey;
        }
 /// <summary>
 /// Refreshes the BSL from repository.
 /// </summary>
 /// <param name="key"></param>
 /// <param name="configService"></param>
 /// <param name="notifyNodes"></param>
 /// <param name="csUser"></param>
 /// <returns></returns>
 public int refreshBSLConfig(ConfigurationKeyValues key, ConfigurationService configService, bool notifyNodes,ServiceUsers csUser)
 {
     int returnCode = ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS;
     string value = key.ConfigurationKeyValue;
     List<TraverseNode> traversePath = configService.getTraversePath(null, Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER, StockTraderUtility.BUSINESS_SERVICES_CONFIG, csUser);
     key = configService.getServiceConfigurationKey(Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER, StockTraderUtility.BUSINESS_SERVICES_CONFIG, key.ConfigurationKeyFieldName, traversePath, csUser);
     if (key != null)
     {
         key.ConfigurationKeyValue = value;
         traversePath = configService.getTraversePath(null, Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER, StockTraderUtility.BUSINESS_SERVICES_CONFIG, csUser);
         if (traversePath!=null)
             returnCode = configService.receiveConfigurationKey(Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER, StockTraderUtility.BUSINESS_SERVICES_CONFIG, key, key, notifyNodes, ConfigUtility.UPDATE_KEY_VALUE, traversePath, csUser);
     }
     return returnCode;
 }
예제 #18
0
        protected void processLogin()
        {
           HttpCookie authcookie = Request.Cookies[FormsAuthentication.FormsCookieName];
           if (authcookie != null)
           {
               FormsAuthenticationTicket tryTicket = (FormsAuthenticationTicket)FormsAuthentication.Decrypt(authcookie.Value);
               if (User.Identity.IsAuthenticated)
               {
                   string userid = User.Identity.Name;
                   Response.Cookies.Remove(FormsAuthentication.FormsCookieName);
               }
           }
            InValid.Text = null;
            Page.Validate();
            allClients = (List<ClientInformation>)ViewState["allClients"];
            knownAddresses = (List<string>)ViewState["knownAddresses"];
            names = (List<string>)ViewState["names"];
            clientDefinitions = (List<string>)ViewState["clientDefinitions"];
            bindings = (List<BindingInformation>)ViewState["bindings"];
            ClientInformation client = null;
            BindingInformation binding = bindings.Find(delegate(BindingInformation bindingItem)
            {
                client = allClients.Find(delegate(ClientInformation clientExist) { return clientExist.ElementName.Equals(clients.SelectedValue); });
                return bindingItem.BindingConfigurationName.Equals(client.BindingConfiguration);
            });
            if (Page.IsValid)
            {
                //Notes on security: 
                //We are using ASP.NET Forms authentication from ConfigWeb, which automates the authentication process against
                //either a simple list of valid users, or a backend database of registered users (ConfigWeb uses this mechanism),
                //Windows Active Directory, or any pluggable mechanism based on the extensibility of Forms Authentication in ASP.NET 2.0.
                //Via Forms Authentication, ASP.NET provides automatic authentication for restricted pages, and automates redirects to login forms 
                //such as this one. In addition, security can be set with WCF bindings, which support transport, message, and transport with
                //message credentials.  You can add additional WCF binding configurations and client configurations to ConfigWeb web.config, and they will 
                //automatically show up as drop-down options on the login page.  The Configuration Service itself authenticates every
                //request against its registered users database; with service operations restricted based on the user rights for that registered user.

                //The remote Configuration Service you are logging into must support the binding option you choose (via the selected Client Configuration) on login; with WCF
                //a service host can simultaneously support many different bindings (perhaps with different security settings), many different
                //listen endpoints (URIs).  And, clients can also support these different binding options, as illustrated with this login
                //page that allows netTcp (binary encoding); or basicHttp (SOAP/text-XML encoding) to be chosen as an option for login and
                //all subsequent requests for Configuration Service operations. Again, you could add different bindings to your Configuration 
                //Service host, and simply add the appropriate client bindings (can generate via svcutil) to ConfigWeb web.config to 
                //restrict access based on transport and/or message level security set in your binding configurations on client and host--
                //for example, adding wsHttp support over https.  See:
                //
                //                          http://msdn2.microsoft.com/en-us/library/ms735093.aspx 
                //
                //
                //Finally, ASP.NET Forms authentication defaults to use SHA1 for HMAC Generation and AES for
                //Encryption, which is recommended. An application such as this in production on the public Internet
                //(vs. internal private net) would be run over SSL. An excellent security Patterns and Practices resource 
                //on how to secure Internet applications can be found at:
                ///
                //                http://msdn2.microsoft.com/en-us/library/aa302415.aspx
                //
                //Information on Forms Authentication, encryption and using Forms Authentication with SSL is available at:
                //
                //               http://msdn2.microsoft.com/en-us/library/ms998310.aspx

                string userID = uid.Text;
                string password = pwd.Text;
                password = Input.LoginValidate(password, Input.EXPRESSION_PWORD);
                userID = Input.LoginValidate(userID, Input.EXPRESSION_USERID);
                if (userID==null || password == null)
                {
                    InValid.Text = "Please enter a valid userid and/or password!";
                    return;
                }
                string address = null;
                if (!CheckBoxAddress.Checked)
                    address = textboxaddress.Text.ToLower().Trim();
                else
                    address = ServiceAddress.Text.ToLower().Trim();
                if (address == null || address == "")
                {
                    InValid.Text = "Please enter a valid address!";
                    return;
                }
                Uri theUri = null;
                try
                {
                    theUri = new Uri(address);
                }
                catch (Exception)
                {
                    InValid.Text = "Please enter a valid address!";
                    return;
                }
                bool remap = false;
                ServiceConfigurationClient configProxy = null;
                ServiceUsers user = new ServiceUsers(0, userID, password, ConfigUtility.CONFIG_NO_RIGHTS, true, 0);
                try
                {
                    user.UserId.Trim();
                    if (!CheckBoxAddress.Checked)
                    {
                        if (binding.BindingType != null)
                        {
                            switch (binding.BindingType)
                            {
                                case ConfigUtility.BASIC_HTTP_BINDING:
                                    {
                                        if (!client.ElementName.ToLower().Contains("t_security"))
                                        {
                                            if (!address.ToLower().StartsWith("https") && address.ToLower().StartsWith("http"))
                                            {
                                                break;
                                            }
                                            else if (address.ToLower().StartsWith("https"))
                                            {
                                                address = address.Remove(4, 1);
                                                textboxaddress.Text = address;
                                                theUri = new Uri(address);
                                                remap = true;
                                                break;
                                            }
                                            else
                                            {
                                                InValid.Text = "You have selected an <b>Http</b> configuration: Please enter a valid <strong>http</strong> address.";
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            if (!address.ToLower().StartsWith("https") && address.ToLower().StartsWith("http"))
                                            {
                                                address = address.Insert(4, "s");
                                                theUri = new Uri(address);
                                                textboxaddress.Text = address;
                                                remap = true;
                                                break;
                                            }
                                            else if (!address.ToLower().StartsWith("https"))
                                            {
                                                InValid.Text = "You have selected an <b>Https</b> configuration: Please enter a valid <strong>https</strong> 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 (!address.ToLower().StartsWith("net.tcp"))
                                        {
                                            InValid.Text = "You have selected a <b>Tcp</b> configuration: Please enter a valid tcp address in form of net.tcp://";
                                            return;
                                        }
                                        break;
                                    }
                            }
                        }
                    }
                    string theClientConfig = null;
                    ServiceUsers returnUser=null;
                    if (CheckBoxAddress.Checked)
                        theClientConfig = ClientConfiguration.Text;
                    else
                        theClientConfig = clients.SelectedValue;
                    configProxy = new ServiceConfigurationClient(theClientConfig, address, user);

                    //Ok, request a login from the remote service
                    LoginInfo returnInfo = configProxy.login(user);
                    if (returnInfo!=null)
                        returnUser = returnInfo.CsUser;

                    //By default, the service will reject admin ops on a per request basis, but we will also reject login here 
                    //in ConfigWeb for non-admins.
                    if (returnUser != null && returnUser.Rights >= ConfigUtility.CONFIG_DEMO_ADMIN_RIGHTS)
                    {
                        //OK--we are logged in!  To allow scale out of ConfigWeb itself, we are going to jam some basic information into a cookie
                        //as client-side session state.  In secure scenarios, like on Azure, ConfigWeb is always run over https.  This is an alternative
                        //to distributed caching of session state, but only appropriate when the state per session is very, very small (a few strings below).
                        string sessionInfo = address + (char)182 + returnUser.LocalUser.ToString() + (char)182 + returnUser.Password + (char)182 +
                            returnUser.Rights.ToString() + (char)182 + returnUser.UserId + (char)182 + returnUser.UserKey.ToString() + (char)182 + theClientConfig +
                                (char)182 + returnInfo.HostNameIdentifier + (char)182 + returnInfo.ConfigServiceName + (char)182 + returnInfo.ServiceHoster + (char)182 +
                                returnInfo.ServiceVersion + (char)182 + returnInfo.RuntimePlatform + (char)182 + returnInfo.HostedServiceID;
                        //FormsAuthentication.SetAuthCookie(returnUser.UserId, false);
                        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(3, returnUser.UserId,DateTime.Now, DateTime.Now.AddMinutes(ConfigSettings.CONFIGWEB_FORMSAUTH_TIMEOUT_MINUTES),false, sessionInfo);
                        string hash = FormsAuthentication.Encrypt(ticket);
                        HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash);
                        Response.Cookies.Add(cookie);
                        Response.Redirect(FormsAuthentication.DefaultUrl, true);
                    }
                    else
                    {
                        InValid.Text = ConfigSettings.EXCEPTION_MESSAGE_INVALID_LOGIN;
                    }
                }
                catch (Exception e)
                {
                    if (remap)
                        InValid.Text = "<b>You entered an https or http address that did not match the selected client configuration binding, and the address was remapped to/from https to/from http automatically before attempting login. </b><br/><br/>";
                    else
                        InValid.Text = "";
                    //Note if a service is misconfigured and will not start, the exception will likely be a web page; which has to be handled differently since its encoding is not text/xml, its text/html 
                    //with lots of characters that will not display if simply printed out on a label control.
                    string displayMessage=null;
                    string innerMessage = "";
                    if (e.Message.ToLower().Contains("<html>"))
                        displayMessage = ConfigUtility.reMapExceptionForDisplay(e.Message);
                    else
                        displayMessage = e.Message;
                    if (e.InnerException != null)
                        innerMessage = "<br/>Inner Exception is: " + e.InnerException.Message;
                    InValid.Text = InValid.Text + "Error Logging In. Exception is: <br/>" + displayMessage + innerMessage;
                }
            }
        }
예제 #19
0
 protected override void OnLoad(EventArgs e)
 {
     Page.Form.DefaultFocus = TextBoxUserName.ClientID;
     Input.getHostData(IsPostBack, ViewState, out userid, out address, out user, out binding, out hostNameIdentifier, out configName, out version, out platform, out hoster, false);
     if (IsPostBack)
     {
         identify = (string)ViewState["identify"];
         action = (string)ViewState["action"];
     }
     else
     {
         action = Request["action"];
         identify = Request["identify"];
         ViewState["action"] = action;
         ViewState["identify"] = identify;
     }
     if (!IsPostBack)
     {
         traversePath = DynamicTraversePath.getTraversePath(hostNameIdentifier, configName, ref configProxy, address, binding, user);
         compositeServiceData = configProxy.getServiceConfiguration(hostNameIdentifier, configName, ConfigUtility.CONFIG_LEVEL_BASIC, false, traversePath, user);
         ViewState["compositeServiceData"] = compositeServiceData;
         userList = configProxy.getServiceUsers(hostNameIdentifier, configName, traversePath, user);
         ViewState["userList"] = userList;
     }
     else
     {
         UpdateMessage.Text = "";
         oldUser = (ServiceUsers)ViewState["oldUser"];
         action = (string)ViewState["action"];
         userList = (List<ServiceUsers>)ViewState["userList"];
         compositeServiceData = (List<ServiceConfigurationData>)ViewState["compositeServiceData"];
     }
     if (compositeServiceData == null)
     {
         Response.Redirect(ConfigSettings.PAGE_NODES,true);
     }
    
     if (action.Equals(ConfigUtility.ADD_USER))
     {
         Update.Enabled = false;
         Delete.Enabled = false;
     }
     else
     {
         Add.Enabled = false;
         thisUser = getUser(userList, identify);
         ViewState["thisUser"] = thisUser;
         if (!IsPostBack)
             ViewState["oldUser"] = thisUser;
         if (thisUser == null)
         {
             Response.Redirect(ConfigSettings.PAGE_NODES,true);
         }
     }
     if (!IsPostBack)
     {
         initRadioButtons();
         if (!action.Equals(ConfigUtility.ADD_USER))
             getData();
     }
     if (action.Equals(ConfigUtility.REMOVE_USER))
     {
         RequiredFieldValidator1.Enabled = false;
         UpdateMessage.Text = "WARNING:  If you are removing a <em>Connected Service User</em> to a remote service , when you delete, you will also be removing <b>all</b> Connected Service Definitions to this host, as well as existing Connection Points for these Connected Service Definitions.";
         UpdateMessage.ForeColor = System.Drawing.Color.Maroon;
     }
     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_USERS + "?name=" + hostNameIdentifier + "&cfgSvc=" + configName + "&version=" + version + "&platform=" + platform + "&hoster=" + hoster + "\">Return to User List</a>";
     GetImageButton.runtimePoweredBy(platform, RuntimePlatform);
 }
예제 #20
0
 protected void Add_Click(object sender, EventArgs e)
 {
     RequiredFieldValidator1.Enabled = true;
     action = ConfigUtility.ADD_USER;
     actiontext = "added";
     thisUser = new ServiceUsers();
     processUpdate();
 }
예제 #21
0
        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;

        }
        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;
        }
        /// <summary>
        /// This method performs the logic required when a specific configuration settings key is changed.  This includes 
        /// potentially updating configuration database, notifying nodes, and performing configuration actions.
        /// </summary>
        /// <param name="targetHostNameIdentifier">The name of the target host we are seeking, as specified in the target's HOST_NAME_IDENTIFIER settings key.</param>
        /// <param name="targetConfigServiceName">The fully qualified name of the Configuration Service implementation class for the host we are seeking, used in
        /// conjunction with targetHostNameIdentifier to uniquely identify a target host.</param>
        /// <param name="oldKey">The key prior to update.</param>
        /// <param name="newKey">The updated key.</param>
        /// <param name="notifyNodes">If true, key update will be flowed to peer nodes.</param>
        /// <param name="action">Action to perform.</param>
        /// <param name="traversePath">Network path to the target host.</param>
        /// <param name="csUser">User to authenticate.</param>
        /// <returns>Int representing success code.</returns>
        public override int receiveConfigurationKey(string targetHostNameIdentifier, string targetConfigServiceNameIdentifier, ConfigurationKeyValues oldKey, ConfigurationKeyValues newKey, bool notifyNodes, string action, List<TraverseNode> traversePath, ServiceUsers csUser)
        {
            ServiceConfigHelper configHelper = new ServiceConfigHelper(settingsInstance);
            bool success = true;
            object theSettingsInstance = new Trade.BusinessServiceConfigurationSettings.Settings();
            IConfigurationActions configActions;
            int returnCode = ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS;
            try
            {
                if (!(configHelper.setServiceRights(ref csUser, ConfigUtility.CONFIG_ADMIN_RIGHTS)>=ConfigUtility.CONFIG_ADMIN_RIGHTS))
                    return ConfigUtility.CLUSTER_UPDATE_FAIL_AUTHENTICATION;
                configActions = (IConfigurationActions)ConfigUtility.reflectGetField(settingsInstance, "thisServiceConfigActions");
                if ((action != ConfigUtility.ADD_KEY && action != ConfigUtility.REMOVE_KEY) && (traversePath == null || traversePath.Count <= 1 || traversePath[0] == null))
                {
                    if (targetHostNameIdentifier != StockTraderUtility.ORDER_PROCESSOR_SERVICE_SELFHOST && targetHostNameIdentifier != StockTraderUtility.ORDER_PROCESSOR_SERVICE_AZURE)
                    {
                        if (!configActions.validateConfigurationKey(settingsInstance, newKey))
                            return ConfigUtility.CLUSTER_UPDATE_FAIL_VALIDATION;
                    }
                }
                ConfigUtility.writeConfigConsoleMessage("\nReceived Request for Configuration Key Change, Action: " + action + ". Keyname: " + oldKey.ConfigurationKeyDisplayName + "\n", EventLogEntryType.Information, true, settingsInstance);
                ConfigUtility.writeConfigConsoleMessage("Value: " + newKey.ConfigurationKeyValue + "\n\n", EventLogEntryType.Information, true, settingsInstance);
                if (traversePath == null || traversePath.Count <= 1 || traversePath[0] == null)
                {
                    bool SHARESERVICECONFIGURATIONDATA = (bool)ConfigUtility.reflectGetField(settingsInstance, "SHARESERVICECONFIGURATIONDATA");
                    if (!SHARESERVICECONFIGURATIONDATA)
                    {
                        List<ServiceUsers> thisServiceUsers = (List<ServiceUsers>)ConfigUtility.reflectGetField(settingsInstance, "thisServiceUsers");
                        ServiceUsers userLocalAdmin = thisServiceUsers.Find(delegate(ServiceUsers userExist) { return csUser.UserId.ToLower().Equals("localadmin") && userExist.Password.Equals(csUser.Password) && csUser.Rights == ConfigUtility.CONFIG_ADMIN_RIGHTS; });
                        if (userLocalAdmin == null)
                            return ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS;
                    }
                    switch (targetHostNameIdentifier)
                    {
                        case StockTraderUtility.ORDER_PROCESSOR_SERVICE_SELFHOST:
                            {
                                theSettingsInstance = new Trade.OrderProcessorServiceConfigurationSettings.Settings();
                                Trade.OrderProcessorHostConfigurationImplementation.ConfigurationService configService = new Trade.OrderProcessorHostConfigurationImplementation.ConfigurationService();
                                int opsRetCode = configService.receiveConfigurationKey(targetHostNameIdentifier, targetConfigServiceNameIdentifier, oldKey, newKey, notifyNodes, action, traversePath, csUser);
                                if (opsRetCode == ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS)
                                    success = true;
                                break;
                            }

                        case StockTraderUtility.ORDER_PROCESSOR_SERVICE_AZURE:
                            {
                                goto case StockTraderUtility.ORDER_PROCESSOR_SERVICE_SELFHOST;
                            }
                        default:
                            {
                                if (notifyNodes)
                                    success = configHelper.sendConfigurationKeyUpdateLocal(oldKey, newKey, action, csUser);
                                break;
                            }
                    }
                    if (success)
                    {
                        if (targetHostNameIdentifier != StockTraderUtility.ORDER_PROCESSOR_SERVICE_SELFHOST)
                            success = configActions.checkChangedSetting(theSettingsInstance, newKey, notifyNodes, csUser);
                        if (notifyNodes && success)
                        {
                            RemoteNotifications remoteNotify = new RemoteNotifications(settingsInstance);
                            return remoteNotify.sendKeyUpdateToClusterMembers(targetHostNameIdentifier, targetConfigServiceNameIdentifier, oldKey, newKey, action);
                        }
                    }
                    else
                        returnCode = ConfigUtility.CLUSTER_UPDATE_FAIL_PERSISTED;
                }
                else
                {
                    if (traversePath != null && traversePath.Count > 1)
                    {
                        RemoteNotifications remoteKeyUpdate = new RemoteNotifications(settingsInstance);
                        ConfigUtility.writeConfigConsoleMessage("     Forwarding Key to Remote Connected Service: " + traversePath[traversePath.Count - 1].MyNode.Address + "\n", EventLogEntryType.Information, true, settingsInstance);
                        return (remoteKeyUpdate.sendConfigurationKeyUpdateRemote(targetHostNameIdentifier, targetConfigServiceNameIdentifier, oldKey, newKey, notifyNodes, action, traversePath, csUser));
                    }
                }
            }
            catch (Exception e)
            {
                ServiceConfigHelper.logServiceOperationException(csUser, e.ToString(), settingsInstance);
                throw;
            }
            return (returnCode);
        }
        /// <summary>
        /// Overrides the base method, performs app-specific logic on specific app-specific setting changes.  For OPS,
        /// there are few app specific routines we need to run when OPS-specific app settings are changed in the repository.
        /// MAKE SURE TO CALL THE BASE checkChangedSetting method FIRST!
        /// </summary>
        /// <param name="settingsInstance">Instance of this host's Settings class.</param>
        /// <param name="updatedConfigurationKey">The key that has been updated.</param>
        /// <param name="block">True to block on any multi-threaded calls, typically the node receiving via
        /// Config Service endpoint blocks, nodes receiving via Node Service do not, if any threads are spun up.</param>
        /// <param name="csUser">The user making the requested configuration update.</param>
        /// <returns>bool as success code.</returns>
        public override bool checkChangedSetting(object settingsInstance, ConfigurationKeyValues updatedConfigurationKey, bool block, ServiceUsers csUser)
        {
            bool success = false;
            //First call the base method, this performs actions for required inherited global settings.
            success = base.checkChangedSetting(settingsInstance, updatedConfigurationKey, block, csUser);
            if (success)
            {
                switch (updatedConfigurationKey.ConfigurationKeyFieldName)
                {
                    
                    case "DAL":
                        {
                            buildConnString();
                            break;
                        }

                    case "DBServer":
                        {
                            buildConnString();
                            break;
                        }

                    case "Database":
                        {
                            buildConnString();
                            break;
                        }

                    case "UserID":
                        {
                            buildConnString();
                            break;
                        }

                    case "Password":
                        {
                            buildConnString();
                            break;
                        }
                   

                    default:
                        {
                            success = true;
                            break;
                        }
                }
            }
            return success;
        }
        /// <summary>
        /// Overrides the base method, performs app-specific logic on specific app-specific setting changes.  For the
        /// Web app there are few app specific routines we need to run when OPS-specific app settings are changed in the repository.
        /// MAKE SURE TO CALL THE BASE checkChangedSetting method FIRST!
        /// </summary>
        /// <param name="settingsInstance">Instance of this host's Settings class.</param>
        /// <param name="updatedConfigurationKey">The key that has been updated.</param>
        /// <param name="block">True to block on any multi-threaded calls, typically the node receiving via
        /// Config Service endpoint blocks, nodes receiving via Node Service do not, if any threads are spun up.</param>
        /// <returns>bool as success code.</returns>
        public override bool checkChangedSetting(object settingsInstance, ConfigurationKeyValues updatedConfigurationKey,bool block,ServiceUsers csUser)
        {
            bool success = false;
            Trade.StockTraderWebApplicationConfigurationImplementation.ConfigurationService configService = new ConfigurationService();
            ServiceConfigHelper configHelper = new ServiceConfigHelper(settingsInstance);
            success = base.checkChangedSetting(settingsInstance, updatedConfigurationKey, block, csUser);
            if (success)
            {
                  switch (updatedConfigurationKey.ConfigurationKeyFieldName)
                  {
                      case "ACCESS_MODE":
                          {
                              setAccessMode(updatedConfigurationKey.ConfigurationKeyValue);
                              ConfigurationKeyValues businessServiceKey = new ConfigurationKeyValues();
                              switch (Settings.ACCESS_MODE)
                              {
                                  
                                  case StockTraderUtility.BSL_IISHOST_BSL_HTTP:
                                      {
                                          if (block)
                                          {
                                              businessServiceKey.ConfigurationKeyFieldName = "REFRESHCONFIG";
                                              businessServiceKey.ConfigurationKeyValue = "RefreshConfig";
                                              businessServiceKey.OriginatingConfigServiceName = StockTraderUtility.BUSINESS_SERVICES_CONFIG;
                                              refreshBSLConfig(businessServiceKey, configService, block, csUser);
                                          }
                                          InitCommunicationChannels(settingsInstance, null, ConfigUtility.INIT_ALL_CONNECTED_INSTANCES);
                                          break;
                                      }

                                  case StockTraderUtility.BSL_IISHOST_BSL_TCP:
                                      {
                                          goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP;
                                      }

                                  case StockTraderUtility.BSL_IISHOST_TCP_TMSEC_CLIENTCERT:
                                      {
                                          goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP;
                                      }

                                  case StockTraderUtility.BSL_IISHOST_TCP_TMSEC_USERNAME:
                                      {
                                          goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP;
                                      }

                                  case StockTraderUtility.BSL_IISHOST_WSHTTP_MSEC_CLIENTCERT:
                                      {
                                          goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP;
                                      }

                                  case StockTraderUtility.BSL_IISHOST_WSHTTP_TMSEC_CLIENTCERT:
                                      {
                                          goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP;
                                      }
                                  case StockTraderUtility.BSL_IISHOST_WSHTTP_TMSEC_USERNAME:
                                      {
                                          goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP;
                                      }

                                  case StockTraderUtility.BSL_AZURE_TCP_TMSEC_CLIENTCERT:
                                      {
                                          goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP;
                                      }

                                  case StockTraderUtility.BSL_AZURE_TCP_TMSEC_USERNAME:
                                      {
                                          goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP;
                                      }

                                  case StockTraderUtility.BSL_AZURE_WSHTTP_TMSEC_CLIENTCERT:
                                      {
                                          goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP;
                                      }

                                  case StockTraderUtility.BSL_AZURE_WSHTTP_TMSEC_USERNAME:
                                      {
                                          goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP;
                                      }
                                 
                                  case StockTraderUtility.BSL_INPROCESS:
                                      {
                                          InitConfigInProcessBusinessService.initConfigBusinessService(ConfigUtility.masterServiceWebHostSyncObject,true);
                                          break;
                                      }

                                  default:
                                      {
                                          break;
                                      }
                                  }
                                  success = true;
                                  break;
                              }

                          case "MAX_DISPLAY_ORDERS":
                          {
                              List<TraverseNode> traversePath=null;
                              int successBSL = ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS;
                              if (Settings.ACCESS_MODE == StockTraderUtility.BSL_SOAP)
                              {
                                  success = true;
                                  break;
                              }
                              ConfigurationKeyValues businessServiceKey = null;
                              ConfigurationKeyValues thisOldbusinessServiceKey = null;
                              businessServiceKey = refreshBSL(out thisOldbusinessServiceKey, "MAX_QUERY_ORDERS", csUser);
                              if (businessServiceKey != null && block)
                              {
                                  businessServiceKey.ConfigurationKeyValue = updatedConfigurationKey.ConfigurationKeyValue;
                                  traversePath = configService.getTraversePath(null, Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER, StockTraderUtility.BUSINESS_SERVICES_CONFIG, csUser);
                                  successBSL = configService.receiveConfigurationKey(Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER,StockTraderUtility.BUSINESS_SERVICES_CONFIG, thisOldbusinessServiceKey,businessServiceKey,block, ConfigUtility.UPDATE_KEY_VALUE,traversePath,csUser);
                                  if (successBSL == ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS)
                                      success = true;
                              }
                              else
                                  success = false;
                              break;
                          }

                      case "MAX_DISPLAY_TOP_ORDERS":
                          {
                              List<TraverseNode> traversePath = null;
                              int successBSL = ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS;
                              if (Settings.ACCESS_MODE == StockTraderUtility.BSL_SOAP)
                              {
                                  success = true;
                                  break;
                              }
                              ConfigurationKeyValues businessServiceKey = null;
                              ConfigurationKeyValues thisOldbusinessServiceKey = null;
                              businessServiceKey = refreshBSL(out thisOldbusinessServiceKey, "MAX_QUERY_TOP_ORDERS", csUser);
                              if (businessServiceKey != null && block)
                              {
                                  businessServiceKey.ConfigurationKeyValue = updatedConfigurationKey.ConfigurationKeyValue;
                                  traversePath = configService.getTraversePath(null, Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER, StockTraderUtility.BUSINESS_SERVICES_CONFIG, csUser);
                                  successBSL = configService.receiveConfigurationKey(Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER, StockTraderUtility.BUSINESS_SERVICES_CONFIG, thisOldbusinessServiceKey, businessServiceKey, block, ConfigUtility.UPDATE_KEY_VALUE, traversePath, csUser);
                                  if (successBSL == ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS)
                                      success = true;
                              }
                              else
                                  success = false;
                              break;
                          }


                      default:
                          {
                              success = true;
                              break;
                          }
                  }
              }
              return success;
        }