Inheritance: SettingsBase, ILoggingSettings
        public void Init(XElement xml)
        {
            if(xml == null)
            {
                Version = new Version(1, 0);
                Logging = new LoggingSettings(WebServerUri);
                Security = new SecuritySettings(WebServerUri);
                Backup = new BackupSettings(WebServerUri);
            }
            else
            {
                WebServerUri = xml.AttributeSafe("WebServerUri");
                Version = new Version(xml.AttributeSafe("Version"));
                Logging = new LoggingSettings(xml.Element(LoggingSettings.SettingName), WebServerUri);
                Security = new SecuritySettings(xml.Element(SecuritySettings.SettingName), WebServerUri);
                Backup = new BackupSettings(xml.Element(BackupSettings.SettingName), WebServerUri);
            }

            Logging.PropertyChanged += SettingChanged;
            Security.PropertyChanged += SettingChanged;
            Backup.PropertyChanged += SettingChanged;

            NotifyOfPropertyChange(() => HasChanges);
        }
        public static void UpdateSettings(LoggingSettings loggingSettings)
        {
            Task.Run(() =>
            {
                LoggingSettings = loggingSettings;

                EnableLogOutput = LoggingSettings.IsLoggingEnabled;

                //Unnecessary to continue if logging is turned off
                if (!EnableLogOutput)
                {
                    return;
                }

                var dirPath = GetDirectoryPath(LoggingSettings);
                var dirExists = Directory.Exists(dirPath);
                if (!dirExists)
                {
                    Directory.CreateDirectory(dirPath);
                }

                _workflowsToLog = new Dictionary<Guid, string>();
                foreach (var wf in LoggingSettings.Workflows)
                {
                    _workflowsToLog.Add(Guid.Parse(wf.ResourceID), wf.ResourceName);
                }

            });
        }
Esempio n. 3
0
        public void ToXmlSerializesCorrectly()
        {
            var logging = new LoggingSettings("localhost");

            logging.ServiceInput = "TestInput";
            logging.LogFileDirectory = "TestDir";
            logging.LogAll = true;
            logging.NestedLevelCount = 2;
            logging.IsOutputLogged = true;
            logging.IsInputLogged = true;
            logging.IsDataAndTimeLogged = true;
            logging.IsDurationLogged = true;
            logging.IsTypeLogged = true;
            logging.IsVersionLogged = true;
            logging.IsLoggingEnabled = true;
            var workflow = new WorkflowDescriptor(XmlResource.Fetch("Workflow"));
            logging.Workflows.Add(workflow);
            logging.PostWorkflow = workflow;

            var actual = logging.ToXml().ToString();
            var expected = XmlResource.Fetch("LoggingSettings").ToString();
            Assert.AreEqual(actual, expected);
        }
Esempio n. 4
0
        public void Init(XElement xml)
        {
            if (xml == null)
            {
                Version  = new Version(1, 0);
                Logging  = new LoggingSettings(WebServerUri);
                Security = new SecuritySettings(WebServerUri);
                Backup   = new BackupSettings(WebServerUri);
            }
            else
            {
                WebServerUri = xml.AttributeSafe("WebServerUri");
                Version      = new Version(xml.AttributeSafe("Version"));
                Logging      = new LoggingSettings(xml.Element(LoggingSettings.SettingName), WebServerUri);
                Security     = new SecuritySettings(xml.Element(SecuritySettings.SettingName), WebServerUri);
                Backup       = new BackupSettings(xml.Element(BackupSettings.SettingName), WebServerUri);
            }

            Logging.PropertyChanged  += SettingChanged;
            Security.PropertyChanged += SettingChanged;
            Backup.PropertyChanged   += SettingChanged;

            NotifyOfPropertyChange(() => HasChanges);
        }
 private static ILoggingSettings GetSettingsObject(IEnumerable<IWorkflowDescriptor> workflows = null)
 {
     var settings = new LoggingSettings("InvalidUri");
     if(workflows != null)
     {
         workflows.ToList().ForEach(wf => settings.Workflows.Add(wf));
     }
     return settings;
 }
        public void LoggingSettingsWithRunPostWorkflowSetButInvalidPostWorkflowSelectedReturnsError()
        {
            var logging = new LoggingSettings(XmlResource.Fetch("LoggingSettings"), "localhost");

            logging.PostWorkflow = new WorkflowDescriptor
                {
                    ResourceID = Guid.NewGuid().ToString(),
                    ResourceName = "Fail"
                };

            var vm = GetVM(logging.Workflows.Cast<WorkflowDescriptor>());

            vm.Object = logging;

            vm.RunPostWorkflow = true;

            var errorResult = vm["PostWorkflowName"];
            Assert.AreEqual(errorResult, "Invalid workflow selected");
            Assert.AreEqual(vm.Error, "Invalid workflow selected");
        }
        public void LoggingSettingsWithValidRunPostWorkflowReturnsNoError()
        {
            var logging = new LoggingSettings(XmlResource.Fetch("LoggingSettings"), "localhost");

            logging.PostWorkflow = logging.Workflows.First(wf => wf.ResourceID == logging.PostWorkflow.ResourceID);

            var vm = GetVM(logging.Workflows.Cast<WorkflowDescriptor>());
            vm.Object = logging;

            var errorResult = vm["PostWorkflowName"];
            Assert.AreEqual(errorResult, "");
            Assert.AreEqual(vm.Error, "");
        }
        [ExcludeFromCodeCoverage] // wf debug logging
        public static string GetDirectoryPath(LoggingSettings loggingSettings)
        {
            var dirPath = loggingSettings.LogFileDirectory;

            if (String.IsNullOrWhiteSpace(dirPath))
            {
                dirPath = GetDefaultLogDirectoryPath();
            }
            return dirPath;
        }