public async ValueTask <IActionResult> Start(StartProcessRequest req) { try { var r = await api.StartAsync(req); return(Ok(new StartProcessResponse(r, false))); } catch (ApiException e) { return(StatusCode(422, new ErrorResponse(e))); } }
public StartProcessResponse StartProcess(StartProcessRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var processInfo = FileUploadManager.StartProcess(request.StartInfo, request.DataStream); var response = new StartProcessResponse(); response.ProcessInfo = processInfo; return(response); }
public StartProcessResponse StartProcess(StartProcessRequest request) { return(Channel.StartProcess(request)); }
private void button1_Click(object sender, System.EventArgs e) { var svcClient = new ChrisBlogMsmqWorkflowContractIMsmqServiceClient(); var req = new StartProcessRequest() {MessageText = textBox1.Text}; svcClient.StartProcess(req); }
public void Start() { ThreadPool.QueueUserWorkItem((state) => { try { Info.State = ProcessState.CheckExists; OnPropertChanged(nameof(State)); byte[] hash; using (var hasher = MD5.Create()) using (var fileStream = FileInfo.OpenRead()) { hash = hasher.ComputeHash(fileStream); Info.FileInfo.Hash = hash; OnPropertChanged(nameof(FileHash)); OnPropertChanged(nameof(ElapsedTime)); FileExistsResponse fileExists; using (var client = new FileUploadClient()) { fileExists = client.FileExists(new FileExistsRequest() { FileInfo = Info.FileInfo, }); } if (fileExists.Result) { Info.Result = ProcessResult.Error; Info.State = ProcessState.Completed; Info.Message = "Файл был загружен раннее"; var reportBuilder = new StringBuilder(); reportBuilder.AppendLine("Файл был загружен раннее."); if (fileExists.InProcess == null) { reportBuilder.AppendLine("Информация о предыдущей загрузке не доступна"); } else { reportBuilder.AppendLine("Информация о предыдущей загрузке."); reportBuilder.AppendLine("Идентификатор: " + fileExists.InProcess.Id); reportBuilder.AppendLine("Файл: " + fileExists.InProcess.FileInfo.Name); reportBuilder.AppendLine("Состояние: " + fileExists.InProcess.State.ToString()); reportBuilder.AppendLine("Результат: " + fileExists.InProcess.Result.ToString()); reportBuilder.AppendLine("Сообщение: " + fileExists.InProcess.Message); reportBuilder.AppendLine("Время начала: " + fileExists.InProcess.StartTime.ToString()); Info.Report = Encoding.UTF8.GetBytes(reportBuilder.ToString()); } OnPropertChanged(nameof(Result)); OnPropertChanged(nameof(State)); OnPropertChanged(nameof(Message)); OnPropertChanged(nameof(ElapsedTime)); } else { Info.State = ProcessState.Transfer; OnPropertChanged(nameof(State)); OnPropertChanged(nameof(ElapsedTime)); var startProcessRequest = new StartProcessRequest(); fileStream.Position = 0L; startProcessRequest.DataStream = fileStream; startProcessRequest.StartInfo = Info; StartProcessResponse startProcessResponse; using (var client = new FileUploadClient()) { startProcessResponse = client.StartProcess(startProcessRequest); } Info = startProcessResponse.ProcessInfo; OnPropertChanged(nameof(Id)); OnPropertChanged(nameof(State)); OnPropertChanged(nameof(ElapsedTime)); } } } catch (Exception e) { //todo: WriteToLog Info.State = ProcessState.Completed; Info.Result = ProcessResult.Error; Info.Message = "Возникла ошибка: " + e.Message; Info.Report = Encoding.UTF8.GetBytes(e.ToString()); OnPropertChanged(nameof(Result)); OnPropertChanged(nameof(State)); OnPropertChanged(nameof(Message)); OnPropertChanged(nameof(ElapsedTime)); } }); }