根据给定起止时间,完成下载任务(大概类似于日历日程这种)
来源:互联网 发布:北京海量数据离职 编辑:程序博客网 时间:2024/06/06 08:40
//指定下载 for emergency, like power off//TODO: file nam e need to bue modifyvoid GridImgDownloadMgr::DesignateDownLoad( UtilsSystem::PosixTime beginTime , UtilsSystem::PosixTime endTime ){// Assign begin time and end time for missing image.if (beginTime >= endTime){return;}// Correct BETime according timezone.UtilsSystem::TimeDuration backSpan(TIME_DIFFERENCE, 0, 0);beginTime -= backSpan;endTime -= backSpan;// Independent from GridImg Appliation.Need read config.if (!m_bStart){m_pAccount = m_pConfig->Read("DownLoad", "user");m_pPassword = m_pConfig->Read("DownLoad", "passwd");m_pThreadPool = UtilsSystem::ThreadpoolPtr(new UtilsSystem::Threadpool(24));m_pThread = boost::make_shared<UtilsSystem::Thread>(boost::bind(&boost::asio::io_service::run, m_pIOService));if ( !m_httpClient.Initialize()){LOG4CXX_ERROR(m_pLogger, "HTTP client initial fail.");}GridImgActorMangerSingleton::GetMutableInstance()->SetLogger(m_pLogger);GridImgActorMangerSingleton::GetMutableInstance()->SetConfiguration(m_pConfig);GridImgActorMangerSingleton::GetMutableInstance()->Initialize();LOG4CXX_INFO(m_pLogger, "Grib image download manager start wihtout app.");}int bHour = UtilsSystem::DateTimeUtils::GetDateTimeUnit(beginTime, HOUR);int bDay = UtilsSystem::DateTimeUtils::GetDateTimeUnit(beginTime, DAY);int bMonth = UtilsSystem::DateTimeUtils::GetDateTimeUnit(beginTime, MONTH);int bYear = UtilsSystem::DateTimeUtils::GetDateTimeUnit(beginTime, YEAR);int eHour = UtilsSystem::DateTimeUtils::GetDateTimeUnit(endTime, HOUR);int eDay = UtilsSystem::DateTimeUtils::GetDateTimeUnit(endTime, DAY);int eMonth = UtilsSystem::DateTimeUtils::GetDateTimeUnit(endTime, MONTH);int eYear = UtilsSystem::DateTimeUtils::GetDateTimeUnit(endTime, YEAR);int dayList[13] = {0,31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};int y = bYear;int m = bMonth;int d = bDay;int h = bHour;bool flagY = true;bool flagM = true;bool flagD = true;bool flagH = true;//-- logicdo{flagM = true;if (y%4 == 0){dayList[2] = 29;}else{dayList[2] = 28;}do{flagD = true;do{flagH = true;do{std::string urlFrmtStr = m_pConfig->Read("Download", "download_url");boost::format frmt(urlFrmtStr);frmt %y %m %d %(h*100) %y %m %d %(h*100);std::string urlStr = str(frmt);// Save path string.std::string filePathStr = m_pConfig->Read("SaveDir","orig_dir");boost::filesystem::path filePath(filePathStr);boost::format fileFrmt(PIC_NAME_FORMAT);fileFrmt %y %m %d %(h*100);std::string fileStr;fileStr = str(fileFrmt);filePath.append(fileStr + PIC_SUFFIX);m_pThreadPool->schedule(boost::bind(&GridImgDownloadMgr::DownloadGribImg, this, urlStr, filePath.string()));if ( y==eYear&m==eMonth&d==eDay&&h>=eHour || h++>=23){flagH = false;}}while (flagH);h = 0;if ( y==eYear&m==eMonth&d==eDay || d++>=dayList[m] ){flagD = false;}}while(flagD);d = 1;if ( y==eYear&m==eMonth || m++>=12){flagM = false;}}while(flagM);m = 1;if ( y++ >= eYear ){flagY = false;}}while (flagY);//--logicreturn;}忽略了2000,2400这种不是闰年的情况,因为根本用不上。
阅读全文
0 0
- 根据给定起止时间,完成下载任务(大概类似于日历日程这种)
- 根据当前日期获取本周起止时间
- 根据当前日期获取本周起止时间
- 【转】根据起止日期+时间取数
- 按照起止时间输出和日历对应的价格列表
- C#根据当前时间获取周,月,季度,年度等时间段的起止时间
- Android 日历日程监听
- Excel 统计起止时间
- My97DatePicker起止时间设置
- 同步Android手机系统日历事件(日程)
- 根据工厂日历自动计算请假时间
- 任务开始时间和完成时间
- Android系统日历日程操作
- React Native日历日程组件
- 获取当月起止时间和获取当天起止时间
- 获取一段时间的起止时间
- 获取上个月的起止时间
- 使用python的yield实现任务调度.给定一个任务列表,每个任务轮流切换执行,类似于切片
- Java NIO Selector
- MapReduce1.0和MapReduce2.0
- EPON+EOC设备网管实现方案
- strtok 用法总结,可以快速提取带分割符号的字符串
- 1.Two Sum (c# Edition)
- 根据给定起止时间,完成下载任务(大概类似于日历日程这种)
- spring_boot整合mybatis项目启动时报错
- javascript判断是电脑还是手机,android手机还是ios
- Location 对象
- 设计18
- SpringMVC-使用converter转换器解决后台接收Date格式数据时The request sent by the client was syntactically incorrect ()
- HttpClient发送Post请求(二)
- DIRECTORY_SEPARATOR
- 统计原理笔记 Notes for Statistics I