private void btnUpdate_Click(object sender, EventArgs e)
        {
            ProgressForm pForm = new ProgressForm();

            pForm.Show();
            dgvPluginData.Sort(dgvPluginData.Columns[0], ListSortDirection.Descending);
            int i = -1; int count = 0;

            while (++i < dgvPluginData.RowCount && (bool)dgvPluginData[0, i].Value == true)
            {
                PluginData pd        = (PluginData)dgvPluginData.Rows[i].Tag;
                string     localName = pd.tagType + ".ent";
                pForm.Text  = "updating " + localName;
                pForm.Value = count++ *100 / totalChecked;
                pForm.Refresh();

                WebClient wc = new WebClient();
                wc.Credentials = new NetworkCredential(updateFTPName, updateFTPPass);
                try
                {
                    wc.DownloadFile(
                        pluginsFTPServer + pd.fileData.name,
                        Globals.Prefs.pathPluginsFolder + "\\" + localName
                        );
                }
                catch (Exception ex)
                {
                    Globals.Global.ShowErrorMsg("Error downloading plugin", ex);
                }
            }
            pForm.Dispose();

            HaloMap.Plugins.IFPHashMap.H1IFPHash.Clear();
            HaloMap.Plugins.IFPHashMap.H2IFPHash.Clear();
        }
 public void Dispose()
 {
     if (form != null)
     {
         form.Dispose();
     }
 }
        public void Dispose()
        {
            FProgressLabel.Dispose();
            FProgressBar.Dispose();

            FTimer.Stop();
            FTimer.Tick -= Snap;
            FTimer.Dispose();
        }
Exemple #4
0
        //public string gameExists(GameImport gi)
        //{
        //    IGame duplicate = PluginHelper.DataManager.GetAllGames().ToList()
        //        .Find(x => x.GetAllCustomFields().ToList().Any(y => y.Name.Equals("gogId") && y.Value.Equals(gi._gogId)));
        //    if (duplicate != null)
        //    {
        //        return duplicate.ApplicationPath;
        //    } else
        //    {
        //        return null;
        //    }
        //}

        //##################    Add games to collection    ##################

        public async void startImport()
        {
            ProgressForm progressForm = new ProgressForm();

            progressForm.Show();
            await progressForm.ShowProgress(gameImport_doWork, "Importing  Games");

            progressForm.Close();
            progressForm.Dispose();
        }
Exemple #5
0
        public void Dispose()
        {
            _owner.InvokeIfRequired(() =>
            {
                _form?.Dispose();
                _form = null;
            });

            _cancellation?.Dispose();
            _cancellation = null;
        }
Exemple #6
0
    public static void RunWithMargueProgress(this Action action)
    {
        var progressForm = new ProgressForm();

        progressForm.Show();
        Task.Factory.StartNew(action)
        .ContinueWith(t =>
        {
            progressForm.Close();
            progressForm.Dispose();
        }, TaskScheduler.FromCurrentSynchronizationContext());
    }
Exemple #7
0
        //##################    Scaning gog.com for games owned    ##################

        private async void GetGames()
        {
            platforms = new Dictionary <int, string>();

            int i = 0;

            foreach (IPlatform platform in PluginHelper.DataManager.GetAllPlatforms())
            {
                platforms.Add(i, platform.Name);
                i++;
            }

            ImportOptions options = new ImportOptions(this);

            options.Show();
            await options.ok.Task;

            options.Close();
            this.skipByTitle  = options.skipByTitle;
            this.skipImported = options.skipImported;
            this.mode         = options.mode;
            this.galaxyPath   = options.galaxyPath;
            this.platform     = options.platform;
            options.Dispose();

            await Scan_Library();

            MessageBox.Show("Skip " + skipGogId.Count.ToString() + " games already imported and " + skipTitle.Count.ToString() + " games by title.");

            ProgressForm progressForm = new ProgressForm();

            progressForm.Show();
            await progressForm.ShowProgress(GetGames_doWork, "Collecting Game Information");

            progressForm.Close();
            progressForm.Dispose();

            if (mode.Equals(Mode.startWithGalaxy))
            {
                GameImportForm importForm = new GameImportForm(this);
                importForm.Show();
            }
            else if (mode.Equals(Mode.linkToDownload))
            {
                GameImportForm2 importForm = new GameImportForm2(this);
                importForm.Show();
            }

            webClient.Dispose();
        }
Exemple #8
0
 internal void OnFinishProgress(Report report)
 {
   if (ShowProgress)
   {
     if (FinishProgress != null)
       FinishProgress(report, EventArgs.Empty);
     else if (FProgress != null)
     {
       FProgress.Close();
       FProgress.Dispose();
       FProgress = null;
     }
   }  
 }
Exemple #9
0
        /// <summary>
        /// Function: Do send schedule
        /// </summary>
        public override void Perform()
        {
            _IsCancel = false;
            if (_sign.Controller.Connection.State == ConnectionState.Closed)
            {
                return;
            }

            if (_waitForm != null)
            {
                _waitForm.Dispose();
            }

            _waitForm = new ProgressForm(this.Upload, Cancel, _sign);
            _waitForm.ShowModalDialog(false);
        }
Exemple #10
0
        void Run(ref Continuation Continuation)
        {
            // Setup progress UI...
            Progress      = new ProgressForm();
            Progress.Text = "Verifying archived files for project '" + Project.Name + "'.";
            Progress.OverallProgressBar.Maximum = 10000;
            Progress.OverallProgressBar.Minimum = 0;
            Progress.OverallProgressBar.Value   = 0;
            Progress.CancelPrompt = "Are you sure you wish to cancel this verification operation?";
            Progress.Show();

            try
            {
                System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.BelowNormal;

                ZippyForm.LogWriteLine(LogLevel.Information, "Starting verification of backup '" + Project.Name + "'.");

                string UserTempFolder = Path.GetTempPath();
                TempRoot = new DirectoryInfo(Utility.StripTrailingSlash(UserTempFolder) + "\\ZippyBackup_Verification");
                Directory.CreateDirectory(TempRoot.FullName);

                try
                {
                    Progress.label1.Text = "Retrieving latest archive manifest...";
                    DoEvents();
                    ArchiveFilename LatestBackup;
                    Manifest        LatestManifest;
                    try
                    {
                        using (NetworkConnection newself = new NetworkConnection(Project.CompleteBackupFolder, Project.BackupCredentials))
                        {
                            // Locate latest backup (either complete or incremental.)
                            lock (Project.ArchiveFileList) LatestBackup = Project.ArchiveFileList.FindMostRecent();
                            if (LatestBackup == ArchiveFilename.MaxValue)
                            {
                                throw new NoCompleteBackupException();
                            }

                            ZippyForm.LogWriteLine(LogLevel.LightDebug, "Loading most recent manifest from '" + LatestBackup.ToString() + "' of project '" + Project.Name + "'.");

                            LatestManifest = LatestBackup.LoadArchiveManifest(Project, true);
                        }
                    }
                    catch (CancelException ce) { throw ce; }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message + "  Error while loading last backup for incremental update.", ex);
                    }

                    int StartTick = Environment.TickCount;

                    if (Continuation.Starting)
                    {
                        ZippyForm.LogWriteLine(LogLevel.LightDebug, "Continuing from previous run.  Searching for starting point '" + Continuation.LastRelativePath + "'.");
                    }

                    Continuation MapContinuation = new Continuation();
                    MapContinuation.Starting         = Continuation.Starting;
                    MapContinuation.LastRelativePath = Continuation.LastRelativePath;

                    Continuation.Required = false;
                    while (!Continuation.Required)
                    {
                        /** Operate on a single zip file at a time.  This requires planning which files are
                         *  coming from where.  Also, we count how many total bytes we'll be extracting.  **/
                        Progress.label1.Text = "Identifying required archive files...";
                        DoEvents();
                        List <Manifest.File>   FileList         = new List <Manifest.File>();
                        List <ArchiveFilename> ArchivesRequired = new List <ArchiveFilename>();
                        TotalBytes = 0;

                        /** For extremely large archives, it can happen that even just scanning through the manifest can be very time consuming.  We don't want
                         *  to spend too much time on this step, so we have a time limit for coming up with file/archive list.  But we also have a time limit
                         *  for the overall verify operation.  We use a pattern of spending N minutes coming up with filenames and then processing that bunch,
                         *  then repeating as long as the overall M minute limit hasn't yet been reached.  This requires keeping track of "where we left off"
                         *  for both the scanning operation and the overall verify operation.  If a file hasn't yet been extracted and verified and we have to
                         *  quit because of time or cancellation, then we need the overall "where we left off" to point to the last extracted file, potentially
                         *  repeating a little bit of the mapping time when we startup again.
                         */

                        int MapStartTick = Environment.TickCount;
                        // If the last loop ran into a mapping time limit, initiate a continuation on the mapping.  If the last verification ran into a time limit,
                        // we are also doing a mapping continuation because there is no need to map anything before the first file of the new set.
                        if (MapContinuation.Required)
                        {
                            MapContinuation.Starting = true;
                        }
                        MapContinuation.Required = false;

                        if (MapContinuation.Starting)
                        {
                            ZippyForm.LogWriteLine(LogLevel.LightDebug, "Identifying required archive files, beginning at '" + MapContinuation.LastRelativePath + "'...");
                        }
                        else
                        {
                            ZippyForm.LogWriteLine(LogLevel.LightDebug, "Identifying required archive files...");
                        }

                        MapManifest(LatestManifest.ArchiveRoot, ref FileList, ref ArchivesRequired, ref TotalBytes, ref MapContinuation, ref MapStartTick);

                        if (MapContinuation.Starting)
                        {
                            // We have the case where we never found the continuation marker.  This can happen if the latest archive mismatches
                            // the one where the continuation marker was made.  We just restart from the beginning of the archive.
                            ZippyForm.LogWriteLine(LogLevel.LightDebug, "Continuation marker not found.  Starting verification from beginning.");
                            MapContinuation.Starting = false;
                            Debug.Assert(FileList.Count == 0 && ArchivesRequired.Count == 0);
                            MapStartTick = Environment.TickCount;
                            MapManifest(LatestManifest.ArchiveRoot, ref FileList, ref ArchivesRequired, ref TotalBytes, ref MapContinuation, ref MapStartTick);
                        }

                        ZippyForm.LogWriteLine(LogLevel.LightDebug, "Archives requiring verification (" + ArchivesRequired.Count + "):");
                        foreach (ArchiveFilename Archive in ArchivesRequired)
                        {
                            ZippyForm.LogWriteLine(LogLevel.LightDebug, "\t" + Archive.ToString());
                        }
                        ZippyForm.LogWriteLine(LogLevel.LightDebug, "Starting individual verifications of " + FileList.Count + " files...");

                        // Begin extracting each file and then immediately deleting if successful.
                        int FilesVerified = 0;
                        foreach (ArchiveFilename Archive in ArchivesRequired)
                        {
                            Progress.label1.Text = "Extracting from archive:  " + Archive.ToString();
                            DoEvents();
                            ZippyForm.LogWriteLine(LogLevel.LightDebug, "Verifying archive: " + Archive.ToString());
                            try
                            {
                                using (ZipFile zip = ZipFile.Read(Project.CompleteBackupFolder + "\\" + Archive.ToString()))
                                {
                                    zip.ZipError        += new EventHandler <ZipErrorEventArgs>(OnZipError);
                                    zip.ExtractProgress += new EventHandler <ExtractProgressEventArgs>(OnZipExtractProgress);
                                    foreach (Manifest.File Entry in FileList)
                                    {
                                        ArchiveFilename NeededArchive = ArchiveFilename.Parse(Entry.ArchiveFile);
                                        if (NeededArchive != Archive)
                                        {
                                            continue;
                                        }

                                        RunEntry(zip, Archive, Entry, Utility.StripTrailingSlash(TempRoot.FullName));
                                        FilesVerified++;

                                        if (AutomaticVerify && (Environment.TickCount - StartTick) > MaxAutomaticDurationInTicks)
                                        {
                                            Continuation.Required         = true;
                                            Continuation.Starting         = true;
                                            Continuation.LastRelativePath = Entry.RelativePath;
                                            ZippyForm.LogWriteLine(LogLevel.LightDebug, "New verification continuation marker set to '" + Continuation.LastRelativePath + "'.");
                                            ZippyForm.LogWriteLine(LogLevel.Information, "Verify terminating early due to individual scan time limit.");
                                            break;
                                        }
                                    }
                                }
                            }
                            catch (FileNotFoundException fe)
                            {
                                StringBuilder Msg = new StringBuilder();
                                Msg.Append("Unable to locate file(s) in archive '" + Archive.ToString() + "'.  Do you want to delete this archive so that it will be reconstructed on your next backup?\n\nThe error was: " + fe.Message);
                                switch (MessageBox.Show(Msg.ToString(), "Error", MessageBoxButtons.YesNoCancel))
                                {
                                case DialogResult.Yes: File.Delete(Project.CompleteBackupFolder + "\\" + Archive.ToString()); break;

                                case DialogResult.No: break;

                                case DialogResult.Cancel: throw new CancelException();

                                default: throw new NotSupportedException();
                                }
                            }
                            catch (Ionic.Zip.ZipException ze)
                            {
                                StringBuilder Msg = new StringBuilder();
                                Msg.Append("Unable to extract file(s) from archive '" + Archive.ToString() + "'.  Do you want to delete this archive so that it will be reconstructed on your next backup?\n\nThe error was: " + ze.Message);
                                switch (MessageBox.Show(Msg.ToString(), "Error", MessageBoxButtons.YesNoCancel))
                                {
                                case DialogResult.Yes: File.Delete(Project.CompleteBackupFolder + "\\" + Archive.ToString()); break;

                                case DialogResult.No: break;

                                case DialogResult.Cancel: throw new CancelException();

                                default: throw new NotSupportedException();
                                }
                            }
                            catch (Ionic.Zlib.ZlibException ze)
                            {
                                StringBuilder Msg = new StringBuilder();
                                Msg.Append("Unable to extract file(s) from archive '" + Archive.ToString() + "'.  Do you want to delete this archive so that it will be reconstructed on your next backup?\n\nThe error was: " + ze.Message);
                                switch (MessageBox.Show(Msg.ToString(), "Error", MessageBoxButtons.YesNoCancel))
                                {
                                case DialogResult.Yes: File.Delete(Project.CompleteBackupFolder + "\\" + Archive.ToString()); break;

                                case DialogResult.No: break;

                                case DialogResult.Cancel: throw new CancelException();

                                default: throw new NotSupportedException();
                                }
                            }

                            ZippyForm.LogWriteLine(LogLevel.LightDebug, "Verified " + FilesVerified + " of " + FileList.Count + " files.");

                            if (Continuation.Required)
                            {
                                break;
                            }
                        }

                        if (!MapContinuation.Required)
                        {
                            break;
                        }
                    }

                    string       BackupStatusFile = Project.CompleteBackupFolder + "\\Backup_Status.xml";
                    BackupStatus bs = new BackupStatus();
                    try { bs = BackupStatus.Load(BackupStatusFile); }
                    catch (Exception) { }
                    bs.LastVerify = DateTime.UtcNow;
                    if (!Continuation.Required)
                    {
                        bs.LastCompletedVerify = DateTime.UtcNow;
                    }
                    if (!Continuation.Required)
                    {
                        bs.LastVerifyRelativePath = "";
                    }
                    else
                    {
                        bs.LastVerifyRelativePath = Continuation.LastRelativePath;
                    }
                    bs.Save(BackupStatusFile);

                    ZippyForm.LogWriteLine(LogLevel.Information, "Verification complete.");
                }
                finally
                {
                    Directory.Delete(TempRoot.FullName);
                }
            }
            catch (CancelException ce)
            {
                ZippyForm.LogWriteLine(LogLevel.Information, "Verification cancelled by user before completion.");
                throw ce;
            }
            catch (Exception ex)
            {
                ZippyForm.LogWriteLine(LogLevel.LightDebug, "Verification interrupted by error: " + ex.Message);
                throw ex;
            }
            finally
            {
                Progress.Dispose();
                Progress = null;

                System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.Normal;
            }
        }
Exemple #11
0
        public void Run()
        {
            // Setup progress UI...
            Progress      = new ProgressForm();
            Progress.Text = "Synchronizing files";
            Progress.OverallProgressBar.Maximum = 10000;
            Progress.OverallProgressBar.Minimum = 0;
            Progress.OverallProgressBar.Value   = 0;
            Progress.Show();

            try
            {
                System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.BelowNormal;

                ZippyForm.LogWriteLine(LogLevel.Information, "Starting synchronize operation for project '" + Project.Name + "'.");

                /** Retrieve newest manifest **/
                ArchiveFilename LatestBackup;
                Manifest        LatestManifest;
                try
                {
                    using (Impersonator newself = new Impersonator(Project.BackupCredentials))
                    {
                        // Locate latest backup (either complete or incremental.)
                        lock (Project.ArchiveFileList) LatestBackup = Project.ArchiveFileList.FindMostRecent();
                        if (LatestBackup == ArchiveFilename.MaxValue)
                        {
                            throw new NoCompleteBackupException();
                        }

                        ZippyForm.LogWriteLine(LogLevel.LightDebug, "Loading most recent manifest from '" + LatestBackup.ToString() + "'.");

                        LatestManifest = LatestBackup.LoadArchiveManifest(Project, true);
                    }
                }
                catch (CancelException ce) { throw ce; }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message + "  Error while loading last backup for sync.", ex);
                }

                SourceRoot = Project.SourceFolder;

                SyncFolder(new DirectoryInfo(Project.SourceFolder), LatestManifest.ArchiveRoot);

                // Update Backup Status file.
                using (Impersonator newself = new Impersonator(Project.BackupCredentials))
                {
                    string       BackupStatusFile = Project.CompleteBackupFolder + "\\Backup_Status.xml";
                    BackupStatus bs = BackupStatus.Load(BackupStatusFile);
                    bs.LastSync = DateTime.UtcNow;
                    bs.Save(BackupStatusFile);
                }
            }
            finally
            {
                Progress.Dispose();
                Progress = null;

                System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.Normal;
            }
        }
Exemple #12
0
        private void RetrieveDataFromFTPServer()
        {
            FtpWebRequest ftpRequest;
            FtpWebResponse ftpResponse;

            xDoc = new XmlDocument();

            ProgressForm formPB = new ProgressForm();
            formPB.Show();

            try
            {
                formPB.Text = "Downloading Database";
                formPB.Value = 0;
                formPB.Refresh();

                #region Attempt to download plugin database file
                try
                {
                    // Create a request for the database file
                    ftpRequest = (FtpWebRequest)WebRequest.Create(pluginsFTPdbFile);
                    // Set default authentication for retrieving the file info
                    ftpRequest.Credentials = new NetworkCredential(updateFTPName, updateFTPPass);

                    ftpRequest.Method = WebRequestMethods.Ftp.GetFileSize;
                    ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
                    // Ask the server for the file size and store it
                    long fileSize = ftpResponse.ContentLength;
                    ftpResponse.Close();

                    WebClient wc = new WebClient();
                    wc.Credentials = ftpRequest.Credentials;
                    xDoc.LoadXml(wc.DownloadString(pluginsFTPdbFile));
                }
                catch
                {
                    xDoc.AppendChild(xDoc.CreateElement("Plugins"));
                }
                #endregion

                formPB.Text = "Check File Dates/Times";
                #region Retrieve list of all files & directories from FTP server
                try
                {
                    // Create a request to the directory we are working in
                    ftpRequest = (FtpWebRequest)WebRequest.Create(pluginsFTPServer);
                    // Set default authentication for retrieving the file info
                    ftpRequest.Credentials = new NetworkCredential(updateFTPName, updateFTPPass);
                    ftpRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
                    ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
                    StreamReader streamReader = new StreamReader(ftpResponse.GetResponseStream());

                    List<string> files = new List<string>();
                    string line = streamReader.ReadLine();
                    while (!string.IsNullOrEmpty(line))
                    {
                        files.Add(line);
                        line = streamReader.ReadLine();
                    }

                    foreach (string s in files)
                    {
                        formPB.Value = files.IndexOf(s) * 100 / files.Count;
                        formPB.Refresh();
                        if (s[0].ToString().ToLower() == "d")
                            continue;

                        // Create a request to the directory we are working in
                        ftpRequest = (FtpWebRequest)WebRequest.Create(pluginsFTPServer + s.Substring(62));
                        ftpRequest.Credentials = new NetworkCredential(updateFTPName, updateFTPPass);
                        ftpRequest.Method = WebRequestMethods.Ftp.GetDateTimestamp;
                        ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
                        DateTime dt = ftpResponse.LastModified;
                        listing.Add(new FileData(s, dt));
                        ftpResponse.Close();
                    }

                }
                catch (Exception ex)
                {
                }
                #endregion

                HashSet<string> hashTable = new HashSet<string>();
                bool xDocChange = false;
                foreach (FileData fd in listing)
                {
                    // We only want files (non-directories)
                    if ((fd.attrib | FileAttributes.Directory) != FileAttributes.Directory)
                    {
                        string[] fName = fd.name.ToLower().Split('.', '-');
                        string modifiedName = fName[0].Replace('!', '_').Replace('+', '_');

                        #region Update information box
                        formPB.Text = "Analyzing: \n" + fd.name;
                        formPB.Value = listing.IndexOf(fd) * 100 / listing.Count;
                        formPB.Refresh();
                        #endregion

                        if (fName[fName.Length - 1] != "ent")
                            continue;

                        /*
                        if (fName.Length > 3)
                        {
                            string ver = fName[1];
                            for (int i = 2; i < fName.Length - 1; i++)
                                ver += '.' + fName[i];
                            fVer = new Version(ver);
                        }
                        */

                        // Check for the matching tag HASHCODE name
                        XmlNodeList xnl = null;
                        XmlNode xNode = null;

                        if (fName.Length > 2)
                            xnl = xDoc.GetElementsByTagName("_" + fName[1]);

                        // Search through each return value for the one in the desired parent TAG TYPE
                        if (xnl != null && xnl.Count > 0)
                            foreach (XmlNode xn in xnl)
                            {
                                if (xn.ParentNode.Name == modifiedName)
                                {
                                    xNode = xn;
                                    break;
                                }
                            }

                    @updatePlugin:
                        // If we do not get any results for the HASHCODE, check for parent TAG TYPE
                        if (xNode == null)
                        {
                            // Search for a matching TAG TYPE
                            XmlNodeList xml = xDoc.GetElementsByTagName(modifiedName);

                            // No matching TAG TYPE was found, so create a tag placeholder (eg. SCNR)
                            if (xml.Count == 0)
                            {
                                xNode = xDoc.CreateElement(modifiedName);
                                xDoc.FirstChild.AppendChild(xNode);
                            }
                            // We found a matching TAG TYPE, so select it
                            else
                            {
                                xNode = xml[0];
                            }

                            // Retrieve the plugin from the server & parse for needed info
                            WebClient wc = new WebClient();
                            wc.Credentials = new NetworkCredential(updateFTPName, updateFTPPass);
                            try
                            {
                                string tempPlugin = wc.DownloadString(pluginsFTPServer + fd.name);
                                XmlDocument xd = new XmlDocument();
                                xd.LoadXml(tempPlugin);
                                XmlNodeList XList;
                                XmlNode xnA;    // Holds author attribute info
                                XmlNode xnV;    // Holds version attribute info
                                string tag;

                                try
                                {
                                    XList = xd.GetElementsByTagName("revision");
                                    xnA = XList[0].Attributes.GetNamedItem("author");
                                    xnV = XList[0].Attributes.GetNamedItem("version");
                                    try
                                    {
                                        XList = xd.GetElementsByTagName("plugin");
                                        tag = XList[0].Attributes.GetNamedItem("class").Value;
                                    }
                                    catch
                                    {
                                        tag = fName[0].ToLower();
                                    }
                                }
                                catch
                                {
                                    try
                                    {
                                        XList = xd.GetElementsByTagName("plugin");
                                        xnA = XList[0].Attributes.GetNamedItem("author");
                                        xnV = XList[0].Attributes.GetNamedItem("version");
                                        tag = XList[0].Attributes.GetNamedItem("class").Value;
                                    }
                                    catch
                                    {
                                        // Bad plugin?
                                        continue;
                                    }
                                }

                                //
                                // Need to generate name first & will rename later
                                //
                                System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
                                string md5 = GetChecksum(encoding.GetBytes(tempPlugin));

                                if (fName.Length > 2)
                                    xNode = xNode.AppendChild(xDoc.CreateElement("_" + fName[1]));
                                else
                                    xNode = xNode.AppendChild(xDoc.CreateElement("_---"));

                                // Append author & version to xNode
                                // (This needs to be after the xNode is possibly set to xNode.Child)

                                // MD5 Hashcode
                                XmlAttribute xAttr = xDoc.CreateAttribute("md5");
                                xAttr.InnerText = md5;
                                xNode.Attributes.Append(xAttr);

                                // Author info
                                xAttr = xDoc.CreateAttribute("tagtype");
                                xAttr.InnerText = tag;
                                xNode.Attributes.Append(xAttr);

                                // Author info
                                xAttr = xDoc.CreateAttribute("author");
                                xAttr.InnerText = xnA.Value;
                                xNode.Attributes.Append(xAttr);

                                // Version info
                                xAttr = xDoc.CreateAttribute("version");
                                xAttr.InnerText = xnV.Value;
                                xNode.Attributes.Append(xAttr);

                                // States that changes need to be made to database file
                                xDocChange = true;
                            }
                            catch (Exception ex)
                            {
                                Globals.Global.ShowErrorMsg("Error from plugin server: ", ex);
                            }
                        }
                        PluginData pd = new PluginData(fd, xNode);
                        if (pd.md5 == string.Empty)
                        {
                            xNode = null;
                            goto @updatePlugin;
                        }
                        if (hashTable.Contains(pd.md5))
                        {
                            // Duplicate file found, erase file & remove entry
                            try
                            {
                                ftpRequest = (FtpWebRequest)WebRequest.Create(pluginsFTPServer + fd.name);
                                // Set default authentication for retrieving the file info
                                ftpRequest.Credentials = new NetworkCredential(updateFTPName, updateFTPPass);

                                ftpRequest.Method = WebRequestMethods.Ftp.DeleteFile;
                                ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
                                // Ask the server for the file size and store it
                                ftpResponse.Close();
                                xDocChange = true;
                            }
                            catch
                            { }
                            continue;
                        }

                        hashTable.Add(pd.md5);

                        // 1827
                        // "_fx_-87943969.ent"
                        // {27/10/2012 1:49:00 AM}
                        // "Grimdoomer"
                        // "0.99"

                        // Create a unique short hash code for this plugin using author, version & file date/time stamp
                        string hashcode = pd.GetHashCode().ToString();
                        string fileName = fName[0] + '-' + hashcode + ".ent";
                        if (fd.name.ToLower() != fileName)
                        {
                            // Rename the node to reflect the [new] hashcode
                            if (xNode.Name != "_" + hashcode)
                                xNode = RenameNode(xNode, string.Empty, '_' + hashcode);
                            #region Rename file to naming sequence
                            // Create a request to the directory we are working in
                            ftpRequest = (FtpWebRequest)WebRequest.Create(pluginsFTPServer + fd.name);
                            // Set default authentication for retrieving the file info
                            ftpRequest.Credentials = new NetworkCredential(updateFTPName, updateFTPPass);
                            ftpRequest.Method = WebRequestMethods.Ftp.Rename;
                            ftpRequest.RenameTo = fileName;
                            ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
                            ftpResponse.Close();
                            #endregion
                            fd.name = fileName;
                        }

                        if (pd.version == "0.0")
                        {
                            int a = 0;
                        }
                        this.Add(fName[0], pd);
                    }

                }
                if (xDocChange)
                {
                    // WriteXDoc back out
                    WebClient wc = new WebClient();
                    wc.Credentials = new NetworkCredential(updateFTPName, updateFTPPass);
                    wc.UploadString(pluginsFTPdbFile, xDoc.InnerXml);
                }
            }
            finally
            {
                // Clean up our loading form
                formPB.Dispose();
            }
        }
Exemple #13
0
        //##################    Scaning gog.com for games owned    ##################

        private async void GetGames()
        {
            platforms = new Dictionary <int, string>();

            int i = 0;

            foreach (IPlatform platform in PluginHelper.DataManager.GetAllPlatforms())
            {
                platforms.Add(i, platform.Name);
                i++;
            }

            // if platforms changed reset
            if (platform == null || !platforms[platformNo].Equals(platform))
            {
                platformNo = 0;
                platform   = platforms[platformNo];
            }

            ImportOptions options = new ImportOptions(this);

            options.Show();
            await options.ok.Task;

            options.Close();
            this.skipByTitle  = options.skipByTitle;
            this.skipImported = options.skipImported;
            this.mode         = options.mode;
            this.galaxyPath   = options.galaxyPath;
            this.platformNo   = options.platformNo;
            this.platform     = platforms[platformNo];
            options.Dispose();

            await Scan_Library();

            ProgressForm progressForm = new ProgressForm("Collecting Game Information");

            progressForm.Show();
            await progressForm.ShowProgress(GetGames_doWork);

            progressForm.Close();
            progressForm.Dispose();

            if (errorForm != null)
            {
                errorForm.Show();
                await errorForm.ok.Task;
                errorForm.Dispose();
            }

            if (gamesFound != null || gamesFound.Count > 0)
            {
                gamesFound.Sort((x1, x2) => x1.title.CompareTo(x2.title));

                if (mode.Equals(Mode.startWithGalaxy))
                {
                    GameImportForm importForm = new GameImportForm(this);
                    importForm.Show();
                }
                else if (mode.Equals(Mode.linkToDownload))
                {
                    GameImportForm2 importForm = new GameImportForm2(this);
                    importForm.Show();
                }
            }

            webClient.Dispose();
        }
 private void CloseProgressBar()
 {
     _progress?.Close();
     _progress?.Dispose();
     _progress = null;
 }
Exemple #15
0
        public void Run(List <Manifest.Entry> Entries, string DestinationFolder)
        {
            // Setup progress UI...
            Progress      = new ProgressForm();
            Progress.Text = "Extracting archived files";
            Progress.OverallProgressBar.Maximum = 10000;
            Progress.OverallProgressBar.Minimum = 0;
            Progress.OverallProgressBar.Value   = 0;
            Progress.CancelPrompt = "Are you sure you wish to cancel this extraction operation?";
            Progress.Show();

            try
            {
                System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.BelowNormal;

                ZippyForm.LogWriteLine(LogLevel.Information, "Starting extraction from project " + Project.Name + " of " + Entries.Count + " files and folders to destination folder '" + DestinationFolder + "'.");

                /** Operate on a single zip file at a time.  This requires planning which files are
                 *  coming from where.  Also, we count how many total bytes we'll be extracting.  **/
                Progress.label1.Text = "Identifying required archive files...";
                List <ArchiveFilename> ArchivesRequired = new List <ArchiveFilename>();
                foreach (Manifest.Entry Entry in Entries)
                {
                    IdentifyRequiredArchives(ArchivesRequired, Entry);
                }

                // Then, begin actual extraction...
                foreach (ArchiveFilename Archive in ArchivesRequired)
                {
                    ZippyForm.LogWriteLine(LogLevel.LightDebug, "Starting extractions from archive '" + Archive.ToString() + "'.");
                    Progress.label1.Text = "Extracting from archive:  " + Archive.ToString();
                    for (; ;)
                    {
                        try
                        {
                            using (ZipFile zip = ZipFile.Read(Project.CompleteBackupFolder + "\\" + Archive.ToString()))
                            {
                                zip.ZipError        += new EventHandler <ZipErrorEventArgs>(OnZipError);
                                zip.ExtractProgress += new EventHandler <ExtractProgressEventArgs>(OnZipExtractProgress);
                                foreach (Manifest.Entry Entry in Entries)
                                {
                                    ZippyForm.LogWriteLine(LogLevel.HeavyDebug, "Extracting '" + Entry.RelativePath + "'.");
                                    RunEntry(zip, Archive, Entry, Utility.StripTrailingSlash(DestinationFolder));
                                }
                            }
                            break;
                        }
                        catch (Ionic.Zip.ZipException ze)
                        {
                            ZippyForm.LogWriteLine(LogLevel.Information, "Zip error during extraction from archive '" + Archive.ToString() + "': " + ze.Message);
                            ZippyForm.LogWriteLine(LogLevel.LightDebug, "Detailed error: " + ze.ToString());

                            StringBuilder Msg = new StringBuilder();
                            Msg.Append("Error extracting from archive '" + Archive.ToString() + "': " + ze.Message);
                            if (Entries.Count < 15)
                            {
                                Msg.AppendLine();
                                Msg.AppendLine("The following entries to be restored are affected:");
                                foreach (Manifest.Entry Entry in Entries)
                                {
                                    if (Entry is Manifest.File)
                                    {
                                        Msg.AppendLine(Entry.Name);
                                    }
                                    if (Entry is Manifest.Folder)
                                    {
                                        Msg.AppendLine(Entry.Name + " folder");
                                    }
                                }
                            }
                            else
                            {
                                Msg.Append("  More than 15 files to be restored are affected.");
                            }
                            switch (MessageBox.Show(Msg.ToString(), "Error", MessageBoxButtons.AbortRetryIgnore))
                            {
                            case DialogResult.Abort: throw new CancelException();

                            case DialogResult.Retry: continue;

                            case DialogResult.Ignore: break;

                            default: throw new NotSupportedException();
                            }
                        }
                    }
                }

                ZippyForm.LogWriteLine(LogLevel.Information, "Extraction operation completed.");
            }
            catch (CancelException ex)
            {
                ZippyForm.LogWriteLine(LogLevel.Information, "Extraction operation canceled.");
                throw ex;
            }
            finally
            {
                Progress.Dispose();
                Progress = null;

                System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.Normal;
            }
        }
Exemple #16
0
 private void backgroundWorker1_RunWorkerCompleted(object sender, EventArgs e) {
     _pf.Close();
     _pf.Dispose();
 }
        private void RetrieveDataFromFTPServer()
        {
            FtpWebRequest  ftpRequest;
            FtpWebResponse ftpResponse;

            xDoc = new XmlDocument();

            ProgressForm formPB = new ProgressForm();

            formPB.Show();

            try
            {
                formPB.Text  = "Downloading Database";
                formPB.Value = 0;
                formPB.Refresh();

                #region Attempt to download plugin database file
                try
                {
                    // Create a request for the database file
                    ftpRequest = (FtpWebRequest)WebRequest.Create(pluginsFTPdbFile);
                    // Set default authentication for retrieving the file info
                    ftpRequest.Credentials = new NetworkCredential(updateFTPName, updateFTPPass);

                    ftpRequest.Method = WebRequestMethods.Ftp.GetFileSize;
                    ftpResponse       = (FtpWebResponse)ftpRequest.GetResponse();
                    // Ask the server for the file size and store it
                    long fileSize = ftpResponse.ContentLength;
                    ftpResponse.Close();

                    WebClient wc = new WebClient();
                    wc.Credentials = ftpRequest.Credentials;
                    xDoc.LoadXml(wc.DownloadString(pluginsFTPdbFile));
                }
                catch
                {
                    xDoc.AppendChild(xDoc.CreateElement("Plugins"));
                }
                #endregion

                formPB.Text = "Check File Dates/Times";
                #region Retrieve list of all files & directories from FTP server
                try
                {
                    // Create a request to the directory we are working in
                    ftpRequest = (FtpWebRequest)WebRequest.Create(pluginsFTPServer);
                    // Set default authentication for retrieving the file info
                    ftpRequest.Credentials = new NetworkCredential(updateFTPName, updateFTPPass);
                    ftpRequest.Method      = WebRequestMethods.Ftp.ListDirectoryDetails;
                    ftpResponse            = (FtpWebResponse)ftpRequest.GetResponse();
                    StreamReader streamReader = new StreamReader(ftpResponse.GetResponseStream());

                    List <string> files = new List <string>();
                    string        line  = streamReader.ReadLine();
                    while (!string.IsNullOrEmpty(line))
                    {
                        files.Add(line);
                        line = streamReader.ReadLine();
                    }

                    foreach (string s in files)
                    {
                        formPB.Value = files.IndexOf(s) * 100 / files.Count;
                        formPB.Refresh();
                        if (s[0].ToString().ToLower() == "d")
                        {
                            continue;
                        }

                        // Create a request to the directory we are working in
                        ftpRequest             = (FtpWebRequest)WebRequest.Create(pluginsFTPServer + s.Substring(62));
                        ftpRequest.Credentials = new NetworkCredential(updateFTPName, updateFTPPass);
                        ftpRequest.Method      = WebRequestMethods.Ftp.GetDateTimestamp;
                        ftpResponse            = (FtpWebResponse)ftpRequest.GetResponse();
                        DateTime dt = ftpResponse.LastModified;
                        listing.Add(new FileData(s, dt));
                        ftpResponse.Close();
                    }
                }
                catch (Exception ex)
                {
                }
                #endregion

                HashSet <string> hashTable  = new HashSet <string>();
                bool             xDocChange = false;
                foreach (FileData fd in listing)
                {
                    // We only want files (non-directories)
                    if ((fd.attrib | FileAttributes.Directory) != FileAttributes.Directory)
                    {
                        string[] fName        = fd.name.ToLower().Split('.', '-');
                        string   modifiedName = fName[0].Replace('!', '_').Replace('+', '_');

                        #region Update information box
                        formPB.Text  = "Analyzing: \n" + fd.name;
                        formPB.Value = listing.IndexOf(fd) * 100 / listing.Count;
                        formPB.Refresh();
                        #endregion

                        if (fName[fName.Length - 1] != "ent")
                        {
                            continue;
                        }

                        /*
                         * if (fName.Length > 3)
                         * {
                         *  string ver = fName[1];
                         *  for (int i = 2; i < fName.Length - 1; i++)
                         *      ver += '.' + fName[i];
                         *  fVer = new Version(ver);
                         * }
                         */

                        // Check for the matching tag HASHCODE name
                        XmlNodeList xnl   = null;
                        XmlNode     xNode = null;

                        if (fName.Length > 2)
                        {
                            xnl = xDoc.GetElementsByTagName("_" + fName[1]);
                        }


                        // Search through each return value for the one in the desired parent TAG TYPE
                        if (xnl != null && xnl.Count > 0)
                        {
                            foreach (XmlNode xn in xnl)
                            {
                                if (xn.ParentNode.Name == modifiedName)
                                {
                                    xNode = xn;
                                    break;
                                }
                            }
                        }

@updatePlugin:
                        // If we do not get any results for the HASHCODE, check for parent TAG TYPE
                        if (xNode == null)
                        {
                            // Search for a matching TAG TYPE
                            XmlNodeList xml = xDoc.GetElementsByTagName(modifiedName);

                            // No matching TAG TYPE was found, so create a tag placeholder (eg. SCNR)
                            if (xml.Count == 0)
                            {
                                xNode = xDoc.CreateElement(modifiedName);
                                xDoc.FirstChild.AppendChild(xNode);
                            }
                            // We found a matching TAG TYPE, so select it
                            else
                            {
                                xNode = xml[0];
                            }

                            // Retrieve the plugin from the server & parse for needed info
                            WebClient wc = new WebClient();
                            wc.Credentials = new NetworkCredential(updateFTPName, updateFTPPass);
                            try
                            {
                                string      tempPlugin = wc.DownloadString(pluginsFTPServer + fd.name);
                                XmlDocument xd         = new XmlDocument();
                                xd.LoadXml(tempPlugin);
                                XmlNodeList XList;
                                XmlNode     xnA; // Holds author attribute info
                                XmlNode     xnV; // Holds version attribute info
                                string      tag;

                                try
                                {
                                    XList = xd.GetElementsByTagName("revision");
                                    xnA   = XList[0].Attributes.GetNamedItem("author");
                                    xnV   = XList[0].Attributes.GetNamedItem("version");
                                    try
                                    {
                                        XList = xd.GetElementsByTagName("plugin");
                                        tag   = XList[0].Attributes.GetNamedItem("class").Value;
                                    }
                                    catch
                                    {
                                        tag = fName[0].ToLower();
                                    }
                                }
                                catch
                                {
                                    try
                                    {
                                        XList = xd.GetElementsByTagName("plugin");
                                        xnA   = XList[0].Attributes.GetNamedItem("author");
                                        xnV   = XList[0].Attributes.GetNamedItem("version");
                                        tag   = XList[0].Attributes.GetNamedItem("class").Value;
                                    }
                                    catch
                                    {
                                        // Bad plugin?
                                        continue;
                                    }
                                }

                                //
                                // Need to generate name first & will rename later
                                //
                                System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
                                string md5 = GetChecksum(encoding.GetBytes(tempPlugin));

                                if (fName.Length > 2)
                                {
                                    xNode = xNode.AppendChild(xDoc.CreateElement("_" + fName[1]));
                                }
                                else
                                {
                                    xNode = xNode.AppendChild(xDoc.CreateElement("_---"));
                                }

                                // Append author & version to xNode
                                // (This needs to be after the xNode is possibly set to xNode.Child)

                                // MD5 Hashcode
                                XmlAttribute xAttr = xDoc.CreateAttribute("md5");
                                xAttr.InnerText = md5;
                                xNode.Attributes.Append(xAttr);

                                // Author info
                                xAttr           = xDoc.CreateAttribute("tagtype");
                                xAttr.InnerText = tag;
                                xNode.Attributes.Append(xAttr);

                                // Author info
                                xAttr           = xDoc.CreateAttribute("author");
                                xAttr.InnerText = xnA.Value;
                                xNode.Attributes.Append(xAttr);

                                // Version info
                                xAttr           = xDoc.CreateAttribute("version");
                                xAttr.InnerText = xnV.Value;
                                xNode.Attributes.Append(xAttr);

                                // States that changes need to be made to database file
                                xDocChange = true;
                            }
                            catch (Exception ex)
                            {
                                Globals.Global.ShowErrorMsg("Error from plugin server: ", ex);
                            }
                        }
                        PluginData pd = new PluginData(fd, xNode);
                        if (pd.md5 == string.Empty)
                        {
                            xNode = null;
                            goto @updatePlugin;
                        }
                        if (hashTable.Contains(pd.md5))
                        {
                            // Duplicate file found, erase file & remove entry
                            try
                            {
                                ftpRequest = (FtpWebRequest)WebRequest.Create(pluginsFTPServer + fd.name);
                                // Set default authentication for retrieving the file info
                                ftpRequest.Credentials = new NetworkCredential(updateFTPName, updateFTPPass);

                                ftpRequest.Method = WebRequestMethods.Ftp.DeleteFile;
                                ftpResponse       = (FtpWebResponse)ftpRequest.GetResponse();
                                // Ask the server for the file size and store it
                                ftpResponse.Close();
                                xDocChange = true;
                            }
                            catch
                            { }
                            continue;
                        }

                        hashTable.Add(pd.md5);

                        // 1827
                        // "_fx_-87943969.ent"
                        // {27/10/2012 1:49:00 AM}
                        // "Grimdoomer"
                        // "0.99"

                        // Create a unique short hash code for this plugin using author, version & file date/time stamp
                        string hashcode = pd.GetHashCode().ToString();
                        string fileName = fName[0] + '-' + hashcode + ".ent";
                        if (fd.name.ToLower() != fileName)
                        {
                            // Rename the node to reflect the [new] hashcode
                            if (xNode.Name != "_" + hashcode)
                            {
                                xNode = RenameNode(xNode, string.Empty, '_' + hashcode);
                            }
                            #region Rename file to naming sequence
                            // Create a request to the directory we are working in
                            ftpRequest = (FtpWebRequest)WebRequest.Create(pluginsFTPServer + fd.name);
                            // Set default authentication for retrieving the file info
                            ftpRequest.Credentials = new NetworkCredential(updateFTPName, updateFTPPass);
                            ftpRequest.Method      = WebRequestMethods.Ftp.Rename;
                            ftpRequest.RenameTo    = fileName;
                            ftpResponse            = (FtpWebResponse)ftpRequest.GetResponse();
                            ftpResponse.Close();
                            #endregion
                            fd.name = fileName;
                        }

                        if (pd.version == "0.0")
                        {
                            int a = 0;
                        }
                        this.Add(fName[0], pd);
                    }
                }
                if (xDocChange)
                {
                    // WriteXDoc back out
                    WebClient wc = new WebClient();
                    wc.Credentials = new NetworkCredential(updateFTPName, updateFTPPass);
                    wc.UploadString(pluginsFTPdbFile, xDoc.InnerXml);
                }
            }
            finally
            {
                // Clean up our loading form
                formPB.Dispose();
            }
        }
Exemple #18
0
        private void _miWiaAcquire_Click(object sender, System.EventArgs e)
        {
            WiaAcquireFlags flags        = WiaAcquireFlags.None;
            bool            showProgress = true;

            _progressDlg = new ProgressForm(DemosGlobalization.GetResxString(GetType(), "Resx_Transferring"), "", 100);

            _wiaAcquiring = true;

            if (_showUserInterface)
            {
                flags = WiaAcquireFlags.UseCommonUI | WiaAcquireFlags.ShowUserInterface;
            }
            else
            {
                // Check if the selected device is scanner and that it has multiple sources (Feeder & Flatbed)
                // then show the select source dialog box.
                if (SelectAcquireSource() != DialogResult.OK)
                {
                    _wiaAcquiring = false;
                    return;
                }
            }

            if (_showUserInterface)
            {
                if (_wiaVersion == WiaVersion.Version2)
                {
                    showProgress = false;
                }
            }

            if (showProgress)
            {
                // Show the progress dialog.
                _progressDlg.Show(this);
            }

            try
            {
                _wiaSession.AcquireOptions = _wiaAcquireOptions;

                if (_wiaProperties.DataTransfer.TransferMode == WiaTransferMode.None) // GetProperties() method not called yet.
                {
                    _transferMode = WiaTransferMode.Memory;
                }
                else
                {
                    _transferMode = _wiaProperties.DataTransfer.TransferMode;
                }

                // Disable the minimize and maximize buttons.
                this.MinimizeBox = false;
                this.MaximizeBox = false;

#if !LEADTOOLS_V19_OR_LATER
                DialogResult dialogResult = _wiaSession.Acquire(this, _sourceItem, flags);
#else
                DialogResult dialogResult = _wiaSession.Acquire(this.Handle, _sourceItem, flags);
#endif // #if !LEADTOOLS_V19_OR_LATER
                if (dialogResult != DialogResult.OK)
                {
                    return;
                }

                // Enable back the minimize and maximize buttons.
                this.MinimizeBox = true;
                this.MaximizeBox = true;

                if (_progressDlg.Visible)
                {
                    if (!_progressDlg.Abort)
                    {
                        _progressDlg.Dispose();
                    }
                }

                if (_sourceItem != null)
                {
                    _sourceItem = null;
                }

                if (_wiaSession.FilesCount > 0) // This property indicates how many files where saved when the transfer mode is File mode.
                {
                    string strMsg = DemosGlobalization.GetResxString(GetType(), "Resx_PagesSavedTo") + "\n\n";
                    if (_wiaSession.FilesPaths.Count > 0)
                    {
                        for (int i = 0; i < _wiaSession.FilesPaths.Count; i++)
                        {
                            string strTemp = string.Format("{0}\n", _wiaSession.FilesPaths[i]);
                            strMsg += strTemp;
                        }
                        MessageBox.Show(this, strMsg, DemosGlobalization.GetResxString(GetType(), "Resx_FileTransfer"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    // WIA 2.0 sometimes doesn't return the acquired files count and paths, so this message will show
                    // the directory where the saved files were saved.
                    if (_wiaVersion == WiaVersion.Version2)
                    {
                        int    len = _wiaAcquireOptions.FileName.LastIndexOf('\\');
                        string strFilesDirectory = _wiaAcquireOptions.FileName.Substring(0, len);
                        string strMsg            = string.Format(DemosGlobalization.GetResxString(GetType(), "Resx_PagesSavedTo") + "\n\n{0}", strFilesDirectory);
                        MessageBox.Show(this, strMsg, DemosGlobalization.GetResxString(GetType(), "Resx_FileTransfer"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }

                _wiaAcquiring = false;
            }
            catch (Exception ex)
            {
                // Enable back the minimize and maximize buttons.
                this.MinimizeBox = true;
                this.MaximizeBox = true;

                _wiaAcquiring = false;
                if (_progressDlg.Visible)
                {
                    if (!_progressDlg.Abort)
                    {
                        _progressDlg.Dispose();
                    }
                }

                Messager.ShowError(this, ex);
            }
            finally
            {
                // Enable back the minimize and maximize buttons.
                this.MinimizeBox = true;
                this.MaximizeBox = true;

                _wiaAcquiring = false;
            }
        }
        public void Run(CommandArgs args)
        {
            var form = new ExportSettingForm()
            {
                ScriptPath       = Config.ScriptPath,
                PmxExportDirPath = Config.PmxExportDirPath,
                VmdExportDirPath = Config.VmdExportDirPath,
                KeepLogOpen      = Config.KeepLogOpen,
                DropPmxFile      = Config.DropPmxFile,
                DropVmdFile      = Config.DropVmdFile,
            };

            form.ShowDialog(ApplicationForm);

            if (form.DialogResult == DialogResult.OK)
            {
                Config.ScriptPath       = form.ScriptPath;
                Config.PmxExportDirPath = form.PmxExportDirPath;
                Config.VmdExportDirPath = form.VmdExportDirPath;
                Config.KeepLogOpen      = form.KeepLogOpen;
                Config.DropPmxFile      = form.DropPmxFile;
                Config.DropVmdFile      = form.DropVmdFile;

                ProgressForm progressForm = new ProgressForm();

                Task.Factory.StartNew(progressForm.ShowDialog);

                using (StreamWriter sw = new StreamWriter("lastest.log", false, Encoding.UTF8)
                {
                    AutoFlush = false
                })
                {
                    Console.SetOut(sw);
                    PythonExecutor.SetOut(sw.BaseStream);

                    RunScript(Config.ScriptPath, progressForm, Finalize);

                    void Finalize()
                    {
                        sw.Flush();
                        sw.Dispose();

                        StreamWriter standardOutput = new StreamWriter(Console.OpenStandardOutput())
                        {
                            AutoFlush = true
                        };

                        Console.SetOut(standardOutput);
                        PythonExecutor.SetOut(standardOutput.BaseStream);

                        if (!form.IsDisposed)
                        {
                            progressForm.LogTextBox.Text = File.ReadAllText("lastest.log");
                        }
                    }

                    if (!Config.KeepLogOpen)
                    {
                        progressForm.Dispose();
                    }
                }
            }
        }
Exemple #20
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            ProgressForm pForm = new ProgressForm();
            pForm.Show();
            dgvPluginData.Sort( dgvPluginData.Columns[0], ListSortDirection.Descending);
            int i = -1; int count = 0;
            while (++i < dgvPluginData.RowCount && (bool)dgvPluginData[0, i].Value == true)
            {
                PluginData pd = (PluginData)dgvPluginData.Rows[i].Tag;
                string localName = pd.tagType + ".ent";
                pForm.Text = "updating " + localName;
                pForm.Value = count++ * 100 / totalChecked;
                pForm.Refresh();

                WebClient wc = new WebClient();
                wc.Credentials = new NetworkCredential(updateFTPName, updateFTPPass);
                try
                {
                    wc.DownloadFile(
                        pluginsFTPServer + pd.fileData.name,
                        Globals.Prefs.pathPluginsFolder + "\\" + localName
                        );
                }
                catch (Exception ex)
                {
                    Globals.Global.ShowErrorMsg("Error downloading plugin", ex);
                }
            }
            pForm.Dispose();

            HaloMap.Plugins.IFPHashMap.H1IFPHash.Clear();
            HaloMap.Plugins.IFPHashMap.H2IFPHash.Clear();
        }