public RosettianClientMessageInspector() { _errorLoggingService = new ErrorLoggingService(); var enterpriseExceptions = new EnterpriseExceptionHandler(_errorLoggingService); var resourceInformationInquiry = new ResourceInformationInquiryClient(); _syncPlant = new ConsolidatedSyncResource(resourceInformationInquiry, _errorLoggingService, enterpriseExceptions); }
/// <summary> /// Public constructor for LoggingExamples02_ViaLoggingService /// which uses dependency injection. /// /// For production code, simply call without the argument myErrorLoggingService /// /// For test methods, you can inject a different implementation based /// on the IErrorLoggingService. /// </summary> /// <param name="myErrorLoggingService"></param> public LoggingExamples02_ViaLoggingService(IErrorLoggingService myErrorLoggingService = null) { if (myErrorLoggingService == null) { myErrorLoggingService = new ErrorLoggingService(); } _errorLoggingService = myErrorLoggingService; }
private void ApplyClientBehavior(ClientRuntime runtime) { // Don't add a message inspector if it already exists if (runtime.MessageInspectors.OfType<EnterpriseClientMessageInspector>().Any()) { return; } var errorLoggingService = new ErrorLoggingService(); runtime.MessageInspectors.Add(new EnterpriseClientMessageInspector(errorLoggingService)); }
/// <summary> /// CurrentCachedSIMPLLoginTrackerRecord method /// </summary> /// <param name="userName"></param> /// <returns></returns> public static SIMPLLoginTracker CurrentCachedSIMPLLoginTrackerRecord(string userName) { if (string.IsNullOrWhiteSpace(userName)) { throw new ArgumentException("Parameter is null or whitespace", "userName"); } var cacheKey = GetCacheKey(userName); if (Cache[cacheKey] == null) { var myErrorLoggingService = new ErrorLoggingService(); var mySIMPLSessionEntities = new SIMPLSessionEntitiesCustom(); var mySIMPLAdminEntitiesRepository = new SIMPLSessionEntitiesRepository(myErrorLoggingService, mySIMPLSessionEntities); var myLoginTracker = mySIMPLAdminEntitiesRepository.GetSIMPLLoginTrackerRecord(userName); GuardsForSIMPLLoginTracker(myLoginTracker); AddToOrUpdateCache(cacheKey, myLoginTracker, TypesCacheExpirationTimeInSeconds); } return Cache[cacheKey] as SIMPLLoginTracker; }
public void MyTestInitialize() { using (ShimsContext.Create()) { // Set up the LoginControllerForTests LoginControllerForTests = DependencyResolver.Current.GetService<LoginController>(); // Set up the LoginViewModelForTests var logout = new Logout(); var myErrorLoggingService = new ErrorLoggingService(); var mySingleConcurrentLoginRules = new SingleConcurrentLoginRules(); var mySIMPLSessionEntitiesRepository = new SIMPLSessionEntitiesRepository(myErrorLoggingService); var mySingleConConcurrentLoginManager = new SingleConcurrentLoginManager(mySingleConcurrentLoginRules, myErrorLoggingService, mySIMPLSessionEntitiesRepository); LoginViewModelForTests = new LoginViewModel(logout, myErrorLoggingService, mySingleConcurrentLoginRules, mySingleConConcurrentLoginManager, mySIMPLSessionEntitiesRepository); ConfigControllerForTests = DependencyResolver.Current.GetService<ConfigController>(); } }
/// <summary> /// Creates and sends mail message using mailHelper property values. /// </summary> public void Send() { var bccAddresses = string.Empty; var ccAddresses = string.Empty; var toAddresses = string.Empty; try { var email = new MailMessage { Subject = Subject, Body = Body, From = new MailAddress(From) }; if (BccAddresses.Count > 0) { foreach (var addr in BccAddresses) { email.Bcc.Add(new MailAddress(addr)); bccAddresses = string.Format("{0}, {1},", bccAddresses, addr); } } if (CcAddresses.Count > 0) { foreach (var addr in CcAddresses) { email.CC.Add(new MailAddress(addr)); ccAddresses = string.Format("{0}, {1},", ccAddresses, addr); } } if (ToAddresses.Count > 0) { foreach (var addr in ToAddresses) { email.To.Add(new MailAddress(addr)); toAddresses = string.Format("{0}, {1},", toAddresses, addr); } } email.IsBodyHtml = true; Client.UseDefaultCredentials = true; Client.Send(email); } catch(Exception inner) { var errorLoggingService = new ErrorLoggingService(); var message = new StringBuilder(); message.AppendFormat("Error occurred when trying to send an email {0}{0}", Environment.NewLine); message.AppendFormat("To addresses: {0}{1}{1}", toAddresses, Environment.NewLine); message.AppendFormat("CC addresses: {0}{1}{1}", ccAddresses, Environment.NewLine); message.AppendFormat("BCC addresses: {0}{1}{1}", bccAddresses, Environment.NewLine); message.AppendFormat("Here is the inner exception message: {0}", inner.Message); var myException = new Exception(message.ToString(), inner); errorLoggingService.LogErrorNoContext(myException); throw myException; } finally { Client.Dispose(); } }
private static void GetLocationIdFromReturnToHeadend(object dtoObject, ref List<string> locationIdsToSync) { var serials = dtoObject as List<string>; var tempLocationsIdsToSync = locationIdsToSync; if (serials != null && serials.Count > 0) { try { Parallel.ForEach(serials, serial => { using (var client = new RosettianClient()) { var equipments = client.SearchEquipment(new SearchFieldsDto() { EquipmentId = serial }, new UserDto() { Name = "SIMPL" }); if (equipments != null && equipments.First() != null && equipments.Count > 0) { tempLocationsIdsToSync.Add(equipments.First().LocationId); } } }); } catch (AggregateException fault) { var log = new ErrorLoggingService(); log.LogErrorNoContext(fault); } } locationIdsToSync = tempLocationsIdsToSync; }
private static void GetLocationIdFromEquipmentDto(object dtoObject, string methodName, ref List<string> locationIdsToSync) { var equipementDto = (dtoObject.GetType().Name == "EquipmentDto") ? dtoObject as EquipmentDto : dtoObject as CableCardDto; if (equipementDto != null && !string.IsNullOrWhiteSpace(equipementDto.LocationId)) { locationIdsToSync.Add(equipementDto.LocationId); if (methodName == "UpdateEquipment") { try { using (var client = new RosettianClient()) { var equipments = client.SearchEquipment( new SearchFieldsDto() { EquipmentId = equipementDto.SerialNumber }, new UserDto() { Name = "SIMPL" }); if (equipments != null && equipments.FirstOrDefault() != null && equipments.Count > 0) { locationIdsToSync.Add(equipments.First().LocationId); } } } catch (FaultException<ValidationFault> fault) { var log = new ErrorLoggingService(); log.LogErrorNoContext(fault); } } } }
private static void GetLocationIdFromEquipmentCriteriaCollectionDto(object dtoObject, string methodName, ref List<string> locationIdsToSync) { var equipmentCollectionDto = dtoObject as EquipmentCriteriaCollectionDto; if (equipmentCollectionDto != null && equipmentCollectionDto.Count > 0) { foreach (var equipment in equipmentCollectionDto) { if (equipment != null && !string.IsNullOrWhiteSpace(equipment.LocationId)) { locationIdsToSync.Add(equipment.LocationId); } } if (methodName != "ActivateONT") return ; try { using (var client = new RosettianClient()) { var baseOntSerial = (equipmentCollectionDto.First().SerialNumber.Count() > 12) ? equipmentCollectionDto.First().SerialNumber.Substring(0, 12) : equipmentCollectionDto.First().SerialNumber; var equipments = client.SearchEquipment( new SearchFieldsDto() { EquipmentId = baseOntSerial }, new UserDto() { Name = "SIMPL" }); if (equipments != null && equipments.FirstOrDefault() != null && equipments.Count > 0) { foreach (var equipment in equipments) { if (equipment != null && !string.IsNullOrWhiteSpace(equipment.LocationId)) { locationIdsToSync.Add(equipment.LocationId); } } } } } catch (FaultException<ValidationFault> fault) { var log = new ErrorLoggingService(); log.LogErrorNoContext(fault); } } }
public void MyTestInitialize() { // Helper code to get the HttpContext SIMPLTestContext 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(); // TODO: Instantiation should be accomplished using Autofac as described by Wiki item http://iteverett.corp.ftr.com/Team%20Wiki/Autofac%20Test%20Initialization.aspx var rosettianClient = new RosettianClient(); var errorLoggingService = new ErrorLoggingService(); // Set up the SubscriberController PpvVodController = new PPV_VODController(rosettianClient, errorLoggingService); PpvVodController.ControllerContext = new ControllerContext(new HttpContextWrapper(HttpContext.Current), new RouteData(), PpvVodController); }