private async void LoadConfiguration()
        {
            var localFolder = ApplicationData.Current.LocalFolder;

            try
            {
                var settingsFile = await localFolder.GetFileAsync("duck_dns_updater_config.cfg");

                if (settingsFile != null)
                {
                    var settings = await FileIO.ReadTextAsync(settingsFile);

                    var settingsValues = settings.Split("|");

                    DomainNames      = settingsValues[0];
                    Token            = settingsValues[1];
                    SelectedInterval = Intervals.FirstOrDefault(i => i.Value == uint.Parse(settingsValues[2]));

                    OkButton.Focus(FocusState.Programmatic);
                }
            }
            catch (FileNotFoundException)
            {
            }
        }
        public void ReadValues(Data data, string path)
        {
            Accounts.ReadValues(data, path + @"Accounts\");

            try
            {
                int numClasses = int.Parse(data.GetValue(@"" + path + @"PrinterMappings\numClasses"));
                for (int i = 0; i < numClasses; i++)
                {
                    PrinterMapping tmp = new PrinterMapping();
                    tmp.ReadValues(data, @"" + path + @"PrinterMappings\" + i + @"\");
                    PrinterMappings.Add(tmp);
                }
            } catch {}


            try
            {
                int numClasses = int.Parse(data.GetValue(@"" + path + @"TitleReplacement\numClasses"));
                for (int i = 0; i < numClasses; i++)
                {
                    TitleReplacement tmp = new TitleReplacement();
                    tmp.ReadValues(data, @"" + path + @"TitleReplacement\" + i + @"\");
                    TitleReplacement.Add(tmp);
                }
            } catch {}

            try { AskSwitchDefaultPrinter = bool.Parse(data.GetValue(@"" + path + @"AskSwitchDefaultPrinter")); } catch { AskSwitchDefaultPrinter = true; }
            try { Language = Data.UnescapeString(data.GetValue(@"" + path + @"Language")); } catch { Language = ""; }
            try { LastUsedProfileGuid = Data.UnescapeString(data.GetValue(@"" + path + @"LastUsedProfileGuid")); } catch { LastUsedProfileGuid = "DefaultGuid"; }
            try { LoggingLevel = (LoggingLevel)Enum.Parse(typeof(LoggingLevel), data.GetValue(@"" + path + @"LoggingLevel")); } catch { LoggingLevel = LoggingLevel.Error; }
            try { PrimaryPrinter = Data.UnescapeString(data.GetValue(@"" + path + @"PrimaryPrinter")); } catch { PrimaryPrinter = "PDFCreator"; }
            try { UpdateInterval = (UpdateInterval)Enum.Parse(typeof(UpdateInterval), data.GetValue(@"" + path + @"UpdateInterval")); } catch { UpdateInterval = UpdateInterval.Weekly; }
        }
        public void ReplaceWith(ApplicationSettings source)
        {
            Accounts.ReplaceWith(source.Accounts);
            JobHistory.ReplaceWith(source.JobHistory);

            PrinterMappings.Clear();
            for (int i = 0; i < source.PrinterMappings.Count; i++)
            {
                PrinterMappings.Add(source.PrinterMappings[i].Copy());
            }

            RssFeed.ReplaceWith(source.RssFeed);

            TitleReplacement.Clear();
            for (int i = 0; i < source.TitleReplacement.Count; i++)
            {
                TitleReplacement.Add(source.TitleReplacement[i].Copy());
            }

            UsageStatistics.ReplaceWith(source.UsageStatistics);
            if (ConversionTimeout != source.ConversionTimeout)
            {
                ConversionTimeout = source.ConversionTimeout;
            }

            if (EnableTips != source.EnableTips)
            {
                EnableTips = source.EnableTips;
            }

            if (Language != source.Language)
            {
                Language = source.Language;
            }

            if (LicenseExpirationReminder != source.LicenseExpirationReminder)
            {
                LicenseExpirationReminder = source.LicenseExpirationReminder;
            }

            if (LoggingLevel != source.LoggingLevel)
            {
                LoggingLevel = source.LoggingLevel;
            }

            if (NextUpdate != source.NextUpdate)
            {
                NextUpdate = source.NextUpdate;
            }

            if (UnitOfMeasurement != source.UnitOfMeasurement)
            {
                UnitOfMeasurement = source.UnitOfMeasurement;
            }

            if (UpdateInterval != source.UpdateInterval)
            {
                UpdateInterval = source.UpdateInterval;
            }
        }
Example #4
0
 /// <summary>
 /// Create a new cluster dictionary, only called internally.
 /// </summary>
 internal ClusterDictionary(ConflictResolution conflictResolutionPolicy  = ConflictResolution.CHRONOLOGICAL,
                            DistributionMethod clusterDistributionMethod = DistributionMethod.FULLY_DISTRIBUTED,
                            UpdateInterval updateIntervalPolicy          = UpdateInterval.IMMEDIATE,
                            Initialization initializationPolicy          = Initialization.LAZY)
 {
     ConflictResolutionPolicy  = conflictResolutionPolicy;
     ClusterDistributionMethod = clusterDistributionMethod;
     UpdateIntervalPolicy      = updateIntervalPolicy;
     InitializationPolicy      = initializationPolicy;
     initialize();
 }
Example #5
0
        //Returnerar en representation av en PodCast som ett ListViewItem
        public ListViewItem ToListViewItem()
        {
            var dataToDisplay = new List <string> {
                Episodes.Count.ToString(),
                Name,
                UpdateInterval.ToString(),
                Category
            };

            return(new ListViewItem(dataToDisplay.ToArray()));
        }
Example #6
0
        public void SaveConfig()
        {
            try
            {
                var xmlDoc = new XmlDocument();
                xmlDoc.Load(_xmlFilePath);

                var setting = xmlDoc.SelectSingleNode("/Config");

                //监测定时器间隔(s)
                var node = setting?.SelectSingleNode("TimerInterval");
                if (node != null)
                {
                    node.InnerText = TimerInterval.ToString();
                }

                //刷新定时器间隔(s)
                node = setting?.SelectSingleNode("UpdateInterval");
                if (node != null)
                {
                    node.InnerText = UpdateInterval.ToString();
                }

                //X坐标轴时间片(minute)
                node = setting?.SelectSingleNode("AxisXSpan");
                if (node != null)
                {
                    node.InnerText = AxisXSpan.ToString();
                }

                //X坐标轴显示步进(minute)
                node = setting?.SelectSingleNode("AxisXStepNumber");
                if (node != null)
                {
                    node.InnerText = AxisXStepNumber.ToString();
                }

                //X坐标轴显示格式
                node = setting?.SelectSingleNode("LabelFormatter");
                if (node != null)
                {
                    node.InnerText = LabelFormatter;
                }

                xmlDoc.Save(_xmlFilePath);

                AxisXStep  = 1.0 * AxisXSpan / AxisXStepNumber;
                AxisXCount = (int)(1.0f * AxisXSpan * Constants.MINUTE_PER_SECOND / TimerInterval);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Example #7
0
 private void Init()
 {
     ApiAccess               = new List <ApiAccess>();
     PrinterMappings         = new List <PrinterMapping>();
     TitleReplacement        = new List <TitleReplacement>();
     AskSwitchDefaultPrinter = true;
     Language            = "";
     LastUsedProfileGuid = "DefaultGuid";
     LoggingLevel        = LoggingLevel.Error;
     PrimaryPrinter      = "clawPDF";
     UpdateInterval      = UpdateInterval.Weekly;
 }
Example #8
0
 public void Start(string tileUri, UpdateInterval updateInterval)
 {
     _tileUri = tileUri;
     _updateInterval = updateInterval;
     _schedule = new ShellTileSchedule()
                        {
                            Interval = _updateInterval,
                            RemoteImageUri = new Uri(_tileUri),
                            Recurrence = UpdateRecurrence.Interval
                        };
     _schedule.StartTime = DateTime.Now;
     _schedule.Start();
 }
Example #9
0
        //
        //Private functions
        //
        private void SelectUpdateRateMenu()
        {
            string tag = UpdateInterval.ToString();

            foreach (ToolStripItem item in updateContextMenu.Items)
            {
                if (item.Tag != null && item.GetType() == typeof(ToolStripMenuItem))
                {
                    ToolStripMenuItem tmi = (ToolStripMenuItem)item;
                    tmi.Checked = tag.Equals(tmi.Tag);
                    tmi.Enabled = AutoUpdateStatus;
                }
            }
        }
Example #10
0
        private static void RefreshLastUpdatedStorageTime(UpdateInterval interval, EntitiesContext dbContext)
        {
            var storage = dbContext.Storages.Where(s => s.StorageType == StorageType.Facebook).Single();

            if (interval == UpdateInterval.Today)
            {
                storage.LastUpdatedToday = DateTime.Now;
            }
            if (interval == UpdateInterval.Closest)
            {
                storage.LastUpdatedClosest = DateTime.Now;
            }
            if (interval == UpdateInterval.Week)
            {
                storage.LastUpdatedClosest = DateTime.Now;
            }
        }
Example #11
0
        /// <summary>
        /// Initialize with NextUpdate and UpdateInterval from Settings
        /// </summary>
        /// <param name="appSettings">Current ApplicationSettings</param>
        /// <param name="appProperties">Current ApplicationProperties</param>
        /// <param name="gpoSettings">Current GpoSettings</param>
        public void Initialize(ApplicationSettings appSettings, ApplicationProperties appProperties, GpoSettings gpoSettings)
        {
            NextUpdate = appProperties.NextUpdate;

            if (EditionFactory.Instance.Edition.HideAndDisableUpdates)
            {
                _updateInterval = UpdateInterval.Never;
            }
            else if ((gpoSettings == null) || (gpoSettings.UpdateInterval == null))
            {
                _updateInterval = appSettings.UpdateInterval;
            }
            else
            {
                _updateInterval = SettingsHelper.GetUpdateInterval(gpoSettings.UpdateInterval);
            }

            _logger.Debug("UpdateManager initialised");
        }
Example #12
0
        public void WriteControllerInfo(ISequence sequence)
        {
            int chanStart = 1;

            string xmlOutName =
                Path.GetDirectoryName(OutFileName) +
                Path.DirectorySeparatorChar +
                Path.GetFileNameWithoutExtension(OutFileName) +
                "_Network.xml";

            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent      = true;
            settings.IndentChars = "\t";

            using (XmlWriter writer = XmlWriter.Create(xmlOutName, settings))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("Vixen3_Export");
                writer.WriteElementString("Resolution", UpdateInterval.ToString());
                writer.WriteElementString("OutFile", Path.GetFileName(OutFileName));
                writer.WriteElementString("Duration", sequence.Length.ToString());

                writer.WriteStartElement("Network");
                foreach (Controller exportInfo in ControllerExportInfo.Where(x => x.IsActive).OrderBy(x => x.Index))
                {
                    writer.WriteStartElement("Controller");
                    writer.WriteElementString("Index", exportInfo.Index.ToString());
                    writer.WriteElementString("Name", exportInfo.Name);
                    writer.WriteElementString("StartChan", chanStart.ToString());
                    writer.WriteElementString("Channels", exportInfo.Channels.ToString());
                    writer.WriteEndElement();

                    chanStart += exportInfo.Channels;
                }
                writer.WriteEndElement();

                writer.WriteEndElement();
                writer.WriteEndDocument();
            }
        }
Example #13
0
        public static TimeSpan ToTimeSpan(this UpdateInterval interval)
        {
            switch (interval)
            {
            case UpdateInterval.Never:
                return(TimeSpan.MaxValue);

            case UpdateInterval.Daily:
                return(TimeSpan.FromDays(1));

            case UpdateInterval.Weekly:
                return(TimeSpan.FromDays(7));

            case UpdateInterval.Monthly:
                var today = DateTime.Now;
                return(TimeSpan.FromDays(DateTime.DaysInMonth(today.Year, today.Month)));

            default:
                throw new ArgumentOutOfRangeException(nameof(interval), interval, null);
            }
        }
Example #14
0
        public MainPage()
        {
            this.InitializeComponent();

            LoadConfiguration();

            RefreshTask = GetActiveRefreshTaskRegistration();

            if (RefreshTask != null)
            {
                RefreshTrigger = (TimeTrigger)((BackgroundTaskRegistration)RefreshTask).Trigger;
                if (RefreshTrigger != null)
                {
                    SelectedInterval = Intervals.FirstOrDefault(i => i.Value == RefreshTrigger.FreshnessTime);
                }
            }

            ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(500, 168));
            ApplicationView.PreferredLaunchViewSize      = new Size(500, 168);
            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;
        }
Example #15
0
        public void SaveToDb(List <Event> events, UpdateInterval interval)
        {
            using (var dbContext = new EntitiesContext())
            {
                foreach (var evnt in events)
                {
                    //. Optimize. Use stored proc. Use hash or index for url comparation

                    if (dbContext.Events.Any(e => e.EventUrl == evnt.EventUrl))
                    {
                        // update
                    }
                    else
                    {
                        dbContext.Events.Add(evnt);
                    }
                }

                //RefreshLastUpdatedStorageTime(interval, dbContext);
                dbContext.SaveChanges();
            }
        }
Example #16
0
        public DateTime LastUpdated(UpdateInterval interval)
        {
            using (var dbContext = new EntitiesContext())
            {
                var storage = dbContext.Storages.Where(s => s.StorageType == StorageType.Facebook).Single();

                if (interval == UpdateInterval.Today)
                {
                    return(storage.LastUpdatedToday);
                }
                if (interval == UpdateInterval.Closest)
                {
                    return(storage.LastUpdatedClosest);
                }
                if (interval == UpdateInterval.Week)
                {
                    return(storage.LastUpdatedWeek);
                }

                return(DateTime.MinValue);
            }
        }
        public void ReadValues(Data data, string path = "")
        {
            Accounts.ReadValues(data, path + @"Accounts\");
            JobHistory.ReadValues(data, path + @"JobHistory\");

            try
            {
                int numClasses = int.Parse(data.GetValue(@"" + path + @"PrinterMappings\numClasses"));
                for (int i = 0; i < numClasses; i++)
                {
                    PrinterMapping tmp = new PrinterMapping();
                    tmp.ReadValues(data, @"" + path + @"PrinterMappings\" + i + @"\");
                    PrinterMappings.Add(tmp);
                }
            } catch {}

            RssFeed.ReadValues(data, path + @"RssFeed\");

            try
            {
                int numClasses = int.Parse(data.GetValue(@"" + path + @"TitleReplacement\numClasses"));
                for (int i = 0; i < numClasses; i++)
                {
                    TitleReplacement tmp = new TitleReplacement();
                    tmp.ReadValues(data, @"" + path + @"TitleReplacement\" + i + @"\");
                    TitleReplacement.Add(tmp);
                }
            } catch {}

            UsageStatistics.ReadValues(data, path + @"UsageStatistics\");
            ConversionTimeout = int.TryParse(data.GetValue(@"" + path + @"ConversionTimeout"), System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out var tmpConversionTimeout) ? tmpConversionTimeout : 60;
            EnableTips        = bool.TryParse(data.GetValue(@"" + path + @"EnableTips"), out var tmpEnableTips) ? tmpEnableTips : true;
            try { Language = Data.UnescapeString(data.GetValue(@"" + path + @"Language")); } catch { Language = ""; }
            LicenseExpirationReminder = DateTime.TryParse(data.GetValue(@"" + path + @"LicenseExpirationReminder"), System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out var tmpLicenseExpirationReminder) ? tmpLicenseExpirationReminder : DateTime.Now;
            LoggingLevel      = Enum.TryParse <LoggingLevel>(data.GetValue(@"" + path + @"LoggingLevel"), out var tmpLoggingLevel) ? tmpLoggingLevel : LoggingLevel.Error;
            NextUpdate        = DateTime.TryParse(data.GetValue(@"" + path + @"NextUpdate"), System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out var tmpNextUpdate) ? tmpNextUpdate : DateTime.Now;
            UnitOfMeasurement = Enum.TryParse <UnitOfMeasurement>(data.GetValue(@"" + path + @"UnitOfMeasurement"), out var tmpUnitOfMeasurement) ? tmpUnitOfMeasurement : UnitOfMeasurement.Centimeter;
            UpdateInterval    = Enum.TryParse <UpdateInterval>(data.GetValue(@"" + path + @"UpdateInterval"), out var tmpUpdateInterval) ? tmpUpdateInterval : UpdateInterval.Weekly;
        }
Example #18
0
 public void SaveToDb(List <Event> events, UpdateInterval interval)
 {
 }
Example #19
0
 DateTime IEventsStorage.LastUpdated(UpdateInterval interval)
 {
     return(DateTime.Now);
 }
Example #20
0
 private void LoadEvents(IEventProvider provider, int updateIntervalHours, int updateDays, UpdateInterval interval)
 {
     if (!provider.Storage.LastUpdated(interval).WithInHours(updateIntervalHours))
     {
         var events = provider.Source.GetTopEvents(DateTime.Now, DateTime.Now.AddDays(updateDays), Locations.Vancouver);
         provider.Storage.SaveToDb(events, interval);
     }
 }
 public static bool Includes(UpdateInterval enumValue, UpdateInterval layer)
 {
     return(((int)enumValue & (1 << (int)layer)) != 0);
 }
Example #22
0
 public void Start(string tileUri, UpdateInterval updateInterval)
 {
     StartCalled = true;
     InvokedTileUri = tileUri;
     InvokedUpdateInterval = updateInterval;
 }