Exemplo n.º 1
0
        private string GetOnlineHash(UpdateFile f)
        {
            var FileName = f.FileName;
            var AppName  = CurrentApp.AppName;
            var Method   = "getHash";


            HttpWebRequest  req  = (HttpWebRequest)HttpWebRequest.Create(string.Format(uri, AppName, FileName, Method, f.RelativeDirectory));
            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();

            string ResponedValue = "";

            byte[] buffer = new byte[512];
            var    stream = resp.GetResponseStream();
            var    count  = stream.Read(buffer, 0, buffer.Length);

            while (count > 0)
            {
                ResponedValue += System.Text.Encoding.Default.GetString(buffer, 0, count);

                count = stream.Read(buffer, 0, buffer.Length);
            }
            stream.Close();
            resp.Close();
            return(ResponedValue);
        }
Exemplo n.º 2
0
        private void DownloadFile(UpdateFile f)
        {
            SetListItem("Downloading File");
            var ftpDir = GetOnlineRootDir(f);

            if (f.DownloadFile(ftpUri + ftpDir, ftpUserName, ftpPass))
            {
                CheckZHash(f);
            }
            else
            {
                SetListItem(f.FileName + " Download Failed");
            }
        }
Exemplo n.º 3
0
        public void CheckZHash(UpdateFile f)
        {
            var    curHash = f.ZHash;
            string zhash   = GetOnlineZHash(f);

            if (zhash == f.ZHash)
            {
                if (f.ExtractFile())
                {
                    CheckFileState(f);
                }
            }
            else
            {
                DownloadFile(f);
            }
        }
Exemplo n.º 4
0
 private void CheckFileState(UpdateFile f)
 {
     SetListItem("Comparing Hashes");
     try {
         if (File.Exists(f.Directory + '\\' + f.FileName))
         {
             var onlineHash = GetOnlineHash(f);
             if (f.Hash != onlineHash)
             {
                 CheckZHash(f);
             }
             else
             {
                 SetListItem(f.FileName + " is up to Date");
             }
         }
         else
         {
             CheckZHash(f);
         }
     } catch (Exception ex) {
         Deloitte.WriteErrorLog(new DingoException(ex));
     }
 }