public void DataObject_IsDebugMode_RemoteInvokeIsTrueAndRunWorkflowAsyncIsFalse_IsDebugModeIsTrue() { //------------Setup for test-------------------------- IDSFDataObject dataObject = new DsfDataObject(string.Empty, Guid.NewGuid(), "<x>1</x>"); dataObject.RunWorkflowAsync = false; dataObject.RemoteInvoke = true; //------------Execute Test--------------------------- var isDebug = dataObject.IsDebugMode(); //------------Assert Results------------------------- Assert.IsTrue(isDebug); }
public StringBuilder ProcessRequest(EsbExecuteRequest request, Guid workspaceID, Guid dataListID, string connectionId) { var channel = new EsbServicesEndpoint(); var xmlData = string.Empty; if (request.Args != null && request.Args.ContainsKey("DebugPayload")) { xmlData = request.Args["DebugPayload"].ToString(); xmlData = xmlData.Replace("<DataList>", "<XmlData>").Replace("</DataList>", "</XmlData>"); } // we need to adjust for the silly xml structure this system was init built on ;( if (string.IsNullOrEmpty(xmlData)) { xmlData = "<DataList></DataList>"; } IDSFDataObject dataObject = new DsfDataObject(xmlData, dataListID); dataObject.EsbChannel = channel; dataObject.ServiceName = request.ServiceName; var resource = ResourceCatalog.Instance.GetResource(workspaceID, request.ServiceName); if (resource != null) { dataObject.ResourceID = resource.ResourceID; } dataObject.ClientID = Guid.Parse(connectionId); dataObject.ExecutingUser = ExecutingUser; // we need to assign new ThreadID to request coming from here, because it is a fixed connection and will not change ID on its own ;) if (!dataObject.Errors.HasErrors()) { var dlID = Guid.Empty; ErrorResultTO errors; if (ExecutingUser == null) { throw new Exception("Null Executing User"); } try { // Execute in its own thread to give proper context ;) var t = new Thread(() => { Thread.CurrentPrincipal = ExecutingUser; dlID = channel.ExecuteRequest(dataObject, request, workspaceID, out errors); }); t.Start(); t.Join(); } catch (Exception e) { Dev2Logger.Log.Error(e.Message, e); } var compiler = DataListFactory.CreateDataListCompiler(); if (request.ExecuteResult.Length > 0) { return(request.ExecuteResult); } // return the datalist ;) if (dataObject.IsDebugMode()) { compiler.ForceDeleteDataListByID(dlID); return(new StringBuilder("Completed Debug")); } var result = compiler.ConvertFrom(dlID, DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), enTranslationDepth.Data, out errors); compiler.ForceDeleteDataListByID(dlID); return(result); } ExecuteMessage msg = new ExecuteMessage { HasError = true }; msg.SetMessage(dataObject.Errors.MakeDisplayReady()); Dev2JsonSerializer serializer = new Dev2JsonSerializer(); return(serializer.SerializeToBuilder(msg)); }