Example #1
0
        protected override void OnTimedEvent(object source, ElapsedEventArgs e)
        {
            if (BaiDuMapManager.inst.RunMode == "ONLINE")
            {
                int version = 0;

                if (CacheVersionProvider.arrangedVersion == 0)
                {
                    BaiDuMapManager.inst.cp.initVersionFormWeb();
                }
                else
                {
                    try
                    {
                        version = Convert.ToInt32(BaiDuMapManager.inst.cp.getCurrentVersion());
                    }
                    catch (Exception f)
                    {
                        version = 16000;
                    }
                }

                if (version > 0)
                {
                    if (version > CacheVersionProvider.arrangedVersion)
                    {
                        long start = BaiDuMapManager.inst.ConvertDateTimeLong(DateTime.Now);
                        CacheVersionProvider.MBVersion newOne = buildVersionInfo(version, start, start + 300 * 60000);
                        BaiDuMapManager.inst.cp.RecordDownloadRecord(newOne, "BYTIME");

                        int currentVerison = CacheVersionProvider.arrangedVersion;
                        int endVerison     = version - 1;
                        while (currentVerison != endVerison + 1)
                        {
                            newOne = buildVersionInfo(currentVerison, 100, 200);
                            BaiDuMapManager.inst.cp.RecordDownloadRecord(newOne, "BYROUND");
                            currentVerison = currentVerison + 1;
                        }
                        CacheVersionProvider.arrangedVersion = version + 1;
                    }
                    else if (version == CacheVersionProvider.arrangedVersion)
                    {
                        long start = BaiDuMapManager.inst.ConvertDateTimeLong(DateTime.Now);
                        CacheVersionProvider.MBVersion newOne = buildVersionInfo(version, start, start + 300 * 60000);
                        BaiDuMapManager.inst.cp.RecordDownloadRecord(newOne, "BYTIME");
                        CacheVersionProvider.arrangedVersion = CacheVersionProvider.arrangedVersion + 1;
                    }
                    else if (version < CacheVersionProvider.arrangedVersion - 1)
                    {
                        BaiDuMapManager.inst.cp.resetVersions();
                        OnTimedEvent(null, null);
                    }
                }
            }
        }
Example #2
0
 private CacheVersionProvider.MBVersion buildVersionInfo(int version, long start, long end)
 {
     CacheVersionProvider.MBVersion result = new CacheVersionProvider.MBVersion()
     {
         version       = version,
         start         = start,
         end           = end,
         name          = "proxy-non",
         threadCount   = 0,
         status        = "",
         timeSpan      = 1,
         completeCount = 1,
         totalCount    = 1,
         receivedBytes = 1,
         wroteBytes    = 1,
         networkSpeed  = 1,
         wroteCounts   = 1
     };
     return(result);
 }