Exemplo n.º 1
0
        public ChannelProcessResult ProcessSubscriberMessage(MessagePackage message)
        {
            if (MessageEntryHelper.MatchEntryCriteria(_param, message, _config.EntryControl))
            {
                if (_pipeLine.Process(message))
                {
                    string  msgXml = message.GetMessageXml();
                    Message msg    = XObjectManager.CreateObject <Message>(msgXml);
                    if (msg == null)
                    {
                        return(ChannelProcessResult.ProcessingError);
                    }

                    msg.Header.ID   = Guid.NewGuid();
                    msg.Header.Type = _config.PublishMessageType;

                    if (_param.Sender.NotifyMessagePublish(msg))
                    {
                        return(ChannelProcessResult.Success);
                    }
                    else
                    {
                        return(ChannelProcessResult.SendingError);
                    }
                }
                else
                {
                    return(ChannelProcessResult.ProcessingError);
                }
            }
            else
            {
                return(ChannelProcessResult.NotMatchEntryCriteria);
            }
        }
Exemplo n.º 2
0
        //internal bool XSLTTransform(string sourceXml, ref string targetXml, string xsltFileName, bool enableExtension)
        //{
        //    string xslFile = ConfigHelper.GetFullPath(Program.AppArgument.ConfigFilePath, xsltFileName);
        //    XMLTransformer it = XMLTransformer.CreateFromFileWithCache(xslFile, Program.Log, enableExtension);
        //    return it.TransformString(sourceXml, ref targetXml, enableExtension ? XSLTExtensionTypes.XmlNodeTransformer : XSLTExtensionTypes.None);
        //}

        internal bool XSLTTransform(string sourceXml, ref string targetXml, string xsltFileName, bool enableExtension)
        {
            string         xslFile = ConfigHelper.GetFullPath(_contextForTemplate2.AppArgument.ConfigFilePath, xsltFileName);
            XMLTransformer it      = XMLTransformer.CreateFromFileWithCache(xslFile, _contextForTemplate2.Log, enableExtension);

            Message sourceMsg = new Message();

            sourceMsg.Body = sourceXml;

            string targetMsgXml = null;
            string sourceMsgXml = sourceMsg.ToXMLString();
            bool   res          = it.TransformString(sourceMsgXml, ref targetMsgXml, enableExtension ? XSLTExtensionTypes.XmlNodeTransformer : XSLTExtensionTypes.None);

            if (res)
            {
                Message targetMsg = XObjectManager.CreateObject <Message>(targetMsgXml);
                if (targetMsg != null)
                {
                    targetXml = targetMsg.Body;
                }
                else
                {
                    _contextForTemplate2.Log.Write(LogType.Error, "Cannot parse xml string to message object. \r\n" + targetMsgXml);
                    res = false;
                }
            }

            return(res);
        }
Exemplo n.º 3
0
        /// <summary>
        /// In order to support including multiple XSLT files in the XSLT script,
        /// we disable the external extension (e.g. calling C# code from XSLT) currently.
        /// </summary>
        /// <param name="sourceMsg"></param>
        /// <param name="targetMsg"></param>
        /// <param name="rootFolderPath"></param>
        /// <param name="log"></param>
        /// <returns></returns>
        public bool TransformMessage(Message sourceMsg, out Message targetMsg, string rootFolderPath, ILog log)
        {
            targetMsg = null;
            if (sourceMsg == null)
            {
                return(false);
            }

            string xslFilePath = XSLTFileLocation;

            if (!Path.IsPathRooted(xslFilePath))
            {
                xslFilePath = Path.Combine(rootFolderPath, xslFilePath);
            }
            XMLTransformer t = XMLTransformer.CreateFromFileWithCache(xslFilePath, log, EnableXSLTExtension);

            if (t == null)
            {
                return(false);
            }

            string targetString = null;
            string sourceString = sourceMsg.ToXMLString();

            if (!t.TransformString(sourceString, ref targetString, XSLTExtensionTypes.None) ||
                string.IsNullOrEmpty(targetString))
            {
                return(false);
            }

            targetMsg = XObjectManager.CreateObject <Message>(targetString);
            return(targetMsg != null);
        }
Exemplo n.º 4
0
        private MSG.Message TransformToCSBDataSetSchemedXDSGWMessage(MSG.Message msg, string msgID)
        {
            if (!_entity.Context.ConfigMgr.Config.EnableXMLTransform)
            {
                return(msg);
            }

            _entity.Context.Log.Write("Begin transforming XDSGW message.");
            string         file = ConfigHelper.GetFullPath(_entity.Context.AppArgument.ConfigFilePath, _entity.Context.ConfigMgr.Config.XSLTFilePath);
            XMLTransformer t    = XMLTransformer.CreateFromFileWithCache(file, _entity.Context.Log);

            if (t == null)
            {
                return(null);
            }

            string csbMsgXml   = "";
            string otherMsgXml = msg.ToXMLString();

            if (!t.TransformString(otherMsgXml, ref csbMsgXml, XSLTExtensionTypes.None))
            {
                return(null);
            }

            MSG.Message csbMsg = XObjectManager.CreateObject <MSG.Message>(csbMsgXml);
            if (csbMsg == null)
            {
                _entity.Context.Log.Write(LogType.Error, "Cannot deserialize the transformed XML into XDSGW message.");
                string fname = string.Format("{0}_transformed", msgID);
                DumpErrorMessage(csbMsgXml, fname);
            }

            _entity.Context.Log.Write("Finish transforming XDSGW message.");
            return(csbMsg);
        }
Exemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            string str = _rcvCtrl.GetXmlString();
            HL7    msg = XObjectManager.CreateObject <HL7>(str);

            MessageBox.Show(this, msg.ToXMLString());
        }
Exemplo n.º 6
0
        public static DElementList OpenXmlFile(string fileName)
        {
            try
            {
                if (!File.Exists(fileName))
                {
                    return(null);
                }

                string strXml = "";
                using (StreamReader sr = File.OpenText(fileName))
                {
                    strXml = sr.ReadToEnd();
                }

                DElementList list = XObjectManager.CreateObject(strXml, typeof(DElementList)) as DElementList;
                if (list != null)
                {
                    list.FillDicomCollection();
                }
                return(list);
            }
            catch (Exception err)
            {
                LogMgt.Logger.Write(err.ToString());
                return(null);
            }
        }
Exemplo n.º 7
0
        private static void Test_Message()
        {
            HYS.Messaging.Objects.Message msg = new HYS.Messaging.Objects.Message();

            msg.Reference = new MessageReference();
            //msg.Reference.FileList = new XCollection<MessageReferenceFile>("File");
            //msg.Reference.FileList = new XCollection<MessageReferenceFile>();
            msg.Reference.FileList.Add(new ReferenceFile());
            msg.Reference.FileList.Add(new ReferenceFile());

            msg.Reference.FileList[0].Name     = "name test";
            msg.Reference.FileList[1].Location = "location test";

            msg.Body = "aaaaa";
            //msg.Body = "aa<aaa";

            string xml = msg.ToXMLString();

            MessageBox.Show(xml);

            HYS.Messaging.Objects.Message msg1 = XObjectManager.CreateObject <HYS.Messaging.Objects.Message>(xml);
            MessageBox.Show(msg1.ToXMLString());

            xml = msg.Reference.FileList.ToXMLString();
            MessageBox.Show(xml);

            //XCollection<MessageReferenceFile> list = XObjectManager.CreateObject<XCollection<MessageReferenceFile>>(xml);
            //MessageBox.Show(list.ToXMLString());

            ReferenceFileCollection list = XObjectManager.CreateObject <ReferenceFileCollection>(xml);

            MessageBox.Show(list.ToXMLString());
        }
Exemplo n.º 8
0
        private void buttonGenerate_Click(object sender, EventArgs e)
        {
            string xml = _ctrlCSBMsg.GetXmlString();

            if (string.IsNullOrEmpty(xml))
            {
                return;
            }

            MSG.Message msg = XObjectManager.CreateObject <MSG.Message>(xml);
            if (msg == null)
            {
                MessageBox.Show(this, "Deserialize CSB DataSet Message failed. See the log file for details.", this.Text);
                return;
            }

            try
            {
                DataSet     ds = new DataSet();
                XmlReadMode m  = ds.ReadXml(XmlReader.Create(new StringReader(msg.Body)));
                this.dataGridViewDS.DataSource = ds.Tables[0];
            }
            catch (Exception err)
            {
                Program.Context.Log.Write(err);
                MessageBox.Show(this, "Deserialize DataSet XML failed. See the log file for details.\r\n\r\nMessage: " + err.Message, this.Text);
            }
        }
Exemplo n.º 9
0
        public bool Initialize(ProcessorInitializationParameter parameter)
        {
            if (parameter == null) return false;

            _param = parameter;
            _config = XObjectManager.CreateObject<XSLTConfig>(parameter.ConfigXmlString);

            if (_config == null)
            {
                WriteLog(LogType.Error, "Deserialize configuration object failed.");
                return false;
            }

            try
            {
                string XSLTFile = _param.GetFullPath(_config.XSLTFileName);

                xslt = new XslCompiledTransform();
                xslt.Load(XSLTFile);
            }catch(Exception ex)
            {
                _param.Log.Write(ex);
                return false;
            }
            return true;
        }
Exemplo n.º 10
0
 public void Load()
 {
     using (StreamReader sr = File.OpenText(_FileName))
     {
         string str = sr.ReadToEnd();
         _Rule = XObjectManager.CreateObject(str, _ruleType) as RuleBase <TC, TR>;
     }
 }
Exemplo n.º 11
0
        public bool ProcessMessage(MessagePackage message)
        {          

            try
            {
                string xmlString;
                try
                {                    
                    Message msg = XObjectManager.CreateObject<Message>(message.GetMessageXml());
                    TextReader tr = new StringReader(msg.Body);
                    //XmlDocument doc = new XmlDocument();
                    //doc.LoadXml(msg.Body);
                    //XPathDocument doc = new XPathDocument(tr);
                    Stream tmpS = new MemoryStream();
                    XmlWriter xw = new XmlTextWriter(tmpS, null);
                    //XPathNavigator nav = doc.CreateNavigator();

                    try
                    {
                        xslt.Transform(XmlReader.Create(tr), xw);
                        xw.Flush();
                        tmpS.Position = 0;

                        StreamReader sr = new StreamReader(tmpS);

                        xmlString = sr.ReadToEnd();
                        sr.Close();
                    }
                    catch (Exception ex)
                    {
                        throw (ex);
                    }
                    finally
                    {
                        xw.Close();
                        tmpS.Close();
                    }

                    msg.Body = xmlString;
                    message.SetMessageXml(msg.ToXMLString(), _config.DeviceName);
                }
                catch (Exception ee)
                {
                    _param.Log.Write(LogType.Error, "Get error while transforming XML, " + ee.Message);
                                       
                    return false;
                }

                               
                
                return true;
            }
            catch (Exception e)
            {
                WriteLog(e);
                return false;
            }
        }
Exemplo n.º 12
0
        public override bool SendMessage(Message request, out Message response)
        {
            response = null;

            if (request == null || request.Header == null)
            {
                _log.Write(LogType.Error, "RPCPullSender cannot send NULL message or message without header.");
                return(false);
            }

            string strReq = request.ToXMLString();

            _log.Write(string.Format("RPCPullSender sending requesting message id {0} via {1}",
                                     request.Header.ID.ToString(), Channel.RPCConfig.URI));

            try
            {
                bool   res    = false;
                string strRsp = null;

                IRPCPullService client = _factory.CreateChannel();
                using (client as IDisposable)
                {
                    res = client.ProcessMessage(strReq, out strRsp);
                }

                if (!res)
                {
                    _log.Write(LogType.Error,
                               string.Format("RPCPullSender receive process failed from the responser entity via {0}",
                                             Channel.RPCConfig.URI));
                    return(false);
                }
                else
                {
                    response = XObjectManager.CreateObject <Message>(strRsp);
                    if (response == null || response.Header == null)
                    {
                        _log.Write(LogType.Error,
                                   string.Format("RPCPullSender receive responsing NULL message or message without header via {0}",
                                                 Channel.RPCConfig.URI));
                        return(false);
                    }
                    else
                    {
                        _log.Write(string.Format("RPCPullSender receive responsing message id {0} via {1}",
                                                 response.Header.ID.ToString(), Channel.RPCConfig.URI));
                    }
                }

                return(true);
            }
            catch (Exception err)
            {
                _log.Write(err);
                return(false);
            }
        }
Exemplo n.º 13
0
 public static T GetMessageContent <T>(string msgContent)
     where T : XBase
 {
     if (msgContent == null || msgContent.Length < 1)
     {
         return(null);
     }
     return(XObjectManager.CreateObject <T>(msgContent));
 }
Exemplo n.º 14
0
        public static DElementList CreateFromXml(string xmlString)
        {
            DElementList list = XObjectManager.CreateObject(xmlString, typeof(DElementList)) as DElementList;

            if (list != null)
            {
                list.FillDicomCollection();
            }
            return(list);
        }
Exemplo n.º 15
0
        public static HYS.IM.Messaging.Objects.Message GetMessage(System.Messaging.Message msg)
        {
            if (msg == null)
            {
                return(null);
            }

            string xml = msg.Body.ToString();

            return(XObjectManager.CreateObject <HYS.IM.Messaging.Objects.Message>(xml));
        }
Exemplo n.º 16
0
        private static DeviceDir _LoadDeviceDir(string deviceFolder)
        {
            string fname = deviceFolder + "\\" + DeviceDirManager.IndexFileName;

            using (StreamReader sr = File.OpenText(fname))
            {
                string    xmlstr = sr.ReadToEnd();
                DeviceDir dir    = XObjectManager.CreateObject(xmlstr, typeof(DeviceDir)) as DeviceDir;
                return(dir);
            }
        }
Exemplo n.º 17
0
        private static void Test_SubscribeCriteria()
        {
            SubscriptionRule sc = new SubscriptionRule();

            sc.Type = RoutingRuleType.MessageType;

            string xml = sc.ToXMLString();

            MessageBox.Show(xml);

            SubscriptionRule sc1 = XObjectManager.CreateObject <SubscriptionRule>(xml);

            MessageBox.Show(sc1.ToXMLString());
        }
Exemplo n.º 18
0
 public static bool Load(string fileName)
 {
     try
     {
         string strXml = GetLogInXML(fileName);
         _log = XObjectManager.CreateObject(strXml, typeof(Log)) as Log;
         return(_log != null);
     }
     catch (Exception err)
     {
         _lastError = err;
         return(false);
     }
 }
Exemplo n.º 19
0
        private static void Test_Header()
        {
            MessageHeader h = new MessageHeader();

            h.ID = Guid.NewGuid();

            string xml = h.ToXMLString();

            MessageBox.Show(xml);

            MessageHeader h1 = XObjectManager.CreateObject <MessageHeader>(xml);

            MessageBox.Show(h1.ToXMLString());
        }
Exemplo n.º 20
0
        private void buttonDispatchFromSub_Click(object sender, EventArgs e)
        {
            string msgXml = _ctlRcvIn.GetXmlString();

            HYS.Messaging.Objects.Message msg = XObjectManager.CreateObject <HYS.Messaging.Objects.Message>(msgXml);

            DateTime dtBegin = DateTime.Now;
            bool     res     = _controler.DispatchSubscriberMessage(msg);
            DateTime dtEnd   = DateTime.Now;
            TimeSpan ts      = dtEnd.Subtract(dtBegin);

            this.labelReqPerform.Text = ts.TotalMilliseconds.ToString() + "ms";

            MessageBox.Show("result: " + res.ToString());
        }
Exemplo n.º 21
0
        private void buttonGenDS_Click(object sender, EventArgs e)
        {
            string xml = _ctrlCSBMsg.GetXmlString();

            if (string.IsNullOrEmpty(xml))
            {
                return;
            }

            MSG.Message msg = XObjectManager.CreateObject <MSG.Message>(xml);
            if (msg == null)
            {
                MessageBox.Show(this, "Deserialize CSB DataSet Message failed. See the log file for details.", this.Text);
                return;
            }

            try
            {
                DataSet     ds = new DataSet();
                XmlReadMode m  = ds.ReadXml(XmlReader.Create(new StringReader(msg.Body)));
                //MessageBox.Show(this, string.Format(
                //        "Data Set Name: {0}\r\n" +
                //        "Table Count: {1}\r\n" +
                //        "Row Count: {2}\r\n",
                //        ds.DataSetName,
                //        ds.Tables.Count,
                //        (ds.Tables.Count > 0) ? ds.Tables[0].Rows.Count : 0),
                //   m.ToString());

                if (ds.Tables.Count > 0)
                {
                    this.dataGridViewDS.DataSource = ds.Tables[0];
                    this.labelDSName.Text          = ds.DataSetName + " (" + ds.Tables[0].Rows.Count + ")";
                }
                else
                {
                    this.dataGridViewDS.DataSource = null;
                    this.labelDSName.Text          = ds.DataSetName + " (0)";
                }
            }
            catch (Exception err)
            {
                Program.Log.Write(err);
                MessageBox.Show(this, "Deserialize DataSet XML failed. See the log file for details.\r\n\r\nMessage: " + err.Message, this.Text);
            }
        }
Exemplo n.º 22
0
        internal bool ProcessMessage(string request, out string response)
        {
            response = "";

            try
            {
                Message req = XObjectManager.CreateObject <Message>(request);

                if (req == null || req.Header == null)
                {
                    _log.Write(LogType.Error,
                               string.Format("RPCPullReceiver receive NULL message or message without header via {0}",
                                             Channel.RPCConfig.URI));
                    return(false);
                }
                else
                {
                    _log.Write(string.Format("RPCPullReceiver receive message id {0} via {1}",
                                             req.Header.ID.ToString(), Channel.RPCConfig.URI));
                }

                Message rsp = null;
                bool    res = NotifyMessageReceived(req, out rsp);

                if (res == false || rsp == null || rsp.Header == null)
                {
                    _log.Write(LogType.Error,
                               "RPCPullReceiver notify the requesting message to the responser entity failed, or receive NULL responsing message, or receive responsing message without header.");
                    return(false);
                }
                else
                {
                    response = rsp.ToXMLString();

                    _log.Write(string.Format("RPCPullReceiver sending response message id {0} via {1}",
                                             rsp.Header.ID.ToString(), Channel.RPCConfig.URI));
                }

                return(true);
            }
            catch (Exception err)
            {
                _log.Write(err);
                return(false);
            }
        }
Exemplo n.º 23
0
 public static bool Load(string fileName)
 {
     try
     {
         using (StreamReader sr = File.OpenText(fileName))
         {
             string strXml = sr.ReadToEnd();
             _RdetOutAdapterConfig = XObjectManager.CreateObject(strXml, typeof(RdetOutboundAdapterConfig)) as RdetOutboundAdapterConfig;
             return(_RdetOutAdapterConfig != null);
         }
     }
     catch (Exception err)
     {
         _lastError = err;
         return(false);
     }
 }
Exemplo n.º 24
0
        private static void Test_Body()
        {
            //string xmlstring = "<a><b>hello</b></a>";
            string xmlstring = XMLHeader + "<a><b>hello</b></a>";

            //XmlTextReader r = new XmlTextReader(new StringReader(xmlstring));
            //if(r.Read()) xmlstring = r.ReadOuterXml();

            HYS.Messaging.Objects.Message msg = new HYS.Messaging.Objects.Message();
            msg.Body = HYS.Messaging.Objects.Message.RemoveXmlHeader(xmlstring);

            string str = msg.ToXMLString();

            MessageBox.Show(str);

            HYS.Messaging.Objects.Message newmsg = XObjectManager.CreateObject <HYS.Messaging.Objects.Message>(str);
            MessageBox.Show(newmsg.ToXMLString());
        }
Exemplo n.º 25
0
        public bool Initialize(ProcessorInitializationParameter parameter)
        {
            if (parameter == null)
            {
                return(false);
            }

            _param  = parameter;
            _config = XObjectManager.CreateObject <SchemaValidatorConfig>(parameter.ConfigXmlString);

            if (_config == null)
            {
                WriteLog(LogType.Error, "Deserialize configuration object failed.");
                return(false);
            }

            return(true);
        }
Exemplo n.º 26
0
 private bool _hasSaved; // the Adapter.Config.exe may call the Save() method twice when there are several IConfigUI form.
 public bool Load(ILogging log)
 {
     try
     {
         using (StreamReader sr = File.OpenText(FileName))
         {
             string str = sr.ReadToEnd();
             Config = XObjectManager.CreateObject(str, typeof(T)) as T;
             return(true);
         }
     }
     catch (Exception e)
     {
         log.Write(e);
         _lastError = e;
         return(false);
     }
 }
Exemplo n.º 27
0
 public bool Load()
 {
     try
     {
         using (StreamReader sr = File.OpenText(FileName))
         {
             string str = sr.ReadToEnd();
             Config = XObjectManager.CreateObject(str, typeof(XIMOutboundConfig)) as XIMOutboundConfig;
             return(true);
         }
     }
     catch (Exception e)
     {
         Program.Log.Write(e);
         _lastError = e;
         return(false);
     }
 }
Exemplo n.º 28
0
        public Message CreateXDSGWMessage(string xdsgwMsg)
        {
            Message msg = XObjectManager.CreateObject <Message>(xdsgwMsg);

            if (msg == null)
            {
                _context.Log.Write(LogType.Error, string.Format("Deserialize XDS Gateway message failed. Please check whether the following XML string conforms to XDS Gateway message schema: \r\n{0}", xdsgwMsg));
            }
            else
            {
                msg.Header.ID = Guid.NewGuid();
                //msg.Header.Type = MessageRegistry.GENERIC_ResponseMessageType;    // do not need to set message type here, set message type when dispatching messages.

                _context.Log.Write(string.Format("Deserialize and create XDS Gateway message success. Message ID: {0}", msg.Header.ID.ToString()));
            }

            return(msg);
        }
Exemplo n.º 29
0
 public bool Load()
 {
     try
     {
         using (StreamReader sr = File.OpenText(FileName))
         {
             string str = sr.ReadToEnd();
             Config = XObjectManager.CreateObject(str, typeof(MWLServerConfig)) as MWLServerConfig;
             DicomMappingHelper.SetFixValue <MWLQueryCriteriaItem, MWLQueryResultItem>(Config.Rule);
             return(true);
         }
     }
     catch (Exception e)
     {
         Program.Log.Write(e);
         _lastError = e;
         return(false);
     }
 }
Exemplo n.º 30
0
        public virtual bool Load()
        {
            try
            {
                using (StreamReader sr = File.OpenText(FileName))
                {
                    string xmlstr = sr.ReadToEnd();
                    _config = XObjectManager.CreateObject(xmlstr, _configType) as ConfigBase;
                }

                _lastError = null;
                return(_config != null);
            }
            catch (Exception err)
            {
                _lastError = err;
                return(false);
            }
        }