コード例 #1
0
        public void HandleMessage(MessageBase message)
        {
            List <AssetOp> opCopy;

            lock (_opList)
            {
                var msg = message as ClientGetOps;
                if (msg.ClearFailedOps)
                {
                    _opList.RemoveAll(x => x.Status == OpStatus.Failed);
                }
                opCopy = _opList.ToList();
            }

            HostOpStatus opstat = new HostOpStatus();

            foreach (var op in opCopy)
            {
                opstat.Ops.Add(new HostOp()
                {
                    ID = op.ID, OpDescription = op.GetType().Name, Status = op.Status, Error = op?.Exception?.Message
                });
            }

            _messageSender(opstat);
        }
コード例 #2
0
ファイル: BeatOnCore.cs プロジェクト: przemo-c/BeatOn
        private void OpManager_OpStatusChanged(object sender, QuestomAssets.AssetOps.AssetOp e)
        {
            List <AssetOp> opCopy;

            lock (_trackedOps)
            {
                if (!_trackedOps.Any(x => x.ID == e.ID))
                {
                    _trackedOps.Add(e);
                }

                _trackedOps.RemoveAll(x => x.Status == OpStatus.Complete);

                opCopy = _trackedOps.ToList();
            }

            HostOpStatus opstat = new HostOpStatus();

            foreach (var op in opCopy)
            {
                string exmsg = null;
                //if (op.Exception != null)
                //{
                //    exmsg = $"{op.Exception.Message} {op.Exception.StackTrace}";
                //    var ex = op.Exception.InnerException;
                //    while (ex != null)
                //    {
                //        exmsg += $"\nInnerException: {ex.Message} {ex.StackTrace}";
                //        ex = ex.InnerException;
                //    }
                //}
                opstat.Ops.Add(new HostOp()
                {
                    ID = op.ID, OpDescription = op.GetType().Name, Status = op.Status, Error = op.Exception?.Message
                });
            }
            lock (_sendClientOpsChangedLock)
            {
                if (_sendClientOpsChanged == null)
                {
                    _sendClientOpsChanged            = new Debouncey <HostOpStatus>(400, false);
                    _sendClientOpsChanged.Debounced += (e2, a) =>
                    {
                        SendMessageToClient(a);
                    };
                }
            }
            if (e.Status == OpStatus.Complete && e.IsWriteOp)
            {
                CurrentConfig.IsCommitted = CurrentConfig.IsCommitted && (!Engine.HasChanges);
                SendConfigChangeMessage();
            }
            _sendClientOpsChanged.EventRaised(this, opstat);
        }
コード例 #3
0
        private void OpManager_OpStatusChanged(object sender, QuestomAssets.AssetOps.AssetOp e)
        {
            List <AssetOp> opCopy;

            lock (_trackedOps)
            {
                if (!_trackedOps.Any(x => x.ID == e.ID))
                {
                    _trackedOps.Add(e);
                }

                _trackedOps.RemoveAll(x => x.Status == OpStatus.Complete);

                opCopy = _trackedOps.ToList();
            }

            HostOpStatus opstat = new HostOpStatus();

            foreach (var op in opCopy)
            {
                string exmsg = null;
                //if (op.Exception != null)
                //{
                //    exmsg = $"{op.Exception.Message} {op.Exception.StackTrace}";
                //    var ex = op.Exception.InnerException;
                //    while (ex != null)
                //    {
                //        exmsg += $"\nInnerException: {ex.Message} {ex.StackTrace}";
                //        ex = ex.InnerException;
                //    }
                //}
                opstat.Ops.Add(new HostOp()
                {
                    ID = op.ID, OpDescription = op.GetType().Name, Status = op.Status, Error = op.Exception?.Message
                });
            }
            lock (_sendClientOpsChangedLock)
            {
                if (_sendClientOpsChanged == null)
                {
                    _sendClientOpsChanged            = new Debouncey <HostOpStatus>(400, false);
                    _sendClientOpsChanged.Debounced += (e2, a) =>
                    {
                        lock (lastSendOpsLock)
                        {
                            lastOpsSendHadOps = (a.Ops.Count > 0);
                            SendMessageToClient(a);
                        }
                    };
                }
            }
            if (e.Status == OpStatus.Complete && e.IsWriteOp)
            {
                CurrentConfig.IsCommitted = CurrentConfig.IsCommitted && (!Engine.HasChanges);
                SendConfigChangeMessage();
            }
            //if the last send didn't have ops and this one does, send the message immediately in addition to debouncing it.
            //  this will send a duplicate message because the debounce is called in addition to the message being sent, but it'll assure keeping things in sync with the client
            lock (lastSendOpsLock)
            {
                if ((opstat.Ops.Count > 0) && !lastOpsSendHadOps)
                {
                    lastOpsSendHadOps = true;
                    SendMessageToClient(opstat);
                }
            }
            _sendClientOpsChanged.EventRaised(this, opstat);
        }