/// <summary> /// Operation that record values in a list. /// Beware that this operation keep a list of all data in memory /// </summary> /// <param name="observed">observed operation</param> /// <returns>resulting operation</returns> public static RecordOperation Record(this IObservableOperation observed) { var observer = new RecordOperation(); observed.Subscribe(observer); return(observer); }
/// <summary> /// Downloads the recording. /// </summary> /// <param name="recordingFileName">File name where recording is to be downloaded.</param> /// <param name="recordOperation">Record Operation.</param> /// <returns>The <see cref="Task"/>.</returns> private async Task DownloadRecording(string recordingFileName, RecordOperation recordOperation) { using (var httpClient = new HttpClient()) { var requestMessage = new HttpRequestMessage( HttpMethod.Get, new Uri(recordOperation.RecordingLocation)); requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", recordOperation.RecordingAccessToken); var httpResponse = await httpClient.SendAsync(requestMessage).ConfigureAwait(false); if (!httpResponse.IsSuccessStatusCode) { throw new ServiceException(new Error() { Message = "Unable to download the recording file.", }); } using (var stream = await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false)) { FileStream fileStream = null; var fileInfo = new FileInfo($"wwwroot/{recordingFileName}"); using (fileStream = new FileStream(fileInfo.FullName, FileMode.Create, FileAccess.Write, FileShare.None)) { await stream.CopyToAsync(fileStream).ConfigureAwait(false); } } } }
/// <summary> /// Execute the pipeline /// </summary> /// <param name="observed">observed operation</param> /// <returns>List of row resulting from the pipeline</returns> public static EtlFullResult ExecuteInThread(this IObservableOperation observed) { RecordOperation record = new RecordOperation(); observed.Subscribe(record); record.Result.Thread = new Thread(new ThreadStart(record.Trigger)); record.Result.Thread.Start(); return record.Result; }
/// <summary> /// Execute the pipeline /// </summary> /// <param name="observed">observed operation</param> /// <param name="throwOnError">Throw exception on error</param> /// <returns>List of row resulting from the pipeline</returns> public static EtlFullResult Execute(this IObservableOperation observed, bool throwOnError) { RecordOperation record = new RecordOperation(); observed.Subscribe(record); record.Start(); if (record.Result.CountExceptions > 0 && throwOnError) { throw new EtlResultException(record.Result, "Pipeline error", record.Result.Exceptions.FirstOrDefault()); } return record.Result; }
private void CheckOperation() { if (_recorded == null) { // To save memory, if the last operation is a record, we do not create a new one. if (Operation is RecordOperation) { _recorded = (RecordOperation)Operation; } else { _recorded = Operation.Record(); } _recorded.Start(); } }
private bool RecordOperationHandler(RecordOperation e) { switch (e) { case RecordOperation.Refresh: RefreshData(); break; case RecordOperation.New: ClearFields(); break; case RecordOperation.Save: string validation = AreValidEntries(); string currdate = ConnectionString.GetCurrentServerDate().ToString(); //bool isNew = textBox3.Text == "0" ? true : false; bool isNew = true; if (string.IsNullOrEmpty(validation)) { service.Save(textBox3.Text, comboBox1.Text, textBox2.Text, dateTimePicker1.Value, dateTimePicker2.Value, textBox1.Text, _user.Id.ToString(), currdate, _user.Id.ToString(), currdate, _activeAirport.Id, isNew); MessageBox.Show(string.Format(@"Equipment {0} was saved successfully", textBox2.Text), "Success"); RefreshData(); } else { MessageBox.Show(validation, "Error"); } break; default: break; } return(true); }
/// <summary> /// Creates a new <see cref="RecordOperationAttribute"/> /// </summary> /// <param name="modelType">The <see cref="Type"/> of modeled table.</param> /// <param name="operation">The <see cref="RecordOperation"/> the method represents.</param> public RecordOperationAttribute(Type modelType, RecordOperation operation) { ModelType = modelType; Operation = operation; }
public RecordEventRegistration(RecordOperation operation, Type eventType) { Operation = operation; EventType = eventType; }
/// <summary> /// Creates a new <see cref="RecordOperationAttribute"/> /// </summary> /// <param name="modelType">The <see cref="Type"/> of modeled table.</param> /// <param name="operation">The <see cref="RecordOperation"/> the method represents.</param> public RecordOperationAttribute(Type modelType, RecordOperation operation) { ModelType = modelType; Operation = operation; }