/// <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(""); } }
/// <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; } }
/// <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; } }