private void RemoteCallHandler(PatcherIpcEnvelope envelope)
        {
            switch (envelope.OpCode)
            {
            case PatcherIpcOpCode.Hello:
                //_client.Initialize(_clientPort);
                Log.Information("[PATCHERIPC] GOT HELLO");
                State = InstallerState.Ready;
                break;

            case PatcherIpcOpCode.InstallOk:
                Log.Information("[PATCHERIPC] INSTALL OK");
                State = InstallerState.Ready;
                break;

            case PatcherIpcOpCode.InstallFailed:
                State = InstallerState.Failed;
                OnFail?.Invoke();

                Stop();
                Environment.Exit(0);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #2
0
        public void Disconnect(LoginClient client)
        {
            lock (Clients)
                Clients.Remove(client);

            OnFail?.Invoke(client);
        }
Exemple #3
0
        public void FishingEnd(bool success)
        {
            foreach (Fish f in Fishes)
            {
                f.FishingEnd();
            }

            areaCollider.enabled = true;

            FishingControls?.Disable();
            FishingControls?.Dispose();
            FishingControls = null;

            Debug.Log("Stopped fishing.");

            if (_fishingBehaviourScript == null)
            {
                return;
            }

            if (success)
            {
                ActiveFish.ForceStopAI();
                Debug.Log("Fish Caught!");
            }
            else
            {
                OnFail?.Invoke();
                Debug.Log("Fish Got Away...");
            }

            Destroy(_fishingBehaviourScript.gameObject);
        }
Exemple #4
0
        IEnumerator Download(string url, OnSuccess onSuccess, OnFail onFail)
        {
            WWW www = new WWW(url);

            yield return(www);

            if (www.isDone)
            {
                byte[] data = www.bytes;
                if (String.IsNullOrEmpty(www.error))
                {
                    if (onSuccess != null)
                    {
                        onSuccess(www);
                    }
                }
                else
                {
                    if (onFail != null)
                    {
                        onFail(www.error);
                    }
                }
            }
        }
Exemple #5
0
    IEnumerator WaitForReload(float time)
    {
        yield return(new WaitForSeconds(time));

        _audioSource.clip = AudioList.Instance.puzzleerror;
        _audioSource.Play();
        OnFail.Invoke();
    }
Exemple #6
0
 public static void notNull(object obj, OnFail onFail, string msg, params object[] args)
 {
     if (obj != null)
     {
         return;
     }
     AssertFail(onFail, msg, args);
 }
Exemple #7
0
 public static void isTrue(bool exp, OnFail onFail, string msg, params object[] args)
 {
     if (exp)
     {
         return;
     }
     AssertFail(onFail, msg, args);
 }
        public async Task Start(Stream stream)
        {
            try {
                using (var parser = new Parser(this.stream = stream)) {
                    if (!storage.Recycle(out var buffer, true))
                    {
                        throw new Exception("Unable to recycle buffer");
                    }
                    for (int endMember; (endMember = await parser.Find("/members/member")) != -1 && !storage.IsClosed;)
                    {
                        try {
                            if (SkipEvery < 1)
                            {
                                ++Records;
                            }
                            else if ((Records++ + StartAt) % (SkipEvery + 1) != 0)
                            {
                                continue;
                            }
                            Position = parser.Current;
                            var p = new Member();
                            await p.Load(parser, endMember, maxDataSize);

                            ++Processed;
                            p.Validate();
                            buffer.Add(p);
                            if (buffer.IsFull)
                            {
                                storage.Store(buffer);
                                OnProgress?.Invoke(this, (double)stream.Position / stream.Length);
                                if (!storage.Recycle(out buffer, true))
                                {
                                    throw new Exception("Unable to recycle buffer");
                                }
                            }
                        }
                        catch (Exception e) when(e is EPersonInvalid || e is Parser.EMaxLengthExceeded)
                        {
                            ++Invalid;
                            OnInvalidItem?.Invoke(this, e);
                        }
                    }
                    if (buffer.Count > 0)
                    {
                        storage.Store(buffer);
                    }
                }
                OnProgress?.Invoke(this, 1);
            }
            catch (Exception e) {
                OnFail?.Invoke(this, e);
                throw;
            }
        }
Exemple #9
0
        public void HandleFail(Exception ex, int retryCount, long elapsedMilliseconds)
        {
            var eventType = string.Format("{0}_Failed", eventName);
            var message   = string.Format("Event {0} failed, Retries {1}, Exception {2}", ex.GetType().Name, eventName, ex);

            if (OnFail != null)
            {
                OnFail.Invoke(ex);
            }

            TraceEvent(eventType, message, retryCount, elapsedMilliseconds);
        }
        public async Task Start()
        {
            try {
                await Setup();

                using (var update = GetUpdateCommand()) {
                    while (!storage.IsClosed || storage.StorageCount > 0)
                    {
                        //Nothing to consume, breaks the loop
                        if (!storage.Take(out var buffer, true))
                        {
                            break;
                        }
                        try {
                            using (var transaction = db.BeginTransaction(System.Data.IsolationLevel.ReadCommitted)) {
                                var records = buffer.Count;
                                using (var writer = db.BeginBinaryImport("COPY synchronize__person (fname, lname, dob, phone) FROM STDIN (FORMAT BINARY)")) {
                                    for (var i = -1; ++i < buffer.Count;)
                                    {
                                        buffer[i].Save(writer);
                                    }
                                    writer.Complete();
                                    writer.Close();
                                }
                                await update.ExecuteNonQueryAsync();

                                await transaction.CommitAsync();

                                Imported += records;
                                buffer.Clear();
                                //Sends the buffer back to be recycled by another Producer
                                storage.Waste(buffer);
                            }
                        }
                        catch {
                            //Failed to save the buffer, return it to the storage
                            storage.Store(buffer);
                            throw;
                        }
                    }
                }
            }
            catch (Exception e) {
                OnFail?.Invoke(this, e);
                throw;
            }
            finally {
                await Teardown();
            }
        }
Exemple #11
0
 private static void AssertFail(OnFail onFail, string msg, params object[] args)
 {
     if (onFail != null)
     {
         onFail();
     }
     if (args == null)
     {
         throw new Exception(msg);
     }
     else
     {
         throw new Exception(string.Format(msg, args));
     }
 }
        public void Dispose()
        {
            GCHandle handle = GCHandle.Alloc(array, GCHandleType.Pinned);   //no method to copy from IntPtr to IntPtr
            int      bytes  = Count * size;

            Copy(handle.AddrOfPinnedObject(), Ptr, bytes);
            handle.Free();

            bool result = GL.UnmapNamedBuffer(ID);

            if (result)
            {
                OnFail?.Invoke(ID);
                callback?.Invoke(ID);
            }
            GC.SuppressFinalize(this);
        }
Exemple #13
0
    public void FinishMoving(bool isOnlyMoving)
    {
        if (isOnlyMoving)
        {
            currentMoving      = null;
            transform.position = new Vector3(10, 10, 0);
            return;
        }

        var settings = currentMoving.GetComponent <PartSettings>();

        if ((settings.destinationObjectTag == null || settings.destinationObjectTag.Equals("")) && _carParts.TryToSetUpDetail(currentMoving, distanceToCorrectDrop))
        {
            generator.GenerateAllFreeSlots();
            AudioPlayPutDetail(currentMoving);
            Vibration.Vibrate(100);
            OnSuccess?.Invoke();
            print("Success");
            if (generator.IsAllDetailsSetUp())
            {
                FindObjectOfType <Level>().StartLevel();
            }
        }
        else if ((settings.destinationObjectTag != null && !settings.destinationObjectTag.Equals("")) &&
                 TryToSetUp(GameObject.FindGameObjectsWithTag(settings.destinationObjectTag), settings.destionationObjectRangeInstall,
                            settings.isColorMatching))
        {
            currentMoving.GetComponent <IInteractiveAction>().Action();
            OnSuccess?.Invoke();
            print("Success");
        }
        else
        {
            if (_carParts.IsInCarBase(currentMoving.transform.position))
            {
                AudioPlayError(currentMoving);
            }
            currentMoving.GetComponent <MovableObject>().ReturnToStartPosition();
            OnFail?.Invoke();
        }
        // transform.position = new Vector3(10, 10, 0);
        currentMoving = null;
    }
        void AttendBubble(GameObject bubble)
        {
            if (sequence.Peek() == bubble.GetComponent <SpriteRenderer>().sprite)
            {
                audioManager.PlayEnvironmentSound("BubbleExplosion");
                Destroy(bubble);
                sequence.Dequeue();
                OnScore.Invoke();

                if (hits >= bubbleCount)
                {
                    FinishGame();
                }
            }
            else
            {
                OnFail.Invoke();
            }
        }
Exemple #15
0
 protected bool HandleReadable(byte[] source)
 {
     lock (Sync)
     {
         if (PipedTo != null)
         {
             if (!PipedTo.Write(source))
             {
                 OnFail?.Invoke();
             }
             return(true);
         }
         if (_OnData != null)
         {
             _OnData(source); return(true);
         }
         return(Readable.Write(source));
     }
 }
Exemple #16
0
        /// <summary>
        /// Compile an Assembly from the given sources
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public Assembly Compile(string[] code)
        {
            var code_provider   = new CSharpCodeProvider();
            var code_parameters = new CompilerParameters();

            code_parameters.ReferencedAssemblies.AddRange(ReferencedAssemblies.ToArray());
            code_parameters.GenerateExecutable = false;
            code_parameters.GenerateInMemory   = false;
            var result = code_provider.CompileAssemblyFromSource(code_parameters, code);

            if (result.Errors.HasErrors)
            {
                foreach (var item in result.Errors)
                {
                    OnFail.Invoke(this, new Logging(item.ToString()));
                }
                return(null);
            }
            return(result.CompiledAssembly);
        }
Exemple #17
0
        // Starts a backoff operation. Accepts an optional parameter to let the listeners know why the backoff operation was started.
        public async Task DoBackoff(string err = null)
        {
            if (_timeoutId != null)
            {
                throw new InvalidOperationException("Backoff in progress.");
            }
            if (_backoffNumber == _maxNumberOfRetry)
            {
                OnFail?.Invoke(err);
                Reset();
            }
            else
            {
                OnBackoff?.Invoke(_backoffNumber, _backoffDelay, err);
                _backoffDelay = _backoffStrategy.Next();
                _timeoutId    = new CancellationTokenSource();
                await Task.Delay(_backoffDelay, _timeoutId.Token);

                OnBackoffInternal();
            }
        }
Exemple #18
0
        /// <summary>
        /// Invokes the proper status event based on the execution context's result status
        /// </summary>
        /// <param name="executionContext"></param>
        protected void InvokeStatusEvent(ExecutionContext executionContext)
        {
            switch (executionContext.Result.Status)
            {
            case TestStatus.Pass:
                OnPass.Invoke(executionContext);
                break;

            case TestStatus.Fail:
                OnFail.Invoke(executionContext);
                break;

            case TestStatus.Error:
                OnError.Invoke(executionContext);
                break;

            case TestStatus.Ignore:
                OnIgnore.Invoke(executionContext);
                break;
            }
        }
        private CSOMOperation executeContext(Func <CSOMOperation, Exception, CSOMOperation> localFailHandler, out bool successful)
        {
            LogTrace($"ThrowOnError set to: {ThrowOnError}, OnBeingExecuted defined: {OnBeingExecuted != null}, LocalFailHandler defined: {localFailHandler != null}, OnFail defined: {OnFail != null}");
            if (OnBeingExecuted != null)
            {
                LogDebug(Messages.AboutToCallExecutor);
                OnBeingExecuted.Invoke(Context);
            }

            try
            {
                LogTrace("Executing context");
                Context.ExecuteQuery();
                LogDebug(Messages.SuccededToExecute);
                successful = true;
                return(this);
            }
            catch (Exception ex)
            {
                LogWarn(string.Format(Messages.FailedToExecute, ex.Message));
                successful = false;

                if (localFailHandler != null)
                {
                    LogTrace("Calling local fail handler");
                    localFailHandler.Invoke(this, ex);
                    return(this);
                }

                if (ThrowOnError)
                {
                    throw;
                }

                OnFail?.Invoke(this, ex);

                return(this);
            }
        }
Exemple #20
0
        public void ExecuteStep()
        {
            try
            {
                SetStart();
                OnStart?.Invoke(Reference);

                Execute();
                OnSuccess?.Invoke(Reference, this);

                SetEnd();
            }
            catch (Exception e)
            {
                HasExecutionError = true;
                OnFail?.Invoke(Reference, e);
            }
            finally
            {
                OnFinish?.Invoke(Reference);
            }
        }
        public static void Start(object obj)
        {
            Setting setting = obj as Setting;

            if (obj == null)
            {
                return;
            }

            try
            {
                FileLoad(setting.FileName);
                Process(setting.Option);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "error", MessageBoxButton.OK);
                OnFail?.Invoke();
                return;
            }

            OnSuccess?.Invoke();
        }
 void TreatFailing()
 {
     OnFail?.Invoke(this.gameObject);
 }
 public virtual void Fail(System.Runtime.ExceptionServices.ExceptionDispatchInfo exceptionInfo)
 {
     OnFail?.Invoke(exceptionInfo);
 }
 private void TaskFail()
 {
     OnFail?.Invoke();
     Debug.Log("Wire task failed");
 }
Exemple #25
0
 public static void notNull(object obj, OnFail onFail, string msg)
 {
     notNull(obj, onFail, msg, null);
 }
 private void TaskFail()
 {
     _task.TaskUnsuccessful();
     OnFail?.Invoke();
 }
 protected void FailedCommand()
 {
     OnFail?.Invoke(this, EventArgs.Empty);
 }
Exemple #28
0
 private void OnFailCaller()
 {
     OnFail?.Invoke(this);
     OnDoneCaller();
 }
Exemple #29
0
 public static void isTrue(bool exp, OnFail onFail, string msg)
 {
     isTrue(exp, onFail, msg, null);
 }
Exemple #30
0
    public void SetupParams(Dictionary <string, string> data, OnSuccess successInvoke = null, OnFail failInvoke = null, bool autoStart = true, ServerType useServerType = 0, bool isuseZip = false)
    {
        this.server        = DataServer.instance;
        this.sendData      = data;
        this.useServerType = useServerType;
        //默认全部打开压缩
        this.useZip = true;

        if (successInvoke != null)
        {
            this.SuccessEvent = (OnSuccess)Delegate.Combine(this.SuccessEvent, successInvoke);
        }
        if (failInvoke != null)
        {
            this.FailEvent = (OnFail)Delegate.Combine(this.FailEvent, failInvoke);
        }
        if (autoStart)
        {
            this.StartRequest();
        }
    }