public void CheckSnipeResultTest() { SL_Scheduler_Accessor target = new SL_Scheduler_Accessor(); // TODO: Initialize to an appropriate value Snipe snipe = new Snipe(); // TODO: Initialize to an appropriate value snipe.SnipeID = 52; bool expected = false; // TODO: Initialize to an appropriate value bool actual; target.CheckSnipeResult(snipe); Assert.Inconclusive("Verify the correctness of this test method."); }
public bool CheckSnipeValidity(Snipe snipe, UltimateSniper_Services.ServiceEBay eBayService) { bool res = false; SqlDataContext myDataConnection = new SqlDataContext(); User user = this.GetUserForSnipe(snipe); if (user == null) { snipe.SnipeStatus = EnumSnipeStatus.ERROR; snipe.SnipeErrorReason = "The user assocated to the snipe couldn't be loaded properly."; } else { eBayItemData item = eBayService.GetItemDetails(snipe.ItemID); if (item.ItemCurrentHighestBid > snipe.SnipeBidInFinalCurrency) { UltimateSniper_Services.ServiceEmail emailService = new UltimateSniper_Services.ServiceEmail(); snipe.SnipeStatus = EnumSnipeStatus.OVERBID; snipe.SnipeErrorReason = "The snipe bid is lower the current price."; ServiceEmail.SendEmail(user, "[SnipeAgent] Maximum bid reached for: " + snipe.SnipeName, "Hello, you snipe bid is lower the current price. You can still modify it by going on www.snipeagent.com and into the section 'My Snipes'. Kind regards, Snipe Agent."); } res = true; item.ItemCurrentHighestBidUserCurrency = this.ConvertValue(item.ItemCurrentHighestBid, item.ItemCurrencyCode.ToString(), user.UserCurrency.ToString()); snipe.ItemLastKnownPrice = item.ItemCurrentHighestBidUserCurrency; snipe.ItemEndDate = item.ItemEndDate; snipe.ItemTitle = item.ItemTitle; snipe.ItemURL = item.ItemURL; snipe.ItemSellerID = item.ItemSellerID; snipe.ItemPictureURL = item.ItemPictureURL; snipe.ItemLastUdpate = ServiceTimeZone.DateTimeToUniversal(DateTime.Now); } snipe.ValidityCheckInProgress = false; myDataConnection.Save<Snipe>((object)snipe, snipe); return res; }
public MyThreadHandle(Snipe snipe) { this._Snipe = snipe; }
public void SetSnipe(Snipe snipe) { presenter.LoadSniper(snipe); this.snipeID = snipeID.ToString(); }
public void SnipeDesactivate(Snipe snipe) { Initialisation(); userHandler.SnipeDesactivate(snipe); }
public void SnipeBid(Snipe snipe) { Initialisation(); userHandler.SnipeBid(snipe); }
/// <summary> /// Use this function to update a Snipe /// You need to be logged in - it must be your Snipe /// </summary> /// <param name="snipe">Snipe to be updated</param> public void SnipeUpdate(Snipe snipe) { if (!this._isUserLoggedIn || snipe.UserID != this._userLoggedIn.UserID) throw new ControlObjectException(EnumSeverity.Bug, EnumMessageCode.UserIDsMismatching); this.CheckSnipeItemData(snipe); snipe.SnipeBidInFinalCurrency = this.ConvertBidCurrency((double)snipe.SnipeBid, snipe.SnipeBidCurrency, snipe.SnipeBidCurrency); this._myDataConnection.Save <Snipe>((object)snipe, snipe); }
/// <summary> /// Use this function to create a new Snipe /// You need to be logged in /// </summary> /// <param name="_snipe">Snipe to be created</param> /// <returns>Snipe with the ID</returns> public Snipe SnipeCreate(Snipe snipe) { if (!this._isUserLoggedIn || snipe.UserID != this._userLoggedIn.UserID) throw new ControlObjectException(EnumSeverity.Bug, EnumMessageCode.UserIDsMismatching); this.CheckSnipeItemData(snipe); System.Random RandNum = new System.Random(); snipe.SnipeDelay = RandNum.Next(5, 15); snipe.SnipeBidInFinalCurrency = this.ConvertBidCurrency((double)snipe.SnipeBid, snipe.SnipeBidCurrency, snipe.SnipeFinalCurrency); snipe = (Snipe)this._myDataConnection.Add<Snipe>((object)snipe, snipe); return snipe; }
private List<eBayItemData> GetSimilarItems(Snipe snipe, int nbRetry) { if (this._backEndObject) this._eBayKeyHandler.NbApiCalls = this._eBayKeyHandler.NbApiCalls + 1; Logger.CreateLog("Beginning__GetSimilarItems", snipe.SnipeID.ToString(), null, EnumLogLevel.INFO); string callname = "findItemsByKeywords"; try { // Creating an object to the BestMatchService class CustomFindingService service = new CustomFindingService(callname, this.User.EBayRegistrationSiteID, this._eBayKeyHandler.GetEBayKeySet().AppID); service.Url = ServiceParametersHelper.eBayFindingUrl(); FindItemsByKeywordsRequest request = new FindItemsByKeywordsRequest(); request.keywords = snipe.ItemTitle; request.sortOrder = SortOrderType.EndTimeSoonest; request.sortOrderSpecified = true; List<ItemFilter> itemF = new List<ItemFilter>(); ItemFilter itemType = new ItemFilter(); itemType.name = ItemFilterType.ListingType; List<string> itemT = new List<string>(); itemT.Add("Auction"); itemType.value = itemT.ToArray(); itemF.Add(itemType); itemType = new ItemFilter(); itemType.name = ItemFilterType.Seller; itemT = new List<string>(); itemT.Add(snipe.ItemSellerID); itemType.value = itemT.ToArray(); itemF.Add(itemType); request.itemFilter = itemF.ToArray(); List<eBayItemData> items = new List<eBayItemData>(); FindItemsByKeywordsResponse response = service.findItemsByKeywords(request); if (response.ack == AckValue.Success) { SearchResult result = response.searchResult; if (response.searchResult.item != null) { foreach (SearchItem itemC in response.searchResult.item) { if (itemC.title == snipe.ItemTitle) items.Add(this.GetItemDetails(long.Parse(itemC.itemId))); } } } else { string error = ""; foreach (ErrorData err in response.errorMessage) error += err.message + Environment.NewLine; throw new Exception(error); } Logger.CreateLog("Ending__GetSimilarItems", snipe.SnipeID.ToString(), null, EnumLogLevel.INFO); return items; } catch (Exception ex) { if (nbRetry < ServiceParametersHelper.nbAPIRetry()) this.GetSimilarItems(snipe, nbRetry + 1); else { Logger.CreateLog("Error__GetSimilarItems", snipe.SnipeID.ToString(), ex, EnumLogLevel.ERROR); throw ex; } } throw new Exception("Unknow error when getting similar items."); }
public void SetSnipe(Snipe snipe) { this.SetSnipe(snipe, 0); }
public bool IsUserWinning(Snipe snipe) { return this.IsUserWinning(snipe, 0); }
public List<eBayItemData> GetSimilarItems(Snipe snipe) { return this.GetSimilarItems(snipe, 0); }
private void CreateFollowingSnipe(Snipe snipe) { Logger.CreateLog("Beginning__CreateFollowingSnipe", snipe.SnipeID.ToString(), null, EnumLogLevel.INFO); // We create a now following snipe if required if (snipe.SnipeGenNextSnipe && snipe.SnipeGenRemainingNb > 0) { try { List<eBayItemData> items = SL_Scheduler.eBayService.GetSimilarItems(snipe); if (items != null && items.Count > 0 && items[0].ItemID != null) { eBayItemData item = items[0]; Snipe newSnipe = snipe; newSnipe.ItemEndDate = item.ItemEndDate; newSnipe.ItemID = (long)item.ItemID; newSnipe.ItemSellerID = item.ItemSellerID; newSnipe.SnipeBid += snipe.SnipeGenIncreaseBid; snipe.SnipeBidInFinalCurrency = this.ConvertBidCurrency((double)snipe.SnipeBid, snipe.SnipeBidCurrency, snipe.SnipeFinalCurrency); newSnipe.SnipeErrorReason = String.Empty; newSnipe.SnipeExecutionDate = null; newSnipe.SnipeGenRemainingNb = newSnipe.SnipeGenRemainingNb - 1; newSnipe.SnipeID = null; newSnipe.SnipeName += " auto"; newSnipe.SnipeStatus = EnumSnipeStatus.ACTIVE; if (newSnipe.SnipeGenOriginalID == null) newSnipe.SnipeGenOriginalID = snipe.SnipeID; SL_Scheduler.myDataConnection.Add<Snipe>((object)newSnipe, newSnipe); } } catch (ControlObjectException ex) { foreach (UserMessage error in ex.ErrorList) Logger.CreateLog("Error__CreateFollowingSnipe_" + error.MessageCode.ToString() + error.Severity.ToString(), snipe.SnipeID.ToString(), ex, EnumLogLevel.ERROR); } catch (Exception ex) { Logger.CreateLog("Error__CreateFollowingSnipe", snipe.SnipeID.ToString(), ex, EnumLogLevel.ERROR); } } Logger.CreateLog("Ending__CreateFollowingSnipe", snipe.SnipeID.ToString(), null, EnumLogLevel.INFO); }
/// <summary> /// This code should be executed regularely to make sure the SNIPE is still valid. /// </summary> /// <param name="snipe">Snipe to be checked </param> /// <returns></returns> private bool CheckSnipeValidity(Snipe snipe) { Logger.CreateLog("Beginning__CheckSnipeValidity", snipe.SnipeID.ToString(), null, EnumLogLevel.INFO); bool res = false; try { res = SL_Scheduler.otherService.CheckSnipeValidity(snipe, SL_Scheduler.eBayService); } catch (ControlObjectException ex) { foreach (UserMessage error in ex.ErrorList) Logger.CreateLog("Error__CheckSnipeValidity_" + error.MessageCode.ToString() + error.Severity.ToString(), snipe.SnipeID.ToString(), ex, EnumLogLevel.ERROR); } catch (Exception ex) { Logger.CreateLog("Error__CheckSnipeValidity", snipe.SnipeID.ToString(), ex, EnumLogLevel.ERROR); } Logger.CreateLog("Ending__CheckSnipeValidity", snipe.SnipeID.ToString(), null, EnumLogLevel.INFO); return res; }
/// <summary> /// This code should be executed when the item ENDED. /// </summary> /// <param name="snipe">Snipe associated to the ENDED item</param> /// <returns></returns> private void CheckSnipeResult(Snipe snipe) { // We reload the snipe from the database... Maybe something changed! snipe = SL_Scheduler.otherService.GetSnipe((int)snipe.SnipeID); if (snipe.ResultInProgress) return; Logger.CreateLog("Beginning__CheckingSnipeResult", snipe.SnipeID.ToString(), null, EnumLogLevel.INFO); try { snipe.ResultInProgress = true; User user = SL_Scheduler.otherService.GetUserForSnipe(snipe); if (user == null) { snipe.SnipeStatus = EnumSnipeStatus.ERROR; snipe.SnipeErrorReason = "The user assocated to the snipe couldn't be loaded properly."; Logger.CreateLog("Error__CheckingSnipeResult", snipe.SnipeID.ToString(), new Exception("The user assocated to the snipe couldn't be loaded properly."), EnumLogLevel.WARN); } else { if (snipe.SnipeStatus == EnumSnipeStatus.EXECUTED || (snipe.SnipeStatus == EnumSnipeStatus.ACTIVE && snipe.SnipeStyle == EnumSnipeStyle.BidOptimizer)) { SL_Scheduler.eBayService.User = user; eBayItemData item = SL_Scheduler.eBayService.GetItemDetails(snipe.ItemID, true); item.ItemCurrentHighestBidUserCurrency = this.ConvertBidCurrency(item.ItemCurrentHighestBid, item.ItemCurrencyCode, user.UserCurrency); snipe.ItemLastKnownPrice = item.ItemCurrentHighestBidUserCurrency; if (SL_Scheduler.eBayService.UserWonTheItem(snipe.ItemID)) snipe.SnipeStatus = EnumSnipeStatus.SUCCEED; else snipe.SnipeStatus = EnumSnipeStatus.FAILED; } if (snipe.SnipeStatus == EnumSnipeStatus.FAILED || snipe.SnipeStatus == EnumSnipeStatus.OVERBID) this.CreateFollowingSnipe(snipe); if (snipe.SnipeStatus == EnumSnipeStatus.ACTIVE) snipe.SnipeStatus = EnumSnipeStatus.UNKNOW; snipe.CancelSnipesInCaseOfSuccess = true; } SL_Scheduler.myDataConnection.Save<Snipe>((object)snipe, snipe); Logger.CreateLog("SnipeSave__PlaceSnipe", snipe.SnipeID.ToString() + "_" + snipe.SnipeStatus.ToString(), null, EnumLogLevel.INFO); } catch (ControlObjectException ex) { foreach (UserMessage error in ex.ErrorList) Logger.CreateLog("Error__CheckingSnipeResult_" + error.MessageCode.ToString() + error.Severity.ToString(), snipe.SnipeID.ToString(), ex, EnumLogLevel.ERROR); } catch (Exception ex) { Logger.CreateLog("Error__CheckingSnipeResult", snipe.SnipeID.ToString(), ex, EnumLogLevel.ERROR); } Logger.CreateLog("Ending__CheckingSnipeResult", snipe.SnipeID.ToString(), null, EnumLogLevel.INFO); snipe.ResultInProgress = false; // Delete object ListSnipesToSurvey.Remove(snipe); foreach (Snipe currSnipe in ListSnipesToSurvey) { if (currSnipe.SnipeID == snipe.SnipeID) { ListSnipesToSurvey.Remove(currSnipe); break; } } // Cleaning UltimateSniper_BusinessObjects.Snipe.CheckTimeEventHandler ctHandler = new Snipe.CheckTimeEventHandler(snipe.CheckTime); this.CheckTimeEvent -= ctHandler; snipe = null; //System.GC.Collect(); }
private bool IsUserWinning(Snipe snipe, int nbRetry) { Logger.CreateLog("Beginning__IsUserWinning", snipe.ItemID.ToString(), null, EnumLogLevel.INFO); string callname = "GetMyeBayBuying"; int nbPage = 0; try { this.BuildService(callname); GetMyeBayBuyingRequestType request = new GetMyeBayBuyingRequestType(); request.Version = _version; request.BidList = new ItemListCustomizationType(); request.BidList.Include = true; request.BidList.IncludeSpecified = true; request.BidList.ListingType = ListingTypeCodeType.Chinese; request.BidList.ListingTypeSpecified = true; request.BidList.Pagination = new PaginationType(); request.BidList.Pagination.EntriesPerPage = 25; request.BidList.Pagination.EntriesPerPageSpecified = true; request.BidList.Pagination.PageNumber = 1; request.BidList.Pagination.PageNumberSpecified = true; DetailLevelCodeType level = DetailLevelCodeType.ReturnAll; List<DetailLevelCodeType> l = new List<DetailLevelCodeType>(); l.Add(level); request.DetailLevel = l.ToArray(); List<string> outputs = new List<string>(); outputs.Add("BidList.ItemArray"); outputs.Add("BidList.PaginationResult"); request.OutputSelector = outputs.ToArray(); GetMyeBayBuyingResponseType response = this.service.GetMyeBayBuying(request); if (response.Ack == AckCodeType.Success) { if (response.BidList != null) nbPage = response.BidList.PaginationResult.TotalNumberOfPages; // There must be at least 1 page if (nbPage > 0) { // We loop throw the pages for (int i = 1; i <= response.BidList.PaginationResult.TotalNumberOfPages; i++) { // Dont reload if we are on the first page if (i != 1) { request.BidList.Pagination = new PaginationType(); request.BidList.Pagination.EntriesPerPage = 25; request.BidList.Pagination.EntriesPerPageSpecified = true; request.BidList.Pagination.PageNumber = i; request.WonList.Pagination.PageNumberSpecified = true; response = service.GetMyeBayBuying(request); } foreach (ItemType items in response.BidList.ItemArray) { if (items.BiddingDetails != null && items.ItemID == snipe.ItemID.ToString()) { UltimateSniper_Services.ServiceOthers otherService = new UltimateSniper_Services.ServiceOthers(); snipe.ItemLastKnownPrice = otherService.ConvertValue(items.BiddingDetails.MaxBid.Value, items.BiddingDetails.MaxBid.currencyID.ToString(), User.UserCurrency.ToString()); if (items.BiddingDetails.QuantityWon == 1) return true; else return false; } } } } } else { 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.IsUserWinning(snipe, nbRetry + 1); else { Logger.CreateLog("Error__IsUserWinning", snipe.ItemID.ToString(), ex, EnumLogLevel.ERROR); throw ex; } } Logger.CreateLog("Ending__IsUserWinning", snipe.ItemID.ToString(), null, EnumLogLevel.INFO); return false; }
public User GetUserForSnipe(Snipe snipe) { SqlDataContext myDataConnection = new SqlDataContext(); Query q = new Query(); Criterion c = new Criterion(); c.Operator = CriteriaOperator.Equal; c.PropertyName = "UserID"; c.Value = snipe.UserID; q.Criteria.Add(c); q.Members.Add("*"); IList<User> userList = myDataConnection.GetByCriteria<User>(q); if (userList.Count != 1) return null; else return userList[0]; }
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); }
/// <summary> /// Place the bid for the snipe passed as parameter /// </summary> /// <param name="snipe"></param> public void SnipeBid(Snipe snipe) { this._serviceOther.CheckSnipeValidity(snipe, this._serviceEBay); this._serviceEBay.SetSnipe(snipe); }
public void SetSnipe(Snipe snipe) { this.ckbBoxInsertion.Checked = snipe.ForInsert; presenter.LoadSniper(snipe); this.pnlAll.Visible = true; this.snipeID = snipeID.ToString(); if (this.ckbBoxInsertion.Checked) this.btnDelete.Visible = false; if (!snipe.ForInsert) btnSave.Attributes.Add("onclick", string.Format("if(confirm('{0}')){{}}else{{return false}}", Resources.lang.UCSnipeDetails_ConfirmSave)); else btnSave.Attributes.Add("onclick", string.Format("if(confirm('{0}')){{}}else{{return false}}", Resources.lang.UCSnipeDetails_ConfirmCreation)); }
/// <summary> /// Use this function to desactivate a snipe /// You need to be logged in - it must be your Snipe /// </summary> /// <param name="snipe">Snipe to be desactivated</param> public void SnipeDesactivate(Snipe snipe) { if (!this._isUserLoggedIn) throw new ControlObjectException(EnumSeverity.Error, EnumMessageCode.UserNotLoggedIn); if (snipe.UserID != this._userLoggedIn.UserID) throw new ControlObjectException(EnumSeverity.Bug, EnumMessageCode.UserIDsMismatching); this._myDataConnection.Delete<Snipe>((object)snipe, snipe); }
public void LoadSniper(Snipe snipe) { double itemPrice; eBayItemData item; if (snipe.SnipeStatus == EnumSnipeStatus.ACTIVE) { if (snipe.ForInsert) { item = this._view.serviceUser.GetItemDetails(snipe.ItemID); itemPrice = item.ItemCurrentHighestBidUserCurrency; snipe.ItemSellerID = item.ItemSellerID; snipe.ItemEndDate = item.ItemEndDate; snipe.ItemPictureURL = item.ItemPictureURL; snipe.ItemTitle = item.ItemTitle; snipe.ItemURL = item.ItemURL; } else { #warning we never refresh the item price from the website itemPrice = snipe.ItemLastKnownPrice; //itemPrice = this._view.serviceUser.GetItemCurrentPrice(snipe.ItemID); } } else itemPrice = snipe.ItemLastKnownPrice; this._view.showSnipeStyles = this._view.serviceUser.UserLoggedIn.ShowSnipeStyles; this._view.SnipeStyle = snipe.SnipeStyle; this.ClearView(); this._view.snipeID = snipe.SnipeID.ToString(); this._view.itemEndDate = this._view.serviceUser.DisplayDateTime(snipe.ItemEndDate, this._view.CurrentCulture); this._view.itemID = snipe.ItemID.ToString(); this._view.itemURL = snipe.ItemURL; this._view.imageURL = snipe.ItemPictureURL; this._view.sellerID = snipe.ItemSellerID; this._view.currentPrice = itemPrice.ToString(); this._view.itemTitle = snipe.ItemTitle; this._view.currency = this._view.serviceUser.UserLoggedIn.UserCurrency.ToString(); this._view.snipeStatus = snipe.SnipeStatus.ToString(); if (snipe.ForInsert) this._view.isEditEnable = true; if (snipe.SnipeID != null) { this._view.snipeName = snipe.SnipeName; this._view.snipeBid = snipe.SnipeBid.ToString(); this._view.snipeID = snipe.SnipeID.ToString(); //this._view.snipeDelay = snipe.SnipeDelay.ToString(); this._view.snipeDescription = snipe.SnipeDescription; this._view.snipeGenNextSnipe = snipe.SnipeGenNextSnipe; this._view.SnipeGenIncreaseBid = snipe.SnipeGenIncreaseBid.ToString(); if (snipe.SnipeGenRemainingNb != null) this._view.SnipeGenRemainingNb = snipe.SnipeGenRemainingNb.ToString(); else this._view.SnipeGenRemainingNb = string.Empty; if (snipe.SnipeStatus != EnumSnipeStatus.ACTIVE || snipe.SnipeExecutionDate != null || snipe.ItemEndDate < this._view.serviceUser.GeteBayOfficialTime()) this._view.isEditAvailable = false; else this._view.isEditAvailable = true; List<int> categoryIDs = new List<int>(); foreach (Category category in snipe.SnipeCategories) categoryIDs.Add((int)category.CategoryID); this._view.categoriesSelectedID = categoryIDs; } }
private void CheckSnipeItemData(Snipe snipe) { if (!this._isUserLoggedIn) throw new ControlObjectException(EnumSeverity.Error, EnumMessageCode.UserNotLoggedIn); eBayItemData item = this.GetItemDetails(snipe.ItemID); snipe.ItemEndDate = item.ItemEndDate; snipe.SnipeFinalCurrency = item.ItemCurrencyCode; snipe.ItemSellerID = item.ItemSellerID; snipe.ItemURL = item.ItemURL; snipe.ItemTitle = item.ItemTitle; snipe.ItemPictureURL = item.ItemPictureURL; if (snipe.SnipeID == null && !this.isGenNextSnipeActive() && snipe.SnipeGenNextSnipe) throw new ControlObjectException(EnumSeverity.Error, EnumMessageCode.SnipeAutoRetryNotAllowed); if (snipe.SnipeGenNextSnipe && snipe.SnipeGenRemainingNb > UserSettings.Default.MaxSnipeAutoRetry) throw new ControlObjectException(EnumSeverity.Warning, EnumMessageCode.MaxSnipeAutoRetryReached); if (item.ItemEndDate < this.GeteBayOfficialTime().AddSeconds(snipe.SnipeDelay + UserSettings.Default.SnipeExecutionDelay)) throw new ControlObjectException(EnumSeverity.Warning, EnumMessageCode.ItemEndedOrDelayToShort); if (snipe.SnipeBid == null) throw new ControlObjectException(EnumSeverity.Warning, EnumMessageCode.SnipeBidNotANumber); if (item.ItemCurrentHighestBidUserCurrency > snipe.SnipeBid) throw new ControlObjectException(EnumSeverity.Warning, EnumMessageCode.SnipeBidUnderCurrentPrice); else if (snipe.SnipeStatus == EnumSnipeStatus.OVERBID) snipe.SnipeStatus = EnumSnipeStatus.ACTIVE; }
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; }
public Snipe SnipeCreate(Snipe snipe) { Initialisation(); return userHandler.SnipeCreate(snipe); }
public void GetSimilarItemsTest() { ServiceEBay target = new ServiceEBay(true); // TODO: Initialize to an appropriate value Snipe snipe = new Snipe(); List<eBayItemData> expected = null; // TODO: Initialize to an appropriate value List<eBayItemData> actual; IList<User> users = new List<User>(); SqlDataContext myDataConnection = new SqlDataContext(); Query q = new Query(); Criterion crit = new Criterion(); crit.Operator = CriteriaOperator.Equal; crit.PropertyName = "UserID"; crit.Value = "2"; q.Criteria.Add(crit); q.Members.Add("*"); users = myDataConnection.GetByCriteria<User>(q); target.User = users[0]; IList<Snipe> snipes = new List<Snipe>(); myDataConnection = new SqlDataContext(); q = new Query(); crit = new Criterion(); crit.Operator = CriteriaOperator.Equal; crit.PropertyName = "SnipeID"; crit.Value = "1"; q.Criteria.Add(crit); q.Members.Add("*"); snipes = myDataConnection.GetByCriteria<Snipe>(q); snipe = snipes[0]; actual = target.GetSimilarItems(snipe); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void SnipeUpdate(Snipe snipe) { Initialisation(); userHandler.SnipeUpdate(snipe); }
public void SetSnipeTest() { User user = new User(); user.EBayUserTokenExpirationDate = DateTime.Now.AddMonths(3); user.EBayUserToken = "AgAAAA**AQAAAA**aAAAAA**N5ewSw**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wFk4CoAJCLowidj6x9nY+seQ**UUsBAA**AAMAAA**f/Kor0HEN77MiUcmv086pizupwLl//2qkvRIrryhDXZtT62f7GO0mSLp9ufBbXEAKkaqUERJqeJqE+dmn16sWrpWr4BqLNOwlWIXsm75nAsEhtD36H9vb04cubUqvXVMHrsXnLAMIdAit2LHgrxYCZKo/BsvrbIVrn/1llC7l3/TiBHUskO51/+sEd3LSjqHj5Bzn6SLTLRvDetRPA0K2KfjhvYFh3wI0tsKnsdczx72+MzHfAHoD7snNtffmHSkiG5HuVXgSGogiT1S38ICcSevuQ89FXXypS5QaAz2a6M+xnTdNFMoayXhvNT1d/Mhh425FExSvzntyLO0Ct6j04Ct0ibzMhJwTScHW9cOyXx8mRrsnNQKjxjlL3Y0dvllqbAwdqai+M8v1A7z1zBD4jdWkDVrOH3U4jpbfwZefBhVQZRvkQ97qRdqGFX+Kz5smmnBJSnQYsIcEaIe4lSkWq+ESiU+V14q0MkwnJBY9FBuHSwio1YF9DafnnJc0j9Me5MqicYb+aO8LO/mt76DOLQfJwQCu9KOPsM/nGvaW1IKxSqQa1uMr/2zDs7iTsolLasjmlu3pWjpeKow9mnZ3P9S47UgSh2LkzV70oUCEX7uelFdeuBzJgNNX+clI7y24jUAznQ+BcVi3U67+UVPt0/BTi6ZIVRCbvI7WyLVniVa3eCSXZtsLW85HjsjsgX2SAItywulWncA9znH6OqbzMAjQMWWSBginJhIjadfmstxYGvcOPLMKTq/cMhPeAGb"; user.UserIPAddress = "82.101.25.10"; ServiceEBay target = new ServiceEBay(user, true); // TODO: Initialize to an appropriate value long itemID = 0; // TODO: Initialize to an appropriate value bool expected = false; // TODO: Initialize to an appropriate value bool actual; Snipe snipe = new Snipe(); snipe.ItemID = 110048667899; snipe.SnipeStyle = EnumSnipeStyle.Snipe; snipe.SnipeBid = 170; target.SetSnipe(snipe); Assert.Inconclusive("Verify the correctness of this test method."); }
protected void btnLoadDetails_Click(object sender, EventArgs e) { try { Snipe snipe = new Snipe(); snipe.ItemID = long.Parse(this.txtBoxItemID.Text); snipe.ForInsert = true; this.presenter.LoadSniper(snipe); this.pnlAll.Visible = true; this.pnlSnipeList.Visible = false; this.pnlItemInfo.Visible = false; } catch { this.AddInformation("WrongItemID", false, EnumSeverity.Warning); } }
/// <summary> /// This code should be executed just before the item ends /// </summary> /// <param name="snipe">Snipe to be executed</param> /// <returns></returns> public void PlaceSnipe(Snipe snipe) { if (snipe.SnipeInProgress) return; Logger.CreateLog("Beginning__PlaceSnipe", snipe.SnipeID.ToString(), null, EnumLogLevel.INFO); try { // We reload the snipe from the database... Maybe something changed! Snipe currsnipe = SL_Scheduler.otherService.GetSnipe((int)snipe.SnipeID); snipe.SnipeStatus = currsnipe.SnipeStatus; snipe.SnipeInProgress = currsnipe.SnipeInProgress; if (snipe.SnipeStatus != EnumSnipeStatus.ACTIVE || snipe.SnipeInProgress) { Logger.CreateLog("ExitForConcurency__PlaceSnipe", snipe.SnipeID.ToString(), null, EnumLogLevel.INFO); return; } snipe.SnipeInProgress = true; SL_Scheduler.myDataConnection.Save<Snipe>((object)snipe, snipe); User user = SL_Scheduler.otherService.GetUserForSnipe(snipe); if (user == null) { snipe.SnipeStatus = EnumSnipeStatus.ERROR; snipe.SnipeErrorReason = "The user assocated to the snipe couldn't be loaded properly."; Logger.CreateLog("Error__PlaceSnipe", snipe.SnipeID.ToString(), new Exception("The user assocated to the snipe couldn't be loaded properly."), EnumLogLevel.WARN); } else { SL_Scheduler.eBayService.User = user; try { SL_Scheduler.eBayService.SetSnipe(snipe); snipe.SnipeStatus = EnumSnipeStatus.EXECUTED; } catch (Exception ex) { snipe.SnipeStatus = EnumSnipeStatus.ERROR; snipe.SnipeErrorReason = ex.Message; Logger.CreateLog("Error__PlaceSnipe", snipe.SnipeID.ToString(), ex, EnumLogLevel.ERROR); } } snipe.SnipeExecutionDate = ServiceTimeZone.DateTimeToUniversal(DateTime.Now); snipe.SnipeInProgress = false; SL_Scheduler.myDataConnection.Save<Snipe>((object)snipe, snipe); Logger.CreateLog("SnipeSave__PlaceSnipe", snipe.SnipeID.ToString() + "_" + snipe.SnipeStatus.ToString(), null, EnumLogLevel.INFO); } catch (ControlObjectException ex) { foreach (UserMessage error in ex.ErrorList) Logger.CreateLog("Error__PlaceSnipe_" + error.MessageCode.ToString() + error.Severity.ToString(), snipe.SnipeID.ToString(), ex, EnumLogLevel.ERROR); } catch (Exception ex) { Logger.CreateLog("Error__PlaceSnipe", snipe.SnipeID.ToString(), ex, EnumLogLevel.ERROR); } snipe.SnipeInProgress = false; Logger.CreateLog("Ending__PlaceSnipe", snipe.SnipeID.ToString(), null, EnumLogLevel.INFO); }