Skip to content

Commit 08d78bb

Browse files
committed
OMERO reconnect.
1 parent f3746ca commit 08d78bb

2 files changed

Lines changed: 28 additions & 14 deletions

File tree

BioLib.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
<PackageIcon>banner.jpg</PackageIcon>
1212
<PackageReadmeFile>README.md</PackageReadmeFile>
1313
<RepositoryUrl>https://github.com/BiologyTools/BioLib</RepositoryUrl>
14-
<AssemblyVersion>3.4.0</AssemblyVersion>
15-
<FileVersion>3.4.0</FileVersion>
16-
<PackageVersion>3.4.0</PackageVersion>
14+
<AssemblyVersion>3.4.1</AssemblyVersion>
15+
<FileVersion>3.4.1</FileVersion>
16+
<PackageVersion>3.4.1</PackageVersion>
1717
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>
1818
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
1919
<PackageProjectUrl>https://biologytools.github.io/</PackageProjectUrl>
2020
<PackageTags>Biology; ImageJ; Bio-Formats; OMERO; Image-Stacks; Microscopy; Whole-Slide-Image; QuPath; </PackageTags>
21-
<PackageReleaseNotes>Added OMERO server support.</PackageReleaseNotes>
21+
<PackageReleaseNotes>Added reconnection code for OMERO server connection.</PackageReleaseNotes>
2222
<Authors>Erik Repo</Authors>
2323
<Platforms>AnyCPU;x64</Platforms>
2424
</PropertyGroup>

Source/OMERO.cs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,23 @@ private static void Init()
9090
}
9191
public static void ReConnect()
9292
{
93-
client = new client(host, port);
94-
session = client.createSession(username, password);
95-
// Initialize OMERO client and gateway
96-
gateway = new Gateway(new SimpleLogger());
97-
LoginCredentials credentials = new LoginCredentials();
98-
credentials.getServer().setHostname(host);
99-
credentials.getServer().setPort(port);
100-
credentials.getUser().setUsername(username);
101-
credentials.getUser().setPassword(password);
102-
experimenter = gateway.connect(credentials);
93+
if (!gateway.isConnected())
94+
{
95+
client = new client(host, port);
96+
session = client.createSession(username, password);
97+
// Initialize OMERO client and gateway
98+
gateway = new Gateway(new SimpleLogger());
99+
LoginCredentials credentials = new LoginCredentials();
100+
credentials.getServer().setHostname(host);
101+
credentials.getServer().setPort(port);
102+
credentials.getUser().setUsername(username);
103+
credentials.getUser().setPassword(password);
104+
experimenter = gateway.connect(credentials);
105+
}
103106
}
104107
public static BioImage GetImage(string filename, long dataset)
105108
{
109+
ReConnect();
106110
try
107111
{
108112
BioImage b = new BioImage("test.ome.tif");
@@ -347,6 +351,7 @@ public static BioImage GetImage(long id)
347351
}
348352
public static Bitmap GetTile(BioImage b, ZCT coord, int x, int y, int width, int height, int level)
349353
{
354+
ReConnect();
350355
var itr = images.iterator();
351356
java.util.List li = new java.util.ArrayList();
352357
java.util.ArrayList imgs = new java.util.ArrayList();
@@ -382,6 +387,7 @@ public static Bitmap GetTile(BioImage b, ZCT coord, int x, int y, int width, int
382387
}
383388
public static Dictionary<long,Pixbuf> GetThumbnails(string[] filenames, int width, int height)
384389
{
390+
ReConnect();
385391
Dictionary<long, Pixbuf> dict = new Dictionary<long, Pixbuf>();
386392
try
387393
{
@@ -423,6 +429,7 @@ public static Dictionary<long,Pixbuf> GetThumbnails(string[] filenames, int widt
423429
}
424430
public static string GetNameFromID(long id)
425431
{
432+
ReConnect();
426433
return browsefacil.getImage(sc, id).getName();
427434
}
428435
private static PixelFormat GetPixelFormat(int bits)
@@ -442,6 +449,7 @@ private static PixelFormat GetPixelFormat(int bits)
442449
}
443450
public static List<string> GetAllFiles()
444451
{
452+
ReConnect();
445453
var meta = session.getMetadataService();
446454
var uims = browsefacil.getUserImages(sc);
447455
List<string> files = new List<string>();
@@ -455,6 +463,7 @@ public static List<string> GetAllFiles()
455463
}
456464
public static List<string> GetDatasets()
457465
{
466+
ReConnect();
458467
var d = browsefacil.getDatasets(sc);
459468
var itr = d.iterator();
460469
List<string> dbs = new List<string>();
@@ -467,6 +476,7 @@ public static List<string> GetDatasets()
467476
}
468477
public static List<DatasetData> GetDatasetsData()
469478
{
479+
ReConnect();
470480
var d = browsefacil.getDatasets(sc);
471481
var itr = d.iterator();
472482
List<DatasetData> dbs = new List<DatasetData>();
@@ -479,6 +489,7 @@ public static List<DatasetData> GetDatasetsData()
479489
}
480490
public static List<string> GetFolders()
481491
{
492+
ReConnect();
482493
var d = browsefacil.getFolders(sc);
483494
var itr = d.iterator();
484495
List<string> dbs = new List<string>();
@@ -490,6 +501,7 @@ public static List<string> GetFolders()
490501
}
491502
public static List<string> GetDatasetFiles(string db)
492503
{
504+
ReConnect();
493505
var d = browsefacil.getDatasets(sc);
494506
var itr = d.iterator();
495507
while (itr.hasNext())
@@ -514,6 +526,7 @@ public static List<string> GetDatasetFiles(string db)
514526
}
515527
public static List<string> GetDatasetFiles(long dbid)
516528
{
529+
ReConnect();
517530
var d = browsefacil.getDatasets(sc);
518531
var itr = d.iterator();
519532
while (itr.hasNext())
@@ -538,6 +551,7 @@ public static List<string> GetDatasetFiles(long dbid)
538551
}
539552
public static List<long> GetDatasetIds(long dbid)
540553
{
554+
ReConnect();
541555
var d = browsefacil.getDatasets(sc);
542556
var itr = d.iterator();
543557
while (itr.hasNext())

0 commit comments

Comments
 (0)