/// <summary> /// Initializes a new instance of the <see cref="CruiseServer" /> class. /// </summary> /// <param name="configurationService">The configuration service.</param> /// <param name="projectIntegratorListFactory">The project integrator list factory.</param> /// <param name="projectSerializer">The project serializer.</param> /// <param name="stateManager">The state manager.</param> /// <param name="fileSystem">The file system.</param> /// <param name="executionEnvironment">The execution environment.</param> /// <param name="extensionList">The extension list.</param> /// <remarks></remarks> public CruiseServer(IConfigurationService configurationService, IProjectIntegratorListFactory projectIntegratorListFactory, IProjectSerializer projectSerializer, IProjectStateManager stateManager, IFileSystem fileSystem, IExecutionEnvironment executionEnvironment, List<ExtensionConfiguration> extensionList) { this.configurationService = configurationService; this.projectSerializer = projectSerializer; this.fileSystem = fileSystem; this.executionEnvironment = executionEnvironment; // Leave the manager for backwards compatability - it is marked as obsolete #pragma warning disable 0618 manager = new CruiseManager(this); #pragma warning restore 0618 serverClient = new CruiseServerClient(this); InitializeServerThread(); // Initialise the configuration configuration = configurationService.Load(); // Initialise the queue manager integrationQueueManager = IntegrationQueueManagerFactory.CreateManager(projectIntegratorListFactory, configuration, stateManager); integrationQueueManager.AssociateIntegrationEvents(OnIntegrationStarted, OnIntegrationCompleted); securityManager = configuration.SecurityManager; // Load the extensions if (extensionList != null) { InitialiseExtensions(extensionList); } this.configurationService.AddConfigurationUpdateHandler(Restart); programmDataFolder = this.executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server); // Initialise the cache time var cacheTimeInConfig = ConfigurationManager.AppSettings["cacheTime"]; if (string.IsNullOrEmpty(cacheTimeInConfig)) { // Set the default cache time to five minutes this.cacheTime = new TimeSpan(0, 5, 0); Log.Info("Log cache time set to 5 minutes"); } else { this.cacheTime = TimeSpan.FromSeconds(Convert.ToDouble(cacheTimeInConfig, CultureInfo.CurrentCulture)); if (this.cacheTime.TotalSeconds < 5) { // If the cache time is less then 5s then turn off caching this.cacheTime = TimeSpan.MinValue; Log.Info("Log cache has been turned off"); } else { Log.Info("Log cache time set to " + this.cacheTime.TotalSeconds.ToString(CultureInfo.CurrentCulture) + " seconds"); } } }
private static IDisposable Pushd(string directory, IExecutionEnvironment platform) { var current = platform.CurrentDirectory; platform.CurrentDirectory = directory; return new DisposableAction(() => platform.CurrentDirectory = current); }
public string GenerateUserFriendlyModel(IExecutionEnvironment env, Dev2DecisionMode mode, out ErrorResultTO errors) { StringBuilder result = new StringBuilder(""); int cnt = 0; errors = new ErrorResultTO(); // build the output for decisions foreach(Dev2Decision dd in TheStack) { result.Append(dd.GenerateUserFriendlyModel(env, Mode, out errors)); // append mode if not at end if((cnt + 1) < TheStack.Count) { result.Append(Mode); } result.AppendLine(); cnt++; } // append the arms result.Append("THEN " + TrueArmText); result.AppendLine(); result.Append("ELSE " + FalseArmText); return result.ToString(); }
public void Setup() { persistanceFilePath = Path.Combine(applicationDataPath, "ProjectsState.xml"); mocks = new MockRepository(); fileSystem = mocks.StrictMock<IFileSystem>(); executionEnvironment = mocks.StrictMock<IExecutionEnvironment>(); }
internal ConfigPreprocessor(IFileSystem fileSystem, IExecutionEnvironment executionEnvironment) { this.fileSystem = fileSystem; this.executionEnvironment = executionEnvironment; programDataFolder = this.executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server); fileSystem.EnsureFolderExists(programDataFolder); }
public XmlProjectStateManager(IFileSystem fileSystem, IExecutionEnvironment executionEnvironment) { this.fileSystem = fileSystem; this.executionEnvironment = executionEnvironment; persistanceFileName = Path.Combine(this.executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server), "ProjectsState.xml"); fileSystem.EnsureFolderExists(persistanceFileName); }
/// <summary> /// Initializes a new instance of the <see cref="FileStateManager"/> class. /// </summary> /// <param name="fileSystem">The file system.</param> /// <param name="executionEnvironment">The execution environment.</param> public FileStateManager(IFileSystem fileSystem, IExecutionEnvironment executionEnvironment) { this.fileSystem = fileSystem; this.executionEnvironment = executionEnvironment; stateFileDirectory = this.executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server); fileSystem.EnsureFolderExists(stateFileDirectory); }
/// <summary> /// Initializes a new instance of the <see cref="FileBasedSessionCache" /> class. /// </summary> /// <param name="fileSystem">The file system.</param> /// <param name="executionEnvironment">The execution environment.</param> /// <param name="clock">The clock.</param> /// <remarks></remarks> public FileBasedSessionCache(IFileSystem fileSystem, IExecutionEnvironment executionEnvironment, IClock clock) : base(clock) { this.fileSystem = fileSystem; this.executionEnvironment = executionEnvironment; storeLocation = Path.Combine(this.executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server), "sessions"); fileSystem.EnsureFolderExists(storeLocation); }
IEnumerable<string> BuildQueryFromTo(SharepointSearchTo sharepointSearchTo, IExecutionEnvironment env, ISharepointFieldTo sharepointFieldTo,int update) { WarewolfIterator iterator = new WarewolfIterator(env.Eval(sharepointSearchTo.ValueToMatch,update)); while (iterator.HasMoreData()) { var fieldType = sharepointFieldTo.GetFieldType(); yield return string.Format("{0}<FieldRef Name=\"{1}\"></FieldRef><Value Type=\"{2}\">{3}</Value>{4}", SharepointSearchOptions.GetStartTagForSearchOption(sharepointSearchTo.SearchType), sharepointSearchTo.InternalName, fieldType, CastWarewolfValueToCorrectType(iterator.GetNextValue(), sharepointFieldTo.Type), SharepointSearchOptions.GetEndTagForSearchOption(sharepointSearchTo.SearchType)); } }
/// <summary> /// Initializes a new instance of the <see cref="MsBuildTask" /> class. /// </summary> /// <param name="executor">The executor.</param> /// <param name="executionEnvironment">The execution environment.</param> /// <param name="shadowCopier">The shadow copier.</param> /// <remarks></remarks> public MsBuildTask(ProcessExecutor executor, IExecutionEnvironment executionEnvironment, IShadowCopier shadowCopier) { this.executor = executor; this.executionEnvironment = executionEnvironment; this.shadowCopier = shadowCopier; this.Executable = GetDefaultExecutable(); this.Timeout = DefaultTimeout; this.Priority = ProcessPriorityClass.Normal; }
protected void CreateCvs() { mockHistoryParser = new DynamicMock(typeof (IHistoryParser)); mockFileSystem = new DynamicMock(typeof (IFileSystem)); executionEnv = new ExecutionEnvironment(); CreateProcessExecutorMock(Cvs.DefaultCvsExecutable); cvs = new Cvs((IHistoryParser)mockHistoryParser.MockInstance, (ProcessExecutor)mockProcessExecutor.MockInstance, (IFileSystem)mockFileSystem.MockInstance, executionEnv); from = new DateTime(2001, 1, 21, 20, 0, 0); to = from.AddDays(1); }
public JsonMappingEvaluated( IExecutionEnvironment env, string sourceName) { _env = env; Simple = new JsonMappingTo { SourceName = sourceName, DestinationName = CalculateDestinationNameFromSourceName(sourceName) }; }
protected override void AddItemsToIterator(IExecutionEnvironment environment) { _compresItr = new WarewolfIterator(environment.Eval(CompressionRatio)); ColItr.AddVariableToIterateOn(_compresItr); _archNameItr = new WarewolfIterator(environment.Eval(ArchiveName)); ColItr.AddVariableToIterateOn(_archNameItr); _archPassItr = new WarewolfIterator(environment.Eval(ArchivePassword)); ColItr.AddVariableToIterateOn(_archPassItr); }
/// <summary> /// Initializes a new instance of the <see cref="Cvs" /> class. /// </summary> /// <param name="parser">The parser.</param> /// <param name="executor">The executor.</param> /// <param name="fileSystem">The file system.</param> /// <param name="executionEnvironment">The execution environment.</param> /// <remarks></remarks> public Cvs(IHistoryParser parser, ProcessExecutor executor, IFileSystem fileSystem, IExecutionEnvironment executionEnvironment) : base(parser, executor) { this.fileSystem = fileSystem; this.executionEnvironment = executionEnvironment; this.Executable = DefaultCvsExecutable; this.CvsRoot = string.Empty; this.WorkingDirectory = string.Empty; this.LabelOnSuccess = false; this.RestrictLogins = string.Empty; this.UrlBuilder = new NullUrlBuilder(); this.AutoGetSource = true; this.CleanCopy = true; this.ForceCheckout = false; this.Branch = string.Empty; this.TagPrefix = "ver-"; }
public CamlQuery BuildCamlQuery(IExecutionEnvironment env, List<SharepointSearchTo> sharepointSearchTos, List<ISharepointFieldTo> fields, int update, bool requireAllCriteriaToMatch = true) { var camlQuery = CamlQuery.CreateAllItemsQuery(); var validFilters = new List<SharepointSearchTo>(); if (sharepointSearchTos != null) { validFilters = sharepointSearchTos.Where(to => !string.IsNullOrEmpty(to.FieldName) && !string.IsNullOrEmpty(to.ValueToMatch)).ToList(); } var filterCount = validFilters.Count; if (filterCount > 0) { var queryString = new StringBuilder("<View><Query><Where>"); if (filterCount > 1) { queryString.Append(requireAllCriteriaToMatch ? "<And>" : "<Or>"); } foreach (var sharepointSearchTo in validFilters) { var searchTo = sharepointSearchTo; var sharepointFieldTo = fields.FirstOrDefault(to => to.InternalName == searchTo.InternalName); var buildQueryFromTo = BuildQueryFromTo(sharepointSearchTo, env, sharepointFieldTo,update); if (buildQueryFromTo != null) { queryString.AppendLine(string.Join(Environment.NewLine, buildQueryFromTo)); } } if (filterCount > 1) { queryString.Append(requireAllCriteriaToMatch ? "</And>" : "</Or>"); } queryString.Append("</Where></Query></View>"); camlQuery.ViewXml = queryString.ToString(); } return camlQuery; }
protected override void AddDebugInputItems(IExecutionEnvironment environment, int update) { AddDebugInputItemPassword("Archive Password", ArchivePassword); }
protected override void AddDebugInputItems(IExecutionEnvironment environment, int update) { AddDebugInputItemPassword("Archive Password", ArchivePassword); }
//MO - Changed : new ctor that accepts the new arguments #pragma warning disable S1541 // Methods and properties should not be too complex #pragma warning disable S3776 // Cognitive Complexity of methods should not be too high public ForEachBootstrapTO(enForEachType forEachType, string from, string to, string csvNumbers, string numberOfExecutes, string recordsetName, IExecutionEnvironment compiler, out ErrorResultTO errors, int update) #pragma warning restore S3776 // Cognitive Complexity of methods should not be too high #pragma warning restore S1541 // Methods and properties should not be too complex { errors = new ErrorResultTO(); ForEachType = forEachType; IIndexIterator localIndexIterator; switch (forEachType) { case enForEachType.InRecordset: if (string.IsNullOrEmpty(recordsetName)) { errors.AddError(string.Format(ErrorResource.IsRequired, "The Recordset Field")); break; } var records = compiler.EvalRecordSetIndexes(recordsetName, update); if (!compiler.HasRecordSet(recordsetName)) { errors.AddError("When selecting a recordset only valid recordsets can be used"); break; } localIndexIterator = new IndexListIndexIterator(records); IndexIterator = localIndexIterator; break; case enForEachType.InRange: if (string.IsNullOrWhiteSpace(@from)) { errors.AddError(string.Format(ErrorResource.IsRequired, "The FROM field")); break; } if (string.IsNullOrWhiteSpace(to)) { errors.AddError(string.Format(ErrorResource.IsRequired, "The TO field")); break; } if (@from.Contains("(*)")) { errors.AddError(string.Format(ErrorResource.StarNotationNotAllowed, "From field")); break; } var evalledFrom = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(@from, update)); int intFrom; if (!int.TryParse(evalledFrom, out intFrom) || intFrom < 1) { errors.AddError(string.Format(ErrorResource.RangeFromOne, "FROM range")); break; } if (to.Contains("(*)")) { errors.AddError(string.Format(ErrorResource.StarNotationNotAllowed, "TO field.")); break; } var evalledTo = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(@to, update)); int intTo; if (!int.TryParse(evalledTo, out intTo) || intTo < 1) { errors.AddError(string.Format(ErrorResource.RangeFromOne, "TO range")); break; } IndexList indexList; if (intFrom > intTo) { indexList = new IndexList(new HashSet <int>(), 0) { MinValue = intFrom, MaxValue = intTo }; var revIdxItr = new ReverseIndexIterator(new HashSet <int>(), 0) { IndexList = indexList }; IndexIterator = revIdxItr; } else { indexList = new IndexList(new HashSet <int>(), 0) { MinValue = intFrom, MaxValue = intTo }; localIndexIterator = new IndexIterator(new HashSet <int>(), 0) { IndexList = indexList }; IndexIterator = localIndexIterator; } break; case enForEachType.InCSV: if (string.IsNullOrEmpty(csvNumbers)) { errors.AddError(string.Format(ErrorResource.IsRequired, "The CSV Field")); break; } var csvIndexedsItr = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(csvNumbers, update)); ErrorResultTO allErrors; var listOfIndexes = SplitOutCsvIndexes(csvIndexedsItr, out allErrors); if (allErrors.HasErrors()) { errors.MergeErrors(allErrors); break; } var listLocalIndexIterator = new ListIndexIterator(listOfIndexes); var listOfIndex = new ListOfIndex(listOfIndexes); listLocalIndexIterator.IndexList = listOfIndex; IndexIterator = listLocalIndexIterator; break; default: if (numberOfExecutes != null && numberOfExecutes.Contains("(*)")) { errors.AddError(string.Format(ErrorResource.StarNotationNotAllowed, "Numbers field.")); break; } int intExNum; var numOfExItr = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(numberOfExecutes, update)); if (!int.TryParse(numOfExItr, out intExNum) || intExNum < 1) { errors.AddError(string.Format(ErrorResource.RangeFromOne, "Number of executes")); } IndexIterator = new IndexIterator(new HashSet <int>(), intExNum); break; } }
public void PushEnvironment(IExecutionEnvironment env) { _environments.Push(Environment); Environment = env; }
public string GenerateUserFriendlyModel(IExecutionEnvironment env, Dev2DecisionMode mode, out ErrorResultTO errors) { errors = new ErrorResultTO(); return "on " + SwitchVariable; }
void AddDebugInputItemFromEntry(string expression, string parameterName, IExecutionEnvironment environment, DebugItem debugItem, int update) { AddDebugItem(new DebugEvalResult(expression, parameterName, environment, update), debugItem); }
public override List <DebugItem> GetDebugInputs(IExecutionEnvironment env, int update) { var parser = DataListFactory.CreateInputParser(); return(GetDebugInputs(env, parser, update).Select(a => (DebugItem)a).ToList()); }
public void CreateScalarInputs(IExecutionEnvironment outerEnvironment, IEnumerable <IDev2Definition> inputScalarList, IExecutionEnvironment env, int update) { foreach (var dev2Definition in inputScalarList) { CreateScalarInputs(outerEnvironment, dev2Definition, env, update); } }
void AddDebugInputItem(IExecutionEnvironment environment, int update) { AddDebugInputItem(new DebugEvalResult(Expression, "fx =", environment, update, false, true)); }
void AddDebugOutputItem(string expression, IExecutionEnvironment environment, int update) { AddDebugOutputItem(new DebugEvalResult(expression, "", environment, update)); }
static void AtomInputs(CommonFunctions.WarewolfEvalResult warewolfEvalResult, IDev2Definition dev2ColumnDefinition, IExecutionEnvironment env) { var recsetResult = warewolfEvalResult as CommonFunctions.WarewolfEvalResult.WarewolfAtomResult; if (dev2ColumnDefinition.IsRecordSet && recsetResult != null) { var correctRecSet = "[[" + dev2ColumnDefinition.RecordSetName + "(*)." + dev2ColumnDefinition.Name + "]]"; env.AssignWithFrame(new AssignValue(correctRecSet, PublicFunctions.AtomtoString(recsetResult.Item)), 0); } }
static void AtomListInputs(CommonFunctions.WarewolfEvalResult warewolfEvalResult, IDev2Definition dev2ColumnDefinition, IExecutionEnvironment env) { // TODO: why is this called but the return never used? can we remove this? DataListUtil.GetRecordsetIndexType(dev2ColumnDefinition.Value); if (warewolfEvalResult is CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult recsetResult) { var correctRecSet = "[[" + dev2ColumnDefinition.RecordSetName + "(*)." + dev2ColumnDefinition.Name + "]]"; env.EvalAssignFromNestedStar(correctRecSet, recsetResult, 0); } }
static void CreateRecordSetsInputs(IExecutionEnvironment outerEnvironment, IRecordSetDefinition recordSetDefinition, IExecutionEnvironment env, int update) { var emptyList = new List <string>(); foreach (var dev2ColumnDefinition in recordSetDefinition.Columns) { if (dev2ColumnDefinition.IsRecordSet) { var defn = "[[" + dev2ColumnDefinition.RecordSetName + "()." + dev2ColumnDefinition.Name + "]]"; if (string.IsNullOrEmpty(dev2ColumnDefinition.RawValue) && !emptyList.Contains(defn)) { emptyList.Add(defn); continue; } var warewolfEvalResult = outerEnvironment.Eval(dev2ColumnDefinition.RawValue, update); if (warewolfEvalResult.IsWarewolfAtomListresult) { AtomListInputs(warewolfEvalResult, dev2ColumnDefinition, env); } if (warewolfEvalResult.IsWarewolfAtomResult) { AtomInputs(warewolfEvalResult, dev2ColumnDefinition, env); } } } foreach (var defn in emptyList) { env.AssignDataShape(defn); } }
//MO - Changed : new ctor that accepts the new arguments public ForEachBootstrapTO(enForEachType forEachType, string from, string to, string csvNumbers, string numberOfExecutes, string recordsetName, IExecutionEnvironment compiler, out ErrorResultTO errors, int update) { errors = new ErrorResultTO(); ForEachType = forEachType; IIndexIterator localIndexIterator; switch(forEachType) { case enForEachType.InRecordset: var records = compiler.EvalRecordSetIndexes(recordsetName, update); if (!compiler.HasRecordSet(recordsetName) ) { errors.AddError("When selecting a recordset only valid recordsets can be used"); break; } localIndexIterator = new IndexListIndexIterator(records); IndexIterator = localIndexIterator; break; case enForEachType.InRange: if(string.IsNullOrWhiteSpace(@from)) { errors.AddError("The from field can not be left empty."); break; } if(string.IsNullOrWhiteSpace(to)) { errors.AddError("The to field can not be left empty."); break; } if(@from.Contains("(*)")) { errors.AddError("The Star notation is not accepted in the From field."); break; } var evalledFrom = ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(@from, update)); int intFrom; if (!int.TryParse(evalledFrom, out intFrom) || intFrom < 1) { errors.AddError("From range must be a whole number from 1 onwards."); break; } if(to.Contains("(*)")) { errors.AddError("The Star notation is not accepted in the To field."); break; } var evalledTo= ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(@to, update)); int intTo; if (!int.TryParse(evalledTo, out intTo) || intTo < 1) { errors.AddError("To range must be a whole number from 1 onwards."); break; } IndexList indexList; if(intFrom > intTo) { indexList = new IndexList(new HashSet<int>(), 0) { MinValue = intFrom, MaxValue = intTo }; ReverseIndexIterator revIdxItr = new ReverseIndexIterator(new HashSet<int>(), 0) { IndexList = indexList }; IndexIterator = revIdxItr; } else { indexList = new IndexList(new HashSet<int>(), 0) { MinValue = intFrom, MaxValue = intTo }; localIndexIterator = new IndexIterator(new HashSet<int>(), 0) { IndexList = indexList }; IndexIterator = localIndexIterator; } break; case enForEachType.InCSV: var csvIndexedsItr = ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(csvNumbers, update)); ErrorResultTO allErrors; List<int> listOfIndexes = SplitOutCsvIndexes(csvIndexedsItr, out allErrors); if(allErrors.HasErrors()) { errors.MergeErrors(allErrors); break; } ListIndexIterator listLocalIndexIterator = new ListIndexIterator(listOfIndexes); ListOfIndex listOfIndex = new ListOfIndex(listOfIndexes); listLocalIndexIterator.IndexList = listOfIndex; IndexIterator = listLocalIndexIterator; break; default: if(numberOfExecutes != null && numberOfExecutes.Contains("(*)")) { errors.AddError("The Star notation is not accepted in the Numbers field."); break; } int intExNum; var numOfExItr = ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(numberOfExecutes, update)); if (!int.TryParse(numOfExItr, out intExNum)) { errors.AddError("Number of executes must be a whole number from 1 onwards."); } IndexIterator = new IndexIterator(new HashSet<int>(), intExNum); break; } }
public override List <DebugItem> GetDebugOutputs(IExecutionEnvironment env, int update) { GetDebugOutputsFromEnv(env, update); return(_debugOutputs); }
public string GenerateUserFriendlyModel(IExecutionEnvironment env, Dev2DecisionMode mode, out ErrorResultTO errors) { errors = new ErrorResultTO(); ErrorResultTO allErrors = new ErrorResultTO(); string fn = DecisionDisplayHelper.GetDisplayValue(EvaluationFn); if(PopulatedColumnCount == 0) { return "If " + fn + " "; } if(PopulatedColumnCount == 1) { if(DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star) { var allValues = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors); allErrors.MergeErrors(errors); StringBuilder expandStarredIndex = new StringBuilder(); expandStarredIndex.Append(allValues[0] + " " + fn); allValues.RemoveAt(0); foreach(var value in allValues) { expandStarredIndex.Append(" " + mode + " " + value + " " + fn); } errors = allErrors; return "If " + expandStarredIndex; } errors = allErrors; return "If " + Col1 + " " + fn + " "; } if(PopulatedColumnCount == 2) { StringBuilder expandStarredIndices = new StringBuilder(); if(DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star) { var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors); allErrors.MergeErrors(errors); expandStarredIndices.Append(Col1 + " " + fn + " " + allCol2Values[0]); allCol2Values.RemoveAt(0); foreach(var value in allCol2Values) { expandStarredIndices.Append(" " + mode + " " + Col1 + " " + fn + " " + value); } errors = allErrors; return "If " + expandStarredIndices; } if(DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors); allErrors.MergeErrors(errors); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + Col2); allCol1Values.RemoveAt(0); foreach(var value in allCol1Values) { expandStarredIndices.Append(" " + mode + " " + value + " " + fn + " " + Col2); } errors = allErrors; return "If " + expandStarredIndices; } if((DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star) || (DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star)) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors); allErrors.MergeErrors(errors); var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors); allErrors.MergeErrors(errors); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + allCol2Values[0]); allCol1Values.RemoveAt(0); allCol2Values.RemoveAt(0); for(var i = 0; i < Math.Max(allCol1Values.Count, allCol2Values.Count); i++) { if(i > allCol1Values.Count) { allCol1Values.Add(null); } if(i > allCol2Values.Count) { allCol2Values.Add(null); } try { expandStarredIndices.Append(" " + mode + " " + allCol1Values[i] + " " + fn + " " + allCol2Values[i]); } catch(IndexOutOfRangeException) { errors.AddError("You appear to have recordsets of differnt sizes"); allErrors.MergeErrors(errors); } } errors = allErrors; return "If " + expandStarredIndices; } errors = allErrors; return "If " + Col1 + " " + fn + " " + Col2 + " "; } if(PopulatedColumnCount == 3) { var expandStarredIndices = ResolveStarredIndices(env, mode.ToString(), out errors); allErrors.MergeErrors(errors); if(!string.IsNullOrEmpty(expandStarredIndices)) { errors = allErrors; return expandStarredIndices; } errors = allErrors; return "If " + Col1 + " " + fn + " " + Col2 + " and " + Col3; } errors = allErrors; return "<< Internal Error Generating Decision Model: Populated Column Count Cannot Exeed 3 >>"; }
private void AddDebugInputItem(string lengthExpression, string fromExpression, string toExpression, IExecutionEnvironment executionEnvironment, enRandomType randomType, int update) { AddDebugInputItem(new DebugItemStaticDataParams(randomType.GetDescription(), "Random")); if (randomType == enRandomType.Guid) { return; } if (randomType == enRandomType.Numbers) { AddDebugInputItem(new DebugEvalResult(fromExpression, "From", executionEnvironment, update)); AddDebugInputItem(new DebugEvalResult(toExpression, "To", executionEnvironment, update)); } else { AddDebugInputItem(new DebugEvalResult(lengthExpression, "Length", executionEnvironment, update)); } }
static internal void CreateRecordSetsInputs(IExecutionEnvironment outerEnvironment, IRecordSetDefinition recordSetDefinition, IList <IDev2Definition> inputs, IExecutionEnvironment env, int update) { var outPutRecSet = inputs.FirstOrDefault(definition => definition.IsRecordSet && DataListUtil.ExtractRecordsetNameFromValue(definition.MapsTo) == recordSetDefinition.SetName); if (outPutRecSet != null) { CreateRecordSetsInputs(outerEnvironment, recordSetDefinition, env, update); } }
Dev2DecisionStack ResolveAllRecords(IExecutionEnvironment env, Dev2DecisionStack stack, Dev2Decision decision, bool[] effectedCols, out ErrorResultTO errors, int update) { if (effectedCols == null) { throw new ArgumentNullException("effectedCols"); } var stackIndex = stack.TheStack.IndexOf(decision); stack.TheStack.Remove(decision); errors = new ErrorResultTO(); if (effectedCols[0]) { var data = env.EvalAsListOfStrings(decision.Col1, update); var reStackIndex = stackIndex; foreach (var item in data) { var newDecision = new Dev2Decision { Col1 = item, Col2 = decision.Col2, Col3 = decision.Col3, EvaluationFn = decision.EvaluationFn }; stack.TheStack.Insert(reStackIndex++, newDecision); } } if (effectedCols[1]) { var data = env.EvalAsListOfStrings(decision.Col2, update); var reStackIndex = stackIndex; foreach (var item in data) { var newDecision = new Dev2Decision { Col1 = FetchStackValue(stack, reStackIndex, 1), Col2 = item, Col3 = decision.Col3, EvaluationFn = decision.EvaluationFn }; if (effectedCols[0]) { // ensure we have the correct indexing ;) if (reStackIndex < stack.TheStack.Count) { stack.TheStack[reStackIndex++] = newDecision; } else { stack.TheStack.Insert(reStackIndex++, newDecision); } } else { stack.TheStack.Insert(reStackIndex++, newDecision); } } } if (effectedCols[2]) { var data = env.EvalAsListOfStrings(decision.Col3, update); var reStackIndex = stackIndex; foreach (var item in data) { var newDecision = new Dev2Decision { Col1 = FetchStackValue(stack, reStackIndex, 1), Col2 = FetchStackValue(stack, reStackIndex, 2), Col3 = item, EvaluationFn = decision.EvaluationFn }; if (effectedCols[0] || effectedCols[1]) { // ensure we have the correct indexing ;) if (reStackIndex < stack.TheStack.Count) { stack.TheStack[reStackIndex++] = newDecision; } else { stack.TheStack.Insert(reStackIndex++, newDecision); } } else { stack.TheStack.Insert(reStackIndex++, newDecision); } } } return(stack); }
static void CreateObjectInputs(IExecutionEnvironment outerEnvironment, IDev2Definition dev2Definition, IExecutionEnvironment env, int update) { if (DataListUtil.RemoveLanguageBrackets(dev2Definition.RawValue).StartsWith("@")) { var jVal = outerEnvironment.EvalJContainer(dev2Definition.RawValue); env.AddToJsonObjects(DataListUtil.AddBracketsToValueIfNotExist(dev2Definition.Name), jVal); } else { var result = outerEnvironment.Eval(dev2Definition.RawValue, update); if (result.IsWarewolfAtomListresult) { if (result is CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult data && data.Item.Any()) { env.AssignWithFrame(new AssignValue(DataListUtil.AddBracketsToValueIfNotExist(dev2Definition.Name), ExecutionEnvironment.WarewolfAtomToString(data.Item.Last())), 0); } } else { if (result is CommonFunctions.WarewolfEvalResult.WarewolfAtomResult data) { env.AssignWithFrame(new AssignValue(DataListUtil.AddBracketsToValueIfNotExist(dev2Definition.Name), ExecutionEnvironment.WarewolfAtomToString(data.Item)), 0); } } } }
void UpdateResultRegions(IExecutionEnvironment environment, string result) { environment.Assign(Result, result); }
//MO - Changed : new ctor that accepts the new arguments public ForEachBootstrapTO(enForEachType forEachType, string from, string to, string csvNumbers, string numberOfExecutes, string recordsetName, IExecutionEnvironment compiler, out ErrorResultTO errors, int update) { errors = new ErrorResultTO(); ForEachType = forEachType; IIndexIterator localIndexIterator; switch (forEachType) { case enForEachType.InRecordset: var records = compiler.EvalRecordSetIndexes(recordsetName, update); if (!compiler.HasRecordSet(recordsetName)) { errors.AddError("When selecting a recordset only valid recordsets can be used"); break; } localIndexIterator = new IndexListIndexIterator(records); IndexIterator = localIndexIterator; break; case enForEachType.InRange: if (string.IsNullOrWhiteSpace(@from)) { errors.AddError("The from field can not be left empty."); break; } if (string.IsNullOrWhiteSpace(to)) { errors.AddError("The to field can not be left empty."); break; } if (@from.Contains("(*)")) { errors.AddError("The Star notation is not accepted in the From field."); break; } var evalledFrom = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(@from, update)); int intFrom; if (!int.TryParse(evalledFrom, out intFrom) || intFrom < 1) { errors.AddError("From range must be a whole number from 1 onwards."); break; } if (to.Contains("(*)")) { errors.AddError("The Star notation is not accepted in the To field."); break; } var evalledTo = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(@to, update)); int intTo; if (!int.TryParse(evalledTo, out intTo) || intTo < 1) { errors.AddError("To range must be a whole number from 1 onwards."); break; } IndexList indexList; if (intFrom > intTo) { indexList = new IndexList(new HashSet <int>(), 0) { MinValue = intFrom, MaxValue = intTo }; ReverseIndexIterator revIdxItr = new ReverseIndexIterator(new HashSet <int>(), 0) { IndexList = indexList }; IndexIterator = revIdxItr; } else { indexList = new IndexList(new HashSet <int>(), 0) { MinValue = intFrom, MaxValue = intTo }; localIndexIterator = new IndexIterator(new HashSet <int>(), 0) { IndexList = indexList }; IndexIterator = localIndexIterator; } break; case enForEachType.InCSV: var csvIndexedsItr = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(csvNumbers, update)); ErrorResultTO allErrors; List <int> listOfIndexes = SplitOutCsvIndexes(csvIndexedsItr, out allErrors); if (allErrors.HasErrors()) { errors.MergeErrors(allErrors); break; } ListIndexIterator listLocalIndexIterator = new ListIndexIterator(listOfIndexes); ListOfIndex listOfIndex = new ListOfIndex(listOfIndexes); listLocalIndexIterator.IndexList = listOfIndex; IndexIterator = listLocalIndexIterator; break; default: if (numberOfExecutes != null && numberOfExecutes.Contains("(*)")) { errors.AddError("The Star notation is not accepted in the Numbers field."); break; } int intExNum; var numOfExItr = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(numberOfExecutes, update)); if (!int.TryParse(numOfExItr, out intExNum)) { errors.AddError("Number of executes must be a whole number from 1 onwards."); } IndexIterator = new IndexIterator(new HashSet <int>(), intExNum); break; } }
public void SetUp() { mocks = new MockRepository(); fileSystem = mocks.DynamicMock <IFileSystem>(); executionEnvironment = mocks.DynamicMock <IExecutionEnvironment>(); }
public void PushEnvironment(IExecutionEnvironment env) { _environments.Push(Environment); Environment = env; }
public override List <DebugItem> GetDebugInputs(IExecutionEnvironment env, int update) => _debugInputs;
protected override void AddItemsToIterator(IExecutionEnvironment environment, int update) { _archPassItr = new WarewolfIterator(environment.Eval(ArchivePassword, update)); ColItr.AddVariableToIterateOn(_archPassItr); }
public override List <DebugItem> GetDebugInputs(IExecutionEnvironment dataList, int update) { return(_debugInputs); }
protected override void AddItemsToIterator(IExecutionEnvironment environment,int update) { _archPassItr = new WarewolfIterator(environment.Eval(DecryptedArchivePassword,update)); ColItr.AddVariableToIterateOn(_archPassItr); }
static void CreateScalarInputs(IExecutionEnvironment outerEnvironment, IDev2Definition dev2Definition, IExecutionEnvironment env, int update) { void ScalarAtomList(CommonFunctions.WarewolfEvalResult warewolfEvalResult) { if (warewolfEvalResult is CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult data && data.Item.Any()) { env.AssignWithFrame(new AssignValue("[[" + dev2Definition.Name + "]]", ExecutionEnvironment.WarewolfAtomToString(data.Item.Last())), 0); } } void ScalarAtom(CommonFunctions.WarewolfEvalResult warewolfEvalResult) { if (warewolfEvalResult is CommonFunctions.WarewolfEvalResult.WarewolfAtomResult data) { env.AssignWithFrame(new AssignValue("[[" + dev2Definition.Name + "]]", ExecutionEnvironment.WarewolfAtomToString(data.Item)), 0); } } if (!string.IsNullOrEmpty(dev2Definition.Name)) { env.AssignDataShape("[[" + dev2Definition.Name + "]]"); } if (!dev2Definition.IsRecordSet && !string.IsNullOrEmpty(dev2Definition.RawValue)) { var warewolfEvalResult = outerEnvironment.Eval(dev2Definition.RawValue, update); if (warewolfEvalResult.IsWarewolfAtomListresult) { ScalarAtomList(warewolfEvalResult); } else { ScalarAtom(warewolfEvalResult); } } }
public ExecTask(IExecutionEnvironment executionEnvironment) : base(executionEnvironment) { }
IEnumerable<string> BuildQueryFromTo(SharepointSearchTo sharepointSearchTo, IExecutionEnvironment env, ISharepointFieldTo sharepointFieldTo,int update) { var warewolfEvalResult = env.Eval(sharepointSearchTo.ValueToMatch, update); var fieldType = sharepointFieldTo.GetFieldType(); if (sharepointSearchTo.SearchType == "In") { var startSearchTerm = string.Format("{0}<FieldRef Name=\"{1}\"></FieldRef>", SharepointSearchOptions.GetStartTagForSearchOption(sharepointSearchTo.SearchType), sharepointSearchTo.InternalName); startSearchTerm+="<Values>"; if(warewolfEvalResult.IsWarewolfAtomListresult) { var listResult = warewolfEvalResult as WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfAtomListresult; if (listResult != null) { foreach(var warewolfAtom in listResult.Item) { var valueString = warewolfAtom.ToString(); if (valueString.Contains(",")) { var listOfValues = valueString.Split(','); startSearchTerm = listOfValues.Select(listOfValue => CastWarewolfValueToCorrectType(listOfValue, sharepointFieldTo.Type)).Aggregate(startSearchTerm, (current, value) => current + string.Format("<Value Type=\"{0}\">{1}</Value>", fieldType, value)); } else { var value = CastWarewolfValueToCorrectType(valueString, sharepointFieldTo.Type); startSearchTerm += string.Format("<Value Type=\"{0}\">{1}</Value>", fieldType, value); } } } }else { var scalarResult = warewolfEvalResult as WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfAtomResult; if(scalarResult!=null) { var valueString = scalarResult.Item.ToString(); if (valueString.Contains(",")) { var listOfValues = valueString.Split(','); startSearchTerm = listOfValues.Select(listOfValue => CastWarewolfValueToCorrectType(listOfValue, sharepointFieldTo.Type)).Aggregate(startSearchTerm, (current, value) => current + string.Format("<Value Type=\"{0}\">{1}</Value>", fieldType, value)); } else { var value = CastWarewolfValueToCorrectType(valueString, sharepointFieldTo.Type); startSearchTerm += string.Format("<Value Type=\"{0}\">{1}</Value>", fieldType, value); } } } startSearchTerm += "</Values>"; startSearchTerm += SharepointSearchOptions.GetEndTagForSearchOption(sharepointSearchTo.SearchType); yield return startSearchTerm; } else { WarewolfIterator iterator = new WarewolfIterator(warewolfEvalResult); while (iterator.HasMoreData()) { yield return string.Format("{0}<FieldRef Name=\"{1}\"></FieldRef><Value Type=\"{2}\">{3}</Value>{4}", SharepointSearchOptions.GetStartTagForSearchOption(sharepointSearchTo.SearchType), sharepointSearchTo.InternalName, fieldType, CastWarewolfValueToCorrectType(iterator.GetNextValue(), sharepointFieldTo.Type), SharepointSearchOptions.GetEndTagForSearchOption(sharepointSearchTo.SearchType)); } } }
public Cvs(IHistoryParser parser, ProcessExecutor executor, IFileSystem fileSystem, IExecutionEnvironment executionEnvironment) : base(parser, executor) { this.fileSystem = fileSystem; this.executionEnvironment = executionEnvironment; }
protected ProjectBase(IExecutionEnvironment executionEnvironment) { this.executionEnvironment = executionEnvironment; }
public void SetUp() { mocks = new MockRepository(); fileSystem = mocks.DynamicMock<IFileSystem>(); executionEnvironment = mocks.DynamicMock<IExecutionEnvironment>(); }
public JsonMappingCompoundTo( IExecutionEnvironment env, JsonMappingTo compound) { _env = env; Compound = compound; Evaluations = new List<JsonMappingEvaluated>(); if (!IsCompound) { Evaluations.Add(new JsonMappingEvaluated(_env, compound.SourceName)); } else { if (WarewolfDataEvaluationCommon.ParseLanguageExpression(Compound.SourceName,0).IsRecordSetNameExpression) { Evaluations = new List<JsonMappingEvaluated> { new JsonMappingEvaluated(_env, Compound.SourceName) }; } else { // we know this is a comma seperated list of expressions Evaluations = // ReSharper disable MaximumChainedReferences ((LanguageAST.LanguageExpression.ComplexExpression)WarewolfDataEvaluationCommon.ParseLanguageExpression(Compound.SourceName,0)) .Item .Where(x => !x.IsWarewolfAtomAtomExpression) .Select(WarewolfDataEvaluationCommon.LanguageExpressionToString) .Select(x => new JsonMappingEvaluated(_env, x)) .ToList(); } // ReSharper restore MaximumChainedReferences } }
public HostedOperatorContext(Uri instanceId, IScheduler scheduler, TraceSource traceSource, IExecutionEnvironment executionEnvironment, IReactive service) : base(instanceId, scheduler, traceSource, executionEnvironment) { ReactiveService = service ?? throw new ArgumentNullException(nameof(service)); }
public void CreateRecordSetsInputs(IExecutionEnvironment outerEnvironment, IRecordSetCollection inputRecSets, IList <IDev2Definition> inputs, IExecutionEnvironment env, int update) { foreach (var recordSetDefinition in inputRecSets.RecordSets) { CreateRecordSetsInputsImpl.CreateRecordSetsInputs(outerEnvironment, recordSetDefinition, inputs, env, update); } }
public string GenerateUserFriendlyModel(IExecutionEnvironment env, Dev2DecisionMode mode, out ErrorResultTO errors) { errors = new ErrorResultTO(); return "For " + CaseValue; }
public override List <DebugItem> GetDebugOutputs(IExecutionEnvironment env) { return(_debugOutputs); }
internal ExecTask(IFileSystem fileSystem, IExecutionEnvironment platform, Path program) : base(fileSystem, platform) { this.program = program; }
private void AddSourceStringDebugInputItem(string expression, IExecutionEnvironment environment) { AddDebugInputItem(new DebugEvalResult(expression, "XML", environment)); }
protected override void ConfigureLogging(ILoggingBuilder logging, IExecutionEnvironment executionEnvironment) { // Use this method to configure the logging }
public DebugEvalResult(string inputVariable, string label, IExecutionEnvironment environment, int update, bool isDataMerge = false) { _inputVariable = inputVariable.Trim(); _label = label; try { if (ExecutionEnvironment.IsRecordsetIdentifier(_inputVariable) && DataListUtil.IsEvaluated(_inputVariable)) { if (DataListUtil.GetRecordsetIndexType(_inputVariable) == enRecordsetIndexType.Blank) { var length = environment.GetLength(DataListUtil.ExtractRecordsetNameFromValue(_inputVariable)); _inputVariable = DataListUtil.ReplaceRecordsetBlankWithIndex(_inputVariable, length); } } if (isDataMerge) { var evalForDataMerge = environment.EvalForDataMerge(_inputVariable, update); var innerIterator = new WarewolfListIterator(); var innerListOfIters = new List <WarewolfIterator>(); foreach (var listOfIterator in evalForDataMerge) { var inIterator = new WarewolfIterator(listOfIterator); innerIterator.AddVariableToIterateOn(inIterator); innerListOfIters.Add(inIterator); } var atomList = new List <DataASTMutable.WarewolfAtom>(); while (innerIterator.HasMoreData()) { var stringToUse = ""; // ReSharper disable once LoopCanBeConvertedToQuery foreach (var warewolfIterator in innerListOfIters) { stringToUse += warewolfIterator.GetNextValue(); } atomList.Add(DataASTMutable.WarewolfAtom.NewDataString(stringToUse)); } var finalString = string.Join("", atomList); _evalResult = WarewolfDataEvaluationCommon.WarewolfEvalResult.NewWarewolfAtomListresult(new WarewolfAtomList <DataASTMutable.WarewolfAtom>(DataASTMutable.WarewolfAtom.Nothing, atomList)); if (DataListUtil.IsFullyEvaluated(finalString)) { _inputVariable = finalString; _evalResult = environment.Eval(finalString, update); } else { var evalToExpression = environment.EvalToExpression(_inputVariable, update); if (DataListUtil.IsEvaluated(evalToExpression)) { _inputVariable = evalToExpression; } } } else { var evalToExpression = environment.EvalToExpression(_inputVariable, update); if (DataListUtil.IsEvaluated(evalToExpression)) { _inputVariable = evalToExpression; } _evalResult = environment.Eval(_inputVariable, update); } } catch (Exception e) { Dev2Logger.Log.Error(e.Message, e); _evalResult = WarewolfDataEvaluationCommon.WarewolfEvalResult.NewWarewolfAtomResult(DataASTMutable.WarewolfAtom.Nothing); } }
internal MSBuild40Task(IFileSystem fileSystem, IExecutionEnvironment platform) : base(fileSystem, platform) { }
public void CreateObjectInputs(IExecutionEnvironment outerEnvironment, IEnumerable <IDev2Definition> inputObjectList, IExecutionEnvironment env, int update) { foreach (var dev2Definition in inputObjectList) { if (!string.IsNullOrEmpty(dev2Definition.RawValue)) { CreateObjectInputs(outerEnvironment, dev2Definition, env, update); } } }