Hi
if you want to write csharp and mumps, it's easier then ever
i have made some changes to the RPCBroker in order to bypass all of the Vista mechanism of registering Options and routines. you just have to write the routine and call it. no need to mess with vista Fileman
you can read about it here on the wiki page of the CsharpToMumps project on
sourceforge.net
https://sourceforge.net/p/csharptomumps/wiki/changes%20to%20the%20broker/
or simply here :
In the previous pages i have explained how to set up the client and server and atart to write in mumps and c#. but as i explained it's a bit tedious to register routines at the vista server due to mechanism of the vista. if you want to skip this mechanism you can make minor changes to the broker and bypass all of this security.
here is how :
open the routine XWBPRS.m and subtitue this code on the RPC() label with this code :
RPC() ;Check the rpc information.
;M Extrinsic Function
;Outputs
;ERR 0 for success, "-1^Text" if error
;
N C,DR,ERR,M,R,RPC,T,X
S R=2,C=";",ERR=0,M=512 ;Max buffer
S RPC=$G(XWB(R,"RPC")) I '$L(RPC) Q "-1^No RPC sent"
I RPC["XUS" D
.S T=$O(^XWB(8994,"B",RPC,0))
.;S ^TEMP($H)="T : "T"RPC : "RPC ;GUY
.I '+T Q "-1^Remote Procedure '"_RPC"' doesn't exist on the server."
.S T(0)=$G(^XWB(8994,T,0))
.I $P(T(0),U,6)=1!($P(T(0),U,6)=2) Q "-1^Remote Procedure '"RPC"' cannot be run at this time." ;P10. Check INACTIVE field. - dpc.
. S XWB(R,"RTAG")=$P(T(0),"^",2)
. S XWB(R,"RNAM")=$P(T(0),"^",3)
. S XWBPTYPE=$P(T(0),"^",4)
. S XWBWRAP=+$P(T(0),"^",8)
E D
. S ^TEMP($H)="IN PART 2"_" RPC "_RPC
. S XWB(R,"RTAG")=$P(RPC,"^",2)
. S XWB(R,"RNAM")=$P(RPC,"^",1)
. S XWBPTYPE=$P(RPC,"^",3)
. S XWBWRAP=$P(RPC,"^",4)
Q ERR
open the XWBSEC.m and change lines as i did here. lines which i changed i marked with the woed GUY.
XWBSEC ;SFISC/VYD,MSC/JDA - RPC BROKER ;06AUG2009
;;1.1;RPC BROKER;3,6,10,35,MSC;Mar 28, 1997
CHKPRMIT(XWBRP) ;checks to see if remote procedure is permited to run
;Input: XWBRP - Remote procedure to check
QUIT ; GUY
Q:$$KCHK^XUSRB("XUPROGMODE")
N ERR,XWBPRMIT,XWBALLOW
S U="^",XWBSEC="" ;Return XWBSEC="" if OK to run RPC
;
;In the beginning, when no DUZ is defined and no context exist, setup
;default signon context
I '$G(DUZ) S DUZ=0,XQY0="XUS SIGNON" D CRCONTXT(.ERR,$$ENCRYP^XUSRB1(XQY0)) ;set up default context
;
;These RPC's are allowed in any context, so we can just quit
I "^XWB IM HERE^XWB CREATE CONTEXT^XWB RPC LIST^XWB IS RPC AVAILABLE^XUS GET USER INFO^XUS GET TOKEN^"[(U_XWBRP_U) Q
;VistAlink RPC's that are always allowed.
I "^XUS KAAJEE GET USER INFO^XUS KAAJEE LOGOUT^"[(U_XWBRP_U) Q
;
;If in Signon context, only allow XUS and XWB rpc's
I $G(XQY0)="XUS SIGNON","^XUS^XWB^"'[(U_$E(XWBRP,1,3)U) S XWBSEC="Application context has not been created!" Q
;XQCS allows all users access to the XUS SIGNON context.
;Also to any context in the XUCOMMAND menu.
;
I $G(XQY0)'="" D ;1.1*6. XQY0="" after XUS SIGNON context deleted.
. S XWBALLOW=$$CHK^XQCS(DUZ,$P(XQY0,U),XWBRP) ;do the check
. S:'XWBALLOW XWBSEC=XWBALLOW
E S XWBSEC="Application context has not been created!"
Q
;
;
CRCONTXT(RESULT,OPTION) ;creates context for the passed in option
K XQY0,XQY N XWB1,XABPGMOD,XWBPGMOD S RESULT=0
S OPTION=$$DECRYP^XUSRB1(OPTION) ;S:OPTION="" OPTION="\"
I OPTION="" S XQY=0,XQY0="",RESULT=1 K ^TMP("XQCS",$J) Q ;delete context if "" passed in.
S XWB1=$$OPTLK^XQCS(OPTION)
I XWB1="" S (XWBSEC,RESULT)="The context '"_OPTION"' does not exist on server." Q ;P10
S RESULT=$$CHK^XQCS(DUZ,XWB1)
;Access or programmer
S XWBPGMOD=$$KCHK^XUSRB("XUPROGMODE")
;---GUY
; COMMA BY GUY I RESULT!XWBPGMOD S XQY0=OPTION,XQY=XWB1,RESULT=1
S XQY0=OPTION,XQY=XWB1,RESULT=1
; COMMA BY GUY E S XWBSEC=RESULT
;---
Q
;
;
STATE(%) ;Return a state value
Q:'$L($G(%)) $G(XWBSTATE)
Q $G(XWBSTATE(%))
;
;
SET(%,VALUE) ;Set the state variable
I $G(%)="" S XWBSTATE=VALUE
S XWBSTATE(%)=VALUE
Q
KILL(%) ;Kill state variable
I $L($G(%)) K XWBSTATE(%)
Q
now if you want to call the procedure TEST1 ON THE routine MYTEST you can do it like that :
public string test(Hashtable arrivals)
{
DConnection.DConnection dc = DConnection.DConnection.GetInstance();
//next 2 lines are commas guy 17/03
//string context = "MYTEST";
//string res = dc.Mdc.CallRPC("XWB CREATE CONTEXT",
//RpcFormatter.FormatArgs(false, Cypher.Encrypt(context)));
;
//MYTEST - program name
//TEST1 - THE LABEL ON THE PROGRAM (ROUTINE NAME)
// 2 - ROUTINE RETURNS ARRAY
// 0 - WORD WRAP - DIDN'T FIGURE YET WHAT IT IS
string res = dc.Mdc.CallRPC("MYTEST^TEST1^2^0", RpcFormatter.FormatArgs(false, arrivals));
return res;
}
and the routine test on the server looks like that :
MYTEST ;
Q
TEST1(RES,ARRAY) ;
S ^TEMP($H,1)=$H_"^"$G(ARRAY("CLINIC"))
S ^TEMP($H,2)=$H"^"_$G(ARRAY("CLINIC"))
S RES(1)="RETURN"
Q
and you don't have to configure anything on the server !