Esempio n. 1
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            var authentication1 = new com.n11.api.Authentication();

            authentication1.appKey    = apiAnahtari1; //api anahtarınız
            authentication1.appSecret = apiSifresi1;  //api şifeniz

            ProductServicePortService prodServ = new ProductServicePortService();

            SaveProductRequest saveRequest = new SaveProductRequest();

            //marka, tarih aralığı
            saveRequest.auth    = authentication1;
            saveRequest.product = new ProductRequest();
            saveRequest.product.productSellerCode = txtMagazaKodu.Text;

            saveRequest.product.title        = txtUrunBasligi.Text;
            saveRequest.product.subtitle     = txtaltBaslik.Text;
            saveRequest.product.description  = richTextBox1.Text;
            saveRequest.product.category     = new CategoryRequest();
            saveRequest.product.category.id  = Convert.ToInt32(txtUrunKategoriNo.Text);
            saveRequest.product.price        = Convert.ToDecimal(txtFiyati.Text);
            saveRequest.product.currencyType = comboBox1.Text;

            ProductImage prImg = new ProductImage();

            ProductImage[] pr = new ProductImage[1];
            pr[0] = prImg;
            string resimUrl = urunResimlericmbBox.Text.Replace("https", "http");

            prImg.url   = resimUrl;
            prImg.order = "1";
            saveRequest.product.images = pr;

            saveRequest.product.productCondition = txtUrunDurumu.Text;
            saveRequest.product.preparingDay     = txtprodPrepDay.Text;
            saveRequest.product.shipmentTemplate = txtKargoSablonu.Text;

            ProductSkuRequest prStock = new ProductSkuRequest();

            prStock.quantity    = txtStokMiktari.Text;
            prStock.optionPrice = Convert.ToDecimal(txtFiyati.Text);
            ProductSkuRequest[] prStockList = new ProductSkuRequest[1];
            prStockList[0] = prStock;

            saveRequest.product.stockItems = prStockList;

            SaveProductResponse saveResponse = prodServ.SaveProduct(saveRequest);

            if (saveResponse.result.errorCode == null)
            {
                MessageBox.Show("ürün kaydedildi");
            }
            else
            {
                MessageBox.Show("ürün kaydedilmedi");
                MessageBox.Show(saveResponse.result.errorMessage);
            }
        }
Esempio n. 2
0
        public KayitIslemi ahandaaa()
        {
            try
            {
                //String strAppKey = "64155786-da91-4204-8735-443d17acf808";
                //String strAppSecret = "***";
                String strUrl             = FotoUrl;
                String strSellerStockCode = productSellerCode;
                //String strSellerStockCode1 = "KırmızıKod-APIDeneme4321000000000";
                String strAttributeName      = "Marka";
                String strAttributeValue     = "Apple";
                String strSkuAttributeKey    = "Renk";
                String strSkuAttributeValue  = "Mavi";
                String strSkuAttributeValue1 = "Kırmızı";
                String strProductTitle       = "Lorem ipsum";
                String strProductSubtitle    = "Lorem ipsum dolor sit amet";
                String strProductSellerCode  = productSellerCode;
                String strProductCondition   = "1"; // 1 yeni, 2 ikinci el
                String strShipmentTemplate   = "AGT";
                //String strProductDescription = this.description;
                String strGtin             = "0190198066473";
                String strGtin1            = "0190198066474";
                int    setOrderValue       = 1;
                int    quantityValue       = 10;
                int    quantityValue1      = 20;
                int    categoryIdValue     = 592;
                int    priceValue          = 50;
                int    currencyTypeValue   = 1;
                int    approvalStatusValue = 1;
                int    preparingDayValue   = 3;

                Authentication authentication = new Authentication();
                authentication.appKey    = strAppKey;
                authentication.appSecret = strAppSecret;

                ProductImage        productImage     = new ProductImage();
                List <ProductImage> productImageList = new List <ProductImage>();
                productImage.url   = strUrl;
                productImage.order = "1"; // foto sırası bu
                productImageList.Add(productImage);

                //List<ProductAttributeRequest> skuAttributeRequestList = new List<ProductAttributeRequest>();
                //ProductAttributeRequest skuAttributeRequest = new ProductAttributeRequest();
                //skuAttributeRequest.name = strSkuAttributeKey;
                //skuAttributeRequest.value = strSkuAttributeValue;
                //skuAttributeRequestList.Add(skuAttributeRequest);

                //List<ProductAttributeRequest> skuAttributeRequestList1 = new List<ProductAttributeRequest>();
                //ProductAttributeRequest skuAttributeRequest1 = new ProductAttributeRequest();
                //skuAttributeRequest1.name = strSkuAttributeKey;
                //skuAttributeRequest1.value = strSkuAttributeValue1;
                //skuAttributeRequestList1.Add(skuAttributeRequest1);

                List <ProductSkuRequest> stockItems = new List <ProductSkuRequest>();

                foreach (ProductSku item in this.stockItems.stockItem)
                {
                    ProductSkuRequest sku1 = new ProductSkuRequest();
                    sku1.sellerStockCode = item.sellerStockCode;
                    foreach (var item2 in item.attributes)
                    {
                        List <ProductAttributeRequest> skuAttributeRequestList1 = new List <ProductAttributeRequest>();
                        ProductAttributeRequest        skuAttributeRequest1     = new ProductAttributeRequest();
                        skuAttributeRequest1.name  = item2.name;
                        skuAttributeRequest1.value = item2.value;
                        skuAttributeRequestList1.Add(skuAttributeRequest1);


                        //skuAttributeRequest1.name = strSkuAttributeKey;
                        //skuAttributeRequest1.value = strSkuAttributeValue1;
                        //skuAttributeRequestList1.Add(skuAttributeRequest1);

                        sku1.attributes = skuAttributeRequestList1.ToArray();
                    }


                    sku1.quantity    = item.quantity;
                    sku1.optionPrice = item.optionPrice;
                    sku1.gtin        = item.gtin;
                    stockItems.Add(sku1);
                }



                //ProductSkuRequest sku = new ProductSkuRequest();
                //sku = this.stockItems;
                //sku.sellerStockCode = strSellerStockCode;
                //sku.attributes = skuAttributeRequestList1.ToArray();// (skuAttributeRequestList);
                //sku.quantity = quantityValue.ToString();
                //sku.gtin = strGtin;

                //ProductSkuRequest sku1 = new ProductSkuRequest();
                ////sku1.sellerStockCode = strSellerStockCode1;
                //sku1.attributes = skuAttributeRequestList1.ToArray();
                //sku1.quantity = quantityValue1.ToString();
                //sku1.gtin = strGtin1;

                //stockItems.Add(sku);
                //stockItems.Add(sku1);

                CategoryRequest categoryRequest = new CategoryRequest();
                categoryRequest.id = category.id;

                //ProductAttributeRequest productAttribute = new ProductAttributeRequest();
                //productAttribute.name = strAttributeName;
                //productAttribute.value = strAttributeValue;
                //List<ProductAttributeRequest> productAttributeRequestList = new List<ProductAttributeRequest>();
                //productAttributeRequestList.Add(this.attributes[0]);
                //productAttributeRequestList.Add(productAttribute);

                ProductRequest productRequest = new ProductRequest();
                productRequest.title             = this.title;
                productRequest.subtitle          = this.subtitle;
                productRequest.description       = this.description;
                productRequest.category          = categoryRequest;
                productRequest.productSellerCode = this.productSellerCode;
                productRequest.price             = this.price;
                productRequest.currencyType      = "1";
                productRequest.images            = this.Foto;
                productRequest.approvalStatus    = this.approvalStatus;
                productRequest.preparingDay      = this.preparingDay;

                productRequest.stockItems = stockItems.ToArray();
                //productRequest.stockItems = this.stostockItems.ToArray();

                productRequest.productCondition = strProductCondition;
                productRequest.shipmentTemplate = this.shipmentTemplate;
                //productRequest.attributes = this.proproductAttributeRequestList.ToArray();


                SaveProductRequest saveProductRequest = new SaveProductRequest();
                saveProductRequest.auth    = authentication;
                saveProductRequest.product = productRequest;

                ProductServicePortService port     = new ProductServicePortService();
                SaveProductResponse       response = port.SaveProduct(saveProductRequest);
                //ResultInfo info = new ResultInfo();
                if (response.result.status == "failure")
                {
                    return(KayitIslemi.Basarisiz);
                }
                else if (response.result.status == "failure")
                {
                    return(KayitIslemi.Basarili);
                }
                else
                {
                    return(KayitIslemi.AgabuNe);
                }
                //System.out.println("Saving product " + response.getProduct().getId() + " is " + response.getResult().getStatus().getValue());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        public SaveProductResponse SaveProduct(Urun urun)
        {
            string siteUrl = string.Format("{0}://{1}{2}{3}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port == 80 ? string.Empty : ":" + HttpContext.Current.Request.Url.Port, HttpContext.Current.Request.ApplicationPath);

            #if DEBUG
            siteUrl = "https://aysemtuhafiye.com";
            #endif
            com.n11Product.api.Authentication authentication = new com.n11Product.api.Authentication
            {
                appKey    = apiKey,
                appSecret = apiSecret
            };

            CategoryRequest categoryRequest = new CategoryRequest();
            categoryRequest.id = urun.entegrasyonBilgi.n11KategoriID;

            ProductImage[] productImages = new ProductImage[urun.urunResimleri.Count];
            for (int i = 0; i < urun.urunResimleri.Count; i++)
            {
                ProductImage productImage = new ProductImage();
                productImage.url   = siteUrl + "/Content/icerik/urun/orjinal/" + urun.urunResimleri[i].resim;
                productImage.order = urun.urunResimleri[i].sira.ToString();
                productImages[i]   = productImage;
            }

            //ProductAttributeRequest[] productAttributeRequests = new ProductAttributeRequest[0];

            /*
             * ProductDiscountRequest productDiscountRequest = new ProductDiscountRequest();
             * productDiscountRequest.startDate = "dd/MM/yyyy";
             * productDiscountRequest.endDate = "dd/MM/yyyy";
             * productDiscountRequest.type = "";
             * productDiscountRequest.value = "1";
             */

            ProductSkuRequest[] productSkuRequests = new ProductSkuRequest[1];
            ProductSkuRequest   productSkuRequest  = new ProductSkuRequest();
            productSkuRequest.quantity    = urun.miktar.ToString();
            productSkuRequest.optionPrice = urun.entegrasyonBilgi.GetN11Fiyat(urun.fiyat);
            productSkuRequests[0]         = productSkuRequest;

            ProductRequest productRequest = new ProductRequest();
            productRequest.productSellerCode = urun.urunID.ToString();
            productRequest.title             = urun.urunAdi;
            productRequest.subtitle          = urun.urunAdi;
            productRequest.description       = urun.urunAciklamasi;
            //productRequest.attributes = productAttributeRequests;//Özellik ve değerleri
            productRequest.category     = categoryRequest;
            productRequest.price        = urun.entegrasyonBilgi.GetN11Fiyat(urun.fiyat);
            productRequest.currencyType = "TL";//USD|EUR|TL
            productRequest.images       = productImages;
            //productRequest.saleStartDate = "dd/MM/yyyy";//Satışa başlama tarihi
            //productRequest.saleEndDate = "dd/MM/yyyy";//Satışı bitirme tarihi
            //productRequest.productionDate = "dd/MM/yyyy";//Üretim tarihi
            //productRequest.expirationDate = "dd/MM/yyyy";//Son kullanma tarihi
            productRequest.productCondition = "1";//1:Yeni|2:2.El
            productRequest.preparingDay     = (urun.kargoSuresi < 1 ? 1 : urun.kargoSuresi).ToString();
            //productRequest.domestic = true;//Yerli ürün mü true|false
            //productRequest.discount = productDiscountRequest;//İndirim bilgisi
            productRequest.shipmentTemplate = urun.entegrasyonBilgi.n11TemplateName;
            productRequest.stockItems       = productSkuRequests;
            //productRequest.groupAttribute = "";
            //productRequest.groupItemCode = "";
            //productRequest.itemName = "";
            //productRequest.maxPurchaseQuantity = "1";//Maximum satın alma miktarı

            SaveProductRequest saveProductRequest = new SaveProductRequest();
            saveProductRequest.auth    = authentication;
            saveProductRequest.product = productRequest;

            ProductServicePortService port = new ProductServicePortService();
            SaveProductResponse       saveProductResponse = port.SaveProduct(saveProductRequest);

            if (saveProductResponse.result.status == "success")
            {
                new EntegrasyonBilgi().N11UrunIDGuncelle(urun.urunID, saveProductResponse.product.id);
            }

            return(saveProductResponse);
        }