Example #1
0
        public void DeployProcessArchive(byte[] processArchiveBytes)
        {
            ParFile parFile = new ParFile(processArchiveBytes);

            MyProcessDefinitionBuilder builder           = new MyProcessDefinitionBuilder(parFile.ProcessDefinition);
            ProcessDefinitionImpl      processDefinition = builder.BuildProcessDefinition();

            using (ISession session = NHibernateHelper.OpenSession())
            {
                DbSession nhSession = new DbSession(session);
                repository.Save(processDefinition, nhSession);
            }
        }
Example #2
0
        public void DeployProcessArchive(Stream processArchiveStream, DbSession dbSession)
        {
            log.Debug("reading process archive...");

            // construct an empty process definition
            ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();

            // Then save the process definition
            // This is done so hibernate will assign an id to this object.
            dbSession.Save(processDefinition);

            IDictionary <string, byte[]> entries = null;

            entries = ZipUtility.ReadEntries(processArchiveStream);

            ProcessDefinitionBuildContext processDefinitionBuilder = new ProcessDefinitionBuildContext(processDefinition, entries, dbSession);

            try
            {
                if (!entries.ContainsKey("processdefinition.xml"))
                {
                    processDefinitionBuilder.AddError("entry '" + "processdefinition.xml" + "' found not found in the process archive");
                    throw new SystemException("entry '" + "processdefinition.xml" + "' found not found in the process archive");
                }
                // parse the  processdefinition.xml
                XmlElement xmlElement = getXmlElementFromBytes(entries["processdefinition.xml"]);
                // build the object model from the xml
                processDefinitionBuilder.PushScope("in processdefinition.xml");
                processDefinition.ReadProcessData(xmlElement, processDefinitionBuilder);
                processDefinition.Version    = GetVersionNr(processDefinitionBuilder, processDefinition.Name);
                processDefinition.ClassFiles = GetAssemblyFiles(processDefinitionBuilder, processDefinition);
                processDefinitionBuilder.PopScope();
                // resolve all forward references
                processDefinitionBuilder.ResolveReferences();

                processDefinition.Validate(processDefinitionBuilder);

                if (processDefinitionBuilder.HasErrors())
                {
                    throw new NpdlException(processDefinitionBuilder.Errors);
                }
                // read the optional web-interface information
                if (entries.ContainsKey("web/webinterface.xml"))
                {
                    log.Debug("processing webinterface.xml...");
                    xmlElement = getXmlElementFromBytes(entries["web/webinterface.xml"]);
                    processDefinitionBuilder.PushScope("in webinterface.xml");
                    processDefinition.ReadWebData(xmlElement, processDefinitionBuilder);
                    processDefinitionBuilder.PopScope();
                }
                else
                {
                    log.Debug("no web/webinterface.xml was supplied");
                }

                processDefinitionRepository.Save(processDefinition, dbSession);
            }
            catch (SystemException e)
            {
                log.Error("xml parsing error :", e);
                processDefinitionBuilder.AddError(e.GetType().FullName + " : " + e.Message);
                processDefinitionBuilder.AddError("couldn't continue to parse the process archive");
                throw new NpdlException(processDefinitionBuilder.Errors);
            }
        }