Skip to content

Commit

Permalink
*introduced RavenDB 2.0 to the project, hurray
Browse files Browse the repository at this point in the history
  • Loading branch information
capaj committed Jan 8, 2013
1 parent 8d581b8 commit dfae6bd
Show file tree
Hide file tree
Showing 27 changed files with 157 additions and 154 deletions.
36 changes: 18 additions & 18 deletions Dem2Server/Dem2Server/ClientViewModel.cs
@@ -1,18 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Fleck;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Raven.Client.Document;
using Raven.Client;
using Dem2Model;

namespace Dem2Server
{
public class ClientViewModel : ServerClientEntity
{

}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Fleck;
using Raven.Imports.Newtonsoft.Json;
using Raven.Imports.Newtonsoft.Json.Linq;
using Raven.Client.Document;
using Raven.Client;
using Dem2Model;

namespace Dem2Server
{
public class ClientViewModel : ServerClientEntity
{

}
}
2 changes: 1 addition & 1 deletion Dem2Server/Dem2Server/Comment.cs
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Raven.Imports.Newtonsoft.Json;
using Dem2Server;

namespace Dem2UserCreated
Expand Down
11 changes: 8 additions & 3 deletions Dem2Server/Dem2Server/Dem2Hub.cs
Expand Up @@ -4,14 +4,15 @@
using System.Linq;
using System.Text;
using Dem2Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Raven.Imports.Newtonsoft.Json;
using Raven.Imports.Newtonsoft.Json.Linq;
using Fleck;
using Raven.Client.Document;
using Raven.Client;
using System.Net;
using Dem2UserCreated;
using Newtonsoft.Json.Converters;
using Raven.Imports.Newtonsoft.Json.Converters;
using Raven.Imports.Newtonsoft.Json.Serialization;

namespace Dem2Server
{
Expand All @@ -33,6 +34,7 @@ public static class Dem2Hub //where everything coexists-inmemory copy of
public static void Initialize(DocumentStore documentDB) //someone provided us with the DB to load data from
{
docDB = documentDB;
docDB.DefaultDatabase = "Dem2";
docDB.Initialize();
EntityRepository.Initialize();
pspScraper.Scraper.docDB = docDB;
Expand Down Expand Up @@ -143,5 +145,8 @@ public static void sendItTo(object that,IWebSocketConnection socket)
{
socket.Send(JsonConvert.SerializeObject(that, new IsoDateTimeConverter()));
}


}

}
14 changes: 4 additions & 10 deletions Dem2Server/Dem2Server/Dem2Server.csproj
Expand Up @@ -64,22 +64,16 @@
<Reference Include="Fleck">
<HintPath>..\packages\Fleck.0.9.6.15\lib\net40\Fleck.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.4.0.8\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog">
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="Raven.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
<Reference Include="Raven.Abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\RavenDB.Client.1.0.992\lib\net40\Raven.Abstractions.dll</HintPath>
<HintPath>..\packages\RavenDB.Client.2.0.2230\lib\net40\Raven.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Raven.Client.Debug">
<HintPath>..\RavenDB\Client\Raven.Client.Debug.dll</HintPath>
</Reference>
<Reference Include="Raven.Client.Lightweight, Version=1.0.0.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
<Reference Include="Raven.Client.Lightweight, Version=2.0.0.0, Culture=neutral, PublicKeyToken=37f41c7f99471593, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\RavenDB.Client.1.0.992\lib\net40\Raven.Client.Lightweight.dll</HintPath>
<HintPath>..\packages\RavenDB.Client.2.0.2230\lib\net40\Raven.Client.Lightweight.dll</HintPath>
</Reference>
<Reference Include="Raven.Client.Lightweight.FSharp">
<HintPath>..\RavenDB\Client\Raven.Client.Lightweight.FSharp.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion Dem2Server/Dem2Server/IVotingLeader.cs
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using System.Text;
using Dem2Model;
using Newtonsoft.Json;
using Raven.Imports.Newtonsoft.Json;
using Dem2UserCreated;

namespace Dem2Server
Expand Down
2 changes: 1 addition & 1 deletion Dem2Server/Dem2Server/Listing.cs
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Raven.Imports.Newtonsoft.Json;
using Dem2Server;

namespace Dem2UserCreated
Expand Down
86 changes: 43 additions & 43 deletions Dem2Server/Dem2Server/Name.cs
@@ -1,43 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Dem2Server;

namespace Dem2Model
{
public class Name:ServerClientEntity
{
private string _firstName;

public string FirstName
{
get { return _firstName; }
set { _firstName = value; }
}

private string _lastName;

public string LastName
{
get { return _lastName; }
set { _lastName = value; }
}

[JsonIgnore]
public string FullName
{
get { return _firstName + " " + _lastName; }
private set {
int whitespace = value.IndexOf(" ");
string[] names = value.Split(value[whitespace]);
_firstName = names[0];
_lastName = names[1];
}
}



}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Raven.Imports.Newtonsoft.Json;
using Dem2Server;

namespace Dem2Model
{
public class Name:ServerClientEntity
{
private string _firstName;

public string FirstName
{
get { return _firstName; }
set { _firstName = value; }
}

private string _lastName;

public string LastName
{
get { return _lastName; }
set { _lastName = value; }
}

[JsonIgnore]
public string FullName
{
get { return _firstName + " " + _lastName; }
private set {
int whitespace = value.IndexOf(" ");
string[] names = value.Split(value[whitespace]);
_firstName = names[0];
_lastName = names[1];
}
}



}
}
3 changes: 1 addition & 2 deletions Dem2Server/Dem2Server/Query.cs
@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Raven.Imports.Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -9,7 +9,6 @@ namespace Dem2Server
{
public class Query
{
[JsonIgnore]
public string sourceJSON { get; set; }
public bool descending { get; set; }
public string sortByProp { get; set; } //
Expand Down
2 changes: 1 addition & 1 deletion Dem2Server/Dem2Server/ServerClientEntity.cs
Expand Up @@ -4,7 +4,7 @@
using System.Linq;
using System.Text;
using Dem2Model;
using Newtonsoft.Json;
using Raven.Imports.Newtonsoft.Json;
using System.Collections.Concurrent;
using System.Runtime.CompilerServices;
using Raven.Abstractions.Commands;
Expand Down
2 changes: 1 addition & 1 deletion Dem2Server/Dem2Server/Subscription.cs
Expand Up @@ -5,7 +5,7 @@
using System.Threading.Tasks;
using Dem2Model;
using Dem2Server;
using Newtonsoft.Json;
using Raven.Imports.Newtonsoft.Json;

namespace Dem2UserCreated
{
Expand Down
45 changes: 14 additions & 31 deletions Dem2Server/Dem2Server/VotableItem.cs
Expand Up @@ -5,8 +5,9 @@
using System.Threading.Tasks;
using Dem2Model;
using Dem2UserCreated;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Raven.Imports.Newtonsoft.Json;
using Raven.Imports.Newtonsoft.Json.Serialization;
using Raven.Imports.Newtonsoft.Json.Converters;

namespace Dem2Server
{
Expand Down Expand Up @@ -44,40 +45,22 @@ public int getResolveCount

internal void IncrementVotableVersion()
{

foreach (var subscriber in subscribedUsers)
{
var op = new entityOperation() { operation = 'u', entity = this as VotableItem };
var votablePropsDict = new Dictionary<string, dynamic>() {
{ "Id", Id },
{ "PositiveVotesCount", PositiveVotesCount },
{ "NegativeVotesCount", NegativeVotesCount }
};
var entityJSON = JsonConvert.SerializeObject(votablePropsDict, new IsoDateTimeConverter());

var opDict = new Dictionary<string, dynamic>() { {"operation",'u'}, {"entity",entityJSON.Replace(@"\","")} };

Dem2Hub.sendItTo(op, subscriber.Value.connection);
var socket = subscriber.Value.connection;
socket.Send("{\"operation\":\"u\",\"entity\":" + entityJSON.Replace(@"\","") + "}");
}
}
}

/// <summary>
/// json.net serializes ALL properties of a class by default
/// this class will tell json.net to only serialize properties if
/// they MATCH the list of valid columns passed through the querystring to criteria object
/// </summary>
//public class CriteriaContractResolver<T> : DefaultContractResolver
//{
// List<string> _properties;

// public CriteriaContractResolver(List<string> properties)
// {
// _properties = properties;
// }

// protected override IList<JsonProperty> CreateProperties(JsonObjectContract contract)
// {
// IList<JsonProperty> filtered = new List<JsonProperty>();

// foreach (JsonProperty p in base.CreateProperties(T, contract)) //fix this problem
// {
// if (_properties.Contains(p.PropertyName))
// filtered.Add(p);

// return filtered;
// }
// }
//}
}
6 changes: 3 additions & 3 deletions Dem2Server/Dem2Server/Vote.cs
Expand Up @@ -5,9 +5,9 @@
using Dem2Server;
using Dem2Model;
using Fleck;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using Raven.Imports.Newtonsoft.Json;
using Raven.Imports.Newtonsoft.Json.Converters;
using Raven.Imports.Newtonsoft.Json.Linq;

namespace Dem2UserCreated
{
Expand Down
2 changes: 1 addition & 1 deletion Dem2Server/Dem2Server/Voting.cs
Expand Up @@ -4,7 +4,7 @@
using System.Text;
using System.Collections.Concurrent;
using Dem2Server;
using Newtonsoft.Json;
using Raven.Imports.Newtonsoft.Json;
using System.Threading.Tasks;
using pspScraper;
using System.Threading;
Expand Down
4 changes: 2 additions & 2 deletions Dem2Server/Dem2Server/WebsocketMessage.cs
Expand Up @@ -4,8 +4,8 @@
using System.Text;
using System.Threading.Tasks;
using Fleck;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Raven.Imports.Newtonsoft.Json;
using Raven.Imports.Newtonsoft.Json.Converters;

namespace Dem2Server
{
Expand Down
13 changes: 12 additions & 1 deletion Dem2Server/Dem2Server/app.config
Expand Up @@ -5,7 +5,18 @@
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

<dependentAssembly>
<assemblyIdentity name="Raven.Client.Lightweight" publicKeyToken="37f41c7f99471593" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Raven.Abstractions" publicKeyToken="37f41c7f99471593" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
</dependentAssembly>
</assemblyBinding>
<gcAllowVeryLargeObjects enabled="true" />
</runtime>
Expand Down
13 changes: 12 additions & 1 deletion Dem2Server/Dem2Server/bin/Debug/Dem2Server.exe.config
Expand Up @@ -5,7 +5,18 @@
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

<dependentAssembly>
<assemblyIdentity name="Raven.Client.Lightweight" publicKeyToken="37f41c7f99471593" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Raven.Abstractions" publicKeyToken="37f41c7f99471593" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
</dependentAssembly>
</assemblyBinding>
<gcAllowVeryLargeObjects enabled="true" />
</runtime>
Expand Down

0 comments on commit dfae6bd

Please sign in to comment.