Exemplo n.º 1
0
    public void cacheSearchResult(ProductResult res)
    {
        if (res != null)
        {
            foreach (Product book in res.prodcutList)
            {
                BookData tmpBook = new BookData();
                tmpBook.url         = api.makeBookUrl(book.productSlug);
                tmpBook.id          = book.id;
                tmpBook.texture     = null;
                tmpBook.description = book.shortDescription;
                tmpBook.name        = book.name;
                if (book.defaultPicture != "" && book.defaultPicture != null)
                {
                    tmpBook.imgString = Convert.ToBase64String(Decompress(Convert.FromBase64String(book.defaultPicture)));
                    Texture2D tmpTexture = new Texture2D(1, 1);
                    tmpTexture.LoadImage(Convert.FromBase64String(tmpBook.imgString));
                    tmpTexture.Apply();
                    tmpBook.texture = tmpTexture;
                }
                //if(tmpBook.imgString != "" && tmpBook.imgString != null)tmpBook.texture.LoadImage(Decompress(Convert.FromBase64String(tmpBook.imgString)));

                cachedData.searchResult.Add(tmpBook);
            }
            if (searchCallBack != null)
            {
                searchCallBack(cachedData.searchResult, res.totalRecord);
            }
        }
    }
        /// <summary>
        /// 上传商品
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public async Task <WebResponseResult <string> > UploadProduct(ProductResult product)
        {
            var stCtx = ServiceContext.Session.NetClient
                        .Create <WebResponseResult <string> >(HttpMethod.Post, ApiList.AddProduct4, data: product.ToString());
            //
            await stCtx.SendAsync();

            if (!stCtx.IsValid())
            {
                throw new Exception("创业赚钱-商品服务器无法连接");
            }
            if (!stCtx.Result.success)
            {
                throw new Exception(stCtx.Result.msg);
            }

            product.product_id = Convert.ToInt32(stCtx.Result.msg);
            try
            {
                DbHelperOleDb.ExecuteSql(string.Format(_sqlFormatInsertProduct, product.ProductName.Replace("'", "\""), product.Source, product.SourceUrl, product.ShopName.Replace("'", "\""),
                                                       product.DetailHtml.Replace("'", "\""), product.ProductPrice, product.product_property, product.Location, product.SalesCount == null ? "0" : product.SalesCount, product.RateTotals == null ? "0" : product.RateTotals, product.product_id,
                                                       product.product_imgs, product.product_details.Replace("'", "\""), product.product_brand.Replace("'", "\""), ServiceContext.Session.Token.userid));
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("商品信息入库失败,但是已经上传成功,商品ID是:{0}{1}[异常]{2}",
                                                  stCtx.Result.msg, Environment.NewLine, ex.Message));
            }

            return(stCtx.Result);
        }
Exemplo n.º 3
0
        public List <ProductResult> SelectReport()
        {
            List <ProductResult> ps = new List <ProductResult>();
            List <ref_product_SelectAll_Result> x = pEntity.ref_product_SelectAll().ToList();

            foreach (ref_product_SelectAll_Result pr in x)
            {
                ProductResult result = new ProductResult();
                result.Barcode            = pr.Barcode;
                result.category_id        = pr.category_id;
                result.criticalQTY        = pr.criticalQTY;
                result.Expirydate         = pr.Expirydate;
                result.measurement        = pr.measurement;
                result.dateCreated        = pr.dateCreated;
                result.dateUpdated        = pr.dateUpdated;
                result.isActive           = pr.isActive;
                result.isDelete           = pr.isDelete;
                result.ProductCode        = pr.ProductCode;
                result.ProductDescription = pr.ProductDescription;
                result.ProductName        = pr.ProductName;
                result.product_id         = pr.product_id;
                result.QTY           = pr.QTY;
                result.retailprice   = pr.retailprice;
                result.supplierprice = pr.supplierprice;
                result.supplier_id   = pr.supplier_id;
                result.updatedBy     = pr.updatedBy;
                result.Weight        = pr.Weight;
                result.unitWeight    = pr.unitWeight;
                ps.Add(result);
                //ps.AddRange(result);
            }
            return(ps);
        }
Exemplo n.º 4
0
        public static ProductResult GetProductResult(DWProduct product)
        {
            var productResult = new ProductResult();

            productResult.Products.Add(product);
            return(productResult);
        }
Exemplo n.º 5
0
        public ProductResult SelectById(int id)
        {
            ref_product_SelectById_Result pr = pEntity.ref_product_SelectById(id).FirstOrDefault();
            ProductResult result             = new ProductResult();

            result.Barcode            = pr.Barcode;
            result.category_id        = pr.category_id;
            result.criticalQTY        = pr.criticalQTY;
            result.Expirydate         = pr.Expirydate;
            result.measurement        = pr.measurement;
            result.dateCreated        = pr.dateCreated;
            result.dateUpdated        = pr.dateUpdated;
            result.isActive           = pr.isActive;
            result.isDelete           = pr.isDelete;
            result.ProductCode        = pr.ProductCode;
            result.ProductDescription = pr.ProductDescription;
            result.ProductName        = pr.ProductName;
            result.product_id         = pr.product_id;
            result.QTY           = pr.QTY;
            result.retailprice   = pr.retailprice;
            result.supplierprice = pr.supplierprice;
            result.supplier_id   = pr.supplier_id;
            result.updatedBy     = pr.updatedBy;
            result.Weight        = pr.Weight;
            result.unitWeight    = pr.unitWeight;
            return(result);
        }
Exemplo n.º 6
0
        public async Task <Response <ProductResult> > GetPagesPartialUrlAsync(string accountName, CancellationToken cancellationToken = default)
        {
            if (accountName == null)
            {
                throw new ArgumentNullException(nameof(accountName));
            }

            using var message = CreateGetPagesPartialUrlRequest(accountName);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
            {
                ProductResult value = default;
                using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);

                if (document.RootElement.ValueKind == JsonValueKind.Null)
                {
                    value = null;
                }
                else
                {
                    value = ProductResult.DeserializeProductResult(document.RootElement);
                }
                return(Response.FromValue(value, message.Response));
            }
Exemplo n.º 7
0
        public ActionResult Details(ProductResult model)
        {
            int id = model.Id;

            model = getDetailsFromId(id);
            return(View("Details", model));
        }
Exemplo n.º 8
0
 private void SetProducts(ProductResult productResult, string rawResponse)
 {
     if (!string.IsNullOrEmpty(rawResponse))
     {
         rawResponse =
             rawResponse.Replace("pricebook-saleprice", "pricebooksaleprice")
             .Replace("pricebook-listprice", "pricebooklistprice")
             .Replace("pricebook-clearanceprice", "pricebookclearanceprice");
         ProductVariants = JsonConvert.DeserializeObject <ProductVariants>(rawResponse);
     }
     foreach (var product in productResult.Products)
     {
         var productId = product.Id;
         if (!VariantIdToExtension.ContainsKey(productId))
         {
             var extension = new ProductDetailItemExtension
             {
                 SizeSegment  = product.SizeSegment,
                 ExclusiveMsg = GetExclusiveMsg(productId),
                 Brand        = product.Brand,
                 PriceRange   = GetPriceRanges(productId)
             };
             VariantIdToExtension.Add(productId, extension);
         }
     }
 }
Exemplo n.º 9
0
        public ActionResult AddToBasket(ProductResult model)
        {
            int productId = model.Id;
            int quantity  = model.Quantity;

            if (Request.Cookies["Basket"] == null)
            {
                HttpCookie cookie = new HttpCookie("Basket");
                cookie.Values.Add(productId.ToString(), quantity.ToString());
                Response.Cookies.Add(cookie);
            }
            else
            {
                HttpCookie cookie = Request.Cookies["Basket"];

                string item = cookie.Values[productId.ToString()];

                if (item != null)
                {
                    cookie.Values[productId.ToString()] = (int.Parse(item) + quantity).ToString();
                }
                else
                {
                    cookie.Values.Add(productId.ToString(), quantity.ToString());
                }

                Response.Cookies.Add(cookie);
            }

            return(RedirectToAction("Browse", new { category = model.Category.ToString().Trim() }));
        }
Exemplo n.º 10
0
        public List <ProductResult> getResultsByCategory(string category)
        {
            ProductsDataContext db = new ProductsDataContext();

            var query = from p in db.Products
                        where p.Category == category
                        select new { p.Category, p.Description, p.Id, p.ImageUrl, p.Name, p.Price, p.Stock };

            var results = new List <ProductResult>();

            foreach (var q in query)
            {
                var result = new ProductResult
                {
                    Name        = q.Name,
                    Category    = q.Category,
                    Price       = (double)q.Price,
                    ImageUrl    = q.ImageUrl,
                    Description = q.Description,
                    Stock       = q.Stock,
                    Id          = q.Id
                };

                results.Add(result);
            }
            return(results);
        }
Exemplo n.º 11
0
        public ActionResult ChangeQuantityInBasket(ProductResult model)
        {
            HttpCookie cookie = Request.Cookies["Basket"];

            int    productId   = model.Id;
            int    quantity    = model.Quantity;
            int    oldQuantity = Int16.Parse(cookie.Values[productId.ToString()]);
            string item        = cookie.Values[productId.ToString()];

            if (item != null)
            {
                if (oldQuantity < quantity)
                {
                    var diff = quantity - oldQuantity;
                    cookie.Values[productId.ToString()] = (int.Parse(item) + diff).ToString();
                }
                else if (oldQuantity > quantity)
                {
                    var diff = oldQuantity - quantity;
                    cookie.Values[productId.ToString()] = (int.Parse(item) - diff).ToString();
                }
            }

            Response.Cookies.Add(cookie);

            return(RedirectToAction("Checkout"));
        }
        public HttpResponseMessage Products()
        {
            var result = new ProductResult();      //you could also use the view class ProductsListView

            result.Products = _repository.GetProducts();
            return(Request.CreateResponse(httpStatusCode, result));
        }
Exemplo n.º 13
0
 public ProductSearchViewModel(UserInformation userInformation)
 {
     try
     {
         this._userInformation = userInformation;
         _productSearchBll     = new ProductSearchBll(this._userInformation);
         ProdSearchModel       = new ProductSearchModel();
         SetdropDownItems();
         GetAllCombo();
         this.searchCommand = new DelegateCommand(this.Search);
         this.selectionChangedManufacturedCommand = new DelegateCommand(this.FilterCostCentre);
         this.selectionChangedFamilyCommand       = new DelegateCommand(this.FilterAll);
         this.closeCommand = new DelegateCommand(this.CloseSubmit);
         this.showProductInformationCommand = new DelegateCommand(this.ShowProductInformation);
         this.printCommand = new DelegateCommand(this.PrintProductSearch);
         this.previewMouseLeftButtonDownCommand = new DelegateCommand(this.ValidateApplicationCombo);
         ProdSearchModel.TotalRecords           = "Part Details";
         ProdSearchModel.HeatTreatment          = "678WERER@#$%^&$#";
         ProductResult = _productSearchBll.GetProductSearchDetails(ProdSearchModel);
         ProductResult.AddNew();
         ProdSearchModel.HeatTreatment = "";
         NotifyPropertyChanged("ProductResult");
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 14
0
        public static async Task <ProductResult> GetProductList()
        {
            ProductResult result = null;

            try
            {
                using (var client = new HttpClient())
                {
                    //var productRequestUri = ConfigurationManager.AppSettings["http://api.bklo.in:3000/getAllProductsJson"].ToString();
                    var productRequestUri = String.Format("http://api.bklo.in:3000/getAllProductsJson");
                    var jsonData          = await client.GetStringAsync(productRequestUri);

                    result = JsonConvert.DeserializeObject <ProductResult>(jsonData);
                    // System.IO.File.WriteAllText(@"D:\KalyanWork\Git\Classroom-Demo\TestApp\Data\BooksData.txt", jsonData);

                    System.IO.File.WriteAllText(@"E:\SumWork\Git\Classroom-Demo\TestApp\Data\BooksData.txt", jsonData);
                    var text  = System.IO.File.ReadAllText(@"E:\SumWork\Git\Classroom-Demo\TestApp\Data\BooksData.txt");
                    var text2 = JsonConvert.DeserializeObject <ProductResult>(text);
                    if (result.timeStamp != text2.timeStamp)
                    {
                        System.IO.File.WriteAllText(@"E:\SumWork\Git\Classroom-Demo\TestApp\Data\BooksData.txt", jsonData);
                    }
                }
                //  return result;
            }
            catch (Exception ex)
            {
            }
            return(result);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 正店抓取
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        async Task ProcessStoreUrl(string url)
        {
            AppendLog(txtLog, "开始嗅探店铺商品...");
            ProductResult currentProduct = new ProductResult();
            var           list           = await GetAllProductsByUrl(url);

            AppendLog(txtLog, "该店铺共嗅探到商品{0}个...", list.Count);

            int index = 1;

            foreach (var item in list)
            {
                AppendLog(txtLog, "开始处理商品{0}...", item.SourceUrl);
                stStatus.Text = string.Format("正在处理第{0}个商品", index++);
                try
                {
                    currentProduct = await _context.UrlConvertProductService.ProcessProduct(item.SourceUrl);
                    await ProcessProductAndUpload(currentProduct);
                }
                catch (Exception ex)
                {
                    FailProducts.Add(currentProduct.SourceUrl, currentProduct);
                    AppendLogError(txtLog, "商品{0}处理失败[已添加到失败队列],等待1秒处理下一个商品,原因:{1}...", currentProduct.SourceUrl, ex.Message);
                    Thread.Sleep(1000);
                    break;
                }
                AppendLog(txtLog, "商品{0}处理完成,等待1秒处理下一个商品...", currentProduct.SourceUrl);
                Thread.Sleep(1000);
            }
        }
Exemplo n.º 16
0
        public ActionResult Index()
        {
            var result = new ProductResult();

            result.Images   = _imagesServices.getAllProducts();
            result.Contents = _contentsServices.getAllProductContents();
            return(View(result));
        }
Exemplo n.º 17
0
        public void ProductQuantity(int area, int qtyExpected)
        {
            ProductResult productResult = new ProductResult();

            productResult.Description = new ProductDescription(1, 30, "1 App", 35, "Gluon", "Gluon is a high performance polymer that can be sprayed onto soil surfaces to form a “veneer” or “crust” which can withstand wind speeds up to 120km/hr. Its crosslinking nature allows rain to seep through the crust instead of washing it away. A light dosage rate will give you enough protection from the elements for up to a month.");
            productResult.Job         = new Job(0, area, 1, 90, true, DateTime.Now, "second Job object");

            Assert.Equal(qtyExpected, productResult.ProductQuantity);
        }
Exemplo n.º 18
0
 private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     foreach (ProductResult product in productsOnPallet)
     {
         if (product.nazwa == this.listBox1.SelectedItem.ToString())
         {
             this.currentProduct = product;
         }
     }
 }
Exemplo n.º 19
0
        private void FillProductComboBox()
        {
            productManager = new ProductManager();
            product        = new ProductResult();
            var list = productManager.GetAllSpecified();

            cmbProduct.DataSource    = list;
            cmbProduct.ValueMember   = nameof(product.ID);
            cmbProduct.DisplayMember = nameof(product.ProductName);
        }
Exemplo n.º 20
0
        /// <summary>
        /// 获取ProductResult对象附加信息
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        public async Task GetProductResultExtensionAsync(ProductResult result)
        {
            //获取品牌信息
            var brand = await context.Brands.FirstOrDefaultAsync(c => c.Id == result.BrandId);

            result.BrandName = brand?.Name;
            //获取商品图片
            var imgs = await context.ProductImgs.Where(c => c.ProductId == result.Id).ToListAsync();

            result.Imgs = Mapper.Map <List <ProductImgResult> >(imgs);
        }
Exemplo n.º 21
0
        public async Task <ProductResult> UpdateProductAsync(Product product)
        {
            ProductResult productResult = new ProductResult();
            var           productId     = await this._productDataSource.UpdateProductAsync(product);

            productResult.CreateTime = DateTime.UtcNow;
            productResult.Result     = productId.ToString();
            productResult.StatusCode = StatusCodes.Status200OK;

            return(productResult);
        }
Exemplo n.º 22
0
        public ProductResult GetProduct(int?prodId)
        {
            var result = new ProductResult
            {
                AdditiveProduct     = GetAdditiveProduct(prodId),
                ChileProduct        = GetChileProduct(prodId),
                PackagingProduct    = GetPackagingProduct(prodId),
                NonInventoryProduct = GetNonInventoryProduct(prodId)
            };

            return(result.ProductKey == null ? null : result);
        }
        public async Task CalculateAveCubicWeight_WhenThereIsNoProductResult_ReturnZero()
        {
            var productInfoGetter = new Mock <IProductInfoGetter>();
            var productResult     = new ProductResult();

            productInfoGetter.Setup(pg => pg.GetProductResultAsync(It.IsAny <string>())).ReturnsAsync(productResult);
            var caculator = new CubicWeightCalculator(productInfoGetter.Object);

            var result = await caculator.CalculateAverageCubicWeightAsync();

            Assert.That(result, Is.EqualTo(0));
        }
Exemplo n.º 24
0
        private async Task <ProductModel> MapProductResultToModelAsync(ProductResult productResult)
        {
            var product = new ProductModel()
            {
                Id                 = productResult.Id,
                CreatedBy          = productResult.CreatedBy,
                CreatedById        = productResult.CreatedById,
                CreatedDate        = productResult.CreatedDate,
                Description        = productResult.Description,
                Name               = productResult.Name,
                Price              = productResult.Price,
                CreatedByPhotoCode = productResult.CreatedByPhotoCode,
                Categories         = productResult.Categories.Select(x => new ProductCategoryRelationModel()
                {
                    Id   = x.Id,
                    Name = x.Name
                }),
                Farms = productResult.Farms.Select(x => new ProductFarmModel()
                {
                    Name = x.Name,
                    Id   = x.FarmId
                }),
                Pictures = productResult.Pictures.Select(y => new PictureRequestModel()
                {
                    PictureId = y.Id
                }),
                ProductAttributes = productResult.ProductAttributes.Select(x => new ProductAttributeRelationModel
                {
                    AttributeId             = x.AttributeId,
                    ControlTypeId           = x.AttributeControlTypeId,
                    DisplayOrder            = x.DisplayOrder,
                    Id                      = x.Id,
                    IsRequired              = x.IsRequired,
                    TextPrompt              = x.TextPrompt,
                    Name                    = x.AttributeName,
                    ControlTypeName         = ((ProductAttributeControlType)x.AttributeControlTypeId).GetEnumDescription(),
                    AttributeRelationValues = x.AttributeRelationValues.Select(c => new ProductAttributeRelationValueModel
                    {
                        Id                        = c.Id,
                        DisplayOrder              = c.DisplayOrder,
                        Name                      = c.Name,
                        PriceAdjustment           = c.PriceAdjustment,
                        PricePercentageAdjustment = c.PricePercentageAdjustment,
                        Quantity                  = c.Quantity
                    })
                })
            };

            product.CreatedByIdentityId = await _userManager.EncryptUserIdAsync(product.CreatedById);

            return(product);
        }
        private static async Task <string> GetTaxNameAsync(Transaction transaction, string taxNameFormat)
        {
            if (!transaction.DigisellerProductId.HasValue)
            {
                return(transaction.Name);
            }

            ProductResult info = await Digiseller.GetProductsInfoAsync(transaction.DigisellerProductId.Value);

            string productName = info.Info.Name;

            return(string.Format(taxNameFormat, productName));
        }
Exemplo n.º 26
0
        private void FillProducts(int selected)
        {
            productManager = new ProductManager();
            product        = new ProductResult();
            list           = productManager.GetAllSpecified();
            //cmbProductName.DataSource = list;
            //cmbProductName.ValueMember = nameof(product.ID);
            //cmbProductName.DisplayMember = product.ProductName;

            for (int i = 0; i < list.Count; i++)
            {
                cmbProductName.Items.Add(list[i].ProductName);
            }
        }
Exemplo n.º 27
0
        private void toolStripButton6_Click(object sender, EventArgs e)
        {
            ProductResult pr = new ProductResult();
            string        id = cmbprod.SelectedValue.ToString();

            pr = _product.SelectById(Convert.ToInt16(id));
            addItem(pr);
            lbltotalamounts.Text  = Addition(lbltotalamounts.Text, lbltotalprice.Text).ToString(); // (Convert.ToDouble(lblgrandtotal.Text) + Convert.ToDouble(lbltotalprice.Text)).ToString();
            cmbprod.SelectedIndex = -1;
            lblmeasure.Text       = "";
            lblprice.Text         = "0.00";
            lbltotalprice.Text    = "0.00";
            txtqty.Text           = "";
        }
Exemplo n.º 28
0
        //private void GetRoleList()
        //{
        //    string[] roleList = { "Admin", "Staff" };

        //    cbRoleList.ItemsSource = roleList;
        //}

        //private async void GetActiveBranchList()
        //{
        //    try
        //    {
        //        dynamic param = new { page = 0 };

        //        RootBranchObject Response = await ObjBranchService.BranchPostAPI("getBranchList", param);

        //        if (Response.Status == "ok")
        //        {
        //            cbBranchList.ItemsSource = (Response.Data.OrderBy(property => property.Name).Select(item => item.Name));
        //        }
        //        else
        //        {
        //            cbBranchList.Items.Add("- Fail to get branch list -");
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        cbBranchList.Items.Add("- Fail to get branch list -");
        //    }
        //}
        #endregion


        private void btnDialogOk_Click(object sender, RoutedEventArgs e)
        {
            for (var i = 0; i < ProductQuantityList.Count; i++)
            {
                ProductResult.Add(new ProductQuantity
                {
                    Branch_name = ProductQuantityList[i].Branch_name,
                    Quantity    = textboxControls[i].Text == ""? "0" : textboxControls[i].Text
                });
            }

            Price = tbPrice.Text == "" ? "0" : tbPrice.Text;

            this.DialogResult = true;
        }
    static void Main(string[] args)
    {
        // create a new instance of my class
        MyClass mc = new MyClass();

        // calculate the product
        ProductResult result = mc.CalculateProduct(10, 6);

        // print out the result
        Console.WriteLine("Result: {0}", result.Result);

        // wait for input before exiting
        Console.WriteLine("Press enter to finish");
        Console.ReadLine();
    }
Exemplo n.º 30
0
 private void addItem(ProductResult pr)
 {
     x        = x + 1;
     itm      = new ListViewItem();
     itm.Text = x.ToString();
     itm.SubItems.Add(pr.Barcode);
     itm.SubItems.Add(pr.ProductCode);
     itm.SubItems.Add(pr.ProductName);
     itm.SubItems.Add(pr.ProductDescription);
     itm.SubItems.Add(lblprice.Text);
     itm.SubItems.Add(lblmeasure.Text);
     itm.SubItems.Add(txtqty.Text);
     itm.SubItems.Add(lbltotalprice.Text);
     itm.SubItems.Add(cmbprod.SelectedValue.ToString());
     this.ProdListV.Items.Add(itm);
 }