/// <summary> /// /// </summary> /// <param name="logonId"></param> /// <param name="criteria"></param> /// <returns></returns> public WorkTypeSearchReturnValue GetValuesOnWorkTypeSelected(Guid logonId, WorkTypeSearchCriteria criteria) { WorkTypeSearchReturnValue returnValue = new WorkTypeSearchReturnValue(); string errorMessage = string.Empty; string warningMessage = string.Empty; bool isValid = false; try { Host.LoadLoggedOnUser(logonId); try { Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid); switch (UserInformation.Instance.UserType) { case DataConstants.UserType.Staff: case DataConstants.UserType.Client: case DataConstants.UserType.ThirdParty: // Can do everything break; default: throw new Exception("Access denied"); } // Create the dataset SrvMatter serviceMatter = new SrvMatter(); //Set the client id and call the client validation method which will set the client ref //Cli ref is required to get the ucn and houcn values which are set in SetDefaultsOnWorkType serviceMatter.ClientId = criteria.ClientId; serviceMatter.ValidateClientId(out errorMessage, out warningMessage); serviceMatter.CurrentWorkTypeId = criteria.Id; isValid = serviceMatter.ValidateCurrentWorkTypeId(out errorMessage, out warningMessage); // TODO: Does not use the criteria: FilterString, OrganisationID, DepartmentId, DepartmentNo, IsPrivateClient, MatterTypeId if (isValid) { serviceMatter.SetDefaultsOnWorkType(); returnValue.IsPublicFunded = serviceMatter.IsPublicFunding; returnValue.DisbLimit = serviceMatter.WorkTypeDisbLimit; returnValue.OverallLimit = serviceMatter.WorkTypeOverallLimit; returnValue.Quote = serviceMatter.WorkTypeQuote; returnValue.TimeLimit = serviceMatter.WorkTypeTimeLimit; returnValue.WipLimit = serviceMatter.WorkTypeWipLimit; returnValue.ChargeRateDescriptionId = serviceMatter.ChargeDescriptionId; returnValue.Franchised = serviceMatter.WorkCategoryFranchised; returnValue.WorkCategoryUFN = serviceMatter.WorkCategoryUFN; returnValue.ClientHOUCN = serviceMatter.ClientHOUCN; returnValue.ClientUCN = serviceMatter.ClientUCN; } else { returnValue.Success = false; returnValue.Message = errorMessage; } } finally { Host.UnloadLoggedOnUser(); } } catch (System.Data.SqlClient.SqlException) { returnValue.Success = false; returnValue.Message = Functions.SQLErrorMessage; } catch (Exception ex) { returnValue.Success = false; returnValue.Message = ex.Message; } return returnValue; }
/// <summary> /// This method get the work type for a specified department /// </summary> /// <param name="logonId">Login id</param> /// <param name="collectionRequest">Collection request</param> /// <param name="criteria">Search criteria for WorkType</param> /// <returns></returns> public WorkTypeSearchReturnValue GetWorkTypesForDepartment(Guid logonId, CollectionRequest collectionRequest, WorkTypeSearchCriteria criteria) { WorkTypeSearchReturnValue returnValue = new WorkTypeSearchReturnValue(); try { Host.LoadLoggedOnUser(logonId); try { Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid); switch (UserInformation.Instance.UserType) { case DataConstants.UserType.Staff: case DataConstants.UserType.Client: case DataConstants.UserType.ThirdParty: // Can do everything break; default: throw new Exception("Access denied"); } // Create a data list creator for a list of matters DataListCreator<WorkTypeSearchItem> dataListCreator = new DataListCreator<WorkTypeSearchItem>(); // Declare an inline event (annonymous delegate) to read the // dataset if it is required dataListCreator.ReadDataSet += delegate(object sender, ReadDataSetEventArgs e) { // Create the dataset // TODO: Does not use the criteria: Id, FilterString, OrganisationID, DepartmentId, IsPrivateClient, MatterTypeId, ClientId e.DataSet = SrvWorkTypeLookup.GetWorkTypesByDepartment(criteria.DepartmentNo); DataTable dt = Functions.SortDataTable(e.DataSet.Tables[0], "WorkTypeDescription"); e.DataSet.Tables.Remove(e.DataSet.Tables[0]); e.DataSet.Tables.Add(dt); }; // Create the data list returnValue.WorkTypes = dataListCreator.Create(logonId, // Give the query a name so it can be cached "WorkTypeSearchForDepartment", // Tell it the query criteria used so if the cache is accessed // again it knows if it is the same query criteria.ToString(), collectionRequest, // Import mappings to map the dataset row fields to the data // list entity properties new ImportMapping[] { new ImportMapping("Id", "WorkTypeID"), new ImportMapping("Description", "WorkTypeDescription"), new ImportMapping("IsArchived", "WorkTypeArchived"), new ImportMapping("Code","WorkTypeCode") } ); } finally { Host.UnloadLoggedOnUser(); } } catch (System.Data.SqlClient.SqlException) { returnValue.Success = false; returnValue.Message = Functions.SQLErrorMessage; } catch (Exception ex) { returnValue.Success = false; returnValue.Message = ex.Message; } return returnValue; }
/// <summary> /// Worktype search /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="collectionRequest"></param> /// <param name="criteria"></param> /// <returns></returns> public WorkTypeSearchReturnValue WorkTypeSearch(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, WorkTypeSearchCriteria criteria) { WorkTypeSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oMatterService = new MatterService(); returnValue = oMatterService.WorkTypeSearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria); } else { returnValue = new WorkTypeSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }