Esempio n. 1
0
        public async Task <Guid> SaveRecountAsync(Recount recount)
        {
            await CheckLoad();

            try
            {
                if (recount.Uid != Guid.Empty)
                {
                    var rowsToDelete = _db.GetWithChildrenAsync <Recount>(recount.Uid).Result.RecountRows;

                    foreach (var recountRow in rowsToDelete)
                    {
                        await _db.DeleteAsync <RecountRow>(recountRow.Uid);
                    }
                }

                await _db.InsertOrReplaceWithChildrenAsync(recount);

                await _db.InsertAllWithChildrenAsync(recount.RecountRows);
            }
            catch (Exception ex)
            {
                Log.Error("DatabaseError", ex.Message);
                return(Guid.Empty);
            }

            return(recount.Uid);
        }
Esempio n. 2
0
    public void InitMainScene()
    {
        ManaMax     = 500f + chosenAccount.statKNG * 40;
        ManaCurrent = ManaMax;

        buffSystem = new BuffHandler(GameObject.Find("GCDBar").transform.position);

        chosenAccount.RefreshStats();
        myBlackScreen = GameObject.Find("BlackScreen");
        mySpellIcon   = GameObject.Find("MySpellIcon");
        recount       = new Recount();
        myEnemy       = WorldMapCore.WMCore.adventureInfoHandler.GetEncounter(GameCore.Core.chosenAdventure, GameCore.difficulty);
        myEnemy.InitEncounter();

        chosenChampion = DescendantPanelCore.DPCore.pickedChampion;
        _mytip         = GameObject.Find("Tooltip");
        if (chosenAccount.myTalentTree != null)
        {
            myTree = chosenAccount.myTalentTree;
        }
        else
        {
            myTree = new TalentTree(chosenChampion);
            myTree.DefaultTree();
        }
        GameObject.Find("ChampionPortrait").GetComponent <Image>().sprite = Champion.GetPortrait(chosenChampion);

        myCaster = new Caster(myTree);

        InitSpells();
        InitItems();

        UpdateStats();
        ApplyAuras();
    }
Esempio n. 3
0
 public void Broadcast(Recount recount)
 {
     logger.LogInformation($"Enviando recount a {others.Count} pares");
     foreach (var other in others)
     {
         channel.Send(other.PublicUrl, recount);
         other.LastActivity = DateTimeOffset.UtcNow;
     }
 }
Esempio n. 4
0
        public int CountRecognitions(Guid urnId)
        {
            Urn     urn          = null;
            Recount recount      = null;
            var     recognitions = 0;
            var     choices      = new List <Guid>();

            foreach (var block in trunk)
            {
                if (urn == null)
                {
                    urn = block.Urns.SingleOrDefault(u => u.Id == urnId);
                }

                if (recount == null)
                {
                    recount = block.Recounts.SingleOrDefault(u => u.UrnId == urnId);
                }

                if (urn != null && recount != null)
                {
                    foreach (var recognition in block.Recognitions)
                    {
                        if (recognition.UrnId == urnId)
                        {
                            if (recognition.Content.SequenceEqual(recount.GetData()))
                            {
                                if (urn.Authorities.Any(a => a.SequenceEqual(recognition.PublicKey)))
                                {
                                    recognitions++;
                                }
                                else
                                {
                                    var choiceId = GetChoiceFromSigner(urn.QuestionId, recognition.PublicKey);
                                    if (choiceId.HasValue && !choices.Contains(choiceId.Value))
                                    {
                                        choices.Add(choiceId.Value);
                                        recognitions++;
                                    }
                                }
                            }
                            else
                            {
                                Trace.TraceWarning($"El reconocimiento {recognition.Id} no es válido");
                            }
                        }
                    }
                }
            }

            if (recount == null)
            {
                Trace.TraceWarning($"No se encontró la urna {urnId} en la blockchain");
            }

            return(recognitions);
        }
        public ObjectResult Post(Recount recount)
        {
            logger.LogInformation("Recount: " + JsonSerializer.Serialize(recount, JsonDefaultSettings.Options));

            node.Add(recount);

            var url = Url.Action("Get", new { urnId = recount.UrnId });

            return(Created(url, recount));
        }
Esempio n. 6
0
        public void Add(Recount recount)
        {
            lock (semaphore)
            {
                if (pendings.ContainsKey(recount.GetKey()))
                {
                    return;
                }

                pendings.Add(recount.GetKey(), recount);
            }

            Peers.Broadcast(recount);
        }
Esempio n. 7
0
        public void RecuentoFirmadoPorSuplente()
        {
            RegistrandoUrnas();

            var recuento0001 = new Recount
            {
                UrnId   = mesa0001Id,
                Results = new[] { new ChoiceRecount {
                                      ChoiceId = espertChoideId, Votes = 10
                                  }, new ChoiceRecount {
                                      ChoiceId = macriChoiceId, Votes = 80
                                  }, new ChoiceRecount {
                                      ChoiceId = fernandezChoiceId, Votes = 117
                                  }, new ChoiceRecount {
                                      ChoiceId = lavagnaChoiceId, Votes = 17
                                  }, new ChoiceRecount {
                                      ChoiceId = delcanoChoiceId, Votes = 12
                                  } }
            };

            signer.Sign(recuento0001, albin);

            var recuento5468 = new Recount
            {
                UrnId   = mesa5468Id,
                Results = new[] { new ChoiceRecount {
                                      ChoiceId = espertChoideId, Votes = 12
                                  }, new ChoiceRecount {
                                      ChoiceId = macriChoiceId, Votes = 131
                                  }, new ChoiceRecount {
                                      ChoiceId = fernandezChoiceId, Votes = 71
                                  }, new ChoiceRecount {
                                      ChoiceId = lavagnaChoiceId, Votes = 29
                                  }, new ChoiceRecount {
                                      ChoiceId = delcanoChoiceId, Votes = 9
                                  } }
            };

            signer.Sign(recuento5468, ana);

            var block = blockchain.MineNextBlock(new BlockItem[]
            {
                recuento0001, recuento5468
            });

            Assert.IsNotNull(block);
            Assert.AreEqual(2, block.Recounts.Count);
        }
Esempio n. 8
0
        public void DesconocidoIntentandoFirmarRecuento()
        {
            RegistrandoUrnas();

            var recuento0001 = new Recount
            {
                UrnId   = mesa0001Id,
                Results = new[] { new ChoiceRecount {
                                      ChoiceId = espertChoideId, Votes = 10
                                  }, new ChoiceRecount {
                                      ChoiceId = macriChoiceId, Votes = 80
                                  }, new ChoiceRecount {
                                      ChoiceId = fernandezChoiceId, Votes = 117
                                  }, new ChoiceRecount {
                                      ChoiceId = lavagnaChoiceId, Votes = 17
                                  }, new ChoiceRecount {
                                      ChoiceId = delcanoChoiceId, Votes = 12
                                  } }
            };

            signer.Sign(recuento0001, zoe);

            var recuento5468 = new Recount
            {
                UrnId   = mesa5468Id,
                Results = new[] { new ChoiceRecount {
                                      ChoiceId = espertChoideId, Votes = 12
                                  }, new ChoiceRecount {
                                      ChoiceId = macriChoiceId, Votes = 131
                                  }, new ChoiceRecount {
                                      ChoiceId = fernandezChoiceId, Votes = 71
                                  }, new ChoiceRecount {
                                      ChoiceId = lavagnaChoiceId, Votes = 29
                                  }, new ChoiceRecount {
                                      ChoiceId = delcanoChoiceId, Votes = 9
                                  } }
            };

            signer.Sign(recuento5468, santino);

            var block = blockchain.MineNextBlock(new BlockItem[]
            {
                recuento0001, recuento5468
            });

            Assert.IsNull(block);
        }
        public void Send(string publicUrl, Recount recount)
        {
            var url = new Uri(new Uri(publicUrl), "api/recount");

            Post(url, JsonSerializer.Serialize(recount, JsonDefaultSettings.Options));
        }
 public void Send(string publicUrl, Recount recount)
 {
     throw new System.NotImplementedException();
 }