public static IDBInterface GetStorage(ProtokollerConfiguration config, StorageConfig cfg, Action <string> NewDataCallback) { if (cfg is SQLiteConfig) { return(new SQLLiteStorage(NewDataCallback)); } else if (cfg is CSVConfig) { return(new CSVStorage(NewDataCallback)); } else if (cfg is ExcelConfig) { return(new ExcelStorage(NewDataCallback)); } else if (cfg is PostgreSQLConfig) { return(new PostgreSQLStorage(NewDataCallback)); } else if (cfg is MySQLConfig) { return(new MySQLStorage(NewDataCallback)); } else if (cfg is Excel2007Config) { return(new Excel2007Storage(NewDataCallback)); } else if (cfg is MsSQLConfig) { return(new MsSQLStorage(NewDataCallback)); } else if (cfg is PLCConfig) { return(new PLCStorage(NewDataCallback)); } else if (cfg is MultiStorageConfig) { return(new MultiStorage.MultiStorage(config, cfg, NewDataCallback)); } return(null); }
public void DeleteTestNegative() { var server = new FakeHttpServer(Port, new[] { new FakeHttpServerResponse(404, "Not found") }); server.Start(); var config = new StorageConfig(endPoint: "http://localhost:" + Port, apiKey: "apiKey", environmentId: "envId"); using var storage = Storage.NewStorage(config); const string recordKey = "123"; var result = storage.DeleteAsync("country", recordKey).Result; Assert.False(result); server.Stop(); var exception = Assert.ThrowsAsync <StorageClientException>(() => storage.DeleteAsync("country", null)); Assert.AreEqual("Record key is null", exception.Message); exception = Assert.ThrowsAsync <StorageClientException>(() => storage.DeleteAsync(null, recordKey)); Assert.AreEqual("Country code is null", exception.Message); }
/// <summary> /// Returns OpcPaths with all paths created from a given OPC folder. /// This involves Loading of a PatchHierarchyInfo cache from disk. If the cache does not /// exist RootPatchName is read from xml. /// </summary> public static OpcPaths FullPathsFrom(string baseDirectory) { var paths = new OpcPaths(baseDirectory); var rootPatchName = string.Empty; //get RootPatchName from cache file or read from xml if (StorageConfig.FileExists(paths.CachedPatchHierarchyPath)) { var info = Load.As <PatchHierarchyInfo>(paths.CachedPatchHierarchyPath); rootPatchName = info.RootPatch; } else { rootPatchName = PatchHierarchyXML.From(baseDirectory).RootPatchName; } Requires.NotEmpty(rootPatchName, "RootPatchName could not be retrieved"); paths.SetRootPatchName(rootPatchName); return(paths); }
public void FindTestPositiveTest() { var server = new FakeHttpServer(Port, new[] { new FakeHttpServerResponse(200, FindResponse) }); server.Start(); var config = new StorageConfig(endPoint: "http://localhost:" + Port, apiKey: "apiKey", environmentId: "envId"); using var storage = Storage.NewStorage(config); const string recordKey = "456"; const string body = "body2"; var filter = new FindFilter() .KeyEq(NumberField.Version, 0); var foundedBatch = storage.FindAsync("country", filter).Result; Assert.NotNull(foundedBatch); Assert.AreEqual(1, foundedBatch.Count); Assert.AreEqual(1, foundedBatch.Records.Count); Assert.AreEqual(body, foundedBatch.Records[0].Body); Assert.AreEqual(recordKey, foundedBatch.Records[0].RecordKey); server.Stop(); }
private static LazyKdTreeSet BuildLazyKdTreeSet(IEnumerable <PatchTree> patches, OpcPaths opcPaths, int level, PositionsType posType, bool overrideExisting, IObserver <float> progressObserver, CancellationToken cancelToken = default(CancellationToken), float maxTriangleSize = float.PositiveInfinity) { var placeHolders = new List <LazyKdTreeSet.KdTreePlaceHolder>(); var progressInc = 1f / patches.Count(); foreach (var p in patches) { cancelToken.ThrowIfCancellationRequested(); var kdtreePath = opcPaths.GetKdTreePath(p.Id, level, posType); if (overrideExisting || !StorageConfig.FileExists(kdtreePath)) { BuildKdTreeForPatch(p.Id, level, p.Info, opcPaths, posType, saveTriangles: false, saveKdTree: true, maxTriangleSize: maxTriangleSize); } // Create place holders placeHolders.Add(new LazyKdTreeSet.KdTreePlaceHolder() { BoundingBox = p.Info.GetGlobalBoundingBox(posType), Affine = p.Info.GetLocal2Global(posType), Path = opcPaths.GetKdTreePath(p.Id, level, posType), ObjectSetPath = p.GetPositionPath(posType) }); if (progressObserver != null) { progressObserver.OnNext(progressInc); } } if (progressObserver != null) { progressObserver.OnCompleted(); } return(new LazyKdTreeSet(placeHolders)); }
public void BatchWriteTestNegativeUnexpected() { const string recordKey1 = "123"; const string responseBody1 = "unexpected"; const int responseStatus = 405; var server = new FakeHttpServer(Port, new[] { new FakeHttpServerResponse(responseStatus, responseBody1) }); server.Start(); var config = new StorageConfig(endPoint: "http://localhost:" + Port, apiKey: "apiKey", environmentId: "envId"); using var storage = Storage.NewStorage(config); var exception = Assert.ThrowsAsync <StorageServerException>(() => storage.BatchWriteAsync("country", new List <Record> { new Record(recordKey1) })); Assert.IsTrue(exception.Message.Contains( "Unexpected response: StatusCode: 405, ReasonPhrase: 'Method Not Allowed", StringComparison.InvariantCulture)); server.Stop(); }
//private static SlimDX.Direct3D11.Device d = new SlimDX.Direct3D11.Device(SlimDX.Direct3D11.DriverType.Reference, SlimDX.Direct3D11.DeviceCreationFlags.None, new SlimDX.Direct3D11.FeatureLevel[] { SlimDX.Direct3D11.FeatureLevel.Level_9_1 }); /// <summary> /// Converts .tif to .dds files in an opc directory for straight to gpu uploads of textures. /// </summary> public static int ConvertTiffsToDDSs(OpcPaths opcPaths, bool overrideExisting = false, IObserver <float> progress = null, CancellationToken cancelToken = default(CancellationToken)) { var tiffs = StorageConfig.GetDirectories(opcPaths.ImagesSubDir) .SelectMany(x => StorageConfig.GetFiles(x)) .Where(x => Path.GetExtension(x) == ".tif"); if (tiffs.IsEmptyOrNull()) { if (progress != null) { progress.OnNext(1f); progress.OnCompleted(); } return(0); } var inc = 1f / tiffs.Count(); foreach (var f in tiffs) { cancelToken.ThrowIfCancellationRequested(); // ConvertTiffToDDS2(f, overrideExisting); // ConvertTiffToDDS(f, overrideExisting); ConvertTiffToDDS3(f, overrideExisting); if (progress != null) { progress.OnNext(inc); } } if (progress != null) { progress.OnCompleted(); } return(tiffs.Count()); }
public async Task GetAttachmentTest() { var server = new FakeHttpServer(Port, new[] { new FakeHttpServerResponse(200, FileId, new Dictionary<string, string> { ["Content-disposition"] = "attachment; filename*=UTF-8''file.txt" }), new FakeHttpServerResponse(200, FileId), new FakeHttpServerResponse(404, "Not found") }); server.Start(); var config = new StorageConfig(endPoint: "http://localhost:" + Port, apiKey: "apiKey", environmentId: "envId"); using var storage = Storage.NewStorage(config); var attachedFile = await storage.GetAttachmentFileAsync(Country, RecordKey, FileId) .ConfigureAwait(false); Assert.IsNotNull(attachedFile); Assert.AreEqual(FileName, attachedFile.Filename); using var reader = new StreamReader(attachedFile.FileContent); var stringFromFile = await reader.ReadToEndAsync().ConfigureAwait(false); Assert.AreEqual(FileId, stringFromFile); attachedFile = await storage.GetAttachmentFileAsync(Country, RecordKey, FileId) .ConfigureAwait(false); Assert.IsNotNull(attachedFile); Assert.IsNull(attachedFile.Filename); using var reader2 = new StreamReader(attachedFile.FileContent); stringFromFile = await reader2.ReadToEndAsync().ConfigureAwait(false); Assert.AreEqual(FileId, stringFromFile); attachedFile = await storage.GetAttachmentFileAsync(Country, RecordKey, FileId) .ConfigureAwait(false); Assert.IsNull(attachedFile); server.Stop(); }
/// <summary> /// ストレージ設定をプロパティに設定する /// </summary> /// <param name="configs">設定リスト</param> /// <returns>正常系はtrueを返し、設定リストがnullの場合にはfalseを返す</returns> public bool SetStorageConfigs(List <DtStorageConfig> configs) { if (configs == null) { return(false); } // 設定時に過去のデータはクリアしておく Storage = new Dictionary <string, StorageConfig>(); foreach (DtStorageConfig config in configs) { StorageConfig c = new StorageConfig(); c.Url = config.Url ?? string.Empty; c.Sas = config.Sas ?? string.Empty; // DBのユニーク制約により、Name(キー)が同一のレコードが複数存在することはないため、 // キー重複チェックは行わない Storage.Add(config.Name, c); } return(true); }
public static void RegisterStorageService(this ContainerBuilder builder, StorageConfig storageConfig) { builder.RegisterInstance(storageConfig).AsSelf().SingleInstance(); if (storageConfig.Type == StorageType.AmazonS3Storage) { builder .Register(x => new AmazonS3StorageService(storageConfig)) .As <IStorageService>() .InstancePerLifetimeScope(); } else { builder .Register(x => new AmazonFsxStorageService(storageConfig)) .As <IStorageService>() .InstancePerLifetimeScope(); Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), storageConfig.AmazonFsxConfig.SharedFolderNetworkPath, storageConfig.Container)); Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), storageConfig.AmazonFsxConfig.SharedFolderNetworkPath, storageConfig.TrashContainer)); } }
public override void Connect_To_Database(StorageConfig config) { myConfig = config as CSVConfig; if (myConfig == null) { throw new Exception("Database Config is NULL"); } if (!string.IsNullOrEmpty(myConfig.NetworkUserName)) { try { networkShare = new NetworkShare(Path.GetDirectoryName(myConfig.Textfile), myConfig.NetworkUserName, myConfig.NetworkPassword); } catch (Exception ex) { if (!RaiseThreadExceptionOccured(this, ex)) { Logging.LogText("Exception: ", ex, Logging.LogLevel.Error); } } } }
public static void ConvertTiffToDDS(string tiffPath, bool overrideExisting = false) { string ddsPath = Path.ChangeExtension(tiffPath, ".dds"); if (overrideExisting || !StorageConfig.FileExists(ddsPath)) { var bitmap = new Bitmap(tiffPath); // Konvertierung var target = SlimDx9TextureConvertible.CreateFile( new SlimDx9TextureConvertible.SlimDx9TextureParameters() { AardvarkFormat = Patch.GetTextureFormatFromPixelFormat(bitmap.PixelFormat), AardvarkUsage = AardvarkUsage.None, FileName = ddsPath, Pool = Pool.Scratch, MipMapLevels = 0 }); var bitmapConvertible = new Convertible("BitmapMemory", bitmap); bitmapConvertible.ConvertInto(target); } }
public async Task GetAttachmentMetaTest() { var server = new FakeHttpServer(Port, new[] { new FakeHttpServerResponse(200, ResponseMeta), new FakeHttpServerResponse(404, "Not found") }); server.Start(); var config = new StorageConfig(endPoint: "http://localhost:" + Port, apiKey: "apiKey", environmentId: "envId"); using var storage = Storage.NewStorage(config); var meta = await storage.GetAttachmentMetaAsync(Country, RecordKey, FileId) .ConfigureAwait(false); Assert.AreEqual(FileName, meta.Filename); Assert.AreEqual(FileId, meta.FileId); Assert.AreEqual(44, meta.Size); Assert.AreEqual(MimeType, meta.MimeType); Assert.AreEqual("abc123", meta.Hash); Assert.AreEqual("https://localhost/v2/storage/records/us/123", meta.DownloadLink); Assert.IsTrue(DateTimeOffset.Now > meta.CreatedAt); Assert.IsTrue(DateTimeOffset.Now > meta.UpdatedAt); meta = await storage.GetAttachmentMetaAsync(Country, RecordKey, FileId).ConfigureAwait(false); Assert.IsNull(meta); server.Stop(); }
public async Task <List <QuadroPersonalizado> > ApagarStorageNaoUtilizado(StorageConfig config) { using (RepositorySession dalSession = new RepositorySession(Runtime.JWInstance)) { IUnitOfWork unitOfWork = dalSession.UnitOfWork; try { var ret = _repositoryQuadro.ObterQuadrosPersonalizadosExpiradosAtivosStorage(ref unitOfWork); foreach (var item in ret) { await _storageAzure.DeleteBlobData(item.Url, config); _repositoryQuadro.AlterarStatusStorageQuadroPersonalizado(ref unitOfWork, item.Url); } return(ret); } catch { throw; } } }
/// <summary> /// NOT TESTED /// </summary> private static KdTreeSet BuildConcreteKdTreeSet(IEnumerable <PatchTree> patches, OpcPaths opcPaths, int level, PositionsType posType, bool overrideExisting, IObserver <float> progressObserver, CancellationToken cancelToken = default(CancellationToken), float maxTriangleSize = float.PositiveInfinity) { var kdTrees = new List <ConcreteKdIntersectionTree>(); var progressInc = 1f / patches.Count(); foreach (var p in patches) { cancelToken.ThrowIfCancellationRequested(); KdIntersectionTree tree; var kdtreePath = opcPaths.GetKdTreePath(p.Id, level, posType); if (overrideExisting || !StorageConfig.FileExists(kdtreePath)) { tree = BuildKdTreeForPatch(p.Id, level, p.Info, opcPaths, posType, saveTriangles: true, saveKdTree: false, maxTriangleSize: maxTriangleSize); } else { tree = Load.As <KdIntersectionTree>(kdtreePath); } kdTrees.Add(tree.ToConcreteKdIntersectionTree()); if (progressObserver != null) { progressObserver.OnNext(progressInc); } } if (progressObserver != null) { progressObserver.OnCompleted(); } return(new KdTreeSet(kdTrees)); }
public void GetAttachmentMetaNegativeTest() { var config = new StorageConfig(endPoint: "http://localhost:" + Port, apiKey: "apiKey", environmentId: "envId"); using var storage = Storage.NewStorage(config); var exception = Assert.ThrowsAsync<StorageClientException>(() => storage.GetAttachmentMetaAsync(Country, null, FileId)); Assert.AreEqual("Record key is null", exception.Message); exception = Assert.ThrowsAsync<StorageClientException>(() => storage.GetAttachmentMetaAsync(null, RecordKey, FileId)); Assert.AreEqual("Country code is null", exception.Message); exception = Assert.ThrowsAsync<StorageClientException>(() => storage.GetAttachmentMetaAsync(Country, RecordKey, null)); Assert.AreEqual("File ID is null", exception.Message); var server = new FakeHttpServer(Port, new[] { new FakeHttpServerResponse(405, "Error"), new FakeHttpServerResponse(200, "StringNotJson:{[") }); server.Start(); var serverException = Assert.ThrowsAsync<StorageServerException>(() => storage.GetAttachmentMetaAsync(Country, RecordKey, FileId)); Assert.IsTrue(serverException.Message.Contains( "Unexpected response: StatusCode: 405, ReasonPhrase: 'Method Not Allowed'", StringComparison.InvariantCulture)); serverException = Assert.ThrowsAsync<StorageServerException>(() => storage.GetAttachmentMetaAsync(Country, RecordKey, FileId)); Assert.AreEqual( "Unexpected error " + "[http://localhost:8087/v2/storage/records/us/3e758b0dc7d6a52f2a314fa996bf5513be8bc5d276935ce2628c67151abc6da3/attachments/456/meta]", serverException.Message); Assert.IsNotNull(serverException.InnerException); server.Stop(); }
/// <summary> /// Creates path helper from a given OPC folder /// </summary> public OpcPaths(string basePath) { ImagePyramidPaths = new List <string>(); BasePath = basePath; PatchesSubDir = Path.Combine(basePath, Identifiers.PatchesSubDir); ImagesSubDir = Path.Combine(basePath, Identifiers.ImagesSubDir); CachedPatchHierarchyPath = Path.Combine(PatchesSubDir, Identifiers.CacheFileName); PatchHierarchyPath = Path.Combine(PatchesSubDir, Identifiers.PatchHierarchyFileName); ProfileLutPath = Path.Combine(PatchesSubDir, Identifiers.ProfilLutFileName); ShortName = Path.Combine(Directory.GetParent(BasePath).Name, Path.GetFileName(basePath)); var subDirs = StorageConfig.GetDirectories(ImagesSubDir); foreach (var sd in subDirs) { var dir = Path.Combine(ImagesSubDir, sd); ImagePyramidPaths.Add(Path.Combine(dir, Identifiers.ImagePyramidFileName)); } }
/// <summary> /// Loads PatchHierarchyInfo from cache file or xml, if cache doesn't exist. /// </summary> public static PatchHierarchyInfo BuildOrLoadCache(OpcPaths paths) { PatchHierarchyInfo patchHierarchyInfo = null; if (StorageConfig.FileExists(paths.CachedPatchHierarchyPath)) { patchHierarchyInfo = FromCacheFile(paths.CachedPatchHierarchyPath); } if (patchHierarchyInfo == null) { Report.BeginTimed("PatchHierarchyInfo: Loading XML for " + paths.ShortName); patchHierarchyInfo = FromXmlFile(paths); Report.End(); } if (patchHierarchyInfo == null) { Report.Error("PatchHierarchyInfo: Loading cache and XML failed for OPC " + paths.ShortName); return(null); } return(patchHierarchyInfo); }
public async Task CreateInspectOperationAsync() { // Snippet: CreateInspectOperationAsync(InspectConfig,StorageConfig,OutputStorageConfig,CallSettings) // Additional: CreateInspectOperationAsync(InspectConfig,StorageConfig,OutputStorageConfig,CancellationToken) // Create client DlpServiceClient dlpServiceClient = await DlpServiceClient.CreateAsync(); // Initialize request argument(s) InspectConfig inspectConfig = new InspectConfig(); StorageConfig storageConfig = new StorageConfig(); OutputStorageConfig outputConfig = new OutputStorageConfig(); // Make the request Operation <InspectOperationResult, InspectOperationMetadata> response = await dlpServiceClient.CreateInspectOperationAsync(inspectConfig, storageConfig, outputConfig); // Poll until the returned long-running operation is complete Operation <InspectOperationResult, InspectOperationMetadata> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result InspectOperationResult result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <InspectOperationResult, InspectOperationMetadata> retrievedResponse = await dlpServiceClient.PollOnceCreateInspectOperationAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result InspectOperationResult retrievedResult = retrievedResponse.Result; } // End snippet }
public void NonHashingSearchKeysNegativeTest() { var config = new StorageConfig(endPoint: "http://localhost:" + Port, environmentId: "envId", clientId: "clientId", clientSecret: "clientSecret", hashSearchKeys: false); using var storage = Storage.NewStorage(config); Assert.IsNotNull(storage); var builder = new StringBuilder(); for (var i = 0; i < 100; i++) { builder.Append("very_long_key_more_than_256_symbols_!"); } var record = new Record("recordKey", key1: builder.ToString()); var exception = Assert.ThrowsAsync <StorageClientException>(async() => await storage.WriteAsync("us", record).ConfigureAwait(false)); Assert.AreEqual("Key1-Key20 length can't be more than 256 chars with option 'hashSearchKeys' = false", exception.Message); }
private Storage(StorageConfig config) { s_helper.Check <StorageClientException>(config == null, Messages.Storage.s_errNullConfig); _httpClient = new HttpClient(); _httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(VersionInfo.ProductName, VersionInfo.ProductVersion)); #pragma warning disable CA1062 _httpClient.Timeout = new TimeSpan(0, 0, config.HttpTimeout); #pragma warning restore CA1062 ITokenClient tokenClient = null; if (!string.IsNullOrEmpty(config.ApiKey)) { tokenClient = new ApiKeyTokenClient(config.ApiKey); } if (!(string.IsNullOrEmpty(config.ClientId) || string.IsNullOrEmpty(config.ClientSecret))) { tokenClient = new OAuthTokenClient(config.DefaultAuthEndpoint, config.AuthEndpoints, config.EnvironmentId, config.ClientId, config.ClientSecret, _httpClient); } s_helper.Check <StorageClientException>(tokenClient == null, Messages.Storage.s_errNullCredentials); _cryptoProvider = config.CryptoProvider; if (config.CryptoProvider == null) { _cryptoProvider = new CryptoProvider(); } _cryptoProvider.ValidateCustomCiphers(config.SecretKeyAccessor?.Invoke()); _hashUtils = new HashUtils(config.EnvironmentId, config.NormalizeKeys, Encoding.UTF8); _transformer = new DtoTransformer(_cryptoProvider, _hashUtils, config.HashSearchKeys, config.SecretKeyAccessor); _dao = HttpDao.NewDao(config.EnvironmentId, tokenClient, _httpClient, config.EndPoint, config.EndpointMask, config.CountriesEndPoint); }
public void When_VCAP_SERVICES_Is_Passed_Then_Get_Storage_Path_Return_Valid_Path_Test() { var storageConfig = new StorageConfig(Resources.VCAP_SERVICES); Assert.AreEqual("/hana/shared/DEV/xs/bin/../controller_data/fss/929b20ea-bd76-42ad-8dc7-b97ba85c9bef", storageConfig.GetStoragePath()); }
public async Task <QuadroPersonalizado> NovoQuadroPersonalizado(QuadroPersonalizado model, StorageConfig config, IFormFile file) { using (RepositorySession dalSession = new RepositorySession(Runtime.JWInstance)) { IUnitOfWork unitOfWork = dalSession.UnitOfWork; JsonImage url = new JsonImage(); unitOfWork.Begin(); try { if (model.Valid) { if (file != null && _storageAzure.IsImage(file.FileName.Trim('\"'))) { if (file.Length > 0) { using (var stream = file.OpenReadStream()) url = await _storageAzure.Upload(stream, Guid.NewGuid() + "_" + file.FileName, config); } else { model.AddNotification(nameof(JsonImage.Url), "Arquivo Vazio"); } } else { model.AddNotification(nameof(JsonImage.Url), "Arquivo não suportado"); } model.Url = url.Url; if (model.Valid) { _repositoryQuadro.InserirQuadroPersonalizado(ref unitOfWork, model); unitOfWork.Commit(); } else if (model.Url != null) { await _storageAzure.DeleteBlobData(model.Url, config); } } } catch { unitOfWork.Rollback(); await _storageAzure.DeleteBlobData(model.Url, config); throw; } return(model); } }
public async Task <QuadroPersonalizado> ApagarQuadroPersonalizado(int congregacaoId, string url, StorageConfig config) { using (RepositorySession dalSession = new RepositorySession(Runtime.JWInstance)) { IUnitOfWork unitOfWork = dalSession.UnitOfWork; unitOfWork.Begin(); try { var model = _repositoryQuadro.ObterQuadroPersonalizado(ref unitOfWork, congregacaoId, url); if (model == null) { model = new QuadroPersonalizado(); model.AddNotification(nameof(JsonImage.Url), "Quadro não encontrado"); unitOfWork.Rollback(); return(model); } await _storageAzure.DeleteBlobData(model.Url, config); _repositoryQuadro.ApagarQuadroPersonalizado(ref unitOfWork, url, congregacaoId); unitOfWork.Commit(); return(model); } catch { throw; } } }
public SampleAzureTableMainRepositoryContext(StorageConfig config, IBestEffortUnitOfWork unitOfWork, IAzureTableStoreFactory storeFactory) : base(config, unitOfWork, storeFactory) { }
public StorageHandler(IStorageServiceClientFactory storageServiceClientFactory, StorageConfig storageConfig) { _storageServiceClientFactory = storageServiceClientFactory; _storageConfig = storageConfig; }
protected override void Render(HtmlTextWriter writer) { string name; string storageConfigName = null; if (!IsDesignTime && UploadModule.IsEnabled) { // Generate a special name recognized by the UploadHttpModule name = FormContext.Current.GenerateFileID(this.UniqueID); storageConfigName = FormContext.Current.GenerateStorageConfigID(this.UniqueID); this.Page.RegisterStartupScript("NeatUploadInputFile-" + this.UniqueID, @" <script type='text/javascript' language='javascript'> <!-- NeatUploadInputFileCreate('" + this.ClientID + @"','" + FormContext.Current.PostBackID + @"'); // --> </script>"); } else { name = this.UniqueID; if (!IsDesignTime) { storageConfigName = FormContext.Current.GenerateStorageConfigID(this.UniqueID); } } // Store the StorageConfig in a hidden form field with a related name if (StorageConfig != null && StorageConfig.Count > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Type, "hidden"); writer.AddAttribute(HtmlTextWriterAttribute.Name, storageConfigName); writer.AddAttribute(HtmlTextWriterAttribute.Value, StorageConfig.Protect()); writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); } writer.AddAttribute(HtmlTextWriterAttribute.Type, "file"); writer.AddAttribute(HtmlTextWriterAttribute.Name, name); base.AddAttributesToRender(writer); writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); //commented out 2010-05-30 by Joe Audette with Dean's approval since he is no longer maintaining the project //if (UploadModule.IsEnabled) //{ // // The constant strings below are broken apart so that you couldn't just search for the text and // // remove it. To find this code, you probably had to understand enough about custom web controls // // to know where to look. People who can't find this code are generally less experienced, harder // // to support, and less likely to submit patches. So they contribute in another way when they // // use NeatUpload - they contribute by advertising it. If they don't want to do that, they can // // always have someone more capable find and remove the code for them (probably for a fee). // // For more information, see the "Branding, Licensing, and the Trademark" section in // // docs/Manual.html. // writer.AddStyleAttribute(HtmlTextWriterStyle.FontSize, "smal" + "ler"); // writer.RenderBeginTag(HtmlTextWriterTag.Span); // writer.Write(" (Po" + "wer" +"ed&nb" + "sp;by&nb" + "sp;"); // writer.AddAttribute(HtmlTextWriterAttribute.Target, "_bla" + "nk"); // writer.AddAttribute(HtmlTextWriterAttribute.Href, // "htt" +"p://ww" + "w.bre"+ "ttle." + "com/" + "neat" + "upload"); // writer.RenderBeginTag(HtmlTextWriterTag.A); // writer.Write("Neat" + "Upload"); // writer.RenderEndTag(); // a // writer.Write(")"); // writer.RenderEndTag(); // span //} }
public ImageController(IOptions <StorageConfig> config) { _storageConfig = config.Value; }
public IOrderedQueryable <T> CreateQuery <T>(IDocumentClient client, StorageConfig cfg) { var collectionLink = $"/dbs/{cfg.DocumentDbDatabase}/colls/{cfg.DocumentDbCollection}"; return(client.CreateDocumentQuery <T>(collectionLink)); }
public async Task DeleteAsync(IDocumentClient client, StorageConfig cfg, string docId) { var collectionLink = $"/dbs/{cfg.DocumentDbDatabase}/colls/{cfg.DocumentDbCollection}"; await client.DeleteDocumentAsync($"{collectionLink}/docs/{docId}"); }