コード例 #1
0
        public SouvenirEN ProcessExchangeSouvenir(string LocationID, decimal Longitude, decimal Latitude, int ChestType, int ConsumerID, ref string error, int AgeID)
        {
            DateTime   RegDate          = DateTime.Now;
            Random     random           = new Random();
            SouvenirEN Souvenir         = new SouvenirEN();
            int        Level            = 0;
            int        souvRandomResult = 0;

            try
            {
                var currentProgress = exchangeCoinsDAL.GetProgressGameIsNotExistTracking(ConsumerID, LocationID, RegDate, ref error);

                if (currentProgress != null)
                {
                    string RandomSouvenirValue = ConfigurationManager.AppSettings["RandomSouvenir"].ToString();

                    var range    = RandomSouvenirValue.Split(',');
                    int minValue = int.Parse(range[0]);
                    int maxValue = int.Parse(range[1]);
                    souvRandomResult = random.Next(minValue, maxValue);

                    if (souvRandomResult <= 30)
                    {
                        Level = 1;
                    }
                    else if (souvRandomResult > 31 && souvRandomResult <= 49)
                    {
                        Level = 2;
                    }
                    else
                    {
                        Level = 3;
                    }


                    var resultSaveData = exchangeCoinsDAL.SpSaveSouvenirAndProgressGame(ConsumerID, LocationID, Longitude, Latitude, RegDate, ChestType, ref error, AgeID, Level, currentProgress.TotalWinCoins);


                    return(resultSaveData);
                }
                else
                {
                    Souvenir.Code = "01";
                    error         = "You can get one coin every day";
                    return(Souvenir);
                }
            }
            catch (Exception ex)
            {
                Souvenir.Code = "02";
                error         = ex.Message;
                return(Souvenir);
            }
        }
コード例 #2
0
        public IResponse createExchangeSouvewnorResultsResponse(SouvenirEN pSouvenir, string error)
        {
            SouvenirResponse response = new SouvenirResponse();

            if (pSouvenir.Code != "00" && pSouvenir.Achievement.Code != "00")
            {
                response.Code    = (pSouvenir.Code != null) ? pSouvenir.Code : pSouvenir.Achievement.Code;
                response.Message = error;
            }
            else
            {
                response.Type                          = 2;
                response.Title                         = pSouvenir.Title;
                response.Description                   = pSouvenir.Description;
                response.ImgUrl                        = pSouvenir.ImgUrl;
                response.Value                         = pSouvenir.Value;
                response.tracking                      = new TrackingResponse();
                response.tracking.TotalWinCoins        = pSouvenir.tracking.TotalWinCoins;
                response.tracking.TotalWinPrizes       = pSouvenir.tracking.TotalWinPrizes;
                response.tracking.TotalSouvenirs       = pSouvenir.tracking.TotalSouvenirs;
                response.tracking.CurrentCoinsProgress = pSouvenir.tracking.CurrentCoinsProgress;
                response.tracking.AgeID                = pSouvenir.tracking.AgeID;


                if (pSouvenir.Achievement.NewLevel > 0)
                {
                    response.Achievement                = new NewAchievement();
                    response.Achievement.Name           = pSouvenir.Achievement.Name;
                    response.Achievement.Level          = pSouvenir.Achievement.Level;
                    response.Achievement.Score          = pSouvenir.Achievement.Score;
                    response.Achievement.ValueNextLevel = pSouvenir.Achievement.ValueNextLevel;
                    response.Achievement.Prize          = pSouvenir.Achievement.Prize;
                }

                response.Code    = pSouvenir.Code;
                response.Message = (error == "") ? pSouvenir.Message : error;
            }

            return(response);
        }
コード例 #3
0
        public SouvenirEN SpSaveSouvenirAndProgressGame(int consumerID, string locationID, decimal Longitude, decimal Latitude, DateTime regDate, int ChestType, ref string error, int AgeID, int Level, int TotalWinCoins)
        {
            SouvenirEN    result        = new SouvenirEN();
            AchievementEN achievementEN = new AchievementEN();
            GameDAL       gameDal       = new GameDAL();

            try
            {
                con.Cnn.Open();
                con.Tra = con.Cnn.BeginTransaction();

                result = con.Cnn.Query <SouvenirEN>("SpSaveSouvenirAndProgressGame", new { ConsumerID = consumerID, LocationID = locationID, Longitude = Longitude, Latitude = Latitude, RegDate = regDate, ChestType = ChestType, AgeID = AgeID, Level = Level, TotalWinCoins = TotalWinCoins },
                                                    con.Tra, commandType: CommandType.StoredProcedure).FirstOrDefault();


                if (result.Code == "00")
                {
                    result.Achievement = ProcessToWinAchievement(consumerID, 1, TotalWinCoins, 7, con.Tra);
                }

                result.tracking = con.Cnn.Query <PlayersTrackingEN>("SpGetProgressGameByConsumer", new { @ConsumerID = consumerID },
                                                                    con.Tra, commandType: CommandType.StoredProcedure).FirstOrDefault();

                con.Tra.Commit();
            }
            catch (Exception ex)
            {
                con.Tra.Rollback();
                Console.WriteLine("Error ExchangeCoinsDAL: " + ex.Message);
                EventViewerLoggerDAL.LogError(ex.Message);
            }
            finally
            {
                con.Cnn.Close();
            }

            return(result);
        }