// <summary> // Prompts the user to copy the database file into the project if appropriate // </summary> // <returns>whether wizard should continue to next page</returns> private bool PromptConvertLocalConnection() { // first check whether connection is Local if (!LocalDataUtil.IsLocalDbFileConnectionString( Wizard.ModelBuilderSettings.DesignTimeProviderInvariantName, Wizard.ModelBuilderSettings.DesignTimeConnectionString)) { return(true); } // if connection is Local but has already been copied into the project should not prompt 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); } } // Special case -- Check if this is a SQL Mobile Device if (LocalDataUtil.IsSqlMobileDeviceConnectionString( Wizard.ModelBuilderSettings.DesignTimeProviderInvariantName, Wizard.ModelBuilderSettings.DesignTimeConnectionString)) { // 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. return(true); } // ask user if they want to copy 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); } }