public ActionResult DeleteConfirmed(int id) { WorkflowHistory workflowhistory = db.WorkflowHistories.Find(id); db.WorkflowHistories.Remove(workflowhistory); db.SaveChanges(); return(RedirectToAction("Index")); }
public WorkflowHistoryPath(WorkflowHistory history) { var folder = new TextFolder(history.Repository, history.ContentFolder); var content = folder.CreateQuery().WhereEquals("UUID", history.ContentUUID).FirstOrDefault(); ContentPath = new TextContentPath(content); PhysicalPath = SettingFile = Path.Combine(ContentPath.PhysicalPath, PATH_NAME, GetFile(history)); VirtualPath = UrlUtility.Combine(ContentPath.VirtualPath, PATH_NAME, GetFile(history)); }
// // GET: /WorkflowHistory/Delete/5 public ActionResult Delete(int id = 0) { WorkflowHistory workflowhistory = db.WorkflowHistories.Find(id); if (workflowhistory == null) { return(HttpNotFound()); } return(View(workflowhistory)); }
public ActionResult Edit(WorkflowHistory workflowhistory) { if (ModelState.IsValid) { db.Entry(workflowhistory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(workflowhistory)); }
public ActionResult Create(WorkflowHistory workflowhistory) { if (ModelState.IsValid) { db.WorkflowHistories.Add(workflowhistory); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(workflowhistory)); }
public override void AddHistory(Sitecore.Data.Items.Item item, string oldState, string newState, string text) { WorkflowHistory history = new WorkflowHistory(); history.Id = item.ID.Guid; history.Language = item.Language.ToString(); history.NewState = newState; history.Now = DateTime.Now; history.OldState = oldState; history.Text = text; history.User = Context.GetUserName(); history.Version = item.Version.ToInt32(); WorkflowHistories.Save(history); }
public WorkflowHistory GetHistory(string workflowID) { WorkflowHistory instance = null; Table table = Table.LoadTable(_client, Constants.HistoryTableName); var item = table.GetItemAsync(workflowID); item.Wait(); if (item.Result != null) { instance = new WorkflowHistory(); instance.Type = new WorkfowType(); List <KeyValuePair <string, DynamoDBEntry> > rows = item.Result.ToList <KeyValuePair <string, DynamoDBEntry> >(); foreach (KeyValuePair <string, DynamoDBEntry> row in rows) { if (row.Key == Constants.WorkflowType) { instance.Type.Name = row.Value.AsString(); } else if (row.Key == Constants.HistoryWorkflowId) { instance.WorkflowID = Guid.Parse(row.Value.AsString()); } else if (row.Key == Constants.BusinessLogic) { instance.Type.BusinessLogicJson = JObject.Parse(row.Value.AsDocument().ToJson()); } else { if (instance.HisoryObjects == null) { instance.HisoryObjects = new List <History>(); } JObject historyObject = JObject.Parse(row.Value.AsDocument().ToJson()); History history = historyObject.ToObject <History>(); instance.HisoryObjects.Add(history); } } } return(instance); }
public bool Reject(object userRefId, object processRefId, string refId, string comment = "") { //try //{ // NHibernateHelper.GetCurrentSession().BeginTransaction(); var actor = _actors.Table.FirstOrDefault(x => x.ActorRefId == userRefId.ToString()); var process = _processes.Table.FirstOrDefault(x => x.ProcessRefId == processRefId.ToString()); if (actor == null || process == null) return false; var hst = new WorkflowHistory { ActionDate = EngineContext.Current.Resolve<IDateTimeHelper>().ConvertToUserTime(DateTime.Now), ActorId = actor.Id, Approved = false, Passed=false, Comment = comment, LevelId = process.CurrentLevelId, ProcessId = process.Id }; _histories.Add(hst); var wkflow = process.Workflow; var onRejectAction = wkflow.OnRejection; switch (onRejectAction) { case Operator.OnRejection.EndWorkflow: process.Closed = true; break; case Operator.OnRejection.MoveToNextWorkflowLevel: { var wkflowLevel = GetNextLevel(processRefId, refId); if (wkflowLevel != null) { if (wkflowLevel.Id == process.CurrentLevelId) // process.Closed = true; else { process.CurrentLevelId = wkflowLevel.Id; } } else process.Closed = true; } break; case Operator.OnRejection.MoveToPreviousWorkflowLevel: { var wkflowLevel = GetPreviousLevel(processRefId, refId); if (wkflowLevel != null) { if (wkflowLevel.Id == process.CurrentLevelId) // process.Closed = true; else { process.CurrentLevelId = wkflowLevel.Id; } var hstory = _histories.Table .Where(x => x.Approved && x.ProcessId == process.Id && x.LevelId == wkflowLevel.Id); foreach (WorkflowHistory h in hstory) { h.Approved = false; _histories.Add(h); //_histories.Refresh(h); } } else process.Closed = true; } break; case Operator.OnRejection.StartWorkflowAgain: var levels = GetWorkflowLevels(process.WorkflowId,refId); var firstLevel = levels.OrderBy(x => x.LevelOrder).FirstOrDefault(); if (firstLevel != null) process.CurrentLevelId = firstLevel.Id; var hstories = _histories.Table.Where(x => x.Approved && x.ProcessId == process.Id); foreach (WorkflowHistory h in hstories) { h.Approved = false; _histories.Add(h); _histories.Refresh(h); } process.Closed = false; break; } _processes.Add(process); // NHibernateHelper.GetCurrentSession().Transaction.Commit(); //} //catch (Exception ex) //{ // NHibernateHelper.GetCurrentSession().Transaction.Rollback(); // throw new WorkflowGenericError("Unable to reject Process: " + ex.Message); //} return true; }
public bool Approve(object userRefId, object processRefId, string refId, string comment = "") { if (CanUserApprove(userRefId, processRefId)) { //try //{ var actor = _actors.Table.FirstOrDefault(x => x.ActorRefId == userRefId.ToString()); var process = _processes.Table.FirstOrDefault(x => x.ProcessRefId == processRefId.ToString()); _processes.Refresh(process); if (actor == null || process == null) return false; var hst = new WorkflowHistory { ActionDate = EngineContext.Current.Resolve<IDateTimeHelper>().ConvertToUserTime(DateTime.Now), ActorId = actor.Id, Approved = true, Passed = true, Comment = comment, LevelId = process.CurrentLevelId, ProcessId = process.Id }; _histories.Add(hst); //var expr = // _levelParameters.Table.FirstOrDefault(x => x.WorkflowLevelId == process.CurrentLevelId); //var _hst = // _histories.Table.Where(x => x.Approved && x.ProcessId == process.Id && x.LevelId == process.CurrentLevelId); //if (expr.MaximumApprovalRequired != _hst.Count()) return true; try { var wkflowLevel = GetNextLevel(processRefId,refId); if (wkflowLevel != null) { if (wkflowLevel.Id == process.CurrentLevelId) process.Closed = true; else { process.CurrentLevelId = wkflowLevel.Id; } } else process.Closed = true; } catch (Exception ex) { process.Closed = true; } _processes.Add(process); // } // NHibernateHelper.GetCurrentSession().Transaction.Commit(); //} //catch (Exception ex) //{ // NHibernateHelper.GetCurrentSession().Transaction.Rollback(); // throw new WorkflowGenericError("Error Approving Process:" + ex.Message); //} } else { throw new WorkflowGenericError("This User cannot approve this process."); } return true; }
private string GetFile(WorkflowHistory history) { return(history.Id + ".config"); }
public virtual void ProcessPendingWorkflowItem(Repository repository, string workflowName, string roleName, string pendingWorkflowItemId, string userName, bool passed, string comment) { var pendingItem = PendingWorkflowItemProvider.Get(new PendingWorkflowItem() { RoleName = roleName, Name = pendingWorkflowItemId, Repository = repository }); if (pendingItem != null) { var content = new TextFolder(repository, pendingItem.ContentFolder).CreateQuery().WhereEquals("UUID", pendingItem.ContentUUID).FirstOrDefault(); if (content != null) { var workflow = Get(repository, workflowName); bool finished = false; if (workflow != null) { WorkflowItem nextWorkflowItem = null; if (passed) { nextWorkflowItem = GetNextWorkflowItem(repository, workflow, pendingItem.WorkflowItemSequence + 1); if (nextWorkflowItem == null) { finished = true; } } else { nextWorkflowItem = GetNextWorkflowItem(repository, workflow, pendingItem.WorkflowItemSequence - 1); } if (nextWorkflowItem != null) { CreatePendingWorkflowItem(repository, content, userName, workflow, nextWorkflowItem, comment); } } if (finished) { var published = content.Published.HasValue ? content.Published.Value : false; if (passed && !published) { ServiceFactory.TextContentManager.Update(repository, new Schema(repository, content.SchemaName), content.UUID , new string[] { "Published" }, new object[] { true }, userName); } } WorkflowHistory history = new WorkflowHistory() { Id = WorkflowHistoryProvider.All(content).Count() + 1, Repository = repository, WorkflowName = pendingItem.WorkflowName, WorkflowItemSequence = pendingItem.WorkflowItemSequence, ItemDisplayName = pendingItem.ItemDisplayName, ContentFolder = pendingItem.ContentFolder, ContentUUID = pendingItem.ContentUUID, ContentSummary = content.GetSummary(), RoleName = pendingItem.RoleName, Passed = passed, ProcessingUtcDate = DateTime.UtcNow, ProcessingUser = userName, Finished = finished, Comment = comment }; WorkflowHistoryProvider.Add(history); } PendingWorkflowItemProvider.Remove(pendingItem); } }
public WorkflowHistory GetHistory(string workflowID) { WorkflowHistory instance = null; MySqlConnection connection = null; try { connection = new MySqlConnection(_connectionString); MySqlCommand command = new MySqlCommand("Administration_GetHistory", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@WorkflowID", workflowID); command.Parameters["@WorkflowID"].Direction = ParameterDirection.Input; connection.Open(); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { if (instance == null) { instance = new WorkflowHistory(); instance.WorkflowID = Guid.Parse(workflowID); instance.Type = new WorkfowType() { ID = reader.GetInt32("idWorkflowType"), Name = reader.GetString("Name"), BusinessLogicJson = JObject.Parse(reader.GetString("BusinessLogic")) }; instance.HisoryObjects = new List <History>(); } History history = new History() { Body = !reader.IsDBNull(0) ? JObject.Parse(reader.GetString(0)):null, CustomPropertiesJson = !reader.IsDBNull(1) ? JObject.Parse(reader.GetString(1)) : null, EventJson = !reader.IsDBNull(2) ? JObject.Parse(reader.GetString(2)) : null, Timestamp = reader.GetDateTime("Timestamp"), SplitID = reader.GetString("SplitID") }; instance.HisoryObjects.Add(history); } reader.Close(); } catch (Exception ex) { throw ex; } finally { connection.Close(); } return(instance); }
private string GetFile(WorkflowHistory history) { return history.Id + ".config"; }
public bool Post([FromBody] WorkflowHistory workflowHistory) { WorkflowHistory test = workflowHistory; return(false); }
/// <summary> /// Gets the <see cref="WorkflowHistory" /> for an application. /// </summary> /// <param name="sessionData">The session data.</param> /// <param name="applicationId">The application id.</param> /// <returns> /// The workflow history for an application. /// </returns> public WorkflowHistory GetWorkflowHistory(SessionData sessionData, string applicationId) { RetrieveApplicationResponse response = this.GetApplicationSecure(sessionData, applicationId); User user = this.userManager.GetUserById(sessionData.UserId); SystemEntitlementAccess entitlements = this.entitlementProvider.GetSystemEntitlements(sessionData.UserId); if (!entitlements.HasEntitlement(SystemEntitlementAccess.VIEW_APPLICATION_HISTORY)) { throw new SecurityException(ExceptionMessages.UnauthorisedAction); } UserFormAccessList authorisedForms = this.entitlementProvider.GetAuthorisedForms(new SecureSession(user), this.DataAccess.GetRoleList()); List<string> authorisedStates = authorisedForms[response.Application.FormId].ExplicitWorkflowStates; foreach (var implicitMembership in authorisedForms[response.Application.FormId].ImplicitWorkflowStates) { authorisedStates.AddRange(implicitMembership.Value); } WorkflowHistory history = this.DataAccess.GetWorkflowHistory(applicationId); WorkflowHistory authorisedHistory = new WorkflowHistory(history.Where(h => authorisedStates.Contains(h.ApplicationState))); WorkflowHistory deDupeHistory = new WorkflowHistory(); for (int i = 0; i < authorisedHistory.Count; i++) { if (i == 0) { deDupeHistory.Add(authorisedHistory[i]); } else if (authorisedHistory[i].ApplicationState != authorisedHistory[i - 1].ApplicationState) { deDupeHistory.Add(authorisedHistory[i]); } } return deDupeHistory; }