Example #1
0
        public ActionResult Ebay(string username, string sid)
        {
            using (var repository = new TradelrRepository())
            {
                var odb = repository.GetOAuthToken(sid, OAuthTokenType.EBAY);

                if (odb == null)
                {
                    throw new Exception("Could not locate ebay token entry");
                }

                try
                {
                    var ebayservice = new EbayService();
                    var token       = ebayservice.GetToken(odb.token_key);

                    odb.token_key    = token;
                    odb.token_secret = "";
                    odb.guid         = username;
                    odb.authorised   = true;
                    odb.expires      = ebayservice.TokenExpires;
                    repository.Save();

                    // sync with ebay
                    var ebay = new NetworksEbay(odb.MASTERsubdomain.id);
                    new Thread(() => ebay.StartSynchronisation(false)).Start();
                }
                catch (Exception ex)
                {
                    Syslog.Write(ex);
                }

                return(Redirect(odb.MASTERsubdomain.ToHostName().ToDomainUrl("/dashboard/networks#ebay")));
            }
        }
Example #2
0
 public ActionResult clearToken()
 {
     try
     {
         var ebay = new NetworksEbay(subdomainid.Value);
         ebay.ClearSynchronisation();
     }
     catch (Exception ex)
     {
         Syslog.Write(ex);
         return(Json(false.ToJsonOKData()));
     }
     return(Json(true.ToJsonOKData()));
 }
Example #3
0
        public void PollForEbayOrders()
        {
            var service = new OrderService(token);

            try
            {
                // get completed orders from a month before
                var completed = service.GetOrders(OrderStatusCodeType.Completed, DateTime.Now.AddMonths(-1),
                                                  DateTime.Now);

                SaveEbayOrders(completed);

                // exclude active orders for now because buyer email is not shown

                /*
                 * // get all orders from last day
                 * var all = service.GetOrders(OrderStatusCodeType.All, DateTime.Now.AddDays(-1), DateTime.Now);
                 *
                 * SaveEbayOrders(all);
                 * */
            }
            catch (ApiException ex)
            {
                if (ex.Message.Contains("Validation of the authentication token in API request failed"))
                {
                    // delete auth token
                    var ebay = new NetworksEbay(sd.id);
                    ebay.ClearSynchronisation();
                }
            }
            catch (Exception ex)
            {
                Syslog.Write(ex);
                Syslog.Write(service.responseXML);
            }
        }