/// <summary> /// This method get the work type for a specified department /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="collectionRequest">Collection request</param> /// <param name="criteria">Search criteria for WorkType</param> /// <returns></returns> public WorkTypeSearchReturnValue GetWorkTypesForDepartment(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, WorkTypeSearchCriteria criteria) { WorkTypeSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oMatterService = new MatterService(); returnValue = oMatterService.GetWorkTypesForDepartment(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria); } else { returnValue = new WorkTypeSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return(returnValue); }
private void BindWorkTypeDropDownList() { MatterServiceClient matterService = null; try { WorkTypeSearchCriteria workTypeCriteria = new WorkTypeSearchCriteria(); //Set this flag to true to get all the worktype records workTypeCriteria.AllWorkTypes = true; CollectionRequest collectionRequest = new CollectionRequest(); collectionRequest.ForceRefresh = true; matterService = new MatterServiceClient(); WorkTypeSearchReturnValue returnValue = matterService.WorkTypeSearch(_logonSettings.LogonId, collectionRequest, workTypeCriteria); if (returnValue.Success) { _ddlWorkType.DataSource = returnValue.WorkTypes.Rows; _ddlWorkType.DataTextField = "Description"; _ddlWorkType.DataValueField = "Code"; _ddlWorkType.DataBind(); AddDefaultToDropDownList(_ddlWorkType, "All WorkType"); } else { throw new Exception(returnValue.Message); } } catch (Exception ex) { throw ex; } finally { if (matterService != null) { if (matterService.State != System.ServiceModel.CommunicationState.Faulted) { matterService.Close(); } } } }
/// <summary> /// Gets the work types based on the selected branch and department. /// </summary> private void GetWorkTypes() { //Check if a department is selected if (_ddlDepartment.SelectedValue != string.Empty) { MatterServiceClient matterService = null; try { CollectionRequest collectionRequest = new CollectionRequest(); WorkTypeSearchCriteria searchCriteria = new WorkTypeSearchCriteria(); if (_ddlDepartment.SelectedValue != String.Empty) { searchCriteria.DepartmentNo = GetDepartmentValueOnIndex(_ddlDepartment.SelectedValue, 1); } searchCriteria.IsPrivateClient = true; searchCriteria.MatterTypeId = 0; matterService = new MatterServiceClient(); WorkTypeSearchReturnValue returnValue = matterService.GetWorkTypesForDepartment(_logonSettings.LogonId, collectionRequest, searchCriteria); //Store the previous selected value. This will prevent the worktype from being reset //if its valid string prevValue = _ddlWorkType.SelectedValue; if (returnValue.Success) { _ddlWorkType.DataSource = returnValue.WorkTypes.Rows; _ddlWorkType.DataTextField = "Description"; _ddlWorkType.DataValueField = "Code"; _ddlWorkType.DataBind(); AddDefaultToDropDownList(_ddlWorkType, "All WorkType"); if (_ddlWorkType.Items.FindByValue(prevValue) != null) { _ddlWorkType.SelectedValue = prevValue; } } else { throw new Exception(returnValue.Message); } } catch (Exception ex) { throw ex; } finally { if (matterService != null) { if (matterService.State != System.ServiceModel.CommunicationState.Faulted) { matterService.Close(); } } } } else { //No dept selected. Reset Worktypes _ddlWorkType.Items.Clear(); BindWorkTypeDropDownList(); } }