예제 #1
0
    // Use this for initialization
    void Start()
    {
        // クーポンを並べる場所(Content)を取得
        RectTransform content = GameObject.Find("Canvas/ScrollView/Viewport/Content").GetComponent <RectTransform>();

        // Contentの高さを設定
        float buttonSpace  = content.GetComponent <VerticalLayoutGroup>().spacing;
        float buttonHeight = buttonPrefab.GetComponent <LayoutElement>().preferredHeight;

        content.sizeDelta = new Vector2(0, (buttonHeight + buttonSpace) * couponCount);

        // クーポン表示関連
        couponList = GameObject.Find("CouponList").GetComponent <CouponList>();
        List <int> idList = couponList.CouponIdList;

        foreach (var id in idList)
        {
            GameObject button = (GameObject)Instantiate(buttonPrefab);
            button.transform.SetParent(content, false);
            button.transform.GetComponentInChildren <Text> ().text = couponList.CouponNames[id];
            button.transform.GetComponent <Button> ().onClick.AddListener(() => OnClick(id));
        }

        _audioSource = GetComponent <AudioSource>();
    }
        public async Task <dynamic> Post([FromBody] Coupon[] items)
        {
            CouponList list = new CouponList();

            list.docs = items.ToList();
            return(await _cloudantService.CreateListAsync(list));
        }
예제 #3
0
    // Use this for initialization
    void Start()
    {
        print("start called");
        _userScore = ScoreManager.Score;
        _score     = 0;

        _audioSource = GetComponent <AudioSource>();
        _couponList  = GameObject.Find("CouponList").GetComponent <CouponList>();

        int couponNum = Random.Range(0, 3);

        print(couponNum);

//		Coupon getcoupon = new Coupon(couponNum, _couponList.CouponNames[couponNum], _couponList.CouponSprites[couponNum]);
        Coupon getcoupon = new Coupon();

        getcoupon.setCouponID(couponNum);
        getcoupon.setCouponName(_couponList.CouponNames[couponNum]);
        getcoupon.setSprite(_couponList.CouponSprites[couponNum]);
        _couponMesText.enabled = false;
        _getCouponMes.enabled  = false;
        _couponImage.enabled   = false;

        _couponImage.sprite = _couponList.CouponSprites[couponNum];

//		_couponList.AddCoupon(getcoupon);
        _couponList.AddCoupon(couponNum);
    }
        public async Task <dynamic> CreateListAsync(CouponList items)
        {
            if (items == null || items.docs == null || !items.docs.Any())
            {
                return(false);
            }

            items.docs.ForEach(c => c.ServerCalled = "T");

            //Console.WriteLine("item tarih:" + items.docs[0].LotteryTime);
            //Console.WriteLine("cekilis tarih:" + CekilisCache.cekilisList[0].tarih);

            items = SetWinCounts(items);

            using (var client = CloudantClient())
            {
                var response = await client.PostAsJsonAsync(_dbName + "/_bulk_docs", items);

                if (response.IsSuccessStatusCode)
                {
                    //var responseJson = await response.Content.ReadAsAsync<List<Coupon>>();
                    return(true);
                }
                string msg = "Failure to POST. Status Code: " + response.StatusCode + ". Reason: " + response.ReasonPhrase;
                Console.WriteLine(msg);
                return(JsonConvert.SerializeObject(new { msg = "Failure to POST. Status Code: " + response.StatusCode + ". Reason: " + response.ReasonPhrase }));
            }
        }
예제 #5
0
 // Use this for initialization
 void Start()
 {
     couponList = GameObject.Find("CouponList").GetComponent <CouponList>();
     popUpView.SetActive(false);
     _selectedID     = couponList.selectedID;
     couponImage     = couponList.CouponSprites [_selectedID];
     renderer.sprite = couponImage;
     thumnail.sprite = couponImage;
     _audioSource    = GetComponent <AudioSource>();
 }
예제 #6
0
        public async void NavigateToPage(string type)
        {
            var inBackpack = new CouponList();

            inBackpack.backpackType = type;
            inBackpack.couponList   = await azure.GetBackpack(user);

            //await Navigation.PushAsync(new BackpackList());
            //list.SelectedItem = null;
        }
        private CouponList SetWinCounts(CouponList items)
        {
            foreach (Coupon item in items.docs)
            {
                string  itemDate = item.LotteryTime.Replace("/", "");
                Cekilis cekilis  = CekilisCache.cekilisList
                                   .Where(c => c.tarih.Equals(itemDate))
                                   .FirstOrDefault();

                if (cekilis != null)
                {
                    string[] cekilisNumbers = cekilis.numbers.Split('-');
                    string[] couponNumbers  = item.Numbers.Split('-');
                    item.WinCount = couponNumbers.Where(n => cekilisNumbers.Contains(n)).Count();
                }
            }

            return(items);
        }
        public async Task <dynamic> GetAllByUserName(string userName)
        {
            CouponSelectorByUser couponSelector = CouponSelectorByUser.Build(userName);

            using (var client = CloudantClient())
            {
                var response = await client.PostAsJsonAsync(_dbName + "/_find", couponSelector);

                if (response.IsSuccessStatusCode)
                {
                    var responseJson = await response.Content.ReadAsStringAsync();

                    CouponList couponList = JsonConvert.DeserializeObject <CouponList>(responseJson);
                    return(couponList.docs);
                }
                string msg = "Failure to GET. Status Code: " + response.StatusCode + ". Reason: " + response.ReasonPhrase;
                Console.WriteLine(msg);
                return(new List <Coupon>());
            }
        }
        public async Task <dynamic> GetByCouponIdAsync(string couponId)
        {
            CouponSelectorForId couponSelector = CouponSelectorForId.Build(couponId);

            using (var client = CloudantClient())
            {
                var response = await client.PostAsync(_dbName + "/_find", new StringContent(JsonConvert.SerializeObject(couponSelector), Encoding.UTF8, "application/json"));

                if (response.IsSuccessStatusCode)
                {
                    var responseJson = await response.Content.ReadAsStringAsync();

                    CouponList couponList = JsonConvert.DeserializeObject <CouponList>(responseJson);
                    return(couponList.docs[0]);
                }
                string msg = "Failure to GET. Status Code: " + response.StatusCode + ". Reason: " + response.ReasonPhrase;
                Console.WriteLine(msg);
                return(new Coupon());
            }
        }
        public async Task <dynamic> GetAllByWinCountAndTarih(string tarih)
        {
            string lotteryTime = tarih.Substring(0, 4) + "/" + tarih.Substring(4, 2) + "/" + tarih.Substring(6, 2);
            CouponSelectorByWinCountAndTarih couponSelector = CouponSelectorByWinCountAndTarih.Build(lotteryTime);

            using (var client = CloudantClient())
            {
                var response = await client.PostAsJsonAsync(_dbName + "/_find", couponSelector);

                if (response.IsSuccessStatusCode)
                {
                    var responseJson = await response.Content.ReadAsStringAsync();

                    CouponList couponList = JsonConvert.DeserializeObject <CouponList>(responseJson);
                    return(couponList.docs);
                }
                string msg = "Failure to GET. Status Code: " + response.StatusCode + ". Reason: " + response.ReasonPhrase;
                Console.WriteLine(msg);
                return(new List <Coupon>());
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string tempDateFilter = Request.QueryString["DateFilter"];
                if (string.IsNullOrEmpty(tempDateFilter))
                {
                    tempDateFilter = "THISMONTH";
                }
                UpdateDateFilter(tempDateFilter);

                DateTime startDate = AlwaysConvert.ToDateTime(Request.QueryString["StartDate"], DateTime.MinValue);
                DateTime endDate   = AlwaysConvert.ToDateTime(Request.QueryString["EndDate"], DateTime.MaxValue);
                if (startDate != DateTime.MinValue)
                {
                    StartDate.SelectedDate = startDate;
                }
                if (endDate != DateTime.MaxValue)
                {
                    EndDate.SelectedDate = endDate;
                }

                //BIND THE COUPON LIST
                CouponList.DataSource = OrderDataSource.GetCouponCodes();
                CouponList.DataBind();
                //INITIALIZE COUPON LIST
                string   couponCode = Request.QueryString["CouponCode"];
                ListItem listItem   = CouponList.Items.FindByValue(couponCode);
                if (listItem != null)
                {
                    CouponList.SelectedIndex = CouponList.Items.IndexOf(listItem);
                }
                //GENERATE REPORT ON FIRST VISIT
                ReportButton_Click(sender, e);
            }
        }
예제 #12
0
        public static Tuple <decimal, List <TireCouponModel>, int> FetchLowestPrice(string ShopName, decimal Price, int MaxCount = 5)
        {
            var data = new TireCouponResultModel();

            using (var client = CacheHelper.CreateCacheClient("TireCouponManage"))
            {
                var cache = client.GetOrSet($"TireCoupon/{ShopName}", () => TireCouponManage(ShopName), TimeSpan.FromHours(3));
                if (cache.Success && cache.Value.Any())
                {
                    data = cache.Value.FirstOrDefault();
                }
                else
                {
                    data = TireCouponManage(ShopName).FirstOrDefault();
                }
            }
            if (data == null)
            {
                return(null);
            }
            var EmptyCoupon = new TireCouponModel
            {
                PKID           = 0,
                CouponType     = 0,
                CouponUseRule  = 0,
                QualifiedPrice = 1M,
                Reduce         = 0M,
            };
            var CouponList = new List <TireCouponModel>();
            var Result     = new Tuple <decimal, List <TireCouponModel>, int>(Price * MaxCount, CouponList, MaxCount);

            for (var Count = 1; Count <= MaxCount; Count++)
            {
                var maxPrice    = Count * Price;
                var LowestPrice = Price * Count;
                var dataA       = data.CouponA.Where(g => g.StartTime <DateTime.Now && g.EndTime> DateTime.Now && g.QualifiedPrice <= maxPrice).Distinct().ToList();
                dataA.Add(EmptyCoupon);
                foreach (var itemA in dataA)
                {
                    var PriceA = itemA.CouponUseRule == 0 ? (maxPrice - itemA.Reduce) : (maxPrice - itemA.Reduce * Math.Floor(maxPrice / itemA.QualifiedPrice));
                    var dataB  = data.CouponB.Where(g => g.StartTime <DateTime.Now && g.EndTime> DateTime.Now && g.QualifiedPrice <= PriceA).Distinct().ToList();
                    dataB.Add(EmptyCoupon);
                    foreach (var itemB in dataB)
                    {
                        var PriceB = itemB.CouponUseRule == 0 ? (PriceA - itemB.Reduce) : (PriceA - itemB.Reduce * Math.Floor(PriceA / itemB.QualifiedPrice));
                        var dataC  = data.CouponC.Where(g => g.StartTime <DateTime.Now && g.EndTime> DateTime.Now && g.QualifiedPrice <= PriceB).Distinct().ToList();
                        dataC.Add(EmptyCoupon);
                        foreach (var itemC in dataC)
                        {
                            var finalPrice = itemC == null ? PriceB : (itemC.CouponUseRule == 0 ? (PriceB - itemC.Reduce) : (PriceB - itemC.Reduce * Math.Floor(PriceB / itemC.QualifiedPrice)));
                            if (finalPrice <= LowestPrice)
                            {
                                LowestPrice = finalPrice;
                                CouponList  = new List <TireCouponModel>()
                                {
                                    itemA, itemB, itemC
                                };
                            }
                        }
                    }
                }
                var stepPrice = Math.Round(LowestPrice / Count, 2);
                if (stepPrice < Result.Item1)
                {
                    Result = new Tuple <decimal, List <TireCouponModel>, int>(stepPrice, CouponList.Where(g => g.CouponType != 0).ToList(), Count);
                }
            }
            return(Result);
        }
예제 #13
0
        public RecurlyList<Coupon> Generate(int amount)
        {
            NumberOfUniqueCodes = amount;
            var coupons = new CouponList();

            var statusCode = Client.Instance.PerformRequest(Client.HttpRequestMethod.Post,
                memberUrl() + "/generate/",
                this.WriteGenerateXml,
                coupons.ReadFromLocation);

            return statusCode == HttpStatusCode.NotFound ? null : coupons;
        }
예제 #14
0
        public RecurlyList<Coupon> GetUniqueCouponCodes()
        {
            var coupons = new CouponList();

            var statusCode = Client.Instance.PerformRequest(Client.HttpRequestMethod.Get,
                memberUrl() + "/unique_coupon_codes/",
                coupons.ReadXmlList);

            return statusCode == HttpStatusCode.NotFound ? null : coupons;
        }