// BUG 9706 - 2013.06.22 - TWR : refactored void DispatchDebugErrors(ErrorResultTO errors, IDSFDataObject dataObject, StateType stateType) { if (errors.HasErrors() && dataObject.IsDebugMode()) { Guid parentInstanceId; Guid.TryParse(dataObject.ParentInstanceID, out parentInstanceId); var debugState = new DebugState { ID = dataObject.DataListID, ParentID = parentInstanceId, WorkspaceID = dataObject.WorkspaceID, StateType = stateType, StartTime = DateTime.Now, EndTime = DateTime.Now, ActivityType = ActivityType.Workflow, DisplayName = dataObject.ServiceName, IsSimulation = dataObject.IsOnDemandSimulation, ServerID = dataObject.ServerID, OriginatingResourceID = dataObject.ResourceID, OriginalInstanceID = dataObject.OriginalInstanceID, SessionID = dataObject.DebugSessionID, EnvironmentID = dataObject.EnvironmentID, ClientID = dataObject.ClientID, Server = string.Empty, Version = string.Empty, Name = GetType().Name, HasError = errors.HasErrors(), ErrorMessage = errors.MakeDisplayReady() }; DebugDispatcher.Instance.Write(debugState, dataObject.RemoteInvoke, dataObject.RemoteInvokerID); } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { var allErrors = new ErrorResultTO(); var errors = new ErrorResultTO(); allErrors.MergeErrors(errors); InitializeDebug(dataObject); // Process if no errors try { TryExecute(dataObject, update, allErrors, errors); } catch (Exception e) { Dev2Logger.Error("DSFDateTime", e, GlobalConstants.WarewolfError); allErrors.AddError(e.Message); } finally { // Handle Errors if (allErrors.HasErrors()) { DisplayAndWriteError("DsfDateTimeDifferenceActivity", allErrors); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); dataObject.Environment.Assign(Result, null, update); } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { var allErrors = new ErrorResultTO(); InitializeDebug(dataObject); try { TryExecute(dataObject, update, allErrors); } catch (Exception e) { Dev2Logger.Error("DSFDateTime", e, GlobalConstants.WarewolfError); allErrors.AddError(e.Message); } finally { // Handle Errors var hasErrors = allErrors.HasErrors(); if (hasErrors) { DisplayAndWriteError("DsfDateTimeActivity", allErrors); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); } if (dataObject.IsDebugMode()) { if (hasErrors) { AddDebugOutputItem(new DebugItemStaticDataParams("", Result, "")); } DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { var allErrors = new ErrorResultTO(); try { var activity = ExecuteDecision(dataObject); NextNodes = new List <IDev2Activity> { activity }; } catch (Exception e) { allErrors.AddError(e.Message); } finally { // Handle Errors var hasErrors = allErrors.HasErrors(); if (hasErrors) { DisplayAndWriteError("DsfDecision", allErrors); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.After, update); _debugOutputs = new List <DebugItem>(); } } }
public void ErrorResultTO_MakeDisplayReady_ShouldReturnAllErrorsAsOne() { var result = new StringBuilder(); result.AppendLine("SomeError"); result.Append("AnotherError"); var errorResultTo = new ErrorResultTO(); Assert.IsNotNull(errorResultTo); var prObj = new PrivateObject(errorResultTo); var errors = prObj.GetField("_errorList") as IList <string>; Assert.IsNotNull(errors); Assert.AreEqual(0, errors.Count); errorResultTo.AddError("SomeError"); errorResultTo.AddError("AnotherError"); errors = prObj.GetField("_errorList") as IList <string>; if (errors != null) { Assert.AreEqual(2, errors.Count); } var makeDisplayReady = errorResultTo.MakeDisplayReady(); Assert.AreEqual(result.ToString(), makeDisplayReady); }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { _debugInputs = new List <DebugItem>(); _debugOutputs = new List <DebugItem>(); _indexCounter = 1; var allErrors = new ErrorResultTO(); try { ExecuteConcreteAction(dataObject, update); } catch (Exception e) { Dev2Logger.Error("SharepointReadListActivity", e, GlobalConstants.WarewolfError); allErrors.AddError(e.Message); } finally { var hasErrors = allErrors.HasErrors(); if (hasErrors) { DisplayAndWriteError("SharepointReadListActivity", allErrors); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { var errorResultTo = new ErrorResultTO(); var allErrors = new ErrorResultTO(); var addExceptionToErrorList = true; InitializeDebug(dataObject); try { var parametersIteratorCollection = BuildParametersIteratorCollection(dataObject.Environment, out IWarewolfIterator batchItr, out IWarewolfIterator timeoutItr, update); var currentOptions = BuildSqlBulkCopyOptions(); var runtimeDatabase = ResourceCatalog.GetResource <DbSource>(dataObject.WorkspaceID, Database.ResourceID); Common.Utilities.PerformActionInsideImpersonatedContext(Common.Utilities.OrginalExecutingUser, () => { if (!allErrors.HasErrors()) { if (runtimeDatabase.ServerType == enSourceType.MySqlDatabase) { DoInsertForMySql(runtimeDatabase, currentOptions, parametersIteratorCollection, batchItr, timeoutItr, dataObject, errorResultTo, allErrors, ref addExceptionToErrorList, update); } else { DoInsertForSqlServer(runtimeDatabase, currentOptions, dataObject, allErrors, batchItr, parametersIteratorCollection, timeoutItr, ref errorResultTo, ref addExceptionToErrorList, update); } } }); allErrors.MergeErrors(errorResultTo); } catch (Exception e) { if (addExceptionToErrorList) { allErrors.AddError(e.Message); } Dev2Logger.Error(this, e, GlobalConstants.WarewolfError); } finally { // Handle Errors if (allErrors.HasErrors()) { DisplayAndWriteError("DsfSqlBulkInsertActivity", allErrors); dataObject.Environment.Assign(Result, null, update); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); if (dataObject.IsDebugMode()) { AddDebugOutputItem(new DebugItemStaticDataParams("Failure", Result, "", "=")); } } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { var errorResultTo = new ErrorResultTO(); var allErrors = new ErrorResultTO(); bool addExceptionToErrorList = true; InitializeDebug(dataObject); try { IWarewolfIterator batchItr; IWarewolfIterator timeoutItr; var parametersIteratorCollection = BuildParametersIteratorCollection(dataObject.Environment, out batchItr, out timeoutItr, update); var currentOptions = BuildSqlBulkCopyOptions(); var runtimeDatabase = ResourceCatalog.Instance.GetResource <DbSource>(dataObject.WorkspaceID, Database.ResourceID); if (runtimeDatabase.ServerType == enSourceType.MySqlDatabase) { DoInsertForMySql(runtimeDatabase, currentOptions, parametersIteratorCollection, batchItr, timeoutItr, dataObject, errorResultTo, allErrors, ref addExceptionToErrorList, update); } else { DoInsertForSqlServer(runtimeDatabase, currentOptions, dataObject, allErrors, batchItr, parametersIteratorCollection, timeoutItr, ref errorResultTo, ref addExceptionToErrorList, update); } allErrors.MergeErrors(errorResultTo); } catch (Exception e) { if (addExceptionToErrorList) { allErrors.AddError(e.Message); } // ReSharper disable InvokeAsExtensionMethod Dev2Logger.Log.Error(this, e); // ReSharper restore InvokeAsExtensionMethod } finally { // Handle Errors if (allErrors.HasErrors()) { DisplayAndWriteError("DsfSqlBulkInsertActivity", allErrors); dataObject.Environment.Assign(Result, null, update); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); if (dataObject.IsDebugMode()) { AddDebugOutputItem(new DebugItemStaticDataParams("Failure", Result, "", "=")); } } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { var searchQuery = new SearchQuery(this, Result, RequireAllFieldsToMatch, RequireAllTrue); var allErrors = new ErrorResultTO(); try { InitializeDebug(dataObject); var searchContext = new SearchContext(this); if (dataObject.IsDebugMode()) { TryAddDebugInputValues(dataObject, searchContext.ToSearch, ref allErrors, update); } searchQuery.Execute(searchContext, allErrors, dataObject, update); if (dataObject.IsDebugMode()) { if (DataListUtil.IsValueRecordset(Result)) { var recVar = DataListUtil.ReplaceRecordsetBlankWithStar(Result); AddDebugOutputItem(new DebugEvalResult(recVar, "", dataObject.Environment, update)); } else { AddDebugOutputItem(new DebugEvalResult(Result, "", dataObject.Environment, update)); } } } catch (Exception exception) { Dev2Logger.Error("DSFRecordsMultipleCriteria", exception, GlobalConstants.WarewolfError); allErrors.AddError(exception.Message); } finally { var hasErrors = allErrors.HasErrors(); if (hasErrors) { DisplayAndWriteError("DsfFindRecordsMultipleCriteriaActivity", allErrors); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); dataObject.Environment.Assign(Result, "-1", update); if (dataObject.IsDebugMode()) { AddDebugOutputItem(new DebugEvalResult(Result, "", dataObject.Environment, update)); } } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { AddScriptSourcePathsToList(); var allErrors = new ErrorResultTO(); var errors = new ErrorResultTO(); allErrors.MergeErrors(errors); var env = dataObject.Environment; InitializeDebug(dataObject); try { if (!errors.HasErrors()) { if (dataObject.IsDebugMode()) { var language = ScriptType.GetDescription(); AddDebugInputItem(new DebugItemStaticDataParams(language, "Language")); AddDebugInputItem(new DebugEvalResult(Script, "Script", env, update)); } allErrors.MergeErrors(errors); if (allErrors.HasErrors()) { return; } TryExecute(dataObject, update, allErrors, env); } } catch (Exception e) when(e is NullReferenceException || e is RuntimeBinderException) { allErrors.AddError(e.GetType() == typeof(NullReferenceException) || e.GetType() == typeof(RuntimeBinderException) ? ErrorResource.ScriptingErrorReturningValue : e.Message.Replace(" for main:Object", string.Empty)); } finally { // Handle Errors if (allErrors.HasErrors()) { DisplayAndWriteError("DsfScriptingPythonActivity", allErrors); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); } if (dataObject.IsDebugMode()) { if (allErrors.HasErrors()) { AddDebugOutputItem(new DebugItemStaticDataParams("", Result, "")); } DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
protected override void ExecuteTool(IDSFDataObject dataObject) { _debugInputs = new List <DebugItem>(); _debugOutputs = new List <DebugItem>(); ErrorResultTO allErrors = new ErrorResultTO(); ErrorResultTO errors = new ErrorResultTO(); InitializeDebug(dataObject); try { ValidateRecordsetName(RecordsetName, errors); GetDebug(dataObject); dataObject.Environment.EvalDelete(RecordsetName); if (!string.IsNullOrEmpty(Result)) { dataObject.Environment.Assign(Result, "Success"); AddDebugOutputItem(new DebugEvalResult(Result, "", dataObject.Environment)); } } catch (Exception e) { allErrors.AddError(e.Message); } finally { // Handle Errors var hasErrors = allErrors.HasErrors(); if (hasErrors) { DisplayAndWriteError("DsfDeleteRecordsActivity", allErrors); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); if (!string.IsNullOrEmpty(Result)) { dataObject.Environment.Assign(Result, "Failure"); } } if (dataObject.IsDebugMode()) { if (hasErrors) { AddDebugOutputItem(new DebugItemStaticDataParams("Failure", Result, "")); } DispatchDebugState(dataObject, StateType.Before); DispatchDebugState(dataObject, StateType.After); } } }
ErrorResultTO TryInvokeService(IDSFDataObject dataObject, ErrorResultTO errors) { var serviceId = dataObject.ResourceID; var serviceName = dataObject.ServiceName; if (serviceId == Guid.Empty && string.IsNullOrEmpty(serviceName)) { errors.AddError(Resources.DynamicServiceError_ServiceNotSpecified); } else { try { errors = InvokeService(dataObject, errors, serviceId, serviceName); } catch (Exception e) { errors.AddError(e.Message, true); } finally { var environment = dataObject.Environment; if (environment.HasErrors()) { var errorString = environment.FetchErrors(); var executionErrors = ErrorResultTO.MakeErrorResultFromDataListString(errorString, true); errors.MergeErrors(executionErrors); } if (dataObject.ReturnType == Web.EmitionTypes.XML || dataObject.ReturnType == Web.EmitionTypes.TRX) { environment.AddError(errors.MakeDataListReady(), true); } else { environment.AddError(errors.MakeDataListReady(false), true); } if (errors.HasErrors()) { Dev2Logger.Error(errors.MakeDisplayReady(), dataObject.ExecutionID.ToString()); } } } return(errors); }
private void HandleErrors(IDSFDataObject dataObject, int update, ErrorResultTO allErrors) { var hasErrors = allErrors.HasErrors(); if (hasErrors) { DisplayAndWriteError(nameof(DsfBaseConvertActivity), allErrors); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { IDev2MergeOperations mergeOperations = new Dev2MergeOperations(); var allErrors = new ErrorResultTO(); var errorResultTo = new ErrorResultTO(); InitializeDebug(dataObject); try { CleanArguments(MergeCollection); if (MergeCollection.Count <= 0) { return; } TryExecuteTool(dataObject, update, mergeOperations, allErrors, errorResultTo); } catch (Exception e) { Dev2Logger.Error("DSFDataMerge", e, GlobalConstants.WarewolfError); allErrors.AddError(e.Message); } finally { #region Handle Errors if (allErrors.HasErrors()) { if (dataObject.IsDebugMode()) { AddDebugOutputItem(new DebugItemStaticDataParams("", Result, "")); } DisplayAndWriteError("DsfDataMergeActivity", allErrors); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } #endregion } }
public void ErrorResultTO_MakeDisplayReady_ShouldReturnAllErrorsAsOne() { var result = new StringBuilder(); result.AppendLine("SomeError"); result.Append("AnotherError"); var errorResultTo = new ErrorResultTO(); Assert.AreEqual(0, errorResultTo.FetchErrors().Count); errorResultTo.AddError("SomeError"); errorResultTo.AddError("AnotherError"); Assert.AreEqual(2, errorResultTo.FetchErrors().Count); var makeDisplayReady = errorResultTo.MakeDisplayReady(); Assert.AreEqual(result.ToString(), makeDisplayReady); }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { _debugOutputs.Clear(); _debugInputs.Clear(); InitializeDebug(dataObject); var errors = new ErrorResultTO(); var allErrors = new ErrorResultTO(); try { if (!errors.HasErrors()) { var innerCount = 1; foreach (AssignObjectDTO t in FieldsCollection) { TryExecuteField(dataObject, update, allErrors, innerCount++, t); } dataObject.Environment.CommitAssign(); allErrors.MergeErrors(errors); } } catch (Exception e) { //Dev2Logger.Error(e, GlobalConstants.WarewolfError); allErrors.AddError(e.Message); } finally { // Handle Errors var hasErrors = allErrors.HasErrors(); if (hasErrors) { var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); DisplayAndWriteError(dataObject, DisplayName, allErrors); } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { AddScriptSourcePathsToList(); var allErrors = new ErrorResultTO(); var env = dataObject.Environment; InitializeDebug(dataObject); try { TryExecute(dataObject, update, allErrors, env); } catch (NullReferenceException) { allErrors.AddError(ErrorResource.ScriptingErrorReturningValue); } catch (RuntimeBinderException e) { allErrors.AddError(e.Message.Replace(" for main:Object", string.Empty)); } catch (Exception e) { allErrors.AddError(e.Message); } finally { if (allErrors.HasErrors()) { var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); DisplayAndWriteError(dataObject, DisplayName, allErrors); } if (dataObject.IsDebugMode()) { if (allErrors.HasErrors()) { AddDebugOutputItem(new DebugItemStaticDataParams("", Result, "")); } DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { var allErrors = new ErrorResultTO(); var errors = new ErrorResultTO(); allErrors.MergeErrors(errors); InitializeDebug(dataObject); // Process if no errors try { ValidateRecordsetName(RecordsetName, errors); allErrors.MergeErrors(errors); if(!allErrors.HasErrors()) { try { TryExecuteTool(dataObject, update, allErrors); } catch (Exception e) { allErrors.AddError(e.Message); dataObject.Environment.Assign(RecordsLength, "0", update); AddDebugOutputItem(new DebugItemStaticDataParams("0", RecordsLength, "", "=")); } } } finally { // Handle Errors var hasErrors = allErrors.HasErrors(); if(hasErrors) { DisplayAndWriteError("DsfRecordsetNullhandlerLengthActivity", allErrors); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); } if(dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { IDev2IndexFinder indexFinder = new Dev2IndexFinder(); var allErrors = new ErrorResultTO(); var errors = new ErrorResultTO(); InitializeDebug(dataObject); try { TryExecute(dataObject, update, indexFinder, allErrors, errors); } catch (Exception e) { Dev2Logger.Error("DSFFindActivity", e, GlobalConstants.WarewolfError); allErrors.AddError(e.Message); } finally { #region Handle Errors var hasErrors = allErrors.HasErrors(); if (hasErrors) { DisplayAndWriteError("DsfIndexActivity", allErrors); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); } #endregion if (dataObject.IsDebugMode()) { if (hasErrors) { AddDebugOutputItem(new DebugEvalResult(Result, "", dataObject.Environment, update)); } DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
void HandleErrors(IDSFDataObject dataObject, int update, ErrorResultTO allErrors) { var hasErrors = allErrors.HasErrors(); if (hasErrors) { var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); DisplayAndWriteError(dataObject, DisplayName, allErrors); } if (dataObject.IsDebugMode()) { if (hasErrors) { AddDebugOutputItem(Result, dataObject.Environment, update); } DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } }
ErrorResultTO TryInvokeService(IDSFDataObject dataObject, ErrorResultTO errors) { var serviceId = dataObject.ResourceID; var serviceName = dataObject.ServiceName; if (serviceId == Guid.Empty && string.IsNullOrEmpty(serviceName)) { errors.AddError(Resources.DynamicServiceError_ServiceNotSpecified); } else { try { errors = InvokeService(dataObject, errors, serviceId, serviceName); } catch (Exception e) { errors.AddError(e.Message); } finally { var environment = dataObject.Environment; if (environment.HasErrors()) { var errorString = environment.FetchErrors(); var executionErrors = ErrorResultTO.MakeErrorResultFromDataListString(errorString); errors.MergeErrors(executionErrors); } environment.AddError(errors.MakeDataListReady()); if (errors.HasErrors()) { Dev2Logger.Error(errors.MakeDisplayReady(), GlobalConstants.WarewolfError); } } } return(errors); }
void HandleErrors(IDSFDataObject dataObject, int update, ErrorResultTO allErrors) { var hasErrors = allErrors.HasErrors(); if (!hasErrors && dataObject.Environment.Errors.Any()) { DisplayAndWriteError(dataObject, DisplayName, allErrors); } if (hasErrors) { var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); DisplayAndWriteError(dataObject, DisplayName, allErrors); } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.After, update); _debugOutputs = new List <DebugItem>(); } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { var allErrors = new ErrorResultTO(); InitializeDebug(dataObject); try { AddValidationErrors(allErrors); if (!allErrors.HasErrors()) { if (dataObject.IsDebugMode()) { ExecuteToolAddDebugItems(dataObject, update); } ExecuteRecordset(dataObject, update); } } catch (Exception e) { Dev2Logger.Error("AdvancedRecordset", e, GlobalConstants.WarewolfError); allErrors.AddError(e.Message); } finally { // Handle Errors var hasErrors = allErrors.HasErrors(); if (hasErrors) { DisplayAndWriteError("AdvancedRecordset", allErrors); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { _debugOutputs.Clear(); _debugInputs.Clear(); if (WebRequestInvoker == null) { return; } var allErrors = new ErrorResultTO(); InitializeDebug(dataObject); try { allErrors = TryExecute(dataObject, update, allErrors); } catch (Exception e) { Dev2Logger.Error("DSFWebGetRequest", e, GlobalConstants.WarewolfError); allErrors.AddError(e.Message); } finally { if (allErrors.HasErrors()) { DisplayAndWriteError("DsfWebGetRequestActivity", allErrors); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); var expression = GetExpression(1); PushResultsToDataList(expression, null, dataObject, update); } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
static string ExtractKeyValuePairs(NameValueCollection pairs, NameValueCollection boundVariables) { // Extract request keys ;) foreach (var key in pairs.AllKeys) { if (key == "wid") //Don't add the Workspace ID to DataList { continue; } if (key.IsXml() || key.IsJSON()) { return(key); //We have a workspace id and XML DataList } boundVariables.Add(key, pairs[key]); } ErrorResultTO errors = new ErrorResultTO(); Dev2Logger.Log.Error(errors.MakeDisplayReady()); return(string.Empty); }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { _debugInputs = new List <DebugItem>(); _debugOutputs = new List <DebugItem>(); _indexCounter = 1; var allErrors = new ErrorResultTO(); try { var sharepointReadListTos = SharepointUtils.GetValidReadListItems(ReadListItems).ToList(); if (sharepointReadListTos.Any()) { TryExecute(dataObject, update, sharepointReadListTos); } } catch (Exception e) { Dev2Logger.Error("SharepointCreateListItemActivity", e, GlobalConstants.WarewolfError); allErrors.AddError(e.Message); } finally { var hasErrors = allErrors.HasErrors(); if (hasErrors) { dataObject.Environment.Assign(Result, "Failed", update); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); DisplayAndWriteError(dataObject, DisplayName, allErrors); } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { IDev2IndexFinder indexFinder = new Dev2IndexFinder(); var allErrors = new ErrorResultTO(); var errors = new ErrorResultTO(); InitializeDebug(dataObject); try { TryExecute(dataObject, update, indexFinder, allErrors, errors); } catch (Exception e) { allErrors.AddError(e.Message); } finally { var hasErrors = allErrors.HasErrors(); if (hasErrors) { var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); DisplayAndWriteError(dataObject, DisplayName, allErrors); } if (dataObject.IsDebugMode()) { if (hasErrors) { AddDebugOutputItem(new DebugEvalResult(Result, "", dataObject.Environment, update)); } DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { AddScriptSourcePathsToList(); ErrorResultTO allErrors = new ErrorResultTO(); ErrorResultTO errors = new ErrorResultTO(); allErrors.MergeErrors(errors); var env = dataObject.Environment; InitializeDebug(dataObject); try { if (!errors.HasErrors()) { if (dataObject.IsDebugMode()) { var language = ScriptType.GetDescription(); AddDebugInputItem(new DebugItemStaticDataParams(language, "Language")); AddDebugInputItem(new DebugEvalResult(Script, "Script", env, update)); } allErrors.MergeErrors(errors); if (allErrors.HasErrors()) { return; } var scriptItr = new WarewolfIterator(dataObject.Environment.Eval(Script, update, false, EscapeScript)); while (scriptItr.HasMoreData()) { var engine = new ScriptingEngineRepo().CreateEngine(ScriptType, _sources); var value = engine.Execute(scriptItr.GetNextValue()); foreach (var region in DataListCleaningUtils.SplitIntoRegions(Result)) { env.Assign(region, value, update); if (dataObject.IsDebugMode() && !allErrors.HasErrors()) { if (!string.IsNullOrEmpty(region)) { AddDebugOutputItem(new DebugEvalResult(region, "", env, update)); } } } } } } catch (Exception e) when(e is NullReferenceException || e is RuntimeBinderException) { if (e.GetType() == typeof(NullReferenceException) || e.GetType() == typeof(RuntimeBinderException)) { allErrors.AddError(ErrorResource.ScriptingErrorReturningValue); } else { allErrors.AddError(e.Message.Replace(" for main:Object", string.Empty)); } } finally { // Handle Errors if (allErrors.HasErrors()) { DisplayAndWriteError("DsfScriptingJavaScriptActivity", allErrors); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); } if (dataObject.IsDebugMode()) { if (allErrors.HasErrors()) { AddDebugOutputItem(new DebugItemStaticDataParams("", Result, "")); } DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { _debugInputs = new List <DebugItem>(); _debugOutputs = new List <DebugItem>(); var allErrors = new ErrorResultTO(); try { var sharepointSource = ResourceCatalog.GetResource <SharepointSource>(dataObject.WorkspaceID, SharepointServerResourceId); if (sharepointSource == null) { var contents = ResourceCatalog.GetResourceContents(dataObject.WorkspaceID, SharepointServerResourceId); sharepointSource = new SharepointSource(contents.ToXElement()); } var env = dataObject.Environment; if (dataObject.IsDebugMode()) { AddInputDebug(env, update); } ListItemCollection listItems; var sharepointHelper = sharepointSource.CreateSharepointHelper(); var fields = sharepointHelper.LoadFieldsForList(SharepointList, true); using (var ctx = sharepointHelper.GetContext()) { var camlQuery = _sharepointUtils.BuildCamlQuery(env, FilterCriteria, fields, update, RequireAllCriteriaToMatch); var list = sharepointHelper.LoadFieldsForList(SharepointList, ctx, false); listItems = list.GetItems(camlQuery); ctx.Load(listItems); ctx.ExecuteQuery(); } using (var ctx = sharepointHelper.GetContext()) { var list = ctx.Web.Lists.GetByTitle(SharepointList); foreach (var item in listItems) { list.GetItemById(item.Id).DeleteObject(); } list.Update(); ctx.ExecuteQuery(); } var successfulDeleteCount = listItems.Count(); if (!string.IsNullOrWhiteSpace(DeleteCount)) { dataObject.Environment.Assign(DeleteCount, successfulDeleteCount.ToString(), update); env.CommitAssign(); AddOutputDebug(dataObject, update); } } catch (Exception e) { Dev2Logger.Error("SharepointDeleteListItemActivity", e); allErrors.AddError(e.Message); } finally { var hasErrors = allErrors.HasErrors(); if (hasErrors) { DisplayAndWriteError("SharepointDeleteListItemActivity", allErrors); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { var env = dataObject.Environment; InitializeDebug(dataObject); var allErrors = new ErrorResultTO(); try { IList <string> toSearch = FieldsToSearch.Split(',').Select(a => a.Trim()).ToList(); var scalarValues = toSearch.Where(DataListUtil.IsValueScalar).ToList(); if (scalarValues.Any()) { throw new Exception("Scalars are not allowed. Please check the following:" + Environment.NewLine + string.Join(Environment.NewLine, scalarValues)); } List <int> results = new List <int>(); if (dataObject.IsDebugMode()) { AddDebugInputValues(dataObject, toSearch, ref allErrors, update); } bool hasEvaled = false; foreach (var searchvar in toSearch) { Func <DataASTMutable.WarewolfAtom, bool> func = null; foreach (FindRecordsTO to in ResultsCollection.Where(a => !String.IsNullOrEmpty(a.SearchType))) { if (to.From.Length > 0 && String.IsNullOrEmpty(to.To) || to.To.Length > 0 && String.IsNullOrEmpty(to.From)) { throw new Exception("From and to Must be populated"); } ValidateRequiredFields(to, out errorsTo); var right = env.EvalAsList(to.SearchCriteria, update); IEnumerable <DataASTMutable.WarewolfAtom> from = new List <DataASTMutable.WarewolfAtom>(); IEnumerable <DataASTMutable.WarewolfAtom> tovalue = new List <DataASTMutable.WarewolfAtom>(); if (!String.IsNullOrEmpty(to.From)) { @from = env.EvalAsList(to.From, update); } if (!String.IsNullOrEmpty(to.To)) { tovalue = env.EvalAsList(to.To, update); } if (func == null) { func = CreateFuncFromOperator(to.SearchType, right, @from, tovalue); } else { func = RequireAllTrue ? CombineFuncAnd(func, to.SearchType, right, @from, tovalue) : CombineFuncOr(func, to.SearchType, right, @from, tovalue); } } var output = env.EnvalWhere(dataObject.Environment.ToStar(searchvar), func, update); if (RequireAllFieldsToMatch && hasEvaled) { results = results.Intersect(output).ToList(); } else { results = results.Union(output).ToList(); } hasEvaled = true; } if (!results.Any()) { results.Add(-1); } var res = String.Join(",", results.Distinct()); env.Assign(Result, res, update); if (dataObject.IsDebugMode()) { AddDebugOutputItem(new DebugEvalResult(Result, "", dataObject.Environment, update)); } } catch (Exception exception) { Dev2Logger.Log.Error("DSFRecordsMultipleCriteria", exception); allErrors.AddError(exception.Message); } finally { var hasErrors = allErrors.HasErrors(); if (hasErrors) { DisplayAndWriteError("DsfFindRecordsMultipleCriteriaActivity", allErrors); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); dataObject.Environment.Assign(Result, "-1", update); if (dataObject.IsDebugMode()) { AddDebugOutputItem(new DebugEvalResult(Result, "", dataObject.Environment, update)); } } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }