/// <summary> /// Get the attached log output for any particular item /// </summary> /// <param name="item">Handle to the item</param> /// <returns>The log text, if found</returns> private static string GetItemLog(SAS.EG.Scripting.ISASEGItem item) { switch (item.Type) { case (int)SAS.EG.Scripting.SASEGItemType.egLog: SAS.EG.Scripting.ISASEGLog log = item as SAS.EG.Scripting.ISASEGLog; return(log.Text); case (int)SAS.EG.Scripting.SASEGItemType.egCode: SAS.EG.Scripting.ISASEGCode code = item as SAS.EG.Scripting.ISASEGCode; if (code.Log != null && code.Log.Text != null) { return(code.Log.Text); } break; case (int)SAS.EG.Scripting.SASEGItemType.egTask: SAS.EG.Scripting.ISASEGTask task = item as SAS.EG.Scripting.ISASEGTask; if (task.Log != null && task.Log.Text != null) { return(task.Log.Text); } break; case (int)SAS.EG.Scripting.SASEGItemType.egQuery: SAS.EG.Scripting.ISASEGQuery query = item as SAS.EG.Scripting.ISASEGQuery; if (query.Log != null && query.Log.Text != null) { return(query.Log.Text); } break; default: return(string.Empty); } return(string.Empty); }
// Search an item within the project. Different actions // needed depending on the type of item. private List <SearchMatch> matchContent(SAS.EG.Scripting.ISASEGItem item, SAS.EG.Scripting.Container c, string filename, string searchString) { List <SearchMatch> matches = new List <SearchMatch>(); // handle SAS programs that are embedded or easily accessed in the local file system if (item is SAS.EG.Scripting.Code) { matches.AddRange(matchTextContent( ((SAS.EG.Scripting.Code)item).Text, searchString, filename, c.Name, "SAS program", item.Name)); if (((SAS.EG.Scripting.Code)item).Log != null) { matches.AddRange( (matchTextContent( ((SAS.EG.Scripting.Code)item).Log.Text, searchString, filename, c.Name, "SAS log", string.Format("{0} - Log", item.Name)))); } } // handle notes if (item is SAS.EG.Scripting.Note) { matches.AddRange(matchTextContent( ((SAS.EG.Scripting.Note)item).Text, searchString, filename, c.Name, "Note", item.Name)); } // handle generated task code and logs if (item is SAS.EG.Scripting.Task) { SAS.EG.Scripting.TaskCode tc = ((SAS.EG.Scripting.Task)item).TaskCode as SAS.EG.Scripting.TaskCode; if (tc != null) { matches.AddRange(matchTextContent( tc.Text, searchString, filename, c.Name, "Generated SAS program", string.Format("{0} - Code", item.Name))); } SAS.EG.Scripting.Log tl = ((SAS.EG.Scripting.Task)item).Log as SAS.EG.Scripting.Log; if (tl != null) { matches.AddRange(matchTextContent( tl.Text, searchString, filename, c.Name, "Log", string.Format("{0} - Log", item.Name))); } } // handle generated query code and logs if (item is SAS.EG.Scripting.Query) { SAS.EG.Scripting.TaskCode tc = ((SAS.EG.Scripting.Query)item).TaskCode as SAS.EG.Scripting.TaskCode; if (tc != null) { matches.AddRange(matchTextContent( tc.Text, searchString, filename, c.Name, "Generated SAS program", string.Format("{0} - Code", item.Name))); } SAS.EG.Scripting.Log tl = ((SAS.EG.Scripting.Query)item).Log as SAS.EG.Scripting.Log; if (tl != null) { matches.AddRange(matchTextContent( tl.Text, searchString, filename, c.Name, "Log", string.Format("{0} - Log", item.Name))); } } // Data items can have tasks built off of them if (item is SAS.EG.Scripting.Data) { // caution: recursive call! foreach (SAS.EG.Scripting.ISASEGItem subitem in ((SAS.EG.Scripting.ISASEGData)item).Tasks) { matches.AddRange(matchContent(subitem, c, filename, searchString)); } } return(matches); }