by digvijay
24. May 2010 11:45
Today, I was just writing a quick application to execute a DQL against a Documentum repository and put the results in a DataGridView something similar to Repoint (Repository interrogation utility) does. I thought it would be a nice code snippet to share so here it is:
1: IDfQuery query = _clientX().getQuery();
2: query.setDQL(txtDQL.Text);
3: IDfCollection rowData = query.execute(_session(), 0);
4: dgvResults.Rows.Clear();
5: dgvResults.Columns.Clear();
6:
7: bool addedHeader = false;
8: while (rowData.next())
9: {
10: try
11: {
12: if (!addedHeader)
13: {
14: dgvResults.AutoGenerateColumns = false;
15: for (int i = 0; i < rowData.getAttrCount(); i++ )
16: {
17: string s = rowData.getAttr(i).getName();
18: dgvResults.Columns.Add(s,s);
19: }
20:
21: addedHeader = true;
22: }
23:
24: List<string> items = new List<string>();
25: for (int i = 0; i < rowData.getAttrCount(); i++)
26: {
27: string s = rowData.getString(rowData.getAttr(i).getName());
28: items.Add(s);
29: }
30: dgvResults.Rows.Add(items.ToArray());
31: }
32: catch
33: {
34: }
35: }
Hope that helps someone!
by digvijay
12. January 2009 22:30
Here is a little handy generic routine to help parse enumerations. I hope someone finds it useful!
public static T GetEnum<T>(string value) where T : struct
{
if (!typeof(T).IsEnum)
throw new InvalidOperationException("Parameter T must be of type Enum.");
if (string.IsNullOrEmpty(value))
throw new ArgumentNullException("Unable to parse the value.");
return (T)Enum.Parse(typeof(T), value, true);
}