Ejemplo n.º 1
0
        static public DeploymentFile CreateFromFile(string fileName, string deployPath)
        {
            if (!File.Exists(fileName))
            {
                throw new FileNotFoundException("File not found.", fileName);
            }

            DeploymentFile df = new DeploymentFile();

            if (Path.GetFileName(deployPath) != String.Empty)
            {
                // Use full deploy path because it specifies a file
                df.FileName = deployPath;
            }
            else if (deployPath == string.Empty)
            {
                df.FileName = Path.GetFileName(fileName);
            }
            else
            {
                df.FileName = Path.GetDirectoryName(deployPath) + "\\" + Path.GetFileName(fileName);
            }

            df.HashValue = GetMD5HashFromFile(fileName);
            df.Version   = FileVersionInfo.GetVersionInfo(fileName).FileVersion;

            return(df);
        }
Ejemplo n.º 2
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);
        }
        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
        }
        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
        }
Ejemplo n.º 5
0
 private bool Equals(DeploymentFile df)
 {
     return(Path.GetFileName(FileName) == Path.GetFileName(df.FileName) && HashValue == df.HashValue && Version == df.Version);
 }