Example #1
0
        public object RemoteInvoke(string receiver, string serviceObjectName, MethodBase method, params object[] parameters)
        {
            if (receiver == _communicationProxy.GetName())
            {
                return(NativeInvoke(serviceObjectName, method, parameters));
            }
            RemoteMethodInvokeArgument args      = new RemoteMethodInvokeArgument(serviceObjectName, method, parameters);
            BinaryFormatter            formatter = new BinaryFormatter();

            using (MemoryStream outStream = new MemoryStream())
            {
                CommandContext cmdContext = new CommandContext();
                _communicationProxy.GetName();
                formatter.Serialize(outStream, args);
                cmdContext.iCommandId       = COMMUNICATION_ID;
                cmdContext.sReceiver        = receiver;
                cmdContext.sSender          = _communicationProxy.GetName();
                cmdContext.sSerializeObject = outStream.GetBuffer();
                cmdContext.iWaitTime        = WAIT_TIME;
                ISyncResult result = _communicationProxy.SyncSendCommand(cmdContext);
                if (result.GetCallResult() != 0)
                {
                    throw new CommunicationException(result.GetCallResult(), "fail to sync send command to " + receiver);
                }
                using (MemoryStream replyStream = new MemoryStream(result.GetSerializedObject()))
                {
                    return(formatter.Deserialize(replyStream));
                }
            }
        }//EndMethod
Example #2
0
        /// <summary>
        /// send command to sessionmanager to get the dataHead
        /// </summary>
        /// <returns></returns>
        public bool Refresh()
        {
            byte[]         buf     = SessionUtility.RequestCommandProtoBuffer(SessionManagerFuncID.QuerySessionDataID, new ByteString[] { });
            CommandContext context = SessionUtility.CreateCommandContext(CommunicationNode.SystemSessionManager, CommunicationCommandID.XA_SYSTEMSESSION_DATA_CACHE, buf);
            ISyncResult    result  = _systemCommunicationProxy.SyncSendCommand(context);

            CLRLogger.GetInstance().LogDevInfo(string.Format("Commit result:{0},proxyName:{1}", result.GetCallResult().ToString(), _systemCommunicationProxy.GetName()));
            _dataHead = SessionUtility.DeserializeDataHead(result.GetSerializedObject());
            return((0 == result.GetCallResult()) ? true : false);
        }
Example #3
0
        /// <summary>
        /// Get datahead form session manager,this datahead is process's status
        /// </summary>
        public bool Refresh()
        {
            byte[]         buf     = SessionUtility.RequestCommandProtoBuffer(SessionManagerFuncID.QueryProcessStatusID, new ByteString[] { ByteString.CopyFromUtf8(_proxyName) });
            CommandContext context = SessionUtility.CreateCommandContext(CommunicationNode.SystemSessionManager, CommunicationCommandID.XA_SYSTEMSESSION_PROCESS_CACHE, buf);
            ISyncResult    result  = _processCommunicationProxy.SyncSendCommand(context);

            if (0 == result.GetCallResult())
            {
                _dataHead = DicomAttributeCollection.Deserialize(result.GetSerializedObject());
                return(true);
            }
            CLRLogger.GetInstance().LogDevError(string.Format("ProcessCacheProxy Refresh failed, proxyName is {0},GetCallResult is {1}.", _proxyName, result.GetCallResult()));
            return(false);
        }
Example #4
0
        public byte[] SyncSendCommand(int cmdID, string receiver, byte[] content,
                                      uint waitTime = 0, string contentAsString = null)
        {
            CommandContext cmdContext = new CommandContext();

            cmdContext.iCommandId       = cmdID;
            cmdContext.sReceiver        = receiver;
            cmdContext.sSerializeObject = content;
            cmdContext.sStringObject    = contentAsString;
            if (waitTime != 0)
            {
                cmdContext.iWaitTime = waitTime;
            }
            ISyncResult result = _communicationProxy.SyncSendCommand(cmdContext);

            if (result.GetCallResult() != NO_ERROR)
            {
                string msg = string.Format("{0} fails to sync send command with command id = {1}, errorCode = {2}, content = {3}",
                                           _communicationProxy.GetName(), cmdID, result.GetCallResult(), content);
                throw new CommunicationException(result.GetCallResult(), msg);
            }
            return(result.GetSerializedObject());
        }
Example #5
0
        /// <summary>
        /// For local only
        /// </summary>
        //private UIH.XA.XSample.BusinessLogicExcutor.PatientManager TestPatientSource = new BusinessLogicExcutor.PatientManager();



        private byte[] SendSyncToPatientManager(string method, params object[] args)
        {
            CommandContext context = new CommandContext();

            context.iCommandId = BusinessLogicCommand;
            //context.sSender
            context.sReceiver             = BusinessLogicProxyName;
            context.bServiceAsyncDispatch = true;

            PatientRemoteObject rObject = new PatientRemoteObject();

            rObject.InvokeTag = method;
            rObject.Paramters = args;

            context.sSerializeObject = SerializeObj.Serialize(rObject);
            context.iWaitTime        = 30000;


            CLRCommunicationProxy proxy = _appContext.GetObject <ICommunicationProxy>(AppContextObjectName.DefaultCommunicationProxy) as CLRCommunicationProxy;

            ISyncResult result = proxy.SyncSendCommand(context);

            return(result.GetSerializedObject());
        }