Пример #1
0
        public SettingsCollection GetDefaultVersionSettings()
        {
            SettingsCollection collection = new SettingsCollection();

            Setting <string> baseUrl = new Setting <string>();

            baseUrl.Key         = "BaseUrl";
            baseUrl.Name        = "Base URL";
            baseUrl.Description = "Base url of the website for the manual.\nPage urls will be appended to this value.";
            baseUrl.Validator   = new UrlValidator();

            collection.TextSettings.Add(baseUrl);

            MultipleChoiceSetting browserSetting = new MultipleChoiceSetting();

            browserSetting.Key         = "BrowserType";
            browserSetting.Name        = "Browser";
            browserSetting.Description = "The browser to use for this version.\n\nFor all browsers:\nThe browser MUST be installed localy on the system.";
            browserSetting.Choices     = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("Chrome", "chrome"),
                new KeyValuePair <string, string>("Firefox", "firefox"),
            };
            browserSetting.Value = "chrome";
            collection.Name      = GetProjectTypeName();
            collection.MultipleChoiceSettings.Add(browserSetting);
            return(collection);
        }
Пример #2
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     if (edit)
     {
         cbbType.SelectedValue      = WebAction.Id;
         parameters                 = WebAction.Parameters;
         btnSetParameters.IsEnabled = parameters == null;
         if (WebAction.Type == Interpic.Models.Behaviours.Action.ActionType.Check)
         {
             CheckAction checkWebAction = WebAction as CheckAction;
             cbbBehaviourWhenFalse.SelectedItem = checkWebAction.BehaviourWhenFalse;
             cbbBehaviourWhenTrue.SelectedItem  = checkWebAction.BehaviourWhenTrue;
         }
         else
         {
             cbbBehaviourWhenFalse.IsEnabled = false;
             cbbBehaviourWhenTrue.IsEnabled  = false;
         }
     }
     else
     {
         cbbBehaviourWhenFalse.SelectedIndex = 0;
         cbbBehaviourWhenTrue.SelectedIndex  = 0;
         cbbType.SelectedIndex = 0;
     }
 }
Пример #3
0
        protected override SettingsCollection createSettings(SettingsCollection settings)
        {
            settings.Add(new Setting("sermon_folder"));
            settings.Add(new Setting("folder_format",Path.Combine("YYYY", "MM", "DD")));

            return settings;
        }
Пример #4
0
        public Backend(InstanceType instanceType, AppType appType)
        {
            settingsCollection  = SettingsCollectionSerializer.DeSerialize();
            trackUsage          = new TrackUsage(settingsCollection.AppSettings, settingsCollection.InternalSettings, instanceType, appType);
            versionControl      = new VersionControl(instanceType, appType, trackUsage);
            jiraTimerCollection = new JiraTimerCollection(settingsCollection.ExportSettings);
            jiraTimerCollection.exportPrompt += OnExportPromptEvent;
            jiraConnection                   = new JiraConnection(trackUsage);
            idleTimerCollection              = new IdleTimerCollection();
            ActivityChecker                  = new ActivityChecker(jiraTimerCollection, settingsCollection.AppSettings);
            ActivityChecker.NoActivityEvent += OnNoActivityEvent;
            hearbeat          = new Timer(1800000);
            hearbeat.Elapsed += HearbeatOnElapsed;
            hearbeat.Start();

            if (Settings.AppSettings.TimerRunningOnShutdown.HasValue)
            {
                var timer = jiraTimerCollection.GetTimer(Settings.AppSettings.TimerRunningOnShutdown.Value);
                if (timer != null && timer.DateStarted.Date == DateTime.Now.Date)
                {
                    JiraTimerCollection.StartTimer(Settings.AppSettings.TimerRunningOnShutdown.Value);
                }

                Settings.AppSettings.TimerRunningOnShutdown = null;
                SaveSettings(false);
            }

            HearbeatOnElapsed(this, null);
        }
Пример #5
0
        public void RenderVideoWEffects()
        {
#if DEBUG
            ResourceManagement.CommandConfiguration = CommandConfiguration.Create(
                "c:/source/ffmpeg/bin/temp",
                "c:/source/ffmpeg/bin/ffmpeg.exe",
                "c:/source/ffmpeg/bin/ffprobe.exe");

            var outputSettings = SettingsCollection.ForOutput(
                new OverwriteOutput(),
                new CodecVideo(VideoCodecType.Libx264),
                new BitRateVideo(3000),
                new BitRateTolerance(3000),
                new FrameRate(30));

            var factory = CommandFactory.Create();

            factory.CreateOutputCommand()
            .WithInput <VideoStream>(Assets.Utilities.GetVideoFile())
            .WithInput <VideoStream>(Assets.Utilities.GetVideoFile())
            .Filter(new CrossfadeConcatenate(1))
            .MapTo <Mp4>("c:/source/ffmpeg/bin/temp/output-test.mp4", outputSettings);

            factory.Render();
#endif
        }
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigViewModel"/> class.
        /// </summary>
        /// <param name="settingsFilename">Path to file containing settings for this.</param>
        public ConfigViewModel(string settingsFilename)
        {
            _settingSource = SettingsCollection.FromFile(settingsFilename);

            if (!object.ReferenceEquals(null, _settingSource))
            {
                try
                {
                    SettingItems = _settingSource.Items.Select(x => SettingsItemConverter(x)).ToList();
                }
                catch (Exception ex)
                {
                    SettingItems = new List <IConfigSetting>();

                    Workspace.RecreateSingletonWindow <ErrorWindow>(new ErrorWindowViewModel(ex)
                    {
                        HeaderMessage = "Error loading config settings",
                    });

                    return;
                }
            }

            CancelCommand = new RelayCommand <ICloseable>(CloseWindow);

            OkCommand = new RelayCommand <ICloseable>(w =>
            {
                SaveChanges();
                CloseWindow(w);
            });
        }
		protected ConfigurationManager (string name)
		{
			settings = new SettingsCollection {help, version, verbose, printlog,
			logFile, configFile, this.name,
			loglevels};
			this.name.MaybeUpdate (SettingSource.Default, name);
		}
Пример #8
0
        private void UpdateDisplay()
        {
            StringBuilder sb = new StringBuilder();

            var items = SettingsCollection.Where(e => e.IsModified);

            foreach (var item in items)
            {
                sb.Append(item.Label.ToUpper());

                if (item is StringSetting)
                {
                    StringSetting ss = item as StringSetting;
                    sb.Append(": ");
                    sb.Append(ss.TextValue);
                }
                else
                {
                    BooleanSetting bs = item as BooleanSetting;
                    if (bs.IsChecked)
                    {
                        sb.Append(": Checked");
                    }
                    else
                    {
                        sb.Append(": Unchecked");
                    }
                }
                sb.Append(Environment.NewLine);
            }

            Display = sb.ToString();
        }
Пример #9
0
        public static void Run()
        {
            //set up ffmpeg command configuration with locations of default output folders, ffmpeg, and ffprobe.
            ResourceManagement.CommandConfiguration = CommandConfiguration.Create(
                @"c:\source\ffmpeg\bin\temp",
                @"c:\source\ffmpeg\bin\ffmpeg.exe",
                @"c:\source\ffmpeg\bin\ffprobe.exe");

            //create a factory
            var factory = CommandFactory.Create();

            //create a command adding a two audio and video files
            var command = factory.CreateOutputCommand()
                          .AddInput(Assets.Utilities.GetVideoFile())
                          .AddInput(Assets.Utilities.GetVideoFile())
                          .AddInput(Assets.Utilities.GetAudioFile())
                          .AddInput(Assets.Utilities.GetAudioFile());

            //select the first two video streams and run concat filter
            var videoConcat = command.Select(command.Take(0), command.Take(1))
                              .Filter(Filterchain.FilterTo <VideoStream>(new Filters.Concat()));

            //select the first two audio streams and run concat filter
            var audioConcat = command.Select(command.Take(2), command.Take(3))
                              .Filter(Filterchain.FilterTo <VideoStream>(new Filters.Concat(1, 0)));

            command.Select(audioConcat, videoConcat)
            .MapTo <Mp4>(@"c:\source\ffmpeg\bin\temp\foo.mp4", SettingsCollection.ForOutput(new OverwriteOutput()));

            //render the output
            factory.Render();
        }
Пример #10
0
        public static void Run()
        {
            //set up ffmpeg command configuration with locations of default output folders, ffmpeg, and ffprobe.
            ResourceManagement.CommandConfiguration = CommandConfiguration.Create(
                @"c:\source\ffmpeg\bin\temp",
                @"c:\source\ffmpeg\bin\ffmpeg.exe",
                @"c:\source\ffmpeg\bin\ffprobe.exe");

            //create a factory
            var factory = CommandFactory.Create();

            //create a command adding a video and audio file
            var command = factory.CreateOutputCommand()
                          .AddInput(Assets.Utilities.GetVideoFile())
                          .AddInput(Assets.Utilities.GetAudioFile());

            //select the first two streams from the input command
            var splitVideo = command.Take(0)
                             .Filter(Filterchain.FilterTo <VideoStream>(new Split(2)));
            var splitAudio = command.Take(1)
                             .Filter(Filterchain.FilterTo <AudioStream>(new ASplit(2)));

            //map the first audio and video stream to the output
            command.Select(splitVideo.Take(0), splitAudio.Take(0))
            .MapTo <Mp4>(@"c:\source\ffmpeg\bin\temp\foo.mp4", SettingsCollection.ForOutput(new OverwriteOutput()));
            command.Select(splitVideo.Take(1), splitAudio.Take(1))
            .MapTo <Mp4>(@"c:\source\ffmpeg\bin\temp\bar.mp4", SettingsCollection.ForOutput(new OverwriteOutput()));

            //render the output
            factory.Render();
        }
Пример #11
0
        public void Test_SettingsCollection_Constructor_Int()
        {
            // ReSharper disable once CollectionNeverUpdated.Local
            var sut = new SettingsCollection(20);

            Assert.True(sut.Count == 0);
        }
Пример #12
0
        public void RunOrganicProfile(int accountID, int profileID)
        {
            List <string> serviceNames = new List <string>();


            using (DataManager.Current.OpenConnection())
            {
                // TODO: get names of services as single-column result arrray
                SqlCommand cmd = DataManager.CreateCommand("select distinct SE.ServiceName from dbo.User_GUI_SerpProfileSearchEngine PSE inner join Constant_SearchEngine SE on PSE.Search_Engine_ID = SE.Search_Engine_ID where account_id = @AccountID:Int and Profile_ID = @ProfileID:Int");
                cmd.Parameters["@AccountID"].Value = accountID;
                cmd.Parameters["@ProfileID"].Value = profileID;

                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        serviceNames.Add(reader[0] as string);
                    }
                }
            }

            SettingsCollection settings = new SettingsCollection();

            settings.Add("ProfileID", profileID.ToString());

            using (ServiceClient <IScheduleManager> client = new ServiceClient <IScheduleManager>())
            {
                foreach (string serviceName in serviceNames)
                {
                    // Request the manager to build the schedule
                    client.Service.AddToSchedule(serviceName, accountID, DateTime.Now, settings);
                }
            }
        }
Пример #13
0
        public void SettingsCollection_MergeRange()
        {
            var startAtDefault           = new SeekPositionInput(2);
            var vcodecDefault            = new CodecVideo(VideoCodecType.Copy);
            var settingsCollectionI      = SettingsCollection.ForInput(new SeekPositionInput(1));
            var settingsCollectionO      = SettingsCollection.ForOutput(new CodecVideo(VideoCodecType.Libx264));
            var settingsCollectionMergeI = SettingsCollection.ForInput(startAtDefault);
            var settingsCollectionMergeO = SettingsCollection.ForOutput(vcodecDefault);


            Assert.Throws <ArgumentException>(() => settingsCollectionI.MergeRange(settingsCollectionMergeO, FFmpegMergeOptionType.OldWins));
            Assert.Throws <ArgumentException>(() => settingsCollectionO.MergeRange(settingsCollectionMergeI, FFmpegMergeOptionType.OldWins));
            Assert.Throws <ArgumentException>(() => settingsCollectionI.MergeRange(settingsCollectionMergeO, FFmpegMergeOptionType.NewWins));
            Assert.Throws <ArgumentException>(() => settingsCollectionO.MergeRange(settingsCollectionMergeI, FFmpegMergeOptionType.NewWins));

            settingsCollectionI.MergeRange(settingsCollectionMergeI, FFmpegMergeOptionType.OldWins);
            settingsCollectionO.MergeRange(settingsCollectionMergeO, FFmpegMergeOptionType.OldWins);

            var startAtSetting = settingsCollectionI.Items[0] as SeekPositionInput;
            var vcodecSetting  = settingsCollectionO.Items[0] as CodecVideo;

            Assert.False(startAtSetting != null && startAtSetting.Length == startAtDefault.Length);
            Assert.False(vcodecSetting != null && vcodecSetting.Codec == vcodecDefault.Codec);

            settingsCollectionI.MergeRange(settingsCollectionMergeI, FFmpegMergeOptionType.NewWins);
            settingsCollectionO.MergeRange(settingsCollectionMergeO, FFmpegMergeOptionType.NewWins);

            startAtSetting = settingsCollectionI.Items[0] as SeekPositionInput;
            vcodecSetting  = settingsCollectionO.Items[0] as CodecVideo;
            Assert.True(startAtSetting != null && startAtSetting.Length == startAtDefault.Length);
            Assert.True(vcodecSetting != null && vcodecSetting.Codec == vcodecDefault.Codec);
        }
Пример #14
0
        public static void Run()
        {
            //set up ffmpeg command configuration with locations of default output folders, ffmpeg, and ffprobe.
            ResourceManagement.CommandConfiguration = CommandConfiguration.Create(
                @"c:\source\ffmpeg\bin\temp",
                @"c:\source\ffmpeg\bin\ffmpeg.exe",
                @"c:\source\ffmpeg\bin\ffprobe.exe");

            //create a factory
            var factory = CommandFactory.Create();

            //set up the output and input settings
            var inputSettings  = SettingsCollection.ForInput(new SeekPositionInput(1d));
            var outputSettings = SettingsCollection.ForOutput(
                new BitRateVideo(3000),
                new DurationOutput(10d));

            //create a command adding a two audio files
            var command = factory.CreateOutputCommand();

            var output = command.WithInput <VideoStream>(Utilities.GetVideoFile(), inputSettings)
                         .To <Mp4>(@"c:\source\ffmpeg\bin\temp\foo.mp4", outputSettings)
                         .First();

            //use the metadata helper calculation engine to determine a snapshot of what the output duration should be.
            var metadataInfo = MetadataHelpers.GetMetadataInfo(command, output.GetStreamIdentifier());

            System.Console.ForegroundColor = ConsoleColor.DarkMagenta;
            Console.WriteLine("Metadata snapshot:");
            Console.WriteLine(string.Format("Duration: {0}", metadataInfo.VideoStream.VideoMetadata.Duration));
            Console.WriteLine(string.Format("Has Video: {0}", metadataInfo.HasVideo));
            Console.WriteLine(string.Format("Has Audio: {0}", metadataInfo.HasAudio));
            System.Console.ForegroundColor = ConsoleColor.White;
        }
Пример #15
0
        private void BtnBuildSettings_Click(object sender, RoutedEventArgs e)
        {
            SettingsEditor editor = new SettingsEditor(buildSettings);

            editor.ShowDialog();
            buildSettings = editor.SettingsCollection;
        }
Пример #16
0
            protected int SetProperty(string collectionPath, string propertyName, object value, Type type)
            {
                SettingsCollection collection = GetOrCreateSettingsCollection(collectionPath);

                collection.SetProperty(propertyName, value, type);
                return(VSConstants.S_OK);
            }
Пример #17
0
 private void BindingData()
 {
     try
     {
         SettingsCollection col = null;
         col = this.LoadData(txtSearch.Text.Trim());
         if (col == null)
         {
             col                = new SettingsCollection();
             lblcount.Text      = "Có 0" + " record";
             rptData.DataSource = col;
             rptData.DataBind();
         }
         else
         {
             lblcount.Text          = "Có " + col.Count.ToString() + " record";
             lblcount.ForeColor     = System.Drawing.Color.Blue;
             anpPager.RecordCount   = col.Count;
             anpPager.PageSize      = Convert.ToInt32(ddlPageSize.SelectedValue);
             anpPager.ShowFirstLast = false;
             col = this.GetSubData(col, anpPager.StartRecordIndex - 1, anpPager.EndRecordIndex);
             rptData.DataSource = col;
             rptData.DataBind();
         }
     }
     catch (Exception ex)
     {
         Global.WriteLogError("BindingData()" + ex);
     }
 }
        protected override Core.Services.ServiceOutcome DoPipelineWork()
        {
            string serviceName = Instance.Configuration.Options["ServiceToRun"];

            if (String.IsNullOrWhiteSpace(serviceName))
            {
                throw new ConfigurationErrorsException("ServiceToRun parameter is not defined on Rerun service.", Instance.Configuration.ElementInformation.Source, Instance.Configuration.ElementInformation.LineNumber);
            }

            using (ServiceClient <IScheduleManager> scheduleManager = new ServiceClient <IScheduleManager>())
            {
                DateTime fromDate = this.TargetPeriod.Start.ToDateTime();
                DateTime toDate   = this.TargetPeriod.End.ToDateTime();



                while (fromDate <= toDate)
                {
                    // {start: {base : '2009-01-01', h:0}, end: {base: '2009-01-01', h:'*'}}
                    var subRange = new DateTimeRange()
                    {
                        Start = new DateTimeSpecification()
                        {
                            BaseDateTime = fromDate,
                            Hour         = new DateTimeTransformation()
                            {
                                Type = DateTimeTransformationType.Exact, Value = 0
                            },
                            Alignment = DateTimeSpecificationAlignment.Start
                        },
                        End = new DateTimeSpecification()
                        {
                            BaseDateTime = fromDate,
                            Hour         = new DateTimeTransformation()
                            {
                                Type = DateTimeTransformationType.Max
                            },
                            Alignment = DateTimeSpecificationAlignment.End
                        }
                    };

                    SettingsCollection options = new SettingsCollection();
                    options.Add(PipelineService.ConfigurationOptionNames.TargetPeriod, subRange.ToAbsolute().ToString());
                    options.Add(PipelineService.ConfigurationOptionNames.ConflictBehavior, DeliveryConflictBehavior.Ignore.ToString());
                    foreach (var option in Instance.Configuration.Options)
                    {
                        if (!options.ContainsKey(option.Key))
                        {
                            options.Add(option.Key, option.Value);
                        }
                    }
                    //run the service
                    scheduleManager.Service.AddToSchedule(serviceName, this.Instance.AccountID, DateTime.Now, options);

                    fromDate = fromDate.AddDays(1);
                }
            }

            return(Core.Services.ServiceOutcome.Success);
        }
        private void RunCommitServices(List <ValidationResult> repairList)
        {
            SettingsCollection _options = new SettingsCollection();

            foreach (ValidationResult itemToFix in repairList)
            {
                DateTimeRange _dateTimeRange    = new DateTimeRange();
                string        TargetPeriodStart = String.Empty;
                string        TargetPeriodEnd   = String.Empty;

                _dateTimeRange.Start = DateTimeSpecification.Parse(itemToFix.TargetPeriodStart.ToString());
                _dateTimeRange.End   = DateTimeSpecification.Parse(itemToFix.TargetPeriodEnd.ToString());

                string serviceName = Const.AdMetricsConst.WorkflowServices.CommitServiceName;
                ServiceClient <IScheduleManager> scheduleManager = new ServiceClient <IScheduleManager>();

                _options.Add("ConflictBehavior", "Ignore");
                _options.Add("DeliveryID", itemToFix.DeliveryID.ToString());

                //Run Service
                _options.Add(PipelineService.ConfigurationOptionNames.TimePeriod, _dateTimeRange.ToAbsolute().ToString());

                //bool result = _listner.FormAddToSchedule(serviceName, -1, DateTime.Now, _options, ServicePriority.Normal);
                //if (!result)
                //{
                //    MessageBox.Show(string.Format("Service {0} for account {1} did not run", serviceName, -1));
                //}
            }
        }
Пример #20
0
        private static void LoadDefaulGlobalSettings()
        {
            DefaultGlobalSettings      = new SettingsCollection();
            DefaultGlobalSettings.Name = "global settings";

            Setting <int> autosaveWarning = new Setting <int>();

            autosaveWarning.Name        = "Save warning";
            autosaveWarning.Key         = "SaveWarningOffset";
            autosaveWarning.Description = "Amount of minutes after Interpic Studio colors the last saved text red when there are unsaved changes.";
            autosaveWarning.Value       = 5;

            Setting <bool> showInfoOnAutomaticSettingsDialog = new Setting <bool>();

            showInfoOnAutomaticSettingsDialog.Name        = "Show info message about settings.";
            showInfoOnAutomaticSettingsDialog.Description = "Show an info message when the settings dialog for a project, page, section or control is automatically opened.";
            showInfoOnAutomaticSettingsDialog.Value       = true;
            showInfoOnAutomaticSettingsDialog.Key         = "ShowInfoForSettings";

            Setting <bool> showHomeTabOnStartup = new Setting <bool>();

            showHomeTabOnStartup.Name        = "Show home tab on startup";
            showHomeTabOnStartup.Description = "Show the home tab when a project has been loaded.";
            showHomeTabOnStartup.Value       = true;
            showHomeTabOnStartup.Key         = "showHomeOnProjectLoad";

            Setting <bool> enableDeveloperMode = new Setting <bool>();

            enableDeveloperMode.Name        = "Enable Developer mode.";
            enableDeveloperMode.Description = "Show the developer menu item in the menu bar.";
            enableDeveloperMode.Value       = false;
            enableDeveloperMode.Key         = "EnableDeveloperMode";

            PathSetting logDirectory = new PathSetting();

            logDirectory.Value       = EXECUTABLE_DIRECTORY;
            logDirectory.DialogTitle = "Set log directory";
            logDirectory.Operation   = PathSetting.PathOperation.Load;
            logDirectory.Type        = PathSetting.PathType.Folder;
            logDirectory.Name        = "Log directory";
            logDirectory.Description = "The directory where the log file is located.";
            logDirectory.Key         = "logDirectory";

            PathSetting workspaceDirectory = new PathSetting();

            workspaceDirectory.Value       = string.Empty;
            workspaceDirectory.DialogTitle = "Set workspace directory";
            workspaceDirectory.Operation   = PathSetting.PathOperation.Load;
            workspaceDirectory.Type        = PathSetting.PathType.Folder;
            workspaceDirectory.Name        = "Workspace directory";
            workspaceDirectory.Description = "The directory where all new projects are created.";
            workspaceDirectory.Key         = "workspaceDirectory";

            DefaultGlobalSettings.NumeralSettings.Add(autosaveWarning);
            DefaultGlobalSettings.BooleanSettings.Add(showInfoOnAutomaticSettingsDialog);
            DefaultGlobalSettings.BooleanSettings.Add(enableDeveloperMode);
            DefaultGlobalSettings.BooleanSettings.Add(showHomeTabOnStartup);
            DefaultGlobalSettings.PathSettings.Add(logDirectory);
            DefaultGlobalSettings.PathSettings.Add(workspaceDirectory);
        }
Пример #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PackageProfile"/> class.
 /// </summary>
 public PackageProfile()
 {
     assetFolders           = new AssetFolderCollection();
     InheritProfiles        = new List <string>();
     Properties             = new SettingsCollection(SettingsGroup);
     OutputGroupDirectories = new Dictionary <string, UDirectory>();
     ProjectReferences      = new List <ProjectReference>();
 }
Пример #22
0
        public CommandSet ReadCommandsFromFile(string filepath)
        {
            try
            {
                if (!File.Exists(filepath))
                {
                    return(null);
                }
                SettingsCollection settings = null;
                try
                {
                    settings = (new SettingsFileLoader()).ReadSettingsFile(filepath);
                }
                catch (Exception exc)
                {
                    log.WriteError("Exception reading commands from file '{0}': {1}", filepath, exc);
                    //return new CommandSet(new List<Command>(), new DateTime());
                    return(null);
                }

                string fileVersion = SettingHelpers.GetSingleStringValue(settings, "FileVersion");
                if (!fileVersion.StartsWith(MASTER_FILE_VERSION_COMPAT))
                {
                    log.WriteError(
                        "Incompatible command file, version: {0}",
                        fileVersion);
                    return(null);
                }
                DateTime timestamp = settings.GetValue("Timestamp").GetUtcDateParam("TimeUtc");
                if (DateTime.UtcNow - timestamp > TimeSpan.FromHours(1))
                {
                    log.WriteInfo(
                        "Ignoring command file older than one hour, timestamp={0:O}",
                        timestamp);
                    return(null);
                }
                DateTime       acknowledgement = SettingHelpers.GetSingleDateTimeValue(settings, "AcknowledgementUtc");
                int            ncmds           = SettingHelpers.GetSingleIntValue(settings, "CommandCount");
                List <Command> cmdlist         = new List <Command>(ncmds);
                for (int i = 0; i < ncmds; ++i)
                {
                    string   key       = string.Format("Command{0}", i + 1);
                    var      cmdData   = settings.GetValue(key);
                    DateTime time      = cmdData.GetDateParam("TimeStampUtc");
                    string   cmdString = cmdData.GetStringParam("CommandString");
                    var      cmd       = new Command(time, cmdString);
                    cmdlist.Add(cmd);
                }

                CommandSet cmdset = new CommandSet(cmdlist, acknowledgement);
                return(cmdset);
            }
            catch (Exception exc)
            {
                log.WriteError("Exception reading command file: {0}", exc);
                return(null);
            }
        }
Пример #23
0
        private static SettingsCollection SetMissingDefaults(SettingsCollection settings)
        {
            if (settings.UiSettings.SetDefaults() || settings.InternalSettings.SetDefaults())
            {
                Serialize(settings);
            }

            return(settings);
        }
        /// <summary>Gets the custom setting from the settings collection with the settingName. If the setting is not found, return the defaultValue.</summary>
        /// <typeparam name="T">The type of the setting.</typeparam>
        /// <param name="settings">The settings collection to search for a setting with the settingName.</param>
        /// <param name="settingName">Name of the setting to search for in the settings collection.</param>
        /// <param name="defaultValue">The default value to use if the settingName is not found in the settings collection.</param>
        /// <returns>T.</returns>
        public static T GetCustomSetting <T>(this SettingsCollection settings, string settingName, T defaultValue = default(T))
        {
            if (settings.ContainsKey(settingName))
            {
                return(settings[settingName].Convert <T>());
            }

            return(defaultValue);
        }
Пример #25
0
 protected ConfigurationManager(string name)
 {
     settings = new SettingsCollection {
         help, version, verbose, printlog,
         logFile, configFile, this.name,
         loglevels
     };
     this.name.MaybeUpdate(SettingSource.Default, name);
 }
        internal static void Serialize(SettingsCollection settingsCollection)
        {
            if (serializer == null)
            {
                serializer = new ItemSerializer <SettingsCollection>("Settings.dat");
            }

            serializer.Serialize(settingsCollection);
        }
Пример #27
0
        public override Func <IFubuFile, RazorTemplate> CreateBuilder(SettingsCollection settings)
        {
            var razorSettings = settings.Get <RazorEngineSettings>();
            var namespaces    = settings.Get <CommonViewNamespaces>();

            var factory = new TemplateFactoryCache(namespaces, razorSettings, new TemplateCompiler(),
                                                   new RazorTemplateGenerator());

            return(file => new RazorTemplate(file, factory));
        }
Пример #28
0
        public void Test_SettingsCollection_Constructor_KeyValuePair()
        {
            var expectedSettings = new List <KeyValuePair <string, string> >();

            Fixture.AddManyTo(expectedSettings, 11);

            var sut = new SettingsCollection(expectedSettings);

            Assert.Equal(expectedSettings, sut);
        }
Пример #29
0
        public void Test_SettingsCollection_Constructor_SettingsCollection()
        {
            var expectedSettings = new SettingsCollection();

            Fixture.AddManyTo(expectedSettings, 14);

            var sut = new SettingsCollection(expectedSettings);

            Assert.Equal(expectedSettings, sut);
        }
Пример #30
0
        private void BtnShowOptions_Click(object sender, RoutedEventArgs e)
        {
            SettingsEditor editor = new SettingsEditor(versionSettings);

            editor.ShowDialog();
            if (editor.DialogResult.Value)
            {
                versionSettings = editor.SettingsCollection;
            }
        }
Пример #31
0
        public void SettingsCollection_AllowMultiple()
        {
            var settingsCollectionO = SettingsCollection.ForOutput();

            settingsCollectionO.Add(new Map("test1"));

            settingsCollectionO.Add(new Map("test2"));

            Assert.True(settingsCollectionO.Count == 2);
        }
Пример #32
0
        public IEnumerable<BehaviorChain> BuildChains(SettingsCollection settings)
        {
            var childGraph = BehaviorGraphBuilder.Import(Registry, settings);
            if (Prefix.IsNotEmpty())
            {
                childGraph.Behaviors.OfType<RoutedChain>().Each(x => { x.Route.Prepend(Prefix); });
            }

            return childGraph.Behaviors;
        }
Пример #33
0
        private void AddContextMenuCommands(
            SettingsCollection ccommands, XElement root, XElement menu)
        {
            foreach (var key in ccommands.Keys)
            {
                if (!ccommands.Get <bool>(key))
                {
                    continue;
                }

                var element = root.Descendants()
                              .FirstOrDefault(e => e.Attribute("id")?.Value == key);

                if (element != null)
                {
                    // deep clone item but must change id and remove getEnabled...

                    var item = new XElement(element);

                    // cleanup the item itself
                    XAttribute id = item.Attribute("id");
                    if (id != null && id.Value.StartsWith("rib"))
                    {
                        id.Value = $"ctx{id.Value.Substring(3)}";
                    }

                    var enabled = item.Attribute("getEnabled");
                    if (enabled != null)
                    {
                        enabled.Remove();
                    }

                    // cleanup all children below the item
                    foreach (var node in item.Descendants()
                             .Where(e => e.Attributes().Any(a => a.Name == "id")))
                    {
                        id = node.Attribute("id");
                        if (id != null && id.Value.StartsWith("rib"))
                        {
                            id.Value = $"ct2{id.Value.Substring(3)}";
                        }

                        enabled = node.Attribute("getEnabled");
                        if (enabled != null)
                        {
                            enabled.Remove();
                        }
                    }

                    item.Add(new XAttribute("insertBeforeMso", "Cut"));

                    menu.Add(item);
                }
            }
        }
Пример #34
0
        public IEnumerable<BehaviorChain> BuildChains(SettingsCollection settings)
        {
            var sources = _sources.Any() ? _sources : new IActionSource[] {new EndpointActionSource()};

            var actions = sources.SelectMany(x => x.FindActions(_applicationAssembly)).ToArray()
                .Distinct();

            var urlPolicies = settings.Get<UrlPolicies>();

            return actions.Select(x => x.BuildChain(urlPolicies)).ToArray();
        }
        public void pulls_value_from_config()
        {
            // look at FubuMVC.Tests.dll.config

            AppSettingsProvider.GetValueFor<DiagnosticsSettings>(x => x.TraceLevel)
                .ShouldBe(TraceLevel.None.ToString());

            var collection = new SettingsCollection();
            collection.Get<DiagnosticsSettings>()
                .TraceLevel.ShouldBe(TraceLevel.None);
        }
Пример #36
0
        public Task<ViewBag> BuildViewBag(SettingsCollection settings)
        {
            return Task.Factory.StartNew(() => {
                var viewFinders = _facilities.Select(x => x.FindViews(settings)).ToArray();

                var views = viewFinders.SelectMany(x => x.Result).ToList();

                _excludes.Each(views.RemoveAll);

                _viewPolicies.Each(x => x.Alter(views));

                return new ViewBag(views);
            });
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            Dictionary<string, object> indicesDict = serializer.Deserialize<Dictionary<string, object>>(reader);

            SettingsCollection collection = new SettingsCollection(); 
            foreach (KeyValuePair<string, object> indexKvp in indicesDict)
            {
                Dictionary<string, object> indexDict = new Dictionary<string, object>();
                indexDict.Add(indexKvp.Key, indexKvp.Value);

                string indexJson = JsonConvert.SerializeObject(indexDict);
                collection.Add(JsonConvert.DeserializeObject<Settings>(indexJson));
            }

            return collection;
        }
Пример #38
0
        public static BehaviorGraph Import(FubuRegistry registry, SettingsCollection parentSettings)
        {
            var graph = new BehaviorGraph(parentSettings);
            startBehaviorGraph(registry, graph);
            var config = registry.Config;

            config.RunActions(ConfigurationType.Settings, graph);

            config.Sources.Union(config.Imports).SelectMany(x => x.BuildChains(graph.Settings)).Each(chain => graph.AddChain(chain));

            config.RunActions(ConfigurationType.Explicit, graph);
            config.RunActions(ConfigurationType.Policy, graph);
            config.RunActions(ConfigurationType.Reordering, graph);
            config.RunActions(ConfigurationType.InjectNodes, graph);

            return graph;
        }
 private MetadataInfoTreeGroup(SettingsCollection settings)
 {
     Settings = settings;
     DependecyTree = new List<MetadataInfoTreeItem>();
 }
Пример #40
0
 public void SetUp()
 {
     theParent = new SettingsCollection(null);
     theSettings = new SettingsCollection(theParent);
 }
Пример #41
0
 public void SetUp()
 {
     theSettings = new SettingsCollection(null);
 }
 public void SaveSettings(string type, SettingsCollection settings)
 {
     saveSettingsType(type, settings);
 }
        void saveSettingsType(string type, SettingsCollection settings)
        {
            this.disableWatcher(type);
            try
            {
                var filePath = getFileFromType(type);

                if (settings == null || settings.Count == 0)
                {
                    if (File.Exists(filePath))
                    {
                        File.Delete(filePath);
                    }

                    return;
                }

                // Cover the case where the file still has a lock on it from a previous IO access and needs time to let go.
                var retryAttempt = 0;
                while(true)
                {
                    try
                    {
                        using (var writer = new StreamWriter(filePath))
                        {
                            settings.Persist(writer);
                            break;
                        }
                    }
                    catch (Exception)
                    {
                        if (retryAttempt < 5)
                        {
                            Thread.Sleep(1000);
                            retryAttempt++;
                        }
                        else
                            throw;
                    }
                }
            }
            finally
            {
                this.enableWatcher(type);
            }
        }
Пример #44
0
 static void CreateSettingsFile()
 {
     SettingsCollection sc = new SettingsCollection {CreateNewSettings("Default")};
     sc.SaveSettings(SettingsFileName);
 }
Пример #45
0
 protected ConfigurationManager()
 {
     settings = new SettingsCollection {help, version, verbose, printlog,
     logFile, configFile,
     loglevels};
 }
Пример #46
0
 public Task<IEnumerable<IViewToken>> FindViews(SettingsCollection settings)
 {
     return Task.Factory.StartNew(() => tokens());
 }
Пример #47
0
        private IEnumerable<Task<IEnumerable<IViewToken>>> viewSources(SettingsCollection settings)
        {
            foreach (IViewFacility facility in _facilities)
            {
                var findViews = facility.FindViews(settings);
                yield return findViews.ContinueWith(task => {
                    var list = task.Result.ToList();
                    _excludes.Each(list.RemoveAll);

                    _viewPolicies.Each(x => x.Alter(list));

                    return list.As<IEnumerable<IViewToken>>();
                });
            }
        }
Пример #48
0
 public ASettings(ASettingsSource source) {
     this.source = source;
     this.settings = createSettings(new SettingsCollection());
     processSettings();
 }
Пример #49
0
        protected virtual SettingsCollection createSettings(SettingsCollection settings) {
            settings.Add(new Setting("EmailSender", null, "email", "sender"));
            settings.Add(new Setting("EmailRecipient", null, "email", "recipient"));
            settings.Add(new Setting("last_drive", current_drive, "portable_settings", "last_drive"));
            settings.Add(new Setting("WindowX", null, "window", "x"));
            settings.Add(new Setting("WindowY", null, "window", "y"));
            settings.Add(new Setting("WindowW", null, "window", "h"));
            settings.Add(new Setting("WindowH", null, "window", "w"));
            settings.Add(new Setting("WindowState", null, "window", "state"));

            return settings;
        }
Пример #50
0
 public Task<IEnumerable<IViewToken>> FindViews(SettingsCollection settings)
 {
     return Task.Factory.StartNew(() => {
         return new IViewToken[]{new TestViewToken()} as IEnumerable<IViewToken>;
     });
 }
 private MetadataInfoTreeSource(IContainer resource, SettingsCollection settings)
 {
     Settings = settings;
     Resource = MetadataInfoTreeContainer.Create(resource);
 }
Пример #52
0
 private static SettingsCollection.ObjectSettings ReadProfileSettings(SettingsCollection settings, string profileName)
 {
     return settings.FirstOrDefault(x => string.Equals(x[SettingsConstants.DisplayNameField], profileName, StringComparison.OrdinalIgnoreCase));
 }
 private void UpdateSettings(bool ForceUpdate)
 {
     if (_settingsLastUpdated == null || _settingsLastUpdated.Add(MinimumTimeBetweenUpdates) < DateTime.Now || ForceUpdate)
     {
         UTorrentSettings CurrentSettings = ServiceClient.GetSettings(_token);
         if (_settings == null)
         {
             _settings = new SettingsCollection();
         }
         _settings.ParseSettings(CurrentSettings.Settings, this);
         _settingsLastUpdated = DateTime.Now;
     }
 }
Пример #54
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompilerContext"/> class.
 /// </summary>
 public CompilerContext()
 {
     Properties = new PropertyCollection();
     PackageProperties = new SettingsCollection(PackageProfile.SettingsGroup);
 }
Пример #55
0
        protected override SettingsCollection createSettings(SettingsCollection settings)
        {
            settings = base.createSettings(settings);

            Setting new_setting = new Setting("backup_path", null, "paths", "backup");
            new_setting.addAdditionalNotification("IsBackupPathSet");
            new_setting.addAdditionalNotification("backup_path_not_set");
            settings.Add(new_setting);

            new_setting = new Setting("sync_path", null, "paths", "sync");
            new_setting.addAdditionalNotification("any_sync_enabled");
            new_setting.addAdditionalNotification("sync_path_set");
            settings.Add(new_setting);

            new_setting = new Setting("steam_override", null, "paths", "steam_override");
            new_setting.addAdditionalNotification("steam_path");
            settings.Add(new_setting);

            new_setting = new Setting("save_paths", null, "paths", "saves");
            settings.Add(new_setting);

            settings.Add(new Setting("IgnoreDateCheck", false, "date_check", "ignore"));

            settings.Add(new Setting("MonitoredGames", null, "games", "monitor"));

            settings.Add(new Setting("VersioningEnabled", false, "versioning", "enabled"));
            settings.Add(new Setting("VersioningUnit", VersioningUnit.Hours, "versioning", "unit"));
            settings.Add(new Setting("VersioningFrequency", 5, "versioning", "frequency"));
            settings.Add(new Setting("VersioningMax", 100, "versioning", "max"));

            settings.Add(new Setting("SuppressSubmitRequests", false, "suppress", "submit_requests"));
            settings.Add(new Setting("SuppressElevationWarnings", false, "suppress", "elevation_warnings"));

            return settings;
        }
Пример #56
0
 void LoadSettings()
 {
     _settingsCollection = SettingsCollection.LoadSettings(SettingsFileName);
     _settings = _settingsCollection.GetSettings(Properties.Settings.Default.MostRecentSetting);
     SettingsProfile.ItemsSource = _settingsCollection.GetSettingsNamesList();
     SettingsProfile.SelectedValue = _settings.DisplayName;
     ucOptions.LoadSettings(_settings);
     ucKeyBinding.LoadSettings(_settings);
 }