diff --git a/Assets/Thumbs.db b/Assets/Thumbs.db new file mode 100755 index 00000000..74a6ee90 Binary files /dev/null and b/Assets/Thumbs.db differ diff --git a/BCFier.exe b/BCFier.exe new file mode 100755 index 00000000..f97454a1 Binary files /dev/null and b/BCFier.exe differ diff --git a/Bcfier.Revit/Bcfier.Revit.csproj b/Bcfier.Revit/Bcfier.Revit.csproj index e4ad369e..750a3445 100644 --- a/Bcfier.Revit/Bcfier.Revit.csproj +++ b/Bcfier.Revit/Bcfier.Revit.csproj @@ -1,155 +1,153 @@ - - - - - Debug - AnyCPU - {2D132990-5674-42DF-93BF-55BA8FDC6A23} - Library - Properties - Bcfier.Revit - Bcfier.Revit - v4.5 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - - Program - C:\Program Files\Autodesk\Revit 2015\Revit.exe - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - - - - true - bin\ManualObfuscation\ - DEBUG;TRACE - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - false - - - - ..\..\..\Program Files\Autodesk\Revit 2016\RevitAPI.dll - False - - - ..\..\..\Program Files\Autodesk\Revit 2016\RevitAPIUI.dll - False - - - - - - - 4.0 - - - - - - - - AddViewRevit.xaml - - - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - - - - - RevitWindow.xaml - Code - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - Always - - - - - - - - {503ce2c1-09d7-4f15-bb42-86196ee01ed4} - Bcfier - True - - - - - - - - - - - + + + + + Debug + AnyCPU + {2D132990-5674-42DF-93BF-55BA8FDC6A23} + Library + Properties + Bcfier.Revit + Bcfier.Revit + v4.5 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + Program + C:\Program Files\Autodesk\Revit 2015\Revit.exe + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + true + bin\ManualObfuscation\ + DEBUG;TRACE + full + AnyCPU + prompt + MinimumRecommendedRules.ruleset + false + + + + C:\Program Files\Autodesk\Revit 2015\RevitAPI.dll + + + C:\Program Files\Autodesk\Revit 2015\RevitAPIUI.dll + + + + + + + 4.0 + + + + + + + + AddViewRevit.xaml + + + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + + + + + RevitWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + Always + + + + + + + + {503ce2c1-09d7-4f15-bb42-86196ee01ed4} + Bcfier + True + + + + + + + + + + + ::xcopy /Y "$(TargetDir)*.*" "C:\ProgramData\Autodesk\Revit\Addins\2015\$(ProjectName)\" ::copy "$(TargetDir)Bcfier.Revit.addin" "C:\ProgramData\Autodesk\Revit\Addins\2015\Bcfier.Revit.addin" - - + + + --> \ No newline at end of file diff --git a/Bcfier.Revit/Properties/AssemblyInfo.cs b/Bcfier.Revit/Properties/AssemblyInfo.cs old mode 100644 new mode 100755 index 5bc73e1f..0368afc7 --- a/Bcfier.Revit/Properties/AssemblyInfo.cs +++ b/Bcfier.Revit/Properties/AssemblyInfo.cs @@ -49,6 +49,6 @@ // 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.1.1")] -[assembly: AssemblyFileVersion("2.0.1.1")] +[assembly: AssemblyVersion("2.0.2")] +[assembly: AssemblyFileVersion("2.0.2")] [assembly: GuidAttribute("59068325-ACDC-4DB3-892A-1C90C9434BF8")] diff --git a/Bcfier.Revit/RevitWindow.xaml b/Bcfier.Revit/RevitWindow.xaml old mode 100644 new mode 100755 index 41fc0f30..0de0ebb5 --- a/Bcfier.Revit/RevitWindow.xaml +++ b/Bcfier.Revit/RevitWindow.xaml @@ -4,6 +4,7 @@ xmlns:ctr="clr-namespace:Bcfier.UserControls;assembly=Bcfier" xmlns:data="clr-namespace:Bcfier.Data;assembly=Bcfier" Title="BCFier for Revit" Width="700" Height="700" Name="mainWin" + Loaded="RevitWindow_OnLoaded" Closing="Window_Closing" Icon="Assets/icon.ico"> diff --git a/Bcfier.Revit/RevitWindow.xaml.cs b/Bcfier.Revit/RevitWindow.xaml.cs old mode 100644 new mode 100755 index 6bddf689..41d773f9 --- a/Bcfier.Revit/RevitWindow.xaml.cs +++ b/Bcfier.Revit/RevitWindow.xaml.cs @@ -10,6 +10,7 @@ using Autodesk.Revit.UI; using System.ComponentModel; +using System.Threading.Tasks; using Component = Bcfier.Bcf.Bcf2.Component; using Point = Bcfier.Bcf.Bcf2.Point; @@ -329,5 +330,14 @@ private void Window_Closing(object sender, CancelEventArgs e) e.Cancel = Bcfier.onClosing(e); } #endregion + + private void RevitWindow_OnLoaded(object sender, RoutedEventArgs e) + { + Task.Run(() => + { + StatHat.Post.EzCounter(@"hello@teocomi.com", "BCFierRevitStart", 1); + }); + } + } } \ No newline at end of file diff --git a/Bcfier.Win/MainWindow.xaml b/Bcfier.Win/MainWindow.xaml old mode 100644 new mode 100755 index 764573b2..40328204 --- a/Bcfier.Win/MainWindow.xaml +++ b/Bcfier.Win/MainWindow.xaml @@ -4,7 +4,7 @@ xmlns:ctr="clr-namespace:Bcfier.UserControls;assembly=Bcfier" xmlns:data="clr-namespace:Bcfier.Data;assembly=Bcfier" Title="BCFier for Windows" Width="700" Height="700" Name="mainWin" - + Loaded="MainWindow_OnLoaded" Closing="Window_Closing" Icon="Assets/icon.ico" > diff --git a/Bcfier.Win/MainWindow.xaml.cs b/Bcfier.Win/MainWindow.xaml.cs old mode 100644 new mode 100755 index 3f738f1b..c804c848 --- a/Bcfier.Win/MainWindow.xaml.cs +++ b/Bcfier.Win/MainWindow.xaml.cs @@ -2,6 +2,7 @@ using System.IO; using System.Windows; using System.ComponentModel; +using System.Threading.Tasks; using System.Windows.Input; using System.Windows.Threading; using Bcfier.Bcf.Bcf2; @@ -75,5 +76,12 @@ private void OnAddView(object sender, ExecutedRoutedEventArgs e) } #endregion + private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) + { + Task.Run(() => + { + StatHat.Post.EzCounter(@"hello@teocomi.com", "BCFierWinStart", 1); + }); + } } } \ No newline at end of file diff --git a/Bcfier.Win/Properties/AssemblyInfo.cs b/Bcfier.Win/Properties/AssemblyInfo.cs old mode 100644 new mode 100755 index 3d111298..61f1500b --- a/Bcfier.Win/Properties/AssemblyInfo.cs +++ b/Bcfier.Win/Properties/AssemblyInfo.cs @@ -49,6 +49,6 @@ // 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.1.1")] -[assembly: AssemblyFileVersion("2.0.1.1")] +[assembly: AssemblyVersion("2.0.2")] +[assembly: AssemblyFileVersion("2.0.2")] [assembly: GuidAttribute("9FC6BA85-A348-40B4-97C4-6699DA912C21")] diff --git a/Bcfier/Api/GitHubRest.cs b/Bcfier/Api/GitHubRest.cs old mode 100644 new mode 100755 index a0b87be9..958a8093 --- a/Bcfier/Api/GitHubRest.cs +++ b/Bcfier/Api/GitHubRest.cs @@ -33,19 +33,17 @@ internal static async Task> GetReleases(CancellationTokenSou return cancel.IsCancellationRequested || !CheckResponse(response, HttpStatusCode.OK) ? null : response.Data; } - internal static async Task GetLatestRelease(CancellationTokenSource cancel) - { - if (cancel.IsCancellationRequested) - return null; + internal static GitHubRelease GetLatestRelease() + { var request = new RestRequest("repos/teocomi/bcfier/releases/latest", Method.GET); request.AddHeader("Content-Type", "application/json"); request.RequestFormat = DataFormat.Json; - var response = await DoTaskAsync(request, cancel); + var response = Client.Execute (request); //if cancellation oending or invalid reponse return null, otherwise the data - return cancel.IsCancellationRequested || !CheckResponse(response, HttpStatusCode.OK) ? null : response.Data; + return !CheckResponse(response, HttpStatusCode.OK) ? null : response.Data; } private static async Task> DoTaskAsync(RestRequest request, CancellationTokenSource cancel) where T : class diff --git a/Bcfier/Api/StatHat.cs b/Bcfier/Api/StatHat.cs new file mode 100755 index 00000000..53364888 --- /dev/null +++ b/Bcfier/Api/StatHat.cs @@ -0,0 +1,358 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Net; + +namespace StatHat +{ + // Delegates + public delegate void ReplyDelegate(string reply); + + public static class Post + { + + // =================== + // How to use StatHat: + // =================== + // + // 1. Add StatHat.cs to your .NET project. + // 2. Call its functions! + // + // ----------------------------------------------------------------------------------- + // + // A simple example of posting a Counter: + // + // StatHat.Post.Counter("FERF34fREF3443432","23FSDfEFWFEF22323", 9.95); + // + // ----------------------------------------------------------------------------------- + // + // A simple example of posting a Value: + // + // StatHat.Post.Value("FERF34fREF3443432","23FSDfEFWFEF22323", 512.2); + // + // ----------------------------------------------------------------------------------- + // + // A simple example of posting a counter with our EZ API - this registers the stat automatically + // if it doesn't exist (and registers you for the site if you don't have a membership): + // + // StatHat.Post.EzCounter("you@example.com","dollars earned", 9.95); + // + // ----------------------------------------------------------------------------------- + // + // If you care to read what the server is replying to your call (for error handling, curiosity, etc.) + // you can pass a delegate function expecting a string for callback. Like so: + // + // + // // Here's some function I want StatHat to call with the reply: + // // --------------------------------------------------- + // void PrintStatHatReply(string reply) { Console.WriteLine(reply); } + // + // // Make a delegate out of it. + // // ----------------------------- + // StatHat.ReplyDelegate myDelegate = new StatHat.ReplyDelegate(PrintStatHatReply); + // + // // Pass that delegate as a parameter: + // // ---------------------------------- + // StatHat.Post.Counter("FERF34fREF3443432","23FSDfEFWFEF22323", 1.0, myDelegate); + // + // + + private const string BaseUrl = "http://api.stathat.com"; + + /// + /// Posts a counter increment to stathat over HTTP + /// + /// the stat's posting key + /// your user key + /// the number to increment + public static void Counter(string key, string ukey, float count) + { + Dictionary p = new Dictionary(); + p.Add("key", key); + p.Add("ukey", ukey); + p.Add("count", count.ToString()); + new FormPoster(Post.BaseUrl, "/c", p); + } + + + /// + /// Posts a counter increment to stathat over HTTP + /// + /// the stat's posting key + /// your user key + /// the number to increment + public static void Counter(string key, string ukey, int count) + { + Post.Counter(key, ukey, (float)count); + + } + /// + /// Posts a value to stathat over HTTP + /// + /// the stat's posting key + /// your user key + /// the number + public static void Value(string key, string ukey, float value) + { + Dictionary p = new Dictionary(); + p.Add("key", key); + p.Add("ukey", ukey); + p.Add("value", value.ToString()); + new FormPoster(Post.BaseUrl, "/v", p); + } + /// + /// Posts a value to stathat over HTTP + /// + /// the stat's posting key + /// your user key + /// the number + public static void Value(string key, string ukey, int value) + { + Post.Value(key, ukey, (float)value); + } + + /// + /// Posts a counter increment to stathat over HTTP using ez API - the stat and/or you don't have to be pre-registered + /// + /// your ezkey (defaults to email address). If you already have a stathat account, use the one associated with it. + /// the name for your stat + /// the number to increment + public static void EzCounter(string ezkey, string stat, float count) + { + Dictionary p = new Dictionary(); + p.Add("ezkey", ezkey); + p.Add("stat", stat); + p.Add("count", count.ToString()); + new FormPoster(Post.BaseUrl, "/ez", p); + } + + /// + /// Posts a counter increment to stathat over HTTP using ez API - the stat and/or you don't have to be pre-registered + /// + /// your ezkey (defaults to email address). If you already have a stathat account, use the one associated with it. + /// the name for your stat + /// the number to increment + public static void EzCounter(string ezkey, string stat, int count) + { + Post.EzCounter(ezkey, stat, (float)count); + } + + /// + /// Posts a counter increment to stathat over HTTP using ez API - the stat and/or you don't have to be pre-registered + /// + /// your ezkey (defaults to email address). If you already have a stathat account, use the one associated with it. + /// the name for your stat + /// the number + public static void EzValue(string ezkey, string stat, float value) + { + Dictionary p = new Dictionary(); + p.Add("ezkey", ezkey); + p.Add("stat", stat); + p.Add("value", value.ToString()); + new FormPoster(Post.BaseUrl, "/ez", p); + } + + /// + /// Posts a counter increment to stathat over HTTP using ez API - the stat and/or you don't have to be pre-registered + /// + /// your ezkey (defaults to email address). If you already have a stathat account, use the one associated with it. + /// the name for your stat + /// the number + public static void EzValue(string ezkey, string stat, int value) + { + Post.EzValue(ezkey, stat, (float)value); + } + + /// + /// Posts a counter increment to stathat over HTTP + /// + /// the stat's posting key + /// your user key + /// the number to increment + /// the function you'd like called with the reply from stathat's server + public static void Counter(string key, string ukey, float count, ReplyDelegate replyDelegate) + { + Dictionary p = new Dictionary(); + p.Add("key", key); + p.Add("ukey", ukey); + p.Add("count", count.ToString()); + new FormPoster(Post.BaseUrl, "/c", p, replyDelegate); + } + /// + /// Posts a counter increment to stathat over HTTP + /// + /// the stat's posting key + /// your user key + /// the number to increment + /// the function you'd like called with the reply from stathat's server + public static void Counter(string key, string ukey, int count, ReplyDelegate replyDelegate) + { + Post.Counter(key, ukey, (float)count, replyDelegate); + + } + /// + /// Posts a value to stathat over HTTP + /// + /// the stat's posting key + /// your user key + /// the number + /// the function you'd like called with the reply from stathat's server + public static void Value(string key, string ukey, float value, ReplyDelegate replyDelegate) + { + Dictionary p = new Dictionary(); + p.Add("key", key); + p.Add("ukey", ukey); + p.Add("value", value.ToString()); + new FormPoster(Post.BaseUrl, "/v", p, replyDelegate); + } + /// + /// Posts a value to stathat over HTTP + /// + /// the stat's posting key + /// your user key + /// the number + /// the function you'd like called with the reply from stathat's server + public static void Value(string key, string ukey, int value, ReplyDelegate replyDelegate) + { + Post.Value(key, ukey, (float)value, replyDelegate); + } + + /// + /// Posts a counter increment to stathat over HTTP using ez API - the stat and/or you don't have to be pre-registered + /// + /// your ezkey (defaults to email address). If you already have a stathat account, use the one associated with it. + /// the name for your stat + /// the number to increment + /// the function you'd like called with the reply from stathat's server + public static void EzCounter(string ezkey, string stat, float count, ReplyDelegate replyDelegate) + { + Dictionary p = new Dictionary(); + p.Add("ezkey", ezkey); + p.Add("stat", stat); + p.Add("count", count.ToString()); + new FormPoster(Post.BaseUrl, "/ez", p, replyDelegate); + } + + /// + /// Posts a counter increment to stathat over HTTP using ez API - the stat and/or you don't have to be pre-registered + /// + /// your ezkey (defaults to email address). If you already have a stathat account, use the one associated with it. + /// the name for your stat + /// the number to increment + /// the function you'd like called with the reply from stathat's server + public static void EzCounter(string ezkey, string stat, int count, ReplyDelegate replyDelegate) + { + Post.EzCounter(ezkey, stat, (float)count, replyDelegate); + } + + /// + /// Posts a counter increment to stathat over HTTP using ez API - the stat and/or you don't have to be pre-registered + /// + /// your ezkey (defaults to email address). If you already have a stathat account, use the one associated with it. + /// the name for your stat + /// the number + /// the function you'd like called with the reply from stathat's server + public static void EzValue(string ezkey, string stat, float value, ReplyDelegate replyDelegate) + { + Dictionary p = new Dictionary(); + p.Add("ezkey", ezkey); + p.Add("stat", stat); + p.Add("value", value.ToString()); + new FormPoster(Post.BaseUrl, "/ez", p, replyDelegate); + } + + /// + /// Posts a counter increment to stathat over HTTP using ez API - the stat and/or you don't have to be pre-registered + /// + /// your ezkey (defaults to email address). If you already have a stathat account, use the one associated with it. + /// the name for your stat + /// the number + /// the function you'd like called with the reply from stathat's server + public static void EzValue(string ezkey, string stat, int value, ReplyDelegate replyDelegate) + { + Post.EzValue(ezkey, stat, (float)value, replyDelegate); + } + + private class FormPoster + { + // Members + HttpWebRequest Request; + Dictionary Parameters; + ReplyDelegate Reply; + string RelUrl; + string BaseUrl; + + + // Methods + public FormPoster(string base_url, string rel_url, Dictionary parameters, ReplyDelegate replyDelegate) + { + this.BaseUrl = base_url; + this.Parameters = parameters; + this.Reply = replyDelegate; + this.RelUrl = rel_url; + this.PostForm(); + } + public FormPoster(string base_url, string rel_url, Dictionary parameters) + { + this.BaseUrl = base_url; + this.Parameters = parameters; + this.Reply = new ReplyDelegate((rep) => { }); + this.RelUrl = rel_url; + this.PostForm(); + } + + private void PostForm() + { + this.Request = (HttpWebRequest)WebRequest.Create(this.BaseUrl + this.RelUrl); + Request.Method = "POST"; + Request.ContentType = "application/x-www-form-urlencoded"; + Request.BeginGetRequestStream(this.RequestCallback, Request); + } + private void RequestCallback(IAsyncResult asyncResult) + { + try + { + string postData = ""; + foreach (string key in this.Parameters.Keys) + { + postData += encodeUriComponent(key) + "=" + encodeUriComponent(this.Parameters[key]) + "&"; + } + Stream newStream = Request.EndGetRequestStream(asyncResult); + StreamWriter streamWriter = new StreamWriter(newStream); + streamWriter.Write(postData); + streamWriter.Close(); + this.Request.BeginGetResponse(this.ResponseCallback, this.Request); + } + catch (Exception e) + { + this.Reply(e.Message); + } + finally { } + } + + private string encodeUriComponent(string s) + { + string res = s.Replace("&", "%26"); + res = res.Replace(" ", "%20"); + return res; + } + + private void ResponseCallback(IAsyncResult asyncResult) + { + try + { + WebResponse response = this.Request.EndGetResponse(asyncResult); + Stream dataStream = response.GetResponseStream(); + StreamReader reader = new StreamReader(dataStream); + string result = reader.ReadToEnd(); + this.Reply(result); + } + catch (Exception e) + { + this.Reply(e.Message); + } + finally { } + } + } + } +} \ No newline at end of file diff --git a/Bcfier/Bcf/Bcf2/Project.cs b/Bcfier/Bcf/Bcf2/Project.cs old mode 100644 new mode 100755 diff --git a/Bcfier/Bcf/BcfContainer.cs b/Bcfier/Bcf/BcfContainer.cs old mode 100644 new mode 100755 index e30c8b68..65dfde83 --- a/Bcfier/Bcf/BcfContainer.cs +++ b/Bcfier/Bcf/BcfContainer.cs @@ -171,15 +171,26 @@ private static BcfFile OpenBcfFile(string bcfzipfile) var dir = new DirectoryInfo(bcffile.TempPath); + var projectFile = Path.Combine(bcffile.TempPath, "project.bcfp"); + if (File.Exists(projectFile)) + { + var project = DeserializeProject(projectFile); + var g = Guid.NewGuid(); + Guid.TryParse(project.Project.ProjectId, out g); + bcffile.ProjectId = g; + } + + //ADD ISSUES FOR EACH SUBFOLDER foreach (var folder in dir.GetDirectories()) { //An issue needs at least the markup file - if (!File.Exists(Path.Combine(folder.FullName, "markup.bcf"))) + var markupFile = Path.Combine(folder.FullName, "markup.bcf"); + if (!File.Exists(markupFile)) continue; - var bcfissue = DeserializeMarkup(Path.Combine(folder.FullName, "markup.bcf")); + var bcfissue = DeserializeMarkup(markupFile); if (bcfissue == null) @@ -205,12 +216,12 @@ private static BcfFile OpenBcfFile(string bcfzipfile) else { bcfissue.Viewpoints = new ObservableCollection(); - string viewpointpath = Path.Combine(folder.FullName, "viewpoint.bcfv"); - if (File.Exists(viewpointpath)) + string viewpointFile = Path.Combine(folder.FullName, "viewpoint.bcfv"); + if (File.Exists(viewpointFile)) { bcfissue.Viewpoints.Add(new ViewPoint(true) { - VisInfo = DeserializeViewpoint(viewpointpath), + VisInfo = DeserializeViewpoint(viewpointFile), SnapshotPath = Path.Combine(folder.FullName, "snapshot.png"), }); //update the comments @@ -261,10 +272,19 @@ private static bool SaveBcfFile(BcfFile bcffile) // Process save file dialog box results if (string.IsNullOrWhiteSpace(filename)) return false; - var bcfProject = new Project(); + var bcfProject = new ProjectExtension + { + Project = new Project + { + Name =string.IsNullOrEmpty(bcffile.ProjectName) ? bcffile.Filename : bcffile.ProjectName, + ProjectId = bcffile.ProjectId.Equals(Guid.Empty) ? Guid.NewGuid().ToString() : bcffile.ProjectId.ToString() + }, + ExtensionSchema = "" + + }; var bcfVersion = new Bcf2.Version { VersionId = "2.0", DetailedVersion = "2.0" }; - var serializerP = new XmlSerializer(typeof(Project)); + var serializerP = new XmlSerializer(typeof(ProjectExtension)); Stream writerP = new FileStream(Path.Combine(bcffile.TempPath, "project.bcfp"), FileMode.Create); serializerP.Serialize(writerP, bcfProject); writerP.Close(); @@ -316,7 +336,7 @@ private static bool SaveBcfFile(BcfFile bcffile) if (File.Exists(filename)) File.Delete(filename); - ZipFile.CreateFromDirectory(bcffile.TempPath, filename, CompressionLevel.Fastest, false); + ZipFile.CreateFromDirectory(bcffile.TempPath, filename, CompressionLevel.Optimal, false); //Open browser at location Uri uri2 = new Uri(filename); @@ -390,6 +410,24 @@ private static Markup DeserializeMarkup(string path) MessageBox.Show("exception: " + ex1); } return output; + } + + private static ProjectExtension DeserializeProject(string path) + { + ProjectExtension output = null; + try + { + using (var markupFile = new FileStream(path, FileMode.Open)) + { + var serializerM = new XmlSerializer(typeof(ProjectExtension)); + output = serializerM.Deserialize(markupFile) as ProjectExtension; + } + } + catch (System.Exception ex1) + { + MessageBox.Show("exception: " + ex1); + } + return output; } diff --git a/Bcfier/Bcf/BcfFile.cs b/Bcfier/Bcf/BcfFile.cs old mode 100644 new mode 100755 index 586fcb27..fc00f99b --- a/Bcfier/Bcf/BcfFile.cs +++ b/Bcfier/Bcf/BcfFile.cs @@ -19,6 +19,8 @@ public class BcfFile : INotifyPropertyChanged private Guid id; public string TempPath { get; set; } public string Fullname { get; set; } + public Guid ProjectId { get; set; } + public string ProjectName { get; set; } private string _filename; private bool _hasBeenSaved; private ObservableCollection _issues; diff --git a/Bcfier/Bcfier.csproj b/Bcfier/Bcfier.csproj index 44c8768a..08e4d741 100644 --- a/Bcfier/Bcfier.csproj +++ b/Bcfier/Bcfier.csproj @@ -1,249 +1,250 @@ - - - - - Debug - AnyCPU - {503CE2C1-09D7-4F15-BB42-86196EE01ED4} - Library - Properties - Bcfier - Bcfier - v4.5 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - - - - true - bin\ManualObfuscation\ - DEBUG;TRACE - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - false - - - Assets\icon.ico - - - - - ..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll - - - - - - - - - - - - - - 4.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IssueListStyle.xaml - - - - - BcfierPanel.xaml - - - BcfReportPanel.xaml - - - AddView.xaml - - - ComponentsList.xaml - - - NewVersion.xaml - - - Settings.xaml - - - SnapWin.xaml - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - - - - - - - - - - - - copy /Y "$(TargetPath)" "C:\Program Files (x86)\BCFier\$(TargetFileName)" - + + + + + Debug + AnyCPU + {503CE2C1-09D7-4F15-BB42-86196EE01ED4} + Library + Properties + Bcfier + Bcfier + v4.5 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + true + bin\ManualObfuscation\ + DEBUG;TRACE + full + AnyCPU + prompt + MinimumRecommendedRules.ruleset + false + + + Assets\icon.ico + + + + + ..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll + + + + + + + + + + + + + + 4.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IssueListStyle.xaml + + + + + BcfierPanel.xaml + + + BcfReportPanel.xaml + + + AddView.xaml + + + ComponentsList.xaml + + + NewVersion.xaml + + + Settings.xaml + + + SnapWin.xaml + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + + + + + + + copy /Y "$(TargetPath)" "C:\Program Files (x86)\BCFier\$(TargetFileName)" + + --> \ No newline at end of file diff --git a/Bcfier/Properties/AssemblyInfo.cs b/Bcfier/Properties/AssemblyInfo.cs old mode 100644 new mode 100755 index 4e7ccf23..740a0fac --- a/Bcfier/Properties/AssemblyInfo.cs +++ b/Bcfier/Properties/AssemblyInfo.cs @@ -53,6 +53,6 @@ // 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.1.1")] -[assembly: AssemblyFileVersion("2.0.1.1")] +[assembly: AssemblyVersion("2.0.2")] +[assembly: AssemblyFileVersion("2.0.2")] [assembly: GuidAttribute("0d553633-80f8-490b-84d6-9d3d6ad4196d")] diff --git a/Bcfier/UserControls/BcfierPanel.xaml.cs b/Bcfier/UserControls/BcfierPanel.xaml.cs old mode 100644 new mode 100755 index 96b23f80..036c3faf --- a/Bcfier/UserControls/BcfierPanel.xaml.cs +++ b/Bcfier/UserControls/BcfierPanel.xaml.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Net; using System.Threading; +using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -30,11 +31,11 @@ public partial class BcfierPanel : UserControl public BcfierPanel() - { + { InitializeComponent(); DataContext = _bcf; //top menu buttons and events - NewBcfBtn.Click += delegate { _bcf.NewFile(); OnAddIssue(null,null);}; + NewBcfBtn.Click += delegate { _bcf.NewFile(); OnAddIssue(null, null); }; OpenBcfBtn.Click += delegate { _bcf.OpenFile(); }; //OpenProjectBtn.Click += OnOpenWebProject; SaveBcfBtn.Click += delegate { _bcf.SaveFile(SelectedBcf()); }; @@ -82,11 +83,11 @@ private bool CheckSaveBcf(BcfFile bcf) MessageBox.Show("exception: " + ex1); } return true; - } - - - - + } + + + + #region commands private void OnDeleteIssues(object sender, ExecutedRoutedEventArgs e) { @@ -116,9 +117,9 @@ private void OnDeleteIssues(object sender, ExecutedRoutedEventArgs e) { MessageBox.Show("exception: " + ex1); } - } - - + } + + private void OnAddComment(object sender, ExecutedRoutedEventArgs e) { try @@ -136,26 +137,26 @@ private void OnAddComment(object sender, ExecutedRoutedEventArgs e) { MessageBox.Show("No Issue selected", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; - } - - - Comment c = new Comment(); - c.Guid = Guid.NewGuid().ToString(); - c.Comment1 = content; - c.Topic = new CommentTopic(); - c.Topic.Guid = issue.Topic.Guid; - c.Date = DateTime.Now; - c.VerbalStatus = verbalStatus; - c.Status = status; - c.Author = Utils.GetUsername(); - - c.Viewpoint = new CommentViewpoint(); - c.Viewpoint.Guid = (view != null) ? view.Guid : ""; - - issue.Comment.Add(c); - - SelectedBcf().HasBeenSaved = false; - + } + + + Comment c = new Comment(); + c.Guid = Guid.NewGuid().ToString(); + c.Comment1 = content; + c.Topic = new CommentTopic(); + c.Topic.Guid = issue.Topic.Guid; + c.Date = DateTime.Now; + c.VerbalStatus = verbalStatus; + c.Status = status; + c.Author = Utils.GetUsername(); + + c.Viewpoint = new CommentViewpoint(); + c.Viewpoint.Guid = (view != null) ? view.Guid : ""; + + issue.Comment.Add(c); + + SelectedBcf().HasBeenSaved = false; + } catch (System.Exception ex1) { @@ -169,15 +170,15 @@ private void OnDeleteComment(object sender, ExecutedRoutedEventArgs e) if (SelectedBcf() == null) return; var values = (object[])e.Parameter; - var comment = values[0] as Comment; - // var comments = selItems.Cast().ToList(); + var comment = values[0] as Comment; + // var comments = selItems.Cast().ToList(); var issue = (Markup)values[1]; if (issue == null) { MessageBox.Show("No Issue selected", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } - if (comment==null) + if (comment == null) { MessageBox.Show("No Comment selected", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; @@ -203,8 +204,8 @@ private void OnDeleteComment(object sender, ExecutedRoutedEventArgs e) private void OnDeleteView(object sender, ExecutedRoutedEventArgs e) { try - { - + { + if (SelectedBcf() == null) return; var values = (object[])e.Parameter; @@ -267,7 +268,7 @@ private void OnOpenSnapshot(object sender, ExecutedRoutedEventArgs e) try { var view = e.Parameter as ViewPoint; - if (view==null || !File.Exists(view.SnapshotPath)) + if (view == null || !File.Exists(view.SnapshotPath)) { MessageBox.Show("The selected Snapshot does not exist", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; @@ -278,8 +279,8 @@ private void OnOpenSnapshot(object sender, ExecutedRoutedEventArgs e) dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen; dialog.Show(); } - else - Process.Start(view.SnapshotPath); + else + Process.Start(view.SnapshotPath); } catch (System.Exception ex1) { @@ -316,14 +317,14 @@ private void OnCloseBcf(object sender, ExecutedRoutedEventArgs e) var bcf = bcfs.First(); if (CheckSaveBcf(bcf)) - _bcf.CloseFile(bcf); + _bcf.CloseFile(bcf); } catch (System.Exception ex1) { MessageBox.Show("exception: " + ex1); } - } - + } + private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e) { var target = e.Source as Control; @@ -341,11 +342,11 @@ private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs #region events private void OnOpenWebProject(object sender, RoutedEventArgs routedEventArgs) - { - + { + } - public void BcfFileClicked (string path) + public void BcfFileClicked(string path) { _bcf.OpenFile(path); } @@ -363,9 +364,9 @@ public bool onClosing(CancelEventArgs e) } else return true; - } - - + } + + return false; } private void HelpBtnOnClick(object sender, RoutedEventArgs routedEventArgs) @@ -384,37 +385,40 @@ private void HelpBtnOnClick(object sender, RoutedEventArgs routedEventArgs) #endregion #region web - private async void CheckUpdates() - { - try - { - var cancel = new CancellationTokenSource(); - var release = await GitHubRest.GetLatestRelease(cancel); - if (release == null) - return; - - string version = release.tag_name.Replace("v",""); - - if (System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.CompareTo(Version.Parse(version)) < 0 && release.assets.Any()) - { - var dialog = new NewVersion(); - dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen; - dialog.Description.Text = release.name + " has been released on "+ release.published_at.ToLongDateString()+"\ndo you want to check it out now?"; - //dialog.NewFeatures.Text = document.Element("Bcfier").Element("Changelog").Element("NewFeatures").Value; - //dialog.BugFixes.Text = document.Element("Bcfier").Element("Changelog").Element("BugFixes").Value; - //dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen; - dialog.ShowDialog(); - if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) - Process.Start(release.assets.First().browser_download_url); - } - } - catch (System.Exception ex1) - { - //warning suppressed - Console.WriteLine("exception: " + ex1); - } - } - + //check github API for new release + private void CheckUpdates() + { + Task.Run(() => + { + try + { + var release = GitHubRest.GetLatestRelease(); + if (release == null) + return; + + string version = release.tag_name.Replace("v", ""); + + if (System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.CompareTo(Version.Parse(version)) < 0 && release.assets.Any()) + { + var dialog = new NewVersion(); + dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen; + dialog.Description.Text = release.name + " has been released on " + release.published_at.ToLongDateString() + "\ndo you want to check it out now?"; + //dialog.NewFeatures.Text = document.Element("Bcfier").Element("Changelog").Element("NewFeatures").Value; + //dialog.BugFixes.Text = document.Element("Bcfier").Element("Changelog").Element("BugFixes").Value; + //dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen; + dialog.ShowDialog(); + if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) + Process.Start(release.assets.First().browser_download_url); + } + } + catch (System.Exception ex1) + { + //warning suppressed + Console.WriteLine("exception: " + ex1); + } + }); + } + #endregion #region drag&drop private void Window_DragEnter(object sender, DragEventArgs e) @@ -435,8 +439,8 @@ private void Window_Drop(object sender, DragEventArgs e) var files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (var f in files) { - if(File.Exists(f)) - _bcf.OpenFile(f); + if (File.Exists(f)) + _bcf.OpenFile(f); } } } @@ -454,8 +458,8 @@ private void Window_DragOver(object sender, DragEventArgs e) if (e.Data.GetDataPresent(DataFormats.FileDrop, true)) { var filenames = e.Data.GetData(DataFormats.FileDrop, true) as string[]; - if (filenames.Any(x=>Path.GetExtension(x).ToUpperInvariant() != ".BCFZIP")) - dropEnabled = false; + if (filenames.Any(x => Path.GetExtension(x).ToUpperInvariant() != ".BCFZIP")) + dropEnabled = false; } else dropEnabled = false; @@ -478,9 +482,9 @@ public BcfFile SelectedBcf() if (BcfTabControl.SelectedIndex == -1 || _bcf.BcfFiles.Count <= BcfTabControl.SelectedIndex) return null; return _bcf.BcfFiles.ElementAt(BcfTabControl.SelectedIndex); - } + } #endregion - - + + } }