示例#1
0
        public virtual void testBuildMimePackageDocJMF()
        {
            JDFDoc docJMF = new JDFDoc("JMF");

            docJMF.setOriginalFileName("JMF.jmf");
            JDFJMF     jmf = docJMF.getJMFRoot();
            JDFCommand com = (JDFCommand)jmf.appendMessageElement(JDFMessage.EnumFamily.Command, JDFMessage.EnumType.SubmitQueueEntry);

            com.appendQueueSubmissionParams().setURL("TheJDF");

            JDFDoc doc = new JDFDoc("JDF");

            doc.setOriginalFileName("JDF.jdf");
            JDFNode n = doc.getJDFRoot();

            n.setType(EnumType.ColorSpaceConversion);
            JDFColorSpaceConversionParams cscp = (JDFColorSpaceConversionParams)n.addResource(ElementName.COLORSPACECONVERSIONPARAMS, null, EnumUsage.Input, null, null, null, null);
            JDFFileSpec fs0 = cscp.appendFinalTargetDevice();

            fs0.setURL(StringUtil.uncToUrl(sm_dirTestData + "test.icc", true));
            JDFRunList rl = (JDFRunList)n.addResource(ElementName.RUNLIST, null, EnumUsage.Input, null, null, null, null);

            rl.addPDF(StringUtil.uncToUrl(sm_dirTestData + "url1.pdf", false), 0, -1);
            for (int i = 0; i < 100; i++)
            {
                rl.addPDF(StringUtil.uncToUrl(sm_dirTestData + "url?.pdf", false), 0, -1);
            }
            AttachmentCollection m = MimeUtil.buildMimePackage(docJMF, doc, true);

            MimeUtil.writeToFile(m, sm_dirTestDataTemp + "testMimePackageDoc.mjm", null);
        }
示例#2
0
        public static void submitMimeToHDM(JDFNode n)
        {
            // build SubmitQueueEntry
            JDFDoc     docJMF = new JDFDoc("JMF");
            JDFJMF     jmf    = docJMF.getJMFRoot();
            JDFCommand com    = (JDFCommand)jmf.appendMessageElement(JDFMessage.EnumFamily.Command, JDFMessage.EnumType.SubmitQueueEntry);

            com.appendQueueSubmissionParams().setURL("dummy");
            System.Net.Mail.AttachmentCollection mp = MimeUtil.buildMimePackage(docJMF, n.getOwnerDocument_JDFElement(), true);

            try
            {
                MIMEDetails md = new MIMEDetails();
                md.transferEncoding      = UrlUtil.BASE64;
                md.httpDetails.chunkSize = -1;
                HttpWebRequest response = MimeUtil.writeToURL(mp, "http://192.168.40.71:8889/jmfportal", md);
                // Java to C# Converstion - What is the ResponseCode for HttpWebRequest?
                //Assert.AreEqual(200, response.GetResponse().getResponseCode());
                MimeUtil.writeToURL(mp, UrlUtil.fileToUrl(new FileInfo("C:\\data\\test.mim"), false), md);
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message); // fail on exception
            }
        }
示例#3
0
        public virtual void testWritePerformance()
        {
            long   start  = JDFDate.ToMillisecs(DateTime.Now);
            string big    = sm_dirTestData + "big.pdf";
            string bigger = sm_dirTestDataTemp + "bigger.pdf";
            JDFDoc docJMF = new JDFDoc("JMF");

            docJMF.setOriginalFileName("JMF.jmf");
            JDFJMF     jmf = docJMF.getJMFRoot();
            JDFCommand com = (JDFCommand)jmf.appendMessageElement(JDFMessage.EnumFamily.Command, JDFMessage.EnumType.SubmitQueueEntry);

            com.appendQueueSubmissionParams().setURL("TheJDF");
            FileInfo fBigger = new FileInfo(bigger);

            SupportClass.FileSupport.CreateNewFile(fBigger);
            FileStream fis = new FileStream(big, FileMode.Open);
            FileStream fos = new FileStream(bigger, FileMode.Create);

            byte[] b = new byte[10000];
            while (true)
            {
                int i = fis.Read(b, 0, 10000);
                if (i <= 0)
                {
                    break;
                }
                for (int j = 0; j < 3; j++)
                {
                    fos.Write(b, 0, i);
                }
            }
            fis.Close();
            fos.Flush();
            fos.Close();

            JDFDoc doc = new JDFDoc("JDF");

            doc.setOriginalFileName("JDF.jdf");
            JDFNode n = doc.getJDFRoot();

            n.setType(EnumType.Interpreting);
            JDFRunList rl = (JDFRunList)n.addResource(ElementName.RUNLIST, EnumUsage.Input);

            rl.addPDF(StringUtil.uncToUrl(bigger, false), 0, -1);
            long setup = JDFDate.ToMillisecs(DateTime.Now);

            Console.WriteLine("Setup time: " + (setup - start));
            AttachmentCollection m = MimeUtil.buildMimePackage(null, doc, true);
            long build             = JDFDate.ToMillisecs(DateTime.Now);

            Console.WriteLine("Build time: " + (build - setup));
            Assert.IsNotNull(MimeUtil.writeToFile(m, sm_dirTestDataTemp + "performance.mjm", null));
            long write = JDFDate.ToMillisecs(DateTime.Now);

            Console.WriteLine("Write time: " + (write - build));
        }
示例#4
0
        public virtual void testEmptyString()
        {
            JDFDoc inMessageDoc = new JDFDoc(ElementName.JMF);
            JDFJMF jmfIn        = inMessageDoc.getJMFRoot();

            jmfIn.appendMessageElement(JDFMessage.EnumFamily.Response, null);
            string s = inMessageDoc.write2String(0);

            Assert.IsNotNull(s);
        }
示例#5
0
        public override void setUp()
        {
            base.setUp();
            JDFDoc      doc  = new JDFDoc("JMF");
            JDFJMF      jmf  = doc.getJMFRoot();
            JDFResponse resp = (JDFResponse)jmf.appendMessageElement(EnumFamily.Response, JDFMessage.EnumType.KnownDevices);

            deviceCap = resp.appendDeviceList().appendDeviceInfo().appendDevice().appendDeviceCap();
            deviceCap.appendBooleanState("Template");
        }
示例#6
0
        public virtual void testGetJMFSubmission()
        {
            JDFDoc d1 = new JDFDoc("JMF");

            d1.setOriginalFileName("JMF.jmf");
            JDFJMF jmf = d1.getJMFRoot();

            jmf.setDeviceID("gr?n?");
            JDFCommand com = (JDFCommand)jmf.appendMessageElement(JDFMessage.EnumFamily.Command, JDFMessage.EnumType.SubmitQueueEntry);

            com.appendQueueSubmissionParams().setURL("TheJDF");

            JDFDoc doc = new JDFDoc("JDF");

            doc.setOriginalFileName("JDF.jdf");
            JDFNode n = doc.getJDFRoot();

            n.setType(EnumType.ColorSpaceConversion);
            JDFColorSpaceConversionParams cscp = (JDFColorSpaceConversionParams)n.addResource(ElementName.COLORSPACECONVERSIONPARAMS, null, EnumUsage.Input, null, null, null, null);
            JDFFileSpec fs0 = cscp.appendFinalTargetDevice();

            fs0.setURL(StringUtil.uncToUrl(sm_dirTestData + "test.icc", true));
            JDFRunList rl = (JDFRunList)n.addResource(ElementName.RUNLIST, null, EnumUsage.Input, null, null, null, null);

            rl.addPDF(StringUtil.uncToUrl(sm_dirTestData + "url1.pdf", false), 0, -1);
            for (int i = 0; i < 100; i++)
            {
                rl.addPDF("gr?n?" + i + ".pdf", 0, -1);
            }
            AttachmentCollection m = MimeUtil.buildMimePackage(d1, doc, true);

            JDFDoc[] d2 = MimeUtil.GetJMFSubmission(m);
            Assert.IsNotNull(d2);
            Assert.AreEqual("cid:JDF.jdf", d2[0].getJMFRoot().getCommand(0).getQueueSubmissionParams(0).getURL());
            Assert.AreEqual(EnumType.ColorSpaceConversion, d2[1].getJDFRoot().getEnumType());

            // now serialize to file and reread - should still work
            MimeUtil.writeToFile(m, sm_dirTestDataTemp + "test2.mjm", null);
            AttachmentCollection m2 = MimeUtil.GetMultiPart(sm_dirTestDataTemp + "test2.mjm");

            Assert.IsNotNull(m2);
            d2 = MimeUtil.GetJMFSubmission(m);
            Assert.IsNotNull(d2);
            Assert.AreEqual("cid:JDF.jdf", d2[0].getJMFRoot().getCommand(0).getQueueSubmissionParams(0).getURL());
            Assert.AreEqual(EnumType.ColorSpaceConversion, d2[1].getJDFRoot().getEnumType());
        }
示例#7
0
        public virtual void testStatusEquals()
        {
            // test if the auto classes implement the correct status

            // compare EnumNodeStatus
            JDFAuditPool myAuditPool = null;

            JDFDoc jdfDoc = new JDFDoc(ElementName.JDF);

            JDFNode jdfRoot = (JDFNode)jdfDoc.getRoot();

            Assert.IsTrue(jdfRoot != null, "No Root found");
            if (jdfRoot == null)
            {
                return; // soothe findbugs ;)
            }
            JDFAncestor ancestor = jdfRoot.appendAncestorPool().appendAncestor();

            ancestor.setStatus(EnumNodeStatus.Completed);

            myAuditPool = jdfRoot.getCreateAuditPool();
            JDFPhaseTime phaseTime = myAuditPool.addPhaseTime(JDFElement.EnumNodeStatus.Completed, null, null);
            JDFSpawned   spawned   = myAuditPool.addSpawned(jdfRoot, null, null, null, null);

            spawned.setStatus(JDFElement.EnumNodeStatus.Completed);

            Assert.AreEqual(spawned.getStatus(), phaseTime.getStatus());
            Assert.AreEqual(spawned.getStatus(), ancestor.getStatus());

            JDFDoc jmfDoc = new JDFDoc(ElementName.JMF);

            JDFJMF jmfRoot = jmfDoc.getJMFRoot();

            Assert.IsTrue(jmfRoot != null, "No Root found");
            if (jmfRoot == null)
            {
                return; // soothe findbugs ;)
            }
            JDFAcknowledge acknowledge = jmfRoot.appendAcknowledge();

            acknowledge.setType("PipePush"); // Type is required and its existance
            // is validated for messages
            JDFJobPhase jobPhase = acknowledge.appendJobPhase();

            jobPhase.setStatus(EnumNodeStatus.Completed);

            JDFMessage message = jmfRoot.appendMessageElement(EnumFamily.Command, null);

            message.setType("PipePush"); // Type is required and its existance is
            // validated for messages
            JDFPipeParams pipeParams = message.appendPipeParams();

            pipeParams.setStatus(EnumNodeStatus.Completed);

            Assert.AreEqual(jobPhase.getStatus(), pipeParams.getStatus());
            Assert.AreEqual(spawned.getStatus(), pipeParams.getStatus());

            // compare EnumResStatus
            JDFDoc      responseDoc  = new JDFDoc(ElementName.RESPONSE);
            JDFResponse responseRoot = (JDFResponse)responseDoc.getRoot();

            Assert.IsTrue(responseRoot != null, "No Root found");
            if (responseRoot == null)
            {
                return; // soothe findbugs ;)
            }
            responseRoot.setType(ElementName.RESOURCE);
            JDFResourceInfo resInfo = responseRoot.appendResourceInfo();

            resInfo.setResStatus(EnumResStatus.Available);

            JDFDoc     commandDoc  = new JDFDoc(ElementName.COMMAND);
            JDFCommand commandRoot = (JDFCommand)commandDoc.getRoot();

            Assert.IsTrue(commandRoot != null, "No Root found");
            if (commandRoot == null)
            {
                return; // soothe findbugs ;)
            }
            commandRoot.setType(ElementName.RESOURCE);
            JDFResourceCmdParams resCmdParams = commandRoot.appendResourceCmdParams();

            resCmdParams.setResStatus(EnumResStatus.Available);

            Assert.AreEqual(resInfo.getStatus(), resCmdParams.getStatus());

            // check EnumQueueStatus
            JDFDoc   queueDoc  = new JDFDoc(ElementName.QUEUE);
            JDFQueue queueRoot = (JDFQueue)queueDoc.getRoot();

            Assert.IsTrue(queueRoot != null, "No Root found");
            if (queueRoot == null)
            {
                return; // soothe findbugs ;)
            }
            queueRoot.setQueueStatus(EnumQueueStatus.Running);

            // check EnumQueueEntryStatus
            JDFQueueEntry queueEntry = queueRoot.appendQueueEntry();

            queueEntry.setQueueEntryStatus(EnumQueueEntryStatus.Running);
        }
示例#8
0
        ///
        ///	 <summary> * Set the Status and StatusDetails of this node update the PhaseTime audit or append a new phasetime as appropriate
        ///	 * also prepare a status JMF
        ///	 *  </summary>
        ///	 * <param name="nodeStatus"> the new status of the node </param>
        ///	 * <param name="nodeStatusDetails"> the new statusDetails of the node </param>
        ///	 * <param name="deviceStatus"> the new status of the device </param>
        ///	 * <param name="deviceStatusDetails"> the new statusDetails of the device </param>
        ///	 * <param name="vPartMap"> the vector of parts to that should be set </param>
        ///	 * <param name="vResLink"> the resourcelinks that are used to fill the various amount attributes in jobphase and phasetime
        ///	 *  </param>
        ///
        public virtual void setPhase(EnumNodeStatus nodeStatus, string nodeStatusDetails, EnumDeviceStatus deviceStatus, string deviceStatusDetails, AmountBag[] amounts)
        {
            docJMFPhaseTime = new JDFDoc(ElementName.JMF);
            JDFJMF jmf = docJMFPhaseTime.getJMFRoot();

            docJMFResource = new JDFDoc(ElementName.JMF);
            JDFJMF jmfRes = docJMFResource.getJMFRoot();

            AmountBag  ab     = getBag(getFirstRefID(), amounts);
            LinkAmount la     = getLinkAmount(getFirstRefID());
            AmountBag  lastAb = la == null ? null : la.lastBag;

            JDFAuditPool ap = m_Node.getCreateAuditPool();
            // TODO rethink when to send 2 phases
            JDFPhaseTime pt1  = ap.getLastPhase(m_vPartMap, null);
            JDFPhaseTime pt2  = pt1;
            bool         bEnd = nodeStatus.Equals(EnumNodeStatus.Completed) || nodeStatus.Equals(EnumNodeStatus.Aborted);

            pt2 = ap.setPhase(nodeStatus, nodeStatusDetails, m_vPartMap, null);
            if (bEnd)
            {
                JDFProcessRun pr = (JDFProcessRun)ap.addAudit(EnumAuditType.ProcessRun, null);
                pr.setPartMapVector(m_vPartMap);
                VElement audits = ap.getAudits(EnumAuditType.PhaseTime, null, m_vPartMap);
                for (int i = 0; i < audits.Count; i++)
                {
                    pr.addPhase((JDFPhaseTime)audits[i]);
                }
                pr.setEndStatus(nodeStatus);
            }

            if (pt1 != null && pt2 != pt1) // we explicitly added a new phasetime
            // audit, thus we need to add a closing
            // JMF for the original jobPhase
            {
                JDFSignal     s          = (JDFSignal)jmf.appendMessageElement(JDFMessage.EnumFamily.Signal, JDFMessage.EnumType.Status);
                JDFDeviceInfo deviceInfo = s.appendDeviceInfo();

                JDFJobPhase jp = deviceInfo.createJobPhaseFromPhaseTime(pt1);
                jp.setJobID(m_Node.getJobID(true));
                jp.setJobPartID(m_Node.getJobPartID(false));
                setJobPhaseAmounts(lastAb, jp);

                if (m_deviceID != null)
                {
                    deviceInfo.setDeviceID(m_deviceID);
                }
            }

            if (pt2 != null)
            {
                JDFSignal     s          = (JDFSignal)jmf.appendMessageElement(JDFMessage.EnumFamily.Signal, JDFMessage.EnumType.Status);
                JDFDeviceInfo deviceInfo = s.appendDeviceInfo();
                if (!bEnd) // don't write a jobphase for an idle device
                {
                    JDFJobPhase jp = deviceInfo.createJobPhaseFromPhaseTime(pt2);
                    setJobPhaseAmounts(ab, jp);
                }

                deviceInfo.setDeviceStatus(deviceStatus);
                deviceInfo.setStatusDetails(deviceStatusDetails);
                deviceInfo.setDeviceID(m_deviceID);
                m_Node.setPartStatus(m_vPartMap, nodeStatus, null);
                getVResLink(amounts, 2); // update the nodes links

                generateResourceSignal(amounts, jmfRes);

                if (bEnd)
                {
                    pt2.deleteNode(); // zapp the last phasetime
                }
                else
                {
                    pt2.setLinks(getVResLink(amounts, 1));
                    pt2.eraseEmptyAttributes(true);
                }
            }

            // cleanup!
            if (vLinkAmount != null)
            {
                for (int i = 0; i < vLinkAmount.Length; i++)
                {
                    string    refID = vLinkAmount[i].rl.getrRef();
                    AmountBag bag   = getBag(refID, amounts);
                    vLinkAmount[i].lastBag = new AmountBag(bag);
                }
            }
            jmf.eraseEmptyAttributes(true);
        }