public void ControlObject() { List<UserMessage> errorList = new List<UserMessage>(); if (string.IsNullOrEmpty(this._CategoryName)) errorList.Add(new UserMessage(EnumSeverity.Error, EnumMessageCode.CategoryNameEmpty)); if (errorList.Count != 0) { ControlObjectException ex = new ControlObjectException(errorList); throw ex; } }
public void ControlObject() { List<UserMessage> errorList = new List<UserMessage>(); //if (string.IsNullOrEmpty(this._eBayUserID)) errorList.Add(new UserMessage(EnumSeverity.Error, EnumMessageCode.UserEbayUserIDEmpty)); //if (string.IsNullOrEmpty(this._eBayUserPwd)) errorList.Add(new UserMessage(EnumSeverity.Error, EnumMessageCode.UserEbayUserPwdEmpty)); if (string.IsNullOrEmpty(this._UserName)) errorList.Add(new UserMessage(EnumSeverity.Error, EnumMessageCode.UserNameEmpty)); else if (this._UserName.Length < 5) errorList.Add(new UserMessage(EnumSeverity.Error, EnumMessageCode.UserNameTooSmall)); if (string.IsNullOrEmpty(this._UserPassword)) errorList.Add(new UserMessage(EnumSeverity.Error, EnumMessageCode.UserPasswordEmpty)); else if (this._UserPassword.Length < 5) errorList.Add(new UserMessage(EnumSeverity.Error, EnumMessageCode.UserPasswordTooSmall)); if (string.IsNullOrEmpty(this._UserEmailAddress)) errorList.Add(new UserMessage(EnumSeverity.Error, EnumMessageCode.UserEmailEmpty)); else if (!isValidEmail()) errorList.Add(new UserMessage(EnumSeverity.Error, EnumMessageCode.UserEmailWrongFormat)); if (string.IsNullOrEmpty(this._UserIPAddress)) errorList.Add(new UserMessage(EnumSeverity.Error, EnumMessageCode.UserIPAddressEmpty)); else if (!IsValidIP()) errorList.Add(new UserMessage(EnumSeverity.Error, EnumMessageCode.UserIPAddressWrongFormat)); if (errorList.Count != 0) { ControlObjectException ex = new ControlObjectException(errorList); throw ex; } }
public void ControlObject() { List<UserMessage> errorList = new List<UserMessage>(); if (this._ItemEndDate == null) errorList.Add(new UserMessage(EnumSeverity.Bug, EnumMessageCode.SnipeItemEndDateEmpty)); if (this._SnipeBid == null) errorList.Add(new UserMessage(EnumSeverity.Error, EnumMessageCode.SnipeBidNotANumber)); if (this._SnipeBid <= 0) errorList.Add(new UserMessage(EnumSeverity.Error, EnumMessageCode.SnipeBidInvalid)); if (this._SnipeDelay <= 0) errorList.Add(new UserMessage(EnumSeverity.Error, EnumMessageCode.SnipeDelayInvalid)); if (string.IsNullOrEmpty(this._SnipeName)) errorList.Add(new UserMessage(EnumSeverity.Error, EnumMessageCode.SnipeNameEmpty)); if (this._SnipeGenNextSnipe && this._SnipeGenRemainingNb == null) errorList.Add(new UserMessage(EnumSeverity.Error, EnumMessageCode.SnipeNbAutoRetryNotSpecified)); if (errorList.Count != 0) { ControlObjectException ex = new ControlObjectException(errorList); throw ex; } }
public bool SaveSniper() { try { Snipe snipe = null; if (string.IsNullOrEmpty(this._view.snipeID)) { snipe = new Snipe(); snipe.SnipeStatus = EnumSnipeStatus.ACTIVE; snipe.SnipeType = EnumSnipeType.ONLINE; } else snipe = this._view.serviceUser.GetSnipe(int.Parse(this._view.snipeID)); try { #warning We consider that the separator is , snipe.SnipeBid = double.Parse(this._view.snipeBid.Replace('.',',')); } catch { // Will be handled in the SL_User function } snipe.ItemID = long.Parse(this._view.itemID); if (this._view.serviceUser.UserLoggedIn.ShowSnipeStyles) snipe.SnipeStyle = this._view.SnipeStyle; else snipe.SnipeStyle = EnumSnipeStyle.Manual; snipe.SnipeCategories = this._view.serviceUser.GetCategories(this._view.categoriesSelectedID); snipe.SnipeBidCurrency = this._view.serviceUser.UserLoggedIn.UserCurrency; //snipe.SnipeDelay = int.Parse(this._view.snipeDelay); snipe.SnipeDescription = this._view.snipeDescription; snipe.SnipeName = this._view.snipeName; if (this._view.snipeGenNextSnipe && this._view.serviceUser.isGenNextSnipeActive()) { snipe.SnipeGenNextSnipe = true; try { snipe.SnipeGenIncreaseBid = int.Parse(this._view.SnipeGenIncreaseBid); } catch { UserMessage message = new UserMessage(); message.MessageCode = EnumMessageCode.SnipeWrongGenIncreaseBid; List<UserMessage> errorList = new List<UserMessage>(); errorList.Add(message); ControlObjectException ex = new ControlObjectException(errorList); throw ex; } try { snipe.SnipeGenRemainingNb = int.Parse(this._view.SnipeGenRemainingNb); } catch { UserMessage message = new UserMessage(); message.MessageCode = EnumMessageCode.SnipeWrongGenRemainingNb; List<UserMessage> errorList = new List<UserMessage>(); errorList.Add(message); ControlObjectException ex = new ControlObjectException(errorList); throw ex; } } else { snipe.SnipeGenNextSnipe = false; snipe.SnipeGenIncreaseBid = 0; snipe.SnipeGenRemainingNb = null; } snipe.UserID = (int)this._view.serviceUser.UserLoggedIn.UserID; if (string.IsNullOrEmpty(this._view.snipeID)) { this._view.serviceUser.SnipeCreate(snipe); this._view.AddInformation("SnipeCreated", true, EnumSeverity.Information); this._navigation.ReloadPage("created=1"); } else { this._view.serviceUser.SnipeUpdate(snipe); this._view.AddInformation("SnipeUpdated", true, EnumSeverity.Information); this.EditSniper(false); this.LoadSniper(snipe); } return true; } catch (ControlObjectException ex) { foreach (UserMessage error in ex.ErrorList) this._view.AddInformation(error.MessageCode.ToString(), true, error.Severity); } catch (Exception ex) { this._view.AddInformation(ex.Message + ex.StackTrace, false, EnumSeverity.Bug); } return false; }
private void SetSnipe(Snipe snipe, int nbRetry) { Logger.CreateLog("Beginning__SetSnipe", snipe.SnipeID.ToString(), null, EnumLogLevel.INFO); string callname = "PlaceOffer"; try { this.BuildService(callname); PlaceOfferRequestType request = new PlaceOfferRequestType(); request.Version = _version; request.ItemID = snipe.ItemID.ToString(); request.Offer = new OfferType(); request.Offer.Action = BidActionCodeType.Bid; request.Offer.ActionSpecified = true; request.Offer.MaxBid = new AmountType(); if (snipe.SnipeStyle == EnumSnipeStyle.Snipe || snipe.SnipeStyle == EnumSnipeStyle.Manual) { request.Offer.MaxBid.currencyID = (UltimateSniper_Services.eBayPublic.CurrencyCodeType)snipe.SnipeBidCurrency; request.Offer.MaxBid.Value = snipe.SnipeBidInFinalCurrency; } if (snipe.SnipeStyle == EnumSnipeStyle.BidOptimizer) { // Creating an object to the BestMatchService class UltimateSniper_Services.ebayShopping.Shopping shoppingService = new UltimateSniper_Services.ebayShopping.Shopping(); int siteID = 1; if (this._user != null) siteID = (int)this._user.EBayRegistrationSiteID; string requestURL = _shoppingServerUrl + "?callname=GetSingleItem&siteid=" + siteID.ToString() + "&appid=" + _eBayKeyHandler.GetEBayKeySet().AppID + "&version=" + _version + "&routing=default"; shoppingService.Url = requestURL; UltimateSniper_Services.ebayShopping.GetSingleItemRequestType itemRequest = new UltimateSniper_Services.ebayShopping.GetSingleItemRequestType(); itemRequest.ItemID = snipe.ItemID.ToString(); itemRequest.IncludeSelector = "Details"; UltimateSniper_Services.ebayShopping.GetSingleItemResponseType shoppingResponse = shoppingService.GetSingleItem(itemRequest); if (shoppingResponse.Ack == UltimateSniper_Services.ebayShopping.AckCodeType.Success) { if (shoppingResponse.Item.MinimumToBid != null && shoppingResponse.Item.ListingStatus == UltimateSniper_Services.ebayShopping.ListingStatusCodeType.Active) { if (shoppingResponse.Item.MinimumToBid.Value > snipe.SnipeBidInFinalCurrency) { List<UserMessage> errorList = new List<UserMessage>(); errorList.Add(new UserMessage(EnumSeverity.Error, EnumMessageCode.SnipeBidOptimizerMaxBidReached)); ControlObjectException ex = new ControlObjectException(errorList); throw ex; } request.Offer.MaxBid.currencyID = (UltimateSniper_Services.eBayPublic.CurrencyCodeType)shoppingResponse.Item.MinimumToBid.currencyID; request.Offer.MaxBid.Value = shoppingResponse.Item.MinimumToBid.Value; } else throw new Exception("This item isn't valid anymore."); } else { string error = ""; foreach (UltimateSniper_Services.ebayShopping.ErrorType err in shoppingResponse.Errors) error += err.LongMessage + Environment.NewLine; throw new Exception(error); } } request.Offer.Quantity = 1; request.Offer.QuantitySpecified = true; request.EndUserIP = User.UserIPAddress; PlaceOfferResponseType response = this.service.PlaceOffer(request); if (response.BotBlock != null) { this._eBayKeyHandler.GetNextEBayKeySet(); throw new Exception("BotBlock detected."); } if (response.Ack != AckCodeType.Success) { #warning implement retry if type = bidoptimizer string error = ""; foreach (ErrorType err in response.Errors) error += err.LongMessage + Environment.NewLine; throw new Exception(error); } } catch (Exception ex) { if (nbRetry < ServiceParametersHelper.nbAPIRetry()) this.SetSnipe(snipe, nbRetry + 1); else { Logger.CreateLog("Error__SetSnipe", snipe.SnipeID.ToString(), ex, EnumLogLevel.ERROR); throw ex; } } Logger.CreateLog("Ending__SetSnipe", snipe.SnipeID.ToString(), null, EnumLogLevel.INFO); }
private void BuildService(string callname) { eBayKeySet keys = this._eBayKeyHandler.GetEBayKeySet(); int siteID = 1; if (this._user != null) siteID = (int)this._user.EBayRegistrationSiteID; string requestURL = _serverUrl + "?callname=" + callname + "&siteid=" + siteID.ToString() + "&appid=" + keys.AppID + "&version=" + _version + "&routing=default"; this.service.Url = requestURL; this.service.RequesterCredentials = new CustomSecurityHeaderType(); this.service.RequesterCredentials.Credentials = new UserIdPasswordType(); this.service.RequesterCredentials.Credentials.AppId = keys.AppID; this.service.RequesterCredentials.Credentials.DevId = keys.DevID; this.service.RequesterCredentials.Credentials.AuthCert = keys.CertID; if (this._backEndObject) this._eBayKeyHandler.NbApiCalls = this._eBayKeyHandler.NbApiCalls + 1; this.service.RequesterCredentials.eBayAuthToken = _user.EBayUserToken; if (!_user.HasValidAssignedEBayAccount()) { List<UserMessage> errorList = new List<UserMessage>(); errorList.Add(new UserMessage(EnumSeverity.Error, EnumMessageCode.UserEBayAccountNotAssociated)); ControlObjectException ex = new ControlObjectException(errorList); throw ex; } }