static BOAContextData GetOrCreateContext(BOAContextData data, Action <string> trace) { if (data.context != null) { return(data); } data = LoadBOAConfigurationFile(data, trace); var context = new ExecutionDataContext { EngineContext = new EngineContext() }; data = LoadBOAConfigurationFile(data, trace); data = Authenticate(data, trace, ConfigurationManager.ChannelSection.Channel.DefaultChannel); context.ApplicationContext = data.authenticationResponse.ApplicationContext; var createNewBusinessKey = FPExtensions.Fun(() => { const string ResourceCode = "ODSTATMTCP"; return(new BusinessKey(context).CreateBusinessKey(ResourceCode, context.ApplicationContext.User.BranchId, DateTime.Now.Date).Value); }); context.EngineContext.MainBusinessKey = createNewBusinessKey(); return(data.WithExecutionDataContext(context)); }
static BOAContextData Authenticate(BOAContextData data, Action <string> trace, ChannelContract channelContract) { if (data.authenticationResponse != null) { return(data); } data = LoadBOAConfigurationFile(data, trace); var request = new AuthenticationRequest { AuthenticationContext = new AuthenticationContext { Channel = channelContract, UserName = AuthenticationUserName } }; trace("Authenticate response waiting..."); var response = new UserManager().Authenticate(request); if (!response.Success) { throw new AuthenticationException("LoginFailed." + StringHelper.ResultToDetailedString(response.Results)); } trace("Authenticate is success."); return(data.WithAuthenticationResponse(response)); }
static BOAContextData LoadBOAConfigurationFile(BOAContextData data, Action <string> trace) { if (data.IsBoaConfigurationFileLoaded) { return(data); } BoaConfigurationFile.Load(data.EnvironmentInfo.ToString, trace); return(data.MarkAsConfigurationFileLoaded()); }
static BOAContextData GetOrCreateObjectHelper(BOAContextData data, Action <string> trace) { if (data.objectHelper != null) { return(data); } data = GetOrCreateContext(data, trace); var objectHelper = new ObjectHelper { Context = data.context }; objectHelper.Context.DBLayer.BeginTransaction(); return(data.WithObjectHelper(objectHelper)); }
public BOAContext(EnvironmentInfo environmentInfo, Action <string> trace) { data = new BOAContextData(environmentInfo); this.trace = trace; }
/// <summary> /// Loads the boa configuration file. /// </summary> public void LoadBOAConfigurationFile() { data = LoadBOAConfigurationFile(data, trace); }
/// <summary> /// Gets the object helper. /// </summary> public ObjectHelper GetObjectHelper() { data = GetOrCreateObjectHelper(data, trace); return(data.objectHelper); }
/// <summary> /// Authenticates the specified channel contract. /// </summary> public void Authenticate(ChannelContract channelContract) { data = Authenticate(data, trace, channelContract); }