Exemplo n.º 1
0
        public void StartDownload()
        {
            WebClient               Client           = new WebClient();
            Delegate_ProgressSet    __ProgressSet    = new Delegate_ProgressSet(ProgressSet);
            Delegate_TextSet        __TextSet        = new Delegate_TextSet(TextSet);
            Delegate_SetButtonState __SetButtonState = new Delegate_SetButtonState(SetButtonState);

            this.Invoke(__SetButtonState, true);
            this.Invoke(__ProgressSet, 10);
            this.Invoke(__TextSet, "Getting version info...");
            string err = GetBuildVersion();

            if (err != "")
            {
                TextSetError(__TextSet, err);
                this.Invoke(__SetButtonState, false);
                return;
            }
            this.Invoke(__ProgressSet, 30);
            this.Invoke(__TextSet, "Downloading zip file...");

            try {
                Client.DownloadFile("http://dermadesignerb.googlecode.com/svn/trunk/DermaDesigner/DermaDesigner/bin/Release/" + BuildVersion, ".$DSUpdateTmp");
            } catch {
                TextSetError(__TextSet, "Could not download file.");
                this.Invoke(__SetButtonState, false);
                return;
            }

            this.Invoke(__ProgressSet, 50);
            this.Invoke(__TextSet, "Unzipping zip file...");

            #region Unzipping Code
            try {
                Stream         str = File.OpenRead(".$DSUpdateTmp");
                ZipInputStream s   = new ZipInputStream(str);
                ZipEntry       theEntry;
                while ((theEntry = s.GetNextEntry()) != null)
                {
                    string directoryName = Path.GetDirectoryName(theEntry.Name);
                    string fileName      = Path.GetFileName(theEntry.Name);
                    if (directoryName.Contains("_svn") || directoryName.Contains(".svn") || fileName.Contains("Updater.exe"))
                    {
                        continue;
                    }
                    // create directory
                    if (directoryName.Length > 0)
                    {
                        Directory.CreateDirectory(directoryName);
                    }

                    if (fileName != String.Empty)
                    {
                        using (FileStream streamWriter = File.Create(theEntry.Name)) {
                            int    size = 2048;
                            byte[] data = new byte[2048];
                            while (true)
                            {
                                size = s.Read(data, 0, data.Length);
                                if (size > 0)
                                {
                                    streamWriter.Write(data, 0, size);
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
            } catch {
                TextSetError(__TextSet, "Could not unzip file.");
                this.Invoke(__SetButtonState, false);
            }
            #endregion Unzipping Code

            this.Invoke(__ProgressSet, 75);
            this.Invoke(__TextSet, "Deleting zip file...");

            try {
                File.Delete(".$DSUpdateTmp");
            } catch {
                TextSetError(__TextSet, "Could not delete file.");
                this.Invoke(__SetButtonState, false);
                return;
            }

            this.Invoke(__ProgressSet, 100);
            this.Invoke(__TextSet, "Completed Successfully!");
            HasCompleted = true;
            this.Invoke(__SetButtonState, false);
        }
Exemplo n.º 2
0
        public void StartDownload()
        {
            WebClient Client = new WebClient();
            Delegate_ProgressSet __ProgressSet = new Delegate_ProgressSet(ProgressSet);
            Delegate_TextSet __TextSet = new Delegate_TextSet(TextSet);
            Delegate_SetButtonState __SetButtonState = new Delegate_SetButtonState(SetButtonState);
            this.Invoke(__SetButtonState, true);
            this.Invoke(__ProgressSet, 10);
            this.Invoke(__TextSet, "Getting version info...");
            string err = GetBuildVersion();
            if (err != "") {
                TextSetError(__TextSet, err);
                this.Invoke(__SetButtonState, false);
                return;
            }
            this.Invoke(__ProgressSet, 30);
            this.Invoke(__TextSet, "Downloading zip file...");

            try {
                Client.DownloadFile("http://dermadesignerb.googlecode.com/svn/trunk/DermaDesigner/DermaDesigner/bin/Release/" + BuildVersion, ".$DSUpdateTmp");
            } catch {
                TextSetError(__TextSet, "Could not download file.");
                this.Invoke(__SetButtonState, false);
                return;
            }

            this.Invoke(__ProgressSet, 50);
            this.Invoke(__TextSet, "Unzipping zip file...");

            #region Unzipping Code
            try {
                Stream str = File.OpenRead(".$DSUpdateTmp");
                ZipInputStream s = new ZipInputStream(str);
                ZipEntry theEntry;
                while ((theEntry = s.GetNextEntry()) != null) {

                    string directoryName = Path.GetDirectoryName(theEntry.Name);
                    string fileName = Path.GetFileName(theEntry.Name);
                    if (directoryName.Contains("_svn") || directoryName.Contains(".svn") || fileName.Contains("Updater.exe")) {
                        continue;
                    }
                    // create directory
                    if (directoryName.Length > 0) {
                        Directory.CreateDirectory(directoryName);
                    }

                    if (fileName != String.Empty) {
                        using (FileStream streamWriter = File.Create(theEntry.Name)) {

                            int size = 2048;
                            byte[] data = new byte[2048];
                            while (true) {
                                size = s.Read(data, 0, data.Length);
                                if (size > 0) {
                                    streamWriter.Write(data, 0, size);
                                } else {
                                    break;
                                }
                            }
                        }
                    }
                }
            } catch {
                TextSetError(__TextSet, "Could not unzip file.");
                this.Invoke(__SetButtonState, false);
            }
            #endregion Unzipping Code

            this.Invoke(__ProgressSet, 75);
            this.Invoke(__TextSet, "Deleting zip file...");

            try {
                File.Delete(".$DSUpdateTmp");
            } catch {
                TextSetError(__TextSet, "Could not delete file.");
                this.Invoke(__SetButtonState, false);
                return;

            }

            this.Invoke(__ProgressSet, 100);
            this.Invoke(__TextSet, "Completed Successfully!");
            HasCompleted = true;
            this.Invoke(__SetButtonState, false);
        }
Exemplo n.º 3
0
 public void TextSetError(Delegate_TextSet d, string error)
 {
     this.Invoke(d, "An error occurred :: " + error);
 }
Exemplo n.º 4
0
 public void TextSetError(Delegate_TextSet d, string error)
 {
     this.Invoke(d, "An error occurred :: " + error);
 }