Exemplo n.º 1
0
 private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     Finished?.Invoke(this, new EditResultEventArgs((IList <EditOperation>)e.Result));
     this.IsBusy = false;
 }
Exemplo n.º 2
0
 public void Stop()
 {
     _innerTimer.Stop();
     Finished?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 3
0
 protected bool Equals(JobExecutionRecord other)
 {
     return(Duration.Equals(other.Duration) && Finished.Equals(other.Finished) && Success.Equals(other.Success));
 }
Exemplo n.º 4
0
        private void ToManage_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
            {
                PlanifiedOperation Operation = (PlanifiedOperation)e.NewItems[0];
                if (Operation != null)
                {
                    Console.WriteLine("Perf - TaskManagement :  New operation will start at : {0} for {1} ", Operation.Start, Operation.OperationName);
                    Task.Factory.StartNew(() =>
                    {
                        object lo = new object();
                        System.Threading.Monitor.Enter(lo);
                        bool OperationExecuted = false;
                        while (!OperationExecuted)
                        {
                            DateTime StartOperationDate = DateTime.Parse(Operation.Start.ToString("HH:mm:ss"));
                            DateTime Current            = DateTime.Parse(DateTime.Now.ToString("HH:mm:ss"));
                            if (StartOperationDate == Current & StartOperationDate.Minute == Current.Minute & Operation.State == OperationStatus.Pending)
                            {
                                try
                                {
                                    NumberOfRunningOperation++;
                                    Exception ex = new Exception();
                                    Stopwatch RealOperationTime = new Stopwatch();
                                    RealOperationTime.Start();
                                    //Operation.OperationCode.Invoke();
                                    RealOperationTime.Stop();
                                    Operation.End          = DateTime.Now;
                                    Operation.RealDuration = RealOperationTime.Elapsed;
                                    //Operation.ResultedObject = Operation.OperationCode.Target;
                                    Operation.State   = OperationStatus.Finished;
                                    OperationExecuted = true;
                                    Finished.Add(Operation);
                                    ToManage.Remove(Operation);

                                    if (Operation.ContiniousOperation & Operation.State == OperationStatus.Finished)
                                    {
                                        Operation.Start = DateTime.Now.Add(Operation.Every);
                                        Operation.State = OperationStatus.Pending;
                                        ToManage.Add(Operation);
                                        Console.WriteLine("Perf - TaskManagement : scheduling new operation for continious logic at : {0}", Operation.Start);

                                        break;
                                    }
                                    else
                                    {
                                        //Operation.OperationCode.Dispose();
                                    }
                                }
                                catch (Exception ex)
                                {
                                    if (Operation.AllowMultipleException)
                                    {
                                        Stopwatch Retry = new Stopwatch();
                                        Retry.Start();

                                        //Operation.OperationCode.Invoke();
                                        Retry.Stop();
                                        Operation.End          = DateTime.Now;
                                        Operation.RealDuration = Retry.Elapsed;
                                        //Operation.ResultedObject = Operation.OperationCode.Target;
                                        Operation.State   = OperationStatus.Exception;
                                        OperationExecuted = true;
                                        Operation.Errors.Add(ex);
                                    }
                                    else
                                    {
                                        //Operation.ResultedObject = Operation.OperationCode.Target;
                                        Operation.State   = OperationStatus.Exception;
                                        OperationExecuted = true;
                                        Operation.Errors.Add(ex);
                                    }
                                }
                            }
                            else
                            {
                                Thread.Sleep(200);
                            }
                        }
                        NumberOfRunningOperation--;
                        System.Threading.Monitor.Exit(lo);
                    });
                }
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Fires "Finished" event if it's not null
 /// </summary>
 /// <param name="sender">The sender of the event</param>
 /// <param name="e">The EventArgs object which provides to subscriber with important info</param>
 public void OnFinished(object sender, EventArgs e) => Finished?.Invoke(sender, e);
Exemplo n.º 6
0
 void _worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     Finished.Raise();
 }
Exemplo n.º 7
0
    void OnControllerColliderHit(ControllerColliderHit hit)
    {
        if (!isDie)
        {
            CharacterController controller = GetComponent <CharacterController>();
            if (blockHitFlag && hit.collider.tag == "BLOCK_BREAKABLE")
            {
                if (controller.collisionFlags == CollisionFlags.Above)
                {
                    if (!isBounce && controller.velocity.y > 0f)
                    {
                        DestroyObject(hit.collider.gameObject);
                        isBounce     = true;
                        blockHitFlag = false;
                    }
                }
            }

            if (hit.collider.tag == "FINISH")
            {
                finishObject = hit.collider.gameObject;
                Finished fo = finishObject.transform.parent.GetComponent <Finished>();
                fo.upFlag();
                isFinish = true;
            }

            if (hit.collider.tag == "ITEMBOX")
            {
                if (controller.collisionFlags == CollisionFlags.Above)
                {
                    if (!isBounce && controller.velocity.y > 0f)
                    {
                        isBounce = true;
                        ItemBox ibox = hit.collider.gameObject.GetComponent <ItemBox>();
                        ibox.hit();
                    }
                }
            }

            if (!superMode)
            {
                if (hit.collider.tag == "ENERMY1")
                {
                    if (gameObject.transform.localPosition.y - gameObject.transform.localScale.y / 2 > hit.collider.gameObject.transform.localPosition.y)
                    {
                        isRiversBounce = true;
                        EHitEngin hitEnermy = hit.collider.gameObject.GetComponent <EHitEngin>();
                        hitEnermy.hit();
                    }
                    else
                    {
                        playerDie(hit.collider.gameObject);
                    }
                }
                else if (hit.collider.tag == "ENERMY2")
                {
                    if (gameObject.transform.localPosition.y - gameObject.transform.localScale.y / 2 > hit.collider.gameObject.transform.localPosition.y)
                    {
                        isRiversBounce = true;
                        EHitEngin hitEnermy = hit.collider.gameObject.GetComponent <EHitEngin>();
                        hitEnermy.hit();
                    }
                    else
                    {
                        playerDie(hit.collider.gameObject);
                    }
                }
                else if (hit.collider.tag == "ENERMY3")
                {
                    playerDie(hit.collider.gameObject);
                }
            }
        }
    }
 /// <summary>
 /// Initializes a new instance of the <see cref="PatientData"/> class.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <param name="firstname">The firstname.</param>
 /// <param name="surname">The surname.</param>
 /// <param name="dateOfBirth">The date of birth.</param>
 /// <param name="sex">The sex.</param>
 /// <param name="phone">The phone.</param>
 /// <param name="weight">The weight.</param>
 /// <param name="address">The address.</param>
 /// <param name="residentOfAsmara">The resident of asmara.</param>
 /// <param name="ambulant">The ambulant.</param>
 /// <param name="finished">The finished.</param>
 /// <param name="linz">The linz.</param>
 /// <param name="waitListStartDate">The wait List Start Date.</param>
 public PatientData(long id, string firstname, string surname, DateTime dateOfBirth,
     Sex sex, /*string city, string street,*/ string phone, int weight, string address,
     ResidentOfAsmara residentOfAsmara, Ambulant ambulant, Finished finished, Linz linz, DateTime? waitListStartDate)
 {
     this.id = id;
     this.firstName = firstname;
     this.surName = surname;
     this.dateOfBirth = dateOfBirth;
     this.sex = sex;
     this.phone = phone;
     this.weight = weight;
     this.address = address;
     this.residentOfAsmara = residentOfAsmara;
     this.ambulant = ambulant;
     this.finished = finished;
     this.Linz = linz;
     this.waitListStartDate = waitListStartDate;
 }
Exemplo n.º 9
0
 protected void InvokeFinished()
 {
     Finished?.Invoke(this, new EventArgs());
 }
Exemplo n.º 10
0
 protected virtual void OnFinished(EventArgs e)
 {
     Finished?.Invoke(this, e);
 }
Exemplo n.º 11
0
 public void Collect(Finished finished, Progress progress)
 {
     this.finished = finished;
       this.progress = progress;
       ThreadPool.QueueUserWorkItem(DoCollect);
 }
Exemplo n.º 12
0
 protected void RaiseFinished()
 {
     Finished?.Invoke(this);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Called when the script is done running
 /// </summary>
 protected virtual void OnFinish( )
 {
     Finished?.Invoke(this);
 }
Exemplo n.º 14
0
        private void StartRequesting()
        {
            CountdownEvent pendingPiecesCountDown = new CountdownEvent(1);
            Piece          nextPiece = null;
            bool           stopped   = false;

            do
            {
                do
                {
                    int next = RequestStrategy.Next();
                    if (next < 0)
                    {
                        break;
                    }

                    nextPiece = _client.GetPiece(next);
                    Trace.WriteLine($"RequestManager: Next piece to request is # {next}");
                    if (nextPiece.IsValid)   // Might be valid if it was fetched from external storage
                    {
                        Debug.WriteLine($"RequestManager: Fetched piece #{nextPiece.Index} from cache");
                        continue;
                    }

                    int start = 0, curBlockLen = _blockLen;

                    pendingPiecesCountDown.AddCount();
                    nextPiece.OnPieceDone += (p) => { pendingPiecesCountDown.Signal(); };

                    do
                    {
                        PeerHandler handler = null;

                        try {
                            Debug.WriteLine($"RequestManager: Acquiring handler...");
                            handler = _exchange.Acquire(nextPiece.Index, _outCancelToken);
                            Debug.WriteLine($"RequestManager: Handler acquired");
                        } catch (OperationCanceledException) {
                            Trace.WriteLine($"RequestManager: Cancelled acquire, restarting...");
                            break;
                        }

                        // nothing in lower pools, wait and try to acquire handler once more
                        if (handler == null)
                        {
                            Debug.WriteLine($"RequestManager: No handler in lower pools, waiting {WaitTimeoutForLowerPoolInMSec / 1000} secs and trying once more");
                            Thread.Sleep(WaitTimeoutForLowerPoolInMSec);
                            continue;
                        }

                        curBlockLen = nextPiece.PieceLength - start < _blockLen ? nextPiece.PieceLength - start : curBlockLen;
                        ThreadPool.QueueUserWorkItem((offsetsTupleObj) => {
                            Tuple <Piece, int, int> offsetsTuple = (Tuple <Piece, int, int>)offsetsTupleObj;
                            try {
                                handler.RequestPiece(offsetsTuple.Item1, offsetsTuple.Item2, offsetsTuple.Item3, _outCancelToken);
                            } catch (OperationCanceledException) {
                            } finally {
                                _exchange.Realese(handler);
                            }
                        }, new Tuple <Piece, int, int>(nextPiece, start, curBlockLen));

                        start += curBlockLen;

                        // last block of piece, breaking
                        if (curBlockLen < _blockLen)
                        {
                            break;
                        }
                    } while (start < nextPiece.PieceLength && !_outCancelToken.IsCancellationRequested);

                    stopped = _myCancelTokenOwner.IsCancellationRequested || _outCancelToken.IsCancellationRequested;
                } while (!stopped);

                if (stopped)
                {
                    break;
                }

                // Initial count
                pendingPiecesCountDown.Signal();
                Trace.WriteLine($"PiecePicker: Finished requesting, pending pieces count {pendingPiecesCountDown.CurrentCount}");
                if (pendingPiecesCountDown.Wait(WaitTimeoutForEndGamePiecesInMSec, _outCancelToken))
                {
                    break;
                }
                else
                {
                    foreach (var uploader in _exchange.GetUploaders())
                    {
                        uploader.CancelPendingOutboundRequests();
                    }

                    pendingPiecesCountDown.Reset();
                }
            } while (!stopped);

            _exchange.Stop();
            Trace.WriteLine($"RequestManager: Finished requesting");
            Finished?.Invoke();
        }
Exemplo n.º 15
0
        public void StartFight()
        {
            while (true)
            {
                for (int i = 0; i < _characters.Count; i++)
                {
                    var c = _characters[i];

                    int       attackedIndex;
                    Character attacked;

                    do
                    {
                        attackedIndex = _r.Next(_characters.Count);
                        attacked      = _characters[attackedIndex];
                    }while (attacked == c || !attacked.IsAlive);

                    c.Attack(attacked);

                    if (!attacked.IsAlive)
                    {
                        _characters.Remove(attacked);
                    }

                    if (_characters.Count == 1)
                    {
                        var winner = _characters.First();
                        Finished?.Invoke(this, new FinishedEventArgs {
                            Winner = winner
                        });
                        return;
                    }
                }

                //foreach(var c in _characters.ToArray())
                //{
                //    if (!c.IsAlive)
                //        continue;

                //    int attackedIndex;
                //    Character attacked;

                //    do
                //    {
                //        attackedIndex = _r.Next(_characters.Count);
                //        attacked = _characters[attackedIndex];
                //    }
                //    while (attacked == c || !attacked.IsAlive);

                //    c.Attack(attacked);

                //    if (!attacked.IsAlive)
                //        _characters.Remove(attacked);

                //    if (_characters.Count == 1)
                //    {
                //        var winner = _characters.First();
                //        Finished?.Invoke(this, new FinishedEventArgs { Winner = winner });
                //        return;
                //    }
                //}
            }
        }
 /// <summary>
 /// Finds the patient by finished.
 /// </summary>
 /// <param name="finished">The finished.</param>
 /// <returns></returns>
 public virtual IList<PatientData> FindPatientByFinished(Finished finished)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 17
0
        public void Update()
        {
            if (Visible)
            {
                if (_scrolling)
                {
                    switch (Controller.GameOptions.TextSpeed)
                    {
                    case 0:
                        _scrollValue += Border.SCALE * 2;
                        break;

                    case 1:
                        _scrollValue += Border.SCALE * 1.5f;
                        break;

                    case 2:
                        _scrollValue += Border.SCALE;
                        break;
                    }
                    if (_scrollValue >= Border.UNIT * 2 * Border.SCALE)
                    {
                        _scrolling   = false;
                        _scrollValue = 0f;
                        _lineIndex++;
                        // reset char index so it only shows the now first line
                        var lines = _text[_textIndex];
                        var line1 = lines[_lineIndex];
                        _charIndex = line1.Length;
                    }
                }
                else
                {
                    var lines = _text[_textIndex];

                    if (_charDelay > 0)
                    {
                        _charDelay--;
                        if (_charDelay == 0)
                        {
                            _charDelay = 0;
                        }
                    }
                    else
                    {
                        if (GameboyInputs.ADown() || GameboyInputs.BDown())
                        {
                            _charDelay = 0;
                        }
                        else
                        {
                            switch (Controller.GameOptions.TextSpeed)
                            {
                            case 0:
                                _charDelay = CHARDELAY_FAST;
                                break;

                            case 1:
                                _charDelay = CHARDELAY_MID;
                                break;

                            case 2:
                                _charDelay = CHARDELAY_SLOW;
                                break;
                            }
                        }
                        var line1 = lines[_lineIndex];
                        if (_charIndex < line1.Length)
                        {
                            // skip escape char
                            if (_charIndex + 2 < line1.Length && line1[_charIndex] == PokemonFontRenderer.ESCAPE_CHAR)
                            {
                                _charIndex += 3;
                            }
                            else
                            {
                                _charIndex++;
                            }
                        }
                        else
                        {
                            if (lines.Length > _lineIndex + 1)
                            {
                                var line2      = lines[_lineIndex + 1];
                                var line2Index = _charIndex - line1.Length;
                                if (line2Index < line2.Length)
                                {
                                    // skip escape char
                                    if (line2Index + 2 < line2.Length && line2[line2Index] == PokemonFontRenderer.ESCAPE_CHAR)
                                    {
                                        _charIndex += 3;
                                    }
                                    else
                                    {
                                        _charIndex++;
                                    }
                                }
                            }
                        }
                    }

                    if (CanAdvance())
                    {
                        if (!_firedFinished && IsFinished)
                        {
                            Finished?.Invoke();
                            _firedFinished = true;
                        }

                        if (_arrowBlinkingDelay > 0)
                        {
                            _arrowBlinkingDelay--;
                            if (_arrowBlinkingDelay == 0)
                            {
                                _arrowBlinkingDelay = ARROW_BLINK_DELAY;
                                _arrowVisible       = !_arrowVisible;
                            }
                        }

                        if (GameboyInputs.APressed() || GameboyInputs.BPressed())
                        {
                            // scroll or show next text block
                            if (lines.Length > _lineIndex + 2)
                            {
                                _scrolling = true;
                            }
                            else
                            {
                                // close textbox when through all text
                                if (_textIndex == _text.Length - 1)
                                {
                                    Close();
                                }
                                else
                                {
                                    _textIndex++;
                                    _charIndex = 0;
                                    _lineIndex = 0;
                                    _charDelay = 4;
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 18
0
 public C_To_S_ThreeManager()
 {
     if (finished == null)
          finished = new Finished();
 }
Exemplo n.º 19
0
        protected virtual void Complete(Exception e = null)
        {
            if (Aborted)
            {
                return;
            }

            var we = e as WebException;

            bool allowRetry = AllowRetryOnTimeout;

            if (e != null)
            {
                allowRetry &= we?.Status == WebExceptionStatus.Timeout;
            }
            else if (!response.IsSuccessStatusCode)
            {
                e = new WebException(response.StatusCode.ToString());

                switch (response.StatusCode)
                {
                case HttpStatusCode.GatewayTimeout:
                case HttpStatusCode.RequestTimeout:
                    break;

                case HttpStatusCode.NotFound:
                case HttpStatusCode.MethodNotAllowed:
                case HttpStatusCode.Forbidden:
                    allowRetry = false;
                    break;

                case HttpStatusCode.Unauthorized:
                    allowRetry = false;
                    break;
                }
            }

            if (e != null)
            {
                if (allowRetry && RetryCount < MAX_RETRIES && responseBytesRead == 0)
                {
                    RetryCount++;

                    logger.Add($@"Request to {Url} failed with {e} (retrying {RetryCount}/{MAX_RETRIES}).");

                    // For now, a client is created for each request due to the following bug in mono: https://bugzilla.xamarin.com/show_bug.cgi?id=60396
                    // Todo: This must not be done, and is dangerous to do, see: https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/
                    createHttpClient();

                    //do a retry
                    internalPerform();
                    return;
                }

                logger.Add($"Request to {Url} failed with {e} (FAILED).");
            }
            else
            {
                logger.Add($@"Request to {Url} successfully completed!");
            }

            try
            {
                ProcessResponse();
            }
            catch (Exception se) { e = e == null ? se : new AggregateException(e, se); }

            Completed = true;

            if (e == null)
            {
                Finished?.Invoke();
            }
            else
            {
                Failed?.Invoke(e);
                Aborted = true;
                throw e;
            }
        }
Exemplo n.º 20
0
 public void EndTurn()
 {
     Finished?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 21
0
 public void GotMessage()
 {
     Finished?.Invoke(model.message);
 }
Exemplo n.º 22
0
 protected virtual void OnFinished(MCSimulationResults results)
 {
     Finished?.Invoke(results);
 }
Exemplo n.º 23
0
        public static void OpenArchive()
        {
            if (!Context.UnarUsable)
            {
                Failed?.Invoke("The UnArchiver is not correctly installed");

                return;
            }

            if (!File.Exists(Context.Path))
            {
                Failed?.Invoke("Specified file cannot be found");

                return;
            }

            try
            {
                string unarFolder   = Path.GetDirectoryName(Settings.Current.UnArchiverPath);
                string extension    = Path.GetExtension(Settings.Current.UnArchiverPath);
                string unarfilename = Path.GetFileNameWithoutExtension(Settings.Current.UnArchiverPath);
                string lsarfilename = unarfilename?.Replace("unar", "lsar");
                string lsarPath     = Path.Combine(unarFolder, lsarfilename + extension);

            #if DEBUG
                stopwatch.Restart();
            #endif
                var lsarProcess = new Process
                {
                    StartInfo =
                    {
                        FileName               = lsarPath,
                        CreateNoWindow         = true,
                        RedirectStandardOutput = true,
                        UseShellExecute        = false,
                        Arguments              = $"-j \"\"\"{Context.Path}\"\"\""
                    }
                };

                lsarProcess.Start();
                string lsarOutput = lsarProcess.StandardOutput.ReadToEnd();
                lsarProcess.WaitForExit();
            #if DEBUG
                stopwatch.Stop();

                Console.WriteLine("Core.OpenArchive(): Took {0} seconds to list archive contents",
                                  stopwatch.Elapsed.TotalSeconds);

                stopwatch.Restart();
            #endif
                long   counter  = 0;
                string format   = null;
                var    jsReader = new JsonTextReader(new StringReader(lsarOutput));

                while (jsReader.Read())
                {
                    switch (jsReader.TokenType)
                    {
                    case JsonToken.PropertyName
                        when jsReader.Value != null && jsReader.Value.ToString() == "XADFileName":
                        counter++;

                        break;

                    case JsonToken.PropertyName
                        when jsReader.Value != null && jsReader.Value.ToString() == "lsarFormatName":
                        jsReader.Read();

                        if (jsReader.TokenType == JsonToken.String &&
                            jsReader.Value != null)
                        {
                            format = jsReader.Value.ToString();
                        }

                        break;
                    }
                }
            #if DEBUG
                stopwatch.Stop();

                Console.WriteLine("Core.OpenArchive(): Took {0} seconds to process archive contents",
                                  stopwatch.Elapsed.TotalSeconds);
            #endif

                Context.UnzipWithUnAr    = false;
                Context.ArchiveFormat    = format;
                Context.NoFilesInArchive = counter;

                if (string.IsNullOrEmpty(format))
                {
                    Failed?.Invoke("File not recognized as an archive");

                    return;
                }

                if (counter == 0)
                {
                    Failed?.Invoke("Archive contains no files");

                    return;
                }

                if (Context.ArchiveFormat == "Zip")
                {
                    Context.UnzipWithUnAr = false;

                    if (Context.UsableDotNetZip)
                    {
                    #if DEBUG
                        stopwatch.Restart();
                    #endif
                        var zf = ZipFile.Read(Context.Path, new ReadOptions
                        {
                            Encoding = Encoding.UTF8
                        });

                        foreach (ZipEntry ze in zf)
                        {
                            // ZIP created with Mac OS X, need to be extracted with The UnArchiver to get correct ResourceFork structure
                            if (!ze.FileName.StartsWith("__MACOSX", StringComparison.CurrentCulture))
                            {
                                continue;
                            }

                            Context.UnzipWithUnAr = true;

                            break;
                        }
                    #if DEBUG
                        stopwatch.Stop();

                        Console.
                        WriteLine("Core.OpenArchive(): Took {0} seconds to navigate in search of Mac OS X metadata",
                                  stopwatch.Elapsed.TotalSeconds);
                    #endif
                    }
                }

                Finished?.Invoke();
            }
            catch (ThreadAbortException) {}
            catch (Exception ex)
            {
                if (Debugger.IsAttached)
                {
                    throw;
                }

                Failed?.Invoke($"Exception {ex.Message}\n{ex.InnerException}");
            #if DEBUG
                Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException);
            #endif
            }
        }
Exemplo n.º 24
0
 /// <summary>
 /// Event raised whenever the fixing function has finish its work.
 /// </summary>
 protected virtual void OnFinished()
 {
     Finished?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 25
0
 void OnFinished(AVPlayerItem item)
 {
     item?.Asset?.CancelLoading();
     Finished?.Invoke(this);
 }
Exemplo n.º 26
0
        protected virtual void OnFinished()
        {
            EventArgs se = new EventArgs();

            Finished?.Invoke(this, se);
        }
Exemplo n.º 27
0
 public int Finish()
 {
     Finished.WaitOne();
     return(TotalTests);
 }
Exemplo n.º 28
0
 private void OnFinished()
 {
     Finished?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 29
0
        public override async ValueTask DisposeAsync()
        {
            await base.DisposeAsync();

            Finished.Dispose();
        }
Exemplo n.º 30
0
        private void inicializarComponente()
        {
            _enderecoForm = new EnderecoMapaForm
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Fill
            };
            _enderecoForm.Endereco = _Info;

            _salvarButton = new Button
            {
                Text  = "Salvar",
                Style = Estilo.Current[Estilo.BTN_PADRAO]
            };
            _salvarButton.Clicked += async(sender, e) =>
            {
                if (string.IsNullOrEmpty(_enderecoForm.Endereco.Cep))
                {
                    await DisplayAlert("Atenção", "Preencha o cep.", "Entendi");

                    return;
                }
                if (string.IsNullOrEmpty(_enderecoForm.Endereco.Uf))
                {
                    await DisplayAlert("Atenção", "Preencha a UF.", "Entendi");

                    return;
                }
                if (string.IsNullOrEmpty(_enderecoForm.Endereco.Cidade))
                {
                    await DisplayAlert("Atenção", "Preencha a cidade.", "Entendi");

                    return;
                }
                if (string.IsNullOrEmpty(_enderecoForm.Endereco.Logradouro))
                {
                    await DisplayAlert("Atenção", "Preencha a rua.", "Entendi");

                    return;
                }
                if (string.IsNullOrEmpty(_enderecoForm.Endereco.Numero))
                {
                    await DisplayAlert("Atenção", "Preencha o numero.", "Entendi");

                    return;
                }

                UserDialogs.Instance.ShowLoading("Enviando...");
                var usuarioFactor = UsuarioFactory.create();
                var usuario       = usuarioFactor.pegarAtual();
                if (_Info != null)
                {
                    var end    = UsuarioEnderecoInfo.clonar(_enderecoForm.Endereco);
                    var endOld = usuario.Enderecos.Where(x => x.Id == _Info.Id).FirstOrDefault();
                    end.Id = endOld.Id;
                    usuario.Enderecos.Remove(endOld);
                    usuario.Enderecos.Add(end);
                }
                else
                {
                    usuario.Enderecos.Add(UsuarioEnderecoInfo.clonar(_enderecoForm.Endereco));
                }
                await usuarioFactor.alterar(usuario);

                var usuarioCadastrado = await usuarioFactor.pegar(usuario.Id);

                usuarioFactor.gravarAtual(usuarioCadastrado);
                UserDialogs.Instance.HideLoading();

                Finished?.Invoke(this, _enderecoForm.Endereco);
                Navigation.PopAsync();
            };
        }
Exemplo n.º 31
0
 private void finished(WebRequest request, Exception e)
 {
     Finished?.Invoke(this, e);
 }
Exemplo n.º 32
0
 private void btnCancel_Click(object sender, RoutedEventArgs e)
 {
     DeInit();
     Finished?.Invoke(this, new EventArgs());
 }
Exemplo n.º 33
0
 public MovementController(Finished eDelegate)
 {
     this.OnMove += eDelegate;
 }
Exemplo n.º 34
0
 /// <summary>
 /// Finds the patient by finished.
 /// </summary>
 /// <param name="finished">The finished.</param>
 /// <returns></returns>
 public override IList<PatientData> FindPatientByFinished(Finished finished)
 {
     IList<PatientData> patients = new List<PatientData>();
     foreach (PatientData patient in this.GetAllPatients()) {
         if (patient.Finished == finished) {
             patients.Add(patient);
         }
     }
     return patients;
 }
Exemplo n.º 35
0
 protected virtual void OnFinished(IRenderable sender, object data) => Finished?.Invoke(sender, data);
Exemplo n.º 36
0
 /// <summary>
 /// Finds the patient by finished.
 /// </summary>
 /// <param name="finished">The finished.</param>
 /// <returns></returns>
 public IList<PatientData> FindPatientByFinished(Finished finished)
 {
     using (ChannelFactory<ISPDBL> cf = new ChannelFactory<ISPDBL>(binding, endpointAddress)) {
         ISPDBL spdBL = cf.CreateChannel();
         return spdBL.FindPatientByFinished(finished);
     }
 }
 public void Instantiate(GameObject target, GameObject actualAxeMan, Finished callback)
 {
     targetTree = target;
     this.actualAxeMan = actualAxeMan;
     finishedCallback = callback;
 }