예제 #1
0
        public CrmConnectionInfo GetConnectionInfo(CrmDbConnection connection)
        {
            var connInfo = _Cache.GetOrAdd(connection.ConnectionString, f =>
            {
                WhoAmIRequest whoRequest   = new WhoAmIRequest();
                WhoAmIResponse whoResponse = (WhoAmIResponse)connection.OrganizationService.Execute(whoRequest);

                var info = new CrmConnectionInfo();
                if (whoResponse != null)
                {
                    info.OrganisationId = whoResponse.OrganizationId;
                    info.UserId         = whoResponse.UserId;
                    info.BusinessUnitId = whoResponse.BusinessUnitId;
                }

                var orgEntity = connection.OrganizationService.Retrieve("organization", info.OrganisationId, new ColumnSet("name"));
                if (orgEntity != null)
                {
                    info.OrganisationName = (string)orgEntity["name"];
                }

                var versionReq      = new RetrieveVersionRequest();
                var versionResponse = (RetrieveVersionResponse)connection.OrganizationService.Execute(versionReq);
                if (versionResponse != null)
                {
                    info.ServerVersion = versionResponse.Version;
                }

                return(info);
            });

            return(connInfo);
        }
예제 #2
0
 public CrmDataAdapter(string selectCommandText, CrmDbConnection connection)
     : base()
 {
     // var dbprovider = DbProviderFactories.GetFactory(CrmAdoConstants.Invariant);
     this.SelectCommand             = new CrmDbCommand(connection, selectCommandText);
     this.SelectCommand.CommandText = selectCommandText;
     this.SelectCommand.Connection  = connection;
 }
예제 #3
0
        public CrmDbCommand(CrmDbConnection connection, IOperationExecutor crmCommandExecutor, ICrmOperationProvider organisationCommandProvider)
        {
            if (crmCommandExecutor == null)
            {
                throw new ArgumentNullException("crmCommandExecutor");
            }

            if (organisationCommandProvider == null)
            {
                throw new ArgumentNullException("organisationCommandProvider");
            }

            _DbConnection                = connection;
            _CrmCommandExecutor          = crmCommandExecutor;
            _OrganisationCommandProvider = organisationCommandProvider;
            _CommandType         = CommandType.Text;
            _ParameterCollection = new CrmParameterCollection();
        }
예제 #4
0
 public CrmDbCommand(CrmDbConnection connection, IOperationExecutor crmCommandExecutor)
     : this(connection, crmCommandExecutor, new SqlGenerationCrmOperationProvider())
 {
 }
예제 #5
0
 public CrmDbCommand(CrmDbConnection connection, string commandText)
     : this(connection, CrmOperationExecutor.Instance)
 {
     _CommandText = commandText;
 }
예제 #6
0
 public CrmDbCommand(CrmDbConnection connection)
     : this(connection, string.Empty)
 {
 }
예제 #7
0
 protected ResultSet(CrmDbConnection connection, OrganizationRequest request, List <ColumnMetadata> columnMetadata)
 {
     _Connection    = connection;
     _OrgRequest    = request;
     ColumnMetadata = columnMetadata;
 }
예제 #8
0
 public EntityMetadataResultSet(CrmDbConnection connection, OrganizationRequest request, List <ColumnMetadata> columnMetadata)
     : base(connection, request, columnMetadata)
 {
 }
예제 #9
0
 public CrmDbTransaction(CrmDbConnection connection)
 {
     _Connection     = connection;
     _IsolationLevel = IsolationLevel.ReadCommitted;
 }