public ServiceEBay(User user, bool backEndObject) { InitVariables(); _user = user; _backEndObject = backEndObject; }
public static void SendContactEmail(User user, string emailTitle, string emailBody) { bool highP = false; if (user.HasOptions()) highP = true; Mail email = new Mail(user.UserName, user.UserEmailAddress, "Admin", GeneralSettings.Default.ContactEmailAddress, emailTitle, emailBody, true, highP); email.Send(); }
public void GetItemDetailsTest() { 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 bool backEndObject = false; // TODO: Initialize to an appropriate value long itemID = 110048891589; // TODO: Initialize to an appropriate value eBayItemData expected = new eBayItemData(); // TODO: Initialize to an appropriate value eBayItemData actual; actual = target.GetItemDetails(itemID); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public User UserCreate(User user) { Initialisation(); return userHandler.UserCreate(user); }
/// <summary> /// Use this function to update a user. /// You need to have signed in first - with the same user /// </summary> /// <param name="user">User with data to be updated</param> public void UserSave(User user) { if (!this._isUserLoggedIn) throw new ControlObjectException(EnumSeverity.Error, EnumMessageCode.UserNotLoggedIn); if (this._userLoggedIn.UserID != user.UserID) throw new ControlObjectException(EnumSeverity.Bug, EnumMessageCode.UserIDsMismatching); this._myDataConnection.Save<User>((object)user, user); }
/// <summary> /// Reload user data from the DB /// </summary> public void UserRefreshInfo() { if (!this._isUserLoggedIn) throw new ControlObjectException(EnumSeverity.Bug, EnumMessageCode.UserNotLoggedIn); Query q = new Query(); Criterion c = new Criterion(); c.Operator = CriteriaOperator.Equal; c.PropertyName = "UserID"; c.Value = this._userLoggedIn.UserID; q.Criteria.Add(c); q.Members.Add("*"); IList<User> users = this._myDataConnection.GetByCriteria<User>(q); if (users.Count == 1) { double hoursDiffStdTime = this._userLoggedIn.HoursDiffStdTime; this._userLoggedIn = users[0]; this._userLoggedIn.HoursDiffStdTime = hoursDiffStdTime; } else throw new ControlObjectException(EnumSeverity.Warning, EnumMessageCode.UserCouldNotBeLoaded); }
/// <summary> /// Log the current user out /// </summary> public void UserLogOut() { this._isUserLoggedIn = false; this._userLoggedIn = null; }
/// <summary> /// Use this function to log in /// </summary> /// <param name="userName">User name</param> /// <param name="userPassword">Password</param> public void UserLogin(string userName, string userPassword, bool mobile, double hoursDiffStdTime) { Query q = new Query(); Criterion c = new Criterion(); c.Operator = CriteriaOperator.Equal; c.PropertyName = "UserName"; c.Value = "'" + userName + "'"; q.Criteria.Add(c); c = new Criterion(); c.Operator = CriteriaOperator.Equal; c.PropertyName = "UserPassword"; c.Value = "'" + userPassword + "'"; q.Criteria.Add(c); c = new Criterion(); c.Operator = CriteriaOperator.Equal; c.PropertyName = "UserActive"; c.Value = "1"; q.Criteria.Add(c); q.Members.Add("*"); IList<User> users = this._myDataConnection.GetByCriteria<User>(q); if (users.Count == 1) { if (mobile && !users[0].HasOptions() && UltimateSniper_ServiceLayer.UserSettings.Default.isMobileInOptionPackage) throw new ControlObjectException(EnumSeverity.Warning, EnumMessageCode.UserMobileAccessDenied); this._isUserLoggedIn = true; this._userLoggedIn = users[0]; this._userLoggedIn.HoursDiffStdTime = hoursDiffStdTime; Random random = new Random(); int num = random.Next(); this.subscriptionRandomHex = num.ToString("X"); this.isMobile = mobile; // We assign the user for the token!! this._serviceEBay.User = this._userLoggedIn; //Thread myThread = new Thread(new ThreadStart(UpdateSnipeValidity)); //myThread.Start(); } else throw new ControlObjectException(EnumSeverity.Warning, EnumMessageCode.UserPasswordAndLoginNotMatching); }
/// <summary> /// Create the user passed as parameter in the DB /// </summary> /// <param name="user">User to be created</param> /// <returns></returns> public User UserCreate(User user) { user.UserRegistrationDate = ServiceTimeZone.DateTimeToUniversal(DateTime.Now); user.UserOptionsEndDate = user.UserRegistrationDate.AddMonths(UserSettings.Default.UserOptionsFreeNbMonths); this._serviceEBay.User = user; user = (User)this._myDataConnection.Add<User>((object)user, user); Category category = new Category(); category.CategoryName = "Cat Num1"; category.IsCategoryActive = true; category.UserID = user.UserID; this._myDataConnection.Add<Category>((object)category, category); category = new Category(); category.CategoryName = "Cat Num2"; category.IsCategoryActive = true; category.UserID = user.UserID; this._myDataConnection.Add<Category>((object)category, category); category = new Category(); category.CategoryName = "Cat Num3"; category.IsCategoryActive = true; category.UserID = user.UserID; this._myDataConnection.Add<Category>((object)category, category); ServiceEmail.SendEmail(user, "[SnipeAgent] Welcome", "Hello, thanks for registering on www.snipeagent.com."); this._userLoggedIn = user; this._isUserLoggedIn = true; return user; }
/// <summary> /// Get the eBay URL from where the user need to sign in /// </summary> /// <returns></returns> public string GetSignInURL() { if (this._isUserLoggedIn) { if (!this.UserLoggedIn.HasValidAssignedEBayAccount()) { User user = new User(); user.EBayUserToken = _serviceOther.DefaultToken(); user.EBayUserTokenExpirationDate = _serviceOther.DefaultTokenExpirationDate(); _serviceEBay.User = user; } return _serviceEBay.BuildTokenURL(); } else throw new ControlObjectException(EnumSeverity.Information, EnumMessageCode.UserNotLoggedIn); }
/// <summary> /// Return official ebay time /// </summary> /// <returns></returns> public DateTime GeteBayOfficialTime() { if (_serviceEBay.User == null) { User user = new User(); user.EBayUserToken = _serviceOther.DefaultToken(); user.EBayUserTokenExpirationDate = _serviceOther.DefaultTokenExpirationDate(); _serviceEBay.User = user; } return ServiceTimeZone.DateTimeToUniversal(this._serviceEBay.GeteBayOfficialTime()); }
private void UpdateView(User user) { _view.UserID = user.UserID.ToString(); _view.eBayRegistrationSiteID = user.EBayRegistrationSiteID; _view.UserDisactivationDate = user.UserDisactivationDate.ToString(); _view.UserEmailAddress = user.UserEmailAddress; _view.UserName = user.UserName; _view.UserPassword = user.UserPassword; _view.UserEbayUserID = user.EBayUserID; _view.UserEbayUserPwd = user.EBayUserPwd; _view.UserRegistrationDate = this._view.serviceUser.DisplayDateTime(user.UserRegistrationDate, this._view.CurrentCulture); _view.UserCurrency = user.UserCurrency; _view.UserOptionPackEndDate = this._view.serviceUser.DisplayDateTime(user.UserOptionsEndDate, this._view.CurrentCulture); if (user.HasValidAssignedEBayAccount()) { _view.eBayUserIDSet = true; _view.EBayUserTokenExpirationDate = this._view.serviceUser.DisplayDateTime(user.EBayUserTokenExpirationDate, this._view.CurrentCulture); } else { _view.eBayUserIDSet = false; _view.EBayUserTokenExpirationDate = String.Empty; } _view.GetToken = true; }
public void SaveUser() { User user; try { if (this._view.serviceUser.IsUserLoggedIn) user = this._view.serviceUser.UserLoggedIn; else user = new User(); user.EBayRegistrationSiteID = this._view.eBayRegistrationSiteID; user.UserCredit = 0; user.UserEmailAddress = this._view.UserEmailAddress; user.UserName = this._view.UserName; user.UserPassword = this._view.UserPassword; user.UserCurrency = this._view.UserCurrency; user.UserIPAddress = this._view.UserIPAddress; //user.EBayUserPwd = this._view.UserEbayUserPwd; //user.EBayUserID = this._view.UserEbayUserID; if (this._view.serviceUser.IsUserLoggedIn) { this._view.serviceUser.UserSave(user); this._view.AddInformation("UserUpdated", true, EnumSeverity.Information); } else { this._view.serviceUser.UserCreate(user); this._navigation.ReloadPage("reg=ok"); } } catch (ControlObjectException ex) { if (this._view.serviceUser.IsUserLoggedIn) this._view.serviceUser.UserRefreshInfo(); foreach (UserMessage error in ex.ErrorList) this._view.AddInformation(error.MessageCode.ToString(), true, error.Severity); } catch (Exception ex) { if (this._view.serviceUser.IsUserLoggedIn) this._view.serviceUser.UserRefreshInfo(); this._view.AddInformation(ex.Message, false, EnumSeverity.Bug); } }
public static void SendEmail(User user, string emailTitle, string emailBody) { Mail email = new Mail("Snipe Agent", GeneralSettings.Default.ContactEmailAddress, user.UserName, user.UserEmailAddress, emailTitle, emailBody, true, false); email.Send(); }
public void UserDesactivate(User user) { Initialisation(); userHandler.UserDesactivate(user); }
/// <summary> /// Fetch the token from eBay and assign it to the user currently logged in /// </summary> public bool SetUserToken(TokenFetcher fetcher) { if (_serviceEBay.User == null) { User user = new User(); user.EBayUserToken = _serviceOther.DefaultToken(); user.EBayUserTokenExpirationDate = _serviceOther.DefaultTokenExpirationDate(); _serviceEBay.User = user; } try { TokenData token = _serviceEBay.FetchToken(fetcher); Query q = new Query(); Criterion c = new Criterion(); c.Operator = CriteriaOperator.Equal; c.PropertyName = "UserID"; c.Value = fetcher.UserID; q.Criteria.Add(c); q.Members.Add("*"); IList<User> users = this._myDataConnection.GetByCriteria<User>(q); if (users.Count == 1) { User user = users[0]; this._userLoggedIn.EBayUserToken = token.Token; this._userLoggedIn.EBayUserTokenExpirationDate = token.ExpirationDate; this.UserSave(user); } else throw new ControlObjectException(EnumSeverity.Bug, EnumMessageCode.UserCouldNotBeLoaded); return true; } catch { return false; } }
public void UserSave(User user) { Initialisation(); userHandler.UserSave(user); }
private static DateTime GeteBayOfficialTime() { if (SL_Scheduler.CurrentEBAyTimeSet && DateTime.Now < SL_Scheduler.CurrentEBAyTimeLastUpdate.AddMinutes(2)) return DateTime.Now.AddSeconds(SL_Scheduler.DiffLocalEbayTime * -1); else { if (SL_Scheduler.eBayService.User == null) { User user = new User(); user.EBayUserToken = otherService.DefaultToken(); user.EBayUserTokenExpirationDate = otherService.DefaultTokenExpirationDate(); SL_Scheduler.eBayService.User = user; } DateTime CurrentEBAyTime = ServiceTimeZone.DateTimeToUniversal(SL_Scheduler.eBayService.GeteBayOfficialTime()); SL_Scheduler.CurrentEBAyTimeLastUpdate = DateTime.Now; SL_Scheduler.CurrentEBAyTimeSet = true; TimeSpan span = SL_Scheduler.CurrentEBAyTimeLastUpdate.Subtract(CurrentEBAyTime); SL_Scheduler.DiffLocalEbayTime = Math.Round(span.TotalSeconds,0); return CurrentEBAyTime; } }