Esempio n. 1
0
    private void btnGenerate_Click(object sender, System.EventArgs e)
    {
        try
        {
            foreach (TreeNode node in treeOutjobs.Nodes)
            {
                foreach (TreeNode _node in node.Nodes)
                {
                    _node.BackColor = System.Drawing.Color.White;
                }
            }
            string process, parameters;
            //Have the user select what outjobs to run.

            DXP.Utils.PercentInit("Running Selected Outjobs", treeOutjobs.Nodes.Count);

            //Start running outjobs based on what nodes are checked
            foreach (TreeNode node in treeOutjobs.Nodes)
            {
                if (node.Checked && node.Nodes.Count > 0)
                {
                    foreach (TreeNode _node in node.Nodes)
                    {
                        if (_node.Checked)
                        {
                            if (dictOutputMedium[_node.FullPath].ODB && ToolsPreferences.ODB_HideRefDes)    //If ODB option enabled then hide all refdes' on the PCB before running outjob.
                            {
                                if (!PreODB())
                                {
                                    break;
                                }
                            }
                            tmpClient.ShowDocument(dictOutputMedium[_node.FullPath].ServerDoc);
                            OutputMedium = dictOutputMedium[_node.FullPath].OutputMedium;

                            if (cboVariant.Enabled == true)
                            {
                                if (cboVariant.Text != "Original")
                                {
                                    OutJobDoc = (IWSM_OutputJobDocument)dictOutputMedium[_node.FullPath].ServerDoc;
                                    //Check to see if variant scope of outjob doc is not set to effect the entire document.
                                    if (OutJobDoc.GetState_VariantScope() != TOutputJobVariantScope.eVariantScope_DefinedForWholeOutputJob)
                                    {
                                        //Set variant scope to effect entire document.
                                        OutJobDoc.SetState_VariantScope(TOutputJobVariantScope.eVariantScope_DefinedForWholeOutputJob);
                                    }
                                    //Set variant setting in outjob to selected variant.
                                    if (OutJobDoc.GetState_VariantName() != cboVariant.Text)
                                    {
                                        OutJobDoc.SetState_VariantName(cboVariant.Text);
                                    }
                                }
                            }
//#if DEBUG
//                                string files="";
//                                OutJobDoc = (IWSM_OutputJobDocument)dictOutputMedium[_node.FullPath].ServerDoc;
//                                OutJobDoc.GetState_MediumOutputer(OutputMedium, 0).DM_Generate_OutputFilesTo(@"T:\users\RLYNE\test projects\SchB_PwbA\Datasheets", OutJobDoc.GetState_MediumOutputer(OutputMedium, 0).DM_Parameters(0).DM_Value());

//                                for (int i = 0; i < OutJobDoc.GetState_OutputerCount(); i++)
//                                {
//                                    System.Diagnostics.Debug.WriteLine(OutJobDoc.GetState_Outputer(i).DM_GeneratorName());
//                                }

//#endif
                            //Generate outjob outputs.
                            switch (OutputMedium.GetState_TypeString())
                            {
                            case "PDF":
                                process    = "WorkspaceManager:Print";
                                parameters = "Action=PublishToPDF|DisableDialog=True|ObjectKind=OutputBatch" +
                                             "|OutputMedium=" + OutputMedium.GetState_Name() +
                                             "|PromptOverwrite=FALSE|OpenOutput=FALSE";
                                DXP.Utils.RunCommand(process, parameters);
                                break;

                            case "Generate Files":

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

                            case "Print":
                                break;

                            default:
                                MessageBox.Show("Unknown Output type: " + OutputMedium.GetState_TypeString() + ", name: " + OutputMedium.GetState_Name());
                                break;
                            }
                            //Undo hidden refdes' if option is enabled.
                            if (dictOutputMedium[_node.FullPath].ODB && ToolsPreferences.ODB_HideRefDes)
                            {
                                if (!PostODB())
                                {
                                    break;
                                }
                            }
                            //_node.ForeColor = System.Drawing.Color.ForestGreen;
                            _node.BackColor = System.Drawing.Color.LightGreen;
                            this.Refresh();
                            treeOutjobs.Refresh();
                        }
                    }
                }
                DXP.Utils.PercentUpdate();
            }

            DXP.Utils.PercentFinish();

            //Close outjob docs
            foreach (IServerDocument ServerDoc in lstServerDocs)
            {
                tmpClient.CloseDocument(ServerDoc);
            }
            //lstServerDocs.Clear();
            //dictOutputMedium.Clear();
            MessageBox.Show("Outjob batch generation complete.");

            DXP.Utils.StatusBarSetStateDefault();

            if (cbClose.Checked)
            {
                this.Close();
            }
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
        }
    }
Esempio n. 2
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;
        }
    }
Esempio n. 3
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");
    }