예제 #1
0
        public MessageStatisticsInfo Statistics()
        {
            MessageStatisticsInfo staInfo = new MessageStatisticsInfo();
            DBHelper dbHelper             = new DBHelper(ConnectionString, DbProviderType.SqlServer);
            string   strSql = "select [State],count(1) as StateCount from MessageRecord group by [state]";

            using (DbDataReader reader = dbHelper.ExecuteReader(strSql, null))
            {
                while (reader.Read())
                {
                    MsgSendState sedState   = (MsgSendState)reader["State"];
                    int          stateCount = (int)reader["StateCount"];
                    switch (sedState)
                    {
                    case MsgSendState.Unsent:
                        staInfo.Unsent = stateCount;
                        break;

                    case MsgSendState.SendFailed:
                        staInfo.SendFailed = stateCount;
                        break;

                    case MsgSendState.SendSuccess:
                        staInfo.SendSuccess = stateCount;
                        break;

                    case MsgSendState.ReceiveFailed:
                        staInfo.ReceiveFailed = stateCount;
                        break;
                    }
                }
            }

            return(staInfo);
        }
예제 #2
0
 public int Count(MsgSendState state)
 {
     return(_MessageRecordProvider.GetCount(new FlagUpdHandle()
     {
         FieldType = FieldType.Int,
         Key = "State",
         Value = (int)state,
         TableName = "MessageRecord"
     }));
 }
예제 #3
0
        public ActionResult Progress(MsgSendState state)
        {
            string cacheKey = Guid.NewGuid().ToString("N");

            Task task = new Task(() =>
            {
                BatchSendSMS(cacheKey, state);
            });

            task.Start();

            if (task.IsCompleted)
            {
                Logger.Info(this, "task 执行结束");
            }

            ViewBag.CacheKey = cacheKey;
            return(View());
        }
예제 #4
0
        public JsonResult CheckSupportSend(MsgSendState state)
        {
            ResultRetrun rmodel = new ResultRetrun();

            if (state == MsgSendState.SendSuccess)
            {
                rmodel.message = "当前状态不支持批量发送";
                return(Json(rmodel.isSuccess, JsonRequestBehavior.AllowGet));
            }

            if (msgService.Count(state) <= 0)
            {
                rmodel.message = "没有要发送的数据";
            }
            else
            {
                rmodel.isSuccess = true;
            }
            return(Json(rmodel, JsonRequestBehavior.AllowGet));
        }
예제 #5
0
        private void BatchSendSMS(string cacheKey, MsgSendState state)
        {
            List <MessageRecord> recordData = msgService.GetAll(new MessageRecordQuery()
            {
                SendState = (int)state
            });
            List <List <MessageRecord> > groupList = GetGroupList(recordData);
            ProgressResult result = new ProgressResult(groupList.Count);

            try
            {
                for (int i = 0; i < groupList.Count; i++)
                {
                    result.Count += 1;
                    if (msgService.Send(groupList[i]))
                    {
                        result.SuccessCount += 1;
                    }

                    Logger.Info(typeof(MessageRecordController), "BatchSendSMS=" + cacheKey + ";data=" + JsonUtils.Serialize(result));
                    CacheHelper.Set(cacheKey, result);
                }
            }
            catch (BizException biz)
            {
                result.Message = biz.Message;
                result.EndTag  = true;
                CacheHelper.Set(cacheKey, result);
            }
            catch (Exception ex)
            {
                result.Message = "系统错误:" + ex.Message;
                result.EndTag  = true;
                CacheHelper.Set(cacheKey, result);
            }
            finally
            {
                Logger.Info(typeof(MessageRecordController), "BatchSendSMS End Result=" + cacheKey + ";data=" + JsonUtils.Serialize(result));
            }
        }
예제 #6
0
    public void TryShotResult(ShotResult shotResult)
    {
        bool playingGoalkeeper = GameplayService.IsGoalkeeper();

        if (playingGoalkeeper)
        {
            Habilidades.EndRound(shotResult.Result == Result.Goal);
        }

        if (!GameplayService.networked)
        {
            if (!playingGoalkeeper)
            {
                if (shotResult.Result == Result.Goal || shotResult.Result == Result.Target)
                {
                    if (shotResult.Perfect && attempts < maxAttempts)
                    {
                        GeneralSounds.instance.vidaExtra();
                        kickEffects.instance.ExtraLife(shotResult.Point);
                        this.attempts++;
                        if (Habilidades.IsActiveSkill(Habilidades.Skills.VIP) && (attempts < maxAttempts))
                        {
                            this.attempts++;
                            kickEffects.instance.ExtraLife(shotResult.Point + (Vector3.up * -1f));
                        }
                    }

                    /*if (this.attempts >= maxAttempts && shotResult.Perfect)
                     * {
                     * if (perfects > 1 || Habilidades.IsActiveSkill(Habilidades.Skills.VIP))
                     * {
                     *    if (this.attempts != 3)
                     *    {
                     *      GeneralSounds.instance.vidaExtra();
                     *      kickEffects.instance.ExtraLife(shotResult.Point);
                     *      this.attempts = 3;
                     *    }
                     * }
                     * }
                     * if(this.attempts < maxAttempts) this.attempts = maxAttempts;*/
                }
                else
                {
                    ShotFailed();
                }
            }
            else
            {
                if (shotResult.Result == Result.Goal)
                {
                    ShotFailed();
                }
                else
                {
                    if (shotResult.Perfect && attempts < maxAttempts)
                    {
                        GeneralSounds.instance.vidaExtra();
                        kickEffects.instance.ExtraLife(shotResult.Point);
                        this.attempts++;
                        if (Habilidades.IsActiveSkill(Habilidades.Skills.VIP) && (attempts < maxAttempts))
                        {
                            this.attempts++;
                            kickEffects.instance.ExtraLife(shotResult.Point + (Vector3.up * -0.5f));
                        }
                    }
                    //else if (this.attempts < maxAttempts && shotResult.Result != Result.OutOfBounds) this.attempts = maxAttempts;
                }
            }

            SumarDineroPorPrimas();
        }
        else if (GameplayService.networked)
        {
            bool isPlayer1 = GameplayService.initialGameMode != GameMode.Shooter;

            if (playingGoalkeeper)
            {
                cntPastillaMultiplayer.marcadorRemoto.Lanzamientos++;
            }
            else
            {
                cntPastillaMultiplayer.marcadorLocal.Lanzamientos++;
            }

            if (newState)
            {
                Debug.Log("APPLYING");
                cntPastillaMultiplayer.marcadorLocal.SetEstado(GetSimpleState(serverState, isPlayer1));
                cntPastillaMultiplayer.marcadorRemoto.SetEstado(GetSimpleState(serverState, !isPlayer1));
                newState = false;
            }
            else
            {
                Debug.Log("CALCULATING");
                MatchState tempstate = serverState;
                if ((isPlayer1 == playingGoalkeeper))
                {
                    tempstate.rounds++;
                }
                if (playingGoalkeeper)
                {
                    MatchStateSimple state = cntPastillaMultiplayer.marcadorRemoto.AddResult(shotResult.Result == Result.Goal);
                    if (isPlayer1)
                    {
                        tempstate.marker_2 = state.marker;
                        tempstate.score_2  = state.score;
                    }
                    else
                    {
                        tempstate.marker_1 = state.marker;
                        tempstate.score_1  = state.score;
                    }
                }
                else
                {
                    MatchStateSimple stateF = cntPastillaMultiplayer.marcadorLocal.AddResult(shotResult.Result == Result.Goal);
                    if (isPlayer1)
                    {
                        tempstate.marker_1 = stateF.marker;
                        tempstate.score_1  = stateF.score;
                    }
                    else
                    {
                        tempstate.marker_2 = stateF.marker;
                        tempstate.score_2  = stateF.score;
                    }
                }
                serverState = tempstate;

                if (!playingGoalkeeper)
                {
                    Debug.Log("SENDING");
                    MsgSendState msg = Shark.instance.mensaje <MsgSendState>();
                    msg.state   = tempstate;
                    msg.defense = MsgDefend.ToDefenseInfoNet(Vector3.zero, shotResult.DefenseResult);
                    msg.send();
                }
                newState = false;
            }

            if (isPlayer1 == playingGoalkeeper)                                           //fin de ronda
            {
                if (serverState.rounds > 4 && serverState.score_1 != serverState.score_2) //fin de partida
                {
                    gameOver = true;

                    bool winner  = isPlayer1 ? (serverState.score_1 > serverState.score_2) : (serverState.score_2 > serverState.score_1);
                    bool perfect = isPlayer1 ? (serverState.score_2 == 0) : (serverState.score_1 == 0);
                    perfect = perfect && (isPlayer1 ? (serverState.score_1 >= 5) : (serverState.score_2 >= 5));

                    if (winner)
                    {
                        Interfaz.MonedasSoft += recompensaMultijugadorWin;
                    }
                    else
                    {
                        Interfaz.MonedasSoft += recompensaMultijugadorFail;
                    }

                    PersistenciaManager.instance.GuardarPartidaMultiPlayer(winner, perfect);
                }
            }
        }

        int points = shotResult.ScorePoints + shotResult.EffectBonusPoints;

        // actualizar la informacion de cada ronda
        RoundInfoManager.instance.AcumularRonda(shotResult.Result, points, shotResult.Perfect);//, GameplayService.IsGoalkeeper() ? (shotResult.DefenseResult == GKResult.Perfect) : (shotResult.Perfect));

        // acumular la recompensa
        // DINERO! MONEDAS!
        int monedas = Mathf.FloorToInt((float)points * DifficultyService.GetRatioRecompensa());

        Interfaz.recompensaAcumulada += monedas;
        Interfaz.MonedasSoft         += monedas;


        if (gameOver && !GameplayService.networked)
        {
            //ifcGameOver.instance.resultTime = FieldControl.instance.seconds;
            Mission mission = MissionManager.instance.GetMission();
            if (attempts > 0)
            {
                // persistir la mision que se acaba de superar
                PersistenciaManager.instance.ActualizarUltimoNivelDesbloqueado(mission.indexMision + 1);


                // comprobar si la en mision que se acaba de superar desbloquea algun jugador
                Jugador jugadorDesbloqueado = InfoJugadores.instance.GetJugadorDesbloqueableEnFase(mission.indexMision);
                if (jugadorDesbloqueado != null)
                {
                    // registrar el dialogo para mostrar el aviso de que se ha obtenido un nuevo jugador y actualizar su estado
                    jugadorDesbloqueado.estado = Jugador.Estado.DISPONIBLE;
                    DialogManager.instance.RegistrarDialogo(new DialogDefinition(DialogDefinition.TipoDialogo.JUGADOR_DESBLOQUEADO, jugadorDesbloqueado));
                }

                // comprobar si en la mision que se acaba de superar se desbloquea alguna equipacion
                Equipacion equipacionDesbloqueada = EquipacionManager.instance.GetEquipacionDesbloqueableEnFase(mission.indexMision);
                if (equipacionDesbloqueada != null)
                {
                    // registrar el dialogo para mostrar el aviso de que se ha obtenido una nueva equipacion y actualizar su estado
                    equipacionDesbloqueada.estado = Equipacion.Estado.DISPONIBLE;
                    DialogManager.instance.RegistrarDialogo(new DialogDefinition(DialogDefinition.TipoDialogo.EQUIPACION_DESBLOQUEADA, equipacionDesbloqueada));
                }

                // comprobar si en la mision que se acaba de superar se ha desbloqueado algun escudo
                Debug.Log(">>> Compruebo escudo => fase ");
                Escudo escudoDesbloqueado = EscudosManager.instance.GetEscudoDesbloqueableEnFase(mission.indexMision);
                if (escudoDesbloqueado != null)
                {
                    // registrar el dialogo para mostrar el aviso de que se ha obtenido un nuevo escudo y desbloquearlo
                    escudoDesbloqueado.bloqueado = false;
                    DialogManager.instance.RegistrarDialogo(new DialogDefinition(DialogDefinition.TipoDialogo.ESCUDO_DESBLOQUEADO, escudoDesbloqueado));
                }
            }
        }

        if (firstShot)
        {
            firstShot = false;
        }
        UpdateEvent();
    }