src/Misc/EFTools/EntityDesign/VisualStudio/ModelWizard/gui/WizardPageDbConfig.cs
// <summary>
//     Prompts the user to copy the database file into the project if appropriate
// </summary>
// <returns>whether wizard should continue to next page</returns>
Prompts the user to copy the database file into the project if appropriate
Prompts the user to copy the database file into the project if appropriate
private bool PromptConvertLocalConnection()
        {
            if (!LocalDataUtil.IsLocalDbFileConnectionString(
                Wizard.ModelBuilderSettings.DesignTimeProviderInvariantName,
                Wizard.ModelBuilderSettings.DesignTimeConnectionString))
            {
                return true;
            }
            var filePath = LocalDataUtil.GetLocalDbFilePath(
                Wizard.ModelBuilderSettings.DesignTimeProviderInvariantName,
                Wizard.ModelBuilderSettings.DesignTimeConnectionString);
            if (!string.IsNullOrEmpty(filePath))
            {
                var projectItemCollection = LocalDataUtil.GetDefaultCollectionForLocalDataFile(Wizard.ServiceProvider, Wizard.Project);
                var targetPath = VsUtils.ConstructTargetPathForDatabaseFile(
                    Wizard.Project, projectItemCollection, Path.GetFileName(filePath));
                if (File.Exists(targetPath))
                {
                    return true;
                }
            }
            if (LocalDataUtil.IsSqlMobileDeviceConnectionString(
                Wizard.ModelBuilderSettings.DesignTimeProviderInvariantName,
                Wizard.ModelBuilderSettings.DesignTimeConnectionString))
            {
                return true;
            }
            var result = VsUtils.ShowMessageBox(
                Wizard.ServiceProvider,
                Resources.LocalDataConvertConnectionText,
                OLEMSGBUTTON.OLEMSGBUTTON_YESNO,
                OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
                OLEMSGICON.OLEMSGICON_QUERY);
            if (DialogResult.Yes != result)
            {
                return true;
            }
            try
            {
                return CopyFileIntoProjectAndConvertConnectionString(filePath);
            }
            catch (FileCopyException e)
            {
                var errMsgWithInnerExceptions = VsUtils.ConstructInnerExceptionErrorMessage(e);
                var errMsg = string.Format(
                    CultureInfo.CurrentCulture, Resources.LocalDataExceptionCopyingFile, e.GetType().FullName, filePath,
                    errMsgWithInnerExceptions);
                VsUtils.ShowErrorDialog(errMsg);
                return false;
            }
        }
private bool PromptConvertLocalConnection ( ) { if ( ! LocalDataUtil . IsLocalDbFileConnectionString ( Wizard . ModelBuilderSettings . DesignTimeProviderInvariantName , Wizard . ModelBuilderSettings . DesignTimeConnectionString ) ) { return true ; } var filePath = LocalDataUtil . GetLocalDbFilePath ( Wizard . ModelBuilderSettings . DesignTimeProviderInvariantName , Wizard . ModelBuilderSettings . DesignTimeConnectionString ) ; if ( ! string . IsNullOrEmpty ( filePath ) ) { var projectItemCollection = LocalDataUtil . GetDefaultCollectionForLocalDataFile ( Wizard . ServiceProvider , Wizard . Project ) ; var targetPath = VsUtils . ConstructTargetPathForDatabaseFile ( Wizard . Project , projectItemCollection , Path . GetFileName ( filePath ) ) ; if ( File . Exists ( targetPath ) ) { return true ; } } if ( LocalDataUtil . IsSqlMobileDeviceConnectionString ( Wizard . ModelBuilderSettings . DesignTimeProviderInvariantName , Wizard . ModelBuilderSettings . DesignTimeConnectionString ) ) { return true ; } var result = VsUtils . ShowMessageBox ( Wizard . ServiceProvider , Resources . LocalDataConvertConnectionText , OLEMSGBUTTON . OLEMSGBUTTON_YESNO , OLEMSGDEFBUTTON . OLEMSGDEFBUTTON_FIRST , OLEMSGICON . OLEMSGICON_QUERY ) ; if ( DialogResult . Yes != result ) { return true ; } try { return CopyFileIntoProjectAndConvertConnectionString ( filePath ) ; } catch ( FileCopyException e ) { var errMsgWithInnerExceptions = VsUtils . ConstructInnerExceptionErrorMessage ( e ) ; var errMsg = string . Format ( CultureInfo . CurrentCulture , Resources . LocalDataExceptionCopyingFile , e . GetType ( ) . FullName , filePath , errMsgWithInnerExceptions ) ; VsUtils . ShowErrorDialog ( errMsg ) ; return false ; } }
Prompts the user to copy the database file into the project if appropriate
Prompts the user to copy the database file into the project if appropriate
// first check whether connection is Local // if connection is Local but has already been copied into the project should not prompt // Special case -- Check if this is a SQL Mobile Device // For mobile devices, if the connection starts with 'Mobile Device' it means that the connection // refers to a location on the device itself. Do not perform conversion. // ask user if they want to copy
whether wizard should continue to next page
whether wizard should continue to next page