|
|
@ -48,6 +48,7 @@ namespace FLocal.Common.dataobjects { |
|
|
|
public const string FIELD_SESSIONKEY = "SessionKey"; |
|
|
|
public const string FIELD_SESSIONKEY = "SessionKey"; |
|
|
|
public const string FIELD_ACCOUNTID = "AccountId"; |
|
|
|
public const string FIELD_ACCOUNTID = "AccountId"; |
|
|
|
public const string FIELD_LASTACTIVITY = "LastActivity"; |
|
|
|
public const string FIELD_LASTACTIVITY = "LastActivity"; |
|
|
|
|
|
|
|
public const string FIELD_LASTHUMANACTIVITY = "LastHumanActivity"; |
|
|
|
public const string FIELD_LASTURL = "LastUrl"; |
|
|
|
public const string FIELD_LASTURL = "LastUrl"; |
|
|
|
public const string FIELD_ISDELETED = "IsDeleted"; |
|
|
|
public const string FIELD_ISDELETED = "IsDeleted"; |
|
|
|
public static readonly TableSpec instance = new TableSpec(); |
|
|
|
public static readonly TableSpec instance = new TableSpec(); |
|
|
@ -87,6 +88,14 @@ namespace FLocal.Common.dataobjects { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private DateTime _lastHumanActivity; |
|
|
|
|
|
|
|
public DateTime lastHumanActivity { |
|
|
|
|
|
|
|
get { |
|
|
|
|
|
|
|
this.LoadIfNotLoaded(); |
|
|
|
|
|
|
|
return this._lastHumanActivity; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private string _lastUrl; |
|
|
|
private string _lastUrl; |
|
|
|
public string lastUrl { |
|
|
|
public string lastUrl { |
|
|
|
get { |
|
|
|
get { |
|
|
@ -105,7 +114,8 @@ namespace FLocal.Common.dataobjects { |
|
|
|
|
|
|
|
|
|
|
|
protected override void doFromHash(Dictionary<string, string> data) { |
|
|
|
protected override void doFromHash(Dictionary<string, string> data) { |
|
|
|
this._sessionKey = data[TableSpec.FIELD_SESSIONKEY]; |
|
|
|
this._sessionKey = data[TableSpec.FIELD_SESSIONKEY]; |
|
|
|
this._lastActivity = new DateTime(long.Parse(data[TableSpec.FIELD_LASTACTIVITY])); |
|
|
|
this._lastActivity = Util.ParseDateTimeFromTimestamp(data[TableSpec.FIELD_LASTACTIVITY]).Value; |
|
|
|
|
|
|
|
this._lastHumanActivity = Util.ParseDateTimeFromTimestamp(data[TableSpec.FIELD_LASTHUMANACTIVITY]).Value; |
|
|
|
this._accountId = int.Parse(data[TableSpec.FIELD_ACCOUNTID]); |
|
|
|
this._accountId = int.Parse(data[TableSpec.FIELD_ACCOUNTID]); |
|
|
|
this._lastUrl = data[TableSpec.FIELD_LASTURL]; |
|
|
|
this._lastUrl = data[TableSpec.FIELD_LASTURL]; |
|
|
|
this._isDeleted = Util.string2bool(data[TableSpec.FIELD_ISDELETED]); |
|
|
|
this._isDeleted = Util.string2bool(data[TableSpec.FIELD_ISDELETED]); |
|
|
@ -117,17 +127,21 @@ namespace FLocal.Common.dataobjects { |
|
|
|
string _url = lastUrl.ToLower(); |
|
|
|
string _url = lastUrl.ToLower(); |
|
|
|
if(_url.StartsWith("/upload/item")) return; |
|
|
|
if(_url.StartsWith("/upload/item")) return; |
|
|
|
if(_url.StartsWith("/static")) return; |
|
|
|
if(_url.StartsWith("/static")) return; |
|
|
|
|
|
|
|
if(_url.StartsWith("/favicon.ico")) return; |
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
Dictionary<string, string> dataToUpdate = new Dictionary<string,string>(); |
|
|
|
|
|
|
|
dataToUpdate[TableSpec.FIELD_LASTACTIVITY] = DateTime.Now.ToUTCString(); |
|
|
|
|
|
|
|
if(lastUrl != null) { |
|
|
|
|
|
|
|
dataToUpdate[TableSpec.FIELD_LASTURL] = lastUrl; |
|
|
|
|
|
|
|
dataToUpdate[TableSpec.FIELD_LASTHUMANACTIVITY] = DateTime.Now.ToUTCString(); |
|
|
|
|
|
|
|
} |
|
|
|
Config.Transactional(transaction => { |
|
|
|
Config.Transactional(transaction => { |
|
|
|
Config.instance.mainConnection.update( |
|
|
|
Config.instance.mainConnection.update( |
|
|
|
transaction, |
|
|
|
transaction, |
|
|
|
TableSpec.instance, |
|
|
|
TableSpec.instance, |
|
|
|
this.id.ToString(), |
|
|
|
this.id.ToString(), |
|
|
|
new Dictionary<string,string>() { |
|
|
|
dataToUpdate |
|
|
|
{ TableSpec.FIELD_LASTACTIVITY, DateTime.Now.ToUTCString() }, |
|
|
|
|
|
|
|
{ TableSpec.FIELD_LASTURL, (lastUrl != null) ? lastUrl : this.lastUrl }, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
@ -154,6 +168,7 @@ namespace FLocal.Common.dataobjects { |
|
|
|
{ TableSpec.FIELD_SESSIONKEY, key }, |
|
|
|
{ TableSpec.FIELD_SESSIONKEY, key }, |
|
|
|
{ TableSpec.FIELD_ACCOUNTID, account.id.ToString() }, |
|
|
|
{ TableSpec.FIELD_ACCOUNTID, account.id.ToString() }, |
|
|
|
{ TableSpec.FIELD_LASTACTIVITY, DateTime.Now.ToUTCString() }, |
|
|
|
{ TableSpec.FIELD_LASTACTIVITY, DateTime.Now.ToUTCString() }, |
|
|
|
|
|
|
|
{ TableSpec.FIELD_LASTHUMANACTIVITY, DateTime.Now.ToUTCString() }, |
|
|
|
{ TableSpec.FIELD_LASTURL, "" }, |
|
|
|
{ TableSpec.FIELD_LASTURL, "" }, |
|
|
|
{ TableSpec.FIELD_ISDELETED, "0" }, |
|
|
|
{ TableSpec.FIELD_ISDELETED, "0" }, |
|
|
|
} |
|
|
|
} |
|
|
@ -181,7 +196,7 @@ namespace FLocal.Common.dataobjects { |
|
|
|
|
|
|
|
|
|
|
|
public XElement exportToXml(UserContext context) { |
|
|
|
public XElement exportToXml(UserContext context) { |
|
|
|
return new XElement("session", |
|
|
|
return new XElement("session", |
|
|
|
new XElement("lastActivity", this.lastActivity.ToXml()), |
|
|
|
new XElement("lastActivity", this.lastHumanActivity.ToXml()), |
|
|
|
new XElement("sessionKey", this.sessionKey), |
|
|
|
new XElement("sessionKey", this.sessionKey), |
|
|
|
this.account.user.exportToXmlForViewing(context), |
|
|
|
this.account.user.exportToXmlForViewing(context), |
|
|
|
AccountIndicator.LoadByAccount(this.account).exportToXml(context) |
|
|
|
AccountIndicator.LoadByAccount(this.account).exportToXml(context) |
|
|
@ -206,7 +221,7 @@ namespace FLocal.Common.dataobjects { |
|
|
|
new JoinSpec[0], |
|
|
|
new JoinSpec[0], |
|
|
|
new SortSpec[] { |
|
|
|
new SortSpec[] { |
|
|
|
new SortSpec( |
|
|
|
new SortSpec( |
|
|
|
TableSpec.instance.getColumnSpec(TableSpec.FIELD_LASTACTIVITY), |
|
|
|
TableSpec.instance.getColumnSpec(TableSpec.FIELD_LASTHUMANACTIVITY), |
|
|
|
false |
|
|
|
false |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|