public virtual async Task CreateContainerAsync(string name) { var containerConfiguration = BlobContainerConfigurationProvider.Get <OSSContainer>(); var containerName = NormalizeContainerName(containerConfiguration, name); if (await ContainerRepository.ContainerExistsAsync(name)) { } // 框架暂时未实现创建Container ,这里采用保存一个空文件,然后删除此文件的方法来创建Container var blobContainer = BlobContainerFactory.Create(containerName); try { var emptyBlobData = System.Text.Encoding.UTF8.GetBytes(""); await blobContainer.SaveAsync("empty.txt", emptyBlobData, true); var container = new BlobContainer(GuidGenerator.Create(), containerName, CurrentTenant.Id) { CreationTime = Clock.Now }; await ContainerRepository.InsertAsync(container); } finally { await blobContainer.DeleteAsync("empty.txt"); } }
public MyWpfObject() { ShipmentRepository ShipmentRepository = new ShipmentRepository(); ContainerRepository ContainerRepository = new ContainerRepository(); PackageRepository PackageRepository = new PackageRepository(); ShipmentRepository.LoadingComplete += Repository_LoadingComplete; ContainerRepository.LoadingComplete += Repository_LoadingComplete; PackageRepository.LoadingComplete += Repository_LoadingComplete; Task[] loadingTasks = new Task[] { new Task(ShipmentRepository.Load), new Task(ContainerRepository.Load), new Task(PackageRepository.Load) }; countdownEvent = new CountdownEvent(loadingTasks.Length); foreach (var task in loadingTasks) { task.Start(); } // Wait till everything is loaded. countdownEvent.Wait(); Console.WriteLine("Everything Loaded"); //Wait till aditional tasks are completed. Task.WaitAll(loadingTasks); Console.WriteLine("Everything Completed"); Console.ReadKey(); }
public HttpResponseMessage GetItemsByDate(DateTime date) { var employees = ContainerRepository.GetContainerByDate(date); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, employees); return(response); }
public HttpResponseMessage GetItemsByContainerNo(String containerNo) { var employees = ContainerRepository.GetContainer(containerNo); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, employees); return(response); }
protected void gvContainer_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = gvContainer.Rows[e.RowIndex]; int containerId = (int)gvContainer.DataKeys[e.RowIndex].Value; Container cont = new Container() { Id = containerId, BookingId = DataUtil.GetBookingIdFromGiffiId(double.Parse(txtGiffRef.Text)), ContainerNo = (row.FindControl("txtContainerNo") as TextBox).Text.Trim(), SealNo = (row.FindControl("txtSealNo") as TextBox).Text.Trim(), NumOfPkgs = int.Parse((row.FindControl("txtNumOfPkgs") as TextBox).Text.Trim()), NetWeight = double.Parse((row.FindControl("txtNetWeight") as TextBox).Text.Trim()), GRS = float.Parse((row.FindControl("txtGRS") as TextBox).Text.Trim()), Truck = (row.FindControl("txtTruck") as TextBox).Text.Trim(), Invoice = long.Parse((row.FindControl("txtTruckInvoice") as TextBox).Text.Trim()), CreatedDate = DateTime.Now }; ContainerRepository cr = new ContainerRepository(); cr.UpdateContainer(cont); gvContainer.EditIndex = -1; gvContainer.DataSource = GetContainers(this._bookingId); gvContainer.DataBind(); }
public TrashHandler(IPersister persister, IItemFinder finder, ISecurityManager security, ContainerRepository <TrashContainerItem> container) { this.finder = finder; this.persister = persister; this.security = security; this.container = container; }
public ExternalContentRepository(ContainerRepository<ExternalItem> containerRepository, IPersister persister, ContentActivator activator, EditSection config) { this.containerRepository = containerRepository; this.persister = persister; this.activator = activator; externalItemType = Type.GetType(config.Externals.ExternalItemType) ?? typeof(ExternalItem); }
public ExternalContentRepository(ContainerRepository <ExternalItem> containerRepository, IPersister persister, ContentActivator activator, EditSection config) { this.containerRepository = containerRepository; this.persister = persister; this.activator = activator; externalItemType = Type.GetType(config.Externals.ExternalItemType) ?? typeof(ExternalItem); }
public HttpResponseMessage Get() { var employees = ContainerRepository.GetAllContainers(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, employees); return(response); }
public HttpResponseMessage Put(List <Container> e) { var item = ContainerRepository.UpdateContainer(e); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, item); return(response); }
public IHttpActionResult GetContainers() { string userId = GetUserId(); DataSet ds = ContainerRepository.GetContainers(userRole(), userId); return(Ok(ds.Tables[0])); }
public void DeleteImages() { Environment.SetEnvironmentVariable("REGISTRY_ENDPOINT", TestEnvironment.Endpoint); #region Snippet:ContainerRegistry_Tests_Samples_DeleteImage // Get the service endpoint from the environment Uri endpoint = new Uri(Environment.GetEnvironmentVariable("REGISTRY_ENDPOINT")); // Create a new ContainerRegistryClient ContainerRegistryClient client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential()); // Iterate through repositories Pageable <string> repositoryNames = client.GetRepositoryNames(); foreach (string repositoryName in repositoryNames) { ContainerRepository repository = client.GetRepository(repositoryName); // Obtain the images ordered from newest to oldest Pageable <ArtifactManifestProperties> imageManifests = repository.GetManifestPropertiesCollection(orderBy: ArtifactManifestOrderBy.LastUpdatedOnDescending); // Delete images older than the first three. foreach (ArtifactManifestProperties imageManifest in imageManifests.Skip(3)) { Console.WriteLine($"Deleting image with digest {imageManifest.Digest}."); Console.WriteLine($" This image has the following tags: "); foreach (var tagName in imageManifest.Tags) { Console.WriteLine($" {imageManifest.RepositoryName}:{tagName}"); } repository.GetArtifact(imageManifest.Digest).Delete(); } } #endregion }
public async Task HandleErrorsAsync() { Environment.SetEnvironmentVariable("REGISTRY_ENDPOINT", TestEnvironment.Endpoint); #region Snippet:ContainerRegistry_Tests_Samples_HandleErrorsAsync Uri endpoint = new Uri(Environment.GetEnvironmentVariable("REGISTRY_ENDPOINT")); // Create a ContainerRepository class for an invalid repository string fakeRepositoryName = "doesnotexist"; ContainerRegistryClient client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential(), new ContainerRegistryClientOptions() { Audience = ContainerRegistryAudience.AzureResourceManagerPublicCloud }); ContainerRepository repository = client.GetRepository(fakeRepositoryName); try { await repository.GetPropertiesAsync(); } catch (RequestFailedException ex) when(ex.Status == 404) { Console.WriteLine("Repository wasn't found."); } #endregion Snippet:ContainerRegistry_Tests_Samples_HandleErrorsAsync }
/// <summary> /// convert container to view model /// </summary> /// <param name="container"></param> /// <returns></returns> public ContainerViewModel ConvertToView(Container container) { ContainerViewModel model = new ContainerViewModel(); var _containerRepository = new ContainerRepository(); var containerParts = _containerRepository.GetContainerParts().Where(x => x.ContainerId == container.ContainerId).ToList(); model.ContainerId = container.ContainerId; model.BillOfLadingId = container.BillOfLadingId; model.ContainerNumber = (!string.IsNullOrEmpty(container.Number)) ? container.Number : "N/A"; if (containerParts != null && containerParts.Count > 0) { model.ContainerParts = new List <ContainerPartViewModel>(); foreach (var containerPart in containerParts) { ContainerPartViewModel convertedModel = new ContainerPartConverter().ConvertToView(containerPart); model.ContainerParts.Add(convertedModel); } } if (_containerRepository != null) { _containerRepository.Dispose(); _containerRepository = null; } return(model); }
public HttpResponseMessage Post(List <Container> e) { HttpResponseMessage response = null; try { var inventory = new List <Container>(); if (!ContainerRepository.isSNexsit(e)) { inventory = ContainerRepository.InsertContainer(e); response = Request.CreateResponse(HttpStatusCode.OK, inventory); } else { response = Request.CreateResponse(HttpStatusCode.Conflict, inventory); } } catch (Exception x) { string error = x.ToString(); if (error.Equals("An error occurred while updating the entries. See the inner exception for details.")) { return(new HttpResponseMessage(HttpStatusCode.NotModified)); } else { return(new HttpResponseMessage(HttpStatusCode.Forbidden)); } } return(response); }
public HttpResponseMessage Delete(int Seq) { var employees = ContainerRepository.DeleteContainer(Seq); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, employees); return(response); }
public IHttpActionResult DeleteContainer(JObject jObject) { if (!string.IsNullOrEmpty(Convert.ToString(jObject["containerId"]))) { ContainerRepository.DeleteContainer(Convert.ToString(jObject["containerId"])); } return(Json(true)); }
public void TestSetup() { client = InstrumentClient(new ContainerRegistryClient(_url, GetCredential(), new ContainerRegistryClientOptions() { Audience = ContainerRegistryAudience.AzureResourceManagerPublicCloud })); repository = client.GetRepository(_repositoryName); }
public TrashHandler(IPersister persister, ISecurityManager security, ContainerRepository <TrashContainerItem> container, StateChanger stateChanger, IWebContext webContext) { this.persister = persister; this.security = security; this.container = container; this.stateChanger = stateChanger; this.webContext = webContext; }
private static async Task <bool> runCompetetionInsideReusableContainer(Gene gene, string mapPath, DirectoryInfo rootDirectory, CancellationToken cancellationToken = default) { var hasFinished = true; //await initializeCompeteionDirectory(gene, 7099, mapPath, rootDirectory, overWriteFiles: true, cancellationToken: cancellationToken); var containerInfo = await ContainerRepository.GetAFreeContainer(cancellationToken); try { //foreach (var file in rootDirectory.GetFiles()) //{ // file.CopyTo(Path.Combine(containerInfo.FilesDirectory.FullName, file.Name), true); //} await initializeCompeteionDirectory(gene, 7099, mapPath, containerInfo.FilesDirectory, overWriteFiles : true, cancellationToken : cancellationToken); await DockerService.StartContainer(containerInfo.Id, cancellationToken); var startTime = DateTime.Now; while (await DockerService.IsContainerRunningAsync(containerInfo.Id, cancellationToken)) { if ((DateTime.Now - startTime) > _maximumAllowedRunTime) { //Console.WriteLine($"gene {geneId} didn't finish"); hasFinished = false; break; } await Task.Delay(1000, cancellationToken); } containerInfo.FilesDirectory.CopyContentsTo(rootDirectory); if (hasFinished) { var defenderClientOutputPath = ClientManager.GetClientOutputPath(rootDirectory, ClientMode.defend); var attackerClientOutputPath = ClientManager.GetClientOutputPath(rootDirectory, ClientMode.attack); hasFinished = File.Exists(defenderClientOutputPath) && File.Exists(attackerClientOutputPath); } var containerInfoPath = Path.Combine(rootDirectory.FullName, "container.info"); await File.AppendAllLinesAsync(containerInfoPath, await DockerService.GetContainerInfo(containerInfo.Id, showAll: true, cancellationToken: cancellationToken), cancellationToken); var containerInspect = Path.Combine(rootDirectory.FullName, "container.inspect.json"); await File.WriteAllTextAsync(containerInspect, await DockerService.GetContainerInspect(containerInfo.Id, cancellationToken: cancellationToken), cancellationToken); var containerLogPath = Path.Combine(rootDirectory.FullName, "container.log"); await File.WriteAllTextAsync(containerLogPath, await DockerService.ContainerLogAsync(containerInfo.Id, cancellationToken), cancellationToken); return(hasFinished); } finally { containerInfo.Release(); } }
/// <summary> /// convert containerPart to view model /// </summary> /// <param name="containerPart"></param> /// <returns></returns> public ContainerPartViewModel ConvertToView(ContainerPart containerPart) { ContainerPartViewModel model = new ContainerPartViewModel(); var _containerRepository = new ContainerRepository(); var _partRepository = new PartRepository(); var _dynamicsPartRepository = new PartDynamicsRepository(); var _foundryOrderRepository = new FoundryOrderRepository(); var container = _containerRepository.GetContainer(containerPart.ContainerId); var foundryOrderPart = _foundryOrderRepository.GetFoundryOrderParts().FirstOrDefault(x => x.FoundryOrderPartId == containerPart.FoundryOrderPartId); var part = _partRepository.GetPart((foundryOrderPart != null) ? foundryOrderPart.PartId : Guid.Empty); var dynamicsPart = _dynamicsPartRepository.GetPartMaster(part != null && !string.IsNullOrEmpty(part.Number) ? part.Number : null); var foundryOrder = _foundryOrderRepository.GetFoundryOrder((foundryOrderPart != null) ? foundryOrderPart.FoundryOrderId : Guid.Empty); model.FoundryOrderPartId = containerPart.FoundryOrderPartId; model.ContainerPartId = containerPart.ContainerPartId; model.ContainerId = containerPart.ContainerId; model.PartId = (part != null) ? part.PartId : Guid.Empty; model.ContainerNumber = (container != null) ? container.Number : "N/A"; model.PartNumber = (part != null && !string.IsNullOrEmpty(part.Number)) ? part.Number : "N/A"; model.FoundryOrderId = (foundryOrder != null) ? foundryOrder.FoundryOrderId : Guid.Empty; model.OrderNumber = (foundryOrder != null && !string.IsNullOrEmpty(foundryOrder.Number)) ? foundryOrder.Number : "N/A"; model.PalletNumber = (!string.IsNullOrEmpty(containerPart.PalletNumber)) ? containerPart.PalletNumber : "N/A"; model.Quantity = containerPart.Quantity; model.Weight = (dynamicsPart != null) ? (dynamicsPart.ITEMSHWT / 100.00m) : 0.00m; model.Cost = foundryOrderPart.Cost; model.Price = foundryOrderPart.Price; model.AvailableQuantity = (foundryOrderPart != null) ? foundryOrderPart.Quantity : 0; model.ShipCode = (foundryOrderPart != null && !string.IsNullOrEmpty(foundryOrderPart.ShipCode)) ? foundryOrderPart.ShipCode : "N/A"; if (_containerRepository != null) { _containerRepository.Dispose(); _containerRepository = null; } if (_partRepository != null) { _partRepository.Dispose(); _partRepository = null; } if (_dynamicsPartRepository != null) { _dynamicsPartRepository.Dispose(); _dynamicsPartRepository = null; } if (_foundryOrderRepository != null) { _foundryOrderRepository.Dispose(); _foundryOrderRepository = null; } return(model); }
public static void Seed(TranslationDb context) { ContainerRepository.AddTestData(context); LanguageRepository.AddTestData(context); ClientRepository.AddTestData(context); TranslationRepository.AddTestData(context); context.SaveChanges(); context.Dispose(); }
public IHttpActionResult SavePermission(JObject jObject) { string userIds = Convert.ToString(jObject["userIds"]); if (!string.IsNullOrEmpty(Convert.ToString(jObject["containerId"]))) { ContainerRepository.UpdateUserContainer(Convert.ToString(jObject["containerId"]), Convert.ToString(jObject["userIds"])); } return(Json(true)); }
protected void gvContainer_RowDeleting(object sender, GridViewDeleteEventArgs e) { int containerId = (int)gvContainer.DataKeys[e.RowIndex].Value; ContainerRepository cr = new ContainerRepository(); cr.Delete(containerId); gvContainer.EditIndex = -1; gvContainer.DataSource = GetContainers(this._bookingId); gvContainer.DataBind(); }
public IHttpActionResult SaveContainer(Container containerModel) { if (string.IsNullOrEmpty(Convert.ToString(containerModel.ContainerId)) || Convert.ToString(containerModel.ContainerId) == "00000000-0000-0000-0000-000000000000") { //Create Container ContainerRepository.InsertContainer(containerModel); } else { //Update Container ContainerRepository.UpdateContainer(containerModel); } return(Ok("")); }
public async Task DeleteImagesAsync() { Environment.SetEnvironmentVariable("REGISTRY_ENDPOINT", TestEnvironment.Endpoint); #region Snippet:ContainerRegistry_Tests_Samples_DeleteImageAsync #if SNIPPET using System.Linq; using Azure.Containers.ContainerRegistry; using Azure.Identity; #endif // Get the service endpoint from the environment Uri endpoint = new Uri(Environment.GetEnvironmentVariable("REGISTRY_ENDPOINT")); // Create a new ContainerRegistryClient ContainerRegistryClient client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential(), new ContainerRegistryClientOptions() { Audience = ContainerRegistryAudience.AzureResourceManagerPublicCloud }); // Iterate through repositories AsyncPageable <string> repositoryNames = client.GetRepositoryNamesAsync(); await foreach (string repositoryName in repositoryNames) { ContainerRepository repository = client.GetRepository(repositoryName); // Obtain the images ordered from newest to oldest AsyncPageable <ArtifactManifestProperties> imageManifests = repository.GetAllManifestPropertiesAsync(manifestOrder: ArtifactManifestOrder.LastUpdatedOnDescending); // Delete images older than the first three. await foreach (ArtifactManifestProperties imageManifest in imageManifests.Skip(3)) { RegistryArtifact image = repository.GetArtifact(imageManifest.Digest); Console.WriteLine($"Deleting image with digest {imageManifest.Digest}."); Console.WriteLine($" Deleting the following tags from the image: "); foreach (var tagName in imageManifest.Tags) { Console.WriteLine($" {imageManifest.RepositoryName}:{tagName}"); await image.DeleteTagAsync(tagName); } await image.DeleteAsync(); } } #endregion }
protected void AddNewContainer_Click(object sender, EventArgs e) { Container cont = null; try { cont = new Container() { BookingId = DataUtil.GetBookingIdFromGiffiId(double.Parse(txtGiffRef.Text)), ContainerNo = txtNewContainerNo.Text.Trim(), SealNo = txtNewSealNo.Text.Trim(), NumOfPkgs = int.Parse(txtNewNumOfPkgs.Text.Trim()), NetWeight = double.Parse(txtNewNet.Text.Trim()), GRS = float.Parse(txtNewGRS.Text.Trim()), Truck = txtNewTruck.Text.Trim(), Invoice = long.Parse(txtNewTruckInvoice.Text.Trim()), CreatedDate = DateTime.Now }; ContainerRepository cRepo = new ContainerRepository(); if (cRepo.InsertContainer(cont)) { //lblAlertSucess.Visible = true; //lblAlertSucess.Text = string.Format("<strong>Success!</strong> Container No. {0} added GIFFI Ref={1}", cont.ContainerNo, txtGiffRef.Text); gvContainer.DataSource = GetContainers(this._bookingId); gvContainer.Visible = true; gvContainer.DataBind(); ClearContainerInput(); } else { this.Page.AlertMessage(GetType(), string.Format("Error!!!! unable to add ContainerNo={0} to GIFFI Ref={1}", cont.ContainerNo, txtGiffRef.Text)); } } catch (SqlException sex) { this.Page.AlertMessage(GetType(), string.Format("SQL Error!!! Unable to add ContainerNo={0} to GIFFI Ref={1}, EXCEPTION={2}", txtNewContainerNo, txtGiffRef.Text, sex.Message)); } catch (Exception ex) { this.Page.AlertMessage(GetType(), string.Format("Error!!! Unable to add ContainerNo={0} to GIFFI Ref={1}, EXCEPTION={2}", txtNewContainerNo, txtGiffRef.Text, ex.Message)); } }
public IHttpActionResult EditContainer(JObject jObject) { string userId = GetUserId(); string containerId = Convert.ToString(jObject["containerId"]); DataSet ds = ContainerRepository.GetContainers(userRole(), ""); if (string.IsNullOrEmpty(containerId)) { return(Ok(new Container())); } string containerName = ContainerRepository.GetContainerName(userRole(), containerId); string directories = ContainerRepository.GetContainerDirectories(userRole(), containerId); Container containerModel = new Container { ContainerId = Guid.Parse(containerId), Name = containerName, Directories = directories }; return(Ok(containerModel)); }
public ContainerServicio() { _containerRepository = new ContainerRepository(); _containerList = new List <P2PContainer>(); _containerListByEvent = new List <P2PContainer>(); P2PContainer container1 = _containerRepository.AddContainer(1, 1, "Event", "{test:1}", true, false, 2, 2, false); P2PContainer container2 = _containerRepository.AddContainer(2, 3, "Donation", "{test:2}", false, true, 2, 2, false); P2PContainer container3 = _containerRepository.AddContainer(3, 8, "Event", "{test:3}", true, false, 2, 2, false); P2PContainer container4 = _containerRepository.AddContainer(4, 2, "Donation", "{test:4}", true, true, 2, 2, false); P2PContainer container5 = _containerRepository.AddContainer(5, 8, "Event", "{test:5}", false, false, 2, 2, false); _containerList.Add(container1); _containerList.Add(container2); _containerList.Add(container3); _containerList.Add(container4); _containerList.Add(container5); _containerListByEvent.Add(container3); _containerListByEvent.Add(container5); }
public async Task <InvokeResult> UpdateContainerRepoAsync(ContainerRepository containerRepo, EntityHeader org, EntityHeader user) { ValidationCheck(containerRepo, Actions.Update); await AuthorizeAsync(containerRepo, AuthorizeResult.AuthorizeActions.Update, user, org); if (!String.IsNullOrEmpty(containerRepo.Password)) { await _secureStorage.RemoveSecretAsync(org, containerRepo.SecurePasswordId); var addSecretResult = await _secureStorage.AddSecretAsync(org, containerRepo.Password); if (!addSecretResult.Successful) { return(addSecretResult.ToInvokeResult()); } containerRepo.SecurePasswordId = addSecretResult.Result; containerRepo.Password = null; } await _repo.UpdateContainerRepoAsync(containerRepo); return(InvokeResult.Success); }
public async Task <InvokeResult> AddContainerRepoAsync(ContainerRepository containerRepo, EntityHeader org, EntityHeader user) { ValidationCheck(containerRepo, Actions.Create); await AuthorizeAsync(containerRepo, AuthorizeResult.AuthorizeActions.Create, user, org); if (String.IsNullOrEmpty(containerRepo.Password)) { return(InvokeResult.FromErrors(new ErrorMessage("Password is required."))); } var addSecretResult = await _secureStorage.AddSecretAsync(org, containerRepo.Password); if (!addSecretResult.Successful) { return(addSecretResult.ToInvokeResult()); } containerRepo.SecurePasswordId = addSecretResult.Result; containerRepo.Password = null; await _repo.AddContainerRepoAsync(containerRepo); return(InvokeResult.Success); }
public LocationWizard(IPersister persister, IHost host, ContainerRepository<Wonderland> containers) { this.persister = persister; this.containers = containers; wizardSettings = new Settings("Wizard", string.Empty, "Wizard settings"); }
public ContentTemplateRepository(IPersister persister, ContainerRepository<TemplateContainer> container, IDefinitionManager definitions) { this.persister = persister; this.container = container; this.definitions = definitions; }
public ContentTemplateRepository(IPersister persister, DefinitionMap map, ContainerRepository<TemplateContainer> container) { this.persister = persister; this.map = map; this.container = container; }
public ContentTemplateRepository(IRepository<ContentItem> repository, DefinitionMap map, ContainerRepository<TemplateContainer> container) { this.repository = repository; this.map = map; this.container = container; }