-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Catalin Dumitru <catalin.dumitru@live.com>
- Loading branch information
1 parent
a810dd4
commit 1306aea
Showing
11 changed files
with
178 additions
and
142 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.IO; | ||
using System.Threading; | ||
using WebServer.Models; | ||
|
||
namespace WebServer.Data | ||
{ | ||
// numele clasei se poate schimba | ||
// asta mi-a venit pe moment | ||
public class ModuleManager | ||
{ | ||
public IDocumentEntityManager EntityManager { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Valideaza un document. Daca statusul sau este gol, atunci | ||
/// se porneste parsarea si apelarea celorlalte moduule. | ||
/// </summary> | ||
/// <param name="doc">Documentul ce trebuie validat</param> | ||
/// <returns>Fisierul XML daca exista. Null daca documentul inca nu a fost creat.</returns> | ||
public String ValidateDocumentOutput(DocumentOutput doc) | ||
{ | ||
if (this.EntityManager == null) | ||
return null; | ||
|
||
switch (doc.Status) { | ||
/*daca fisierul a fost creat, il intoarcems*/ | ||
case DocumentManager.StatusOK: | ||
return doc.Document; | ||
/*daca documentul e in curs de parsare, nu facem nimic*/ | ||
case DocumentManager.StatusParsing: | ||
return null; | ||
/*daca documentul este gol, pornim workerul ce se ocupa de apelarea modulelor*/ | ||
case DocumentManager.StatusEmpty: | ||
this._StartWorker(doc); | ||
return null; | ||
default: | ||
return null; | ||
} | ||
} | ||
|
||
private void _StartWorker(DocumentOutput doc) { | ||
ModuleWorker worker = new ModuleWorker(this.EntityManager, doc); | ||
|
||
/*cream un thread nou*/ | ||
Thread thread = new Thread(new ThreadStart(worker.Run)); | ||
thread.Start(); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.IO; | ||
using WebServer.Models; | ||
|
||
namespace WebServer.Data | ||
{ | ||
// Thread-ul in care se va trata cererea | ||
public class ModuleWorker | ||
{ | ||
private IDocumentEntityManager _em = null; | ||
private DocumentOutput _doc = null; | ||
|
||
public ModuleWorker(IDocumentEntityManager em, DocumentOutput doc) | ||
{ | ||
this._em = em; | ||
this._doc = doc; | ||
} | ||
|
||
public void Run() | ||
{ | ||
if(this._em == null || this._doc == null) | ||
return; | ||
|
||
/*schimbam statusul initial sa spunem ca documentul se parseaza*/ | ||
this._doc.Status = DocumentManager.StatusParsing; | ||
this._em.Save(); | ||
|
||
/*rezultatul apelarii*/ | ||
Boolean res = false; | ||
|
||
switch (this._doc.Type) | ||
{ | ||
case DocumentManager.TypeSummary: | ||
res = this._CreateSummaryDocument(); | ||
break; | ||
case DocumentManager.TypeTimeline: | ||
res = this._CreateTimelineDocument(); | ||
break; | ||
} | ||
|
||
if (res) { | ||
/*daca a reusit parsarea facem update la baza de date*/ | ||
this._doc.Status = DocumentManager.StatusOK; | ||
this._em.Save(); | ||
} else { | ||
/*mai bagam o fisa*/ | ||
this._doc.Status = DocumentManager.StatusEmpty; | ||
this._em.Save(); | ||
} | ||
} | ||
|
||
private Boolean _CreateSummaryDocument() { | ||
/*apeleaza modulele de sumarizare extragere de informatii si creaza | ||
documentul xml*/ | ||
|
||
/*daca a reusit apelarea modulelor*/ | ||
return false; | ||
} | ||
|
||
private Boolean _CreateTimelineDocument() { | ||
/*apeleaza modulele de situatii si timp si ceraza documentul xml*/ | ||
|
||
/*daca a reusit apelarea modulelor*/ | ||
return false; | ||
} | ||
} | ||
} |
Oops, something went wrong.