internal MessageAdapter CreateMessageAdapter(int count) { MessageAdapter adapter = new MessageAdapter(this, count) { Message = Consts.ProgressMessage, Formatter = new ApiResultFormatter() }; return(adapter); }
protected override void ProcessRecord() { base.ProcessRecord(); Validation(); var items = OptimizeImageItems; if (FilePath != null) { items = HelperFunctions.CreateOptimizeImageItems(FilePath).ToArray(); } MessageAdapter adapter = CreateMessageAdapter(items.Count()); Task.Factory.StartNew(() => { for (int x = 0; x < items.Count(); x++) { if (Wait) { var request = new OptimizeUploadWaitRequest( CreateDataStore(items[x])) { WebP = WebP, Lossy = Lossy, AutoOrient = AutoOrient, SamplingScheme = HelperFunctions.ConvertSamplingScheme(SamplingScheme) }; var task = Client.OptimizeWait(items[x].Path, request); adapter.WriteObject(task.Result); } else { var request = new OptimizeUploadRequest(new Uri(CallBackUrl), CreateDataStore(items[x])) { WebP = WebP, Lossy = Lossy, AutoOrient = AutoOrient, SamplingScheme = HelperFunctions.ConvertSamplingScheme(SamplingScheme) }; var task = Client.Optimize(items[x].Path, request); adapter.WriteObject(task.Result); } } adapter.Finished = true; }); adapter.Listen(); }
protected override void ProcessRecord() { base.ProcessRecord(); MessageAdapter adapter = CreateMessageAdapter(FilePath.Count()); Task.Factory.StartNew(() => { for (int x = 0; x < FilePath.Count(); x++) { if (Wait) { var request = new Kraken.Model.OptimizeUploadWaitRequest() { WebP = WebP, Lossy = Lossy, AutoOrient = AutoOrient, SamplingScheme = HelperFunctions.ConvertSamplingScheme(SamplingScheme) }; var task = Client.OptimizeWait(FilePath[x], request); adapter.WriteObject(task.Result); } else { var request = new Kraken.Model.OptimizeUploadRequest(new Uri(CallBackUrl)) { WebP = WebP, Lossy = Lossy, AutoOrient = AutoOrient, SamplingScheme = HelperFunctions.ConvertSamplingScheme(SamplingScheme) }; var task = Client.Optimize(FilePath[x], request); adapter.WriteObject(task.Result); } } adapter.Finished = true; }); adapter.Listen(); }