private VisionHandwritingModel GetVisionHandwritingModel(VisionHandwritingAttribute attribute) { if (attribute.ImageSource == Bindings.ImageSource.Client) { throw new ArgumentException($"ImageSource of Client does not support binding to vision models. Use Url or BlobStorage instead. "); } attribute.Validate(); var client = new VisionHandwritingClient(this, attribute, _loggerFactory); VisionHandwritingRequest request = new VisionHandwritingRequest(); if (attribute.ImageSource == ImageSource.BlobStorage) { var fileTask = StorageServices.GetFileBytes(attribute.BlobStoragePath, attribute.BlobStorageAccount); fileTask.Wait(); request.ImageBytes = fileTask.Result; } else { request.ImageUrl = attribute.ImageUrl; } var result = client.HandwritingAsync(request); result.Wait(); return(result.Result); }
public FileToManage(FileInfo info, string root) { GUID = Guid.NewGuid().ToString(); rootDirectory = root; fileName = info.Name; fullPath = info.FullName; fileSize = info.Length; service = FileStructure.algo.SortingHat(this); }
private VisionDomainRequest BuildRequest(VisionDomainAttribute attribute) { VisionDomainRequest request = new VisionDomainRequest(); if (attribute.ImageSource == ImageSource.BlobStorage) { var fileTask = StorageServices.GetFileBytes(attribute.BlobStoragePath, attribute.BlobStorageAccount); fileTask.Wait(); request.ImageBytes = fileTask.Result; } else { request.ImageUrl = attribute.ImageUrl; } return(request); }
public IStorage Get(StorageServices storageServices) { var services = _serviceProvider.GetServices <IStorage>(); switch (storageServices) { case StorageServices.SubPath: return(services.First(o => o.GetType() == typeof(StorageSubPathFilesystem))); case StorageServices.HostFilesystem: return(services.First(o => o.GetType() == typeof(StorageHostFullPathFilesystem))); case StorageServices.Thumbnail: return(services.First(o => o.GetType() == typeof(StorageThumbnailFilesystem))); default: throw new ArgumentOutOfRangeException(nameof(storageServices), storageServices, null); } }
/// <summary> /// Initializes a new instance of the <see cref="BotServices"/> class. /// </summary> /// <param name="botConfiguration">Parsed .bot configuration file.</param> public BotServices(BotConfiguration botConfiguration) { foreach (var service in botConfiguration.Services) { switch (service.Type) { case ServiceTypes.Endpoint: { var endpoint = (EndpointService)service; EndpointServices.Add(endpoint.Name, endpoint); break; } case ServiceTypes.BlobStorage: { // Create a Storage client. var storage = (BlobStorageService)service; if (string.IsNullOrWhiteSpace(storage.ConnectionString)) { throw new InvalidOperationException("The Storage ConnectionString ('connectionString') is required. Please update your '.bot' file."); } var storageAccount = CloudStorageAccount.Parse(storage.ConnectionString); StorageServices.Add(storage.Name, storageAccount); break; } case ServiceTypes.QnA: { // Create a QnA Maker that is initialized and suitable for passing // into the IBot-derived class (QnABot). var qna = (QnAMakerService)service; if (string.IsNullOrWhiteSpace(qna.KbId)) { throw new InvalidOperationException("The QnA KnowledgeBaseId ('kbId') is required. Please update your '.bot' file."); } if (string.IsNullOrWhiteSpace(qna.EndpointKey)) { throw new InvalidOperationException("The QnA EndpointKey ('endpointKey') is required. Please update your '.bot' file."); } if (string.IsNullOrWhiteSpace(qna.Hostname)) { throw new InvalidOperationException("The QnA Host ('hostname') is required. Please update your '.bot' file."); } var qnaEndpoint = new QnAMakerEndpoint() { KnowledgeBaseId = qna.KbId, EndpointKey = qna.EndpointKey, Host = qna.Hostname, }; var qnaMaker = new QnAMaker(qnaEndpoint); QnAServices.Add(qna.Name, qnaMaker); break; } case ServiceTypes.Luis: { var luis = (LuisService)service; if (string.IsNullOrWhiteSpace(luis.AppId)) { throw new InvalidOperationException("The LUIS AppId ('appId') is required. Please update your '.bot' file."); } if (string.IsNullOrWhiteSpace(luis.AuthoringKey)) { throw new InvalidOperationException("The LUIS AuthoringKey ('authoringKey') is required. Please update your '.bot' file."); } if (string.IsNullOrWhiteSpace(luis.Region)) { throw new InvalidOperationException("The LUIS Region ('region') is required. Please update your '.bot' file."); } var app = new LuisApplication(luis.AppId, luis.AuthoringKey, luis.GetEndpoint()); var recognizer = new LuisRecognizer(app); LuisServices.Add(luis.Name, recognizer); break; } case ServiceTypes.Generic: { var genericService = (GenericService)service; if (genericService.Name == "carwashuservicebus") { if (string.IsNullOrWhiteSpace(genericService.Configuration["connectionString"])) { throw new InvalidOperationException("The ServiceBus ConnectionString ('connectionString') is required. Please update your '.bot' file."); } var serviceBusConnection = new ServiceBusConnection(genericService.Configuration["connectionString"]); ServiceBusServices.Add(genericService.Name, serviceBusConnection); } break; } } } }
public static string MoveService(file f, StorageServices newService) { f.service = Enum.GetName(typeof(StorageServices), newService); return UploadFile(f); }
public StorageServiceListAdapter(Activity activity, StorageServices storageServices) : this(activity) { _storageServices = storageServices; }
public StorageServiceListAdapter(Activity activity) { _activity = activity; _storageServices = new StorageServices(); }