Accessing a SESSION


(Chris Conn) #1

What is the proper way to access a SESSION object?

I’ve read articles saying:
Ice.Core.Session SOSession: The type or namespace name ‘Session’ does not exist in the namespace ‘Ice.Core’ (are you missing an assembly reference?)

((Mfg.Core.Session)oTrans.Session).UserName : Error CS0234: The type or namespace name ‘Mfg’ does not exist in the namespace ‘Epicor’ (are you missing an assembly reference?)

I am starting to think I maybe be missing an assembly reference lol.

The interesting thing is that I swear I’ve done this before with no issue in a Customization, but I am having issues within a BPM.


(Jose C Gomez) #2

Within a BPM you shouldn’t need the session. You have the Db object context and the callContextClient. What do you need from the session on a BPM?


Get Server Name or Database in BPM C#
(Chris Conn) #3

Which DB I am operating in. I.E Test or Live


(Jose C Gomez) #4

this.Session.AppServerURL should work within a BPM


(Chris Conn) #5

Really!!! this.Session with no casting… lol, boy do I feel silly


(Bart Elia) #6

I can make it harder if you want but I might get lynched :wink:

Let me know if you have issues with it. There are a few advanced gymnastics in there possible when we will need that in the core app. Still waiting to see if people stumble into them in the wild :wink:


(Chris Conn) #7

It seems the AppServerURL var is empty :frowning:

Really wishing my IT would get me access to remote debugging already :cry:


(Jose C Gomez) #8

Works for Me @Chris_Conn
What Method are you running this on? Mine works fine


(Chris Conn) #9

Running this on a data directive for SYS_TASK table - alerts me by email when MRP starts/stops

String serv = this.Session.AppServerURL ;
message.Body = "<h1>MRP started in Camden: "+serv+"</h1><BR>MRP Started by "+user+" on "+start+"<BR>Please wait before using any MRP suggestions until the task has completed. You will be notified on completion.";

Also, if you keep blanking out your server address how the hell am I supposed to target you for attacks? :stuck_out_tongue_winking_eye:


(Chris Conn) #10

Waiting on @Bart_Elia to save the day with some (NON-RESTFUL) secret code lol


(Bart Elia) #11

Sorry folks, this place is an after hours hang out in the lazy boy and I’ve had too many honey do’s with the holidays fast approaching. I have not forgotten you. I’ll see what I can determine about this URL property. It’s one of the few I have not added personally.


(Bart Elia) #12

It looks like that session property is only set when called by a ‘Rich Client’ - The Shell or EWA base clients. It’s actually used for BPM on the client.
Can I brainstorm a work around with you? What are you trying to accomplish where you need this Url?


(Jose C Gomez) #13

He’s trying to identify the current instance within a BPM for conditional logic
Pilot, vs Prod etc
I came up with a work around using DB_NAME() but that can open up a whole can of worms in the wrong hands so I won’t post the example here. Don’t want shoot yourself in the foot syndrome.
Maybe you have a better idea


(Joshua Giese) #14

I have that in a few of mine. I read the database connection string to determine path based on which I’m hitting.

Joshua Giese
CTO
920.437.6400 x342
Wisconsin Converting Inc.


Get Server Name
(Bart Elia) #15

Oh! If you just need the machine name?

System.Environment.MachineName
or
System.Net.Dns.GetHostName()


(Chris Conn) #16

I appreciate the offer but I got it going with a little assistance.

Would the solution you suggest for DNS hostname work for DBs on the same server? I assume the DNS name would be the same.


(David Arista) #17

Hi @Chris_Conn were you able to fix this? I’m also using the SysTask table to send emails when a process gets an error but when using the Session.APPServerURL the emails are not sent, if I remove it the emails are received.


(Chris Conn) #18

Ah - I remember now, Session.AppServerURL didnt get populated in that context. I dont remember the exact solution but it involved some squirrely code.


(David Arista) #19

Thank you I could resolve it, by doing some additional code.