Exemple #1
0
        /// <summary>
        /// Saves the settings passed across and returns the saved values.
        /// </summary>
        /// <param name="args"></param>
        private void SaveFilterConfiguration(RequestReceivedEventArgs args)
        {
            if (args.Request.HttpMethod == "POST")
            {
                var json = new SaveFilterConfigurationJson();

                try {
                    json.DataVersion   = long.Parse(args.Request.FormValues["DataVersion"], CultureInfo.InvariantCulture);
                    json.ProhibitMlat  = bool.Parse(args.Request.FormValues["ProhibitMlat"]);
                    json.ProhibitIcaos = bool.Parse(args.Request.FormValues["ProhibitIcaos"]);
                    json.Icaos         = args.Request.FormValues["Icaos"];

                    var filterConfiguration = json.ToFilterConfiguration(json.DuplicateIcaos, json.InvalidIcaos);

                    json.WasStaleData = !FilterConfigurationStorage.Save(this, filterConfiguration);
                    if (!json.WasStaleData)
                    {
                        json.FromFilterConfiguration(filterConfiguration);
                    }
                } catch (Exception ex) {
                    json.Exception = LogException(ex, "Exception caught during FeedFilter SaveFilterConfiguration: {0}", ex.ToString());
                }

                SendJsonResponse(args, json);
            }
        }
Exemple #2
0
        /// <summary>
        /// Returns the current filter settings.
        /// </summary>
        /// <param name="args"></param>
        private void FetchFilterConfiguration(RequestReceivedEventArgs args)
        {
            if(args.Request.HttpMethod == "GET") {
                var json = new FilterConfigurationJson();

                try {
                    json.FromFilterConfiguration(FilterConfigurationStorage.Load());
                } catch(Exception ex) {
                    json.Exception = LogException(ex, "Exception caught during FeedFilter FetchFilterConfiguration: {0}", ex.ToString());
                }

                SendJsonResponse(args, json);
            }
        }
Exemple #3
0
        /// <summary>
        /// Initialises the object.
        /// </summary>
        public static void Initialise(Plugin plugin)
        {
            if (!_Initialised)
            {
                _Initialised = true;

                var options = OptionsStorage.Load(plugin);
                _ParsedConfiguration.ApplyOptionsChange(options);

                var filterConfiguration = FilterConfigurationStorage.Load();
                _ParsedConfiguration.ApplyFilterConfigurationChange(filterConfiguration);

                OptionsStorage.OptionsChanged += OptionsStorage_OptionsChanged;
                FilterConfigurationStorage.FilterConfigurationChanged += FilterConfigurationStorage_FilterConfigurationChanged;
            }
        }