Esempio n. 1
0
        private List <string> CheckUploadFiles()
        {
            List <string> list = null;

            Dispatcher.Invoke(new Action(() => list = new List <string>(ListboxFiles.Items.Cast <string>())));

            try
            {
                string value;
                using (WebClient webClient = new WebClient()
                {
                    Encoding = Encoding.UTF8
                })
                    value = webClient.DownloadString(Path.Combine(configuration.publicUrl, ".updatemachine", "index").Replace('\\', '/'));

                Updater.FileIndex index = JsonConvert.DeserializeObject <Updater.FileIndex>(value);

                foreach (Updater.FileItem f in index.Files)
                {
                    string s = Path.Combine(root, f.Name);
                    if (File.Exists(s) && f.SHA1 == Updater.GetFileSHA1(s))
                    {
                        list.Remove(f.Name);
                    }
                }
            }
            catch { }

            return(list);
        }
Esempio n. 2
0
        private string BuildIndex()
        {
            List <string> list = null;

            Dispatcher.Invoke(new Action(() => list = new List <string>(ListboxFiles.Items.Cast <string>())));

            List <Updater.FileItem> fileItems = new List <Updater.FileItem>();

            list.ForEach(f =>
            {
                string s = Path.Combine(root, f);
                fileItems.Add(new Updater.FileItem()
                {
                    Name = f, SHA1 = Updater.GetFileSHA1(s)
                });
            });

            Updater.FileIndex index = new Updater.FileIndex()
            {
                Files = fileItems.ToArray()
            };

            return(JsonConvert.SerializeObject(index));
        }