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

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
teocomi committed Sep 29, 2015
2 parents b6067eb + e8630f1 commit 1e63016
Show file tree
Hide file tree
Showing 16 changed files with 326 additions and 138 deletions.
4 changes: 2 additions & 2 deletions Bcfier.Revit/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyVersion("2.0.1")]
[assembly: AssemblyFileVersion("2.0.1")]
[assembly: GuidAttribute("59068325-ACDC-4DB3-892A-1C90C9434BF8")]
4 changes: 2 additions & 2 deletions Bcfier.Win/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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("1.0.1.1")]
[assembly: AssemblyFileVersion("1.0.1.1")]
[assembly: AssemblyVersion("2.0.1")]
[assembly: AssemblyFileVersion("2.0.1")]
[assembly: GuidAttribute("9FC6BA85-A348-40B4-97C4-6699DA912C21")]
25 changes: 25 additions & 0 deletions Bcfier/Api/GitHubAsset.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bcfier.Api
{
public class GitHubAsset
{
public string url { get; set; }
public int id { get; set; }
public string name { get; set; }
public object label { get; set; }
public GitHubAuthor uploader { get; set; }
public string content_type { get; set; }
public string state { get; set; }
public int size { get; set; }
public int download_count { get; set; }
public string created_at { get; set; }
public string updated_at { get; set; }
public string browser_download_url { get; set; }
}
}

29 changes: 29 additions & 0 deletions Bcfier/Api/GitHubAuthor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bcfier.Api
{
public class GitHubAuthor
{
public string login { get; set; }
public int id { get; set; }
public string avatar_url { get; set; }
public string gravatar_id { get; set; }
public string url { get; set; }
public string html_url { get; set; }
public string followers_url { get; set; }
public string following_url { get; set; }
public string gists_url { get; set; }
public string starred_url { get; set; }
public string subscriptions_url { get; set; }
public string organizations_url { get; set; }
public string repos_url { get; set; }
public string events_url { get; set; }
public string received_events_url { get; set; }
public string type { get; set; }
public bool site_admin { get; set; }
}
}
29 changes: 29 additions & 0 deletions Bcfier/Api/GitHubRelease.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bcfier.Api
{
public class GitHubRelease
{
public string url { get; set; }
public string assets_url { get; set; }
public string upload_url { get; set; }
public string html_url { get; set; }
public int id { get; set; }
public string tag_name { get; set; }
public string target_commitish { get; set; }
public string name { get; set; }
public bool draft { get; set; }
public GitHubAuthor author { get; set; }
public bool prerelease { get; set; }
public DateTime created_at { get; set; }
public DateTime published_at { get; set; }
public List<GitHubAsset> assets { get; set; }
public string tarball_url { get; set; }
public string zipball_url { get; set; }
public string body { get; set; }
}
}
83 changes: 83 additions & 0 deletions Bcfier/Api/GitHubRest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using RestSharp;
using DataFormat = RestSharp.DataFormat;

namespace Bcfier.Api
{
public static class GitHubRest
{
internal static RestClient Client
{
get { return new RestClient(@"https://api.github.com/"); }
}

internal static async Task<List<GitHubRelease>> GetReleases(CancellationTokenSource cancel)
{
if (cancel.IsCancellationRequested)
return null;


var request = new RestRequest("repos/teocomi/bcfier/releases?access_token=ef85819857533da4a216df2ae8e6db642827e922", Method.GET);
request.AddHeader("Content-Type", "application/json");
request.RequestFormat = DataFormat.Json;
request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; };

var response = await DoTaskAsync<List<GitHubRelease>>(request, cancel);

return cancel.IsCancellationRequested || !CheckResponse(response, HttpStatusCode.OK) ? null : response.Data;
}
internal static async Task<GitHubRelease> GetLatestRelease(CancellationTokenSource cancel)
{
if (cancel.IsCancellationRequested)
return null;


var request = new RestRequest("repos/teocomi/bcfier/releases/latest?access_token=ef85819857533da4a216df2ae8e6db642827e922", Method.GET);
request.AddHeader("Content-Type", "application/json");
request.RequestFormat = DataFormat.Json;

var response = await DoTaskAsync<GitHubRelease>(request, cancel);
//if cancellation oending or invalid reponse return null, otherwise the data
return cancel.IsCancellationRequested || !CheckResponse(response, HttpStatusCode.OK) ? null : response.Data;
}

private static async Task<IRestResponse<T>> DoTaskAsync<T>(RestRequest request, CancellationTokenSource cancel) where T : class
{
IRestResponse<T> response = null;
try
{
if (cancel != null)
response = await Client.ExecuteTaskAsync<T>(request, cancel.Token);
}
catch (OperationCanceledException ex)
{
var gg = ex.Data;
return null;
}
return response;
}

private static bool CheckResponse(IRestResponse response, HttpStatusCode expectedCode)
{
try
{
if (null == response || response.StatusCode != expectedCode)
return false;
}
catch (Exception ex1)
{
MessageBox.Show("exception: " + ex1);
}
return true;
}


}
}
108 changes: 55 additions & 53 deletions Bcfier/Bcf/BcfFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ public BcfFile()
Id = Guid.NewGuid();
TempPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "BCFier", Id.ToString());
Issues = new ObservableCollection<Markup>();
this._view = new ListCollectionView(this.Issues);

}
public bool HasBeenSaved
{
Expand Down Expand Up @@ -84,6 +82,7 @@ public ObservableCollection<Markup> Issues
set
{
_issues = value;
this._view = new ListCollectionView(this.Issues);
NotifyPropertyChanged("Issues");
}
}
Expand All @@ -102,12 +101,15 @@ public Markup SelectedIssue
}
}


public ICollectionView View
{
get { return this._view; }
get
{
return this._view;
}
}

public string TextSearch
{
get { return _textSearch; }
Expand All @@ -125,13 +127,13 @@ public string TextSearch

private bool Filter(object o)
{
var issue = (Markup) o;
var issue = (Markup)o;
if (issue == null)
return false;
if (issue.Topic != null && ((issue.Topic.Title != null && issue.Topic.Title.ToLowerInvariant().Contains(TextSearch.ToLowerInvariant())) ||
( issue.Topic.Description != null && issue.Topic.Description.ToLowerInvariant().Contains(TextSearch.ToLowerInvariant()))) ||
(issue.Topic.Description != null && issue.Topic.Description.ToLowerInvariant().Contains(TextSearch.ToLowerInvariant()))) ||
issue.Comment != null && issue.Comment.Any(x => x.Comment1.ToLowerInvariant().Contains(TextSearch.ToLowerInvariant()))

)
return true;
return false;
Expand Down Expand Up @@ -171,7 +173,7 @@ public void RemoveView(ViewPoint view, Markup issue, bool delComm)
var guid = view.Guid;
issue.Viewpoints.Remove(view);
//remove comments associated with that view
var viewcomments = issue.Comment.Where(x => x.Viewpoint!=null && x.Viewpoint.Guid == guid).ToList();
var viewcomments = issue.Comment.Where(x => x.Viewpoint != null && x.Viewpoint.Guid == guid).ToList();

if (!viewcomments.Any())
return;
Expand Down Expand Up @@ -220,61 +222,61 @@ public void MergeBcfFile(IEnumerable<BcfFile> bcfFiles)
{

foreach (var bcf in bcfFiles)
{
foreach (var mergedIssue in bcf.Issues)
{
foreach (var mergedIssue in bcf.Issues)
//it's a new issue
if (!Issues.Any(x => x.Topic != null && mergedIssue.Topic != null && x.Topic.Guid == mergedIssue.Topic.Guid))
{
//it's a new issue
if (!Issues.Any(x => x.Topic!=null && mergedIssue.Topic!=null && x.Topic.Guid == mergedIssue.Topic.Guid))
string sourceDir = Path.Combine(bcf.TempPath, mergedIssue.Topic.Guid);
string destDir = Path.Combine(TempPath, mergedIssue.Topic.Guid);

Directory.Move(sourceDir, destDir);
//update path set for binding
foreach (var view in mergedIssue.Viewpoints)
{
string sourceDir = Path.Combine(bcf.TempPath, mergedIssue.Topic.Guid);
string destDir = Path.Combine(TempPath, mergedIssue.Topic.Guid);
view.SnapshotPath = Path.Combine(TempPath, mergedIssue.Topic.Guid, view.Snapshot);
}
Issues.Add(mergedIssue);

Directory.Move(sourceDir, destDir);
//update path set for binding
foreach (var view in mergedIssue.Viewpoints)
}
//it exists, let's loop comments and views
else
{
var issue = Issues.First(x => x.Topic.Guid == mergedIssue.Topic.Guid);
var newComments = mergedIssue.Comment.Where(x => issue.Comment.All(y => y.Guid != x.Guid)).ToList();
if (newComments.Any())
foreach (var newComment in newComments)
issue.Comment.Add(newComment);
//sort comments
issue.Comment = new ObservableCollection<Comment>(issue.Comment.OrderByDescending(x => x.Date));

var newViews = mergedIssue.Viewpoints.Where(x => issue.Viewpoints.All(y => y.Guid != x.Guid)).ToList();
if (newViews.Any())
foreach (var newView in newViews)
{
view.SnapshotPath = Path.Combine(TempPath, mergedIssue.Topic.Guid, view.Snapshot);
//to avoid conflicts in case both contain a snapshot.png or viewpoint.bcfv
//img to be merged
string sourceFile = newView.SnapshotPath;
//assign new safe name based on guid
newView.Snapshot = newView.Guid + ".png";
//set new temp path for binding
newView.SnapshotPath = Path.Combine(TempPath, issue.Topic.Guid, newView.Snapshot);
//assign new safe name based on guid
newView.Viewpoint = newView.Guid + ".bcfv";
File.Move(sourceFile, newView.SnapshotPath);
issue.Viewpoints.Add(newView);


}
Issues.Add(mergedIssue);

}
//it exists, let's loop comments and views
else
{
var issue = Issues.First(x => x.Topic.Guid == mergedIssue.Topic.Guid);
var newComments = mergedIssue.Comment.Where(x => issue.Comment.All(y => y.Guid != x.Guid)).ToList();
if(newComments.Any())
foreach (var newComment in newComments)
issue.Comment.Add(newComment);
//sort comments
issue.Comment = new ObservableCollection<Comment>(issue.Comment.OrderByDescending(x=>x.Date));

var newViews = mergedIssue.Viewpoints.Where(x => issue.Viewpoints.All(y => y.Guid != x.Guid)).ToList();
if (newViews.Any())
foreach (var newView in newViews)
{
//to avoid conflicts in case both contain a snapshot.png or viewpoint.bcfv
//img to be merged
string sourceFile = newView.SnapshotPath;
//assign new safe name based on guid
newView.Snapshot = newView.Guid + ".png";
//set new temp path for binding
newView.SnapshotPath = Path.Combine(TempPath, issue.Topic.Guid, newView.Snapshot);
//assign new safe name based on guid
newView.Viewpoint = newView.Guid + ".bcfv";
File.Move(sourceFile, newView.SnapshotPath);
issue.Viewpoints.Add(newView);


}
}
}
Utils.DeleteDirectory(bcf.TempPath);
}
Utils.DeleteDirectory(bcf.TempPath);
}
HasBeenSaved = false;



}
catch (System.Exception ex1)
{
Expand Down
7 changes: 7 additions & 0 deletions Bcfier/Bcfier.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationFramework.Aero" />
<Reference Include="RestSharp">
<HintPath>..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
Expand All @@ -73,6 +76,10 @@
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<Compile Include="Api\GitHubAsset.cs" />
<Compile Include="Api\GitHubAuthor.cs" />
<Compile Include="Api\GitHubRelease.cs" />
<Compile Include="Api\GitHubRest.cs" />
<Compile Include="Bcf\Bcf2\Markup.cs" />
<Compile Include="Bcf\Bcf2\Project.cs" />
<Compile Include="Bcf\Bcf2\Version.cs" />
Expand Down
Loading

0 comments on commit 1e63016

Please sign in to comment.