public int InsertWorkItem(IWorkflowItem entity) { return(LockExecute <int>(() => { if (!string.IsNullOrEmpty(entity.Alias) && entity.Alias.IndexOf('.') > 0) { entity.Alias = entity.Alias.Substring(entity.Alias.LastIndexOf('.') + 1); } if (entity.ItemId >= 10000) { WorkItemsRead.Add(entity); return Dao.Get().Insert <WorkflowItemRead>(entity); } else { WorkflowEventManager.RaiseWorkItemEvent(EventStep.Before, ItemActionType.Insert, this, entity); WorkItems.Add(entity); int result = Dao.Get().Insert <WorkflowItem>(entity); if (result > 0) { WorkflowEventManager.RaiseWorkItemEvent(EventStep.After, ItemActionType.Insert, this, entity); } return result; } })); }
public int GetMaxReadTaskID() { if (WorkItemsRead.IsNullOrEmpty()) { return(10000); } return(WorkItemsRead.OrderByDescending(o => o.ItemId).First().ItemId); }
public int UpdateWorkItem(IWorkflowItem entity) { return(LockExecute <int>(() => { if (entity.ItemId >= 10000) { WorkItemsRead.Remove(entity); WorkItemsRead.Add(entity); return Dao.Get().Update <WorkflowItemRead>(entity); } else { WorkItems.Remove(entity); WorkItems.Add(entity); return Dao.Get().Update <WorkflowItem>(entity); } })); }
public int UpdateWorkItem(IList <IWorkflowItem> entities) { return(LockExecute <int>(() => { int effectCount = 0; foreach (var entity in entities) { if (entity.ItemId >= 10000) { WorkItemsRead.Remove(entity); WorkItemsRead.Add(entity); effectCount += Dao.Get().Update <WorkflowItemRead>(entity); } else { WorkItems.Remove(entity); WorkItems.Add(entity); effectCount += Dao.Get().Update <WorkflowItem>(entity); } } return effectCount; })); }