Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit 1e63016

Browse files
committed
Merge branch 'dev'
2 parents b6067eb + e8630f1 commit 1e63016

File tree

16 files changed

+326
-138
lines changed

16 files changed

+326
-138
lines changed

Bcfier.Revit/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@
4949
// You can specify all the values or you can default the Build and Revision Numbers
5050
// by using the '*' as shown below:
5151
// [assembly: AssemblyVersion("1.0.*")]
52-
[assembly: AssemblyVersion("2.0.0.0")]
53-
[assembly: AssemblyFileVersion("2.0.0.0")]
52+
[assembly: AssemblyVersion("2.0.1")]
53+
[assembly: AssemblyFileVersion("2.0.1")]
5454
[assembly: GuidAttribute("59068325-ACDC-4DB3-892A-1C90C9434BF8")]

Bcfier.Win/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@
4949
// You can specify all the values or you can default the Build and Revision Numbers
5050
// by using the '*' as shown below:
5151
// [assembly: AssemblyVersion("1.0.*")]
52-
[assembly: AssemblyVersion("1.0.1.1")]
53-
[assembly: AssemblyFileVersion("1.0.1.1")]
52+
[assembly: AssemblyVersion("2.0.1")]
53+
[assembly: AssemblyFileVersion("2.0.1")]
5454
[assembly: GuidAttribute("9FC6BA85-A348-40B4-97C4-6699DA912C21")]

Bcfier/Api/GitHubAsset.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Bcfier.Api
8+
{
9+
public class GitHubAsset
10+
{
11+
public string url { get; set; }
12+
public int id { get; set; }
13+
public string name { get; set; }
14+
public object label { get; set; }
15+
public GitHubAuthor uploader { get; set; }
16+
public string content_type { get; set; }
17+
public string state { get; set; }
18+
public int size { get; set; }
19+
public int download_count { get; set; }
20+
public string created_at { get; set; }
21+
public string updated_at { get; set; }
22+
public string browser_download_url { get; set; }
23+
}
24+
}
25+

Bcfier/Api/GitHubAuthor.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Bcfier.Api
8+
{
9+
public class GitHubAuthor
10+
{
11+
public string login { get; set; }
12+
public int id { get; set; }
13+
public string avatar_url { get; set; }
14+
public string gravatar_id { get; set; }
15+
public string url { get; set; }
16+
public string html_url { get; set; }
17+
public string followers_url { get; set; }
18+
public string following_url { get; set; }
19+
public string gists_url { get; set; }
20+
public string starred_url { get; set; }
21+
public string subscriptions_url { get; set; }
22+
public string organizations_url { get; set; }
23+
public string repos_url { get; set; }
24+
public string events_url { get; set; }
25+
public string received_events_url { get; set; }
26+
public string type { get; set; }
27+
public bool site_admin { get; set; }
28+
}
29+
}

Bcfier/Api/GitHubRelease.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Bcfier.Api
8+
{
9+
public class GitHubRelease
10+
{
11+
public string url { get; set; }
12+
public string assets_url { get; set; }
13+
public string upload_url { get; set; }
14+
public string html_url { get; set; }
15+
public int id { get; set; }
16+
public string tag_name { get; set; }
17+
public string target_commitish { get; set; }
18+
public string name { get; set; }
19+
public bool draft { get; set; }
20+
public GitHubAuthor author { get; set; }
21+
public bool prerelease { get; set; }
22+
public DateTime created_at { get; set; }
23+
public DateTime published_at { get; set; }
24+
public List<GitHubAsset> assets { get; set; }
25+
public string tarball_url { get; set; }
26+
public string zipball_url { get; set; }
27+
public string body { get; set; }
28+
}
29+
}

Bcfier/Api/GitHubRest.cs

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Net;
5+
using System.Text;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
using System.Windows;
9+
using RestSharp;
10+
using DataFormat = RestSharp.DataFormat;
11+
12+
namespace Bcfier.Api
13+
{
14+
public static class GitHubRest
15+
{
16+
internal static RestClient Client
17+
{
18+
get { return new RestClient(@"https://api.github.com/"); }
19+
}
20+
21+
internal static async Task<List<GitHubRelease>> GetReleases(CancellationTokenSource cancel)
22+
{
23+
if (cancel.IsCancellationRequested)
24+
return null;
25+
26+
27+
var request = new RestRequest("repos/teocomi/bcfier/releases?access_token=ef85819857533da4a216df2ae8e6db642827e922", Method.GET);
28+
request.AddHeader("Content-Type", "application/json");
29+
request.RequestFormat = DataFormat.Json;
30+
request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; };
31+
32+
var response = await DoTaskAsync<List<GitHubRelease>>(request, cancel);
33+
34+
return cancel.IsCancellationRequested || !CheckResponse(response, HttpStatusCode.OK) ? null : response.Data;
35+
}
36+
internal static async Task<GitHubRelease> GetLatestRelease(CancellationTokenSource cancel)
37+
{
38+
if (cancel.IsCancellationRequested)
39+
return null;
40+
41+
42+
var request = new RestRequest("repos/teocomi/bcfier/releases/latest?access_token=ef85819857533da4a216df2ae8e6db642827e922", Method.GET);
43+
request.AddHeader("Content-Type", "application/json");
44+
request.RequestFormat = DataFormat.Json;
45+
46+
var response = await DoTaskAsync<GitHubRelease>(request, cancel);
47+
//if cancellation oending or invalid reponse return null, otherwise the data
48+
return cancel.IsCancellationRequested || !CheckResponse(response, HttpStatusCode.OK) ? null : response.Data;
49+
}
50+
51+
private static async Task<IRestResponse<T>> DoTaskAsync<T>(RestRequest request, CancellationTokenSource cancel) where T : class
52+
{
53+
IRestResponse<T> response = null;
54+
try
55+
{
56+
if (cancel != null)
57+
response = await Client.ExecuteTaskAsync<T>(request, cancel.Token);
58+
}
59+
catch (OperationCanceledException ex)
60+
{
61+
var gg = ex.Data;
62+
return null;
63+
}
64+
return response;
65+
}
66+
67+
private static bool CheckResponse(IRestResponse response, HttpStatusCode expectedCode)
68+
{
69+
try
70+
{
71+
if (null == response || response.StatusCode != expectedCode)
72+
return false;
73+
}
74+
catch (Exception ex1)
75+
{
76+
MessageBox.Show("exception: " + ex1);
77+
}
78+
return true;
79+
}
80+
81+
82+
}
83+
}

Bcfier/Bcf/BcfFile.cs

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ public BcfFile()
3333
Id = Guid.NewGuid();
3434
TempPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "BCFier", Id.ToString());
3535
Issues = new ObservableCollection<Markup>();
36-
this._view = new ListCollectionView(this.Issues);
37-
3836
}
3937
public bool HasBeenSaved
4038
{
@@ -84,6 +82,7 @@ public ObservableCollection<Markup> Issues
8482
set
8583
{
8684
_issues = value;
85+
this._view = new ListCollectionView(this.Issues);
8786
NotifyPropertyChanged("Issues");
8887
}
8988
}
@@ -102,12 +101,15 @@ public Markup SelectedIssue
102101
}
103102
}
104103

105-
104+
106105
public ICollectionView View
107106
{
108-
get { return this._view; }
107+
get
108+
{
109+
return this._view;
110+
}
109111
}
110-
112+
111113
public string TextSearch
112114
{
113115
get { return _textSearch; }
@@ -125,13 +127,13 @@ public string TextSearch
125127

126128
private bool Filter(object o)
127129
{
128-
var issue = (Markup) o;
130+
var issue = (Markup)o;
129131
if (issue == null)
130132
return false;
131133
if (issue.Topic != null && ((issue.Topic.Title != null && issue.Topic.Title.ToLowerInvariant().Contains(TextSearch.ToLowerInvariant())) ||
132-
( issue.Topic.Description != null && issue.Topic.Description.ToLowerInvariant().Contains(TextSearch.ToLowerInvariant()))) ||
134+
(issue.Topic.Description != null && issue.Topic.Description.ToLowerInvariant().Contains(TextSearch.ToLowerInvariant()))) ||
133135
issue.Comment != null && issue.Comment.Any(x => x.Comment1.ToLowerInvariant().Contains(TextSearch.ToLowerInvariant()))
134-
136+
135137
)
136138
return true;
137139
return false;
@@ -171,7 +173,7 @@ public void RemoveView(ViewPoint view, Markup issue, bool delComm)
171173
var guid = view.Guid;
172174
issue.Viewpoints.Remove(view);
173175
//remove comments associated with that view
174-
var viewcomments = issue.Comment.Where(x => x.Viewpoint!=null && x.Viewpoint.Guid == guid).ToList();
176+
var viewcomments = issue.Comment.Where(x => x.Viewpoint != null && x.Viewpoint.Guid == guid).ToList();
175177

176178
if (!viewcomments.Any())
177179
return;
@@ -220,61 +222,61 @@ public void MergeBcfFile(IEnumerable<BcfFile> bcfFiles)
220222
{
221223

222224
foreach (var bcf in bcfFiles)
225+
{
226+
foreach (var mergedIssue in bcf.Issues)
223227
{
224-
foreach (var mergedIssue in bcf.Issues)
228+
//it's a new issue
229+
if (!Issues.Any(x => x.Topic != null && mergedIssue.Topic != null && x.Topic.Guid == mergedIssue.Topic.Guid))
225230
{
226-
//it's a new issue
227-
if (!Issues.Any(x => x.Topic!=null && mergedIssue.Topic!=null && x.Topic.Guid == mergedIssue.Topic.Guid))
231+
string sourceDir = Path.Combine(bcf.TempPath, mergedIssue.Topic.Guid);
232+
string destDir = Path.Combine(TempPath, mergedIssue.Topic.Guid);
233+
234+
Directory.Move(sourceDir, destDir);
235+
//update path set for binding
236+
foreach (var view in mergedIssue.Viewpoints)
228237
{
229-
string sourceDir = Path.Combine(bcf.TempPath, mergedIssue.Topic.Guid);
230-
string destDir = Path.Combine(TempPath, mergedIssue.Topic.Guid);
238+
view.SnapshotPath = Path.Combine(TempPath, mergedIssue.Topic.Guid, view.Snapshot);
239+
}
240+
Issues.Add(mergedIssue);
231241

232-
Directory.Move(sourceDir, destDir);
233-
//update path set for binding
234-
foreach (var view in mergedIssue.Viewpoints)
242+
}
243+
//it exists, let's loop comments and views
244+
else
245+
{
246+
var issue = Issues.First(x => x.Topic.Guid == mergedIssue.Topic.Guid);
247+
var newComments = mergedIssue.Comment.Where(x => issue.Comment.All(y => y.Guid != x.Guid)).ToList();
248+
if (newComments.Any())
249+
foreach (var newComment in newComments)
250+
issue.Comment.Add(newComment);
251+
//sort comments
252+
issue.Comment = new ObservableCollection<Comment>(issue.Comment.OrderByDescending(x => x.Date));
253+
254+
var newViews = mergedIssue.Viewpoints.Where(x => issue.Viewpoints.All(y => y.Guid != x.Guid)).ToList();
255+
if (newViews.Any())
256+
foreach (var newView in newViews)
235257
{
236-
view.SnapshotPath = Path.Combine(TempPath, mergedIssue.Topic.Guid, view.Snapshot);
258+
//to avoid conflicts in case both contain a snapshot.png or viewpoint.bcfv
259+
//img to be merged
260+
string sourceFile = newView.SnapshotPath;
261+
//assign new safe name based on guid
262+
newView.Snapshot = newView.Guid + ".png";
263+
//set new temp path for binding
264+
newView.SnapshotPath = Path.Combine(TempPath, issue.Topic.Guid, newView.Snapshot);
265+
//assign new safe name based on guid
266+
newView.Viewpoint = newView.Guid + ".bcfv";
267+
File.Move(sourceFile, newView.SnapshotPath);
268+
issue.Viewpoints.Add(newView);
269+
270+
237271
}
238-
Issues.Add(mergedIssue);
239-
240-
}
241-
//it exists, let's loop comments and views
242-
else
243-
{
244-
var issue = Issues.First(x => x.Topic.Guid == mergedIssue.Topic.Guid);
245-
var newComments = mergedIssue.Comment.Where(x => issue.Comment.All(y => y.Guid != x.Guid)).ToList();
246-
if(newComments.Any())
247-
foreach (var newComment in newComments)
248-
issue.Comment.Add(newComment);
249-
//sort comments
250-
issue.Comment = new ObservableCollection<Comment>(issue.Comment.OrderByDescending(x=>x.Date));
251-
252-
var newViews = mergedIssue.Viewpoints.Where(x => issue.Viewpoints.All(y => y.Guid != x.Guid)).ToList();
253-
if (newViews.Any())
254-
foreach (var newView in newViews)
255-
{
256-
//to avoid conflicts in case both contain a snapshot.png or viewpoint.bcfv
257-
//img to be merged
258-
string sourceFile = newView.SnapshotPath;
259-
//assign new safe name based on guid
260-
newView.Snapshot = newView.Guid + ".png";
261-
//set new temp path for binding
262-
newView.SnapshotPath = Path.Combine(TempPath, issue.Topic.Guid, newView.Snapshot);
263-
//assign new safe name based on guid
264-
newView.Viewpoint = newView.Guid + ".bcfv";
265-
File.Move(sourceFile, newView.SnapshotPath);
266-
issue.Viewpoints.Add(newView);
267-
268-
269-
}
270-
}
271272
}
272-
Utils.DeleteDirectory(bcf.TempPath);
273273
}
274+
Utils.DeleteDirectory(bcf.TempPath);
275+
}
274276
HasBeenSaved = false;
275277

276278

277-
279+
278280
}
279281
catch (System.Exception ex1)
280282
{

Bcfier/Bcfier.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
</PropertyGroup>
5555
<ItemGroup>
5656
<Reference Include="PresentationFramework.Aero" />
57+
<Reference Include="RestSharp">
58+
<HintPath>..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
59+
</Reference>
5760
<Reference Include="System" />
5861
<Reference Include="System.Configuration" />
5962
<Reference Include="System.Data" />
@@ -73,6 +76,10 @@
7376
<Reference Include="PresentationFramework" />
7477
</ItemGroup>
7578
<ItemGroup>
79+
<Compile Include="Api\GitHubAsset.cs" />
80+
<Compile Include="Api\GitHubAuthor.cs" />
81+
<Compile Include="Api\GitHubRelease.cs" />
82+
<Compile Include="Api\GitHubRest.cs" />
7683
<Compile Include="Bcf\Bcf2\Markup.cs" />
7784
<Compile Include="Bcf\Bcf2\Project.cs" />
7885
<Compile Include="Bcf\Bcf2\Version.cs" />

0 commit comments

Comments
 (0)