Skip to content

Commit 6e2b24c

Browse files
author
jsonBackup
committed
Revert changes to ProcessStorage done in 269af5c
1 parent 8e2b80c commit 6e2b24c

File tree

2 files changed

+459
-451
lines changed

2 files changed

+459
-451
lines changed

src/Moryx.ControlSystem.ProcessEngine/Processes/ProcessStorage.cs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,15 @@ public void SaveProcess(ProcessData processData)
287287
entity = processRepository.GetByKey(processData.Id);
288288
}
289289
else
290-
{
291-
entity = processRepository.Create();
292-
entity.Id = processData.Id;
293-
entity.TypeName = processData.Process.GetType().Name;
294-
entity.State = (int)processData.State;
295-
entity.JobId = processData.Job.Id;
290+
{
291+
// Do not use Repository.Create here because id is self-generated.
292+
entity = uow.DbContext.Processes.Add(new ProcessEntity
293+
{
294+
Id = processData.Id,
295+
TypeName = processData.Process.GetType().Name,
296+
State = (int)processData.State,
297+
JobId = processData.Job.Id,
298+
}).Entity;
296299
}
297300
entity.State = (int)processData.State;
298301
entity.Rework = processData.Rework;
@@ -361,11 +364,15 @@ private void SaveActivity(IUnitOfWork<ProcessContext> uow, ActivityData activity
361364
}
362365
else
363366
{
364-
dbActivity = activityRepo.Create();
365-
dbActivity.Id = activity.Id;
366-
dbActivity.TaskId = activityData.Task.Id;
367-
dbActivity.ResourceId = activityData.Resource.Id;
368-
dbActivity.ProcessId = activityData.ProcessData.Id;
367+
// Do not use Repository.Create here because id is self-generated.
368+
dbActivity = new()
369+
{
370+
Id = activity.Id,
371+
TaskId = activityData.Task.Id,
372+
ResourceId = activityData.Resource.Id,
373+
ProcessId = activityData.ProcessData.Id,
374+
};
375+
uow.DbContext.Activities.Add(dbActivity);
369376
}
370377

371378
// UpdateList tracing info

0 commit comments

Comments
 (0)