/// <summary> /// Creates the table. /// </summary> /// <param name="table">The table.</param> /// <param name="collection">The collection.</param> private void CreateTable(ref DataTable table, IDfCollection collection) { if (table != null) { return; } table = new DataTable(); DqlDataType converter = new DqlDataType(); IDfTypedObject typedObj = collection.getTypedObject(); IDfAttr attr = null; int count = collection.getAttrCount(); for (int i = 0; i < count; i++) { attr = collection.getAttr(i); string field = attr.getName(); tagDfValueTypes dataType = attr.isRepeating() ? tagDfValueTypes.DF_STRING : (tagDfValueTypes)attr.getDataType(); if (converter.ContainsKey(dataType)) { table.Columns.Add(converter[dataType](field)); } } typedObj = null; attr = null; }
/// <summary> /// Initializes the broker. /// </summary> /// <exception cref="Exception">Failed creating Documentum client</exception> private void InitializeBroker() { //File.AppendAllText("DqlConnect.log", sessionId + " InitalizeBroker\r\n\r\n"); _clientx = new DfClientX(); _client = _clientx.getLocalClient(); if (_client == null) { throw new Exception("Failed creating Documentum client"); } IDfTypedObject config = _client.getClientConfig(); builder = new DqlConnectionStringBuilder(this.ConnectionString); config.setString("dfc.docbroker.host", DefaultBrokerHost ?? SetDefaultBrokerHost()); //File.AppendAllText("DqlConnect.log", sessionId + " Broker set to: " + DefaultBrokerHost + Environment.NewLine); builder.SetExtendedProperties(config); //builder.GetExtendedProperties().ForEach(item => //{ config.setString(item.Key, item.Value); }); IDfDocbaseMap map = _client.getDocbaseMap(); Catalogs = new List <string>(); int count = map.getDocbaseCount(); for (int i = 0; i < count; i++) { Catalogs.Add(map.getDocbaseName(i)); } map = null; config = null; }
/// <summary> /// Sets the default broker host. /// </summary> /// <returns>System.String.</returns> public static string SetDefaultBrokerHost() { var clientx = new DfClientX(); var client = clientx.getLocalClient(); IDfTypedObject config = client.getClientConfig(); DefaultBrokerHost = config.getString("dfc.docbroker.host"); config = null; clientx = null; GC.Collect(); //FreeDllsNow(0); return(DefaultBrokerHost); }
/// <summary> /// Sets the extended properties. /// </summary> /// <param name="config">The configuration.</param> public void SetExtendedProperties(IDfTypedObject config) { foreach (var item in GetExtendedProperties()) { var items = item.Key.Split(new string[] { "[", "]" }, StringSplitOptions.RemoveEmptyEntries); if (items.Count() > 1) { config.setRepeatingString(items.First().Trim(), int.Parse(items.Last().Trim()), item.Value.Trim()); } else { config.setString(item.Key.Trim(), item.Value.Trim()); } } }
/// <summary> /// Fills the specified data set. /// </summary> /// <param name="dataSet">The data set.</param> /// <param name="token">The token.</param> /// <returns>System.Int32.</returns> public int Fill(DataSet dataSet, CancellationToken token) { DqlReader formatter = new DqlReader(); List <DqlCommand> commands = new List <DqlCommand>(); command.CommandText.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries) .ToList().Where(w => string.IsNullOrEmpty(w) == false).ToList() .ForEach(commandText => commands.Add(new DqlCommand(commandText, (DqlConnection)command.Connection))); foreach (var cmd in commands) { if (token.IsCancellationRequested) { throw new OperationCanceledException("A cancellation token associated with this operation was canceled"); } DqlConnection cn = cmd.Connection; if (cn == null) { throw new Exception("Connection is null"); } IDfCollection records = cn.ExecuteQuery(cmd); DataTable table = null; IDfTypedObject typedObj = null; #region Row Iterator while (records.next()) { if (token.IsCancellationRequested) { throw new OperationCanceledException("A cancellation token associated with this operation was canceled"); } CreateTable(ref table, records); typedObj = records.getTypedObject(); DataRow row = table.NewRow(); table.Rows.Add(row); #region Column Iterator int count = records.getAttrCount(); for (int i = 0; i < count; i++) { var collection = records; IDfAttr attr = collection.getAttr(i); string field = attr.getName(); if (formatter.ContainsKey((tagDfValueTypes)attr.getDataType())) { row[field] = formatter[(tagDfValueTypes)attr.getDataType()](attr, collection); } } #endregion } #endregion records.close(); records = null; typedObj = null; if (table != null) { dataSet.Tables.Add(table); } } commands.ForEach(item => item.Dispose()); return(1); }