/// <summary> /// Initializes the specified config item. /// </summary> /// <param name="configItem">The config item.</param> /// <exception cref="Forge.Configuration.Shared.InvalidConfigurationValueException">CertificateSource value is invalid. /// or /// CertificateSource value is invalid. /// or /// CertificateFile value is invalid. /// or /// Password value is invalid. /// or /// Subject value is invalid. /// or /// CertificateSource value is invalid.</exception> /// <exception cref="Forge.Configuration.Shared.InvalidConfigurationException">Invalid certificate. /// or /// Failed to find certificate. /// or /// Failed to find certificate.</exception> public override void Initialize(CategoryPropertyItem configItem) { if (configItem == null) { ThrowHelper.ThrowArgumentNullException("configItem"); } if (!IsInitialized) { CertificateConfigurationSource certSource = new CertificateConfigurationSource(); certSource.Initialize(configItem); mCertificate = certSource.Certificate; CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(configItem.PropertyItems, "Protocol"); if (pi != null) { try { Protocol = (SslProtocols)Enum.Parse(typeof(SslProtocols), pi.EntryValue, true); } catch (Exception) { } } base.Initialize(configItem); IsInitialized = true; } }
/// <summary> /// Initializes the specified item. /// </summary> /// <param name="item">The item.</param> public virtual void Initialize(CategoryPropertyItem item) { this.Filter = null; if (item != null) { this.SinkId = item.Id; CategoryPropertyItem rootItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(item.PropertyItems, CONFIG_FILTER); if (rootItem != null) { try { Type filterType = TypeHelper.GetTypeFromString(rootItem.EntryValue, TypeLookupModeEnum.AllowAll, true, true, true); this.Filter = (IErrorReportFilter)filterType.GetConstructor(Type.EmptyTypes).Invoke(new object[] { }); this.Filter.Initialize(rootItem); } catch (Exception ex) { this.Filter = null; string message = string.Format("Failed to create error report filter. Type: '{0}'. Sink type: '{1}'", rootItem.EntryValue, this.GetType().AssemblyQualifiedName); if (LOGGER.IsErrorEnabled) { LOGGER.Error(message, ex); } throw new InitializationException(message, ex); } } } }
/// <summary> /// Parses the int value. /// </summary> /// <param name="root">The root.</param> /// <param name="entryId">The entry id.</param> /// <param name="minValue">The min value.</param> /// <param name="maxValue">The max value.</param> /// <param name="value">The value.</param> /// <returns>True, if the parse method was succeeded, otherwise False.</returns> protected static bool ParseIntValue(CategoryPropertyItem root, String entryId, int minValue, int maxValue, ref int value) { bool result = false; CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(root.PropertyItems, entryId); if (pi != null) { try { value = int.Parse(pi.EntryValue); result = true; } catch (FormatException ex) { throw new InvalidConfigurationException(String.Format("Invalid value for item: {0}", entryId), ex); } if (value < minValue) { throw new InvalidConfigurationException(String.Format("Minimum value ({0}) is out of range ({1}) for item: {2}", minValue, result, entryId)); } if (value > maxValue) { throw new InvalidConfigurationException(String.Format("Maximum value ({0}) is out of range ({1}) for item: {2}", maxValue, result, entryId)); } } return(result); }
private void Initialize() { string appId = ApplicationHelper.ApplicationId; bool mutexResult = false; string typeName = String.Format("HibernateStorageProvider_{0}_{1}_{2}", appId, StorageId, typeof(T).AssemblyQualifiedName.GetHashCode().ToString()); if (typeName.Length > 255) { // limit the length of the mutex name to avoid exception typeName = typeName.Substring(0, 255); } mAppIdMutex = new Mutex(true, typeName, out mutexResult); if (!mutexResult) { throw new InitializationException("An other application with the specified application identifier is running."); } this.mDeviceId = HashGeneratorHelper.GetSHA256BasedValue(StorageId); CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(StorageConfiguration.Settings.CategoryPropertyItems, String.Format("NHibernateProvider/KnownStorageIdsToReset/{0}", StorageId)); if (pi != null) { Reset(); } LoadAllocationTable(); }
/// <summary> /// Initialize message sink from configuration /// </summary> /// <param name="pi">The pi.</param> public virtual void Initialize(CategoryPropertyItem pi) { if (pi == null) { ThrowHelper.ThrowArgumentNullException("pi"); } if (!this.mInitialized) { CategoryPropertyItem piCompressData = ConfigurationAccessHelper.GetCategoryPropertyByPath(pi.PropertyItems, "CompressData"); if (piCompressData != null) { bool.TryParse(piCompressData.EntryValue, out mCompressData); CategoryPropertyItem piCompressDataOverSize = ConfigurationAccessHelper.GetCategoryPropertyByPath(pi.PropertyItems, "CompressDataOverSize"); if (piCompressDataOverSize != null) { int result = 0; if (int.TryParse(piCompressDataOverSize.EntryValue, out result)) { mCompressDataOverSize = result; } } } } }
private void SectionHandler_OnConfigurationChanged(object sender, EventArgs e) { string value = ConfigurationAccessHelper.GetValueByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, "NetworkContext"); if (string.IsNullOrEmpty(value) || string.IsNullOrEmpty(value.Trim())) { throw new InitializationException("Network context name not configured."); } this.mName = value.Trim(); value = ConfigurationAccessHelper.GetValueByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, "NetworkContext/Separation"); bool boolValue = false; if (!string.IsNullOrEmpty(value)) { bool.TryParse(value, out boolValue); } Separation = boolValue; CategoryPropertyItem piRoot = ConfigurationAccessHelper.GetCategoryPropertyByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, "NetworkContext/Separation/WhiteList"); List <ContextRule> list = new List <ContextRule>(); if (piRoot != null) { foreach (CategoryPropertyItem pi in piRoot) { if (string.IsNullOrEmpty(pi.EntryName) || string.IsNullOrEmpty(pi.EntryName.Trim())) { throw new InitializationException("Invalid context rule."); } if (string.IsNullOrEmpty(pi.EntryValue) || string.IsNullOrEmpty(pi.EntryValue.Trim())) { throw new InitializationException("Invalid context rule."); } list.Add(new ContextRule(pi.EntryName, pi.EntryValue)); } } WhiteList = list; piRoot = ConfigurationAccessHelper.GetCategoryPropertyByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, "NetworkContext/Separation/BlackList"); list = new List <ContextRule>(); if (piRoot != null) { foreach (CategoryPropertyItem pi in piRoot) { if (string.IsNullOrEmpty(pi.EntryName) || string.IsNullOrEmpty(pi.EntryName.Trim())) { throw new InitializationException("Invalid context rule."); } if (string.IsNullOrEmpty(pi.EntryValue) || string.IsNullOrEmpty(pi.EntryValue.Trim())) { throw new InitializationException("Invalid context rule."); } list.Add(new ContextRule(pi.EntryName, pi.EntryValue)); } } BlackList = list; }
/// <summary> /// Fails the safe start storage provider. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="storageId">The storage id.</param> /// <param name="dataFormatter">The data formatter.</param> /// <param name="compressContent">if set to <c>true</c> [compress content].</param> /// <param name="enableReset">if set to <c>true</c> [enable reset].</param> /// <param name="hasError">if set to <c>true</c> [has error].</param> /// <returns></returns> public static HibernateStorageProvider <T> FailSafeStartStorageProvider <T>(string storageId, IDataFormatter <T> dataFormatter, bool compressContent, bool enableReset, out bool hasError) { HibernateStorageProvider <T> result = null; hasError = false; try { result = new HibernateStorageProvider <T>(storageId, dataFormatter, compressContent); IEnumeratorSpecialized <T> iterator = result.GetEnumerator(); while (iterator.MoveNext()) { // check data consistency } } catch (Exception ex) { if (LOGGER.IsErrorEnabled) { LOGGER.Error(string.Format("NHIBERNATE_STORAGE_PROVIDER, failed to initialize storage provider: '{0}'. Reset allowed: {1}", storageId, enableReset.ToString()), ex); } hasError = true; if (enableReset) { // reset the content of the storage provider CategoryPropertyItem root = ConfigurationAccessHelper.GetCategoryPropertyByPath(StorageConfiguration.Settings.CategoryPropertyItems, "NHibernateProvider"); CategoryPropertyItem removeItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(root.PropertyItems, "KnownStorageIdsToReset"); if (removeItem == null) { removeItem = new CategoryPropertyItem(); removeItem.Id = "KnownStorageIdsToReset"; root.PropertyItems.Add(removeItem); } CategoryPropertyItem storeItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(removeItem.PropertyItems, storageId); if (storeItem == null) { storeItem = new CategoryPropertyItem(); storeItem.Id = storageId; removeItem.PropertyItems.Add(storeItem); try { result = new HibernateStorageProvider <T>(storageId, dataFormatter, compressContent); } finally { removeItem.PropertyItems.Remove(storeItem); } } } else { throw; } } return(result); }
/// <summary> /// Parses the string value. /// </summary> /// <param name="root">The root.</param> /// <param name="entryId">The entry id.</param> /// <param name="defaultValue">The default value.</param> /// <returns>True, if the parse method was succeeded, otherwise False.</returns> protected static String ParseStringValue(CategoryPropertyItem root, String entryId, String defaultValue) { String result = defaultValue; CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(root.PropertyItems, entryId); if (pi != null) { result = pi.EntryValue; } return(result); }
private void SectionHandler_OnConfigurationChanged(object sender, EventArgs e) { CategoryPropertyItem piRoot = ConfigurationAccessHelper.GetCategoryPropertyByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, "NetworkPeering/NAT_Gateways"); List <AddressEndPoint> list = new List <AddressEndPoint>(); if (piRoot != null) { foreach (CategoryPropertyItem pi in piRoot) { list.Add(AddressEndPoint.Parse(pi.EntryValue)); } } EndPoints = list; }
private static void SectionHandler_OnConfigurationChanged(object sender, EventArgs e) { CategoryPropertyItem rootItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemoteDesktopConfiguration.Settings.CategoryPropertyItems, CONFIG_ROOT); if (rootItem != null) { int mouseMoveSendingInterval = Consts.DEFAULT_MOUSE_MOVE_SEND_INTERVAL; if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_MOUSE_MOVE_SEND_INTERVAL, 0, int.MaxValue, ref mouseMoveSendingInterval)) { MouseMoveSendInterval = mouseMoveSendingInterval; } } Raiser.CallDelegatorBySync(EventConfigurationChanged, new object[] { null, EventArgs.Empty }); }
/// <summary> /// Parses the enum value. /// </summary> /// <typeparam name="TEnum">The type of the enum.</typeparam> /// <param name="root">The root.</param> /// <param name="entryId">The entry unique identifier.</param> /// <returns></returns> protected static TEnum ParseEnumValue <TEnum>(CategoryPropertyItem root, String entryId) where TEnum : struct { TEnum result = default(TEnum); CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(root.PropertyItems, entryId); if (pi != null) { try { result = (TEnum)Enum.Parse(typeof(TEnum), pi.EntryValue, true); } catch (Exception) { } } return(result); }
/// <summary> /// Parses the boolean value. /// </summary> /// <param name="root">The root.</param> /// <param name="entryId">The entry id.</param> /// <returns>True, if the parse method was succeeded, otherwise False.</returns> protected static bool ParseBooleanValue(CategoryPropertyItem root, String entryId) { bool result = false; CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(root.PropertyItems, entryId); if (pi != null) { try { result = bool.Parse(pi.EntryValue); } catch (Exception) { } } return(result); }
/// <summary> /// Initializes the <see cref="HibernateStorageProvider<T>"/> class. /// </summary> static HibernateStorageProvider() { SYSTEM_ID = HashGeneratorHelper.GetSHA256BasedValue(ApplicationHelper.ApplicationId); CategoryPropertyItem configItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(StorageConfiguration.Settings.CategoryPropertyItems, "NHibernateProvider/NHibernateStorages/Default"); if (configItem != null) { DEFAULT_SESSION_FACTORY = CreateEntityManagerFactory(configItem); } configItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(StorageConfiguration.Settings.CategoryPropertyItems, "NHibernateProvider/NHibernateStorages/StorageSpecified"); if (configItem != null) { foreach (CategoryPropertyItem pi in configItem) { mSessionFactoriesForStorages.Add(configItem.Id, CreateEntityManagerFactory(configItem)); } } }
private void SectionHandler_OnConfigurationChanged(object sender, EventArgs e) { CategoryPropertyItem piRoot = ConfigurationAccessHelper.GetCategoryPropertyByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, "NetworkPeering/TCP_Connections"); List <ConnectionEntry> list = new List <ConnectionEntry>(); if (piRoot != null) { foreach (CategoryPropertyItem pi in piRoot) { AddressEndPoint address = AddressEndPoint.Parse(pi.EntryValue); bool reConnect = true; int delayValue = 1000; int conTimeout = Timeout.Infinite; string item = ConfigurationAccessHelper.GetValueByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, string.Format("NetworkPeering/TCP_Connections/{0}/ReconnectOnFailure", pi.Id)); if (!string.IsNullOrEmpty(item)) { bool.TryParse(item, out reConnect); } item = ConfigurationAccessHelper.GetValueByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, string.Format("NetworkPeering/TCP_Connections/{0}/DelayBetweenAttempsInMS", pi.Id)); if (!string.IsNullOrEmpty(item)) { int.TryParse(item, out delayValue); if (delayValue < 0) { delayValue = 1000; } } item = ConfigurationAccessHelper.GetValueByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, string.Format("NetworkPeering/TCP_Connections/{0}/ConnectionTimeout", pi.Id)); if (!string.IsNullOrEmpty(item)) { int.TryParse(item, out conTimeout); if (conTimeout < Timeout.Infinite) { conTimeout = Timeout.Infinite; } } list.Add(new ConnectionEntry(address, reConnect, delayValue, conTimeout)); } } EndPoints = list; }
/// <summary> /// Initializes the channel. /// </summary> /// <param name="pi">The pi.</param> public virtual void Initialize(CategoryPropertyItem pi) { DoDisposeCheck(); if (pi == null) { ThrowHelper.ThrowArgumentNullException("pi"); } if (!mInitialized) { { this.mConnectionData = null; CategoryPropertyItem item = ConfigurationAccessHelper.GetCategoryPropertyByPath(pi.PropertyItems, "RemoteAddress"); if (item != null) { this.mConnectionData = AddressEndPoint.Parse(item.EntryValue); } if (item != null) { ConfigurationAccessHelper.ParseLongValue(pi.PropertyItems, "DefaultErrorResponseTimeout", Timeout.Infinite, long.MaxValue, ref mDefaultErrorResponseTimeout); } } { mServerEndpoints.Clear(); CategoryPropertyItem baseAddressesItems = ConfigurationAccessHelper.GetCategoryPropertyByPath(pi.PropertyItems, "BaseAddresses"); if (baseAddressesItems != null) { IEnumerator <CategoryPropertyItem> iterator = baseAddressesItems.GetEnumerator(); while (iterator.MoveNext()) { mServerEndpoints.Add(AddressEndPoint.Parse(iterator.Current.EntryValue)); } } } { mSessionReusable = true; ConfigurationAccessHelper.ParseBooleanValue(pi.PropertyItems, "SessionReusable", ref mSessionReusable); } } }
/// <summary> /// Initializes the specified item. /// </summary> /// <param name="item">The item.</param> public override void Initialize(CategoryPropertyItem item) { base.Initialize(item); this.FilterLogic = GroupFilterLoginEnum.And; mFilters.Clear(); if (item.PropertyItems != null) { GroupFilterLoginEnum logic = GroupFilterLoginEnum.And; if (ConfigurationAccessHelper.ParseEnumValue <GroupFilterLoginEnum>(item.PropertyItems, CONFIG_FILTER_LOGIC, ref logic)) { this.FilterLogic = logic; } CategoryPropertyItem filterItems = ConfigurationAccessHelper.GetCategoryPropertyByPath(item.PropertyItems, CONFIG_FILTERS); if (filterItems != null && filterItems.PropertyItems != null) { foreach (CategoryPropertyItem filterItem in filterItems.PropertyItems) { try { Type filterType = TypeHelper.GetTypeFromString(filterItem.EntryValue, TypeLookupModeEnum.AllowAll, true, true, true); IErrorReportFilter filter = (IErrorReportFilter)filterType.GetConstructor(Type.EmptyTypes).Invoke(new object[] { }); filter.Initialize(filterItem); mFilters.Add(filter); } catch (Exception ex) { if (LOGGER.IsErrorEnabled) { LOGGER.Error(string.Format("GROUP_FILTER, failed to create error report filter. Type: '{0}'", filterItem.EntryValue), ex); } } } } } this.IsInitialized = true; }
private void SectionHandler_OnConfigurationChanged(object sender, EventArgs e) { CategoryPropertyItem piRoot = ConfigurationAccessHelper.GetCategoryPropertyByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, "NetworkPeering/TCPServers/Auto"); List <AddressEndPoint> list = new List <AddressEndPoint>(); if (piRoot != null) { foreach (CategoryPropertyItem pi in piRoot) { list.Add(AddressEndPoint.Parse(pi.EntryValue)); } } EndPoints = list; string value = ConfigurationAccessHelper.GetValueByPath(TerraGrafConfiguration.Settings.CategoryPropertyItems, "NetworkPeering/TCPServers/Auto"); bool boolValue = false; if (!string.IsNullOrEmpty(value)) { bool.TryParse(value, out boolValue); } mAuto = boolValue; }
public static void Save(ConfigurationSaveMode saveMode) { CategoryPropertyItem rootItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemoteDesktopConfiguration.Settings.CategoryPropertyItems, CONFIG_ROOT); if (rootItem == null) { rootItem = new CategoryPropertyItem(); rootItem.Id = CONFIG_ROOT; RemoteDesktopConfiguration.Settings.CategoryPropertyItems.Add(rootItem); } CategoryPropertyItem piMouseMoveSendingInterval = ConfigurationAccessHelper.GetCategoryPropertyByPath(rootItem.PropertyItems, CONFIG_MOUSE_MOVE_SEND_INTERVAL); if (piMouseMoveSendingInterval == null) { piMouseMoveSendingInterval = new CategoryPropertyItem(); piMouseMoveSendingInterval.Id = CONFIG_MOUSE_MOVE_SEND_INTERVAL; rootItem.PropertyItems.Add(piMouseMoveSendingInterval); } piMouseMoveSendingInterval.EntryValue = MouseMoveSendInterval.ToString(); RemoteDesktopConfiguration.Save(saveMode); }
private void btLoadConfig_Click(object sender, EventArgs e) { string configId = lvConfigs.SelectedItems[0].Text; CategoryPropertyItem configItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(TerraGrafTestConfiguration.Settings.CategoryPropertyItems, configId); int i = 0; foreach (CategoryPropertyItem item in configItem) { string domainId = item.Id; string configDir = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configuration"), configId); string configFile = Path.Combine(configDir, item.EntryValue); AppDomainSetup domainInfo = new AppDomainSetup(); domainInfo.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; domainInfo.ConfigurationFile = configFile; domainInfo.ApplicationName = AppDomain.CurrentDomain.SetupInformation.ApplicationName; AppDomain domain = AppDomain.CreateDomain(domainId, AppDomain.CurrentDomain.Evidence, domainInfo); TreeView treeView = new TreeView(); Button btInit = new Button(); Button btDebug = new Button(); ListView lvNetworkConnections = new ListView(); ColumnHeader chNetworkConnections = new ColumnHeader(); Button btDisconnect = new Button(); Button btDisconnectActive = new Button(); CheckBox cbBlackHole = new CheckBox(); Panel pServers = new System.Windows.Forms.Panel(); ListView lvServers = new System.Windows.Forms.ListView(); Button btStartServer = new System.Windows.Forms.Button(); Button btStopServer = new System.Windows.Forms.Button(); ColumnHeader chServers = new System.Windows.Forms.ColumnHeader(); Label lContext = new System.Windows.Forms.Label(); TextBox tbContext = new System.Windows.Forms.TextBox(); Button btSendContext = new System.Windows.Forms.Button(); Label lConnect = new Label(); Button btConnect = new Button(); TextBox tbConnect = new TextBox(); Button btBroadcast = new Button(); Button btUDP = new Button(); Button btTcp = new Button(); Button btSockets = new System.Windows.Forms.Button(); Button btRemoting = new System.Windows.Forms.Button(); Button btEverlight = new System.Windows.Forms.Button(); Button btUpdateWF = new Button(); TabPage page = new TabPage(domainId); //page.Controls.Add(btUpdateWF); //page.Controls.Add(btEverlight); page.Controls.Add(btRemoting); page.Controls.Add(btSockets); page.Controls.Add(btTcp); page.Controls.Add(btUDP); page.Controls.Add(btBroadcast); page.Controls.Add(btConnect); page.Controls.Add(tbConnect); page.Controls.Add(lConnect); page.Controls.Add(btSendContext); page.Controls.Add(tbContext); page.Controls.Add(lContext); page.Controls.Add(pServers); page.Controls.Add(btDisconnectActive); page.Controls.Add(btDisconnect); page.Controls.Add(cbBlackHole); page.Controls.Add(lvNetworkConnections); page.Controls.Add(btDebug); page.Controls.Add(btInit); page.Controls.Add(treeView); page.Location = new System.Drawing.Point(4, 22); page.Size = new System.Drawing.Size(571, 343); page.TabIndex = i + 1; page.Text = domainId; page.UseVisualStyleBackColor = true; page.Tag = domain; cbBlackHole.AutoSize = true; cbBlackHole.Location = new System.Drawing.Point(170, 7); cbBlackHole.Size = new System.Drawing.Size(75, 17); cbBlackHole.TabIndex = 2; cbBlackHole.Text = "BlackHole"; cbBlackHole.UseVisualStyleBackColor = true; cbBlackHole.Enabled = false; cbBlackHole.Tag = domain; // TODO: blackhole értéket kiolvasni cbBlackHole.CheckedChanged += new System.EventHandler(this.cbBlackHole_CheckedChanged); btDisconnect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); btDisconnect.Location = new System.Drawing.Point(230, 283); btDisconnect.Size = new System.Drawing.Size(75, 23); btDisconnect.TabIndex = 1; btDisconnect.Text = "Disconnect"; btDisconnect.UseVisualStyleBackColor = true; btDisconnect.Click += new System.EventHandler(this.btDisconnect_Click); btDisconnectActive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); btDisconnectActive.Location = new System.Drawing.Point(230, 312); btDisconnectActive.Size = new System.Drawing.Size(75, 23); btDisconnectActive.TabIndex = 3; btDisconnectActive.Text = "Dis. Active"; btDisconnectActive.UseVisualStyleBackColor = true; btDisconnectActive.Click += new System.EventHandler(this.btDisconnectActive_Click); treeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); treeView.Location = new System.Drawing.Point(8, 37); treeView.Size = new System.Drawing.Size(216, 298); treeView.TabIndex = 1; treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.TreeView_AfterSelect); btInit.Location = new System.Drawing.Point(8, 3); btInit.Size = new System.Drawing.Size(75, 23); btInit.TabIndex = 0; btInit.Text = "Initialize"; btInit.UseVisualStyleBackColor = true; btInit.Click += new System.EventHandler(this.btInitialize_Click); btDebug.Location = new System.Drawing.Point(89, 3); btDebug.Size = new System.Drawing.Size(75, 23); btDebug.TabIndex = 2; btDebug.Text = "Debug"; btDebug.UseVisualStyleBackColor = true; btDebug.Click += new EventHandler(btDebug_Click); btDebug.Enabled = false; chNetworkConnections.Text = "Id"; chNetworkConnections.Width = 50; lvNetworkConnections.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Right))); lvNetworkConnections.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { chNetworkConnections }); lvNetworkConnections.FullRowSelect = true; lvNetworkConnections.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; lvNetworkConnections.HideSelection = false; lvNetworkConnections.Location = new System.Drawing.Point(230, 37); lvNetworkConnections.MultiSelect = false; lvNetworkConnections.Size = new System.Drawing.Size(75, 240); lvNetworkConnections.TabIndex = 0; lvNetworkConnections.UseCompatibleStateImageBehavior = false; lvNetworkConnections.View = System.Windows.Forms.View.Details; pServers.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); pServers.Controls.Add(btStopServer); pServers.Controls.Add(btStartServer); pServers.Controls.Add(lvServers); pServers.Location = new System.Drawing.Point(311, 37); pServers.Size = new System.Drawing.Size(252, 139); pServers.TabIndex = 4; lvServers.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); lvServers.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { chServers }); lvServers.FullRowSelect = true; lvServers.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; lvServers.HideSelection = false; lvServers.Location = new System.Drawing.Point(3, 3); lvServers.MultiSelect = false; lvServers.Size = new System.Drawing.Size(162, 133); lvServers.TabIndex = 0; lvServers.UseCompatibleStateImageBehavior = false; lvServers.View = System.Windows.Forms.View.Details; lvServers.SelectedIndexChanged += new System.EventHandler(this.lvServers_SelectedIndexChanged); btStartServer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); btStartServer.Location = new System.Drawing.Point(171, 3); btStartServer.Size = new System.Drawing.Size(75, 23); btStartServer.TabIndex = 1; btStartServer.Text = "Start"; btStartServer.UseVisualStyleBackColor = true; btStartServer.Click += new System.EventHandler(this.btStartServer_Click); btStopServer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); btStopServer.Enabled = false; btStopServer.Location = new System.Drawing.Point(171, 32); btStopServer.Size = new System.Drawing.Size(75, 23); btStopServer.TabIndex = 2; btStopServer.Text = "Stop"; btStopServer.UseVisualStyleBackColor = true; btStopServer.Click += new System.EventHandler(this.btStopServer_Click); chServers.Text = "Endpoints"; chServers.Width = 128; lContext.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); lContext.AutoSize = true; lContext.Location = new System.Drawing.Point(314, 183); lContext.Size = new System.Drawing.Size(46, 13); lContext.TabIndex = 5; lContext.Text = "Context:"; tbContext.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); tbContext.Location = new System.Drawing.Point(366, 179); tbContext.Size = new System.Drawing.Size(100, 20); tbContext.TabIndex = 6; btSendContext.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); btSendContext.Location = new System.Drawing.Point(482, 178); btSendContext.Size = new System.Drawing.Size(75, 23); btSendContext.TabIndex = 7; btSendContext.Text = "Send"; btSendContext.UseVisualStyleBackColor = true; btSendContext.Click += new System.EventHandler(this.btSendContext_Click); lConnect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); lConnect.AutoSize = true; lConnect.Location = new System.Drawing.Point(311, 209); lConnect.Size = new System.Drawing.Size(47, 13); lConnect.TabIndex = 8; lConnect.Text = "Connect"; tbConnect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); tbConnect.Location = new System.Drawing.Point(366, 206); tbConnect.Size = new System.Drawing.Size(100, 20); tbConnect.TabIndex = 9; btConnect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); btConnect.Location = new System.Drawing.Point(482, 206); btConnect.Size = new System.Drawing.Size(75, 23); btConnect.TabIndex = 10; btConnect.Text = "Connect"; btConnect.UseVisualStyleBackColor = true; btConnect.Click += new System.EventHandler(this.btConnect_Click); btBroadcast.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); btBroadcast.Location = new System.Drawing.Point(311, 232); btBroadcast.Size = new System.Drawing.Size(75, 23); btBroadcast.TabIndex = 11; btBroadcast.Text = "Broadcast"; btBroadcast.UseVisualStyleBackColor = true; btBroadcast.Click += new System.EventHandler(this.btBroadcast_Click); btUDP.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); btUDP.Location = new System.Drawing.Point(393, 232); btUDP.Size = new System.Drawing.Size(75, 23); btUDP.TabIndex = 12; btUDP.Text = "UDP"; btUDP.UseVisualStyleBackColor = true; btUDP.Click += new System.EventHandler(this.btUDP_Click); btTcp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); btTcp.Location = new System.Drawing.Point(475, 232); btTcp.Size = new System.Drawing.Size(75, 23); btTcp.TabIndex = 13; btTcp.Text = "TCP"; btTcp.UseVisualStyleBackColor = true; btTcp.Click += new System.EventHandler(this.btTcp_Click); btSockets.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); btSockets.Location = new System.Drawing.Point(311, 261); btSockets.Size = new System.Drawing.Size(75, 23); btSockets.TabIndex = 14; btSockets.Text = "Sockets"; btSockets.UseVisualStyleBackColor = true; btSockets.Click += new System.EventHandler(this.btSockets_Click); btRemoting.Location = new System.Drawing.Point(393, 261); btRemoting.Size = new System.Drawing.Size(75, 23); btRemoting.TabIndex = 15; btRemoting.Text = "Remoting"; btRemoting.UseVisualStyleBackColor = true; btRemoting.Click += new System.EventHandler(this.btRemoting_Click); tcDomains.TabPages.Add(page); mTreeViewsById.Add(domainId, treeView); mButtonDebugs.Add(domainId, btDebug); mListViewNetworkConnections.Add(domainId, lvNetworkConnections); mBlackHoleCheckBoxes.Add(domainId, cbBlackHole); mListViewServers.Add(domainId, lvServers); mButtonStartServers.Add(domainId, btStartServer); mButtonStopServers.Add(domainId, btStopServer); mContexts.Add(domainId, tbContext); mConnections.Add(domainId, tbConnect); Wrapper wrapper = (Wrapper)domain.CreateInstanceAndUnwrap(typeof(Wrapper).Assembly.FullName, typeof(Wrapper).FullName); mWrapper.Add(domainId, wrapper); //wrapper.NetworkPeerDiscovered += new EventHandler<NetworkPeerChangedEventArgs>(wrapper_NetworkPeerDiscovered); //wrapper.NetworkPeerDistanceChanged += new EventHandler<NetworkPeerChangedEventArgs>(wrapper_NetworkPeerDistanceChanged); //wrapper.NetworkPeerUnaccessible += new EventHandler<NetworkPeerChangedEventArgs>(wrapper_NetworkPeerUnaccessible); //wrapper.NetworkPeerContextChanged += new EventHandler<NetworkPeerContextEventArgs>(wrapper_NetworkPeerContextChanged); mRootNodes.Add(domainId, new Dictionary <string, TreeNode>()); mPeerNodes.Add(domainId, new Dictionary <string, TreeNode>()); lvServers.Tag = wrapper; btStartServer.Tag = wrapper; btStopServer.Tag = wrapper; btSendContext.Tag = wrapper; btConnect.Tag = wrapper; btBroadcast.Tag = wrapper; btUDP.Tag = wrapper; btTcp.Tag = wrapper; btSockets.Tag = wrapper; btRemoting.Tag = wrapper; btEverlight.Tag = wrapper; btUpdateWF.Tag = wrapper; i++; } btLoadConfig.Enabled = false; lvConfigs.Enabled = false; }
public static void Initialize() { if (!mInitialized) { Raiser.CallDelegatorBySync(EventInitialization, new object[] { null, new ServiceInitializationStateEventArgs(ServiceInitializationStateEnum.Before) }); ChannelServices.Initialize(); if (LOGGER.IsInfoEnabled) { LOGGER.Info("Initializing ServiceBase services."); } CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemotingConfiguration.Settings.CategoryPropertyItems, "Services"); if (pi != null) { IEnumerator <CategoryPropertyItem> iterator = pi.GetEnumerator(); try { while (iterator.MoveNext()) { pi = iterator.Current; if (string.IsNullOrEmpty(pi.Id)) { throw new InvalidConfigurationException("Contract type not definied. Empty item found in configuration."); } Type contractType = null; Type defaultImplementationType = null; try { contractType = TypeHelper.GetTypeFromString(pi.Id); if (ContractDescriptors.ContainsKey(contractType)) { throw new InvalidConfigurationException(String.Format("Duplicated contract type configuration found in services. Contract: {0}", contractType.FullName)); } ContractValidator.ValidateContractIntegrity(contractType); } catch (Exception ex) { throw new InvalidConfigurationValueException(String.Format("Unable to resolve contract type: {0}", pi.Id), ex); } if (!string.IsNullOrEmpty(pi.EntryValue)) { try { defaultImplementationType = TypeHelper.GetTypeFromString(pi.EntryValue); if (!contractType.IsAssignableFrom(defaultImplementationType)) { throw new InvalidProxyImplementationException(String.Format("Provided default implementation type '{0}' does not implement contract interface '{1}'.", defaultImplementationType.FullName, contractType.FullName)); } ImplementationValidator.ValidateImplementationIntegrity(defaultImplementationType); } catch (Exception ex) { throw new InvalidConfigurationValueException(String.Format("Unable to resolve implementation type: {0}", pi.EntryValue), ex); } } ContractServiceSideDescriptor descriptor = new ContractServiceSideDescriptor(contractType, defaultImplementationType); IEnumerator <CategoryPropertyItem> channelIterator = pi.GetEnumerator(); while (channelIterator.MoveNext()) { CategoryPropertyItem channelImplementationItem = channelIterator.Current; if (string.IsNullOrEmpty(channelImplementationItem.Id)) { throw new InvalidConfigurationValueException(String.Format("Channel identifier is missing from a configuration item of the contract '{0}'", pi.Id)); } if (string.IsNullOrEmpty(channelImplementationItem.EntryValue)) { throw new InvalidConfigurationValueException(String.Format("Implementation type is missing from a configuration item of the contract '{0}'", pi.Id)); } if (!ChannelServices.IsChannelRegistered(channelImplementationItem.Id)) { throw new InvalidConfigurationValueException(String.Format("Unregistered channel provided '{0}' in configuration section of the contract: {1}.", channelImplementationItem.Id, pi.Id)); } Type type = null; try { type = TypeHelper.GetTypeFromString(channelImplementationItem.EntryValue); if (!contractType.IsAssignableFrom(type)) { throw new InvalidProxyImplementationException(String.Format("Provided implementation type '{0}' does not implement contract interface '{1}'.", type.FullName, contractType.FullName)); } ImplementationValidator.ValidateImplementationIntegrity(type); } catch (Exception ex) { throw new InvalidConfigurationValueException(String.Format("Unable to resolve non-default implementation type: {0} for contract: {1} for the channel: {2}", channelImplementationItem.EntryValue, pi.Id, channelImplementationItem.Id), ex); } if (descriptor.ImplementationPerChannel.ContainsKey(channelImplementationItem.Id)) { throw new InvalidConfigurationException(String.Format("Duplicated channel identifier at contract '{0}'.", pi.Id)); } descriptor.ImplementationPerChannel.Add(channelImplementationItem.Id, type); } ContractDescriptors.Add(contractType, descriptor); } ChannelServices.StartListeningChannels(); } catch (Exception ex) { ContractDescriptors.Clear(); throw ex; } } mInitialized = true; if (LOGGER.IsInfoEnabled) { LOGGER.Info("ServiceBase services successfully initialized."); } Raiser.CallDelegatorBySync(EventInitialization, new object[] { null, new ServiceInitializationStateEventArgs(ServiceInitializationStateEnum.After) }); } }
private void SectionHandler_OnConfigurationChanged(object sender, EventArgs e) { List <IErrorReportPackageSink> sinks = new List <IErrorReportPackageSink>(); CategoryPropertyItem rootItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(ErrorReportConfiguration.Settings.CategoryPropertyItems, CONFIG_SINKS); if (rootItem != null) { if (rootItem.PropertyItems != null) { foreach (CategoryPropertyItem sinkItem in rootItem.PropertyItems) { try { Type sinkType = TypeHelper.GetTypeFromString(sinkItem.EntryValue, TypeLookupModeEnum.AllowAll, true, true, true); IErrorReportPackageSink sink = (IErrorReportPackageSink)sinkType.GetConstructor(Type.EmptyTypes).Invoke(new object[] { }); sink.Initialize(sinkItem); sinks.Add(sink); } catch (Exception ex) { if (LOGGER.IsErrorEnabled) { LOGGER.Error(string.Format("ERROR_REPORT_SERVICE, failed to create error report sink. Type: '{0}'", sinkItem.EntryValue), ex); } } } } } IErrorReportFilter filter = null; rootItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(ErrorReportConfiguration.Settings.CategoryPropertyItems, CONFIG_FILTER); if (rootItem != null) { try { Type filterType = TypeHelper.GetTypeFromString(rootItem.EntryValue, TypeLookupModeEnum.AllowAll, true, true, true); filter = (IErrorReportFilter)filterType.GetConstructor(Type.EmptyTypes).Invoke(new object[] { }); filter.Initialize(rootItem); } catch (Exception ex) { filter = null; if (LOGGER.IsErrorEnabled) { LOGGER.Error(string.Format("ERROR_REPORT_SERVICE, failed to create error report filter. Type: '{0}'", rootItem.EntryValue), ex); } } } lock (mReportPackageSinks) { mErrorReportFilter = filter; mReportPackageSinks.ForEach(s => s.Close()); mReportPackageSinks.Clear(); mReportPackageSinks.AddRange(sinks); sinks.Clear(); if (LOGGER.IsInfoEnabled) { LOGGER.Info(string.Format("ERROR_REPORT_SERVICE, current active sink(s): {0}", mReportPackageSinks.Count.ToString())); } } }
private static void SectionHandler_OnConfigurationChanged(object sender, EventArgs e) { CategoryPropertyItem rootItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemoteDesktopConfiguration.Settings.CategoryPropertyItems, CONFIG_ROOT); if (rootItem != null) { AuthenticationModeEnum authMode = AuthenticationModeEnum.OnlyPassword; if (ConfigurationAccessHelper.ParseEnumValue <AuthenticationModeEnum>(rootItem.PropertyItems, CONFIG_AUTHENTICATION_MODE, ref authMode)) { AuthenticationMode = authMode; } string moduleStore = string.Empty; if (ConfigurationAccessHelper.ParseStringValue(rootItem.PropertyItems, CONFIG_AUTHENTICATION_MODULE_STORE, ref moduleStore)) { mAuthenticationModuleStore = moduleStore; } bool propagateOnNetwork = true; if (ConfigurationAccessHelper.ParseBooleanValue(rootItem.PropertyItems, CONFIG_PROPAGATE_ON_NETWORK, ref propagateOnNetwork)) { PropagateServiceOnTheNetwork = propagateOnNetwork; } DesktopShareModeEnum desktopShareMode = DesktopShareModeEnum.Shared; if (ConfigurationAccessHelper.ParseEnumValue <DesktopShareModeEnum>(rootItem.PropertyItems, CONFIG_DESKTOP_SHARE_MODE, ref desktopShareMode)) { DesktopShareMode = desktopShareMode; } bool acceptKeyboardAndMouseInputFromClients = true; if (ConfigurationAccessHelper.ParseBooleanValue(rootItem.PropertyItems, CONFIG_ACCEPT_INPUTS_FROM_CLIENTS, ref acceptKeyboardAndMouseInputFromClients)) { AcceptKeyboardAndMouseInputFromClients = acceptKeyboardAndMouseInputFromClients; } int desktopImageClipWidth = Consts.DEFAULT_DESKTOP_IMAGE_CLIP_SIZE; if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_DESKTOP_IMAGE_CLIP_WIDTH, Consts.MINIMAL_CLIP_SIZE, int.MaxValue, ref desktopImageClipWidth)) { DesktopImageClipWidth = desktopImageClipWidth; } int desktopImageClipHeight = Consts.DEFAULT_DESKTOP_IMAGE_CLIP_SIZE; if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_DESKTOP_IMAGE_CLIP_WIDTH, Consts.MINIMAL_CLIP_SIZE, int.MaxValue, ref desktopImageClipHeight)) { DesktopImageClipHeight = desktopImageClipHeight; } int clientsPerServiceThreads = Consts.DEFAULT_CLIENTS_PER_SERVICE_THREADS; if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_DESKTOP_IMAGE_CLIP_WIDTH, Consts.MINIMAL_CLIENTS_PER_SERVICE_THREADS, int.MaxValue, ref clientsPerServiceThreads)) { ClientsPerServiceThreads = clientsPerServiceThreads; } int maximumFailedLoginAttempt = Consts.DEFAULT_MAXIMUM_FAILED_LOGIN_ATTEMPT; if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_MAXIMUM_FAILED_LOGIN_ATTEMPT, 0, int.MaxValue, ref maximumFailedLoginAttempt)) { MaximumFailedLoginAttempt = maximumFailedLoginAttempt; } int blackListTimeout = Consts.DEFAULT_BLACKLIST_TIMEOUT_IN_MINUTES; if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_BLACKLIST_TIMEOUT, 0, int.MaxValue, ref blackListTimeout)) { BlackListTimeout = blackListTimeout; } int imageClipQuality = Consts.DEFAULT_IMAGE_CLIP_QUALITY; if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_IMAGE_CLIP_QUALITY, 10, 100, ref imageClipQuality)) { DefaultImageClipQuality = imageClipQuality; } int mouseMoveSendingInterval = Consts.DEFAULT_MOUSE_MOVE_SEND_INTERVAL; if (ConfigurationAccessHelper.ParseIntValue(rootItem.PropertyItems, CONFIG_MOUSE_MOVE_SEND_INTERVAL, 0, int.MaxValue, ref mouseMoveSendingInterval)) { MouseMoveSendInterval = mouseMoveSendingInterval; } } Raiser.CallDelegatorBySync(EventConfigurationChanged, new object[] { null, EventArgs.Empty }); }
public static void Save(ConfigurationSaveMode saveMode) { CategoryPropertyItem rootItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemoteDesktopConfiguration.Settings.CategoryPropertyItems, CONFIG_ROOT); if (rootItem == null) { rootItem = new CategoryPropertyItem(); rootItem.Id = CONFIG_ROOT; RemoteDesktopConfiguration.Settings.CategoryPropertyItems.Add(rootItem); } CategoryPropertyItem piAuthMode = ConfigurationAccessHelper.GetCategoryPropertyByPath(rootItem.PropertyItems, CONFIG_AUTHENTICATION_MODE); if (piAuthMode == null) { piAuthMode = new CategoryPropertyItem(); piAuthMode.Id = CONFIG_AUTHENTICATION_MODE; rootItem.PropertyItems.Add(piAuthMode); } piAuthMode.EntryValue = AuthenticationMode.ToString(); CategoryPropertyItem piModuleStore = ConfigurationAccessHelper.GetCategoryPropertyByPath(rootItem.PropertyItems, CONFIG_AUTHENTICATION_MODULE_STORE); if (piModuleStore == null) { piModuleStore = new CategoryPropertyItem(); piModuleStore.Id = CONFIG_AUTHENTICATION_MODULE_STORE; rootItem.PropertyItems.Add(piModuleStore); } piModuleStore.EntryValue = AuthenticationModuleStore; CategoryPropertyItem piPropagation = ConfigurationAccessHelper.GetCategoryPropertyByPath(rootItem.PropertyItems, CONFIG_PROPAGATE_ON_NETWORK); if (piPropagation == null) { piPropagation = new CategoryPropertyItem(); piPropagation.Id = CONFIG_PROPAGATE_ON_NETWORK; rootItem.PropertyItems.Add(piPropagation); } piPropagation.EntryValue = PropagateServiceOnTheNetwork.ToString(); CategoryPropertyItem piDesktopShareMode = ConfigurationAccessHelper.GetCategoryPropertyByPath(rootItem.PropertyItems, CONFIG_DESKTOP_SHARE_MODE); if (piDesktopShareMode == null) { piDesktopShareMode = new CategoryPropertyItem(); piDesktopShareMode.Id = CONFIG_DESKTOP_SHARE_MODE; rootItem.PropertyItems.Add(piDesktopShareMode); } piDesktopShareMode.EntryValue = DesktopShareMode.ToString(); CategoryPropertyItem piAcceptInputEvents = ConfigurationAccessHelper.GetCategoryPropertyByPath(rootItem.PropertyItems, CONFIG_ACCEPT_INPUTS_FROM_CLIENTS); if (piAcceptInputEvents == null) { piAcceptInputEvents = new CategoryPropertyItem(); piAcceptInputEvents.Id = CONFIG_ACCEPT_INPUTS_FROM_CLIENTS; rootItem.PropertyItems.Add(piAcceptInputEvents); } piAcceptInputEvents.EntryValue = AcceptKeyboardAndMouseInputFromClients.ToString(); CategoryPropertyItem piDesktopImageClipWidth = ConfigurationAccessHelper.GetCategoryPropertyByPath(rootItem.PropertyItems, CONFIG_DESKTOP_IMAGE_CLIP_WIDTH); if (piDesktopImageClipWidth == null) { piDesktopImageClipWidth = new CategoryPropertyItem(); piDesktopImageClipWidth.Id = CONFIG_DESKTOP_IMAGE_CLIP_WIDTH; rootItem.PropertyItems.Add(piDesktopImageClipWidth); } piDesktopImageClipWidth.EntryValue = DesktopImageClipWidth.ToString(); CategoryPropertyItem piDesktopImageClipHeight = ConfigurationAccessHelper.GetCategoryPropertyByPath(rootItem.PropertyItems, CONFIG_DESKTOP_IMAGE_CLIP_HEIGHT); if (piDesktopImageClipHeight == null) { piDesktopImageClipHeight = new CategoryPropertyItem(); piDesktopImageClipHeight.Id = CONFIG_DESKTOP_IMAGE_CLIP_HEIGHT; rootItem.PropertyItems.Add(piDesktopImageClipHeight); } piDesktopImageClipHeight.EntryValue = DesktopImageClipHeight.ToString(); CategoryPropertyItem piClientsPerServiceThreads = ConfigurationAccessHelper.GetCategoryPropertyByPath(rootItem.PropertyItems, CONFIG_CLIENTS_PER_SERVICE_THREADS); if (piClientsPerServiceThreads == null) { piClientsPerServiceThreads = new CategoryPropertyItem(); piClientsPerServiceThreads.Id = CONFIG_CLIENTS_PER_SERVICE_THREADS; rootItem.PropertyItems.Add(piClientsPerServiceThreads); } piClientsPerServiceThreads.EntryValue = ClientsPerServiceThreads.ToString(); CategoryPropertyItem piMaximumFailedLoginAttempt = ConfigurationAccessHelper.GetCategoryPropertyByPath(rootItem.PropertyItems, CONFIG_MAXIMUM_FAILED_LOGIN_ATTEMPT); if (piMaximumFailedLoginAttempt == null) { piMaximumFailedLoginAttempt = new CategoryPropertyItem(); piMaximumFailedLoginAttempt.Id = CONFIG_MAXIMUM_FAILED_LOGIN_ATTEMPT; rootItem.PropertyItems.Add(piMaximumFailedLoginAttempt); } piMaximumFailedLoginAttempt.EntryValue = MaximumFailedLoginAttempt.ToString(); CategoryPropertyItem piBlackListTimeout = ConfigurationAccessHelper.GetCategoryPropertyByPath(rootItem.PropertyItems, CONFIG_BLACKLIST_TIMEOUT); if (piBlackListTimeout == null) { piBlackListTimeout = new CategoryPropertyItem(); piBlackListTimeout.Id = CONFIG_BLACKLIST_TIMEOUT; rootItem.PropertyItems.Add(piBlackListTimeout); } piBlackListTimeout.EntryValue = BlackListTimeout.ToString(); CategoryPropertyItem piImageClipQuality = ConfigurationAccessHelper.GetCategoryPropertyByPath(rootItem.PropertyItems, CONFIG_IMAGE_CLIP_QUALITY); if (piImageClipQuality == null) { piImageClipQuality = new CategoryPropertyItem(); piImageClipQuality.Id = CONFIG_IMAGE_CLIP_QUALITY; rootItem.PropertyItems.Add(piImageClipQuality); } piImageClipQuality.EntryValue = DefaultImageClipQuality.ToString(); CategoryPropertyItem piMouseMoveSendingInterval = ConfigurationAccessHelper.GetCategoryPropertyByPath(rootItem.PropertyItems, CONFIG_MOUSE_MOVE_SEND_INTERVAL); if (piMouseMoveSendingInterval == null) { piMouseMoveSendingInterval = new CategoryPropertyItem(); piMouseMoveSendingInterval.Id = CONFIG_MOUSE_MOVE_SEND_INTERVAL; rootItem.PropertyItems.Add(piMouseMoveSendingInterval); } piMouseMoveSendingInterval.EntryValue = MouseMoveSendInterval.ToString(); RemoteDesktopConfiguration.Save(saveMode); }
public static void Initialize() { if (!mInitialized) { if (LOGGER.IsInfoEnabled) { LOGGER.Info("Initializing channel services."); } CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemotingConfiguration.Settings.CategoryPropertyItems, "Channels"); if (pi != null) { try { IEnumerator <CategoryPropertyItem> iterator = pi.GetEnumerator(); while (iterator.MoveNext()) { pi = iterator.Current; if (string.IsNullOrEmpty(pi.Id)) { throw new InvalidConfigurationException("Channel id has not been definied."); } if (string.IsNullOrEmpty(pi.EntryValue)) { throw new InvalidConfigurationException("Channel class name has not been definied."); } Channel channel = null; try { if (LOGGER.IsInfoEnabled) { LOGGER.Info(string.Format("Create channel instance from type '{0}'. ChannelId: '{1}'", pi.EntryValue, pi.Id)); } Type cls = TypeHelper.GetTypeFromString(pi.EntryValue); channel = (Channel)cls.GetConstructor(new Type[] { }).Invoke(null); } catch (Exception ex) { throw new InvalidConfigurationValueException(String.Format("Unable to create instance of channel type: {0}", pi.EntryValue), ex); } mChannels.Add(channel); if (LOGGER.IsInfoEnabled) { LOGGER.Info(string.Format("Initializing channel instance, type '{0}'. ChannelId: '{1}'", pi.EntryValue, pi.Id)); } channel.Initialize(pi); //channel.startListening(); } } catch (Exception ex) { // system restoring if (mChannels.Count > 0) { foreach (Channel c in mChannels) { c.StopListening(); c.Dispose(); } mChannels.Clear(); } throw new InitializationException(String.Format("Unable to initialize {0}.", typeof(ChannelServices).Name), ex); } } mInitialized = true; if (LOGGER.IsInfoEnabled) { LOGGER.Info("Channel services successfully initialized."); } } }
public static void Initialize() { if (!mInitialized) { Raiser.CallDelegatorBySync(EventInitialization, new object[] { null, new ServiceInitializationStateEventArgs(ServiceInitializationStateEnum.Before) }); ChannelServices.Initialize(); if (LOGGER.IsInfoEnabled) { LOGGER.Info("Initializing client proxy services."); } CategoryPropertyItem pi = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemotingConfiguration.Settings.CategoryPropertyItems, "Clients"); if (pi != null) { try { IEnumerator <CategoryPropertyItem> iterator = pi.GetEnumerator(); while (iterator.MoveNext()) { pi = iterator.Current; if (string.IsNullOrEmpty(pi.Id)) { throw new InvalidConfigurationException("Contract type not definied. Empty item found in configuration."); } Type contractType = null; String defaultChannelId = null; Type defaultProxyType = null; try { contractType = TypeHelper.GetTypeFromString(pi.Id); if (mContractDescriptors.ContainsKey(contractType)) { throw new InvalidConfigurationException(String.Format("Duplicated contract type configuration found in clients. Contract: {0}", contractType.FullName)); } ContractValidator.ValidateContractIntegrity(contractType); } catch (Exception ex) { throw new InvalidConfigurationValueException(String.Format("Unable to resolve contract type: {0}", pi.Id), ex); } { CategoryPropertyItem defaultChannelIdPropertyItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemotingConfiguration.Settings.CategoryPropertyItems, String.Format("Clients/{0}/Defaults/DefaultChannelId", pi.Id)); if (defaultChannelIdPropertyItem != null) { defaultChannelId = defaultChannelIdPropertyItem.EntryValue; if (string.Empty.Equals(defaultChannelId)) { defaultChannelId = null; } } } { CategoryPropertyItem defaultProxyTypePropertyItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemotingConfiguration.Settings.CategoryPropertyItems, String.Format("Clients/{0}/Defaults/DefaultProxyType", pi.Id)); if (defaultProxyTypePropertyItem != null) { if (defaultProxyTypePropertyItem.EntryValue != null && !string.Empty.Equals(defaultProxyTypePropertyItem.EntryValue)) { try { defaultProxyType = TypeHelper.GetTypeFromString(defaultProxyTypePropertyItem.EntryValue); ImplementationValidator.ValidateProxyIntegration(defaultProxyType); } catch (Exception ex) { throw new InvalidConfigurationValueException(String.Format("Unable to resolve proxy type: {0} for contract: {1}", defaultProxyTypePropertyItem.EntryValue, pi.Id), ex); } } } } if (!(defaultChannelId == null && defaultProxyType == null)) { if (defaultChannelId == null || defaultProxyType == null) { throw new InvalidConfigurationException(String.Format("Both of 'DefaultChannelId' and 'DefaultProxyType' values are must be filled in configuration. Contract type: {0}", pi.Id)); } if (!contractType.IsAssignableFrom(defaultProxyType)) { throw new InvalidProxyImplementationException(String.Format("Provided default proxy type '{0}' does not implement contract interface '{1}'.", defaultProxyType.FullName, contractType.FullName)); } } ContractClientSideDescriptor descriptor = new ContractClientSideDescriptor(contractType, defaultChannelId, defaultProxyType); { CategoryPropertyItem customDefinitionsPropertyItem = ConfigurationAccessHelper.GetCategoryPropertyByPath(RemotingConfiguration.Settings.CategoryPropertyItems, String.Format("Clients/{0}/CustomDefinitions", pi.Id)); if (customDefinitionsPropertyItem != null) { IEnumerator <CategoryPropertyItem> customDefinitionsIterator = customDefinitionsPropertyItem.GetEnumerator(); while (customDefinitionsIterator.MoveNext()) { CategoryPropertyItem channelProxyItem = customDefinitionsIterator.Current; if (string.IsNullOrEmpty(channelProxyItem.Id)) { throw new InvalidConfigurationValueException(String.Format("Channel identifier is missing from a configuration item at the CustomDefinitions of the contract '{0}'", pi.Id)); } if (string.IsNullOrEmpty(channelProxyItem.EntryValue)) { throw new InvalidConfigurationValueException(String.Format("Proxy type is missing from a configuration item at the CustomDefinitions of the contract '{0}'", pi.Id)); } if (!ChannelServices.IsChannelRegistered(channelProxyItem.Id)) { throw new InvalidConfigurationValueException(String.Format("Unregistered channel provided '{0}' in CustomDefinitions configuration section of the contract: {1}.", channelProxyItem.Id, pi.Id)); } Type type = null; try { type = TypeHelper.GetTypeFromString(channelProxyItem.EntryValue); if (!contractType.IsAssignableFrom(type)) { throw new InvalidProxyImplementationException(String.Format("Provided proxy type '{0}' does not implement contract interface '{1}'.", type.FullName, contractType.FullName)); } ImplementationValidator.ValidateProxyIntegration(type); } catch (Exception ex) { throw new InvalidConfigurationValueException(String.Format("Unable to resolve non-default proxy type: {0} for contract: {1} for the channel: {2}", channelProxyItem.EntryValue, pi.Id, channelProxyItem.Id), ex); } if (descriptor.ImplementationPerChannel.ContainsKey(channelProxyItem.Id)) { throw new InvalidConfigurationException(String.Format("Duplicated channel identifier in CustomDefinitions section at contract '{0}'.", pi.Id)); } descriptor.ImplementationPerChannel.Add(channelProxyItem.Id, type); } } } mContractDescriptors.Add(contractType, descriptor); } mSingletonInstance = new ProxyServices(); //if (mContractDescriptors.Count > 0) //{ // mSingletonInstance = new ProxyServices(); //} } catch (Exception ex) { mContractDescriptors.Clear(); throw ex; } } //ChannelServices.startListeningChannels(); mInitialized = true; if (LOGGER.IsInfoEnabled) { LOGGER.Info("Client proxy services successfully initialized."); } Raiser.CallDelegatorBySync(EventInitialization, new object[] { null, new ServiceInitializationStateEventArgs(ServiceInitializationStateEnum.After) }); } }
private static ISessionFactory CreateEntityManagerFactory(SchemaFactoryModeEnum mode, CategoryPropertyItem configItem) { CategoryPropertyItem item = ConfigurationAccessHelper.GetCategoryPropertyByPath(configItem.PropertyItems, "DatabaseManager"); if (item != null && !string.IsNullOrEmpty(item.EntryValue)) { Type databaseManagerType = null; try { databaseManagerType = TypeHelper.GetTypeFromString(item.EntryValue); } catch (Exception ex) { throw new InvalidConfigurationValueException(ex.Message, ex); } if (databaseManagerType != null) { using (IDatabaseManager manager = (IDatabaseManager)databaseManagerType.GetConstructor(Type.EmptyTypes).Invoke(null)) { manager.Initialize(item); Dictionary <string, string> settings = new Dictionary <string, string>(); foreach (CategoryPropertyItem pi in ConfigurationAccessHelper.GetCategoryPropertyByPath(configItem.PropertyItems, "NHibernateSettings")) { settings[pi.Id] = pi.EntryValue; } manager.EnsureDatabaseIntegrity(SYSTEM_ID, settings, mode); } } } string hbm2ddl = "hbm2ddl.auto"; NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration(); cfg.Properties.Clear(); foreach (CategoryPropertyItem pi in ConfigurationAccessHelper.GetCategoryPropertyByPath(configItem.PropertyItems, "NHibernateSettings")) { if (!hbm2ddl.Equals(pi.Id.ToLower())) { cfg.Properties[pi.Id] = pi.EntryValue; } } if (mode == SchemaFactoryModeEnum.Create) { cfg.Properties[hbm2ddl] = "create"; } else if (mode == SchemaFactoryModeEnum.Create_And_Drop) { cfg.Properties[hbm2ddl] = "create-drop"; } HbmSerializer serializer = new HbmSerializer(); serializer.HbmAssembly = typeof(PersistentStorageItem).Assembly.GetName().FullName; serializer.HbmAutoImport = true; serializer.Validate = true; serializer.WriteDateComment = false; serializer.HbmDefaultAccess = "field"; cfg.AddInputStream(serializer.Serialize(typeof(PersistentStorageItem).Assembly)); //cfg.Configure(); if (mode == SchemaFactoryModeEnum.Validate) { SchemaValidator schemaValidator = new SchemaValidator(cfg); schemaValidator.Validate(); // validate the database schema } else if (mode == SchemaFactoryModeEnum.Update) { SchemaUpdate schemaUpdater = new SchemaUpdate(cfg); // try to update schema schemaUpdater.Execute(false, true); if (schemaUpdater.Exceptions.Count > 0) { throw new Exception("FAILED TO UPDATE SCHEMA"); } } return(cfg.BuildSessionFactory()); }