Пример #1
0
        protected override void ThreadStart()
        {
            while (!this.Terminate)
            {
                this.WaitHandle.WaitOne();
                IMessage message = null;

                while ((message = this.SourceStore.Get()) != null)
                {
                    long storageSizeLimit = new Preferences().StorageSizeLimit;
                    if (storageSizeLimit == -1)
                    {
                        this.TargetStore.Add(message);
                    }
                    else
                    {
                        this.TargetStore.Add(message, storageSizeLimit);
                    }
                    
                    this.SourceStore.Remove();
                }

                this.WaitHandle.Reset();
            }
        }
Пример #2
0
        public void Put(IMessage message)
        {
            for (int i = 0; i < 10; i++)
            {
                try
                {
                    long storageSizeLimit = new Preferences().StorageSizeLimit;
                    if (storageSizeLimit == -1)
                    {
                        this.TargetStore.Add(message);
                    }
                    else
                    {
                        this.TargetStore.Add(message, storageSizeLimit);
                    }

                    return;
                }
                catch (Exception exception)
                {
                    this.Logger.Err("StoreService.ThreadStart. Error {0}", exception.ToString());
                }

                Reyna.Sleep.Wait(1);
            }
        }
Пример #3
0
        public ReynaService(byte[] password, ICertificatePolicy certificatePolicy, bool useNetworkState, IReynaLogger logger)
        {
            this.Password = password;
            this.Logger = logger;
            this.PersistentStore = new SQLiteRepository(password);
            this.HttpClient = new HttpClient(certificatePolicy);
            this.EncryptionChecker = new EncryptionChecker();

            this.ForwardWaitHandle = new AutoResetEventAdapter(false);

            if (useNetworkState)
            {
                this.SystemNotifier = new SystemNotifier();
                this.NetworkWaitHandle = new NamedWaitHandle(false, Reyna.NetworkStateService.NetworkConnectedNamedEvent);
                this.NetworkStateService = new NetworkStateService(this.SystemNotifier, this.NetworkWaitHandle);
            }

            var preferences = new Preferences();
            this.StoreService = new StoreService(this.PersistentStore, logger);
            this.ForwardService = new ForwardService(this.PersistentStore, this.HttpClient, this.NetworkStateService, this.ForwardWaitHandle, Preferences.ForwardServiceTemporaryErrorBackout, Preferences.ForwardServiceMessageBackout, preferences.BatchUpload, logger);
        }
Пример #4
0
 public static void SetBatchUploadConfiguration(bool value, Uri url, long checkInterval)
 {
     var preferences = new Preferences();
     preferences.SaveBatchUpload(value);
     preferences.SaveBatchUploadUrl(url);
     preferences.SaveBatchUploadCheckInterval(checkInterval);
 }
Пример #5
0
        internal static void SaveCellularDataAsWwanForBackwardsCompatibility()
        {
            Preferences preferences = new Preferences();
            TimeRange timeRange = preferences.CellularDataBlackout;
            if (timeRange != null)
            {
                int hourFrom = (int)Math.Floor((double)timeRange.From.MinuteOfDay / 60);
                int minuteFrom = timeRange.From.MinuteOfDay % 60;
                string blackoutFrom = ZeroPad(hourFrom) + ":" + ZeroPad(minuteFrom);

                int hourTo = (int)Math.Floor((double)timeRange.To.MinuteOfDay / 60);
                int minuteTo = timeRange.To.MinuteOfDay % 60;
                string blackoutTo = ZeroPad(hourTo) + ":" + ZeroPad(minuteTo);

                preferences.SetWwanBlackoutRange(blackoutFrom + "-" + blackoutTo);
            }
        }