public override void CheckedData(SynCheckedDataInfoEntity entity, SynDataInfoEntity item)
        {
            BaiduV2ReportService serviceReport
                = new BaiduV2ReportService(item.AccountName, CryptHelper.DESDecode(item.AccountPwd), CryptHelper.DESDecode(item.Token));

            while (string.IsNullOrEmpty(entity.FilePath))
            {
                Thread.Sleep(1000);
                if (serviceReport.HasReportOnServer(item.DealWithId))
                {
                    FilePathInfo fpi = null;
                    while (fpi == null)
                    {
                        fpi = serviceReport.GetReportFileUrl(item.DealWithId);
                    }

                    if (fpi != null)
                    {
                        entity.FilePath = fpi.FilePath;
                        entity.FileName = fpi.FileName;
                        // 记录获取下载链接的时间,精确到小时
                        entity.DealWithDate = DateTime.Now;
                        // 直接下载
                        base.DownloadFileAndSynData(entity);
                        DataHelper.AppendSynCheckedDataInfo(entity);

                        DataHelper.RemoveSynDataInfo(item);
                    }
                }
            }

            serviceReport = null;
        }
Beispiel #2
0
 protected void RequestStatistics(DateTime dt, SynDataInfoEntity entity)
 {
     foreach (var key in ParamHelper.MaterialKeys)
     {
         ParamHelper.managerReport.GetReportId(key, dt, entity);
     }
 }
        public override void CheckedData(SynCheckedDataInfoEntity entity, SynDataInfoEntity item)
        {
            BaiduV2AccountService serviceAccount
                 = new BaiduV2AccountService(item.AccountName, CryptHelper.DESDecode(item.AccountPwd), CryptHelper.DESDecode(item.Token));

            while (string.IsNullOrEmpty(entity.FilePath))
            {
                Thread.Sleep(1000);
                if (serviceAccount.HasFileOnServer(item.DealWithId))
                {
                    List<FilePathInfo> alls = new List<FilePathInfo>();
                    while (!alls.Any())
                    {
                        alls = serviceAccount.GetAllObjectsPath(item.DealWithId);
                    }

                    if (alls.Any())
                    {
                        foreach (var url in alls)
                        {
                            entity.FilePath = url.FilePath;
                            entity.FileName = url.FileName;
                            // 记录获取下载链接的时间,精确到小时
                            entity.DealWithDate = DateTime.Now;
                            // 直接下载
                            base.DownloadFileAndSynData(entity);
                            DataHelper.AppendSynCheckedDataInfo(entity);
                        }
                        DataHelper.RemoveSynDataInfo(item);
                    }
                }
            }

            serviceAccount = null;
        }
 public void GetDealWithId(DateTime dt, SynDataInfoEntity entity)
 {
     if (manager.ContainsKey(entity.DealWithType ?? 0))
     {
         manager[entity.DealWithType ?? 0].GetDealWithId(dt, entity);
     }
 }
 public void CheckedData(SynCheckedDataInfoEntity entity, SynDataInfoEntity model)
 {
     if (manager.ContainsKey(model.DealWithType ?? 0))
     {
         manager[model.DealWithType ?? 0].CheckedData(entity, model);
     }
 }
Beispiel #6
0
 public void GetReportId(string key, DateTime dt, SynDataInfoEntity entity)
 {
     if (manager.ContainsKey(key))
     {
         manager[key].GetReportId(dt, entity);
     }
 }
 protected override void RequestReport(DateTime dt, SynDataInfoEntity entity)
 {
     // 同时请求统计数据,默认从2013-1-1开始
     DateTime dtGlobal = Properties.Settings.Default.GlobalDate;
     TimeSpan ts2 = dt - dtGlobal;
     for (int i = 0; i < ts2.TotalDays; i++)
     {
         DateTime paramTime = dtGlobal.AddDays(i);
         base.RequestStatistics(dt, entity);
     }
 }
        // 请求服务器生成数据文件
        public override void GetDealWithId()
        {
            LogHelper.AddLog("开始发送处理请求", "GetDealWithId");

            try
            {
                // 取得所有账号
                var accounts = ParamHelper.wcfAccount.FindAll().ToList();
                // 此处请求生成文件
                foreach (var item in accounts)
                {
                    try
                    {
                        SynDataInfoEntity entity = new SynDataInfoEntity()
                        {
                            AccountName = item.AccountName,
                            AccountPwd  = item.AccountPwd,
                            Token       = item.Token,
                        };

                        DateTime dt        = DateTime.Now;
                        var      campaigns = ParamHelper.wcfCampaign.FindByExpression(x => x.AccountName == item.AccountName).Count();
                        if (campaigns < 1)
                        {
                            entity.DealWithType = 1;
                            dt = ParamHelper.Current;
                        }
                        else
                        {
                            entity.DealWithType = 2;
                            dt = ParamHelper.PreviousDate;
                        }
                        entity.DealWithDate = dt;
                        entity.DataType     = 1;

                        ParamHelper.managerDealWith.GetDealWithId(dt, entity);
                        entity = null;
                    }
                    catch (Exception ex)
                    {
                        LogHelper.AddLog(ex.Message, item.AccountName, "GetFileId");
                        continue;
                    }
                }
                LogHelper.AddLog(string.Format("发送请求结束,共获得{0}个处理ID", ParamHelper.SynDataMax), "GetFileId");
                // 设置上一次同步的时间
                SettingsHelper.SetPreviousDate(ParamHelper.Current);
            }
            catch (Exception ex)
            {
                LogHelper.AddLog(ex.Message, "GetFileId");
            }
        }
Beispiel #9
0
        public static void AppendSynDataInfo(SynDataInfoEntity entity)
        {
            ParamHelper.wcfSynData.Add(entity);
            // 新建一个对象,避免操作同一个对象引起的ID问题
            SynDataInfoEntity model = new SynDataInfoEntity();

            model.ID           = entity.ID;
            model.AccountName  = entity.AccountName;
            model.AccountPwd   = entity.AccountPwd;
            model.Token        = entity.Token;
            model.DataTag      = entity.DataTag;
            model.DataType     = entity.DataType;
            model.DealWithDate = entity.DealWithDate;
            model.DealWithId   = entity.DealWithId;
            model.DealWithType = entity.DealWithType;

            DataHelper.AppendData(model, ParamHelper.SynDatas);
            ParamHelper.SynDataMax++;
        }
Beispiel #10
0
        /// <summary>
        /// 请求处理编号
        /// </summary>
        public void GetDealWithId(DateTime dt, SynDataInfoEntity entity)
        {
            BaiduV2AccountService serviceAccount
                = new BaiduV2AccountService(entity.AccountName, CryptHelper.DESDecode(entity.AccountPwd), CryptHelper.DESDecode(entity.Token));
            string dealId = string.Empty;

            // 轮询接口,直到有ID返回
            while (string.IsNullOrEmpty(dealId))
            {
                dealId = RequestDealWithId(serviceAccount, dt);
                Thread.Sleep(500);
            }

            if (string.IsNullOrEmpty(dealId) == false)
            {
                entity.DealWithId = dealId;
                DataHelper.AppendSynDataInfo(entity);

                RequestReport(dt, entity);
            }
        }
Beispiel #11
0
        public void GetReportId(DateTime dt, SynDataInfoEntity entity)
        {
            BaiduV2ReportService baiduReportService
                = new BaiduV2ReportService(entity.AccountName, CryptHelper.DESDecode(entity.AccountPwd), CryptHelper.DESDecode(entity.Token));

            string dealId = string.Empty;

            while (string.IsNullOrEmpty(dealId))
            {
                dealId = RequestId(baiduReportService, dt);
                Thread.Sleep(500);
            }

            if (string.IsNullOrEmpty(dealId) == false)
            {
                entity.DealWithDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
                entity.DealWithType = 3;
                entity.DataType     = 2;
                entity.DealWithId   = dealId;
                entity.DataTag      = GetDataTag();
                DataHelper.AppendSynDataInfo(entity);
            }
        }
Beispiel #12
0
 public static void RemoveSynDataInfo(SynDataInfoEntity entity)
 {
     DataHelper.RemoveData(entity, ParamHelper.SynDatas);
     ParamHelper.wcfSynData.Delete(entity);
     ParamHelper.SynDataMax--;
 }
Beispiel #13
0
 public virtual void CheckedData(SynCheckedDataInfoEntity entity, SynDataInfoEntity item)
 {
 }
Beispiel #14
0
 /// <summary>
 /// 请求统计数据
 /// </summary>
 protected virtual void RequestReport(DateTime dt, SynDataInfoEntity entity)
 {
 }
Beispiel #15
0
 protected override void RequestReport(DateTime dt, SynDataInfoEntity entity)
 {
     // 同时请求统计数据,只取昨天的
     base.RequestStatistics(dt, entity);
 }