Example #1
0
        internal static void ExecuteCycle(Clock clock, float deltaTime = 0f)
        {
            if (clock != null)
            {
                var currentMsUpdate = clock.GetElapsedSeconds();
                if (currentMsUpdate == 0)
                {
                    Thread.Sleep(1);
                    currentMsUpdate = clock.GetElapsedSeconds();
                }

                Script.DeltaTime = (float)currentMsUpdate;
                clock.Reset();
            }
            else
            {
                Script.DeltaTime = deltaTime;
            }

            lock (RtUpdate)
            {
                RtUpdate?.Invoke();
            }
            lock (Updating)
            {
                Updating?.Invoke();
            }
            lock (Destroying)
            {
                Destroying?.Invoke();
            }
        }
Example #2
0
        /// <summary>
        /// Updates a payment method
        /// </summary>
        /// <param name="token">The payment method token</param>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see cref="Attempt"/>.
        /// </returns>
        public Attempt <PaymentMethod> Update(string token, PaymentMethodRequest request)
        {
            Mandate.ParameterNotNull(request, "request");

            Updating.RaiseEvent(new SaveEventArgs <PaymentMethodRequest>(request), this);

            var attempt = TryGetApiResult(() => BraintreeGateway.PaymentMethod.Update(token, request));

            if (!attempt.Success)
            {
                return(Attempt <PaymentMethod> .Fail(attempt.Exception));
            }

            var result = attempt.Result;

            if (result.IsSuccess())
            {
                var cacheKey = MakePaymentMethodCacheKey(token);

                RuntimeCache.ClearCacheItem(cacheKey);

                Updated.RaiseEvent(new SaveEventArgs <PaymentMethod>(result.Target), this);

                return(Attempt <PaymentMethod> .Succeed((PaymentMethod)RuntimeCache.GetCacheItem(cacheKey, () => result.Target)));
            }

            var error = new BraintreeApiException(result.Errors, result.Message);

            LogHelper.Error <BraintreePaymentMethodApiService>("Failed to update payment method", error);

            return(Attempt <PaymentMethod> .Fail(error));
        }
        /// <summary>
        /// Updates an existing subscription
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see cref="Attempt"/>.
        /// </returns>
        public Attempt <Subscription> Update(SubscriptionRequest request)
        {
            Updating.RaiseEvent(new SaveEventArgs <SubscriptionRequest>(request), this);

            var attempt = TryGetApiResult(() => BraintreeGateway.Subscription.Update(request.Id, request));

            if (!attempt.Success)
            {
                return(Attempt <Subscription> .Fail(attempt.Exception));
            }

            var result = attempt.Result;

            if (result.IsSuccess())
            {
                Updated.RaiseEvent(new SaveEventArgs <Subscription>(result.Target), this);

                var cacheKey = MakeSubscriptionCacheKey(request.Id);
                RuntimeCache.ClearCacheItem(cacheKey);

                return(Attempt <Subscription> .Succeed(result.Target));
            }

            var error = new BraintreeApiException(result.Errors, result.Message);

            LogHelper.Error <BraintreeSubscriptionApiService>("Failed to create a subscription", error);

            return(Attempt <Subscription> .Fail(error));
        }
        /// <summary>
        /// Обращение к API Raspberry Pi
        /// </summary>
        private static ApiResponce ApiRequest(string request, Method method, object postdata = null)
        {
            if (CheckForPi())
            {
                Updating?.Invoke(null, new EventArgs());
                var req = new RestRequest(request, method);
                if (postdata != null)
                {
                    req.AddHeader("Content-type", "application/json");
                    req.AddJsonBody(postdata);
                }
                var resp = RestClient.Execute(req);
                if (resp.ContentType != "application/json")
                {
                    return(new ApiResponce(resp, null));
                }
                try
                {
                    var json = JObject.Parse(resp.Content);
                    return(new ApiResponce(resp, json));
                }
                catch (JsonReaderException e)
                {
                    return(new ApiResponce(ApiStatus.JsonParsingError));
                }
            }

            return(new ApiResponce(ApiStatus.PiNotFound));
        }
        public void ClearAllObjects()
        {
            Initialize();

            Updating.SafeInvoke(this);

            lock (_lockObject)
            {
                using (var analyzer = new StandardAnalyzer(LuceneDefaults.Version))
                {
                    using (var writer = new IndexWriter(_indexDirectory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED))
                    {
                        _indexedObjects.Clear();
                        _searchableMetadata.Clear();

                        writer.DeleteAll();

                        writer.Optimize();
                        writer.Commit();
                    }
                }
            }

            Updated.SafeInvoke(this);
        }
Example #6
0
 private void OnUpdating(Object dataObject)
 {
     if (Updating != null)
     {
         Updating.Invoke(dataObject, EventArgs.Empty);
     }
 }
Example #7
0
        public void Setup()
        {
            _nEventsRecieved = 0;
            _testTrack1      = new Track()
            {
                Altitude  = 10000,
                X         = 50000,
                Y         = 50000,
                Course    = 200,
                Tag       = "test1",
                TimeStamp = DateTime.Now,
                Velocity  = 300
            };
            _testTrack2 = new Track()
            {
                Altitude  = 11000,
                Tag       = "test2",
                X         = 51000,
                Y         = 51000,
                Course    = 210,
                Velocity  = 310,
                TimeStamp = DateTime.Now
            };
            _filtering = Substitute.For <IFiltering>();
            _calc      = Substitute.For <ICalculating>();
            _uut       = new Updating(_filtering, _calc);

            _uut.TracksUpdated += (o, args) =>
            {
                _updatedTracks = args.UpdatedTracks;
                ++_nEventsRecieved;
            };
        }
Example #8
0
        public void ClearAllObjects()
        {
            Initialize();

            Updating?.Invoke(this, EventArgs.Empty);

            lock (_lockObject)
            {
                using (var analyzer = new StandardAnalyzer(LuceneDefaults.Version))
                {
                    using (var writer = new IndexWriter(_indexDirectory, CreateIndexWriterConfig(analyzer)))
                    {
                        _indexedObjects.Clear();
                        _searchableMetadata.Clear();

                        writer.DeleteAll();

                        writer.PrepareCommit();
                        writer.Commit();
                    }
                }
            }

            Updated?.Invoke(this, EventArgs.Empty);
        }
Example #9
0
    IEnumerator CaptureControls()
    {
        yield return(new WaitForSeconds(2));

        while (true)
        {
            if (Input.GetKey(KeyCode.I))
            {
                transform.position += transform.forward * ZoomSpeed;
            }
            else if (Input.GetKey(KeyCode.O))
            {
                transform.position -= transform.forward * ZoomSpeed;
            }

            if (Input.GetMouseButton(1))
            {
                RightButtonHolding();
            }

            Updating?.Invoke();

            yield return(null);
        }
    }
Example #10
0
        private void Update()
        {
            isNotUpdating.Reset();

            Updating?.Invoke(this, EventArgs.Empty);

            isNotUpdating.Set();
        }
        /// <summary>
        /// Message Handler that removes a configuration from the cache when the value is updated
        /// </summary>
        /// <param name="target">A message containing the configuration to be removed</param>
        public void AcceptMessage(Updating <CmsConfiguration> target)
        {
            if (target is null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            CachedValues.TryRemove(target.Target.Name, out object _);
        }
Example #12
0
        /// <summary>
        /// A message handler for the "Update" event that sets the modified property
        /// </summary>
        /// <param name="updateMessage"></param>
        public virtual void AcceptMessage(Updating <T> updateMessage)
        {
            if (updateMessage is null)
            {
                throw new ArgumentNullException(nameof(updateMessage));
            }

            updateMessage.Target.DateModified = DateTime.Now;
        }
        /// <summary>
        /// A message handler for handling changes to email messages. Used to set the state to "debug" if the website is in debug mode, per the configuration service
        /// </summary>
        /// <param name="updateMessage">The message containing the email being updated.</param>
        public void AcceptMessage(Updating <EmailMessage> updateMessage)
        {
            Contract.Requires(updateMessage != null);

            if (this.ConfigurationService.IsDebug())
            {
                updateMessage.Target.State = EmailMessageState.Debug;
            }
        }
        /* Crud */
        public Comment Save(Comment comment, bool updateTopicPostCount = true)
        {
            var newComment = comment.Id <= 0;
            var eventArgs  = new CommentEventArgs()
            {
                Comment = comment
            };

            if (newComment)
            {
                Creating.Raise(this, eventArgs);
            }
            else
            {
                Updating.Raise(this, eventArgs);
            }

            if (!eventArgs.Cancel)
            {
                //save comment
                _databaseContext.Database.Save(comment);


                //topic post count
                if (updateTopicPostCount)
                {
                    UpdateTopicPostsCount(comment);
                }

                //parent comment state
                if (comment.ParentCommentId > 0)
                {
                    var p = GetById(comment.ParentCommentId);
                    if (p != null)
                    {
                        p.HasChildren = true;
                    }
                    Save(p, false);
                }

                if (newComment)
                {
                    Created.Raise(this, eventArgs);
                }
                else
                {
                    Updated.Raise(this, eventArgs);
                }
            }
            else
            {
                CancelledByEvent.Raise(this, eventArgs);
            }

            return(comment);
        }
Example #15
0
 /// <summary>
 /// Handles the needed event-calls before updating.
 /// </summary>
 private void OnUpdating(IUpdateTrigger trigger, CustomUpdateData customData)
 {
     try
     {
         double deltaTime = _deltaTimeCounter.Elapsed.TotalSeconds;
         _deltaTimeCounter.Restart();
         Updating?.Invoke(new UpdatingEventArgs(deltaTime, trigger, customData));
     }
     catch { /* Well ... that's not my fault */ }
 }
Example #16
0
 /// <summary>
 /// Handles the needed event-calls before updating.
 /// </summary>
 private void OnUpdating()
 {
     try
     {
         long lastUpdateTicks = _lastUpdate.Ticks;
         _lastUpdate = DateTime.Now;
         Updating?.Invoke(new UpdatingEventArgs((DateTime.Now.Ticks - lastUpdateTicks) / 10000000.0));
     }
     catch { /* Well ... that's not my fault */ }
 }
Example #17
0
        public override void AcceptMessage(Updating <DatabaseFile> update)
        {
            if (update is null)
            {
                throw new ArgumentNullException(nameof(update));
            }

            this.Process(update.Target);
            base.AcceptMessage(update);
        }
Example #18
0
        public virtual void AddObjects(IEnumerable <ISearchable> searchables)
        {
            Initialize();

            Updating?.Invoke(this, EventArgs.Empty);

            lock (_lockObject)
            {
                using (var analyzer = new StandardAnalyzer(LuceneDefaults.Version))
                {
                    using (var writer = new IndexWriter(_indexDirectory, CreateIndexWriterConfig(analyzer)))
                    {
                        foreach (var searchable in searchables)
                        {
                            var index = _currentIndex++;
                            _indexedObjects.Add(index, searchable);
                            _searchableIndexes.Add(searchable, index);

                            var document = new Document();

                            var indexField = new StringField(IndexId, index.ToString(), Field.Store.YES);

                            document.Add(indexField);

                            var metadata            = searchable.MetadataCollection;
                            var searchableMetadatas = metadata.All.OfType <ISearchableMetadata>();

                            foreach (var searchableMetadata in searchableMetadatas)
                            {
                                if (searchableMetadata.GetValue <object>(searchable.Instance, out var searchableMetadataValue))
                                {
                                    var searchableMetadataValueAsString = ObjectToStringHelper.ToString(searchableMetadataValue);

                                    var field = new TextField(searchableMetadata.SearchName, searchableMetadataValueAsString, Field.Store.YES);
                                    document.Add(field);

                                    if (!_searchableMetadata.ContainsKey(searchableMetadata.SearchName))
                                    {
                                        _searchableMetadata.Add(searchableMetadata.SearchName, searchableMetadata);
                                    }
                                }
                            }

                            writer.AddDocument(document);
                        }

                        writer.PrepareCommit();
                        writer.Commit();
                    }
                }
            }

            Updated?.Invoke(this, EventArgs.Empty);
        }
        public override void AcceptMessage(Updating <NavigationMenuItem> update)
        {
            if (update is null)
            {
                throw new System.ArgumentNullException(nameof(update));
            }

            update.Target.UpdateProperties();

            base.AcceptMessage(update);
        }
Example #20
0
        /// <inheritdoc/>
        public void Update(UltravioletTime time)
        {
            Contract.EnsureNotDisposed(this, Disposed);

            this.keyboard.Update(time);
            this.mouse.Update(time);
            this.gamePadInfo.Update(time);
            this.touchInfo.Update(time);

            Updating?.Invoke(this, time);
        }
Example #21
0
 public void SetUp()
 {
     _output = Substitute.For <IOutput>();
     _transponderReceiver = Substitute.For <ITransponderReceiver>();
     _parsing             = new Parsing(_transponderReceiver);
     _airspace            = new Airspace();
     _filtering           = new Filtering(_airspace, _parsing);
     _calculating         = new Calculating();
     _updating            = new Updating(_filtering, _calculating);
     _uut = new Rendering(_updating, _output);
     transponderDataInside = "ATR423;39045;12932;14000;20151006213456789";
 }
Example #22
0
 /// <summary>
 /// Handles the needed event-calls before updating.
 /// </summary>
 protected virtual void OnUpdating()
 {
     try
     {
         long lastUpdateTicks = _lastUpdate.Ticks;
         _lastUpdate = DateTime.Now;
         Updating?.Invoke(this, new UpdatingEventArgs((DateTime.Now.Ticks - lastUpdateTicks) / 10000000f));
     }
     catch
     {
         // Well ... that's not my fault
     }
 }
        public void ApplySettings(IActivityMonitor m)
        {
            if (!_f.EnsureDirectory(m))
            {
                return;
            }
            var s = _driver.GetSolution(m, allowInvalidSolution: true);

            if (s == null)
            {
                return;
            }

            if (_driver.BuildRequiredSecrets.Count == 0)
            {
                m.Warn("No build secrets collected for this solution. Skipping KeyVault configuration.");
                return;
            }

            var passPhrase = _secretStore.GetSecretKey(m, SolutionDriver.CODECAKEBUILDER_SECRET_KEY, true);

            // Opens the actual current vault: if more secrets are defined we keep them.
            Dictionary <string, string> current = KeyVault.DecryptValues(TextContent, passPhrase);

            current.Clear();

            // The central CICDKeyVault is protected with the same CODECAKEBUILDER_SECRET_KEY secret.
            Dictionary <string, string> centralized = KeyVault.DecryptValues(_sharedState.CICDKeyVault, passPhrase);

            bool complete = true;

            foreach (var name in _driver.BuildRequiredSecrets.Select(x => x.SecretKeyName))
            {
                if (!centralized.TryGetValue(name, out var secret))
                {
                    m.Error($"Missing required build secret '{name}' in central CICDKeyVault. It must be added.");
                    complete = false;
                }
                else
                {
                    current[name] = secret;
                }
            }
            if (complete)
            {
                Updating?.Invoke(this, new CodeCakeBuilderKeyVaultUpdatingArgs(m, _solutionSpec, s, current));
                string result = KeyVault.EncryptValuesToString(current, passPhrase);
                CreateOrUpdate(m, result);
            }
        }
        public virtual void AddObjects(IEnumerable <ISearchable> searchables)
        {
            Initialize();

            Updating.SafeInvoke(this);

            lock (_lockObject)
            {
                using (var analyzer = new StandardAnalyzer(LuceneDefaults.Version))
                {
                    using (var writer = new IndexWriter(_indexDirectory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED))
                    {
                        foreach (var searchable in searchables)
                        {
                            var index = _currentIndex++;
                            _indexedObjects.Add(index, searchable);
                            _searchableIndexes.Add(searchable, index);

                            var document = new Document();
                            document.Add(new Field(IndexId, index.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));

                            var metadata            = searchable.MetadataCollection;
                            var searchableMetadatas = metadata.All.OfType <ISearchableMetadata>();

                            foreach (var searchableMetadata in searchableMetadatas)
                            {
                                var searchableMetadataValue         = searchableMetadata.GetValue(searchable.Instance);
                                var searchableMetadataValueAsString = ObjectToStringHelper.ToString(searchableMetadataValue);

                                var field = new Field(searchableMetadata.SearchName, searchableMetadataValueAsString, Field.Store.YES, searchableMetadata.Analyze ? Field.Index.ANALYZED : Field.Index.NOT_ANALYZED, Field.TermVector.NO);

                                document.Add(field);

                                if (!_searchableMetadata.ContainsKey(searchableMetadata.SearchName))
                                {
                                    _searchableMetadata.Add(searchableMetadata.SearchName, searchableMetadata);
                                }
                            }

                            writer.AddDocument(document);
                        }

                        writer.Optimize();
                        writer.Commit();
                    }
                }
            }

            Updated.SafeInvoke(this);
        }
Example #25
0
        static void Main(string[] args)
        {
            var transponderReceiver   = TransponderReceiverFactory.CreateTransponderDataReceiver();
            var transponderdataReader = new Parsing(transponderReceiver);
            var airspace    = new Airspace();
            var filtering   = new Filtering(airspace, transponderdataReader);
            var calc        = new Calculating();
            var trackUpdate = new Updating(filtering, calc);
            var output      = new Output();
            //var proximityDetection = new ProximityDetection(trackUpdate);
            var trackRender = new Rendering(trackUpdate, output);

            //var eventRender = new EventRender(proximityDetection);

            Console.ReadLine();
        }
Example #26
0
        public override void AcceptMessage(Updating <JsonForm> update)
        {
            if (update is null)
            {
                throw new ArgumentNullException(nameof(update));
            }

            Type ConcreteForm = GetConcreteFormType(update.Target.Name);

            if (ConcreteForm != null)
            {
                throw new Exception(FORM_NAME_COLLISION_MESSAGE);
            }

            base.AcceptMessage(update);
        }
        public static void AcceptMessage(Updating <DatabaseFile> message)
        {
            if (message is null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            if (ExistingFiles.ContainsKey(message.Target.FilePath))
            {
                ExistingFiles[message.Target.FilePath] = !message.Target.IsDeleted;
            }
            else
            {
                ExistingFiles.TryAdd(message.Target.FilePath, !message.Target.IsDeleted);
            }
        }
 public ActionResult ChangeStatus(int Solicitud, int Status)
 {
     Updating update = new Updating() { Message = "Proceso de Actualización Exitosa." };
     using (var db = new Entities())
     {
         var solicitud = db.SS_SolicitudServicio.Find(Solicitud);
         solicitud.ST_Id = Status;
         db.Entry(solicitud).State = EntityState.Modified;
         db.SaveChanges();
         if (Status == 3)
         {
             SendEmailNotification(solicitud, true);
         }
     }
     return Json(update.SerializeToJson(), JsonRequestBehavior.AllowGet);
 }
Example #29
0
        /// <inheritdoc/>
        public void Update(UltravioletTime time)
        {
            Contract.EnsureNotDisposed(this, Disposed);

            var result = default(FMOD_RESULT);

            result = FMOD_System_Update(system);
            if (result != FMOD_OK)
            {
                throw new FMODException(result);
            }

            UpdateAudioDevices();

            Updating?.Invoke(this, time);
        }
Example #30
0
        public void SetUp()
        {
            _nEventsReceived     = 0;
            _transponderReceiver = Substitute.For <ITransponderReceiver>();
            _parsing             = new Parsing(_transponderReceiver);
            _airspace            = new Airspace();
            _filtering           = new Filtering(_airspace, _parsing);
            _calculating         = new Calculating();
            _uut = new Updating(_filtering, _calculating);
            transponderDataInside  = "ATR423;39045;12932;14000;20151006213456789";
            transponderDataInside2 = "ATR423;39045;12937;14000;20151006213457789";

            _uut.TracksUpdated += (o, args) =>
            {
                _updatedTracks = args.UpdatedTracks;
                ++_nEventsReceived;
            };
        }
Example #31
0
 private void RaiseUpdatingHelper(float delta)
 {
     if (Current.Active)
     {
         Command.ResetConsumedCommands();
         CommandQueue.Instance.IssueCommands();
         try {
             Updating?.Invoke(delta);
             CommandHandlerList.Global.ProcessCommands();
         } finally {
             Application.MainMenu?.Refresh();
         }
     }
     else
     {
         Updating?.Invoke(delta);
     }
 }