Пример #1
0
        public virtual void ReadWebData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext)
        {
            // first read the image
            XmlElement imageElement = xmlElement.GetChildElement("image");

            creationContext.Check((imageElement != null), "element image is missing");
            // reading the image-file
            String imageFileName = imageElement.GetProperty("name");

            creationContext.Check(((Object)imageFileName != null), "image name is missing");
            this._image = (byte[])creationContext.Entries[imageFileName];

            if (this._image == null)
            {
                creationContext.AddError("couldn't find image file '" + imageFileName + "' in the process archive. (make sure the specified path is relative to the archive-root)");
            }

            this._imageMimeType = imageElement.GetProperty("mime-type");
            creationContext.Check(((Object)_imageMimeType != null), "image mime-type is missing");
            try
            {
                _imageHeight = Int32.Parse(imageElement.GetProperty("height"));
                creationContext.Check(((Object)_imageHeight != null), "image height is missing");
                _imageWidth = Int32.Parse(imageElement.GetProperty("width"));
                creationContext.Check(((Object)_imageWidth != null), "image width is missing");
            }
            catch (FormatException e)
            {
                creationContext.AddError("image height or width contains unparsable numbers : height=\"" + imageElement.GetProperty("height") + "\" width=\"" + imageElement.GetProperty("width") + "\". Exception: " + e.Message);
            }

            DbSession dbSession = creationContext.DbSession;

            // then the activity-states
            IEnumerator iter = xmlElement.GetChildElements("activity-state").GetEnumerator();

            while (iter.MoveNext())
            {
                XmlElement activityStateElement = (XmlElement)iter.Current;
                String     activityStateName    = activityStateElement.GetProperty("name");
                creationContext.Check(((Object)activityStateName != null), "property name in activity state is missing");

                Object[]  values = new Object[] { activityStateName, _id };
                IType[]   types  = new IType[] { DbType.STRING, DbType.LONG };
                StateImpl state  = null;

                try
                {
                    state = (StateImpl)dbSession.FindOne(queryFindState, values, types);
                }
                catch (DbException e)
                {
                    creationContext.AddError("activity-state '" + activityStateName + "' was referenced from the webinterface.xml but not defined in the processdefinition.xml. Exception:" + e.Message);
                }

                state.ReadWebData(activityStateElement, creationContext);
            }
        }