private async Task EnrollTenantForService( string enrollingTenantName, string serviceTenantName, string?enrollmentConfigurationName = null) { ITenantStore managementService = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantStore>(); ITenantProvider tenantProvider = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantProvider>(); ITenant enrollingTenant = await tenantProvider.GetTenantAsync(this.scenarioContext.Get <string>(enrollingTenantName)).ConfigureAwait(false); ITenant serviceTenant = await tenantProvider.GetTenantAsync(this.scenarioContext.Get <string>(serviceTenantName)).ConfigureAwait(false); List <EnrollmentConfigurationItem> enrollmentConfiguration = string.IsNullOrEmpty(enrollmentConfigurationName) ? new List <EnrollmentConfigurationItem>() : this.scenarioContext.Get <List <EnrollmentConfigurationItem> >(enrollmentConfigurationName); await CatchException.AndStoreInScenarioContextAsync( this.scenarioContext, () => managementService.EnrollInServiceAsync( enrollingTenant, serviceTenant, enrollmentConfiguration.ToArray())).ConfigureAwait(false); }
public Task WhenIUseTheTenantStoreToInitialiseTheTenancyProviderUsingTheForceOption() { ITenantStore service = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantStore>(); return(CatchException.AndStoreInScenarioContextAsync( this.scenarioContext, () => service.InitialiseTenancyProviderAsync(true))); }
public Task WhenIValidateTheServiceManifestCalled(string manifestName) { ITenantStore store = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantStore>(); ServiceManifest manifest = this.scenarioContext.Get <ServiceManifest>(manifestName); return(CatchException.AndStoreInScenarioContextAsync( this.scenarioContext, () => manifest.ValidateAndThrowAsync(store))); }
public void WhenIDeserializeTheManifestCalled(string manifestName) { CatchException.AndStoreInScenarioContext( this.scenarioContext, () => { ServiceManifest manifest = this.LoadManifestFile(manifestName); this.scenarioContext.Set(manifest); }); }
private Task CreateTenant(Guid wellKnownGuid, string clientName, string?parentId = null) { ITenantStore service = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantStore>(); return(CatchException.AndStoreInScenarioContextAsync( this.scenarioContext, async() => { ITenant newTenant = await service.CreateClientTenantWithWellKnownGuidAsync(wellKnownGuid, clientName, parentId).ConfigureAwait(false); this.scenarioContext.Set(newTenant.Id, clientName); })); }
public Task WhenIUseTheTenantStoreToCreateANewClientTenantCalled(string clientName) { ITenantStore service = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantStore>(); return(CatchException.AndStoreInScenarioContextAsync( this.scenarioContext, async() => { ITenant newTenant = await service.CreateClientTenantAsync(clientName).ConfigureAwait(false); this.scenarioContext.Set(newTenant.Id, clientName); })); }
public Task CreateServiceTenantWithExceptionHandlingAsync(ServiceManifest manifest) { ITenantStore service = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantStore>(); return(CatchException.AndStoreInScenarioContextAsync( this.scenarioContext, async() => { ITenant newTenant = await service.CreateServiceTenantAsync(manifest).ConfigureAwait(false); this.scenarioContext.Set(newTenant.Id, manifest.ServiceName); })); }
private async Task AddConfiguration( string tenantName, string configurationName) { ITenantStore tenantStore = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantStore>(); ITenantProvider tenantProvider = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantProvider>(); ITenant tenant = await tenantProvider.GetTenantAsync(this.scenarioContext.Get <string>(tenantName)).ConfigureAwait(false); List <ConfigurationItem> configuration = this.scenarioContext.Get <List <ConfigurationItem> >(configurationName); await CatchException.AndStoreInScenarioContextAsync( this.scenarioContext, () => tenantStore.AddOrUpdateStorageConfigurationAsync( tenant, configuration.ToArray())).ConfigureAwait(false); }
public async Task WhenIUseTheTenantStoreToUnenrollTheTenantCalledFromTheServiceCalled( string unenrollingTenantName, string serviceTenantName) { ITenantStore tenantStore = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantStore>(); ITenantProvider tenantProvider = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantProvider>(); ITenant unenrollingTenant = await tenantProvider.GetTenantAsync(this.scenarioContext.Get <string>(unenrollingTenantName)).ConfigureAwait(false); ITenant serviceTenant = await tenantProvider.GetTenantAsync(this.scenarioContext.Get <string>(serviceTenantName)).ConfigureAwait(false); await CatchException.AndStoreInScenarioContextAsync( this.scenarioContext, () => tenantStore.UnenrollFromServiceAsync( unenrollingTenant.Id, serviceTenant.Id)).ConfigureAwait(false); }
public void SearchFilesInAllComp(string textToSearch) //If directory not selected. { try { string[] drivers = Environment.GetLogicalDrives(); //Get all drives. foreach (string item in drivers) //Search in every drive { SearchFilesInDirectory(item, textToSearch); //Drive = directory. } } catch (System.Security.SecurityException) { CatchException?.Invoke(this, new ExceptionEventArgs("There is no required permission. ", ConsoleColor.Yellow)); } catch (Exception ex) { CatchException?.Invoke(this, new ExceptionEventArgs("Error occurs. Details: " + ex.Message, ConsoleColor.Blue)); } }
public ActionResult ErrorFile(Models.ErrorFilePage row) { ViewBag.PreviousUrl = TempData["PreviousUrl"] != null ? TempData["PreviousUrl"] : GetPreviousUrl(); bool Supprimer = false; bool Importer = false; if (Request.Form["Action"] != null) { if (Request.Form["Action"].IndexOf("Imp", StringComparison.OrdinalIgnoreCase) >= 0) { Importer = true; } else if (Request.Form["Action"].IndexOf("Sup", StringComparison.OrdinalIgnoreCase) >= 0) { Supprimer = true; } } System.Web.Script.Serialization.JavaScriptSerializer scriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer(); var Fichier = row.Fichiers.FirstOrDefault(); if (Fichier != null) { byte[] input = null; int FileLen = Fichier.ContentLength; System.IO.Stream MyStream; input = new byte[FileLen]; MyStream = Fichier.InputStream; MyStream.Read(input, 0, FileLen); row.MyEx = scriptSerializer.Deserialize <MyException>(System.Text.Encoding.UTF8.GetString(input)).EEE(); } else if (!string.IsNullOrWhiteSpace(row.Fichier)) { var filename = System.IO.Path.Combine(Server.MapPath("~/App_Data"), row.Fichier + ".ERDUMP"); if (Supprimer) { System.IO.File.Delete(filename); row.MyEx = null; } else { row.MyEx = scriptSerializer.Deserialize <MyException>(System.IO.File.ReadAllText(filename)).EEE(); } } else { row.MyEx = null; } // Except = exception.EEE(); if (Importer && row.MyEx != null) { try { //throw new System.Data.Entity.Validation.DbEntityValidationException(); var sql = new Models.Entities(); sql.CatchMe_Exception.Add(row.MyEx); sql.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException e) { ViewBag.ErrorMessage = CatchException.Dump(e).ToString().Replace("\n", "<br/>"); return(View(row)); } if (!string.IsNullOrWhiteSpace(row.Fichier)) { var filename = System.IO.Path.Combine(Server.MapPath("~/App_Data"), row.Fichier + ".ERDUMP"); System.IO.File.Delete(filename); } return(RedirectToAction("Erreur", new { id = row.MyEx.CodeCatch })); } return(View(row)); }
public void SearchFilesInDirectory(string directory, string textToSearch) //Search files in directory. { try { string[] files = Directory.GetFiles(directory); //Get all files in directory foreach (string item in files) { string itemToLowerCase = item.ToLower(); //Make file name in lowercase letters if (itemToLowerCase.Contains(textToSearch.ToLower())) //Check if file name contains searching text in lowercase letters { FoundFile?.Invoke(this, new ResultEventArgs(SearchId, item)); //If matching file found, invoke event and pass him search ID from DB, and matching file name. } } } catch (UnauthorizedAccessException) { CatchException?.Invoke(this, new ExceptionEventArgs("There is no required permission to: " + directory, ConsoleColor.Red)); } catch (DirectoryNotFoundException) { CatchException?.Invoke(this, new ExceptionEventArgs("Path: " + directory + " is not found or is invalid", ConsoleColor.DarkMagenta)); } catch (PathTooLongException) { CatchException?.Invoke(this, new ExceptionEventArgs("Error:The specified path, file name, or both exceed the system-defined maximum length.", ConsoleColor.DarkRed)); } catch (ArgumentException) { CatchException?.Invoke(this, new ExceptionEventArgs("Error:path is a zero-length string, contains only white space, or contains one or more invalid characters.", ConsoleColor.DarkCyan)); } catch (IOException) { CatchException?.Invoke(this, new ExceptionEventArgs("Error. Path: " + directory + " is a file name or a network error has occurred", ConsoleColor.Green)); } catch (Exception ex) { CatchException?.Invoke(this, new ExceptionEventArgs("Error: " + ex.Message, ConsoleColor.DarkBlue)); } try { string[] dirs = Directory.GetDirectories(directory); //Get all directories in selected directory foreach (string item in dirs) { SearchFilesInDirectory(item, textToSearch); //Recursion, search files in every directory in directory. } } catch (UnauthorizedAccessException) { CatchException?.Invoke(this, new ExceptionEventArgs("There is no required permission to: " + directory, ConsoleColor.Red)); } catch (DirectoryNotFoundException) { CatchException?.Invoke(this, new ExceptionEventArgs("Path: " + directory + " is not found or is invalid", ConsoleColor.DarkMagenta)); } catch (ArgumentException) { CatchException?.Invoke(this, new ExceptionEventArgs("Error:path is a zero-length string, contains only white space, or contains one or more invalid characters.", ConsoleColor.DarkCyan)); } catch (PathTooLongException) { CatchException?.Invoke(this, new ExceptionEventArgs("Error:The specified path, file name, or both exceed the system-defined maximum length.", ConsoleColor.DarkRed)); } catch (IOException) { CatchException?.Invoke(this, new ExceptionEventArgs("Error. Path: " + directory + " is a file name", ConsoleColor.Green)); } catch (Exception ex) { CatchException?.Invoke(this, new ExceptionEventArgs("Error: " + ex.Message, ConsoleColor.Blue)); } }