コード例 #1
0
ファイル: Form1.cs プロジェクト: skywhitebai/skyAmazonClient
        private void btnLogin_Click(object sender, EventArgs e)
        {
            String userName = txtUserName.Text;
            String password = txtPassword.Text;

            if (String.IsNullOrEmpty(userName))
            {
                MessageBox.Show("用户名不能为空");
                return;
            }
            if (String.IsNullOrEmpty(password))
            {
                MessageBox.Show("密码不能为空");
                return;
            }
            //登录获取loginToken
            String macAddress = GetSystemInfo.getMacAddr_Local();
            BaseResponse <CurrentUserInfo> loginResponse = AccountService.login(userName, password);

            if (!loginResponse.isSuccessd())
            {
                MessageBox.Show(loginResponse.Message);
                return;
            }
            //获取店铺信息
            BaseResponse <Shop> getCurrentUserShopResponse = ShopService.getCurrentUserShop();

            if (!getCurrentUserShopResponse.isSuccessd())
            {
                MessageBox.Show(getCurrentUserShopResponse.Message);
                return;
            }
            //AppConstant.sellerId = getCurrentUserShopResponse.Data.SellerId;
            //AppConstant.mwsAuthToken = getCurrentUserShopResponse.Data.MwsAuthToken;
            if (String.IsNullOrEmpty(getCurrentUserShopResponse.Data.SellerId) ||
                String.IsNullOrEmpty(getCurrentUserShopResponse.Data.MwsAuthToken) ||
                String.IsNullOrEmpty(getCurrentUserShopResponse.Data.ShopMarketplaceId)
                )
            {
                MessageBox.Show("店铺信息不完整");
                return;
            }
            AppConstant.dealInfoAppend("开始同步数据");
            if (AppConstant.threadShowDealInfo != null)
            {
                AppConstant.threadShowDealInfo.Abort();
            }
            AppConstant.threadShowDealInfo = new Thread(new ThreadStart(
                                                            showDealInfo));
            AppConstant.threadShowDealInfo.Start(); //启动线程
            shop = getCurrentUserShopResponse.Data;
            if (AppConstant.threadSynOrder != null)
            {
                AppConstant.threadSynOrder.Abort();
            }
            AppConstant.threadSynOrder = new Thread(new ThreadStart(
                                                        synOrder));
            AppConstant.threadSynOrder.Start(); //启动线程
        }
コード例 #2
0
        internal static BaseResponse <Shop> getCurrentUserShop()
        {
            String macAddress = GetSystemInfo.getMacAddr_Local();
            string loginToken = AppConstant.loginToken;

            if (String.IsNullOrEmpty(macAddress))
            {
                return(BaseResponse <Shop> .failMessage("macAddress不能为空"));
            }
            if (String.IsNullOrEmpty(loginToken))
            {
                return(BaseResponse <Shop> .failMessage("loginToken不能为空"));
            }
            IDictionary <string, string> textParams = new Dictionary <string, string>();

            textParams.Add("macAddress", macAddress);
            textParams.Add("loginToken", loginToken);
            string resJson = new HttpUtils().DoPost(AppConstant.getCurrentUserShopUrl, textParams);
            BaseResponse <Shop> baseResponse = JsonNewtonsoft.FromJSON <BaseResponse <Shop> >(resJson);

            return(baseResponse);
        }