Ejemplo n.º 1
0
    /// <summary>
    /// Run ModBOM outjob
    /// </summary>
    void ExportModBOM()
    {
        try
        {
            string                 process, parameters;
            IDXPProject            Project       = DXP.GlobalVars.DXPWorkSpace.DM_FocusedProject();
            List <IServerDocument> lstServerDocs = new List <IServerDocument>();
            IClient                tmpClient     = DXP.GlobalVars.Client;

            IProject project = DXP.GlobalVars.DXPWorkSpace.DM_FocusedProject() as IProject;

            List <string> lstOutjobDocPaths = new frmBatchOutjob().GetOutputJobPath(); //Get a list of all outjob docs in the project

            if (lstOutjobDocPaths == null)
            {
                return;
            }


            //Open the outjob docs
            foreach (string strPath in lstOutjobDocPaths)
            {
                lstServerDocs.Add(tmpClient.OpenDocument("OUTPUTJOB", strPath));
            }

            List <TreeNode> lstTreeNode;
            //Get outjob mediums
            foreach (IServerDocument ServerDoc in lstServerDocs)
            {
                OutJobDoc = (IWSM_OutputJobDocument)ServerDoc;

                lstTreeNode = new List <TreeNode>();
                for (int i = 0; i < OutJobDoc.GetState_OutputMediumCount(); i++)
                {
                    if (OutJobDoc.GetState_OutputMedium(i).GetState_TypeString() == "Generate Files")
                    {
                        OutputMedium = OutJobDoc.GetState_OutputMedium(i);
                        if (OutputMedium.GetState_Name() == "ModBOM")
                        {
                            tmpClient.ShowDocument(ServerDoc);

                            OutJobDoc = (IWSM_OutputJobDocument)ServerDoc;
                            OutJobDoc.SetState_VariantScope(TOutputJobVariantScope.eVariantScope_DefinedForWholeOutputJob);
                            OutJobDoc.SetState_VariantName("Var_PE");

                            //Generate outjob outputs.

                            process    = "WorkspaceManager:GenerateReport";
                            parameters = "Action=Run|ObjectKind=OutputBatch" +
                                         "|OutputMedium=" + OutputMedium.GetState_Name() +
                                         "|PromptOverwrite=FALSE|OpenOutput=FALSE";
                            DXP.Utils.RunCommand(process, parameters);

                            foreach (IServerDocument tmpServerDoc in lstServerDocs)
                            {
                                tmpClient.CloseDocument(tmpServerDoc);
                            }

                            MessageBox.Show("Process Complete");

                            return;
                        }
                    }
                }
            }
            MessageBox.Show("There is no \"ModBOM\" outjob in this project. You must create one to proceed.\nThe outjob must contain parameters \"Var_Eng\", \"Var_Flt\" and \"libref\". The container must be named \"ModBOM\"");
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
Ejemplo n.º 2
0
    public void frmBatchOutjob_Load(object sender, System.EventArgs e)
    {
        IDXPProject Project = DXP.GlobalVars.DXPWorkSpace.DM_FocusedProject();

        IProject project = DXP.GlobalVars.DXPWorkSpace.DM_FocusedProject() as IProject;

        //Load cboVariant with all variants in the active projet.
        if (project.DM_ProjectVariantCount() > 0)
        {
            cboVariant.Enabled = true;
            cboVariant.Items.Add("Original");
            cboVariant.Items.Add("[No Variations]");

            for (int i = 0; i < project.DM_ProjectVariantCount(); i++)
            {
                cboVariant.Items.Add(project.DM_ProjectVariants(i).DM_Description());
            }
            cboVariant.SelectedIndex = 0;
        }
        else
        {
            cboVariant.Enabled = false;
        }

        bool ODB = false;

        DXP.Utils.StatusBarSetState(2, "Collecting Outjobs");

        List <string> lstOutjobDocPaths = GetOutputJobPath();    //Get a list of all outjob docs in the project

        if (lstOutjobDocPaths == null)
        {
            return;
        }

        this.Text = Project.DM_ProjectFileName();


        //Open the outjob docs
        foreach (string strPath in lstOutjobDocPaths)
        {
            lstServerDocs.Add(tmpClient.OpenDocument("OUTPUTJOB", strPath));
        }

        DXP.Utils.PercentInit("Load Outjobs", lstServerDocs.Count);    //Progressbar init.
        List <TreeNode> lstTreeNode;

        //Get outjob mediums
        foreach (IServerDocument ServerDoc in lstServerDocs)
        {
            OutJobDoc = (IWSM_OutputJobDocument)ServerDoc;

            lstTreeNode = new List <TreeNode>();
            for (int i = 0; i < OutJobDoc.GetState_OutputMediumCount(); i++)
            {
                ODB = false;
                for (int j = 0; j < OutJobDoc.GetState_MediumOutputersCount(OutJobDoc.GetState_OutputMedium(i)); j++)
                {
                    //Check to see if outjob container is will generate ODB++ files. Flag it for hide refdes later.
                    if (OutJobDoc.GetState_MediumOutputer(OutJobDoc.GetState_OutputMedium(i), j).DM_GetDescription() == "ODB++ Files")
                    {
                        ODB = true;
                    }
                }
                //If outjob is not a Print then store the information and add to list.
                if (OutJobDoc.GetState_OutputMedium(i).GetState_TypeString() != "Print")
                {
                    dictOutputMedium.Add(System.IO.Path.GetFileName(ServerDoc.GetFileName()) + "-" + OutJobDoc.GetState_OutputMedium(i).GetState_Name(), new clsOutJob(OutJobDoc.GetState_OutputMedium(i), ServerDoc, ODB));
                    lstTreeNode.Add(new TreeNode(OutJobDoc.GetState_OutputMedium(i).GetState_Name()));    //Build list of nodes for form tree view
                }
                else
                {    //Dont remember why this is excluded.
                     //throw new  NotImplementedException("Batchoutjob \"print\" medium type");
                }
            }
            //Add collected outjob info to treeview.
            treeOutjobs.Nodes.Add(new TreeNode(System.IO.Path.GetFileName(ServerDoc.GetFileName()), lstTreeNode.ToArray()));     //Populate form treenodes
            DXP.Utils.PercentUpdate();
        }
        treeOutjobs.ExpandAll();

        DXP.Utils.PercentFinish();
        DXP.Utils.StatusBarSetState(2, "Select Outjobs to Run");
    }