Example #1
0
        private static void CheckObjects(object objDlPath, IZipClient zipClient)
        {
            try
            {
                Uri    objManifest     = new Uri(Path.Combine(System.Configuration.ConfigurationSettings.AppSettings["PrivateObjectsManifest"], "manifest.txt"));
                string dlPath          = objDlPath.ToString();
                string lastCheckedPath = Path.Combine(dlPath, LAST_CHECKED);

                using (WebClient mwc = new WebClient())
                {
                    string dlList = mwc.DownloadString(objManifest);
                    if (!string.IsNullOrWhiteSpace(dlList))
                    {
                        string[] objToCheck = dlList.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string toCheck in objToCheck)
                        {
                            string         txtPath    = Path.Combine(dlPath, Path.ChangeExtension(toCheck, "txt"));
                            DateAndVersion lastUpdate = new DateAndVersion(txtPath);
                            Uri            comPath    = new Uri(Path.Combine(Path.Combine(System.Configuration.ConfigurationSettings.AppSettings["PrivateObjectsManifest"], toCheck)));
                            WebRequest     request    = WebRequest.Create(comPath);
                            request.Method = "HEAD";

                            using (WebResponse wr = request.GetResponse())
                            {
                                DateTime lmDate;
                                if (DateTime.TryParse(wr.Headers[HttpResponseHeader.LastModified], out lmDate))
                                {
                                    if (lmDate > lastUpdate.StoredDate)
                                    {
                                        //download the updated component
                                        using (WebClient fd = new WebClient())
                                        {
                                            fd.DownloadProgressChanged += fd_DownloadProgressChanged;
                                            byte[] comBin = fd.DownloadData(comPath);
                                            if (comBin.Length > 0)
                                            {
                                                using (MemoryStream ms = new MemoryStream(comBin))
                                                {
                                                    zipClient.ExtractAll(ms, dlPath, true);
                                                }

                                                DateAndVersion.Write(new DateAndVersion(txtPath, lmDate, ExeVersion));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                DateAndVersion.Write(new DateAndVersion(lastCheckedPath, DateTime.Now, ExeVersion));
            }
            catch (Exception ex)
            {
            }
        }
Example #2
0
 public void Write()
 {
     DateAndVersion.Write(this);
 }