Exemple #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;
        }
    }
Exemple #2
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);
        }
    }