public string GetTokenJSON(int userCode) { Dictionary<string, int> localTokens = new Dictionary<string, int>(); EbayServiceBL service = new EbayServiceBL(userCode); foreach (KeyValuePair<int, string> pair in service.UserTokens) { string result = service.GetUser(pair.Value); localTokens.Add(result, pair.Key); } string tokenJSON = Common.Serialize(localTokens); return tokenJSON; }
protected void Page_Load(object sender, EventArgs e) { Dictionary<string,int> localTokens = new Dictionary<string,int>(); EbayServiceBL service = new EbayServiceBL(UserKey); foreach (KeyValuePair<int, string> pair in service.UserTokens) { string result = service.GetUser(pair.Value); localTokens.Add(result, pair.Key); } string tokenJSON = Common.Serialize(localTokens); hfTokenJSON.Value = tokenJSON; }
protected void btnConfirmAuthorization_Click(object sender, EventArgs e) { if (IsValid) { string sessionID = hfSessionID.Value; try { // fetch a new token using SessionID string token = new EbayServiceBL(UserKey).FetchToken(sessionID); if (string.IsNullOrEmpty(token) == false) { // save entry in database. DataModelEntities context = new DataModelEntities(); // check if user is creating a new account, or updating existing one UserAccount userAccount = null; if (hfSelectedEbayAccountID.Value == "0") { userAccount = new UserAccount(); userAccount.User_Code = UserKey; userAccount.Account_Code = (int)Constant.Accounts.Ebay; userAccount.Application_Name = string.Empty; userAccount.Config_Value1 = token; userAccount.Created_Date = DateTime.Now; userAccount.Is_Active = true; userAccount.User_IP = Request.UserHostAddress; context.UserAccounts.AddObject(userAccount); } else { int userAccountCode = Convert.ToInt32(hfSelectedEbayAccountID.Value); userAccount = context.UserAccounts.First(u => u.User_Account_Code == userAccountCode); userAccount.Config_Value1 = token; userAccount.Modified_Date = DateTime.Now; userAccount.User_IP = Request.UserHostAddress; } context.SaveChanges(); try { EbayServiceBL service = new EbayServiceBL((int)userAccount.User_Code); if (service.UserTokens != null) { Dictionary<string, int> localTokens = new Dictionary<string, int>(); foreach (KeyValuePair<int, string> pair in service.UserTokens) { string ebayUserName = service.GetUser(pair.Value); if (pair.Key == userAccount.User_Account_Code) { userAccount.Ebay_User_Name = ebayUserName; context.SaveChanges(); } } } ParcelBL objParcelBL = new ParcelBL(); System.Threading.Thread t = new System.Threading.Thread(() => objParcelBL.SaveEbayUserItems(UserKey)); t.Start(); } catch (Exception ex) { Logging.WriteLog(LogType.Critical, ex.ToString()); } ScriptManager.RegisterClientScriptBlock(this, GetType(), "1", "window.location.reload()", true); lblAuthError.Text = string.Empty; } else { lblAuthError.Text = "Either you have not authorized properly, or the Ebay servers are down for the moment. Please try agian in a while."; } } catch (Exception ex) { lblAuthError.Text = "Either you have not authorized properly, or the Ebay servers are down for the moment. Please try agian in a while."; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Dictionary<string, int> localTokens = new Dictionary<string, int>(); EbayServiceBL service = new EbayServiceBL(UserKey); if (service.UserTokens != null) { string userNames = ""; foreach (KeyValuePair<int, string> pair in service.UserTokens) { string result = service.GetUser(pair.Value); localTokens.Add(result, pair.Key); userNames = result + ","; } hfSeller.Value = "";//userNames.Substring(0, userNames.Length - 1); string tokenJSON = Common.Serialize(localTokens); hfTokenJSON.Value = tokenJSON; AutomatePricingSettings(); BindEBayAccount(); BindCategory(); BindSettings(); BindCountry(); } else { Response.Redirect("~/pages/shopconnect.aspx", true); } } }