Exemplo n.º 1
0
        private static void Treat(string path, int projectLength, Util.Enum.Action action)
        {
            try
            {
                string[] subdirectories = Directory.GetDirectories(path);

                string pathName = string.Format(@"{0}", path);

                foreach (string subdirectory in subdirectories)
                {
                    Treat(subdirectory, projectLength, action);
                }

                string newPath = string.Format(@"{0}{1}", path.Substring(0, projectLength), TreatDirectoryName(pathName.Substring(projectLength), action));

                if (!path.Equals(newPath))
                {
                    MoveElements(pathName, newPath);

                    DeleteDirectory(path);
                }
            }
            catch (Exception ex)
            {
                System.Console.ForegroundColor = ConsoleColor.Yellow;
                System.Console.WriteLine(string.Format("Error treating {0} file path. Exception: {1}", Path.GetFileName(path), ex.Message));
            }
        }
Exemplo n.º 2
0
        private static void TreatProjects(string path, Util.Enum.Action action)
        {
            string[] subdirectories = Directory.GetDirectories(path);

            string pathName = string.Format(@"{0}", path);

            foreach (string subdirectory in subdirectories)
            {
                try
                {
                    Treat(subdirectory, path.Length, action);
                }
                catch (Exception ex)
                {
                    System.Console.ForegroundColor = ConsoleColor.Yellow;
                    System.Console.WriteLine(string.Format("Error mounting new tree for directory {0} file path. Exception: {1}", path, ex.Message));
                }
            }

            DeleteEmptyDirectories(path);
        }
Exemplo n.º 3
0
        private static string TreatDirectoryName(string path, Util.Enum.Action action)
        {
            string result = path;

            GeodatascanBHP_Entities dbContext = new GeodatascanBHP_Entities();

            var sortedByActionListExpression = (from e in dbContext.Expression where e.Action == (int)action select e);

            foreach (Expression expressionAux in sortedByActionListExpression)
            {
                if (result.ToUpper().Contains(expressionAux.Description.ToUpper()))
                {
                    switch (expressionAux.Action)
                    {
                    case (int)Util.Enum.Action.REPLACE:

                        result = result.Replace(expressionAux.Description, expressionAux.Replacement);
                        result = result.Replace(expressionAux.Description.ToLower(), expressionAux.Replacement);
                        result = result.Replace(expressionAux.Description.ToUpper(), expressionAux.Replacement);

                        break;

                    case (int)Util.Enum.Action.DELETE:

                        result = result.Replace(expressionAux.Description, string.Empty);
                        result = result.Replace(expressionAux.Description.ToLower(), string.Empty);
                        result = result.Replace(expressionAux.Description.ToUpper(), string.Empty);

                        break;

                    default:
                        break;
                    }
                }
            }

            result = result.Replace(@"\\", @"\");

            return(result);
        }