public PluginExecuteResult Execute()
        {
            EventProcessing(this, new PluginEventArgs(string.Format("Checking for {0}...", this)));

            bool          newVersion    = false;
            InstallerInfo installerInfo = http.LastModified(siteInfo.InstallerUrl);

            if (installerInfo.CreationTime.Date > latest.CreationTime.Date)
            {
                newVersion = true;
            }
            else if (installerInfo.Length != latest.Length)
            {
                newVersion = true;
            }
            if (newVersion)
            {
                EventUpdate(this, new PluginEventArgs("New version found!"));
                NewLatestVersion(installerInfo);
                latest = installerInfo;
                string path = PluginSaveHelper.BuildSavePath(info, latest.CreationTime, ".zip");
                if (!File.Exists(path))
                {
                    down.FileAsync(siteInfo.InstallerUrl);
                }
                else
                {
                    EventProcessing(this, new PluginEventArgs("File already exists already"));
                    BuildVersion(path);
                }
            }


            return(PluginExecuteResult.Failed);
        }
        private void Done(RequestState state)
        {
            string path = PluginSaveHelper.BuildSavePath(info, latest.CreationTime, ".zip");

            File.WriteAllBytes(path, state.ResponseContent.ToArray());

            string tmp = Path.Combine(Path.GetDirectoryName(path), "tmp");

            System.IO.Compression.ZipFile.ExtractToDirectory(path, tmp);
            File.Delete(path);
            string[] files = Directory.GetFiles(tmp, "*.exe");
            if (files.Length == 0)
            {
                return;
            }

            string newpath = PluginSaveHelper.BuildSavePath(info, latest.CreationTime);

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

            File.Move(files[0], newpath);

            BuildVersion(newpath);

            Directory.Delete(tmp, true);
            EventProcessing(this, new PluginEventArgs(latest.ToString()));
        }
Beispiel #3
0
        private void Done(RequestState state)
        {
            string path = PluginSaveHelper.BuildSavePath(info, latest.CreationTime);

            File.WriteAllBytes(path, state.ResponseContent.ToArray());

            BuildVersion(null);
            EventProcessing(this, new PluginEventArgs(latest.ToString()));
        }