Exemple #1
0
 public void Start()
 {
     if (m_status < DownLoadTaskStatus.Start)
     {
         m_status = DownLoadTaskStatus.Start;
     }
 }
Exemple #2
0
        public void Stop()
        {
            if (m_tempFile != null)
            {
                m_tempFile.Stop();
            }

            if (m_thread != null)
            {
                m_thread.Abort();
                m_thread = null;
            }
            m_status = DownLoadTaskStatus.Finished;
        }
Exemple #3
0
        void OnFinishedCallback(bool succ)
        {
            m_succesed = succ;
            if (m_succesed)
            {
                LogUtils.Log(m_name + " download succ!");

                try
                {
                    //todo...move or decrompress
                    string desName = PathUtils.GetPersistentPath() + m_name;
                    PathUtils.MakeSureDirExist(desName);

                    if (File.Exists(desName))
                    {
                        File.Delete(desName);
                    }

                    File.Copy(m_tempFile.GetTempFileName(), desName);
                    m_tempFile.Delete();

                    //check
                    if (m_signature.Length > 0)
                    {
                        bool vaild = FileChecker.VerifyFileSignature(desName, m_signature);
                        if (vaild == false)
                        {
                            File.Delete(desName);
                            LogUtils.LogError(m_name + " VerifyFileSignature faild!");
                        }
                        m_succesed = vaild;
                    }
                }
                catch (System.Exception ex)
                {
                    m_succesed = false;
                    LogUtils.LogError(ex.ToString());
                }
            }
            else
            {
                LogUtils.LogError(m_name + " download faild!");
            }
            m_status = DownLoadTaskStatus.Finished;
        }
Exemple #4
0
 public void Update()
 {
     if (m_status == DownLoadTaskStatus.Start)
     {
         LogUtils.Log(m_name + " download begin!");
         m_status = DownLoadTaskStatus.DownLoading;
         m_thread = new Thread(OnTaskStart);
         m_thread.Start();
     }
     if (m_status == DownLoadTaskStatus.Finished)
     {
         if (!m_succesed && m_retryTimes > 0 && !m_isStop)
         {
             --m_retryTimes;
             m_status = DownLoadTaskStatus.Wait;  //try again
             return;
         }
         if (resultCb != null)
         {
             resultCb(m_name, m_succesed);
         }
         resultCb = null;
     }
 }