public void ShowHome(String preview, Int32 processDefinitionId, Int32 flowId) { if (log.IsDebugEnabled) { log.Debug("ShowHome preview:" + preview + " processDefinitionId:" + processDefinitionId + " flowId:" + flowId); } IDefinitionSessionLocal definitionComponent = null; IExecutionSessionLocal executionComponent = null; try { definitionComponent = ServiceLocator.Instance.GetService(typeof(IDefinitionSessionLocal)) as IDefinitionSessionLocal; executionComponent = ServiceLocator.Instance.GetService(typeof(IExecutionSessionLocal)) as IExecutionSessionLocal; // IList taskList = executionComponent.GetTaskList(new Relations(new System.String[]{"processInstance.processDefinition"})); IList taskList = executionComponent.GetTaskList(); IList processDefinitions = definitionComponent.GetProcessDefinitions(); // Collect data for the preview if (preview != null) { if (preview.Equals("process")) { if (processDefinitionId == 0) { ArrayList errors = new ArrayList(); errors.Add("when parameter 'preview' is equal to 'process', a valid parameter 'processDefinitionId' should be provided as well,"); Context.Flash["errormessages"] = errors; } IProcessDefinition processDefinition = null; // Get the processDefinition processDefinition = definitionComponent.GetProcessDefinition(processDefinitionId); Context.Flash["processDefinition"] = processDefinition; } else if (preview.Equals("activity")) { if (flowId == 0) { ArrayList errors = new ArrayList(); errors.Add("when parameter 'preview' is equal to 'activity', a valid parameter 'flowId' should be provided as well,"); Context.Flash["errormessages"] = errors; } // IFlow flow = executionComponent.GetFlow(flowId, new Relations(new System.String[]{"processInstance.processDefinition"})); IFlow flow = executionComponent.GetFlow(flowId); Context.Flash["activity"] = flow.Node; AddImageCoordinates((IState)flow.Node); Context.Flash["processDefinition"] = flow.ProcessInstance.ProcessDefinition; } } Context.Flash["taskList"] = taskList; Context.Flash["processDefinitions"] = processDefinitions; Context.Flash["preview"] = preview; } finally { ServiceLocator.Instance.Release(executionComponent); ServiceLocator.Instance.Release(definitionComponent); } }
public void DeployProcess() { IDefinitionSessionLocal definitionComponent = null; try { definitionComponent = ServiceLocator.Instance.GetService(typeof(IDefinitionSessionLocal)) as IDefinitionSessionLocal; IDictionary files = Context.Request.Files; IEnumerator enumerator = Context.Request.Files.Keys.GetEnumerator(); while (enumerator.MoveNext()) { log.Debug("key " + enumerator.Current); log.Debug("value " + files[enumerator.Current]); HttpPostedFile postfile = (HttpPostedFile)files[enumerator.Current]; log.Debug("name: " + postfile.FileName); byte[] b = new byte[postfile.InputStream.Length]; postfile.InputStream.Read(b, 0, (int)postfile.InputStream.Length); definitionComponent.DeployProcessArchive(b); } } catch (NpdlException npdlEx) { IEnumerator iter = npdlEx.ErrorMsgs.GetEnumerator(); while (iter.MoveNext()) { AddMessage(iter.Current.ToString()); } } finally { ServiceLocator.Instance.Release(definitionComponent); } Redirect("developer", "showhome"); }
public void ProcessImage(Int64 processDefinitionId) { IDefinitionSessionLocal definitionComponent = null; try { definitionComponent = ServiceLocator.Instance.GetService(typeof(IDefinitionSessionLocal)) as IDefinitionSessionLocal; Context.Response.ContentType = "image/gif"; if (log.IsDebugEnabled) { log.Debug("show ProcessImage processDefinitionId:" + processDefinitionId); } IProcessDefinition processDefinition = definitionComponent.GetProcessDefinition(processDefinitionId); byte[] gifContents = processDefinition.Image; if (gifContents != null) { Context.Response.OutputStream.Write(gifContents, 0, gifContents.Length); } } finally { ServiceLocator.Instance.Release(definitionComponent); } }
public void StartProcessInstance(long processDefinitionId) { if (log.IsDebugEnabled) { log.Debug("StartProcessInstance processDefinitionId:" + processDefinitionId); } IExecutionSessionLocal executionComponent = null; IDefinitionSessionLocal definitionComponent = null; try { executionComponent = ServiceLocator.Instance.GetService(typeof(IExecutionSessionLocal)) as IExecutionSessionLocal; definitionComponent = ServiceLocator.Instance.GetService(typeof(IDefinitionSessionLocal)) as IDefinitionSessionLocal; IProcessDefinition processDefinition = definitionComponent.GetProcessDefinition(processDefinitionId); Context.Flash["activity"] = processDefinition.StartState; Context.Flash["processDefinition"] = processDefinition; Context.Flash["preview"] = "activity"; AddImageCoordinates(processDefinition.StartState); //create Form IActivityForm activityForm = executionComponent.GetStartForm(processDefinitionId); AddFormData(activityForm); RenderView("activityForm"); } finally { ServiceLocator.Instance.Release(executionComponent); ServiceLocator.Instance.Release(definitionComponent); } }
// // GET: /User/ public ActionResult ShowHome() { IPrincipal userAdapter = new PrincipalUserAdapter("ae"); HttpContext.User = userAdapter; Thread.CurrentPrincipal = userAdapter; IDefinitionSessionLocal definitionComponent = null; IExecutionSessionLocal executionComponent = null; try { definitionComponent = ServiceLocator.Instance.GetService(typeof(IDefinitionSessionLocal)) as IDefinitionSessionLocal; executionComponent = ServiceLocator.Instance.GetService(typeof(IExecutionSessionLocal)) as IExecutionSessionLocal; IList taskList = executionComponent.GetTaskList(); IList processDefinitions = definitionComponent.GetProcessDefinitions(); ViewData["taskList"] = taskList; ViewData["processDefinitions"] = processDefinitions; ViewData["preview"] = null; //Context.Flash["taskList"] = taskList; //Context.Flash["processDefinitions"] = processDefinitions; //Context.Flash["preview"] = preview; } finally { ServiceLocator.Instance.Release(executionComponent); ServiceLocator.Instance.Release(definitionComponent); } return(View()); }
public void DisposeContainer() { servicelocator.Release(definitionComponent); definitionComponent=null; servicelocator.Release(executionComponent); executionComponent=null; _container.Dispose(); _container = null; }
public void SetContainer() { //configure the container _container = new NetBpmContainer(new XmlInterpreter(TestHelper.GetConfigDir()+"app_config.xml")); testUtil = new TestUtil(); servicelocator = ServiceLocator.Instance; definitionComponent = servicelocator.GetService(typeof (IDefinitionSessionLocal)) as IDefinitionSessionLocal; executionComponent = servicelocator.GetService(typeof (IExecutionSessionLocal)) as IExecutionSessionLocal; testUtil.LoginUser("ae"); }
public void SetContainer() { //configure the container _container = new NetBpmContainer(new XmlInterpreter(TestHelper.GetConfigDir()+"app_config.xml")); testUtil = new TestUtil(); servicelocator = ServiceLocator.Instance; definitionComponent = servicelocator.GetService(typeof (IDefinitionSessionLocal)) as IDefinitionSessionLocal; executionComponent = servicelocator.GetService(typeof (IExecutionSessionLocal)) as IExecutionSessionLocal; schedulerComponent = servicelocator.GetService(typeof (ISchedulerSessionLocal)) as ISchedulerSessionLocal; organisationComponent = servicelocator.GetService(typeof (IOrganisationSessionLocal)) as IOrganisationSessionLocal; testUtil.LoginUser("ae"); // deploy Archiv FileInfo parFile = new FileInfo(TestHelper.GetExampleDir()+GetParArchiv()); FileStream fstream = parFile.OpenRead(); byte[] b = new byte[parFile.Length]; fstream.Read(b, 0, (int) parFile.Length); definitionComponent.DeployProcessArchive(b); }
public void ShowHome(Int32 processDefinitionId, String startAfter, String startBefore, String initiator, String actor) { IDefinitionSessionLocal definitionComponent = null; ILogSessionLocal logComponent = null; try { definitionComponent = ServiceLocator.Instance.GetService(typeof(IDefinitionSessionLocal)) as IDefinitionSessionLocal; logComponent = ServiceLocator.Instance.GetService(typeof(ILogSessionLocal)) as ILogSessionLocal; if (log.IsDebugEnabled) { log.Debug("ShowHome processDefinitionId:" + processDefinitionId + " startAfter:" + startAfter + " startBefore:" + startBefore + " initiator:" + initiator + " actor:" + actor); } Context.Flash["allProcessDefinitions"] = definitionComponent.GetAllProcessDefinitions(); // date text to datetime DateTime before = DateTime.MinValue; DateTime after = DateTime.MinValue; if (startAfter != null && startAfter != "") { try { after = DateTime.ParseExact(startAfter, DATEFORMAT, enUS); } catch (FormatException ex) { AddMessage(startAfter + " is not a vaild dateformat!"); log.Debug(startAfter + " is not a vaild dateformat!" + ex.Message); } } if (startBefore != null && startBefore != "") { try { before = DateTime.ParseExact(startBefore, DATEFORMAT, enUS); } catch (FormatException ex) { AddMessage(startBefore + " is not a vaild dateformat!"); log.Debug(startBefore + " is not a vaild dateformat!" + ex.Message); } } //show processes only if a definition is selected if (processDefinitionId != 0) { // TODO: add the handling of startAfter and startBefore IList allProcessInstances = logComponent.FindProcessInstances(after, before, initiator, actor, processDefinitionId); if (allProcessInstances.Count != 0) { Context.Flash["allProcessInstances"] = allProcessInstances; } } Context.Flash["processDefinitionId"] = processDefinitionId; Context.Flash["initiator"] = initiator; Context.Flash["actor"] = actor; Context.Flash["startBefore"] = startBefore; Context.Flash["startAfter"] = startAfter; Context.Flash["serviceLocator"] = ServiceLocator.Instance; } finally { ServiceLocator.Instance.Release(logComponent); ServiceLocator.Instance.Release(definitionComponent); } }