Пример #1
0
    void Start()
    {
        refreshScores();
        var buildTypeText = transform.Find("BuildType").GetComponent <Text>();

        #if HMS_BUILD
        buildTypeText.text = "HMS Build";
        #else
        buildTypeText.text = "GMS Build";
        #endif

        localProduct = new LocalProduct();
        var StartGameBtn = transform.Find("StartGameBtn").GetComponent <Button>();
        StartGameBtn.onClick.AddListener(OnClickedStartGameBtn);

        removeAdsButton = transform.Find("RemoveAdsButton").GetComponent <Button>();
        removeAdsButton.onClick.AddListener(OnClickedBuyButton);

        IapManager.Instance.Init(localProduct, (isInitialized) =>
        {
            if (isInitialized)
            {
                isProductLoaded = true;
                ShowProduct();
            }
            else
            {
                Debug.Log("Iap Manager cannot be initialized...");
            }
        });
    }
Пример #2
0
        public void Init(LocalProduct localProduc, Action <bool> initCallback)
        {
            _iapProvider  = IapFactory.GetAvailableIapProvider();
            _initCallback = initCallback;

            _iapProvider.Init(localProduc, this);
        }
Пример #3
0
        public void Init(LocalProduct localProduct, IIapListener listener)
        {
            _listener     = listener;
            _localProduct = localProduct;

            // If Products already installed fetch them from UnityStoreController
            if (IsInitialized())
            {
                FetchedProducts(_unityStoreController.products.all);
                _listener.OnProductsQuerySuccess();
                return;
            }

            #if HMS_BUILD && !UNITY_EDITOR
            var builder = ConfigurationBuilder.Instance(HuaweiPurchasingModule.Instance());
            #else
            var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
            #endif

            builder.AddProduct("remove_ads", ProductType.NonConsumable);
            UnityPurchasing.Initialize(this, builder);
        }
Пример #4
0
        public ActionResult Import(FormCollection collection)
        {
            var actionResult = new List <ImportResultItem>();

            var file = Request.Files[0];

            if (file == null || file.ContentLength == 0 || String.IsNullOrEmpty(file.FileName) ||
                !file.FileName.Contains(".xls"))
            {
                actionResult.Add(new ImportResultItem
                {
                    ResultType = ImportResultType.CommonError,
                    Message    = "Can't import. File extension must be <strong>.xls</strong>"
                });
                return(View(actionResult));
            }

            var workbook  = Workbook.Load(file.InputStream);
            var worksheet = workbook.Worksheets[0];

            var caellCategoryID = worksheet.Cells[0, 0];
            int categoryID;

            if (caellCategoryID.IsEmpty || !int.TryParse(caellCategoryID.StringValue, out categoryID))
            {
                actionResult.Add(new ImportResultItem
                {
                    ResultType = ImportResultType.CommonError,
                    Message    = "Can't import. You shouldn't edit the first two rows"
                });
                return(View(actionResult));
            }

            var rowsIndexs = worksheet.Cells.Rows.Where(q => q.Key > 1).Select(q => q.Key).OrderBy(q => q);
            var lastColumn = worksheet.Cells.Rows[0].LastColIndex;

            var result = new List <LocalProduct>();

            foreach (var rowIndex in rowsIndexs)
            {
                var tempLocalProduct = new LocalProduct();

                var sProductID = worksheet.Cells[rowIndex, 0].Value != null
                    ? (string)worksheet.Cells[rowIndex, 0].Value
                    : "";

                var product = new Product();

                int productID;
                if (int.TryParse(sProductID, out productID))
                {
                    product.ID = productID;
                }

                product.CategoryID       = categoryID;
                product.ReviewLink       = worksheet.Cells[rowIndex, 1].StringValue;
                product.Title            = worksheet.Cells[rowIndex, 2].StringValue;
                product.SmallDescription = worksheet.Cells[rowIndex, 3].StringValue;
                product.Description      = worksheet.Cells[rowIndex, 4].StringValue;

                var isActive = worksheet.Cells[rowIndex, 5].StringValue != "" &&
                               worksheet.Cells[rowIndex, 5].StringValue == "1";

                product.IsActive = isActive;

                var manufacturerID = 0;
                if (!int.TryParse(worksheet.Cells[rowIndex, 6].StringValue, out manufacturerID))
                {
                    continue;
                }
                product.ManufacturerID = manufacturerID;

                tempLocalProduct.Product = product;

                for (var j = 7; j <= lastColumn; j++)
                {
                    if (worksheet.Cells[rowIndex, j].IsEmpty)
                    {
                        continue;
                    }

                    int tempCategoryParameterID;
                    if (int.TryParse(worksheet.Cells[0, j].StringValue, out tempCategoryParameterID))
                    {
                        tempLocalProduct.ProductValues.Add(new ProductParameterValue
                        {
                            Value = worksheet.Cells[rowIndex, j].ToString(),
                            CategoryParameterID = tempCategoryParameterID
                        });
                    }
                }

                result.Add(tempLocalProduct);
            }

            actionResult = _productService.ImportProducts(result);

            return(View(actionResult));
        }
        public async Task <ServiceResponseBase> Check(int id, AccountViewModel account)
        {
            try
            {
                var inStorage = await _context.InStorage.FirstOrDefaultAsync(o => o.Id == id);

                if (inStorage != null)
                {
                    inStorage.Status += 1;
                    var inStorageDetails = await _context.InStorDetail.Where(o => o.OrderNum == inStorage.OrderNum).ToListAsync();

                    if (inStorage.Status == (int)InOpStatus.已入库)
                    {
                        foreach (var inStorageDetail in inStorageDetails)
                        {
                            inStorageDetail.RealNum = inStorageDetail.Num;
                        }
                    }
                    if (inStorage.Status == (int)InOpStatus.已上架)
                    {
                        foreach (var inStorageDetail in inStorageDetails)
                        {
                            inStorageDetail.PutRealNum = inStorageDetail.RealNum;
                            var localProduct = await _context.LocalProduct.FirstOrDefaultAsync(o => o.CompanyId == inStorage.CompanyId &&
                                                                                               o.BarCode == inStorageDetail.BarCode && o.LocalNum == inStorageDetail.LocalNum);

                            if (localProduct == null)
                            {
                                var location = await _context.Location.FirstOrDefaultAsync(o => o.LocalBarCode == inStorageDetail.LocalNum);

                                localProduct = new LocalProduct
                                {
                                    Sn          = Guid.NewGuid().ToString("N"),
                                    StorageNum  = location.StorageNum,
                                    StorageName = null,
                                    LocalNum    = inStorageDetail.LocalNum,
                                    LocalName   = null,
                                    LocalType   = location.LocalType,
                                    ProductNum  = inStorageDetail.ProductNum,
                                    BarCode     = inStorageDetail.BarCode,
                                    ProductName = inStorageDetail.ProductName,
                                    BatchNum    = "",
                                    Num         = (double)inStorageDetail.PutRealNum,
                                    SupNum      = null,
                                    SupName     = null,
                                    CreateTime  = DateTime.Now,
                                    CreateUser  = account.Id.ToString(),
                                    CreateName  = account.Name,
                                    Remark      = null,
                                    CompanyId   = account.CompanyId
                                };
                                _context.LocalProduct.Add(localProduct);
                            }
                            else
                            {
                                localProduct.Num += (double)inStorageDetail.PutRealNum;
                            }
                        }
                    }
                    _context.Entry(inStorage).State = EntityState.Modified;
                }

                await _context.SaveChangesAsync();

                return(new ServiceResponseBase()
                {
                    Status = Status.ok
                });
            }
            catch (Exception ex)
            {
                return(new ServiceResponseBase()
                {
                    Status = Status.error, Message = ex.Message
                });
            }
        }