public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg) { string errorMessage; if (!Validate(out errorMessage)) { throw new ArgumentException(errorMessage); } string lookupKey; if (!pInMsg.Context.TryRead(new ContextProperty(SourcePropertyPath), out lookupKey)) { throw new InvalidOperationException("Could not find lookup key in context"); } var util = new LookupUtilityService(_repository); var value = util.GetValue(ListName, lookupKey, DefaultValue); if (string.IsNullOrEmpty(value)) { throw new InvalidOperationException("Could not find value for key " + lookupKey); } pInMsg.Context.Promote(new ContextProperty(DestinationPropertyPath), value); return(pInMsg); }
public static void Init(TestContext context) { mock = new Mock <ILookupRepository>(); util = new LookupUtilityService(mock.Object); var dictionary = new Dictionary <string, string>(); dictionary.Add("ConfigKey", "ConfigValue"); dictionary.Add("default", "DefaultValue"); mock.Setup(s => s.LoadList(list)).Returns(dictionary); }
public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg) { string errorMessage; if (!Validate(out errorMessage)) { throw new ArgumentException(errorMessage); } //component will not be executed if the property is set to true if (Disabled) { return(pInMsg); } //get the value from the provided property IBaseMessageContext context = pInMsg.Context; string key = (string)context.Read(new ContextProperty(PropertyPath)); // PropertyPath.Split('#')[1], PropertyPath.Split('#')[0]).ToString(); //query the sharepoint table var lookupService = new LookupUtilityService(new SharepointLookupRepository()); string result = ""; try { result = lookupService.GetValue(ListName, key, true); }catch (ArgumentException ex) { if (ThrowException) { throw ex; } else { System.Diagnostics.EventLog.WriteEntry(pContext.PipelineName, ex.Message, System.Diagnostics.EventLogEntryType.Warning); } } //promote the result to the provided destination property if (PromoteProperty) { pInMsg.Context.Promote(new ContextProperty(DestinationPath), result); } else { pInMsg.Context.Write(new ContextProperty(DestinationPath), result); } return(pInMsg); }
public SharePointApplicationService() { //Todo: Check if code is run from Visual Studio or BizTalk. //bool isBizTalk = Process.GetCurrentProcess() // .ProcessName.ToLower().Contains("btsntsvc.exe"); //if(isBizTalk) //{ svc = new LookupUtilityService(new SharepointLookupRepository()); //} //else //{ //svc = new LookupUtilityService(new LookupRepositoryMock()); //} }
public SSOApplicationService() { _lookupUtilityService = new LookupUtilityService(new SSOLookupRepository()); }
public SqlApplicationService() { svc = new LookupUtilityService(new SqlLookupRepository()); }