protected override JobHandle OnUpdate(JobHandle inputDeps) { var job = new ConvertJob() { m_charaMoves = m_group.GetComponentDataArray <CharaMove>(), m_positions = m_group.GetComponentDataArray <Position>(), }; inputDeps = job.Schedule(inputDeps); inputDeps.Complete(); return(inputDeps); }
public static Job ToJob(this ConvertJob job) { return(new Job { JobId = job.ConvertJobId, SessionId = job.SessionId, ExpireDateUtc = job.ExpireDateUtc?.UtcDateTime, InputFileId = job.InputFileId, OutputFileId = job.OutputFileId, ErrorType = (ConvertErrorType?)job.ErrorTypeId, Rating = job.Rating }); }
public void UpdateJob(Guid jobId, byte?rating) { ConvertJob job = this.context.ConvertJobs.Where(p => p.ConvertJobId == jobId).Single(); job.Rating = rating; this.context.ConvertJobs.Update(job); /*ConvertJob job = new ConvertJob * { * ConvertJobId = jobId * }; * * this.context.ConvertJobs.Attach(job); * * job.Rating = rating;*/ this.context.SaveChanges(); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { NativeArray <CharaLook> charaLooks = m_query.ToComponentDataArray <CharaLook>(Allocator.TempJob); NativeArray <CharaMuki> charaMukis = m_query.ToComponentDataArray <CharaMuki>(Allocator.TempJob); var job = new ConvertJob() { m_charaLooks = charaLooks, m_charaMukis = charaMukis, }; inputDeps = job.Schedule(inputDeps); inputDeps.Complete(); m_query.CopyFromComponentDataArray(job.m_charaLooks); charaLooks.Dispose(); charaMukis.Dispose(); return(inputDeps); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { NativeArray <CharaPos> charaPoses = m_query.ToComponentDataArray <CharaPos>(Allocator.TempJob); NativeArray <Translation> positions = m_query.ToComponentDataArray <Translation>(Allocator.TempJob); var job = new ConvertJob() { m_charaPoses = charaPoses, m_positions = positions, }; inputDeps = job.Schedule(inputDeps); inputDeps.Complete(); m_query.CopyFromComponentDataArray(job.m_positions); charaPoses.Dispose(); positions.Dispose(); return(inputDeps); }
public void CreateJob(ConvertJob job, bool createSessionIfNotExists) { if (createSessionIfNotExists && (job.SessionId.HasValue) && (!this.context.ConvertSessions.Where(p => p.SessionId == job.SessionId).Any())) { lock (CreateSessionLocker) { if (!this.context.ConvertSessions.Where(p => p.SessionId == job.SessionId).Any()) { this.context.ConvertSessions.Add(new ConvertSession { SessionId = job.SessionId.Value, CreateDateUtc = DateTime.UtcNow }); this.context.SaveChanges(); } } } this.context.ConvertJobs.Add(job); this.context.SaveChanges(); }
public bool Execute(Stream fileStream, string fileName, IDictionary customAttributes, Guid?sessionId = null) { byte[] inputFileBytes; inputFileBytes = new byte[fileStream.Length]; fileStream.Read(inputFileBytes, 0, (int)fileStream.Length); string extension = Path.GetExtension(fileName); List <CustomAttribute> attr = null; if (customAttributes != null) { attr = new List <CustomAttribute>(); foreach (var p in customAttributes.Keys) { attr.Add(new CustomAttribute { Name = p.ToString(), Value = customAttributes[p].ToString() }); } } var pdfConverter = new ServiceClient(new EndpointAddress(this.serviceOptions.Address)); ConvertResponseMessage result = null; try { result = pdfConverter.Convert(new ConvertMessage { FileBytes = inputFileBytes, FileExtension = extension, CustomAttributes = attr }); } catch (FileExtensionNullException) { this.validationDictionary.AddError("FileExtension", "File doesn't have extension"); } catch (FormatNotSupportedException) { this.validationDictionary.AddError("FileExtension", "File format doesn't supported"); } catch (EndpointNotFoundException) { this.validationDictionary.AddError("ApiService", "Service is unavailable. Please try again later."); } catch { this.validationDictionary.AddError("ApiService", "An unexpected error occurred. Please try again. If the problem persists, please contact the developer."); } ConvertJob job = null; if (result != null) { job = new ConvertJob { ConvertJobId = result.RequestId, SessionId = sessionId, ExpireDateUtc = DateTime.Now.ToUniversalTime() + TimeSpan.FromHours(1), InputFile = new BinaryFile { FileId = Guid.NewGuid(), CreateDateUtc = DateTime.UtcNow, FileName = fileName, FileSize = inputFileBytes.Length, Content = new BinaryFileContent { FileBytes = inputFileBytes } }, OutputFile = new BinaryFile { FileId = Guid.NewGuid(), CreateDateUtc = DateTime.UtcNow, FileName = Path.GetFileNameWithoutExtension(fileName) + ".pdf", FileSize = result.FileBytes.Length, Content = new BinaryFileContent { FileBytes = result.FileBytes } } }; cacheRepository.CreateJob(job, true); } return(result != null); }
public void Add(ConvertJob job) { _channel.Writer.WriteAsync(job); }