src/Misc/EFTools/EntityDesign/VisualStudio/ModelWizard/gui/WizardPageDbConfig.cs
// <summary>
//     Copies the local file into the project
// </summary>
// <param name="filePath">Path to file to copy</param>
// <returns>whether the copy is successful</returns>
Copies the local file into the project
Copies the local file into the project
[SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsTrackProjectDocuments3.HandsOffFiles(System.UInt32,System.Int32,System.String[])")]
        private bool CopyFileIntoProjectAndConvertConnectionString(string filePath)
        {
            try
            {
                var serviceProvider = Wizard.ServiceProvider;
                var project = Wizard.Project;
                var vsTrackProjectDocuments = serviceProvider.GetService(typeof(SVsTrackProjectDocuments)) as IVsTrackProjectDocuments3;
                if (null == vsTrackProjectDocuments)
                {
                    Debug.Fail("Could not get IVsTrackProjectDocuments3 from service provider.");
                }
                else
                {
                    vsTrackProjectDocuments.HandsOffFiles((uint)__HANDSOFFMODE.HANDSOFFMODE_ReadAccess, 1, new[] { filePath });
                }
                ProjectItem dbProjectItem = null;
                var targetProjectItemCollection = LocalDataUtil.GetDefaultCollectionForLocalDataFile(Wizard.ServiceProvider, project);
                dbProjectItem = VsUtils.BringDatabaseFileIntoProject(serviceProvider, project, targetProjectItemCollection, filePath);
                if (dbProjectItem == null)
                {
                    var errmsg = string.Format(CultureInfo.CurrentCulture, Resources.LocalDataErrorAddingFile, filePath, project.UniqueName);
                    throw new FileCopyException(errmsg);
                }
                var newFilePath = (string)dbProjectItem.Properties.Item("FullPath").Value;
                return RetargetConnectionString(newFilePath);
            }
            catch (COMException ex)
            {
                if (ex.ErrorCode == VSConstants.OLE_E_PROMPTSAVECANCELLED)
                {
                    return false;
                }
                else
                {
                    throw;
                }
            }
        }
[ SuppressMessage ( " " , " " , MessageId = " " ) ] private bool CopyFileIntoProjectAndConvertConnectionString ( string filePath ) { try { var serviceProvider = Wizard . ServiceProvider ; var project = Wizard . Project ; var vsTrackProjectDocuments = serviceProvider . GetService ( typeof ( SVsTrackProjectDocuments ) ) as IVsTrackProjectDocuments3 ; if ( null == vsTrackProjectDocuments ) { Debug . Fail ( " " ) ; } else { vsTrackProjectDocuments . HandsOffFiles ( ( uint ) __HANDSOFFMODE . HANDSOFFMODE_ReadAccess , 1 , new [ ] { filePath } ) ; } ProjectItem dbProjectItem = null ; var targetProjectItemCollection = LocalDataUtil . GetDefaultCollectionForLocalDataFile ( Wizard . ServiceProvider , project ) ; dbProjectItem = VsUtils . BringDatabaseFileIntoProject ( serviceProvider , project , targetProjectItemCollection , filePath ) ; if ( dbProjectItem == null ) { var errmsg = string . Format ( CultureInfo . CurrentCulture , Resources . LocalDataErrorAddingFile , filePath , project . UniqueName ) ; throw new FileCopyException ( errmsg ) ; } var newFilePath = ( string ) dbProjectItem . Properties . Item ( " " ) . Value ; return RetargetConnectionString ( newFilePath ) ; } catch ( COMException ex ) { if ( ex . ErrorCode == VSConstants . OLE_E_PROMPTSAVECANCELLED ) { return false ; } else { throw ; } } }
Copies the local file into the project
Copies the local file into the project
// File is not in the project and user wants to convert it. // releases any read locks on this file so we can read it // now re-target the connection string at the copied file // User canceled a checkout prompt.
whether the copy is successful
whether the copy is successful
filePath
string
Path to file to copy
Path to file to copy