/// <summary> /// Search workflow types /// If none is specified, returns all the workflow types. /// </summary> /// <returns>Reply that contains the list of workflow types found.</returns> public static WorkflowTypeSearchReply SearchWorkflowTypes(WorkflowTypeSearchRequest request) { WorkflowTypeSearchReply reply = null; try { reply = WorkflowTypeRepositoryService.SearchWorkflowTypes(request); } catch (Exception e) { throw new BusinessException(-1, e.Message); } return reply; }
/// <summary> /// Gets workflowTypes from QueryService /// </summary> /// <param name="client"></param> private void GetWorkflowTypes(IWorkflowsQueryService client) { WorkflowTypeSearchReply replyDC = null; WorkflowTypeSearchRequest request = new WorkflowTypeSearchRequest(); request.SearchText = this.SearchText; request.PageSize = pageSize; request.PageNumber = this.DataPagingVM.ResetPageIndex ? 1 : this.DataPagingVM.PageIndex; request.SortColumn = DefaultSortColumn; request.SortAscending = this.SortByAsceinding; replyDC = client.SearchWorkflowTypes(request); if (null != replyDC && null != replyDC.StatusReply && 0 == replyDC.StatusReply.Errorcode) { this.WorkflowTypes = new ObservableCollection<WorkflowTypeSearchDC>(replyDC.SearchResults); DataPagingVM.ResultsLength = replyDC.ServerResultsLength; } else { this.WorkflowTypes = new ObservableCollection<WorkflowTypeSearchDC>(); DataPagingVM.ResultsLength = 0; } }
/// <summary> /// Search workflowtypes /// </summary> /// <returns></returns> public static WorkflowTypeSearchReply SearchWorkflowTypes(WorkflowTypeSearchRequest request) { WorkflowTypeSearchReply reply = new WorkflowTypeSearchReply(); IList<WorkflowTypeSearchDC> wftList = new List<WorkflowTypeSearchDC>(); try { WorkflowTypeSearchDC wfat = null; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetStoredProcCommand(StoredProcNames.WorkflowType_Search); db.AddParameter(cmd, "@SearchText", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.SearchText); db.AddParameter(cmd, "@SortColumn", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.SortColumn); db.AddParameter(cmd, "@SortAscending", DbType.Boolean, ParameterDirection.Input, null, DataRowVersion.Default, request.SortAscending); db.AddParameter(cmd, "@PageSize", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.PageSize); db.AddParameter(cmd, "@PageNumber", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.PageNumber); using (IDataReader reader = db.ExecuteReader(cmd)) { while (reader.Read()) { wfat =new WorkflowTypeSearchDC(); wfat.Guid = reader[DataColumnNames.Guid] != DBNull.Value ?(Guid)reader[DataColumnNames.Guid] : Guid.Empty; wfat.Id = Convert.ToInt32(reader[DataColumnNames.Id]); wfat.Name = Convert.ToString(reader[DataColumnNames.Name]); wfat.AuthGroupId = Convert.ToInt32(reader[DataColumnNames.AuthGroupId]); wfat.AuthGroupName = reader[DataColumnNames.AuthGroupName] != DBNull.Value ? Convert.ToString(reader[DataColumnNames.AuthGroupName]) : string.Empty; wfat.PublishingWorkflow = reader[DataColumnNames.PublishingWorkflowName] != DBNull.Value ? Convert.ToString(reader[DataColumnNames.PublishingWorkflowName]) : string.Empty; wfat.PublishingWorkflowVersion = reader[DataColumnNames.PublishingWorkflowVersion] != DBNull.Value ? Convert.ToString(reader[DataColumnNames.PublishingWorkflowVersion]) : string.Empty; wfat.PublishingWorkflowId = reader[DataColumnNames.PublishingWorkflowId] != DBNull.Value ? Convert.ToInt32(reader[DataColumnNames.PublishingWorkflowId]) : 0; wfat.WorkflowTemplate = reader[DataColumnNames.WorkflowTemplateName] != DBNull.Value ? Convert.ToString(reader[DataColumnNames.WorkflowTemplateName]) : string.Empty; wfat.WorkflowTemplateVersion = reader[DataColumnNames.WorkflowTemplateVersion] != DBNull.Value ? Convert.ToString(reader[DataColumnNames.WorkflowTemplateVersion]) : string.Empty; wfat.WorkflowTemplateId = reader[DataColumnNames.WorkflowTemplateId] != DBNull.Value ? Convert.ToInt32(reader[DataColumnNames.WorkflowTemplateId]) : 0; wfat.WorkflowsCount = reader[DataColumnNames.WorkflowsCount] != DBNull.Value ? Convert.ToInt32(reader[DataColumnNames.WorkflowsCount]) : 0; wftList.Add(wfat); } reply.SearchResults = wftList; reader.NextResult(); if (reader.Read()) { reply.ServerResultsLength = Convert.ToInt32(reader["Total"]); } } } catch (SqlException e) { e.HandleException(); } return reply; }
public void WorkflowTypeSearch() { //Test create a new workflow type WorkFlowTypeCreateOrUpdateRequestDC request = new WorkFlowTypeCreateOrUpdateRequestDC(); WorkFlowTypeCreateOrUpdateReplyDC reply = null; request.Incaller = INCALLER; request.IncallerVersion = INCALLERVERSION; request.InGuid = Guid.NewGuid(); request.InName = "TestType_" + request.InGuid.ToString(); request.InInsertedByUserAlias = INSERTEDBYUSERALIAS; request.InAuthGroupId = 2; try { reply = WorkflowTypeBusinessService.WorkflowTypeCreateOrUpdate(request); Assert.IsNotNull(reply); Assert.AreEqual(reply.StatusReply.Errorcode, 0); WorkflowTypeSearchRequest searchRequest = new WorkflowTypeSearchRequest(); searchRequest.Incaller = INCALLER; searchRequest.IncallerVersion = INCALLERVERSION; searchRequest.SearchText = "TestType"; searchRequest.PageSize = 10; searchRequest.PageNumber = 1; WorkflowTypeSearchReply searchReply = WorkflowTypeBusinessService.SearchWorkflowTypes(searchRequest); Assert.IsNotNull(searchReply); Assert.AreEqual(searchReply.StatusReply.Errorcode, 0); Assert.IsTrue(searchReply.ServerResultsLength >= 1); } catch (Exception ex) { string faultMessage = ex.Message; Assert.Fail(faultMessage + "-catch (Exception ex) in reply = CWF.BAL.WorkflowTypeBusinessService.WorkflowTypeCreateOrUpdate();"); } }