public override object GetProperty(HP.HPTRIM.SDK.TrimObject tmo, HP.HPTRIM.SDK.Database database, IMainObjectRequest request) { return(new TrimStringProperty() { Value = string.Format("test - {0}", DateTime.Now) }); }
public void Dispose(bool disposing) { if (disposing) { if (!_isDisposed) { if (null != _trimDatabase) { if (_trimDatabase is SDK.Database) { try { _trimDatabase.Dispose(); _trimDatabase = null; } catch { throw; } } else { throw new Exception(string.Format("Attempting to dispose: {0}.", _trimDatabase.GetType().Name)); } } _isDisposed = true; } } }
public override object GetProperty(HP.HPTRIM.SDK.TrimObject tmo, HP.HPTRIM.SDK.Database database, IMainObjectRequest request) { HP.HPTRIM.SDK.Record record = tmo as HP.HPTRIM.SDK.Record; HP.HPTRIM.SDK.Location closestLocation = null; double lastDistanceTo = 0; if (record != null) { if (!string.IsNullOrEmpty(record.GpsLocation)) { GeoCoordinate coord; if (tryGetCoordinate(record.GpsLocation, out coord)) { HP.HPTRIM.SDK.TrimMainObjectSearch search = new HP.HPTRIM.SDK.TrimMainObjectSearch(database, HP.HPTRIM.SDK.BaseObjectTypes.Location); search.SetSearchString($"locGps:within 5 kilometres of record {record.Uri} and type:ProjectTeam"); foreach (HP.HPTRIM.SDK.Location location in search) { GeoCoordinate locationCoord; if (tryGetCoordinate(location.GpsLocation, out locationCoord)) { if (closestLocation == null) { closestLocation = location; lastDistanceTo = locationCoord.GetDistanceTo(coord); } else if (locationCoord.GetDistanceTo(coord) < lastDistanceTo) { closestLocation = location; lastDistanceTo = locationCoord.GetDistanceTo(coord); } } } } } } if (closestLocation != null) { return(closestLocation.ToRefModel(request) as LocationRef); } return(null); }
private void setDatabase(string identity, string wgName, int wgPort, string dbid, string alt_wgName, int alt_wgPort, bool isSingleHop, string remoteIp) { _trimDatabase = new Database() { Id = dbid, WorkgroupServerName = wgName, WorkgroupServerPort = wgPort, IsSingleHopClient = isSingleHop }; if (!string.IsNullOrWhiteSpace(identity)) { _trimDatabase.TrustedUser = identity; if (TrimApplication.ServiceType == ServiceTypes.WebService) { TrimUserOptionSet webclientOption = new TrimUserOptionSet(_trimDatabase, UserOptionSetIds.WebClient); string timeZone = webclientOption.GetPropertyString(PropertyIds.WebClientUserOptionsTimezone); if (!string.IsNullOrEmpty(timeZone)) { try { _trimDatabase.SetTimezoneString(timeZone); } catch { // if an invalid time zone is set we do not want an exception as that would stop the user fixing the time-zone // _log.WarnFormat("Invalid timezone ({0}) set by {1}", timeZone, identity); } } } // this allows the users IP address to be logged in the WGS log if (!string.IsNullOrEmpty(remoteIp)) { _trimDatabase.ClientIPAddress = remoteIp; } } if (!string.IsNullOrEmpty(alt_wgName)) { _trimDatabase.AlternateWorkgroupServerName = alt_wgName; _trimDatabase.AlternateWorkgroupServerPort = alt_wgPort; } if (_trimDatabase.IsValid) { //Now that all the properties have been established, attempt to connect to the database _trimDatabase.Connect(); if (!_trimDatabase.IsConnected) { throw new DatabaseConnectException("Database failed to connect. " + _trimDatabase.ErrorMessage); } } else { throw new DatabaseConnectException("Unable to connect to database. " + _trimDatabase.ErrorMessage); } }
public override object GetProperty(HP.HPTRIM.SDK.TrimObject tmo, HP.HPTRIM.SDK.Database database, IMainObjectRequest request) { return(RegisterFileService.getCommandDefs(tmo as HP.HPTRIM.SDK.Record)); }