private DialogResult PromptForCredentials()
        {
            DialogResult result = DialogResult.Cancel;

            // Prompt the user for credentials.
            using (PrintDriverCredentialForm credentialForm = new PrintDriverCredentialForm())
            {
                credentialForm.ShareLocation = RepositoryPath;
                result = credentialForm.ShowDialog();
                if (result == DialogResult.OK)
                {
                    RepositoryPath = credentialForm.ShareLocation; //The user may have changed the driver share location.
                }
            }

            return(result);
        }
        private bool LoadPrintDriverVersionsMombi()
        {
            string pattern    = @"evo\\.*?([\d\.]+).*$";
            bool   successful = true;

            try
            {
                using (AssetInventoryContext context = DbConnect.AssetInventoryContext())
                {
                    Collection <string> versions = new Collection <string>();

                    foreach (var directory in Directory.GetDirectories(GlobalSettings.Items[Setting.UniversalPrintDriverBaseLocation]))
                    {
                        // Parse the directory name and find the version number
                        Match match = Regex.Match(directory, pattern);

                        if (match.Success)
                        {
                            string version = match.Groups[1].Value;
                            if (!context.PrintDriverVersions.Any(x => x.Value.Equals(version)) &&
                                !versions.Any(x => x.Equals(version)))
                            {
                                versions.Add(version);
                            }
                        }
                    }

                    if (versions.Count > 0)
                    {
                        foreach (var version in versions)
                        {
                            PrintDriverVersion newVersion = new PrintDriverVersion();
                            newVersion.Value = version;
                            newVersion.PrintDriverVersionId = SequentialGuid.NewGuid();
                            context.PrintDriverVersions.Add(newVersion);
                        }

                        context.SaveChanges();
                        LoadVersionCheckList();
                        RefreshVersionCheckList();
                    }
                }
            }
            catch (IOException)
            {
                // Prompt the user for credentials.
                using (PrintDriverCredentialForm credentialForm = new PrintDriverCredentialForm())
                {
                    credentialForm.ShareLocation = GlobalSettings.Items[Setting.UniversalPrintDriverBaseLocation];
                    if (credentialForm.ShowDialog() == DialogResult.OK)
                    {
                        successful = LoadPrintDriverVersionsMombi();
                    }
                    else
                    {
                        successful = false;
                    }
                }
            }

            return(successful);
        }