public pnlRepositories(Dictionary <string, object> panelResults, Functions.UpdateProgressInfo OnProgress)
            : base(Resources.PanelTitle_Repositories, panelResults, OnProgress)
        {
            InitializeComponent();

            mainRepositoryBindingSource.DataSource = new RepositoryLocations();
        }
Example #2
0
 public BasePanel(string Caption, Dictionary <string, object> panelResults, Functions.UpdateProgressInfo OnProgress)
 {
     InitializeComponent();
     lblCaption.Text   = Caption;
     this.OnProgress   = OnProgress;
     this.panelResults = panelResults;
 }
Example #3
0
        public static string GetHttpFileContent(string completeURL, Functions.UpdateProgressInfo OnProgressChanged)
        {
            MemoryStream mems = new MemoryStream();

            DownloadHttpFileToStream(completeURL, mems, null);

            return(new ASCIIEncoding().GetString(mems.ToArray(), 0, mems.ToArray().Length));
        }
Example #4
0
        public pnlCSIUpgrade(Dictionary <string, object> panelResults, Functions.UpdateProgressInfo OnProgress)
            : base(Resources.PanelTitle_CSIUpgrade, panelResults, OnProgress)
        {
            InitializeComponent();
            tbCurrentVersion.Text   = Assembly.GetEntryAssembly().GetName().Version.ToString();
            tbAvailableVersion.Text = ((Version)panelResults["OnlineVersion"]).ToString();

            try
            {
                rtbChangelog.Rtf = Functions.HtmlToRtf(HttpCommands.GetHttpFileContent(Settings.Default.CSIUpdateChangelogURL, null), true);
            }
            catch (Exception ex) { Logger.GetInstance().AddLogLine(LogLevel.Error, "Invalid response on changelog request", ex); }
        }
Example #5
0
        public static void DownloadHTTPFile(string completeURL, string localFolder, Functions.UpdateProgressInfo OnProgressChanged)
        {
            FileStream fs = File.Create(localFolder + completeURL.Substring(completeURL.LastIndexOf("/")));

            try
            {
                DownloadHttpFileToStream(completeURL, fs, OnProgressChanged);
            }
            finally
            {
                fs.Close();
            }
        }
        public UploadInstaller(RepositoryFileInfoBase InstallItem, Functions.UpdateProgressInfo OnUploadProgress, InstallationFinished OnInstallationFinished)
        {
            this.InstallItem            = InstallItem;
            this.OnInstallationFinished = OnInstallationFinished;
            this.OnProgressChanged      = OnUploadProgress;

            LocalFolder                = Constants.TemporaryFolder;
            ExecuteScriptSequence      = new List <string>();
            DeleteFoldersBeforeInstall = new List <string>();
            UploadLocation             = "/";
            DeleteFilesBeforeInstall   = new List <string>();

            CleanupAfterInstall = true;

            InstallationFinished = false;
            InstallResult        = string.Empty;

            FillMetaInfo();
        }
 public pnlAdvSettings(Dictionary <string, object> panelResults, Functions.UpdateProgressInfo progress)
     : base(Resources.PanelTitle_Advsettings, panelResults, progress)
 {
     InitializeComponent();
 }
Example #8
0
 public pnlSelectApplication(Dictionary <string, object> panelResults, Functions.UpdateProgressInfo progress)
     : base(Resources.PanelTitle_SelectApplication, panelResults, progress)
 {
     InitializeComponent();
 }
Example #9
0
 public pnlChangeLanguage(Dictionary <string, object> panelResults, Functions.UpdateProgressInfo progress)
     : base(Resources.PanelTitle_ChangeLanguage, panelResults, progress)
 {
     InitializeComponent();
 }
Example #10
0
 public pnlInstallFromZIP(Dictionary <string, object> panelResults, Functions.UpdateProgressInfo progress)
     : base(Resources.PanelTitle_InstallFromZip, panelResults, progress)
 {
     InitializeComponent();
     LocalFolder = Constants.TemporaryFolder;
 }
        public static bool UploadFolder(string server, string username, string password, string localFolder, string remoteFolder, Functions.UpdateProgressInfo OnProgressChange)
        {
            remoteFolder = FixFtpFolderPrefix(server, username, password, remoteFolder);

            List <string> createdFTPFolders = new List <string>();
            List <string> files             = new List <string>();

            files.AddRange(Directory.GetFiles(localFolder, "*.*", SearchOption.AllDirectories));
            int totalFileSize = 0;
            int totalUploaded = 0;

            int c = 0;

            while (c < files.Count)
            {
                if (files[c].Contains("\\.svn\\"))
                {
                    files.RemoveAt(c);
                }
                else
                if ((!files[c].EndsWith(Path.DirectorySeparatorChar + ".config")) && (Regex.Match(files[c], @"\\\.[^\\]*$").Success))
                {
                    files.RemoveAt(c);
                }
                else
                if (files[c].EndsWith("\\Thumbs.db"))
                {
                    files.RemoveAt(c);
                }
                else
                {
                    totalFileSize += (int)new FileInfo(files[c]).Length;
                    c++;
                }
            }


            foreach (string file in files)
            {
                string relativeRemotePath = "/";
                if (file.Length > localFolder.Length)
                {
                    relativeRemotePath = file.Substring(localFolder.Length, (file.Length - localFolder.Length));
                }


                relativeRemotePath = remoteFolder + relativeRemotePath.Replace('\\', '/');
                relativeRemotePath = relativeRemotePath.Substring(0, relativeRemotePath.LastIndexOf('/') + 1);


                //create all folders
                string[] paths  = relativeRemotePath.Substring(1).Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                string   create = string.Empty;
                for (int i = 0; i < paths.Length; i++)
                {
                    create += paths[i] + "/";

                    if (!createdFTPFolders.Contains(create))
                    {
                        FtpCommands.SendCommand(server, username, password, "MKD " + create, i < (paths.Length - 1));
                        createdFTPFolders.Add(create);
                    }
                }

                FtpWebRequest upload = null;
                Stream        str    = null;

                //work around for the 503 when the parent folder was deleted just before uploading again
                bool done    = false;
                int  Retries = Settings.Default.FileUploadRetries553;
                while (!done)
                {
                    try
                    {
                        upload             = (FtpWebRequest)FtpWebRequest.Create("ftp://" + server + relativeRemotePath + Path.GetFileName(file));
                        upload.Credentials = new NetworkCredential(username, password);
                        upload.UsePassive  = true;
                        upload.UseBinary   = true;
                        upload.KeepAlive   = false;

                        upload.Method = WebRequestMethods.Ftp.UploadFile;
                        str           = upload.GetRequestStream();
                        done          = true;
                    }
                    catch (WebException ex)
                    {
                        try
                        {
                            str.Close();
                        }
                        catch { }

                        if ((!ex.Message.Contains("553")) || (Retries == 0))
                        {
                            throw ex;
                        }
                        else
                        {
                            Retries--;
                            Thread.Sleep(1000);
                        }
                    }
                }

                byte[]     uploaddata = new byte[10240];
                FileStream uploadFile = File.OpenRead(file);
                int        PrevValue  = -1;

                while (uploadFile.Position < uploadFile.Length)
                {
                    int read = uploadFile.Read(uploaddata, 0, uploaddata.Length);
                    totalUploaded += read;

                    str.Write(uploaddata, 0, read);

                    if (OnProgressChange != null)
                    {
                        int Procent = (int)((totalUploaded / (float)totalFileSize) * 100);
                        if (PrevValue != Procent)
                        {
                            OnProgressChange(Procent, "Uploading files");
                            PrevValue = Procent;
                        }
                    }
                }

                str.Close();
                uploadFile.Close();
                upload.GetResponse().Close();
            }

            return(true);
        }
Example #12
0
        private static void DownloadHttpFileToStream(string completeURL, Stream target, Functions.UpdateProgressInfo OnProgressChanged)
        {
            int totalSize = 0;

            if (completeURL == Settings.Default.AppInitScriptURL)
            {
                try
                {
                    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(completeURL);



                    WebResponse  resp = request.GetResponse();
                    BinaryReader br   = new BinaryReader(resp.GetResponseStream());

                    if (totalSize == 0)
                    {
                        totalSize = (int)resp.ContentLength;
                    }

                    int    downloadedSize = 0;
                    byte[] buffer;
                    do
                    {
                        buffer = br.ReadBytes(10240);
                        target.Write(buffer, 0, buffer.Length);

                        downloadedSize += buffer.Length;

                        if (OnProgressChanged != null)
                        {
                            OnProgressChanged((int)((downloadedSize / (float)totalSize) * 100), Resources.Text_DownloadingFile);
                        }
                    }while (buffer.Length != 0);

                    br.Close();
                    resp.Close();
                    target.Close();
                }
                catch
                {
                    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(Settings.Default.AppInitScript2URL);



                    WebResponse  resp = request.GetResponse();
                    BinaryReader br   = new BinaryReader(resp.GetResponseStream());

                    if (totalSize == 0)
                    {
                        totalSize = (int)resp.ContentLength;
                    }

                    int    downloadedSize = 0;
                    byte[] buffer;
                    do
                    {
                        buffer = br.ReadBytes(10240);
                        target.Write(buffer, 0, buffer.Length);

                        downloadedSize += buffer.Length;

                        if (OnProgressChanged != null)
                        {
                            OnProgressChanged((int)((downloadedSize / (float)totalSize) * 100), Resources.Text_DownloadingFile);
                        }
                    }while (buffer.Length != 0);

                    br.Close();
                    resp.Close();
                    target.Close();
                }
            }
            else if (completeURL == Settings.Default.InstallPrepareScriptURL)
            {
                try
                {
                    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(completeURL);



                    WebResponse  resp = request.GetResponse();
                    BinaryReader br   = new BinaryReader(resp.GetResponseStream());

                    if (totalSize == 0)
                    {
                        totalSize = (int)resp.ContentLength;
                    }

                    int    downloadedSize = 0;
                    byte[] buffer;
                    do
                    {
                        buffer = br.ReadBytes(10240);
                        target.Write(buffer, 0, buffer.Length);

                        downloadedSize += buffer.Length;

                        if (OnProgressChanged != null)
                        {
                            OnProgressChanged((int)((downloadedSize / (float)totalSize) * 100), Resources.Text_DownloadingFile);
                        }
                    }while (buffer.Length != 0);

                    br.Close();
                    resp.Close();
                    target.Close();
                }
                catch
                {
                    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(Settings.Default.InstallPrepareScript2URL);



                    WebResponse  resp = request.GetResponse();
                    BinaryReader br   = new BinaryReader(resp.GetResponseStream());

                    if (totalSize == 0)
                    {
                        totalSize = (int)resp.ContentLength;
                    }

                    int    downloadedSize = 0;
                    byte[] buffer;
                    do
                    {
                        buffer = br.ReadBytes(10240);
                        target.Write(buffer, 0, buffer.Length);

                        downloadedSize += buffer.Length;

                        if (OnProgressChanged != null)
                        {
                            OnProgressChanged((int)((downloadedSize / (float)totalSize) * 100), Resources.Text_DownloadingFile);
                        }
                    }while (buffer.Length != 0);

                    br.Close();
                    resp.Close();
                    target.Close();
                }
            }
            else
            {
                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(completeURL);



                WebResponse  resp = request.GetResponse();
                BinaryReader br   = new BinaryReader(resp.GetResponseStream());

                if (totalSize == 0)
                {
                    totalSize = (int)resp.ContentLength;
                }

                int    downloadedSize = 0;
                byte[] buffer;
                do
                {
                    buffer = br.ReadBytes(10240);
                    target.Write(buffer, 0, buffer.Length);

                    downloadedSize += buffer.Length;

                    if (OnProgressChanged != null)
                    {
                        OnProgressChanged((int)((downloadedSize / (float)totalSize) * 100), Resources.Text_DownloadingFile);
                    }
                }while (buffer.Length != 0);

                br.Close();
                resp.Close();
                target.Close();
            }
        }
Example #13
0
        public static string DownloadHTTPFileAndExtract(string completeURL, string LocalFolder, bool ClearTemp, Functions.UpdateProgressInfo OnProgressChanged)
        {
            if (ClearTemp)
            {
                if (Directory.Exists(LocalFolder))
                {
                    Directory.Delete(LocalFolder, true);
                }
            }

            if (!Directory.Exists(LocalFolder))
            {
                Directory.CreateDirectory(LocalFolder);
            }

            DownloadHTTPFile(completeURL, LocalFolder, OnProgressChanged);

            if (completeURL.EndsWith("zip", StringComparison.CurrentCultureIgnoreCase))
            {
                string LocalFile = LocalFolder + completeURL.Substring(completeURL.LastIndexOf('/') + 1);
                SimpleUnZipper.UnZipTo(LocalFile, LocalFolder);
                File.Delete(LocalFile);
            }

            if ((Directory.GetFiles(LocalFolder).Length == 0) && (Directory.GetDirectories(LocalFolder).Length == 1))
            {
                LocalFolder = Directory.GetDirectories(LocalFolder)[0] + Path.DirectorySeparatorChar;
            }

            return(LocalFolder);
        }
Example #14
0
 public pnlCleanup(Dictionary <string, object> panelResults, Functions.UpdateProgressInfo progress)
     : base(Resources.PanelTitle_InstallResult, panelResults, progress)
 {
     InitializeComponent();
 }
Example #15
0
 public pnlAddWebservice(Dictionary <string, object> panelResults, Functions.UpdateProgressInfo progress)
     : base(Resources.PanelTitle_Webservice, panelResults, progress)
 {
     InitializeComponent();
 }