Skip to content

Instantly share code, notes, and snippets.

@talSas
Created November 29, 2021 11:07
Show Gist options
  • Save talSas/b7be4239d427b0f13ccdbcc63645cf43 to your computer and use it in GitHub Desktop.
Save talSas/b7be4239d427b0f13ccdbcc63645cf43 to your computer and use it in GitHub Desktop.
Custom GetAllMember Methode
public class RStabConnection
{
public EndpointAddress Address { get; set; } = new EndpointAddress("http://localhost:8081");
private BasicHttpBinding Binding;
private RstabApplicationClient applicationClient;
private RstabModelClient rstab9ModelClient;
private readonly int maxObjectNumber = 1000000;// rstab & rfem dont allow more than 1kk objects
public RStabConnection()
{
Binding = new BasicHttpBinding
{
// Send timeout is set to 60 seconds.
SendTimeout = new TimeSpan(0, 0, 60),
UseDefaultWebProxy = true,
};
try
{
applicationClient = new RstabApplicationClient(Binding, Address);
string modelUrl = applicationClient.get_active_model();
ConnectToModel(modelUrl);
}
catch (Exception exception)
{
Console.WriteLine("Error");
}
}
private bool ConnectToModel(string modelUrl)
{
try
{
rstab9ModelClient = new RstabModelClient(Binding, new EndpointAddress(modelUrl));
return true;
}
catch
{
return false;
}
}
public member[] GetAllMember()
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
int memberCount = rstab9ModelClient.get_object_count(object_types.E_OBJECT_TYPE_MEMBER, 0);
member[] memberList = new member[memberCount];
int counter = 1;
int arrayIndex = 0;
while (counter < memberCount && counter < maxObjectNumber)
{
try
{
member member = rstab9ModelClient.get_member(counter);
memberList[arrayIndex] = member;
arrayIndex++;
}
catch
{
//donothing
}
counter++;
}
stopwatch.Stop();
Debug.WriteLine(stopwatch.ElapsedMilliseconds);
return memberList;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment