/// <summary>
        /// Gets static files by TModel and actionType.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="actionType"></param>
        /// <returns></returns>
        private async Task <HttpResponseMessage> Get <TModel>(TModel model, ActionType actionType)
            where TModel : StaticFileModel
        {
            var result = new HttpResponseMessage();

            if (!ModelState.IsValid)
            {
                result.StatusCode = HttpStatusCode.BadRequest;
                return(result);
            }

            try
            {
                var processor = _processorFactory.GetProcessor <TModel>(model, actionType);
                var request   = await processor.Process(model, actionType);

                result.Content = new StreamContent(request.File);

                return(result);
            }

            catch (Exception e)
            {
                return(HandleException(e));
            }
        }
Пример #2
0
        /// <summary>
        /// Processor a XML file into the MongoDB.
        /// </summary>
        /// <param name="directoryPath">the directory of all the files to process</param>
        private static void ProcessFiles(string directoryPath)
        {
            foreach (var FileName in Directory.GetFiles(directoryPath))
            {
                IProcessor Processor = IProcessorFactory.GetProcessor(FileName);

                if (Processor != null)
                {
                    Processor.ProcessFile();
                }
            }
        }
Пример #3
0
    public void MyLogic()
    {
        IProcessor processor = _processorFactory.GetProcessor(_settings);

        processor.Process();
    }