private IProcessingContextCollection PrepareSignals(string moduleName, string signalKey, bool isWriteOperation, InputModelParameters inputModelParametersTemplate) { List <IProcessingContext> resultContexts = new List <IProcessingContext>(); bool isMaintenance = false; InputModelParameters inputModelParameters = inputModelParametersTemplate.DeepClone(); if (string.IsNullOrEmpty(moduleName) || moduleName.Equals("null", StringComparison.OrdinalIgnoreCase))//Apply for all modules { foreach (KraftModule kraftModule in _KraftModuleCollection.GetSortedModules()) { KraftModuleSignal signal = FindSignal(kraftModule, signalKey); if (signal != null) { isMaintenance = signal.Maintenance; if (kraftModule.KraftModuleRootConf.Signals.Count > 0) { resultContexts.Add(Signal2ProcessingContext(inputModelParameters, kraftModule, signal, isWriteOperation)); } } } } else { KraftModule kraftModule = _KraftModuleCollection.GetSortedModules().Find(m => m.Key.Equals(moduleName, StringComparison.OrdinalIgnoreCase)); KraftModuleSignal signal = FindSignal(kraftModule, signalKey); if (signal != null) { isMaintenance = signal.Maintenance; resultContexts.Add(Signal2ProcessingContext(inputModelParameters, kraftModule, signal, isWriteOperation)); } } _ProcessingContextCollection = new ProcessingContextCollection(resultContexts, isMaintenance); return(_ProcessingContextCollection); }
public override IProcessingContextCollection GenerateProcessingContexts(string kraftRequestFlagsKey, ISecurityModel securityModel = null) { Dictionary <string, object> data = ReconstructFromMultipart(); List <InputModel> inputModels = new List <InputModel>(); if (securityModel == null) { if (_KraftGlobalConfigurationSettings.GeneralSettings.AuthorizationSection.RequireAuthorization) { securityModel = new SecurityModel(_HttpContext); } else { securityModel = new SecurityModelMock(_KraftGlobalConfigurationSettings.GeneralSettings.AuthorizationSection); } } InputModelParameters inputModelParameters = CreateBaseInputModelParameters(_KraftGlobalConfigurationSettings, securityModel); inputModelParameters = ExtendInputModelParameters(inputModelParameters); inputModelParameters.LoaderType |= ELoaderType.DataLoader; //TODO Not override passed in flags inputModelParameters.Data = data; _ProcessingContextCollection = new ProcessingContextCollection(CreateProcessingContexts(new List <InputModel>() { new InputModel(inputModelParameters) })); return(_ProcessingContextCollection); }
public override IProcessingContextCollection GenerateProcessingContexts(string kraftRequestFlagsKey, ISecurityModel securityModel = null) { IProcessingContext processingContext = new ProcessingContext(this); List <IProcessingContext> processingContexts = new List <IProcessingContext>(); processingContexts.Add(processingContext); _ProcessingContextCollection = new ProcessingContextCollection(processingContexts); return(_ProcessingContextCollection); }
public override IProcessingContextCollection GenerateProcessingContexts(KraftGlobalConfigurationSettings kraftGlobalConfigurationSettings, string kraftRequestFlagsKey, ISecurityModel securityModel = null) { IProcessingContext processingContext = new ProcessingContext(this); processingContext.InputModel = new InputModel(new InputModelParameters()); List <IProcessingContext> processingContexts = new List <IProcessingContext>(); processingContexts.Add(processingContext); _ProcessingContextCollection = new ProcessingContextCollection(processingContexts); return(_ProcessingContextCollection); }
public override IProcessingContextCollection GenerateProcessingContexts(string kraftRequestFlagsKey, ISecurityModel securityModel = null) { List <InputModel> inputModels = new List <InputModel>(); List <BatchRequest> batchRequests = new List <BatchRequest>(); if (_RequestContentType == ESupportedContentTypes.JSON) { batchRequests = GetBodyJson <List <BatchRequest> >(_HttpContext.Request); } foreach (BatchRequest batchRequest in batchRequests) { InputModel inputModel = CreateInputModel(batchRequest, _KraftGlobalConfigurationSettings, kraftRequestFlagsKey, securityModel); inputModels.Add(inputModel); } _ProcessingContextCollection = new ProcessingContextCollection(CreateProcessingContexts(inputModels)); return(_ProcessingContextCollection); }
public override void GenerateResponse() { IProcessingContext processingContext = new ProcessingContext(this); List <Dictionary <string, object> > listData = new List <Dictionary <string, object> >(); Type postedFileType = typeof(PostedFile); foreach (IProcessingContext item in _ProcessingContextCollection.ProcessingContexts) { if (item.ReturnModel.Status.IsSuccessful) { listData.Add(new Dictionary <string, object>()); Dictionary <string, object> currentData = item.ReturnModel.Data as Dictionary <string, object>; if (currentData != null) { foreach (string key in currentData.Keys) { if (currentData[key].GetType() != postedFileType) { listData[listData.Count - 1].Add(key, currentData[key]); } } } } if (processingContext.ReturnModel.Status.IsSuccessful) { processingContext.ReturnModel.Status.IsSuccessful = item.ReturnModel.Status.IsSuccessful; } processingContext.ReturnModel.Status.StatusResults.AddRange(item.ReturnModel.Status.StatusResults); } processingContext.ReturnModel.Data = listData; List <IProcessingContext> processingContexts = new List <IProcessingContext>(); processingContexts.Add(processingContext); ProcessingContextCollection processingContextCollection = new ProcessingContextCollection(processingContexts); HttpResponseBuilder responseBuilder = new XmlPacketResponseBuilder(processingContextCollection); responseBuilder.GenerateResponse(_HttpContext); }
public override IProcessingContextCollection GenerateProcessingContexts(KraftGlobalConfigurationSettings kraftGlobalConfigurationSettings, string kraftRequestFlagsKey, ISecurityModel securityModel = null) { Dictionary <string, object> files = ResolveMultipartAsJson(); List <InputModel> inputModels = new List <InputModel>(); if (files != null) { foreach (string key in files.Keys) { if (files[key] is IPostedFile postedFile) { if (securityModel == null) { if (kraftGlobalConfigurationSettings.GeneralSettings.AuthorizationSection.RequireAuthorization) { securityModel = new SecurityModel(_HttpContext); } else { securityModel = new SecurityModelMock(kraftGlobalConfigurationSettings.GeneralSettings.AuthorizationSection); } } InputModelParameters inputModelParameters = CreateBaseInputModelParameters(kraftGlobalConfigurationSettings, securityModel); inputModelParameters = ExtendInputModelParameters(inputModelParameters); inputModelParameters.LoaderType |= ELoaderType.DataLoader; //TODO Not override passed in flags foreach (string metaInfoKey in postedFile.MetaInfo.Keys) { inputModelParameters.Data.Add(metaInfoKey, postedFile.MetaInfo[metaInfoKey]); } inputModelParameters.Data.Add(key, postedFile); inputModels.Add(new InputModel(inputModelParameters)); } } } _ProcessingContextCollection = new ProcessingContextCollection(CreateProcessingContexts(inputModels)); return(_ProcessingContextCollection); }
public override IProcessingContextCollection GenerateProcessingContexts(KraftGlobalConfigurationSettings kraftGlobalConfigurationSettings, string kraftRequestFlagsKey, ISecurityModel securityModel = null) { if (securityModel == null) { if (kraftGlobalConfigurationSettings.GeneralSettings.AuthorizationSection.RequireAuthorization) { securityModel = new SecurityModel(_HttpContext); } else { securityModel = new SecurityModelMock(kraftGlobalConfigurationSettings.GeneralSettings.AuthorizationSection); } } InputModelParameters inputModelParameters = CreateBaseInputModelParameters(kraftGlobalConfigurationSettings, securityModel); inputModelParameters = ExtendInputModelParameters(inputModelParameters); inputModelParameters.Data = GetBodyJson <Dictionary <string, object> >(_HttpContext.Request); inputModelParameters.FormCollection = _FormCollection; inputModelParameters.LoaderType = GetLoaderType(kraftRequestFlagsKey); if (inputModelParameters.LoaderType == ELoaderType.None) { inputModelParameters.LoaderType = ELoaderType.ViewLoader; } RouteData routeData = _HttpContext.GetRouteData(); if (routeData != null) { inputModelParameters.BindingKey = routeData.Values[Constants.RouteSegmentConstants.RouteBindingkey] as string; } IProcessingContext processingContext = new ProcessingContext(this); processingContext.InputModel = new InputModel(inputModelParameters); List <IProcessingContext> processingContexts = new List <IProcessingContext>(1); processingContexts.Add(processingContext); _ProcessingContextCollection = new ProcessingContextCollection(processingContexts); return(_ProcessingContextCollection); }
public override IProcessingContextCollection GenerateProcessingContexts(KraftGlobalConfigurationSettings kraftGlobalConfigurationSettings, string kraftRequestFlagsKey, ISecurityModel securityModel = null) { if (securityModel == null) { if (kraftGlobalConfigurationSettings.GeneralSettings.AuthorizationSection.RequireAuthorization) { securityModel = new SecurityModel(_HttpContext); } else { securityModel = new SecurityModelMock(kraftGlobalConfigurationSettings.GeneralSettings.AuthorizationSection); } } InputModelParameters inputModelParameters = CreateBaseInputModelParameters(kraftGlobalConfigurationSettings, securityModel); inputModelParameters = ExtendInputModelParameters(inputModelParameters); inputModelParameters.Data = GetBodyJson <Dictionary <string, object> >(_HttpContext.Request); inputModelParameters.FormCollection = _FormCollection; inputModelParameters.LoaderType = GetLoaderType(kraftRequestFlagsKey); _ProcessingContextCollection = new ProcessingContextCollection(CreateProcessingContexts(new List <InputModel> { new InputModel(inputModelParameters) })); return(_ProcessingContextCollection); }
public BinaryResponseBuilder(ProcessingContextCollection processingContextCollection) { _ProcessingContextCollection = processingContextCollection; }