public string GetProvisionedSubIdByBillingSubId(string usi, UserDto userDto) { var user = TypeAdapter.Adapt<UserDto, User>(userDto); try { var provisionedUsi = base.GetProvisionedSubIdByBillingSubId(usi, user); return provisionedUsi; } catch (FaultException<ValidationFault> fault) { throw new FaultException<ValidationFaultDto>(TypeAdapter.Adapt<ValidationFault, ValidationFaultDto>(fault.Detail)); } }
public List<AccountNotesDto> GetNotes(string tn, string environment, string sequence, UserDto userDto) { var user = TypeAdapter.Adapt<UserDto, User>(userDto); List<AccountNotes> accountNotes; try { accountNotes = base.GetNotes(tn, environment, sequence, user); } catch (FaultException<ValidationFault> fault) { throw new FaultException<ValidationFaultDto>(TypeAdapter.Adapt<ValidationFault, ValidationFaultDto>(fault.Detail)); } return TypeAdapter.Adapt<List<AccountNotes>, List<AccountNotesDto>>(accountNotes); }
public string PingIPAddress(string dataPortSerial, UserDto userDto) { var user = TypeAdapter.Adapt<UserDto, User>(userDto); string result = null; try { result = base.PingIPAddress(dataPortSerial, user); } catch (FaultException<ValidationFault> fault) { throw new FaultException<ValidationFaultDto>(TypeAdapter.Adapt<ValidationFault, ValidationFaultDto>(fault.Detail)); } return result; }
public FacilityDataDto GetFacilityData(string loadedSubId, UserDto userDto) { var user = TypeAdapter.Adapt<UserDto, User>(userDto); FacilityData facilityData = null; try { facilityData = _facilityService.GetFacilityData(loadedSubId, user); }catch(FaultException<ValidationFault> fault) { throw new FaultException<ValidationFaultDto>(TypeAdapter.Adapt<ValidationFault, ValidationFaultDto>(fault.Detail)); } return TypeAdapter.Adapt<FacilityData, FacilityDataDto>(facilityData); }
public List<BillingSearchSubscriberDto> SearchSubscriber(BillingSearchFieldsDto criteriaDto, UserDto userDto) { var user = TypeAdapter.Adapt<UserDto, User>(userDto); var criteria = TypeAdapter.Adapt<BillingSearchFieldsDto, BillingSearchFields>(criteriaDto); List<BillingSearchSubscriber> billingSearchResults = null; try { billingSearchResults = base.SearchSubscriber(criteria, user) as List<BillingSearchSubscriber>; } catch (FaultException<ValidationFault> fault) { throw new FaultException<ValidationFaultDto>(TypeAdapter.Adapt<ValidationFault, ValidationFaultDto>(fault.Detail)); } return TypeAdapter.Adapt<List<BillingSearchSubscriber>, List<BillingSearchSubscriberDto>>(billingSearchResults); }
public string GetCustomerNetworkProfile(string dataPortSerial, UserDto userDto) { var user = TypeAdapter.Adapt<UserDto, User>(userDto); string result = null; try { result = base.GetCustomerNetworkProfile(dataPortSerial, user); } catch (FaultException<ValidationFault> fault) { throw new FaultException<ValidationFaultDto>(TypeAdapter.Adapt<ValidationFault, ValidationFaultDto>(fault.Detail)); } return result; }
public List<FiberJumperDto> GetHubDetails(string region, string coCode, string hubNumber, UserDto userDto) { var user = TypeAdapter.Adapt<UserDto, User>(userDto); List<FiberJumper> jumperList = null; try { jumperList = _facilityService.GetHubDetails(region, coCode, hubNumber, user); } catch (FaultException<ValidationFault> fault) { throw new FaultException<ValidationFaultDto>(TypeAdapter.Adapt<ValidationFault, ValidationFaultDto>(fault.Detail)); } return TypeAdapter.Adapt<List<FiberJumper>, List<FiberJumperDto>>(jumperList); }
public List<TroubleTicketSearchDto> GetTroubleTickets(BillingSearchFieldsDto bsfDto, UserDto userDto) { var user = TypeAdapter.Adapt<UserDto, User>(userDto); var bsf = TypeAdapter.Adapt<BillingSearchFieldsDto, BillingSearchFields>(bsfDto); List<TroubleTicketSearch> troubleTickets = null; try { troubleTickets = base.GetTroubleTickets(bsf, user); } catch (FaultException<ValidationFault> fault) { throw new FaultException<ValidationFaultDto>(TypeAdapter.Adapt<ValidationFault, ValidationFaultDto>(fault.Detail)); } return TypeAdapter.Adapt<List<TroubleTicketSearch>, List<TroubleTicketSearchDto>>(troubleTickets); }
public TroubleTicketDto LoadTroubleTicket(BillingSearchFieldsDto criteriaDto, UserDto userDto) { var user = TypeAdapter.Adapt<UserDto, User>(userDto); var criteria = TypeAdapter.Adapt<BillingSearchFieldsDto, BillingSearchFields>(criteriaDto); TroubleTicket troubleTicket = null; try { troubleTicket = base.LoadTroubleTicket(criteria, user); } catch (FaultException<ValidationFault> fault) { throw new FaultException<ValidationFaultDto>(TypeAdapter.Adapt<ValidationFault, ValidationFaultDto>(fault.Detail)); } return TypeAdapter.Adapt<TroubleTicket, TroubleTicketDto>(troubleTicket); }
/// <summary> /// Remove the Residential Gateway (RG) /// </summary> /// <param name="deviceID"></param> /// <param name="currentUserAsDto"></param> /// <returns></returns> public bool RemoveResidentialGateway(string deviceID, UserDto currentUserAsDto) { if (String.IsNullOrWhiteSpace(deviceID)) { throw new Exception("Invalid DeviceID provided"); } List<EquipmentDto> equipmentDtoItems = null; var serialNumbers = new List<string>(); var resultForReturnToHeadend = false; equipmentDtoItems = this._rosettianService.SearchEquipment( new SearchFieldsDto { EquipmentId = deviceID }, currentUserAsDto); if ((equipmentDtoItems == null) || (!equipmentDtoItems.Any())) { throw new Exception(String.Format("Residential Gateway {0} not Found on Account.", deviceID)); } foreach (EquipmentDto item in equipmentDtoItems) { if ((item != null) && (!String.IsNullOrWhiteSpace(item.SerialNumber))) { serialNumbers.Add(item.SerialNumber); } } if (!serialNumbers.Any()) { throw new Exception(String.Format("Residential Gateway {0} did not have any serial numbers.", deviceID)); } resultForReturnToHeadend = this._rosettianService.ReturnToHeadend(serialNumbers, currentUserAsDto); return resultForReturnToHeadend; }
/// <summary> /// Loads the video devices. /// </summary> /// <param name="criteriaDto">The criteria dto.</param> /// <param name="userDto">The user dto.</param> /// <returns></returns> public IEnumerable<EquipmentDto> LoadVideoDevices(SearchFieldsDto criteriaDto, UserDto userDto) { var videoDevices = new List<EquipmentDto>(); var devices = _rosettianService.SearchEquipment(criteriaDto, userDto); if (devices == null || devices.Count() == 0) { return videoDevices; } if (!devices.FindAll(d => d.Type.IptvCapable).Any()) { return videoDevices; } videoDevices = devices.FindAll(d => d.Type.IptvCapable).ConvertAll<EquipmentDto>(a => { var loadedEquipment = _rosettianService.LoadEquipment(a.SerialNumber, true, userDto); if (loadedEquipment != null && loadedEquipment.CustomFields != null && loadedEquipment.CustomFields.Any()) { var selectedRoom = loadedEquipment.CustomFields.ToList().Find(cf => cf.Label == "ROOM_LOCATION"); if (selectedRoom != null) { a.CustomFields.Add(new CustomFieldDto { Category = selectedRoom.Category, Label = "SELECTED_ROOM", Value = selectedRoom.Value, ValueType = selectedRoom.ValueType, MaxLength = selectedRoom.MaxLength, MinLength = selectedRoom.MinLength }); } a.CustomFields.AddRange( _rosettianService.GetCustomFields(userDto).ToList().FindAll(cf => cf.Label == "ROOM_LOCATION")); } return a; }); return videoDevices; }
/// <summary> /// Loads the composite subscriber. /// </summary> /// <param name="usi">The usi.</param> /// <param name="dpiRegion"></param> /// <param name="userDto">The user dto.</param> /// <returns></returns> public CompositeSubscriber LoadCompositeSubscriber(string usi, string dpiRegion, UserDto userDto) { var compositeSubscriber = new CompositeSubscriber(); var rosettianResults = new SubscriberDto(); var provisionedPhonesResults = new List<PhoneDto>(); BillingandServiceAccountDto esbResults; var esbResultsEnterpriseServiceExceptionFound = false; var headerArgs = new HeaderArgs(dpiRegion, userDto.Name, String.Empty, userDto.Name, userDto.Email, userDto.Role); Task<SubscriberDto> rosettianResponse = null; Task<BillingandServiceAccountDto> esbGetAccountResponse = null; Task<List<PhoneDto>> provisioningSubPhonesReponse = null; try { rosettianResponse = Task.Factory.StartNew(() => _rosettianService.LoadSubscriber(usi, userDto)); esbGetAccountResponse = Task.Factory.StartNew(() => _enterpriseService.GetBillingServiceAccounts(usi, headerArgs)); provisioningSubPhonesReponse = Task.Factory.StartNew(() => _rosettianService.LoadSubscriberPhones(usi, userDto)); Task.WaitAll(rosettianResponse, esbGetAccountResponse, provisioningSubPhonesReponse); } catch (AggregateException ae) { foreach (var e in ae.InnerExceptions) { var handled = false; var isFaultException = (e is FaultException<ValidationFaultDto>); var isServiceError = (e is MessageSecurityException || e is ServerTooBusyException || e is CommunicationException || e is TimeoutException); // Note: if you reverse the order below, VS2013 warns you that isFaultException is always false. if ((isFaultException) || (isServiceError)) { // Throw exception if LoadSubscriber and not LoadSubscriberPhones if ((e.StackTrace.Contains("LoadSubscriber")) && (!(e.StackTrace.Contains("LoadSubscriberPhones")))) { var myException = new Exception("Error retrieving Provisioning information for subscriber from Triad, unable to proceed.", e); _errorLoggingService.LogErrorNoContext(myException); throw myException; } // Do not throw exception if LoadSubscriberPhones if (e.StackTrace.Contains("LoadSubscriberPhones")) { var myException = new Exception("Error retrieving Provisioning information for subscriber's phones from Triad, preceeding with loading the subscriber.", e); _errorLoggingService.LogErrorNoContext(myException); handled = true; } } if (!handled) { const string baseErrorMessage = "Error retrieving DPI information for subscriber"; if (e is EnterpriseServiceException) { esbResultsEnterpriseServiceExceptionFound = true; var myException = new Exception(String.Format("{0}, as error is an EnterpriseServiceException we are going to proceed", baseErrorMessage)); _errorLoggingService.LogErrorNoContext(myException); handled = true; } else if (!isFaultException) { var myException = new Exception(String.Format("{0}, unable to proceed.", baseErrorMessage), e); _errorLoggingService.LogErrorNoContext(myException); throw myException; } } if (!handled) { var myException = new Exception("Unknown error condition retrieving either Provisioning or DPI information for subscriber, unable to proceed.", e); _errorLoggingService.LogErrorNoContext(myException); throw myException; } } } catch (Exception e) { var myException = new Exception("Unknown error condition retrieving either Provisioning or DPI information for subscriber, unable to proceed.", e); _errorLoggingService.LogErrorNoContext(myException); throw myException; } rosettianResults = ((rosettianResponse != null) && (!rosettianResponse.IsFaulted)) ? rosettianResponse.Result : null; provisionedPhonesResults = ((provisioningSubPhonesReponse != null) && (!provisioningSubPhonesReponse.IsFaulted)) ? provisioningSubPhonesReponse.Result : null; esbResults = ((esbGetAccountResponse != null) && (!esbGetAccountResponse.IsFaulted)) ? esbGetAccountResponse.Result : null; compositeSubscriber = FacadeExtensions.Merge(rosettianResults, esbResults, provisionedPhonesResults); compositeSubscriber.BillingRegion = dpiRegion; compositeSubscriber.ProvisionedUsi = usi; // User Story 11766 and Bug 11769 - Adding a new error message for the case where ESB errors out or times out and we don't get any response if ((esbResults == null) && (!esbResultsEnterpriseServiceExceptionFound)) { compositeSubscriber.SubscriberErrorMessages = "DPI data request timed out"; } return compositeSubscriber; }
/// <summary> /// Gets the residential gateway device and other IP Capable devices. /// </summary> /// <param name="criteriaDto">The criteria dto.</param> /// <param name="userDto">The user dto.</param> /// <returns></returns> public CompositeEquipment LoadCompositeEquipment(SearchFieldsDto criteriaDto, UserDto userDto) { var devices = _rosettianService.SearchEquipment(criteriaDto, userDto); if (devices == null || !devices.Any()) { return new CompositeEquipment { ErrorDetails = new ErrorDetails { Code = ResidentialGatewayErrorCode.GatewayNotFound.ToString(), Message = @"RG not Found on Account. Provide the RG serial number and click the button below to associate." }, }; } // retrieve video devices var videoDevices = devices.FindAll(d => d.Type.IptvCapable).ConvertAll<EquipmentDto>(a => { var loadedEquipment = _rosettianService.LoadEquipment(a.SerialNumber, true, userDto); if (loadedEquipment != null && loadedEquipment.CustomFields != null && loadedEquipment.CustomFields.Any()) { a.CustomFields = loadedEquipment.CustomFields; } return a; }); // retrieve RGs var rgEquipments = devices.FindAll( a => (a.Type != null && (a.Type.Category == EquipmentCategoryDto.RGDataPort || a.Type.Category == EquipmentCategoryDto.RGVoicePort))); // return CompositeEquipment with Active RG not Found error when there's no active RG if (!rgEquipments.Any(a => a.Status.Equals("ACTIVE", StringComparison.OrdinalIgnoreCase))) { return new CompositeEquipment { ErrorDetails = new ErrorDetails { Code = ResidentialGatewayErrorCode.GatewayNotFound.ToString(), Message = @"Active RG not Found on Account. Provide the RG serial number and click the button below to associate." }, VideoDevices = videoDevices, OtherRGEquipments = rgEquipments.GroupBy(a => a.SerialNumber.Substring(0, a.SerialNumber.Length - 3)) .Select(g => g.First()) .ToList() }; } // return CompositeEquipment var rgActiveEquipment = rgEquipments.Find(a => a.Status.Equals("ACTIVE", StringComparison.OrdinalIgnoreCase)); rgEquipments.RemoveAll(r => r.SerialNumber.StartsWith(rgActiveEquipment.SerialNumber.Substring(0, rgActiveEquipment.SerialNumber.Length - 3))); return new CompositeEquipment { ResidentialEquipment = _rosettianService.LoadEquipment(rgActiveEquipment.SerialNumber, true, userDto), VideoDevices = videoDevices, OtherRGEquipments = rgEquipments.GroupBy(a => a.SerialNumber.Substring(0, a.SerialNumber.Length - 3)).Select(g => g.First()).ToList() }; }
public void MyTestInitialize() { // Setup context var mySimplTestContext = new SIMPLTestContext(); HttpContext.Current = mySimplTestContext.GetHttpSession(); var userName = mySimplTestContext.GetNameFromWindowsIdentity(); CurrentUser.SetInstance(userName); RosettianUser = CurrentUser.AsUserDto(); OrderHistoryController4Test = DependencyResolver.Current.GetService<OrderHistoryController>(); OrderHistoryController4Test.ControllerContext = new ControllerContext(new HttpContextWrapper(HttpContext.Current), new RouteData(), OrderHistoryController4Test); }
/// <summary> /// Updates the phone details. /// </summary> /// <param name="subId">The sub identifier.</param> /// <param name="phoneDetails">The phone details.</param> /// <param name="userDto">The user dto.</param> /// <returns></returns> /// <exception cref="BusinessFacadeFaultException"> /// </exception> public bool UpdatePhoneDetails(string subId, PhoneDetails phoneDetails, UserDto userDto) { PhoneDto selectedPhone = null; var phones = _rosettianService.LoadSubscriberPhones(subId, userDto); if (phones != null && phones.Any()) { selectedPhone = phones.FirstOrDefault(phone => phone.PhoneNumber == phoneDetails.TN); } if (selectedPhone == null) { throw new BusinessFacadeFaultException { MessageDetail = @"TN not found." }; } selectedPhone.Update(phoneDetails); if (!_rosettianService.UpdateSubscriberPhone(subId, selectedPhone, userDto)) { throw new BusinessFacadeFaultException { MessageDetail = String.Format(@"Update subscriber phone: {0} failed.", selectedPhone) }; } return true; }
public string ResetVoicemailPassword(string subId, string phoneNumber, UserDto user, HeaderArgs headerArgs) { var passcode = String.Empty; try { if (String.IsNullOrEmpty(phoneNumber) || String.IsNullOrEmpty(subId)) { throw new BusinessFacadeFaultException(500, "Phone Number or SubscriberId was null or empty"); } passcode = _enterpriseService.GeneratePasscode(phoneNumber, headerArgs); int n; if (String.IsNullOrWhiteSpace(passcode) || passcode.Length != 6 || !Int32.TryParse(passcode, out n)) { throw new BusinessFacadeFaultException(500, "Passcode returned from ESB was null or empty"); } var phone = _rosettianService.LoadSubscriberPhones(subId, user).Find(ph => ph.PhoneNumber == phoneNumber); if (phone != null && phone.PhoneProvSpec != null) { phone.PhoneProvSpec.VoicemailPIN = passcode; if (!_rosettianService.UpdateSubscriberPhone(subId, phone, user)) throw new BusinessFacadeFaultException(500, "Rosettian was unable to update phone object"); _rosettianService.PerformPhoneOperation( new List<PhoneOperationDto> { new PhoneOperationDto { PhoneNumber = phone.PhoneNumber, Type = PhoneOperationTypeDto.Refresh } }, user ); } else { throw new BusinessFacadeFaultException(500, "Rosettian was unable to find the phonenumber to be updated."); } } catch (Exception ex) { _errorLoggingService.LogErrorNoContext(ex); throw new Exception("Unable to Reset VM Password at current time, please try again.", ex); } return passcode; }
/// <summary> /// Search both Provisioning and Billing for subscribers. /// </summary> /// <param name="searchCriteriaDto">Search parameters</param> /// <param name="userDto">Currently logged in user</param> /// <param name="searchResultStatusString">RETURN value containing the status of collection</param> /// <returns>List collection containing found distinct USIs based upon search criteria</returns> public List<SubscriberSearchResult> SearchSubscribers(SearchFieldsDto searchCriteriaDto, UserDto userDto, out string searchResultStatusString) { var billingCriteria = TypeAdapter.Adapt<SearchFieldsDto, BillingSearchFieldsDto>(searchCriteriaDto); var billingList = new List<SubscriberSearchResult>(); var provisioningList = new List<SubscriberSearchResult>(); var searchResultStatus = SearchResultStatus.Error; var taskArray = new List<Task>(); Task<List<SubscriberDto>> provisioningServiceTask = null; //Provision Search if (!billingCriteria.ExcludeProvisioning && searchCriteriaDto.HasProvisioningFields) { provisioningServiceTask = Task.Factory.StartNew( () => _rosettianService.SearchSubscribers(searchCriteriaDto, userDto) ?? new List<SubscriberDto>()); taskArray.Add(provisioningServiceTask); } Task<List<BillingSearchSubscriberDto>> billingServiceTask = null; //Billing Search if (!billingCriteria.ExcludeDPI && searchCriteriaDto.HasBillingFields) { billingServiceTask = Task.Factory.StartNew( () => _billingClient.SearchSubscriber(billingCriteria, userDto) ?? new List<BillingSearchSubscriberDto>()); taskArray.Add(billingServiceTask); } try { Task.WaitAll(taskArray.ToArray()); } catch (AggregateException ae) { ae.InnerExceptions.ToList().ForEach(innerException => { _errorLoggingService.LogErrorNoContext(innerException); if (innerException.Message.Contains("Unable to determine DPI environment.")) { throw new ArgumentException("No subscribers found. Please add the state if this is a pending install."); } }); } finally { foreach (var task in taskArray) { if (task.Status == TaskStatus.RanToCompletion) { if (task == billingServiceTask) { searchResultStatus = searchResultStatus | SearchResultStatus.BillingPartialSuccess; billingList = billingServiceTask.Result.Select(MapBillingResponseToSubscriberSearchResult) .ToList(); } if (task == provisioningServiceTask) { searchResultStatus = searchResultStatus | SearchResultStatus.ProvisioningPartialSuccess; provisioningList = provisioningServiceTask.Result.Select( MapProvisioningResponseToSubscriberSearchResult).ToList(); } } } } searchResultStatusString = searchResultStatus.GetStringValue(); return CreateCompositeSearchSubscriberResponse(billingList, provisioningList, searchCriteriaDto); }
/// <summary> /// Activate Mediaroom STB /// </summary> /// <param name="deviceId"></param> /// <param name="currentLocationId"></param> /// <param name="currentSubscriberId"></param> /// <param name="userDto">The user.</param> /// <returns></returns> public bool ActivateMediaroomStb(string deviceId, string currentLocationId, string currentSubscriberId, UserDto userDto) { // STEP 1: Arguments validation if (String.IsNullOrWhiteSpace(deviceId)) { throw new ArgumentException("Device ID cannot be null or empty or whitespace"); } if (String.IsNullOrWhiteSpace(currentLocationId)) { throw new ArgumentException("Location ID cannot be null or empty or whitespace"); } // STEP 2: Normalize arguments deviceId = deviceId.Trim().ToUpper(); currentLocationId = currentLocationId.Trim().ToUpper(); // STEP 3: Load equipment var device = _rosettianService.LoadEquipment(deviceId, false, userDto); // STEP 4: Business rules validation - throws error if the device does not exist if (null == device || !String.Equals(device.SerialNumber, deviceId, StringComparison.OrdinalIgnoreCase)) { throw new Exception( String.Format("Activation is not allowed, device [{0}] does not exist", deviceId)); } // STEP 5: Business rules validation - throws error if the device is not U-Verse STBs if (!DeviceLogic.IsIptvDevice(device.Type)) { throw new Exception( String.Format("Activation is not allowed, device [{0}] is not video device", deviceId)); } // STEP 6: Business rules validation - throws error if the device already exists on current location if (String.Equals(device.LocationId, currentLocationId, StringComparison.OrdinalIgnoreCase)) { throw new Exception( String.Format( "Activation is not allowed, device [{0}] already exists on current location [{1}]", deviceId, currentLocationId)); } // STEP 7: Business rules validation - throws error if the device already assigned to another subscriber and is "ACTIVE" if (!String.IsNullOrWhiteSpace(device.AssociatedSubscriberId) && !String.Equals(device.AssociatedSubscriberId, currentSubscriberId, StringComparison.OrdinalIgnoreCase) && device.Status == "ACTIVE") { throw new Exception( String.Format( "Activation is not allowed, device [{0}] already activated for another subscriber [{1}]", deviceId, device.AssociatedSubscriberId)); } // STEP 8: Activate the device on current location device.Status = "ACTIVE"; device.LocationId = currentLocationId; return _rosettianService.UpdateEquipment(device, userDto); }
//Get the Triad USI associated with the Subscriber for DPI WTN USI //IF failed use given USI private string GetProvisionedUSIByBillingUSI(string usi, UserDto userDto) { var provisionedUSI = string.Empty; try { provisionedUSI = _billingClient.GetProvisionedSubIdByBillingSubId(usi, userDto); } catch { provisionedUSI = usi; } finally { provisionedUSI = (string.IsNullOrEmpty(provisionedUSI))? usi : provisionedUSI; } return provisionedUSI; }
/// <summary> /// Finds the equipments with device port information. /// It is applicable not only for RGs, But also for equipments. /// </summary> /// <param name="serialNumber">The serial number.</param> /// <param name="userDto"></param> /// <returns></returns> public List<EquipmentDto> FindEquipments(string serialNumber, UserDto userDto) { var criteria = new SearchFieldsDto { EquipmentId = serialNumber }; var equipments = this._rosettianService.SearchEquipment(criteria, userDto); //TODO: Replace following with rosettian operation that retrieves ports. That operation was not ready yet. List<string> devicePorts = new List<string> { "P01", "P02", "D01" }; List<EquipmentDto> matchedEquipments = new List<EquipmentDto>(); if (devicePorts.Any(a => serialNumber.EndsWith(a))) { serialNumber = serialNumber.Substring(0, serialNumber.Length - 3); } if (equipments != null && equipments.Any()) { devicePorts.ForEach(p => { var matches = equipments.FindAll(e => e.SerialNumber.Equals(String.Format("{0}{1}", serialNumber, p) , StringComparison.OrdinalIgnoreCase)); if (matches.Any()) { matchedEquipments.AddRange(matches); } }); } return matchedEquipments; }
/// <summary> /// GetCopperAndFiberFacilitiesData /// </summary> /// <param name="facilityRequest">The facilityRequest</param> /// <param name="dpiRegion">The dpiRegion</param> /// <param name="userDto">The user dto</param> /// <returns></returns> public GetFacilitiesResponseDto GetCopperAndFiberFacilitiesData(GetFacilitiesRequestDto facilityRequest, string dpiRegion, UserDto userDto) { var taskArray = new List<Task>(); Task<GetFacilitiesResponseDto> dpiFacilityTask = null; Task<FacilityDataDto> rozFacilityTask = null; GetFacilitiesResponseDto dpiFacilityData = null; FacilityDataDto rozFacilityData = null; // retrieve copper and fiber facilities data from esb, rosettian respectively try { dpiFacilityTask = Task.Factory.StartNew( () => _enterpriseService.GetFacilitiesData(facilityRequest, new HeaderArgs(dpiRegion, userDto.Name, null, userDto.Name, userDto.Email, userDto.Role))); taskArray.Add(dpiFacilityTask); rozFacilityTask = Task.Factory.StartNew( () => _rozFacilityClient.GetFacilityData(facilityRequest.USI, userDto)); taskArray.Add(rozFacilityTask); Task.WaitAll(taskArray.ToArray()); } catch (AggregateException ae) { ae.InnerExceptions.ToList() .ForEach(innerException => _errorLoggingService.LogErrorNoContext(innerException)); } finally { foreach (var task in taskArray.Where(task => task.Status == TaskStatus.RanToCompletion)) { if (task == dpiFacilityTask && dpiFacilityTask != null) dpiFacilityData = dpiFacilityTask.Result; if (task == rozFacilityTask && rozFacilityTask != null) rozFacilityData = rozFacilityTask.Result; } } // construct facilities data with retrieved copper, fiber facilities data var currentSubFacilityData = dpiFacilityData ?? new GetFacilitiesResponseDto { PlantData = new PlantDataDto() }; if (currentSubFacilityData.PlantData == null) currentSubFacilityData.PlantData = new PlantDataDto(); if (rozFacilityData != null) { var fiberPlantDataStatus = string.Empty; if (currentSubFacilityData.PlantData.FiberPlantData != null) fiberPlantDataStatus = currentSubFacilityData.PlantData.FiberPlantData.Status; currentSubFacilityData.PlantData.FiberPlantData = MapToFiberPlantDataDto(rozFacilityData, fiberPlantDataStatus); } // return facilities data return currentSubFacilityData; }
public void MyTestInitialize() { // Helper code to get the HttpContext var mySIMPLTestContext = new SIMPLTestContext(); HttpContext.Current = mySIMPLTestContext.GetHttpSession(); // Helper Code to get the user logged into Windows var userName = mySIMPLTestContext.GetNameFromWindowsIdentity(); // Calling actual production code to set the instance for this username CurrentUser.SetInstance(userName); // Calling actual production code to get the Rosettian User Object RosettianUser = CurrentUser.AsUserDto(); // Set up the PhoneController PhoneControllerForTests = new PhoneController(); PhoneControllerForTests.ControllerContext = new ControllerContext(new HttpContextWrapper(HttpContext.Current), new RouteData(), PhoneControllerForTests); }