Example #1
0
        public void PutSettingsValues(SettingsGroupDescriptor group, string user, string instanceKey,
                                      Dictionary <string, string> dirtyValues)
        {
            using (var context = new DataAccessContext())
            {
                // next we obtain any previously stored configuration document for this settings group
                var documentKey = new ConfigurationDocumentKey(group.Name, group.Version, user, instanceKey);
                var broker      = context.GetConfigurationDocumentBroker();

                var values = new Dictionary <string, string>();
                var parser = new SettingsParser();

                var document = broker.GetConfigurationDocument(documentKey);
                if (document == null)
                {
                    document = new ConfigurationDocument
                    {
                        CreationTime          = Platform.Time,
                        DocumentName          = group.Name,
                        DocumentVersionString = VersionUtils.ToPaddedVersionString(group.Version, false, false),
                        User         = user,
                        DocumentText = string.Empty
                    };
                    broker.AddConfigurationDocument(document);
                }
                else
                {
                    // parse document
                    parser.FromXml(document.DocumentText, values);
                }

                // update the values that have changed
                foreach (var kvp in dirtyValues)
                {
                    values[kvp.Key] = kvp.Value;
                }

                try
                {
                    if (values.Count > 0)
                    {
                        // generate the document, update local cache and server
                        document.DocumentText = parser.ToXml(values);
                        context.Commit();
                    }
                }
                catch (EndpointNotFoundException e)
                {
                    Platform.Log(LogLevel.Debug, e, "Unable to save settings to configuration service.");
                }
            }
        }
 /// <summary>
 /// Insert a ConfigurationDocument
 /// </summary>
 /// <param name="entity"></param>
 public void AddConfigurationDocument(ConfigurationDocument entity)
 {
     Context.ConfigurationDocuments.InsertOnSubmit(entity);
 }
Example #3
0
 partial void UpdateConfigurationDocument(ConfigurationDocument instance);
Example #4
0
 partial void DeleteConfigurationDocument(ConfigurationDocument instance);
Example #5
0
 partial void InsertConfigurationDocument(ConfigurationDocument instance);