Ejemplo 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);
            }
        }
        public void Product_HappyPath_CanCRUD()
        {
            SaveProductResponse resp = null;
            var client = new JsonServiceClient(TestAppHost.BaseUri);

            var newProduct = new Product
            {
                Title       = "Happy path test product",
                Description = "Happy path test product",
                Tags        = "test",
                Price       = 1000000000000m,
                Sku         = "TEST",
                Grams       = 1,
                Barcode     = "TEST",
                Weight      = 1m,
                WeightUnit  = "kg",
                Color       = "Pink",
                Vendor      = Constants.Vendors.JlcConcept
            };

            var login = client.Post(Constants.TestAdminAuthenticate);

            client.SessionId = login.SessionId;

            Assert.DoesNotThrow(() => resp = client.Post(new SaveProduct {
                Product = newProduct
            }));
            Assert.NotNull(resp);
            Assert.NotNull(resp.Product);
            Assert.True(resp.Product.ShopifyId.HasValue);
            Assert.GreaterOrEqual(resp.Product.ShopifyId, 1);
            Assert.AreEqual(resp.Product.Title, newProduct.Title);

            Product stored = null;

            using (var db = Host.Container.Resolve <IDbConnection>())
            {
                Assert.DoesNotThrow(() => stored = db.Single(db.From <Product>()
                                                             .Where(x => x.ShopifyId == resp.Product.ShopifyId)));
            }
            Assert.NotNull(stored);
            Assert.GreaterOrEqual(stored.ShopifyId, 1);
            Assert.AreEqual(stored.ShopifyId, resp.Product.ShopifyId);
        }
Ejemplo n.º 3
0
        public ActionResult N11Yayinla(int urunID)
        {
            if (Session["kullaniciID"] == null)
            {
                return(RedirectToAction("Login"));
            }

            string mesaj = "Ürün N11'de Yayınlanmış/Güncellenmiştir...";

            N11 n11 = new N11();

            Urun urun = new Urun();

            urun.LoadFromID(urunID);
            urun.LoadEntegrasyonBilgi();

            long n11UrunID = 0;

            Int64.TryParse(urun.entegrasyonBilgi.n11UrunID.ToString(), out n11UrunID);

            if (n11UrunID == 0)
            {
                SaveProductResponse saveProductResponse = n11.SaveProduct(urun);
                if (saveProductResponse.result.status != "success")
                {
                    mesaj = saveProductResponse.result.errorMessage;
                }
            }
            else
            {
                UpdateProductBasicResponse updateProductBasicResponse = n11.UpdateProductBasic(urun);
                if (updateProductBasicResponse.result.status != "success")
                {
                    mesaj = updateProductBasicResponse.result.errorMessage;
                }
            }

            return(RedirectToAction("UrunDetay", new { id = urunID, hata = mesaj }));
        }
Ejemplo n.º 4
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;
            }
        }
        void hamisina()
        {
            var authentication = new n11ProductService.Authentication();

            authentication.appKey    = "66e296ef-ba12-4c7a-8d3f-67027f1e1962"; //api anahtarınız
            authentication.appSecret = "OiVekmVJRKC2wi0X";                     //api şifeniz


            var productImageList = new List <ProductImage>();

            var productImage = new ProductImage();

            productImage.url = "http://www.cikolatacerez.com/images/products/00/02/70/270_buyuk_zoom.jpg";

            productImage.order = "1"; //sıra;

            productImageList.Add(productImage);

            var stockItems = new List <ProductSkuRequest>();

            var sku1 = new ProductSkuRequest();

            sku1.sellerStockCode = "1"; //stokkodu;
            sku1.quantity        = "1"; //Stokmiktar;
            sku1.optionPrice     = 105; // Stok Fiyatı
            stockItems.Add(sku1);

            var categoryRequest = new CategoryRequest();

            categoryRequest.id = 1356;// Ürünü bağlayacağınız kategoriId

            ProductRequest productRequest = new ProductRequest();

            productRequest.productSellerCode = "1";
            productRequest.title             = "MEHMET ALİ HASAN";
            productRequest.subtitle          = "BUAYA AÇIKLAMA LAZIM";
            productRequest.description       = "AçıklamaWEWQE";
            productRequest.category          = categoryRequest;
            productRequest.price             = 105;     //Ürün Fiyatı
            productRequest.currencyType      = "9999";  //Döviztipi
            productRequest.images            = productImageList.ToArray();
            productRequest.approvalStatus    = "1";     // 1: Onaylanmış ürün | 0: Beklemede
            productRequest.preparingDay      = "3";     //Ürün Hazırlık Süresi;
            productRequest.stockItems        = stockItems.ToArray();
            productRequest.productCondition  = "1";     // 1 Yeni Ürün | 2 İkinci El
            productRequest.shipmentTemplate  = "AKİDE"; //Kargo Şablon adı;



            var attr = new ProductAttributeRequest();

            attr.name  = "Marka";
            attr.value = "Ahs";

            var attList = new List <ProductAttributeRequest>();

            attList.Add(attr);
            productRequest.attributes = attList.ToArray();

            var discount = new ProductDiscountRequest();

            discount.type  = "3";  //1: İndirim Tutarı Cinsinden | 2: İndirim Oranı Cinsinden | 3: İndirimli Fiyat Cinsinden
            discount.value = "80"; // % olarak indirim

            productRequest.discount = discount;

            var saveProductRequest = new SaveProductRequest();

            saveProductRequest.auth    = authentication;
            saveProductRequest.product = productRequest;
            // ProductServicePort port = new ProductServicePortService().getProductServicePortSoap11();
            var port = new n11ProductService.ProductServicePortService();
            SaveProductResponse saveProductResponse = port.SaveProduct(saveProductRequest);

            MessageBox.Show(saveProductResponse.result.errorMessage);
        }
Ejemplo n.º 6
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);
        }