コード例 #1
0
        /// <summary>
        /// Updates the Restore folder location of those db files whose orginal directory location
        /// is not present in the destination computer.
        /// </summary>
        internal void UpdateDBFilesPhysicalRelocate()
        {
            foreach (DbFile item in DbFiles)
            {
                string fileName = this.GetTargetDbFilePhysicalName(item.PhysicalName);
                item.PhysicalNameRelocate = PathWrapper.Combine(PathWrapper.GetDirectoryName(item.PhysicalName),
                                                                fileName);
                Uri  pathUri;
                bool fUriCreated = Uri.TryCreate(item.PhysicalNameRelocate, UriKind.Absolute, out pathUri);
                if ((!fUriCreated || pathUri.Scheme != Uri.UriSchemeHttps) &&
                    !Directory.Exists(Path.GetDirectoryName(item.PhysicalNameRelocate)))
                {
                    string directoryPath = string.Empty;
                    if (string.Compare(item.DbFileType, SR.Log, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        directoryPath = Util.GetDefaultLogFileFolder();
                    }
                    else
                    {
                        directoryPath = Util.GetDefaultDataFileFolder();
                    }

                    item.PhysicalNameRelocate = PathWrapper.Combine(directoryPath, fileName);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Check if the folder path exists
        /// </summary>
        /// <param name="connection">sql connection</param>
        /// <param name="filePath">full file path</param>
        /// <returns></returns>
        internal static string IsFolderPathExisting(SqlConnection connection, string filePath)
        {
            string folderPath   = PathWrapper.GetDirectoryName(filePath);
            string errorMessage = string.Empty;

            if (string.IsNullOrEmpty(folderPath))
            {
                errorMessage = SR.InvalidBackupPathError;
            }
            else if (string.Compare(GetMachineName(connection.DataSource), Environment.MachineName, StringComparison.OrdinalIgnoreCase) == 0 &&
                     !Directory.Exists(folderPath))
            {
                errorMessage = SR.InvalidBackupPathError;
            }
            else
            {
                bool isFolderOnRemote;
                bool existsOnRemote = IsPathExisting(connection, folderPath, out isFolderOnRemote);
                if (!existsOnRemote)
                {
                    errorMessage = SR.InvalidBackupPathError;
                }
            }

            return(errorMessage);
        }
コード例 #3
0
        private string PathToPlugins()
        {
            var assemblyLocation  = typeof(PluginHandler).Assembly.Location;
            var assemblyDirectory = pathWrapper.GetDirectoryName(assemblyLocation);
            var root = pathWrapper.Combine(assemblyDirectory, "..", "..", "..", "..", "..", "Plugins");

            return(root);
        }
コード例 #4
0
        /// <summary>
        /// Returns the folder where result files should be written
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static string GetResultsFolder(this VisualStudio.TestTools.UnitTesting.TestContext context)
        {
            var path = Environment.GetEnvironmentVariable("RESULTS_FOLDER");

            if (string.IsNullOrEmpty(path))
            {
                path = context.Properties.ContainsKey("resultsFolder") ? context.Properties["resultsFolder"].ToString() : null;
            }
            if (string.IsNullOrEmpty(path))
            {
                path = PathWrapper.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                path = PathWrapper.Combine(path, "results");
            }
            return(path);
        }
コード例 #5
0
        /// <summary>
        /// Get the initial directory for the browse folder dialog
        /// </summary>
        /// <param name="serverConnection">The connection to the server</param>
        /// <returns></returns>
        public static string GetBrowseStartPath(ServerConnection serverConnection)
        {
            string result = String.Empty;

            // if (US.Current.SSMS.TaskForms.ServerFileSystem.LastPath.TryGetValue(serverConnection.TrueName, out result))
            // {
            //     return result;
            // }

            if ((result == null) || (result.Length == 0))
            {
                // try and fetch the default location from SMO...
                Microsoft.SqlServer.Management.Smo.Server server = new Microsoft.SqlServer.Management.Smo.Server(serverConnection);
                result = server.Settings.DefaultFile;

                if ((result == null) || (result.Length == 0))
                {
                    // if the default file property doesn't return a string,
                    // use the location of the model database's data file.
                    Enumerator enumerator = new Enumerator();
                    Request    request    = new Request();
                    request.Urn    = "Server/Database[@Name='model']/FileGroup[@Name='PRIMARY']/File";
                    request.Fields = new string[1] {
                        "FileName"
                    };
                    DataSet dataSet = enumerator.Process(serverConnection, request);

                    if (0 < dataSet.Tables[0].Rows.Count)
                    {
                        string path = dataSet.Tables[0].Rows[0][0].ToString();
                        result = PathWrapper.GetDirectoryName(path);
                    }
                }
            }

            return(result);
        }
コード例 #6
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        internal static void Initialize()
        {
            TraceService.WriteLine("NinjaController::Initialize");

            try
            {
                if (initialized == false)
                {
                    TraceService.WriteLine("NinjaController::Initialize AutoRegister");

                    //// only auto register classes in this assembly.
                    TinyIoCContainer container = TinyIoCContainer.Current;

                    string location = Assembly.GetExecutingAssembly().Location;

                    TraceService.WriteLine("NinjaController::Initialize Assembly Location=" + location);

                    PathBase pathBase  = new PathWrapper();
                    string   directory = pathBase.GetDirectoryName(location);

                    TraceService.WriteLine("NinjaController::Initialize NinjaCoder.MvvmCross.dll");

                    string path = directory + @"\NinjaCoder.MvvmCross.dll";

                    if (File.Exists(path))
                    {
                        //// NinjaCoder for MvvmCross interfaces.
                        container.AutoRegister(Assembly.LoadFrom(path));
                    }
                    else
                    {
                        TraceService.WriteError(path + " does not exist");
                    }

                    //// we only want one instance of the VisualStudio class.
                    container.Register <VisualStudioService>().AsSingleton();

                    //// register the types that aren't auto-registered by TinyIoC.
                    container.Register <ITranslator <string, CodeConfig> >(new CodeConfigTranslator());
                    container.Register <ITranslator <string, CodeSnippet> >(new CodeSnippetTranslator());
                    container.Register <ITranslator <XElement, Plugin> >(new PluginTranslator());
                    container.Register <ITranslator <string, Plugins> >(new PluginsTranslator());
                    container.Register <ITranslator <string, CommandsList> >(new CommandsListTranslator());
                    container.Register <ITranslator <string, CustomRenderers> >(new CustomRenderersTranslator());

                    //// file io abstraction
                    container.Register <IFileSystem>(new FileSystem());

                    TraceService.WriteLine("NinjaController::Initialize Scorchio.Infrastructure.dll");

                    path = directory + @"\Scorchio.Infrastructure.dll";

                    if (File.Exists(path))
                    {
                        //// Scorchio.Infrastructure interfaces.
                        container.AutoRegister(Assembly.LoadFrom(path));
                    }
                    else
                    {
                        TraceService.WriteError(path + " does not exist");
                    }

                    TraceService.WriteLine("NinjaController::Initialize AccentTranslator");

                    //// register the types that aren't auto-registered by TinyIoC.
                    container.Register <ITranslator <IList <Accent>, IEnumerable <AccentColor> > >(new AccentTranslator());

                    TraceService.WriteLine("NinjaController::Initialize Scorchio.VisualStudio.dll");

                    path = directory + @"\Scorchio.VisualStudio.dll";

                    if (File.Exists(path))
                    {
                        //// Scorchio.VisualStudio interfaces.
                        container.AutoRegister(Assembly.LoadFrom(path));
                    }
                    else
                    {
                        TraceService.WriteError(path + " does not exist");
                    }

                    initialized = true;
                }

                TraceService.WriteLine("NinjaController::Initialize end");
            }
            catch (ReflectionTypeLoadException exception)
            {
                TraceService.WriteError("ReflectionTypeLoadException=" + exception);

                foreach (Exception ex in exception.LoaderExceptions)
                {
                    TraceService.WriteError("ReflectionTypeLoadException=" + ex);
                }
            }
            catch (Exception exception)
            {
                TraceService.WriteError("Exception=" + exception);

                if (exception.InnerException != null)
                {
                    ReflectionTypeLoadException loadException = exception.InnerException as ReflectionTypeLoadException;

                    if (loadException != null)
                    {
                        foreach (Exception ex in loadException.LoaderExceptions)
                        {
                            TraceService.WriteError("ReflectionTypeLoadException=" + ex);
                        }
                    }
                }
            }
        }