Skip to content

Commit

Permalink
2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
teocomi committed Nov 6, 2015
1 parent 09ccb30 commit 559a977
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 35 deletions.
109 changes: 76 additions & 33 deletions RVTVersionerGUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public partial class MainWindow : Window

private static Regex FoundYear = new Regex(@"\s\d{4}\s");
private ObservableCollection<RevitFile> SourceCollection = new ObservableCollection<RevitFile>();
List<String> RevitFiles = new List<string>();

public MainWindow()
{
Expand Down Expand Up @@ -83,26 +84,26 @@ private void ProcessSourceFiles(string[] files)
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
string version = fvi.FileVersion;

List<String> RevitFiles = new List<string>();
RevitFiles = new List<string>();
var start = DateTime.Now;

//seach subdirectories for revit files
foreach (var s in files)
{
if (Directory.Exists(s))
RevitFiles.AddRange(
Directory
.EnumerateFiles(s)
.Where(
file =>
file.ToLower().EndsWith("rvt") || file.ToLower().EndsWith("rfa") ||
s.ToLower().EndsWith("rte") || s.ToLower().EndsWith("rtf"))
.ToList());
if (Directory.Exists(s))
{
RevitFiles.AddRange(Directory.GetFiles(s, "*.rvt", SearchOption.AllDirectories).ToList());
RevitFiles.AddRange(Directory.GetFiles(s, "*.rfa", SearchOption.AllDirectories).ToList());

//WalkDirectoryTree(new DirectoryInfo(s));
}

else if (File.Exists(s) &&
(s.ToLower().EndsWith("rvt") || s.ToLower().EndsWith("rfa") || s.ToLower().EndsWith("rte") ||
s.ToLower().EndsWith("rtf")))
(s.ToLower().EndsWith(".rvt") || s.ToLower().EndsWith(".rfa")))
RevitFiles.Add(s);

}
MessageBox.Show("Completed in "+(DateTime.Now-start).TotalSeconds.ToString() + " seconds.");
//user double clicked on the exe
if (files.Length == 0)
{
Expand Down Expand Up @@ -132,6 +133,46 @@ private void ProcessSourceFiles(string[] files)
MessageBox.Show(ex.Message);
}
}
private void WalkDirectoryTree(System.IO.DirectoryInfo root)
{
System.IO.FileInfo[] files = null;
System.IO.DirectoryInfo[] subDirs = null;

// First, process all the files directly under this folder
try
{
var dir = root.FullName;
RevitFiles.AddRange(
Directory
.EnumerateFiles(dir)
.Where(
file =>
file.ToLower().EndsWith("rvt") || file.ToLower().EndsWith("rfa"))
.ToList());
}
// This is thrown if even one of the files requires permissions greater
// than the application provides.
catch (UnauthorizedAccessException e)
{
}

catch (System.IO.DirectoryNotFoundException e)
{
Console.WriteLine(e.Message);
}
subDirs = root.GetDirectories();
if (subDirs != null)
{
// Now find all the subdirectories under this directory.
subDirs = root.GetDirectories();

foreach (System.IO.DirectoryInfo dirInfo in subDirs)
{
// Resursive call for each subdirectory.
WalkDirectoryTree(dirInfo);
}
}
}

private void Window_DragOver(object sender, DragEventArgs e)
{
Expand Down Expand Up @@ -418,9 +459,9 @@ public StructuredStorageRoot(Stream stream)
}
catch (Exception ex)
{
MessageBox.Show("Cannot get StructuredStorageRoot: " + ex.Message);
throw new StructuredStorageException(
"Cannot get StructuredStorageRoot", ex);
//MessageBox.Show("Cannot get StructuredStorageRoot: " + ex.Message);
//throw new StructuredStorageException(
// "Cannot get StructuredStorageRoot", ex);
}
}

Expand All @@ -435,33 +476,35 @@ public StructuredStorageRoot(string fileName)
}
catch (Exception ex)
{
MessageBox.Show("Cannot get StructuredStorageRoot: " + ex.Message);
throw new StructuredStorageException(
"Cannot get StructuredStorageRoot", ex);
//MessageBox.Show("Cannot get StructuredStorageRoot: " + ex.Message);
//throw new StructuredStorageException(
// "Cannot get StructuredStorageRoot", ex);
}
}

private static object InvokeStorageRootMethod(
StorageInfo storageRoot,
string methodName,
params object[] methodArgs)
private static object InvokeStorageRootMethod(StorageInfo storageRoot,string methodName,params object[] methodArgs)
{
Type storageRootType
= typeof (StorageInfo).Assembly.GetType(
"System.IO.Packaging.StorageRoot",
true, false);

try
{
Type storageRootType = typeof (StorageInfo).Assembly.GetType("System.IO.Packaging.StorageRoot",false, false);

object result = storageRootType.InvokeMember(
methodName,
BindingFlags.Static | BindingFlags.Instance
| BindingFlags.Public | BindingFlags.NonPublic
| BindingFlags.InvokeMethod,
null, storageRoot, methodArgs);
methodName,
BindingFlags.Static | BindingFlags.Instance
| BindingFlags.Public | BindingFlags.NonPublic
| BindingFlags.InvokeMethod,
null, storageRoot, methodArgs);

return result;
}
catch (Exception ex)
{
}
return null;
}

private void CloseStorageRoot()
private
void CloseStorageRoot()
{
InvokeStorageRootMethod(_storageRoot, "Close");
}
Expand Down
4 changes: 2 additions & 2 deletions RVTVersionerGUI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyVersion("2.1.0.0")]
[assembly: AssemblyFileVersion("2.1.0.0")]

0 comments on commit 559a977

Please sign in to comment.