Artikel einstellen

Auszug aus der eXODA Library - Code zum Einstellen eines Artikels über die eBay-API


///
/// Stellt den Artikel bei eBay ein
/// 

//////
public eBayItemProperties AddItemToeBay(eBayItemProperties eXODAeBayItem)
{
eXODALib.ItemLib.Items oItems = new eXODALib.ItemLib.Items();
oItems.Initialize(exsettings);
eXODALib.ItemLib.Item oItem = new eXODALib.ItemLib.Item();

oItem = oItems.LoadItem(eXODAeBayItem.eXODAItemID);

if (eXODAeBayItem.ItemTitel.IndexOf(„#“) == -1)
if (eXODAeBayItem.ItemTitel.Length <= 75) { if (eXODAeBayItem.eXODAItemID.ToString().Length >= 3)
{
string sSQL = „Select * from Artikel where ID = “ + eXODAeBayItem.eXODAItemID + “ and Mandant ='“ + this.exSettings.eXODAClientname + „‚“;
this.exSettings.HS4Dataset.Open(HS4Software.DatabaseType.ExistingConnection, „“, sSQL, „item“, „ID“, true, false);

sSQL = „Select ID from Artikel where eBayAuktionLaufend = 1 and Lagerbestand > 0 and Matchcode = ‚OK‘ and Modell = ‚“ + this.exsettings.HS4Dataset.HSDataSet.Tables[„item“].Rows[0][„Modell“].ToString() + „‚ and Mandant = ‚“ + this.exSettings.eXODAClientname + „‚“;
this.exSettings.HS4Dataset.Open(HS4Software.DatabaseType.ExistingConnection, „“, sSQL, „check“, „ID“, true, false);

//if (this.exSettings.HS4Dataset.HSDataSet.Tables[„check“].Rows.Count == 0)
//eXODAeBayItem.ItemTitel = eXODAeBayItem.ItemTitel + “ #“ + eXODAeBayItem.eXODAItemID.ToString().Substring(eXODAeBayItem.eXODAItemID.ToString().Length – 3, 3);
}
}

if ((oItem.BundleQuantity != 0) && (oItem.BundleUnit != null))
{
double dListenpreis = Convert.ToDouble(eXODAeBayItem.BuyItNowPrice);
double dInhalt = oItem.BundleQuantity;
double dMLPreis = dListenpreis / dInhalt;
string sGebindeText;

string sGross = „“;
string sKlein = „“;
if (oItem.BundleUnit != null)
switch (oItem.BundleUnit)
{
case „g“:
case „kg“:
sGross = „kg“;
sKlein = „g“;
break;
case „l“:
case „ml“:
sGross = „l“;
sKlein = „ml“;
break;
default:
sGross = „l“;
sKlein = „ml“;
break;
}
if (dInhalt <= 250)
{
sGebindeText = „Inhalt “ + dInhalt.ToString() + oItem.BundleUnit + „: (100″ + sKlein + “ = “ + Convert.ToDecimal(dMLPreis * 100).ToString(„c“) + “ inkl. MwSt)“;
}
else
{
sGebindeText = „Inhalt “ + dInhalt.ToString() + oItem.BundleUnit + „: (1″ + sGross + “ = “ + Convert.ToDecimal(dMLPreis * 1000).ToString(„c“) + “ inkl. MwSt)“;
}
eXODAeBayItem.BundleText = sGebindeText;
}
if (oItems.Stock(eXODAeBayItem.eXODAItemID) <= 0) { eXODAeBayItem.AddItemErrorText = „Der Artikel konnte nicht eingestellt werden, weil der Lagerbestand unterschritten ist.“; return eXODAeBayItem; } //if (eXODAeBayItem.ItemSiteCodeType == null) // eXODAeBayItem.ItemSiteCodeType = SiteCodeType.Germany; string sSiteCodeType = eXODAeBayItem.ItemSiteCodeType.ToString(); string sFilename = „c:/temp/“ + exSettings.eXODAClientname + „/“ + eXODAeBayItem.eXODAItemID.ToString() + „.“ + sSiteCodeType + „.exo“; //Wenn eine Attributedatei if (System.IO.File.Exists(sFilename)) { if (cTools.TextFileRead(sFilename) != „keine Attribute\r\n“) { AttributesMaster attrMaster = this.DownloadCategories(eXODAeBayItem.Category, GeteBayApiContext(true, eXODAeBayItem.ItemSiteCodeType)); System.Collections.Specialized.NameValueCollection request; BinaryFormatter binFormatter = new BinaryFormatter(); FileStream fs = new FileStream(sFilename, FileMode.Open); request = (System.Collections.Specialized.NameValueCollection)binFormatter.Deserialize(fs); fs.Close(); IAttributeSetCollection sets = attrMaster.NameValuesToAttributeSets( AttributesHelper.ConvertFromNameValues(request)); IErrorSetCollection errList = attrMaster.Validate(sets); eXODAeBayItem.AttribSet = attrMaster.ConvertAttributeSetArray(sets); } } ItemType item = new ItemType(); item = BuildeBayItem(eXODAeBayItem); AddItemCall apicall = new AddItemCall(GeteBayApiContext(true, eXODAeBayItem.ItemSiteCodeType)); apicall.Timeout = 360000; //Bilder if (eXODAeBayItem.Pictures != null) { apicall.PictureFileList = new StringCollection(); item.PictureDetails = new PictureDetailsType(); item.PictureDetails.PhotoDisplay = PhotoDisplayCodeType.SuperSizePictureShow; //item.PictureDetails.GalleryType = GalleryTypeCodeType.Gallery; //item.PictureDetails.GalleryTypeSpecified = true; item.PictureDetails.PictureURL = new StringCollection(); int iPicCounter = 0; string sPicfilename = „“; string sPictureHost = cTools.ClientSetting(„eXODAHostname“, exSettings.eXODAClientname, exSettings.HS4Dataset).ToString(); string sPictureHTMLString = „“; foreach (string pic in eXODAeBayItem.Pictures.Split(Convert.ToChar(„;“))) { if (pic.Trim().Length > 0)
{
iPicCounter = iPicCounter + 1;
if (!System.IO.Directory.Exists(„c:/temp/“ + exSettings.eXODAClientname + „/eBayPictures“))
System.IO.Directory.CreateDirectory(„c:/temp/“ + exSettings.eXODAClientname + „/eBayPictures“);
sPicfilename = „c:/temp/“ + exSettings.eXODAClientname + „/eBayPictures/“ + eXODAeBayItem.eXODAItemID + „_“ + iPicCounter.ToString() + „.jpg“;

string sNewPictureURL = „“;
if (pic.ToLower().IndexOf(„http“) < 0)
sNewPictureURL = „http://“ + sPictureHost + „/“ + pic.Substring(pic.ToLower().IndexOf(„clients“), pic.Length – pic.ToLower().IndexOf(„clients“));
else
sNewPictureURL = pic;
if (item.PictureDetails.PictureURL.Count < 1) { item.PictureDetails.PictureURL.Add(sNewPictureURL); item.PictureDetails.GalleryType = GalleryTypeCodeType.Gallery; item.PictureDetails.GalleryTypeSpecified = true; item.PictureDetails.GalleryURL = sNewPictureURL; } //Nur ab dem zweiten Bild hinzufügen if (iPicCounter > 1)
sPictureHTMLString = sPictureHTMLString + “

„;

}
}

if (sPictureHTMLString.Length > 0)
sPictureHTMLString = “

“ + sPictureHTMLString + „

„;

if (item.Description.IndexOf(„#BILDER#“) > 0)
{
item.Description = item.Description.Replace(„#BILDER#“, sPictureHTMLString);
}

}

//Bilder Ende
apicall.Timeout = 360000;
FeeTypeCollection fees = apicall.AddItem(item);

foreach (FeeType fee in fees)
{
if (fee.Name == „ListingFee“)
{
eXODAeBayItem.ListingFee = fee.Fee.Value;
break;
}
}

eXODAeBayItem.eBayID = item.ItemID;
return eXODAeBayItem;
}

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.