Beispiel #1
0
        /// <summary>
        /// Try to fulfill the request from cache, if a cache directory has been set.
        /// If the request can be served from cache, the content stream is initialised for the cache source,
        /// and the state is set to finished.
        /// </summary>
        /// <returns>True if the request could be served from the cache.</returns>
        public bool TryCache()
        {
            try
            {
#if VERBOSE
                Log.Write(Log.Levels.Verbose, "DataRequest: trying to fulfill request for " + this.Source + " from cache");
                Log.Write(Log.Levels.Verbose, "DataRequest: trying " + m_request.CacheLocation);
#endif
                if (m_request.CacheCallback != null)
                {
#if VERBOSE
                    Log.Write(Log.Levels.Verbose, "DataRequest: asking cache callback for file stream");
#endif
                    m_contentStream = m_request.CacheCallback(m_request); //new FileStream(m_request.CacheLocation, FileMode.Open);
                    if (m_contentStream != null)
                    {
                        m_state    = DataRequestState.Finished;
                        m_cacheHit = true;

                        m_cacheHits++;
                        return(true);
                    }
                }
                return(false);
            }
            catch (IOException)
            {
                return(false);
            }
        }
Beispiel #2
0
 public DataRequest(DataRequestDescriptor request)
 {
     m_lock          = new Object();
     m_request       = request;
     m_contentStream = null;
     m_state         = DataRequestState.Queued;
     m_cacheHit      = false;
     m_headers       = new NameValueCollection();
     m_priority      = 50;
     m_totalRequests++;
     m_nextTry = DateTime.Now;
 }
Beispiel #3
0
        public AboutFormSettings
        (
            [NameValue(AttributeNames.DEFAULTVALUE, "Title")]
            [Comments("Header field on the form")]
            string title,

            [Comments("Includes the URL to retrieve the data.")]
            RequestDetails requestDetails,

            [Comments("Defines the state of the request including the sort, filter, page and page size.")]
            DataRequestState state,

            [Comments("List of fields and form groups for display.")]
            List <DetailItem> fieldSettings
        )
        {
            Title          = title;
            RequestDetails = requestDetails;
            State          = state;
            FieldSettings  = fieldSettings;
        }
Beispiel #4
0
        public DropDownTemplate
        (
            [Comments("HTML template for the drop-down.")]
            [NameValue(AttributeNames.DEFAULTVALUE, "dropDownTemplate")]
            string templateName,

            [Comments("Place holder text.")]
            [NameValue(AttributeNames.DEFAULTVALUE, "Select One ...")]
            string placeHolderText,

            [Comments("Update modelType first. Property name for the text field. Use a period for nested fields i.e. foo.bar.")]
            [ParameterEditorControl(ParameterControlType.ParameterSourcedPropertyInput)]
            [NameValue(AttributeNames.PROPERTYSOURCEPARAMETER, "modelType")]
            string textField,

            [Comments("Update modelType first. Property name for the value field. Use a period for nested fields i.e. foo.bar.")]
            [ParameterEditorControl(ParameterControlType.ParameterSourcedPropertyInput)]
            [NameValue(AttributeNames.PROPERTYSOURCEPARAMETER, "modelType")]
            string valueField,

            [Comments("Details about the drop-down data source including joins and partial field set (selects).")]
            RequestDetails requestDetails,

            [Comments("The request state defines sorting, filtering, grouping and aggregates if necessary.")]
            DataRequestState state = null,

            [ParameterEditorControl(ParameterControlType.ParameterSourceOnly)]
            [Comments("Fully qualified class name for the model type.")]
            string modelType = "Contoso.Domain.Entities"
        )
        {
            TemplateName    = templateName;
            PlaceHolderText = placeHolderText;
            TextField       = textField;
            ValueField      = valueField;
            State           = state;
            RequestDetails  = requestDetails;
        }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataRequestResult"/> struct.
 /// </summary>
 /// <param name="requestState">
 /// The request state.
 /// </param>
 /// <param name="resultRoute">
 /// The result route.
 /// </param>
 public DataRequestResult(DataRequestState requestState, TravelRoute resultRoute)
 {
     this.RequestState = requestState;
     this.ResultRoute = resultRoute;
 }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JourneyEventArgs"/> class.
 /// </summary>
 /// <param name="route">
 /// The route.
 /// </param>
 /// <param name="requestState">
 /// The request state.
 /// </param>
 /// <param name="initiatedDate">
 /// The initiated date.
 /// </param>
 public JourneyEventArgs(TravelRoute route, DataRequestState requestState, DateTime initiatedDate)
 {
     this.ResultRoute = route;
     this.RequestState = requestState;
     this.RequestInitiatedDate = initiatedDate;
 }