Profile.ConnectionState Property Always Shows pjProfileOnline

B

BradleyWard

Hello,

I am developing an add-in for Project Professional 2007 and in that add-in I
need to determine whether the user chose to connect to the backend server
(Project Server 2007) or not. It would seem that the
Application.Profiles.ActiveProfile.ConnectionState should give me exactly
what I want, but I am not seeing it ever give me anything but pjProfileOnline.

Here is how I am determining that:

1. I start Project Professional 2007 by running my add-in project inside
Visual Studio 2007.

2. I have a breakpoint just inside the ThisAddIn_Startup() method so that I
can check the setting of the
Application.Profiles.ActiveProfile.ConnectionState property.

3. I see the Login dialog appear, and I select the desired profile and click
on the OK button to connect to PS2007 on that server.

4. I hit my breakpoint and I check the ConnectionState property and it is
set to pjProfileOnline, as I would expect.

5. I exit Project Professional to end the debug session, then I re-run the
project to start a new debug session.

6. This time, on the Login dialog I hit the Work Offline button.

7. I hit my breakpoint and check the value of the ConnectionState. But it
still has a value of pjProfileOnline, NOT pjProfileOffline as I would expect!

Note that when I turn on the status bar on Project Professional, I see a
"Connected" in the first test scenario and a "Offline" in the 2nd scenario,
which is exactly what I would expect to see. I'm just not seeing that in the
ConnectionState property.

Any ideas?

Thanks
 
J

Jack Dahlgren

Take a look at profiles.activeprofile.name and see if it is set to "Computer"
That should give you information about whether they are connected or not.

-Jack Dahlgren
http://zo-d.com/blog
 
B

BradleyWard

Thanks for the suggestion, Jack.

I ran my add-in in debug mode twice again, once logging on, then once where
I hit the WorkOffline button. In both cases, the ActiveProfile.Name property
was set to the hostname of the server on which Project Server is running.
That piece of data is at least consistent with the fact that ConnectionState
stills shows online. But it is inconsistent with the fact that in the status
bar at the bottom of Project Professional 2007 it correctly shows "Connected"
or "Offline".

I wonder where that server name in the Name property is coming from? As I
understand plug-ins, the very first time I even get any control is when the
ThisAddIn_Startup() method gets called. As you can see from the following
code snippet from that method, I'm not doing much of anything before I check
these two properties! Very strange...

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
string msg;

s_app = Application;

m_isOnline = false;

try
{
MSProject.Profile profile = s_app.Profiles.ActiveProfile;

string name = profile.Name;

MSProject.PjProfileConnectionState connState =
profile.ConnectionState;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top