Ejemplo n.º 1
0
        public void start()
        {
            //Register listener
            var listener = new Listen();

            ActionUtil.AddListener(listener);
        }
Ejemplo n.º 2
0
        public T Run <T>(DataBus dataBus, string code) where T : class
        {
            //string serializedCode = SerializeCode(code);
            string      serializedCode = code;
            DebugAction debugAction    = new DebugAction(dataBus);

            debugAction.CommandLine = serializedCode;
            //string.Format(codeFormat, serializedCode);
            HttpResponseMessage response = debugAction.DoAction();

            Execute excuteObject = debugAction.ResponseData as Execute;

            ActionUtil.StoreMessages(excuteObject.ClientRequestEntity);
            while (excuteObject.ClientRequestEntity.Messages.Rearm)
            {
                //Get messages
                MessageResponseAction messageResponseAction = new MessageResponseAction(dataBus);

                response     = messageResponseAction.DoAction();
                excuteObject = messageResponseAction.ResponseData as Execute;
                ActionUtil.StoreMessages(excuteObject.ClientRequestEntity);
            }
            if (typeof(T) == typeof(JsonRaw))
            {
                JsonRaw jsonRaw = new JsonRaw();
                jsonRaw.Text = excuteObject.ClientRequestEntity.Messages[0].Text;
                //response. GetContent();
                return(jsonRaw as T);
            }
            string resultStr = excuteObject.ClientRequestEntity.Messages[0].Text;

            return(JsonToObject <T>(resultStr));
        }
        private void OnDataReceived(object sender, SocketDataReceived e)
        {
            try
            {
                if (_isDisposed || e.Packet == null)
                {
                    return;
                }

                var packet = (Packet)e.Packet;
                packet.ClientReceiveTime = e.Time;

                if (ActionUtil.IsInternalAction(packet.Action, GSLiveType.RealTime))
                {
                    _responseHandlers.GetValue(packet.Action)?.HandlePacket(packet, packet.SendType);
                }
                else
                {
                    GameService.SynchronizationContext?.Send(
                        delegate { _responseHandlers.GetValue(packet.Action)?.HandlePacket(packet, packet.SendType); },
                        null);
                }
            }
            catch (Exception exception)
            {
                exception.LogException <RealTimeHandler>(DebugLocation.RealTime, "OnDataReceived");
            }
        }
Ejemplo n.º 4
0
        private void OnDataReceived(object sender, SocketDataReceived e)
        {
            try
            {
                if (e.Packet == null)
                {
                    return;
                }

                var packet = (Packet)e.Packet;

                if (ActionUtil.IsInternalAction(packet.Action, GSLiveType.TurnBased))
                {
                    _responseHandlers.GetValue(packet.Action)?.HandlePacket(packet);
                }
                else
                {
                    GameService.SynchronizationContext?.Send(
                        delegate { _responseHandlers.GetValue(packet.Action)?.HandlePacket(packet); }, null);
                }
            }
            catch (Exception exception)
            {
                exception.LogException <TurnBasedHandler>(DebugLocation.TurnBased, "OnDataReceived");
            }
        }
Ejemplo n.º 5
0
        protected override void Execute(Hashtable Params)
        {
            switch (ActionUtil.GetCmd(Params))
            {
            case ActionUtil.AutoRun:
                CBTypes.Items.Add(account_type.NormalAcount);
                CBTypes.Items.Add(account_type.VirtualAccount);
                CBTypes.Items.Add(account_type.AgentAccount);
                CBTypes.Items.Add(account_type.ManageAccount);
                CBTypes.SelectedIndex = 0;

                _objValidationHelper.Add(TxtAccountID);
                _objValidationHelper.Add(TxtPassword);
                _objValidationHelper.Add(TxtConfirm);
                _objValidationHelper.Add(CBTypes);
                _objValidationHelper.Add(TxtParentAgent);

                standardGrid1.DataMember = DictSet.TableName;
                standardGrid1.DataSource = MemberDBUtils.GetMemberDigest(GetControl());

                _objValidationHelper.ResetAllState(false, false);
                _objValidationHelper.ValidateAll();
                break;
            }

            base.Execute(Params);
        }
        /// <summary>
        /// Run a Function method on remote clients of this room (or on all, including this client).
        /// </summary>
        /// <param name="functionName">The name of a fitting function that was has the GsLiveFunction attribute.</param>
        /// <param name="type">The group of targets and the way the Function gets sent.</param>
        /// <param name="parameters">The Parameters that the Function method has.</param>
        public static void RunFunction <TFrom>(string functionName, FunctionType type, params object[] parameters)
        {
            if (!IsAvailable)
            {
                throw new GameServiceException("GsLiveRealtime is Not Available");
            }

            if (!FiroozehGameService.Core.GameService.GSLive.IsRealTimeAvailable())
            {
                throw new GameServiceException("RealTime is Not Available");
            }

            var objType = typeof(TFrom);

            _monoBehaviourHandler.RefreshMonoBehaviourCache();
            var isOk = _functionHandler.RunFunction(functionName, objType, type, parameters);

            if (!isOk)
            {
                return;
            }


            var extraBuffer  = GsSerializer.Function.SerializeParams(parameters);
            var functionData = new FunctionData(objType.FullName, functionName, type, extraBuffer);

            // run on this Client
            if (type == FunctionType.All || type == FunctionType.Buffered)
            {
                ActionUtil.ApplyFunction(functionData: functionData, monoBehaviourHandler: _monoBehaviourHandler);
            }

            SenderUtil.NetworkRunFunction(functionData);
        }
Ejemplo n.º 7
0
    private TutorialPointer ShowPointer(GameObject obj, bool changeParent, Action onHide)
    {
        var    element       = UIManager.Instance.GetElement <TutorialElement>();
        Action restoreParent = null;

        if (changeParent)
        {
            restoreParent = TutorialService.Instance.ChangeParent(obj.transform, element.ObjectParent);
            element.ShowLockLayer();
        }

        element.ShowPointer(obj);

        Action hideAction = () =>
        {
            ActionUtil.ExecuteOnce(ref restoreParent);
            element.HideLockLayer();
            element.HidePointer();
            onHide.Execute();
        };

        var pointer = new TutorialPointer
        {
            Pointer    = element.Pointer,
            HideAction = hideAction
        };

        return(pointer);
    }
Ejemplo n.º 8
0
        protected override void Execute(Hashtable Params)
        {
            switch (ActionUtil.GetCmd(Params))
            {
            case CAppendNode4List:
                AppendNode4List(Params);
                break;

            case CInsertChild4List:
                InsertChild4List(Params);
                break;

            case CMarkDelete4List:
                MarkDelete4List(Params);
                break;

            case CDisableSelected:
                DisableSelected(Params);
                break;

            case CEnableSelected:
                EnableSelected(Params);
                break;
            }
        }
Ejemplo n.º 9
0
 protected void Finish()
 {
     TutorialService.Instance.SetFinishTutorial(GetType(), () =>
     {
         ActionUtil.ExecuteOnce(ref _onSuccess);
     });
 }
Ejemplo n.º 10
0
        public KeyboardController(MarioGame game)
        {
            this.game = game;

            downActions    = new Dictionary <Keys, Action>();
            pressActions   = new Dictionary <Keys, Action>();
            releaseActions = new Dictionary <Keys, Action>();

            previous = Keyboard.GetState();

            this.OnKeyPressed(Keys.Q, game.Exit);
            this.OnKeyPressed(Keys.R, game.LevelReset);
            this.OnKeyPressed(Keys.M, game.MenuReset);
            this.OnKeyPressed(Keys.Enter, InputActions.start);

            this.OnKeyPressed(Keys.Up, ActionUtil.Chain(InputActions.jump, InputActions.menuUp));
            this.OnKeyPressed(Keys.W, ActionUtil.Chain(InputActions.jump, InputActions.menuUp));
            this.OnKeyPressed(Keys.Space, ActionUtil.Chain(InputActions.jump, InputActions.menuUp));

            this.OnKeyDownRelease(Keys.Left, InputActions.moveLeft, InputActions.halt);
            this.OnKeyDownRelease(Keys.A, InputActions.moveLeft, InputActions.halt);
            this.OnKeyDownRelease(Keys.Right, InputActions.moveRight, InputActions.halt);
            this.OnKeyDownRelease(Keys.D, InputActions.moveRight, InputActions.halt);

            this.OnKeyPressed(Keys.F, InputActions.fire);

            this.OnKeyDown(Keys.Down, InputActions.crouch);
            this.OnKeyDown(Keys.S, InputActions.crouch);


            this.OnKeyPressed(Keys.Down, InputActions.menuDown);
            this.OnKeyPressed(Keys.S, InputActions.menuDown);
        }
Ejemplo n.º 11
0
 public void Start()
 {
     lock (this)
     {
         if (_started)
         {
             return;
         }
         _started = true;
     }
     ActionUtil.RunAsync(() =>
     {
         try
         {
             SendRequest();
         }
         finally
         {
             lock (this)
             {
                 _finished = true;
                 ChromTaskList.OnTaskCompleted(this);
             }
         }
     });
 }
Ejemplo n.º 12
0
        public bool AsyncFetchContents(ChorusAccount chorusAccount, ChorusUrl chorusUrl, out ChorusServerException chorusException)
        {
            Uri requestUri = GetContentsUri(chorusAccount, chorusUrl);

            if (null == requestUri)
            {
                chorusException = null;
                return(true);
            }
            RequestKey requestKey = new RequestKey(chorusAccount, requestUri);

            lock (_lock)
            {
                ChorusContentsResponse chorusContentsResponse;
                if (_chorusContentsByServerUrl.TryGetValue(requestKey, out chorusContentsResponse))
                {
                    chorusException = chorusContentsResponse.ChorusException;
                    return(chorusContentsResponse.IsComplete);
                }
                chorusException = null;
                if (!_fetchRequests.Add(requestKey))
                {
                    return(false);
                }
            }
            ActionUtil.RunAsync(() => FetchAndStoreContents(chorusAccount, requestUri), "Fetch from Chorus");   // Not L10N
            return(false);
        }
Ejemplo n.º 13
0
 protected bool AsyncFetch <T>(Uri requestUri, Func <Uri, T> fetcher, out RemoteServerException remoteException)
 {
     if (null == requestUri)
     {
         remoteException = null;
         return(true);
     }
     lock (_lock)
     {
         RemoteResponse response;
         var            key = new RequestKey(typeof(T), requestUri);
         if (_responses.TryGetValue(key, out response))
         {
             remoteException = response.Exception;
             return(true);
         }
         remoteException = null;
         if (!_fetchRequests.Add(key))
         {
             return(false);
         }
     }
     ActionUtil.RunAsync(() => FetchAndStore(requestUri, fetcher));
     return(false);
 }
Ejemplo n.º 14
0
        private void FilterRows()
        {
            if (!_allowUpdateGrid)
            {
                return;
            }

            if (_cancellationTokenSource != null)
            {
                _cancellationTokenSource.Cancel();
            }

            _cancellationTokenSource = new CancellationTokenSource();
            _filteredRows            = null;
            var expr = GetCurrentMatchExpression();

            if (expr.IsRegexValid())
            {
                Cursor = Cursors.WaitCursor;

                ActionUtil.RunAsync(() =>
                {
                    GetFilteredRows(_cancellationTokenSource.Token, _foldChangeRows, expr);
                });
            }
            else
            {
                _filteredRows = new List <StringWrapper>();
                UpdateGrid(expr);
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Start background rendering thread.
 /// </summary>
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     if (!DesignMode)
     {
         ActionUtil.RunAsync(BackgroundRender, _backgroundThreadName);
     }
 }
Ejemplo n.º 16
0
 public void Initialize(TimedTask timer)
 {
     Logger.Info("Plugin version is " + PluginVersion);
     Config.Instance.Initialize();
     TimerUtil.Instance.RestartTimers();
     Status = "EcoLiveDataExporter fully initialized!";
     ActionUtil.AddListener(this);
 }
Ejemplo n.º 17
0
 public async ValueTask DisposeAsync()
 {
     await ActionUtil.ExecuteAll(
         () => _receiverLink.CloseAsync(),
         () => _senderLink.CloseAsync(),
         () => _senderLink.Session.CloseAsync()
         ).ConfigureAwait(false);
 }
Ejemplo n.º 18
0
 protected override void Execute(Hashtable Params)
 {
     switch (ActionUtil.GetCmd(Params))
     {
     case CGetQRImage:
         GetQRImage(Params);
         break;
     }
 }
Ejemplo n.º 19
0
 private void OnTweenComplete(long lockId)
 {
     Unlock(lockId);
     ActionUtil.ExecuteOnce(ref BeforeOnClick);
     if (OnClick != null)
     {
         OnClick.Invoke();
     }
 }
Ejemplo n.º 20
0
 protected virtual void Execute(Hashtable Params)
 {
     switch (ActionUtil.GetCmd(Params))
     {
     default:
         PickParam(Params).SetError(string.Format("未找到处理该命令的执行体!{0}", ActionUtil.GetCmd(Params)));
         break;
     }
 }
Ejemplo n.º 21
0
        public void PerformWork(Control parent, int delayMillis, Action <ILongWaitBroker> performWork)
        {
            _startTime  = DateTime.UtcNow; // Said to be 117x faster than Now and this is for a delta
            _parentForm = parent;
            try
            {
//                Action<Action<ILongWaitBroker>> runner = RunWork;
//                _result = runner.BeginInvoke(performWork, runner.EndInvoke, null);
                ActionUtil.RunAsync(() => RunWork(performWork));

                // Wait as long as the caller wants before showing the progress
                // animation to the user.
//                _result.AsyncWaitHandle.WaitOne(delayMillis);

                // Return without notifying the user, if the operation completed
                // before the wait expired.
//                if (_result.IsCompleted)
                if (_completionEvent.WaitOne(delayMillis))
                {
                    return;
                }

                progressBar.Value = Math.Max(0, _progressValue);
                if (_message != null)
                {
                    labelMessage.Text = _message;
                }

                ShowDialog(parent);
            }
            finally
            {
                var x = _exception;

                // Get rid of this window before leaving this function
                Dispose();
                _completionEvent.Dispose();

                if (IsCanceled && null != x)
                {
                    if (x is OperationCanceledException || x.InnerException is OperationCanceledException)
                    {
                        x = null;
                    }
                }

                if (x != null)
                {
                    Helpers.WrapAndThrowException(x);
                }
            }
        }
Ejemplo n.º 22
0
        private void DoUpdateRemaining(CancellationToken cancellationToken)
        {
            btnOK.Enabled           = false;
            DocumentFinalCalculated = false;

            lblRemaining.Text     = Resources.PeptidesPerProteinDlg_UpdateRemaining_Calculating___;
            lblEmptyProteins.Text = string.Empty;

            var keepAll = KeepAll;

            numMinPeptides.Enabled = !keepAll;

            ActionUtil.RunAsync(() =>
            {
                var doc             = _document;
                var minPeptides     = MinPeptides;
                var removeRepeated  = RemoveRepeatedPeptides;
                var removeDuplicate = RemoveDuplicatePeptides;
                SrmDocument docFinal;
                try
                {
                    docFinal = GetDocumentFinal(cancellationToken, doc, minPeptides, removeRepeated, removeDuplicate,
                                                out _documentFinalEmptyProteins);
                }
                catch (OperationCanceledException)
                {
                    docFinal = null;
                }
                if (cancellationToken.IsCancellationRequested || docFinal == null)
                {
                    return;
                }
                CommonActionUtil.SafeBeginInvoke(this, () =>
                {
                    DocumentFinal           = docFinal;
                    DocumentFinalCalculated = true;
                    btnOK.Enabled           = true;

                    if (keepAll)
                    {
                        lblEmptyProteins.Text = string.Format(_emptyProteinsText,
                                                              DocumentFinalEmptyProteins.GetValueOrDefault());
                    }

                    int proteinCount, peptideCount, precursorCount, transitionCount;
                    NewTargetsFinal(out proteinCount, out peptideCount, out precursorCount, out transitionCount);
                    lblRemaining.Text = FormatCounts(_remaniningText, proteinCount, peptideCount, precursorCount,
                                                     transitionCount);
                });
            });
        }
Ejemplo n.º 23
0
        public void GotoLink()
        {
            WebHelpers.OpenLink(_linkUrl);

            ActionUtil.RunAsync(() =>
            {
                Thread.Sleep(1000);
                Invoke(new Action(() =>
                {
                    SetForegroundWindow(Handle);
                    btnContinue.Focus();
                }));
            });
        }
Ejemplo n.º 24
0
 private void RunExecutable(SrmDocument document, IToolMacroProvider toolMacroProvider, TextWriter textWriter, IProgressMonitor progressMonitor, Control parent)
 {
     ActionUtil.RunAsync(() =>
     {
         try
         {
             RunExecutableBackground(document, toolMacroProvider, textWriter, progressMonitor, parent);
         }
         catch (Exception e)
         {
             progressMonitor.UpdateProgress(new ProgressStatus(string.Empty).ChangeErrorException(e));
         }
     }, @"Run Executable");
 }
Ejemplo n.º 25
0
 private void PostToLink(string url, SrmDocument doc, IProgressMonitor progressMonitor, IWebHelpers webHelpers)
 {
     ActionUtil.RunAsync(() =>
     {
         try
         {
             PostToLinkBackground(url, doc, progressMonitor, webHelpers);
         }
         catch (Exception exception)
         {
             progressMonitor.UpdateProgress(new ProgressStatus(string.Empty).ChangeErrorException(exception));
         }
     }, @"Post To Link");
 }
Ejemplo n.º 26
0
        public void ChooseDialog(int option)
        {
            if (_dialog == _raidPhase.Intro)
            {
                _dialog = _raidPhase.Dialogs[option];
            }
            else
            {
                _dialog = ActionUtil.PerformAction(_actionDialogModels, option);
            }

            AnimateText.SetTextButtonInteractable(true);
            NextStep();
            DialogOptions.HideDialogOptions();
        }
Ejemplo n.º 27
0
        protected override void Execute(System.Collections.Hashtable Params)
        {
            switch (ActionUtil.GetCmd(Params))
            {
            case ActionUtil.AutoRun:
                _objValidationHelper = new ControlValidationHelper(errorProvider1);
                _objValidationHelper.Add(TxtPassword);
                _objValidationHelper.Add(TxtConfirm);

                _objValidationHelper.ResetAllState(false, false);
                _objValidationHelper.ValidateAll();
                break;
            }

            base.Execute(Params);
        }
Ejemplo n.º 28
0
        protected override void Execute(Hashtable Params)
        {
            switch (ActionUtil.GetCmd(Params))
            {
            case CCreateNewAccount:
                CreateNewAccount(Params);
                break;

            case CChangePassword:
                ChangePassword(Params);
                break;

            case CDIGEST:
                DIGEST(Params);
                break;
            }
        }
Ejemplo n.º 29
0
        protected override void Execute(Hashtable Params)
        {
            switch (ActionUtil.GetCmd(Params))
            {
            case ActionUtil.AutoRun:
                // 初始化界面
                InitControls(PickParam(Params).GetValueAsString("代理商清单"), uConditionGridControl1);
                InitControls(PickParam(Params).GetValueAsString("下级代理"), uConditionGridControl2);
                InitControls(PickParam(Params).GetValueAsString("返利策略"), uConditionGridControl3);
                InitControls(PickParam(Params).GetValueAsString("每月流水"), uConditionGridControl4);
                InitControls(PickParam(Params).GetValueAsString("通行证"), uConditionGridControl5);
                InitControls(PickParam(Params).GetValueAsString("线上银行卡"), uConditionGridControl6);
                break;
            }

            base.Execute(Params);
        }
Ejemplo n.º 30
0
 private static void SendAnalyticsHitAsync()
 {
     if (!Install.Version.Equals(String.Empty) &&
         Install.Type != Install.InstallType.developer)
     {
         ActionUtil.RunAsync(() =>
         {
             try
             {
                 SendAnalyticsHit();
             }
             catch (Exception ex)
             {
                 Trace.TraceWarning(@"Exception sending analytics hit {0}", ex);
             }
         });
     }
 }
 /**
  * Sets the onclick action using the ActionUtil.Run delegate
  */
 public GUIButton OnClick(ActionUtil.Run r)
 {
     this.action = r;
     return this;
 }