/// <summary> /// Gets a list of Events for an activity /// </summary> /// <param name="activityid"></param> /// <returns></returns> public List <Events> GetEvents(string activityid) { List <Events> list = new List <Events>(); SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder hostServerConnectionString = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder(); hostServerConnectionString.Host = servername; hostServerConnectionString.Port = 5555; hostServerConnectionString.IsPrimaryLogin = true; hostServerConnectionString.Integrated = true; SourceCode.SmartObjects.Client.SmartObjectClientServer serverName = new SourceCode.SmartObjects.Client.SmartObjectClientServer(); serverName.CreateConnection(); serverName.Connection.Open(hostServerConnectionString.ToString()); try { SourceCode.SmartObjects.Client.SmartObject smartObject = serverName.GetSmartObject("Event_Instance"); smartObject.MethodToExecute = "List"; smartObject.Properties["ActivityInstanceID"].Value = activityid; SourceCode.SmartObjects.Client.SmartObjectList smoList = serverName.ExecuteList(smartObject); foreach (SourceCode.SmartObjects.Client.SmartObject item in smoList.SmartObjectsList) { int ProcInstId = 0; int ActInstId = 0; int.TryParse(item.Properties["ProcessInstanceID"].Value, out ProcInstId); int.TryParse(item.Properties["ActivityInstanceID"].Value, out ActInstId); DateTime startDate = DateTime.Today; DateTime finishDate = DateTime.Today; DateTime.TryParse(item.Properties["StartDate"].Value, out startDate); DateTime.TryParse(item.Properties["FinishDate"].Value, out finishDate); list.Add(new Events { ProcessInstanceId = ProcInstId, ActivityInstanceId = ActInstId, EventName = item.Properties["EventName"].Value, Status = item.Properties["Status"].Value, StartDate = startDate, FinishDate = finishDate, Destination = item.Properties["Destination"].Value }); } } catch (Exception ex) { list.Add(new Events { ProcessInstanceId = 0, ActivityInstanceId = 0, EventName = ex.Message, Status = "Error", StartDate = DateTime.Today, FinishDate = DateTime.Today }); } finally { serverName.Connection.Close(); } return(list); }
/// <summary> /// SmartObject call to get a certain test plan /// </summary> /// <param name="TestId"></param> /// <returns></returns> public static List <TestPlanTest> BuildTestPlan(int TestId) { List <TestPlanTest> list = new List <TestPlanTest>(); SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder hostServerConnectionString = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder(); hostServerConnectionString.Host = "localhost"; hostServerConnectionString.Port = 5555; hostServerConnectionString.IsPrimaryLogin = true; hostServerConnectionString.Integrated = true; SourceCode.SmartObjects.Client.SmartObjectClientServer serverName = new SourceCode.SmartObjects.Client.SmartObjectClientServer(); serverName.CreateConnection(); serverName.Connection.Open(hostServerConnectionString.ToString()); try { SourceCode.SmartObjects.Client.SmartObject smartObject = serverName.GetSmartObject("K2C_TST_SMO_TestRun"); smartObject.MethodToExecute = "List_1"; smartObject.GetMethod("List_1").Parameters["pTestId"].Value = TestId.ToString(); SourceCode.SmartObjects.Client.SmartObjectList smoList = serverName.ExecuteList(smartObject); foreach (SourceCode.SmartObjects.Client.SmartObject item in smoList.SmartObjectsList) { var z = item.Properties["Sign"].Value; int testrunid = 0; int parameters = 0; int Milliseconds = 0; int.TryParse(item.Properties["NumberOfParameters"].Value, out parameters); int.TryParse(item.Properties["TestRunId"].Value, out testrunid); int.TryParse(item.Properties["Milliseconds"].Value, out Milliseconds); list.Add(new TestPlanTest { TestRunId = testrunid, TestType = item.Properties["TestType"].Value, ExpectedResult = item.Properties["ExpectedResult"].Value, LeftParameter = item.Properties["LeftParameter"].Value, MiddleParameter = item.Properties["MiddleParameter"].Value, RightParameter = item.Properties["RightParameter"].Value, Milliseconds = Milliseconds, NumberOfParameters = parameters, Sign = item.Properties["Sign"].Value }); } } catch (Exception ex) { list.Add(new TestPlanTest { }); } finally { serverName.Connection.Close(); } return(list); }