Skip to content

Commit

Permalink
added a lot of bubu
Browse files Browse the repository at this point in the history
  • Loading branch information
azulayel committed Jun 28, 2016
1 parent f80ceb2 commit c6b0741
Show file tree
Hide file tree
Showing 7 changed files with 1,086 additions and 27 deletions.
1,030 changes: 1,030 additions & 0 deletions .vs/config/applicationhost.config

Large diffs are not rendered by default.

62 changes: 42 additions & 20 deletions Server/StaticsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ namespace OctanificationServer.Server
class StaticsService
{
private readonly string _resourcesPath;
private Member[] _staticData;
private Member _requstBody;
private List<Member> _staticCollection;

internal StaticsService(string resourcesPath)
{
Expand All @@ -27,8 +30,8 @@ internal StaticsService(string resourcesPath)
internal void ServeStatic(HttpListenerContext context)
{
Console.WriteLine("starting serving... " + context.Request.HttpMethod + " " + context.Request.RawUrl + " on thread " + Thread.CurrentThread.ManagedThreadId);
Member[] staticData = new Member[] {};
Member requstBody = ReadRequstBody(context);
_staticData = new Member[] {};
_requstBody = ReadRequstBody(context);

//Thread.Sleep(10000);

Expand All @@ -45,7 +48,7 @@ internal void ServeStatic(HttpListenerContext context)
try
{
string input = file.ReadToEnd();
staticData = JSONableExtensions.FromJsonArray<Member>(input);
_staticData = JSONableExtensions.FromJsonArray<Member>(input);
}
catch (Exception e)
{
Expand All @@ -54,7 +57,7 @@ internal void ServeStatic(HttpListenerContext context)
finally
{
Console.WriteLine("finished reading from the static file " + _resourcesPath);
DataProcessing(requstBody, staticData);
DataProcessing(_requstBody, _staticData);
}
}
}
Expand Down Expand Up @@ -146,29 +149,48 @@ private void DataProcessing(Member input, Member[] staticInput)
staticMember.Following.AddRange(input.Following);

if (staticMember.Url != input.Url) staticMember.Url = input.Url;

_staticCollection = new List<Member>((IEnumerable<Member>) staticInput);

}
else
{
IList<Member> staticCollection = staticInput;
staticCollection.Add(input);
_staticCollection = new List<Member>((IEnumerable<Member>) staticInput);
_staticCollection.Add(input);
}

// foreach (var member in staticInput)
// foreach (var user in member.Following)
// {
// if (user == input.Name) input.Followed[input.Followed.Length] = user;
// }
// foreach (var newUser in input.Following)
// {
// if (newUser == member.Name) member.Followed[member.Followed.Length] = newUser;
// }
// }
// if (!isExists) staticInput[staticInput.Length] = input;
//


AddFollowedUsers(staticInput);
AddUserFollowing();

Console.WriteLine("Finshing to processing the data...");
}

//Are following me
private void AddFollowedUsers(Member[] input)
{
Member staticMember = _staticCollection.FirstOrDefault(s => s.Name == _requstBody.Name);

foreach (var member in input) {
foreach (var user in member.Following)
{
if (user == staticMember.Name) staticMember.Followed.Add(member.Name);
}
}
}

//
private void AddUserFollowing()
{
Member staticMember = _staticCollection.FirstOrDefault(s => s.Name == _requstBody.Name);

foreach (var user in staticMember.Following) {
foreach (var member in _staticCollection)
{
if (user == member.Name) member.Followed.Add(staticMember.Name);
}
}

}

}
}
21 changes: 14 additions & 7 deletions StaticData/OctanUsers.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
[
{
"Name": "name",
"Entities": ["defect", "naama"],
"Followed": ["elad", "naama"],
"Following": ["elad", "yoed", "hanan"],
"Url": "localhost:8080"
}
{
"Name": "talia",
"Entities": [ "defect" ],
"Followed": [ "hanan" ],
"Following": [ ],
"Url": "localhost:8080"
},
{
"Name": "arial",
"Entities": [ "defect" ],
"Followed": [ "hanan" ],
"Following": [ ],
"Url": "localhost:8080"
}
]
Binary file modified bin/Debug/OctanificationServer.exe
Binary file not shown.
Binary file modified bin/Debug/OctanificationServer.pdb
Binary file not shown.
Binary file modified obj/Debug/OctanificationServer.exe
Binary file not shown.
Binary file modified obj/Debug/OctanificationServer.pdb
Binary file not shown.

0 comments on commit c6b0741

Please sign in to comment.