FeaturesRequest.cs
1 using sage.ew.db;
2 using System;
3 using System.Web.Script.Serialization;
4 
5 namespace Sage.ES.S50.Features
6 {
7  internal class FeaturesRequest
8  : IFeatureRequest
9  {
13  public string Id { get; set; }
14 
18  public DateTime FechaPeticion { get; set; }
19 
23  public DateTime FechaProximaPeticion { get; set; }
24 
28  public bool Enabled
29  {
30  get
31  {
32  return _oResult is ResultadoRequest ? _oResult.Code == 0 : false;
33  }
34  }
35 
36  private ResultadoRequest _oResult;
37 
43  public FeaturesRequest(string tcId, string tcResult)
44  {
45  Id = tcId;
46  FechaPeticion = DateTime.Now;
47  FechaProximaPeticion = FechaPeticion.AddDays(1);
48 
49  try
50  {
51  _oResult = new JavaScriptSerializer().Deserialize<ResultadoRequest>(tcResult);
52  }
53  catch(Exception loEx)
54  {
55  DB.Registrar_Error(loEx);
56  }
57  }
58  }
59 
60  internal class FeaturesServerRequest
61  : FeaturesRequest
62  {
63 
67  public FeaturesServerRequest()
68  :base("serverrequest", "")
69  {
70  FechaProximaPeticion = FechaPeticion.AddHours(1);
71  }
72  }
73 }