Beispiel #1
0
 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)
     });
 }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 public override bool IsUsedFor(HP.HPTRIM.SDK.TrimObject tmo, string propName)
 {
     return(tmo is HP.HPTRIM.SDK.Record);
 }
 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));
 }