コード例 #1
0
ファイル: Form1.cs プロジェクト: Blayer98/Project-Dollhouse
        public Form1()
        {
            if (File.Exists(RelativePath + "Client.manifest"))
                m_ClientManifest = new ManifestFile(File.Open(RelativePath + "Client.manifest", FileMode.Open));
            else
            {
                MessageBox.Show("Couldn't find manifest - unable to update!");
                Environment.Exit(0);
            }

            if (MessageBox.Show("Backup data before updating?", "Backup", MessageBoxButtons.YesNo) == DialogResult.Yes)
                FileManager.Backup(m_ClientManifest, RelativePath);

            InitializeComponent();

            this.FormClosing += new FormClosingEventHandler(Form1_FormClosing);

            m_Requester = new Requester("https://dl.dropboxusercontent.com/u/257809956/PatchManifest.manifest");

            m_Requester.OnFetchedManifest += new FetchedManifestDelegate(m_Requester_OnFetchedManifest);
            m_Requester.OnTick += new DownloadTickDelegate(m_Requester_OnTick);
            m_Requester.OnFetchedFile += new FetchedFileDelegate(m_Requester_OnFetchedFile);
            Logger.OnMessageLogged += new MessageLoggedDelegate(Logger_OnMessageLogged);

            m_Requester.Initialize();
        }
コード例 #2
0
        /// <summary>
        /// Takes a backup of all files in the client's manifest.
        /// </summary>
        /// <param name="Manifest">The client's manifest.</param>
        /// <param name="WorkingDir">The client's residing directory.</param>
        public static void Backup(ManifestFile Manifest, string WorkingDir)
        {
            try
            {
                if (!Directory.Exists(WorkingDir + "Backup"))
                    Directory.CreateDirectory(WorkingDir + "Backup");

                foreach (PatchFile PFile in Manifest.PatchFiles)
                {
                    if (File.Exists(WorkingDir + PFile.Address))
                    {
                        FileManager.CreateDirectory(WorkingDir + "Backup\\" + PFile.Address);
                        File.Copy(WorkingDir + PFile.Address, WorkingDir + "Backup\\" + PFile.Address);
                    }
                }
            }
            catch (Exception e)
            {
                Log.LogThis("Exception in FileManager.Backup:" + e.ToString(), eloglevel.error);
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: Blayer98/Project-Dollhouse
        /// <summary>
        /// The manifest was fetched.
        /// </summary>
        /// <param name="Manifest">The patch manifest that was fetched.</param>
        private void m_Requester_OnFetchedManifest(ManifestFile Manifest)
        {
            m_PatchManifest = Manifest;

            //Versions didn't match, do update.
            if (m_ClientManifest.Version != m_PatchManifest.Version)
            {
                foreach (PatchFile clPF in m_ClientManifest.PatchFiles)
                {
                    foreach (PatchFile pmPF in m_PatchManifest.PatchFiles)
                    {
                        if (NeedToDownloadFile(pmPF, clPF))
                        {
                            if(!m_PatchDiff.Contains(pmPF))
                                m_PatchDiff.Add(pmPF);
                        }
                    }
                }

                this.Invoke(new MethodInvoker(() =>
                {
                    PrgFile.Value = 0;
                }));

                Directory.CreateDirectory(RelativePath + "Tmp");
                m_Requester.FetchFile(m_PatchDiff[0].URL);
            }
            else
            {
                MessageBox.Show("Your client is up to date!\n Exiting...");
                if (File.Exists(RelativePath + "Project Dollhouse Client.exe"))
                    Process.Start(RelativePath + "Project Dollhouse Client.exe");

                Environment.Exit(0);
            }
        }