private static IEntityServices SetupConnection(int connectionId, string domainName) { ConnectionDto connection; using (var db = new TenantDb(ConnectionString.ForDomain(domainName))) { var conn = db.Connections.Single(x => x.ConnectionId == connectionId && x.IsActive); connection = new ConnectionDto { ConnectionId = conn.ConnectionId, Url = conn.Url.Trim(), UserName = conn.UserName.Trim(), Password = conn.Password.Trim() }; } IAuthenticator authenticator = new Authentication(); IOrganizationService organizationService = authenticator.Authenticate(new AuthenticationInformation { OrganizationUri = connection.Url, UserName = connection.UserName, Password = connection.Password }); IEntityServices entityService = new EntityServices(organizationService); return entityService; }
public ConnectionDto GetConnectionById(string domainName, int connectionId) { using (var db= new TenantDb(ConnectionString.ForDomain(domainName))) { var cnx = db.Connections .Single(x => x.ConnectionId == connectionId && x.IsActive); var connection = new ConnectionDto { ConnectionId = cnx.ConnectionId, Name = cnx.Description, ConnectionType = cnx.ConnectionType, UserName = cnx.UserName, Password = cnx.Password, Url = cnx.Url, ValidationStatus = cnx.ValidationStatus, ValidationMessage = cnx.ValidationMessage, IsActive = cnx.IsActive }; return connection; } }
public void SaveConnection(ApplicationContext context, ConnectionDto connection) { using (var db=new TenantDb(ConnectionString.ForDomain(context.TenantDomainName))) { var conn = new Connection { Description = connection.Name, ConnectionType = connection.ConnectionType, UserName = connection.UserName, Password = connection.Password, Url = connection.Url, ValidationStatus = connection.ValidationStatus, ValidationMessage = connection.ValidationMessage ?? String.Empty, CreatedOn = DateTime.Now, CreatedBy = context.UserId, ModifiedBy = context.UserId, ModifiedOn = DateTime.Now, IsActive = true }; db.Connections.Add(conn); db.SaveChanges(); } }
public HttpResponseMessage SaveConnection(ConnectionDto connection) { ConnectionService.SaveConnection(Context, connection); return Request.CreateResponse(HttpStatusCode.OK); }