Beispiel #1
0
    /// <summary>
    /// Gets the focused projects output path.
    /// </summary>
    /// <returns>Path as string</returns>
    public static string OutputPath()
    {
        try
        {
            IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;
            IDXPProject   CurrentProject   = CurrentWorkspace.DM_FocusedProject();

            return(CurrentProject.DM_GetOutputPath());
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return("");
        }
    }
Beispiel #2
0
    /// <summary>
    /// Generate CSV height report.
    /// </summary>
    /// <param name="argHeights">Reference to the dict storing report info.</param>
    private void GenerateCSV(ref Dictionary <string, Heights> argHeights)
    {
        try
        {
            DXP.Utils.PercentInit("Generating CSV", argHeights.Count);
            int       i      = 4;
            ArrayList report = new ArrayList();
            report.Add("Excel Component Heights Report");
            report.Add("========================");
            report.Add("Ref,Footprint,Symbol Height (mils),Body Height (mils),Difference (Sym-Body),Library");
            foreach (KeyValuePair <string, Heights> item in argHeights)
            {
                report.Add(item.Key + "," +
                           item.Value.Footprint + "," +
                           ((item.Value.ParameterHeight < 0) ? "N/A" : item.Value.ParameterHeight.ToString()) + "," +
                           ((item.Value.BodyHeight < 0) ? "N/A" : item.Value.BodyHeight.ToString()) + "," +
                           ("=C" + i + "-D" + i) + "," +
                           item.Value.Library);
                i++;

                DXP.Utils.PercentUpdate();
            }

            IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;
            IDXPProject   CurrentProject   = CurrentWorkspace.DM_FocusedProject();

            string fileName = CurrentProject.DM_GetOutputPath() + "\\HeightReport.csv";
            if (!Directory.Exists(Path.GetDirectoryName(fileName)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(fileName));
            }
            File.WriteAllLines(fileName, (string[])report.ToArray(typeof(string)));
            IServerDocument reportDocument = DXP.GlobalVars.Client.OpenDocument("Text", fileName);
            if (reportDocument != null)
            {
                CurrentProject.DM_AddGeneratedDocument(fileName);
                DXP.GlobalVars.Client.ShowDocument(reportDocument);
            }

            DXP.Utils.PercentFinish();
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
Beispiel #3
0
    /// <summary>
    /// Generate text height report.
    /// </summary>
    /// <param name="argHeights">Reference to the dict storing report info.</param>
    private void GenerateReport(ref Dictionary <string, Heights> argHeights)
    {
        try
        {//Generating Report
            DXP.Utils.PercentInit("Generating Report", argHeights.Count);

            ArrayList report = new ArrayList();
            report.Add("Component Heights Report");
            report.Add("========================");
            foreach (KeyValuePair <string, Heights> item in argHeights)
            {
                report.Add("Component " + item.Key);
                report.Add(item.Value.ToString());
                report.Add("");

                DXP.Utils.PercentUpdate();
            }

            IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;
            IDXPProject   CurrentProject   = CurrentWorkspace.DM_FocusedProject();

            string fileName = CurrentProject.DM_GetOutputPath() + "\\HeightReport.txt";
            File.WriteAllLines(fileName, (string[])report.ToArray(typeof(string)));

            IServerDocument reportDocument = DXP.GlobalVars.Client.OpenDocument("Text", fileName);
            if (reportDocument != null)
            {
                CurrentProject.DM_AddGeneratedDocument(fileName);
                DXP.GlobalVars.Client.ShowDocument(reportDocument);
            }

            DXP.Utils.PercentFinish();
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
Beispiel #4
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;
        }
    }
Beispiel #5
0
    /// <summary>
    ///
    /// </summary>
    public void OpenDesignNotes()
    {
        try
        {
            IDXPProject Project = DXP.GlobalVars.DXPWorkSpace.DM_FocusedProject();
            Dictionary <string, string> Params      = GetParams();
            IOptionsStorage             ProjOptions = Project.DM_OptionsStorage();
            if (Project == null)
            {
                MessageBox.Show("Project not found. Try again.");
                return;
            }

            string strProjPath = Util.ProjPath();

            if (strProjPath == "\\")
            {
                MessageBox.Show("Project not found. Try again.");
                return;
            }

            string DesignNotesPath = OneNotePath(strProjPath, "Open Notebook.onetoc2");
            string ProjAssy = "", ProjQual = "", PwbNum = "";


            for (int i = 0; i <= Project.DM_GetParameterCount() - 1; i++)
            {
                if (Project.DM_GetParameterName(i) == "SwRI_Pwb_Qual")
                {
                    ProjQual = Project.DM_GetParameterValue(i);
                }
                else if (Project.DM_GetParameterName(i) == "SwRI_Title_Assy")
                {
                    ProjAssy = Project.DM_GetParameterValue(i);
                }
                else if (Project.DM_GetParameterName(i) == "SwRI_Pwb_Number")
                {
                    PwbNum = Project.DM_GetParameterValue(i);
                }
            }

            if (ProjQual == null)
            {
                MessageBox.Show("SwRI_Pwb_Qual project parameter is blank. Please fill this parameter in and try again.");
                return;
            }
            if (ProjAssy == null)
            {
                MessageBox.Show("SwRI_Title_Assy project parameter is blank. Please fill this parameter in and try again.");
                return;
            }
            if (PwbNum == null)
            {
                MessageBox.Show("SwRI_Pwb_Number project parameter is blank. Please fill this parameter in and try again.");
                return;
            }
            if (PwbNum != "")
            {
                PwbNum = PwbNum.Substring(0, 5);
            }
            //SwRI_Pwb_Number
            System.IO.Directory.SetCurrentDirectory(Util.ProjPath());
            if (DesignNotesPath == "" && ProjQual != "" && ProjAssy != "")
            {
                CopyFile(Params["template"], ".\\" + PwbNum + "_" + ProjAssy + "_" + ProjQual + "_Notes");
                DesignNotesPath = Util.ProjPath() + PwbNum + "_" + ProjAssy + "_" + ProjQual + "_Notes\\Open Notebook.onetoc2";
            }
            //CopyFile(Params["template"], ".\\Design_Notes_" + ProjAssy + "_" + ProjQual);
            //DesignNotesPath = Util.ProjPath() + "Design_Notes_" + ProjAssy + "_" + ProjQual + "\\Open Notebook.onetoc2";

            else if (DesignNotesPath.Contains("Design_Notes\\Open Notebook.onetoc2"))
            {
                try
                {
                    Directory.Move(Path.GetDirectoryName(DesignNotesPath) + "\\", Util.ProjPath() + PwbNum + "_" + ProjAssy + "_" + ProjQual + "_Notes\\");
                    DesignNotesPath = Util.ProjPath() + PwbNum + "_" + ProjAssy + "_" + ProjQual + "_Notes\\Open Notebook.onetoc2";
                }
                catch //(IOException ex)
                {
                    //MessageBox.Show("")
                    //throw;
                }
            }
            else if (DesignNotesPath.Contains("Design_Notes_" + ProjAssy + "_" + ProjQual + "\\Open Notebook.onetoc2"))
            {
                try
                {
                    Directory.Move(Path.GetDirectoryName(DesignNotesPath) + "\\", Util.ProjPath() + PwbNum + "_" + ProjAssy + "_" + ProjQual + "_Notes\\");
                    DesignNotesPath = Util.ProjPath() + PwbNum + "_" + ProjAssy + "_" + ProjQual + "_Notes\\Open Notebook.onetoc2";
                }
                catch //(IOException ex)
                {
                    //MessageBox.Show("")
                    //throw;
                }
            }
            else if ((ProjQual == "" || ProjAssy == "") && DesignNotesPath == "")
            {
                CopyFile(Params["template"], ".\\" + Path.GetFileNameWithoutExtension(Project.DM_ProjectFileName()) + "_Notes");
                DesignNotesPath = Util.ProjPath() + Path.GetFileNameWithoutExtension(Project.DM_ProjectFileName()) + "_Notes" + "\\Open Notebook.onetoc2";
                //create folder using project name instead.
                //MessageBox.Show("Missing project Qual and Assembly parameters.");
                //return;
            }

            System.Diagnostics.Process proc = System.Diagnostics.Process.Start(DesignNotesPath);
            proc.Dispose();
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
        }
    }
Beispiel #6
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");
    }
Beispiel #7
0
    public void Update_PDF_Sch_Links()
    {
        DXP.Utils.StatusBarSetState(2, "Fixing PDFs");

        string ProjPath = Util.ProjPath();


        IDXPProject     Project     = DXP.GlobalVars.DXPWorkSpace.DM_FocusedProject();
        IOptionsStorage ProjOptions = Project.DM_OptionsStorage();

        if (Project == null)
        {
            MessageBox.Show("Project not found. Try again.");
            return;
        }

        if (ProjPath == "\\")
        {
            MessageBox.Show("Project not found. Try again.");
            return;
        }

        string SchRev = "";

        //SwRI_SCH_Rev

        for (int i = 0; i <= Project.DM_GetParameterCount() - 1; i++)
        {
            if (Project.DM_GetParameterName(i) == "SwRI_SCH_Rev")
            {
                SchRev = Project.DM_GetParameterValue(i);
            }
        }
        if (SchRev == "")
        {
            MessageBox.Show("Schematic rev not found.");
            return;
        }

        string SchFolder = ProjPath + "Project Outputs\\sch" + SchRev + "\\";

        if (!Directory.Exists(SchFolder))
        {
            MessageBox.Show("Schematic project output folder missing.");
            return;
        }
        bool errors = false;
        int  count  = 0;

        DXP.Utils.PercentInit("Fixing PDFs", Directory.GetFiles(SchFolder).Length);

        //string[] PDFs;
        //PDFs = Directory.GetFiles(PDFPath, "*.pdf");
        //DateTime LatestDT = new DateTime();
        //foreach (string item in PDFs)
        //{
        //    if (File.GetCreationTime(item).Date == DateTime.Today.Date)
        //        if (File.GetCreationTime(item) > LatestDT)
        //        {
        //            LatestDT = File.GetCreationTime(item);
        //            LatestPDF = item;
        //        }
        //}

        foreach (string path in Directory.GetFiles(SchFolder))
        {
            if (path.ToLower().EndsWith("pdf"))
            {
                if (UpdatePDF(path) == false)
                {
                    errors = true;
                }
                count++;
            }
            Utils.PercentUpdate();
        }

        DXP.Utils.PercentFinish();

        if (errors)
        {
            MessageBox.Show("Something went wrong. A PDF may have been open.\r\nPlease close the PDF and try again.");
        }
        MessageBox.Show("Process complete.\r\n" + count + " file(s) processed");
    }