/// <inheritdoc /> public override IEnumerable <UploadSession> GetStaleSessions(DateTime staleBefore) { List <UploadSession> sessions = new List <UploadSession>(); string sql; sql = "SELECT " + _statusField + " FROM " + _table + " AS kw_sessions WHERE " + _requestIdField + " IS NULL AND (SELECT MAX(" + _lastUpdatedField + ") FROM " + _table + " AS kw_status WHERE kw_status." + _sessionIdField + "=kw_sessions." + _sessionIdField + ") < " + _lastUpdatedParameterName; using (IDbConnection cn = CreateConnection(_connectionString)) using (IDbCommand cmd = cn.CreateCommand()) { cmd.CommandText = sql; AddParameter(cmd, _lastUpdatedParameterName, DbType.DateTime, staleBefore); cn.Open(); using (IDataReader rd = cmd.ExecuteReader(CommandBehavior.SingleResult)) { while (rd.Read()) { sessions.Add(UploadSession.Deserialize(rd.GetString(0))); } } } return(sessions); }
/// <inheritdoc /> public override UploadSession GetSession(string uploadSessionId) { string data = GetData(uploadSessionId, null); if (!string.IsNullOrEmpty(data)) { return(UploadSession.Deserialize(data)); } else { return(null); } }
internal static object GetStringDeserialized(string value) { value = value.Replace(' ', '+'); // TODO: decrypt ObjectStateFormatter formatter = new ObjectStateFormatter(); if (string.IsNullOrEmpty(value)) { return(null); } else if (value.StartsWith("session-")) { return(UploadSession.Deserialize(value.Substring("session-".Length))); } else if (value.StartsWith("request-")) { return(UploadRequest.Deserialize(value.Substring("request-".Length))); } else if (value.StartsWith("sessionlist-")) { string[] uploadSessionStrings = (string[])formatter.Deserialize(value.Substring("sessionlist-".Length)); List <UploadSession> sessions = new List <UploadSession>(); foreach (string sessionString in uploadSessionStrings) { sessions.Add(UploadSession.Deserialize(sessionString)); } return(sessions); } else if (value.StartsWith("requestlist-")) { string[] uploadRequestStrings = (string[])formatter.Deserialize(value.Substring("requestlist-".Length)); List <UploadRequest> requests = new List <UploadRequest>(); foreach (string requestString in uploadRequestStrings) { requests.Add(UploadRequest.Deserialize(requestString)); } return(requests); } else { return(formatter.Deserialize(value)); } }