コード例 #1
0
        public void TestBuildDeploymentManifest(string deploymentPath)
        {
            DeploymentManifest dm1 = new DeploymentManifest();

            // Add files here
            // Second part needs to be remote file name

            dm1.Files.Add(DeploymentFile.CreateFromFile(@"D:\TS\C-DentalClaimTracker\bin\Release\DentalClaimTracker.exe",
                                                        deploymentPath));

            dm1.Save(DeploymentManifestFilePath);

            DeploymentManifest dm2 = new DeploymentManifest();

            dm2.LoadFromFile(DeploymentManifestFilePath);
        }
コード例 #2
0
        public bool CheckForUpdates()
        {
            RemoteManifest.LoadFromUrl(Settings.Default.RemoteDeploymentManifest);

            string         rootDir   = Path.GetDirectoryName(Application.ExecutablePath) + "\\";
            string         localFile = "";
            DeploymentFile localDF;

            foreach (DeploymentFile df in RemoteManifest.Files)
            {
                if (Path.IsPathRooted(df.FileName))
                {
                    localFile = df.FileName;
                }
                else
                {
                    localFile = Path.Combine(rootDir, df.FileName);
                }

                if (!File.Exists(localFile))
                {
                    // This file is missing from the local system, updates are needed
                    FileUpdateList.Add(df);
                }
                else
                {
                    localDF = DeploymentFile.CreateFromFile(localFile);

                    if (localDF != df)
                    {
                        // This file does not match the remote manifest, updates are needed
                        FileUpdateList.Add(df);
                    }
                }
            }

            return(FileUpdateList.Count > 0); // Updates are needed if there are any files in this list
        }
コード例 #3
0
        private void CheckAndCleanup()
        {
            string         tempDir   = Path.GetTempPath() + Application.ProductName;
            string         rootDir   = Path.GetDirectoryName(Application.ExecutablePath) + "\\";
            string         localFile = "";
            DeploymentFile localDF;

            foreach (DeploymentFile df in RemoteManifest.Files)
            {
                if (Path.IsPathRooted(df.FileName))
                {
                    localFile = df.FileName;
                }
                else
                {
                    localFile = Path.Combine(rootDir, df.FileName);
                }

                if (!File.Exists(localFile))
                {
                    // This file is missing from the local system, updates are needed
                    throw new Exception("One or more files did not update successfully. The server checksum values do not match the local file.");
                }
                else
                {
                    localDF = DeploymentFile.CreateFromFile(localFile);

                    if (localDF != df)
                    {
                        // This file does not match the remote manifest, updates are needed
                        throw new Exception("One or more files did not update successfully. The server checksum values do not match the local file.");
                    }
                }
            }

            Directory.Delete(tempDir, true); // Delete all temporary files
        }