public void LoadLiveData(IWorkflowsQueryService client) { ActivitySearchRequestDC request = new ActivitySearchRequestDC(); request.SearchText = SearchFilter; request.PageNumber = resetPageIndex ? 1 : this.DataPagingVM.PageIndex; request.PageSize = pageSize; request.FilterByCreator = FilterByCreatedBy; request.FilterByDescription = FilterByDescription; request.FilterByName = filterByName; request.FilterByVersion = FilterByVersion; request.FilterByTags = FilterByTags; request.FilterByType = FilterByType; request.FilterOlder = FilterOldVersions; if (!string.IsNullOrEmpty(sortColumn)) { request.SortColumn = sortColumn.ToLower().Trim(); request.SortAscending = sortDirection == ListSortDirection.Ascending; } try { ActivitySearchReplyDC searchResults = null; Utility.DoTaskWithBusyCaption("Loading...", () => { searchResults = client.SearchActivities(request); this.DataPagingVM.ResultsLength = searchResults.ServerResultsLength; ExistingWorkflows = new ObservableCollection<StoreActivitiesDC>(searchResults.SearchResults); }); WorkflowsView = new CollectionViewSource(); WorkflowsView.Source = existingWorkflows; } catch (FaultException<ServiceFault> ex) { throw new CommunicationException(ex.Detail.ErrorMessage); } catch (FaultException<ValidationFault> ex) { throw new BusinessValidationException(ex.Detail.ErrorMessage); } catch (Exception ex) { throw new CommunicationException(ex.Message); } finally { IsBusy = false; } }
/// <summary> /// Performs input validation and gets activities by searching with some params /// </summary> /// <param name="request">Request that specifies the search parameters</param> /// <returns>Response that contains a list of activities.</returns> public static ActivitySearchReplyDC SearchActivities(ActivitySearchRequestDC request) { var reply = new ActivitySearchReplyDC(); try { // Validates the input and throws ValidationException for any issues found. request.ValidateRequest(); reply = ActivityRepositoryService.SearchActivities(request); } catch (ValidationException e) { e.HandleException(); } catch (DataAccessException e) { e.HandleException(); } return reply; }
private void GetActivities(IWorkflowsQueryService client) { ActivitySearchRequestDC request = new ActivitySearchRequestDC(); request.SearchText = this.SearchFilter; request.PageNumber = this.DataPagingVM.ResetPageIndex ? 1 : this.DataPagingVM.PageIndex; request.PageSize = pageSize; request.FilterByCreator = false; request.FilterByDescription = false; request.FilterByName = true; request.FilterByVersion = false; request.FilterByTags = false; request.FilterByType = false; request.FilterOlder = this.FilterOldVersions; try { ActivitySearchReplyDC searchResults = null; searchResults = client.SearchActivities(request); this.DataPagingVM.ResultsLength = searchResults.ServerResultsLength; this.Activities = new ObservableCollection<StoreActivitiesDC>(searchResults.SearchResults); } catch (FaultException<ServiceFault> ex) { IsBusy = false; throw new CommunicationException(ex.Detail.ErrorMessage); } catch (FaultException<ValidationFault> ex) { IsBusy = false; throw new BusinessValidationException(ex.Detail.ErrorMessage); } catch (Exception ex) { IsBusy = false; throw new CommunicationException(ex.Message); } }
public void ActivityBusinessServiceSearchActivitiesWhichReturnEmptyReply() { using (ImplementationOfType impl = new ImplementationOfType(typeof(ActivityRepositoryService))) { impl.Register(() => ActivityRepositoryService.SearchActivities(Argument<ActivitySearchRequestDC>.Any)) .Execute(delegate { return null; }); CWF.DataContracts.ActivitySearchRequestDC request = new ActivitySearchRequestDC(); var reply = ActivityBusinessService.SearchActivities(request); } }
public void ActivityBusinessServiceSearchActivitiesThrowDataAccessException() { int eventCode = EventCode.DatabaseEvent.Validation.ActivityLibraryNotFound; DataAccessException exception = new DataAccessException(eventCode); try { using (ImplementationOfType impl = new ImplementationOfType(typeof(ActivityRepositoryService))) { impl.Register(() => ActivityRepositoryService.SearchActivities(Argument<ActivitySearchRequestDC>.Any)) .Execute(delegate { throw exception; return null; }); CWF.DataContracts.ActivitySearchRequestDC request = new ActivitySearchRequestDC(); var reply = ActivityBusinessService.SearchActivities(request); } } catch (BusinessException e) { Assert.AreEqual(eventCode, e.ErrorCode); } }
public void SearchActivities() { ActivitySearchRequestDC request = new ActivitySearchRequestDC(); request.Incaller = INCALLER; request.IncallerVersion = INCALLERVERSION; ActivitySearchReplyDC reply = null; try { reply = ActivityRepositoryService.SearchActivities(request); } catch (Exception ex) { string faultMessage = ex.Message; Assert.Fail(faultMessage + "-catch (Exception ex) on reply = ActivityRepositoryService.SearchActivities(request);"); } }
/// <summary> /// Search the activities for a criteria and do paging to return only a certain amount of /// results. /// </summary> /// <param name="request">ActivitySearchRequestDC</param> /// <returns>List of activities.</returns> public static ActivitySearchReplyDC SearchActivities(ActivitySearchRequestDC request) { ActivitySearchReplyDC result = new ActivitySearchReplyDC(); var resultCollection = new List<StoreActivitiesDC>(); Database database = null; DbCommand command = null; StoreActivitiesDC sab = null; try { database = DatabaseFactory.CreateDatabase(); command = database.GetStoredProcCommand(StoredProcNames.ActivitySearch); database.AddParameter(command, "@SearchText", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.SearchText); database.AddParameter(command, "@SortColumn", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.SortColumn); database.AddParameter(command, "@SortAscending", DbType.Boolean, ParameterDirection.Input, null, DataRowVersion.Default, request.SortAscending); database.AddParameter(command, "@PageSize", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.PageSize); database.AddParameter(command, "@PageNumber", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.PageNumber); database.AddParameter(command, "@FilterOlder", DbType.Boolean, ParameterDirection.Input, null, DataRowVersion.Default, request.FilterOlder); database.AddParameter(command, "@FilterByName", DbType.Boolean, ParameterDirection.Input, null, DataRowVersion.Default, request.FilterByName); database.AddParameter(command, "@FilterByDescription", DbType.Boolean, ParameterDirection.Input, null, DataRowVersion.Default, request.FilterByDescription); database.AddParameter(command, "@FilterByTags", DbType.Boolean, ParameterDirection.Input, null, DataRowVersion.Default, request.FilterByTags); database.AddParameter(command, "@FilterByType", DbType.Boolean, ParameterDirection.Input, null, DataRowVersion.Default, request.FilterByType); database.AddParameter(command, "@FilterByVersion", DbType.Boolean, ParameterDirection.Input, null, DataRowVersion.Default, request.FilterByVersion); database.AddParameter(command, "@FilterByCreator", DbType.Boolean, ParameterDirection.Input, null, DataRowVersion.Default, request.FilterByCreator); using (IDataReader reader = database.ExecuteReader(command)) { while (reader.Read()) { sab = new StoreActivitiesDC(); sab.Name = Convert.ToString(reader["Name"]); sab.Description = Convert.ToString(reader["Description"]); sab.Id = Convert.ToInt32(reader["Id"]); sab.InsertedByUserAlias = Convert.ToString(reader["InsertedByUserAlias"]); sab.MetaTags = Convert.ToString(reader["MetaTags"]); sab.Guid = new Guid(Convert.ToString(reader["Guid"])); sab.Version = Convert.ToString(reader["Version"]); sab.WorkflowTypeName = Convert.ToString(reader["WorkFlowTypeName"]); if (reader["InsertedDateTime"] != DBNull.Value) { sab.InsertedDateTime = Convert.ToDateTime(reader["InsertedDateTime"]); } resultCollection.Add(sab); } result.SearchResults = resultCollection; reader.NextResult(); if (reader.Read()) { result.ServerResultsLength = Convert.ToInt32(reader["Total"]); } } } catch (SqlException ex) { ex.HandleException(); } return result; }