public void Test() { TypeCollection collection = new TypeCollection(); // This gets compile time warning: collection.Add(typeof(int)); }
private void initializeType() { int chickenCount = context.orders.Where(e => e.type.Equals("Chicken")).Count(); int porkCount = context.orders.Where(e => e.type.Equals("Pork")).Count(); int mixedCount = context.orders.Where(e => e.type.Equals("Mixed")).Count(); TypeCollection.Clear(); TypeCollection.Add(new PieSeries { Title = Application.Current.FindResource("Pork") as string, Values = new ChartValues <ObservableValue> { new ObservableValue(porkCount) }, DataLabels = true }); TypeCollection.Add(new PieSeries { Title = Application.Current.FindResource("Chicken") as string, Values = new ChartValues <ObservableValue> { new ObservableValue(chickenCount) }, DataLabels = true }); TypeCollection.Add( new PieSeries { Title = Application.Current.FindResource("Mixed") as string, Values = new ChartValues <ObservableValue> { new ObservableValue(mixedCount) }, DataLabels = true }); }
/// <summary> /// Converts comma-separated list of exception type names into the appropriate TypeCollection ready to set into the filter. /// </summary> /// <param name="configString"></param> /// <returns></returns> public static TypeCollection ParseTriggerExceptions(string configString) { if (configString == null || configString.Length == 0) { return(null); } TypeCollection outCollection = new TypeCollection(); string[] tokens = configString.Split(SEPS); for (int i = 0; i < tokens.Length; i++) { string typename = tokens[i]; Type t = null; // Normally you must fully-qualify the name, e.g. eBay.Service.Core.Sdk.ApiException. // We allow shorthand for the 3 obvious ones. if (tokens[i].ToLower(System.Globalization.CultureInfo.InvariantCulture).Equals("apiexception")) { t = typeof(ApiException); } else if (tokens[i].ToLower(System.Globalization.CultureInfo.InvariantCulture).Equals("httpexception")) { t = typeof(HttpException); } else if (tokens[i].ToLower(System.Globalization.CultureInfo.InvariantCulture).Equals("sdkexception")) { t = typeof(SdkException); } else { t = Type.GetType(tokens[i]); } outCollection.Add(t); } return(outCollection); }
public bool Load(FileInfo file) { if (file == null) { throw (new ArgumentNullException("file")); } if (!file.Exists) { return(false); } CultureInfo savedCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); try { lock (typeof(EasyProperties)) { using (XmlTextReader reader = new XmlTextReader(file.FullName)) { TypeCollection types = new TypeCollection(); bool inTree = false; bool fBreak = false; while (reader.Read() && !fBreak) { switch (reader.NodeType) { case XmlNodeType.EndElement: if (reader.LocalName == "Types") { fBreak = true; } break; case XmlNodeType.Element: string propertyName = reader.LocalName; if (propertyName == "Types") { inTree = true; } if (inTree && propertyName == EasyPropertiesNode.XN_ELEMENT) { string typeName = reader.GetAttribute(EasyPropertiesNode.XN_AT_TYPE); types.Add(Type.GetType(typeName, true)); } break; } } base.Read(reader, types); } } return(true); } catch (Exception ex) { throw (new Exception("Error loading properties: " + ex.Message + "\nSettings have been restored to default values.", ex)); } finally { Thread.CurrentThread.CurrentCulture = savedCulture; } }
internal TypeCollection GetTypeCollection(IGenericParameterProvider genericParameterProvider) { var typeCollection = new TypeCollection(); foreach (var genericParameter in genericParameterProvider.GenericParameters) { typeCollection.Add(GetBfType(genericParameter)); typeCollection.AddRange(GetTypeCollection(genericParameter)); } return(typeCollection); }
/// <summary> /// Compiled Bindings or Bindings to Event - new way of binding appeared with C#6-2015. /// This method is binded to a Check event and we are able to save all the type of sculpture which the user selects. /// </summary> public void TypeCheckBox_OnChecked(object sender, RoutedEventArgs args) { var checkBox = (CheckBox)sender; var type = checkBox.Tag.ToString(); if (PassedSculpture.SculptureTypes.All(type1 => type1 != type)) { PassedSculpture.SculptureTypes.Add(type); TypeCollection.Add(type); } }
/// <summary> /// This method is binded to the Unchecked event of the CheckBox control. /// This method removes unchecked types of the sculpture from the collection of types related to that Sculpture. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void TypeCheckBox_OnUnchecked(object sender, RoutedEventArgs e) { var checkBox = (CheckBox)sender; var type = checkBox.Tag.ToString(); var collection = PassedSculpture.SculptureTypes.Where(type1 => type1 != type).ToList(); PassedSculpture.SculptureTypes.Clear(); TypeCollection.Clear(); collection.ForEach(type1 => PassedSculpture.SculptureTypes.Add(type1)); collection.ForEach(type1 => TypeCollection.Add(type1)); }
/// <summary> /// Fills the type table. /// </summary> private void FillTypeList() { // TODO: _types should be stored in cache, and managed there // TODO: We will need some sort of Cache Manager, that can be extended // TO Support distributed caching ItemData id = DAL.Items; id.Connection = new DatabaseHelper().Connection; DataTable dtTypes = id.GetItemTypes(); if (dtTypes != null && dtTypes.Rows.Count > 0) { foreach (DataRow row in dtTypes.Rows) { // TODO: should be using type guid _types.Add(new ItemType(Convert.ToInt32(row["ItemTypeId"]), row["Name"].ToString(), row["Description"].ToString(), row["typeSettings"].ToString(), Convert.ToInt32(row["BaseType"]))); } } }
void GetSellerListOfItems() { ApiContext oContext = new ApiContext(); int nNumberofTotalListing = 0; int nNumberofSoldListing = 0; double nTotalAmount = 0; int nAlreadyRelistedCount = 0; int nEligibleItemForRelist = 0; string szShippingType; string szError = ""; string szInsertString = ""; string[] szArray = new string[30]; string[] szItemArray = new string[30]; int nCount = 0; string szHighBidder = ""; string szSubTitle = " "; string szTitle = " "; string szDescription = " "; string szSelectString = " "; DateTime jddate = new DateTime(); string szInventoryCategory = " "; string szInventoryCamera = " "; string szInventoryLocation = " "; string szInventorySource = " "; DateTime jdInvShipDate = new DateTime(); DateTime jdListedDate = new DateTime(); double dInvPrice = 0; int nQtyAvail = 0; int nQtySold = 0; int nLotSize = 0; //dataGridView1.Rows.Clear(); Cursor.Current = Cursors.WaitCursor; System.Data.OleDb.OleDbConnection conn_newdb = new System.Data.OleDb.OleDbConnection(); conn_newdb.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" + "Data source= " + txtbx_dbpath.Text; try { conn_newdb.Open(); } catch (Exception) { szError = "Failed"; } /*the inventory header database connection*/ System.Data.OleDb.OleDbConnection conn_newdb2 = new System.Data.OleDb.OleDbConnection(); conn_newdb2.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" + "Data source= " + txtbx_InvDBPath.Text; try { conn_newdb2.Open(); } catch (Exception) { szError = "Failed"; } txtResults.Text = " "; // set the dev,app,cert information oContext.ApiCredential.ApiAccount.Developer = ConfigurationManager.AppSettings["DevID"]; oContext.ApiCredential.ApiAccount.Application = ConfigurationManager.AppSettings["AppID"]; oContext.ApiCredential.ApiAccount.Certificate = ConfigurationManager.AppSettings["CertID"]; // set the AuthToken oContext.ApiCredential.eBayToken = ConfigurationManager.AppSettings["UserToken"]; // set the base SOAP URL .. use https://api.sandbox.ebay.com/wsapi for Sandbox calls //oContext.SoapApiServerUrl = "https://api.ebay.com/wsapi"; oContext.SoapApiServerUrl = ConfigurationManager.AppSettings["ServerUrl"]; // set the Site of the Context oContext.Site = eBay.Service.Core.Soap.SiteCodeType.US; // very important, let's setup the logging ApiLogManager oLogManager = new ApiLogManager(); oLogManager.ApiLoggerList.Add(new eBay.Service.Util.FileLogger("GetSellerList459NETSDK.log", true, true, true)); oLogManager.EnableLogging = true; oContext.ApiLogManager = oLogManager; // the WSDL Version used for this SDK build oContext.Version = "459"; // set the CallRetry properties CallRetry oCallRetry = new CallRetry(); // set the delay between each retry to 1 millisecond oCallRetry.DelayTime = 1; // set the maximum number of retries oCallRetry.MaximumRetries = 3; // set the error codes on which to retry StringCollection oErrorCodes = new StringCollection(); oErrorCodes.Add("10007"); // Internal error to the application ... general error oErrorCodes.Add("2"); // unsupported verb error oErrorCodes.Add("251"); // eBay Structured Exception ... general error oCallRetry.TriggerErrorCodes = oErrorCodes; // set the exception types on which to retry TypeCollection oExceptions = new TypeCollection(); oExceptions.Add(typeof(System.Net.ProtocolViolationException)); // the "Client found response content type of 'text/plain'" exception is of type SdkException, so let's add that to the list oExceptions.Add(typeof(SdkException)); oCallRetry.TriggerExceptions = oExceptions; // set CallRetry back to ApiContext oContext.CallRetry = oCallRetry; // set the timeout to 2 minutes oContext.Timeout = 120000; GetSellerListCall oGetSellerListCall = new GetSellerListCall(oContext); // set the Version used in the call oGetSellerListCall.Version = oContext.Version; // set the Site of the call oGetSellerListCall.Site = oContext.Site; // enable the compression feature oGetSellerListCall.EnableCompression = true; // use GranularityLevel of Fine //oGetSellerListCall.GranularityLevel = GranularityLevelCodeType.Fine; oGetSellerListCall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll); // get the first page, 200 items per page PaginationType oPagination = new PaginationType(); oPagination.EntriesPerPage = 200; //oPagination.EntriesPerPageSpecified = true; oPagination.PageNumber = 1; //oPagination.PageNumberSpecified = true; oGetSellerListCall.Pagination = oPagination; oGetSellerListCall.UserID = txtbx_userid.Text; // ask for all items that are ending in the future (active items) //oGetSellerListCall.EndTimeFilter = new TimeFilter(DateTime.Now.AddDays(-3),DateTime.Now); //oGetSellerListCall.EndTimeFilter = new TimeFilter(dateTimePicker1.Value, DateTime.Now); oGetSellerListCall.EndTimeFilter = new TimeFilter(dateTimePicker1.Value, dateTimePicker2.Value); // return items that end soonest first oGetSellerListCall.Sort = 1; // see http://developer.ebay.com/DevZone/SOAP/docs/WSDL/xsd/1/element/1597.htm for Sort documentation try { ItemTypeCollection oItems = oGetSellerListCall.GetSellerList(); // output some of the data nNumberofTotalListing = 0; nNumberofSoldListing = 0; int pagenumber = 1; while (pagenumber <= oGetSellerListCall.PaginationResult.TotalNumberOfPages) { if (pagenumber > 1) { oGetSellerListCall.Pagination.PageNumber = pagenumber; //oGetSellerListCall.Execute(); oItems = oGetSellerListCall.GetSellerList(); } foreach (ItemType oItem in oItems) { if (oItem.SKU != null) { szArray = oItem.SKU.Split(' '); } else { szArray[0] = "BLANK"; } nQtySold = oItem.SellingStatus.QuantitySold; nQtyAvail = oItem.Quantity - nQtySold; nLotSize = oItem.LotSize; szItemArray = szArray[0].Split(','); szItemArray = szItemArray[0].Split('.'); if (oItem.SellingStatus.HighBidder != null) { szHighBidder = oItem.SellingStatus.HighBidder.UserID; } else { szHighBidder = " "; } if (oItem.SubTitle != null) { szSubTitle = oItem.SubTitle.Replace('\"', ' '); } else { szSubTitle = " "; } if (oItem.Title != null) { szTitle = oItem.Title.Replace('\"', ' '); } else { szTitle = " "; } //ShippingServiceOptionsTypeCollection shippingCol = new ShippingServiceOptionsTypeCollection(); //shippingCol = oItem.ShippingDetails.ShippingServiceOptions; ShippingServiceOptionsType[] opt = new ShippingServiceOptionsType[10]; if (oItem.ShippingDetails.ShippingServiceOptions.Count == 0) { szShippingType = "NOTKNOWN"; } else { opt[0] = oItem.ShippingDetails.ShippingServiceOptions[0]; if (opt[0].ShippingServiceCost == null) { szShippingType = "FREE"; } else { if (opt[0].ShippingServiceCost.Value > 0) { szShippingType = "NOT FREE"; } else { szShippingType = "FREE"; } } } nNumberofTotalListing = nNumberofTotalListing + 1; //oItem.ShippingDetails.ShippingServiceOptions. //if (oItem.ShippingDetails.ShippingServiceOptions.IndexO == ShippingTypeCodeType.Free) //if (oItem.ShippingDetails.ShippingType == ShippingTypeCodeType.Free) // szShippingType = "FREE"; if (oItem.SellingStatus.HighBidder != null) { /*if (!(chkbx_OnlyRelistOnes.Checked)) * { * dataGridView1.Rows.Add(oItem.ItemID, oItem.ListingType, oItem.Title, oItem.SubTitle, oItem.ListingDetails.StartTime.ToShortDateString(), oItem.ListingDetails.EndTime.ToShortDateString(), oItem.SellingStatus.CurrentPrice.Value, oItem.SellingStatus.HighBidder.UserID); * }*/ nNumberofSoldListing = nNumberofSoldListing + 1; nTotalAmount = nTotalAmount + Convert.ToDouble(oItem.SellingStatus.CurrentPrice.Value); } else { if (oItem.ListingDetails.RelistedItemID == null) { // dataGridView1.Rows.Add(oItem.ItemID, oItem.ListingType, oItem.Title, oItem.SubTitle, oItem.ListingDetails.StartTime.ToShortDateString(), oItem.ListingDetails.EndTime.ToShortDateString(), oItem.SellingStatus.CurrentPrice.Value, "DNS"); nEligibleItemForRelist += 1; } else { nAlreadyRelistedCount += 1; } } /**/ /*Get the data from the inventory header so that we can load this main db*/ /*************************************************************************/ szSelectString = " "; int outnumber = 0; //jdInvShipDate = new DateTime(0); if (int.TryParse(szItemArray[0].ToString(), out outnumber)) //if (int.TryParse(szItemArray[0].ToString()), out value) { szSelectString = "Select * from InventoryHeader where INVITEM = " + szItemArray[0]; OleDbCommand cmd_InvMon = new OleDbCommand(szSelectString, conn_newdb2); OleDbDataReader reader_InvMon = cmd_InvMon.ExecuteReader(); while (reader_InvMon.Read()) { if (reader_InvMon != null) { if ((reader_InvMon["INVDATE"].ToString() != null) && reader_InvMon["INVDATE"].ToString() != " " && reader_InvMon["INVDATE"].ToString() != "") { jddate = Convert.ToDateTime(reader_InvMon["INVDATE"].ToString()); } if ((reader_InvMon["INVSOLDDATE"].ToString() != null) && reader_InvMon["INVSOLDDATE"].ToString() != " " && reader_InvMon["INVSOLDDATE"].ToString() != "") { jdInvShipDate = Convert.ToDateTime(reader_InvMon["INVSOLDDATE"].ToString()); } else { jdInvShipDate = Convert.ToDateTime("01/01/1974"); } if ((reader_InvMon["INVLISTEDDATE"].ToString() != null) && reader_InvMon["INVLISTEDDATE"].ToString() != " " && reader_InvMon["INVLISTEDDATE"].ToString() != "") { jdListedDate = Convert.ToDateTime(reader_InvMon["INVLISTEDDATE"].ToString()); } szInventoryCamera = reader_InvMon["INVCAMERA"].ToString(); szInventoryCategory = reader_InvMon["INVHEADER"].ToString(); szInventoryLocation = reader_InvMon["INVLOCATION"].ToString(); szInventorySource = reader_InvMon["INVCHECKINDATE"].ToString(); dInvPrice = Convert.ToDouble(reader_InvMon["INVPRICE"].ToString()); } break; } } /*************************************************************************/ szDescription = ""; //szDescription = oItem.Description; //szDescription = szDescription.Replace("\"", "\"\""); if (CheckRecordExistence(szItemArray[0], oItem.ItemID)) { //Update szInsertString = ""; szInsertString = "Update EbayAnalysis Set " + "SoldDate = " + "\"" + oItem.ListingDetails.EndTime.AddHours(-7) + "\"," + "ListedDate = " + "\"" + oItem.ListingDetails.StartTime.AddHours(-7) + "\"," + "HighBidder = " + "\"" + szHighBidder + "\"," + "SoldPrice = " + oItem.SellingStatus.CurrentPrice.Value + "," + "Description = " + "\"" + szDescription + "\"," + "Category = " + "\"" + oItem.PrimaryCategory.CategoryID + "\"," + "CategoryDescription = " + "\"" + oItem.PrimaryCategory.CategoryName + "\"," + "ShippingType = " + "\"" + szShippingType + "\"," + "InventoryDate = " + "\"" + jddate + "\"," + "InventoryShipDate = " + "\"" + jdInvShipDate + "\"," + //"InventoryListedDate = " + "\"" + jdListedDate + "\"," + "InventoryCategory = " + "\"" + szInventoryCategory + "\"," + "InventoryCamera = " + "\"" + szInventoryCamera + "\"," + "InventoryLocation = " + "\"" + szInventoryLocation + "\"," + "InventorySource = " + "\"" + szInventorySource + "\"," + "InventoryPrice = " + dInvPrice + "," + "QtySold = " + nQtySold + "," + "QtyAvailable = " + nQtyAvail + "," + "LotSize = " + nLotSize + " Where ( CustomItemNumber = " + "\"" + szItemArray[0] + "\"" + "AND " + "EbayItemNumber = " + "\"" + oItem.ItemID + "\"" + ")"; } else { szInsertString = ""; szInsertString = "insert into EbayAnalysis (" + "CustomItemNumber," + "EbayItemNumber," + "SoldDate," + "ListedDate," + "HighBidder," + "StartingPrice," + "SoldPrice," + "NumberOfDays," + "Title," + "SubTitle," + "Description," + "Category," + "CategoryDescription," + "ShippingType," + "InventoryDate," + "InventoryShipDate," + "InventoryListedDate," + "InventoryCategory," + "InventoryCamera," + "InventoryLocation," + "InventorySource," + "InventoryPrice," + "QtySold," + "QtyAvailable," + "LotSize" + ") VALUES ( " + "\"" + szItemArray[0] + "\"," + oItem.ItemID + "," + "\"" + oItem.ListingDetails.EndTime.AddHours(-7) + "\"," + "\"" + oItem.ListingDetails.StartTime.AddHours(-7) + "\"," + "\"" + szHighBidder + "\"," + oItem.StartPrice.Value + "," + oItem.SellingStatus.CurrentPrice.Value + "," + "0" + "," + "\"" + szTitle + "\"" + "," + "\"" + szSubTitle + "\"" + "," + "\"" + szDescription + "\"," + "\"" + oItem.PrimaryCategory.CategoryID + "\"," + "\"" + oItem.PrimaryCategory.CategoryName + "\"," + "\"" + szShippingType + "\"," + "\"" + jddate + "\"," + "\"" + jdInvShipDate + "\"," + "\"" + jdListedDate + "\"," + "\"" + szInventoryCategory + "\"," + "\"" + szInventoryCamera + "\"," + "\"" + szInventoryLocation + "\"," + "\"" + szInventorySource + "\"," + dInvPrice + "," + nQtySold + "," + nQtyAvail + "," + nLotSize + ")"; } OleDbCommand cmd6 = new OleDbCommand(szInsertString, conn_newdb); cmd6.ExecuteNonQuery(); nCount++; label1.Text = nCount.ToString(); label1.Refresh(); } pagenumber += 1; } conn_newdb.Close(); conn_newdb2.Close(); //pagenumber += 1; } catch (ApiException oApiEx) { // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do txtResults.Text = oApiEx.Message; return; } catch (SdkException oSdkEx) { // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do txtResults.Text = oSdkEx.Message; return; } catch (Exception oEx) { // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do txtResults.Text = oEx.Message; return; } Cursor.Current = Cursors.Default; }
/// <summary> /// Initializes a new instance of the <see cref="TypeCatalogFile"/> class. /// </summary> /// <param name="typeCatalogFile">The type catalog file.</param> /// <param name="encoding">The encoding.</param> /// <exception cref="ArgumentException">typeCatalogFile</exception> public TypeCatalogFile(string typeCatalogFile, Encoding encoding = null) { if (string.IsNullOrWhiteSpace(typeCatalogFile)) { throw new ArgumentException($"{nameof(typeCatalogFile)} must be a non empty string"); } if (File.Exists(typeCatalogFile)) { Encoding = encoding ?? new FileInfo(typeCatalogFile).GetEncoding(); typeCatalogFile = File.ReadAllText(typeCatalogFile, Encoding); } typeCatalogFile = typeCatalogFile.TrimStart(','); using (var stringReader = new StringReader(typeCatalogFile)) { using (var csvReader = new CsvReader(stringReader, CsvConfiguration)) { string[] header = { }; if (!header.Any() && csvReader.Read() && csvReader.ReadHeader()) { header = csvReader.Context.HeaderRecord; } parameterDefinitions = header .Select(h => { var headerParts = h.Split(new [] { "##" }, 3, StringSplitOptions.None); if (!headerParts.Any() || 3 != headerParts.Length) { throw new InvalidDataException( "Type catalog's header must consists of the following 3 parts: " + "{ParameterName}##{ParameterType}##{ParameterUnits}" ); } var name = headerParts.ElementAt(0); var units = headerParts.ElementAt(1).TryGetUnitTypeFromCatalogString(out var unitType) ? unitType : UnitType.UT_Undefined; var type = units.TryGetParameterType(out var paramType) ? paramType : ParameterType.Invalid; var displayUnits = headerParts.ElementAt(2).TryGetFromCatalogString(out var displayUnitType) ? displayUnitType : DisplayUnitType.DUT_UNDEFINED; return(new ParameterDefinition { Name = name, ParameterType = type, DisplayUnitType = displayUnits }); }) .ToList(); while (csvReader.Read()) { var record = csvReader.Context.Record; var typeName = record.First(); var parameters = new List <IParameterWithValue>(record.Skip(1).Select((value, index) => new Parameter <object>( parameterDefinitions[index] as ParameterDefinition, value ))); var type = new Type(typeName, parameters); types.Add(type); } } } }
private void GetAllTypes(TypeCollection<NodeType> types) { types.Add(this); foreach (NodeType subType in this.GetChildren()) subType.GetAllTypes(types); }
public TypeCollection<NodeType> GetChildren() { TypeCollection<NodeType> children = new TypeCollection<NodeType>(this.SchemaRoot); foreach (NodeType nt in _children) children.Add(nt); return children; }
void RelistEbayItem(string szItem, double dNewStartingPrice, double dNewBuyNowPrice, string szNewCategory, string szNumberofDays, string szListingType) { txtResults.Text = " "; ApiContext oContext = new ApiContext(); // set the dev,app,cert information oContext.ApiCredential.ApiAccount.Developer = ConfigurationManager.AppSettings["DevID"]; oContext.ApiCredential.ApiAccount.Application = ConfigurationManager.AppSettings["AppID"]; oContext.ApiCredential.ApiAccount.Certificate = ConfigurationManager.AppSettings["CertID"]; // set the AuthToken oContext.ApiCredential.eBayToken = ConfigurationManager.AppSettings["UserToken"]; // set the base SOAP URL .. use https://api.sandbox.ebay.com/wsapi for Sandbox calls //oContext.SoapApiServerUrl = "https://api.ebay.com/wsapi"; oContext.SoapApiServerUrl = ConfigurationManager.AppSettings["ServerUrl"]; // set the Site of the Context oContext.Site = eBay.Service.Core.Soap.SiteCodeType.US; // very important, let's setup the logging ApiLogManager oLogManager = new ApiLogManager(); oLogManager.ApiLoggerList.Add(new eBay.Service.Util.FileLogger("GetSellerList459NETSDK.log", true, true, true)); oLogManager.EnableLogging = true; oContext.ApiLogManager = oLogManager; // the WSDL Version used for this SDK build oContext.Version = "459"; // set the CallRetry properties CallRetry oCallRetry = new CallRetry(); // set the delay between each retry to 1 millisecond oCallRetry.DelayTime = 1; // set the maximum number of retries oCallRetry.MaximumRetries = 3; // set the error codes on which to retry StringCollection oErrorCodes = new StringCollection(); oErrorCodes.Add("10007"); // Internal error to the application ... general error oErrorCodes.Add("2"); // unsupported verb error oErrorCodes.Add("251"); // eBay Structured Exception ... general error oCallRetry.TriggerErrorCodes = oErrorCodes; // set the exception types on which to retry TypeCollection oExceptions = new TypeCollection(); oExceptions.Add(typeof(System.Net.ProtocolViolationException)); // the "Client found response content type of 'text/plain'" exception is of type SdkException, so let's add that to the list oExceptions.Add(typeof(SdkException)); oCallRetry.TriggerExceptions = oExceptions; // set CallRetry back to ApiContext oContext.CallRetry = oCallRetry; // set the timeout to 2 minutes oContext.Timeout = 120000; RelistItemCall oRelistItemCall = new RelistItemCall(oContext); // set the Version used in the call oRelistItemCall.Version = oContext.Version; // set the Site of the call oRelistItemCall.Site = oContext.Site; // enable the compression feature oRelistItemCall.EnableCompression = true; ItemType item = new ItemType(); item.ItemID = szItem; item.BuyItNowPrice = new AmountType(); item.BuyItNowPrice.Value = dNewBuyNowPrice; item.StartPrice = new AmountType(); item.StartPrice.Value = dNewStartingPrice; item.StartPrice.currencyID = CurrencyCodeType.USD; item.BuyItNowPrice.currencyID = CurrencyCodeType.USD; item.ListingType = new ListingTypeCodeType(); item.ListingType = ListingTypeCodeType.Chinese; item.DispatchTimeMax = 2; item.ReturnPolicy = new ReturnPolicyType(); item.ReturnPolicy.ReturnsAcceptedOption = "ReturnsAccepted"; //item.ReturnPolicy.ReturnsWithin = "Days_3"; item.ReturnPolicy.ShippingCostPaidBy = "Buyer"; item.ReturnPolicy.ReturnsWithinOption = "Days_3"; item.ReturnPolicy.RefundOption = "Exchange"; item.ReturnPolicy.Description = "Retund policy applies to item that are sold with Guaranteed or Warranty. Refund policy does not apply to anything that is being sold AS-IS with no warranty. Please read item description carefully. If you have any questions about warranty please do not hesitate to call us at 303-521-3869 or email us"; //item.ListingDuration =szNumberofDays; //item.ListingDuration = "Days_7"; try { oRelistItemCall.RelistItem(item); } catch (ApiException oApiEx) { // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do txtResults.Text = oApiEx.Message; return; } catch (SdkException oSdkEx) { // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do txtResults.Text = oSdkEx.Message; return; } catch (Exception oEx) { // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do txtResults.Text = oEx.Message; return; } DataGridViewRow theRow = dataGridView1.Rows[dataGridView1.SelectedRows[0].Index]; theRow.DefaultCellStyle.BackColor = Color.Red; Cursor.Current = Cursors.Default; }
void GetSellerListOfItems() { ApiContext oContext = new ApiContext(); int nNumberofTotalListing = 0; int nNumberofSoldListing = 0; double nTotalAmount = 0; int nAlreadyRelistedCount = 0; int nEligibleItemForRelist = 0; string szShippingType; dataGridView1.Rows.Clear(); Cursor.Current = Cursors.WaitCursor; txtResults.Text = " "; // set the dev,app,cert information oContext.ApiCredential.ApiAccount.Developer = ConfigurationManager.AppSettings["DevID"]; oContext.ApiCredential.ApiAccount.Application = ConfigurationManager.AppSettings["AppID"]; oContext.ApiCredential.ApiAccount.Certificate = ConfigurationManager.AppSettings["CertID"]; // set the AuthToken oContext.ApiCredential.eBayToken = ConfigurationManager.AppSettings["UserToken"]; // set the base SOAP URL .. use https://api.sandbox.ebay.com/wsapi for Sandbox calls //oContext.SoapApiServerUrl = "https://api.ebay.com/wsapi"; oContext.SoapApiServerUrl = ConfigurationManager.AppSettings["ServerUrl"]; // set the Site of the Context oContext.Site = eBay.Service.Core.Soap.SiteCodeType.US; // very important, let's setup the logging ApiLogManager oLogManager = new ApiLogManager(); oLogManager.ApiLoggerList.Add(new eBay.Service.Util.FileLogger("GetSellerList459NETSDK.log", true, true, true)); oLogManager.EnableLogging = true; oContext.ApiLogManager = oLogManager; // the WSDL Version used for this SDK build oContext.Version = "459"; // set the CallRetry properties CallRetry oCallRetry = new CallRetry(); // set the delay between each retry to 1 millisecond oCallRetry.DelayTime = 1; // set the maximum number of retries oCallRetry.MaximumRetries = 3; // set the error codes on which to retry StringCollection oErrorCodes = new StringCollection(); oErrorCodes.Add("10007"); // Internal error to the application ... general error oErrorCodes.Add("2"); // unsupported verb error oErrorCodes.Add("251"); // eBay Structured Exception ... general error oCallRetry.TriggerErrorCodes = oErrorCodes; // set the exception types on which to retry TypeCollection oExceptions = new TypeCollection(); oExceptions.Add(typeof(System.Net.ProtocolViolationException)); // the "Client found response content type of 'text/plain'" exception is of type SdkException, so let's add that to the list oExceptions.Add(typeof(SdkException)); oCallRetry.TriggerExceptions = oExceptions; // set CallRetry back to ApiContext oContext.CallRetry = oCallRetry; // set the timeout to 2 minutes oContext.Timeout = 120000; GetSellerListCall oGetSellerListCall = new GetSellerListCall(oContext); // set the Version used in the call oGetSellerListCall.Version = oContext.Version; // set the Site of the call oGetSellerListCall.Site = oContext.Site; // enable the compression feature oGetSellerListCall.EnableCompression = true; // use GranularityLevel of Fine oGetSellerListCall.GranularityLevel = GranularityLevelCodeType.Fine; // get the first page, 200 items per page PaginationType oPagination = new PaginationType(); oPagination.EntriesPerPage = 200; //oPagination.EntriesPerPageSpecified = true; oPagination.PageNumber = 1; //oPagination.PageNumberSpecified = true; oGetSellerListCall.Pagination = oPagination; oGetSellerListCall.UserID = txtUserID.Text; // ask for all items that are ending in the future (active items) //oGetSellerListCall.EndTimeFilter = new TimeFilter(DateTime.Now.AddDays(-3),DateTime.Now); //oGetSellerListCall.EndTimeFilter = new TimeFilter(dateTimePicker1.Value, DateTime.Now); oGetSellerListCall.EndTimeFilter = new TimeFilter(dateTimePicker1.Value, dateTimePicker2.Value); // return items that end soonest first oGetSellerListCall.Sort = 1; // see http://developer.ebay.com/DevZone/SOAP/docs/WSDL/xsd/1/element/1597.htm for Sort documentation try { ItemTypeCollection oItems = oGetSellerListCall.GetSellerList(); // output some of the data nNumberofTotalListing = 0; nNumberofSoldListing = 0; int pagenumber = 1; while (pagenumber <= oGetSellerListCall.PaginationResult.TotalNumberOfPages) { if (pagenumber > 1) { oGetSellerListCall.Pagination.PageNumber = pagenumber; //oGetSellerListCall.Execute(); oItems = oGetSellerListCall.GetSellerList(); } foreach (ItemType oItem in oItems) { nNumberofTotalListing = nNumberofTotalListing + 1; if (oItem.ShippingDetails.ShippingType == ShippingTypeCodeType.Free) { szShippingType = "FREE"; } if (oItem.SellingStatus.HighBidder != null) { if (!(chkbx_OnlyRelistOnes.Checked)) { dataGridView1.Rows.Add(oItem.ItemID, oItem.ListingType, oItem.Title, oItem.SubTitle, oItem.ListingDetails.StartTime.ToShortDateString(), oItem.ListingDetails.EndTime.ToShortDateString(), oItem.SellingStatus.CurrentPrice.Value, oItem.SellingStatus.HighBidder.UserID); } nNumberofSoldListing = nNumberofSoldListing + 1; nTotalAmount = nTotalAmount + Convert.ToDouble(oItem.SellingStatus.CurrentPrice.Value); } else { if (oItem.ListingDetails.RelistedItemID == null) { dataGridView1.Rows.Add(oItem.ItemID, oItem.ListingType, oItem.Title, oItem.SubTitle, oItem.ListingDetails.StartTime.ToShortDateString(), oItem.ListingDetails.EndTime.ToShortDateString(), oItem.SellingStatus.CurrentPrice.Value, "DNS"); nEligibleItemForRelist += 1; } else { nAlreadyRelistedCount += 1; } } //Console.WriteLine("ItemID is " + oItem.ItemID); //Console.WriteLine("This item is of type " + oItem.ListingType.ToString()); //if (0 < oItem.SellingStatus.BidCount) //{ // The HighBidder element is valid only if there is at least 1 bid // Console.WriteLine("High Bidder is " + oItem.SellingStatus.HighBidder.UserID); //} //Console.WriteLine("Current Price is " + oItem.SellingStatus.CurrentPrice.currencyID.ToString() + " " + oItem.SellingStatus.CurrentPrice.Value.ToString()); //Console.WriteLine("End Time is " + oItem.ListingDetails.EndTime.ToLongDateString() + " " + oItem.ListingDetails.EndTime.ToLongTimeString()); //Console.WriteLine(""); // the data that is accessible through the item object // for different GranularityLevel and DetailLevel choices // can be found at the following URL: // http://developer.ebay.com/DevZone/SOAP/docs/WebHelp/GetSellerListCall-GetSellerList_Best_Practices.html } pagenumber += 1; } //pagenumber += 1; // // // //Console.WriteLine("Done"); txtbx_AmountSold.Text = nTotalAmount.ToString(); txtbx_NumberOfListing.Text = nNumberofTotalListing.ToString(); txtbx_NumberofSold.Text = nNumberofSoldListing.ToString(); txtbx_AlreadyListed.Text = nAlreadyRelistedCount.ToString(); txtbx_relistEligible.Text = nEligibleItemForRelist.ToString(); } catch (ApiException oApiEx) { // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do txtResults.Text = oApiEx.Message; return; } catch (SdkException oSdkEx) { // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do txtResults.Text = oSdkEx.Message; return; } catch (Exception oEx) { // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do txtResults.Text = oEx.Message; return; } Cursor.Current = Cursors.Default; }