Beispiel #1
0
 /// <summary>
 /// 检测看有没有多点登录
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void timer_Tick(object sender, EventArgs e)
 {
     if (EnableRun)
     {
         var api    = new Api.BuyApi("CheckClientCode", "Account", new { ID = userinfo.ID, Code = userinfo.Code });
         var result = api.CreateRequestReturnBuyResult <object>();
         if (result.State != "Success")
         {
             EnableRun = false;
             frmLogin.Show();
             MessageBox.Show("检测到在有你的帐号在别的地方登陆");
         }
     }
 }
        public void UploadTaobao(string path)
        {
            var    fileInfo = new FileInfo(path);
            var    fileName = fileInfo.Name;
            string fileUrl  = null;

            try
            {
                OnStateChange?.Invoke(Enums.StateLogType.TaoBaoCouponUploadStart, $"代理{dlProxy.PhoneNumber}的{fileName}开始上传");
                Dictionary <string, string> files = new Dictionary <string, string>();
                files.Add("file", path);
                var uploadFileApi = new Api.BuyUploadApi(files);
                fileUrl = uploadFileApi.CreateRequestReturnUrls()[0];
                OnStateChange?.Invoke(Enums.StateLogType.TaoBaoCouponUploadComplated, $"代理{dlProxy.PhoneNumber}的{fileName}上传完成");
                try
                {
                    OnStateChange(Enums.StateLogType.TaoBaoCouponAddDbStart, $"代理{dlProxy.PhoneNumber}的{fileName}开始处理");
                    var api = new Api.BuyApi("Import", "Taobao", new
                    {
                        UserID = dlProxy.ID,
                        Url    = fileUrl
                    });

                    var result = api.CreateRequestReturnBuyResult <object>();
                    if (result.State == "Success")
                    {
                        OnStateChange?.Invoke(Enums.StateLogType.TaoBaoCouponAddDbComplated, $"代理{dlProxy.PhoneNumber}的{fileName}处理完成");
                    }
                    else
                    {
                        OnStateChange?.Invoke(Enums.StateLogType.TaoBaoCouponAddDbFail, $"代理{dlProxy.PhoneNumber}的{fileName}处理失败");
                    }
                }
                catch (Exception ex)
                {
                    try
                    {
                        Bll.Buy.LoopCheckCouponUserTemps(dlProxy.ID, Enums.Platform.TaoBao);
                        OnStateChange?.Invoke(Enums.StateLogType.TaoBaoCouponAddDbComplated, $"代理{dlProxy.PhoneNumber}的{fileName}处理完成");
                    }
                    catch (Exception)
                    {
                        OnStateChange?.Invoke(Enums.StateLogType.TaoBaoCouponDownloadFail, $"{fileName}处理失败");
                        SystemBase.WriteLog($"提交失败 {ex.Message}", "UploadTaobao");
                    }
                }
            }
            catch (Exception ex)
            {
                OnStateChange?.Invoke(Enums.StateLogType.TaoBaoCouponUploadFail, $"代理{dlProxy.PhoneNumber}的{fileName}上传失败");
                SystemBase.WriteLog($"上传失败 {ex.Message}", "UploadTaobao");
            }
            finally
            {
                try
                {
                    fileInfo.Delete();
                }
                catch (Exception ex)
                {
                    OnStateChange?.Invoke(Enums.StateLogType.TaoBaoCouponDeleteTemp, $"代理{dlProxy.PhoneNumber}的{fileName}缓存文件删除失败");
                }
            }
            Task task = new Task(() =>
            {
                chrome.Load(COUPON_DOWNLOAD_URL);
            });

            task.Start();
        }