Example #1
0
 /// <summary>
 /// Updates the value of the specified property to the given guid value while setting its data type to System.Guid
 /// </summary>
 /// <param name="store">Extending class</param>
 /// <param name="collectionPath">Path of the collection of the property</param>
 /// <param name="propertyName">Name of the property</param>
 /// <param name="value">Value of the property</param>
 public static void SetGuid(this WritableSettingsStore store, string collectionPath, string propertyName, Guid?value)
 {
     if (value == null)
     {
         store.DeletePropertyIfExists(collectionPath, propertyName);
     }
     else
     {
         store.SetString(collectionPath, propertyName, value.ToString());
     }
 }
Example #2
0
        /// <summary>
        /// Writes Crm Connection to settings store
        /// </summary>
        /// <param name="crmConnections">Crm Connections to write to settings store</param>
        private void SetCrmConnections(CrmConnections crmConnections)
        {
            if (crmConnections?.Connections == null)
            {
                _settingsStore.DeletePropertyIfExists(CollectionPath, ConnectionsPropertyName);
                return;
            }
            Dictionary <Guid, string> passwordCache = new Dictionary <Guid, string>();

            foreach (var connection in crmConnections.Connections)
            {
                if (connection.ConnectionId != null && !passwordCache.ContainsKey(connection.ConnectionId.Value))
                {
                    passwordCache.Add(connection.ConnectionId.Value, connection.UserPassword);
                }

                if (!string.IsNullOrEmpty(connection.UserPassword) && connection.SavePassword)
                {
                    connection.UserPassword = EncryptString(connection.UserPassword);
                }
                else
                {
                    connection.UserPassword = null;
                }
            }

            var connectionsXml = XmlSerializerHelper.Serialize(crmConnections.Connections);

            _settingsStore.SetString(CollectionPath, ConnectionsPropertyName, connectionsXml);
            _settingsStore.SetBoolean(CollectionPath, AutoPublishPropertyName, crmConnections.PublishAfterUpload);
            _settingsStore.SetBoolean(CollectionPath, IgnoreExtensionsProprtyName, crmConnections.IgnoreExtensions);
            _settingsStore.SetBoolean(CollectionPath, ExtendedLogProprtyName, crmConnections.ExtendedLog);

            foreach (var connection in crmConnections.Connections)
            {
                if (connection.ConnectionId != null && passwordCache.ContainsKey(connection.ConnectionId.Value))
                {
                    connection.UserPassword = passwordCache[connection.ConnectionId.Value];
                }
            }
        }