Exemple #1
0
            private void AddChannel()
            {
                PullChannelConfig c = new PullChannelConfig();

                c.SenderEntityID   = _entityConfig.EntityID;
                c.SenderEntityName = _entityConfig.Name;

                FormPullChannel frm = new FormPullChannel(c, FormPullChannel.ActionType.Add, _entityConfig.RequestConfig.Channels);

                if (frm.ShowDialog(_formMain) != DialogResult.OK)
                {
                    return;
                }

                PullChannelConfig t = frm.ChannelConfig;

                if (t == null)
                {
                    return;
                }

                _entityConfig.RequestConfig.Channels.Add(t);

                RefreshChannelList();
                SelectChannel(t);
            }
Exemple #2
0
 private void SelectChannel(PullChannelConfig t)
 {
     foreach (ListViewItem i in _formMain.listViewRQChannelList.Items)
     {
         if (i.Tag as PullChannelConfig == t)
         {
             i.Selected = true;
             i.EnsureVisible();
             break;
         }
     }
 }
Exemple #3
0
        public bool NotifyMessageRequest(Message request, out Message response)
        {
            response = new Message();

            try
            {
                if (request == null ||
                    request.Header == null ||
                    OnMessageRequest == null)
                {
                    return(false);
                }

                if (Program.ConfigMgr.Config.RequestConfig.Channels.Count < 1)
                {
                    Program.Log.Write(LogType.Error, "Cannot find binded responser entity to receive the requesting message.");
                    return(false);
                }
                else
                {
                    // Support sending request to the first responser entity only.
                    //PullChannelConfig route = Program.ConfigMgr.Config.RequestConfig.Channels[0];
                    PullChannelConfig route = Program.ConfigMgr.Config.RequestConfig.FindTheFirstMatchedChannel(request);
                    if (route == null)
                    {
                        Program.Log.Write(LogType.Error, string.Format("Cannot find requesting channel to send the request message type: {0}.", request.Header.Type));
                        return(false);
                    }

                    Program.Log.Write(string.Format("Sending request({0}:{1}) to entity({2})", request.Header.Type, request.Header.ID.ToString(), route.ReceiverEntityID));
                    bool result = OnMessageRequest(route, request, out response);
                    Program.Log.Write(string.Format("Received response({0}) from entity({1}), result: {2}", response != null && response.Header != null ? response.Header.Type.ToString() + ":" + response.Header.ID.ToString() : "NULL", route.ReceiverEntityID, result.ToString()));

                    if (result &&
                        response != null &&
                        response.Header != null)
                    {
                        return(true);
                    }
                    else
                    {
                        Program.Log.Write(LogType.Error, "Received responsing message failed or receive a unwanted responsing message.");
                        return(false);
                    }
                }
            }
            catch (Exception err)
            {
                Program.Log.Write(err);
                return(false);
            }
        }
Exemple #4
0
            private void ViewChannel()
            {
                PullChannelConfig chn = GetSelectedChannel();

                if (chn == null)
                {
                    return;
                }

                FormPullChannel frm = new FormPullChannel(chn, FormPullChannel.ActionType.View);

                frm.ShowDialog(_formMain);
            }
Exemple #5
0
            private void DeleteChannel()
            {
                PullChannelConfig chn = GetSelectedChannel();

                if (chn == null)
                {
                    return;
                }

                _entityConfig.ResponseConfig.Channels.Remove(chn);

                RefreshChannelList();
                RefreshChannelButton();
            }
Exemple #6
0
            private void DeleteChannel()
            {
                PullChannelConfig t = GetSelectedChannel();

                if (t == null)
                {
                    return;
                }

                _entityConfig.RequestConfig.Channels.Remove(t);

                RefreshChannelList();
                RefreshChannelButton();
            }
Exemple #7
0
            private void EditChannel()
            {
                PullChannelConfig t = GetSelectedChannel();

                if (t == null)
                {
                    return;
                }

                FormPullChannel frm = new FormPullChannel(t, FormPullChannel.ActionType.Edit, _entityConfig.RequestConfig.Channels);

                if (frm.ShowDialog(_formMain) != DialogResult.OK)
                {
                    return;
                }

                RefreshChannelList();
                SelectChannel(t);
            }
Exemple #8
0
        public FormPullChannel(PullChannelConfig cfg, ActionType actionType, XCollection <PullChannelConfig> cfgList)
        {
            InitializeComponent();

            _cfgList       = cfgList;
            _channelConfig = cfg;
            _actionType    = actionType;

            if (_channelConfig == null)
            {
                _channelConfig = new PullChannelConfig();
            }

            _routTypeCtrl           = new RoutingTypeControler(this.comboBoxRoutingType);
            _routTypeCtrl.Selected += new RoutingTypeSelectedHanlder(_routTypeCtrl_Selected);
            _routTypeCtrl.Initialize();

            _protocolTypeCtrl = new ProtocolTypeControler(this.comboBoxProtocolType);
            _protocolTypeCtrl.Initialize();
        }
Exemple #9
0
        public FormChannelURI(PullChannelConfig chn)
        {
            InitializeComponent();
            _pullChannel = chn;

            if (_pullChannel.ProtocolType == ProtocolType.RPC_NamedPipe)
            {
                this.groupBoxURI.Text = "WCF Named Pipe Address";
            }
            else if (_pullChannel.ProtocolType == ProtocolType.RPC_SOAP)
            {
                this.groupBoxURI.Text = "WCF SOAP Address";
            }
            else if (_pullChannel.ProtocolType == ProtocolType.RPC_TCP)
            {
                this.groupBoxURI.Text = "WCF TCP Address";
            }

            this.textBoxURI.Text = _pullChannel.RPCConfig.URI;
        }
Exemple #10
0
 public FormPullChannel(PullChannelConfig cfg, ActionType actionType)
     : this(cfg, actionType, null)
 {
 }
Exemple #11
0
 public LPCQueryReceiver(PullChannelConfig config, ILog log)
     : base(config, log)
 {
     log.Write("Registering LPC responser. Pull route: " + config.ID.ToString());
     LPCReceiverDictionary.RegisterPullReceiver(config.ID, this);
 }
Exemple #12
0
 public LPCQuerier(PullChannelConfig config, ILog log)
     : base(config, log)
 {
     _parameter = config.LPCConfig;
 }
Exemple #13
0
 public RPCPullSender(PullChannelConfig config, ILog log)
     : base(config, log)
 {
 }
Exemple #14
0
 public RPCPullReceiver(PullChannelConfig config, ILog log)
     : base(config, log)
 {
 }
Exemple #15
0
        static bool UpdateChannelInResponser(PullChannelConfig cfg)
        {
            EntityAssemblyConfig acfg = null;

            foreach (EntityContractBase c in Program.SolutionMgt.Config.Entities)
            {
                if (c.EntityID == cfg.ReceiverEntityID)
                {
                    acfg = c.AssemblyConfig;
                    break;
                }
            }

            if (acfg == null)
            {
                Program.Log.Write(LogType.Error, "Cannot find responser in the integration solution: "
                                  + cfg.ReceiverEntityName + " (" + cfg.ReceiverEntityID + ")");
                return(false);
            }

            bool ret = false;

            acfg = GetEntityAssemblyConfigForEntity(acfg);
            EntityConfigAgent agent = new EntityConfigAgent(acfg, Program.Log);

            if (agent.Initialize(acfg.InitializeArgument))
            {
                EntityConfigBase ecfg = agent.EntityConfig;
                if (ecfg == null)
                {
                    Program.Log.Write(LogType.Error, "Cannot get responser configuration: "
                                      + cfg.ReceiverEntityName + " (" + cfg.ReceiverEntityID + ")");
                }
                else
                {
                    List <PullChannelConfig> deleteList = new List <PullChannelConfig>();
                    foreach (PullChannelConfig chn in ecfg.ResponseConfig.Channels)
                    {
                        if (chn.SenderEntityID == cfg.SenderEntityID)
                        {
                            deleteList.Add(chn);
                            break;
                        }
                    }

                    foreach (PullChannelConfig chn in deleteList)
                    {
                        ecfg.ResponseConfig.Channels.Remove(chn);
                    }

                    ecfg.ResponseConfig.Channels.Add(cfg);

                    if (agent.EntityConfigInstance.SaveConfiguration())
                    {
                        ret = true;
                        Program.Log.Write("Save responser configuration succeeded: "
                                          + cfg.ReceiverEntityName + " (" + cfg.ReceiverEntityID + ")");
                    }
                    else
                    {
                        Program.Log.Write(LogType.Error, "Save responser configuration failed: "
                                          + cfg.ReceiverEntityName + " (" + cfg.ReceiverEntityID + ")");
                    }
                }

                agent.Uninitialize();
            }

            return(ret);
        }
Exemple #16
0
        static void AddAndApplyChannel(string[] args)
        {
            int count = 6;

            if (args.Length < count)
            {
                Program.Log.Write("Arguement is not enough.");
                return;
            }

            try
            {
                string type         = args[1];
                string entityID     = args[2];
                string entityName   = args[3];
                string messageType  = args[4];
                string protocolType = args[5];

                switch (type.ToLowerInvariant())
                {
                case "publisher":
                {
                    MessageType mt = MessageType.Parse(messageType);
                    if (mt == null)
                    {
                        Program.Log.Write("Message Type can not be parse from: " + messageType);
                        return;
                    }

                    PushChannelConfig c = new PushChannelConfig();
                    c.ReceiverEntityID   = Program.ConfigMgt.Config.EntityAssembly.EntityInfo.EntityID;
                    c.ReceiverEntityName = Program.ConfigMgt.Config.EntityAssembly.EntityInfo.Name;
                    c.ProtocolType       = (ProtocolType)Enum.Parse(typeof(ProtocolType), protocolType);
                    c.Subscription.Type  = RoutingRuleType.MessageType;
                    c.Subscription.MessageTypeList.Add(mt);
                    c.SenderEntityID   = new Guid(entityID);
                    c.SenderEntityName = entityName;

                    switch (c.ProtocolType)
                    {
                    case ProtocolType.LPC: ChannelHelper.GenerateLPCChannel(c); break;

                    case ProtocolType.MSMQ: ChannelHelper.GenerateMSMQChannel(c); break;

                    default: Program.Log.Write("Following protocol type is not supported by now: " + c.ProtocolType.ToString()); return;
                    }

                    EntityConfigAgent agent = new EntityConfigAgent(Program.ConfigMgt.Config.EntityAssembly, Program.Log);
                    if (agent.Initialize(Program.ConfigMgt.Config.EntityAssembly.InitializeArgument))
                    {
                        EntityConfigBase cfg = agent.EntityConfig;
                        if (cfg == null)
                        {
                            Program.Log.Write("Cannot read configuration file.");
                        }
                        else
                        {
                            if (cfg.SubscribeConfig == null)
                            {
                                cfg.SubscribeConfig = new SubscribeConfig();
                            }
                            cfg.SubscribeConfig.Channels.Add(c);

                            if (agent.EntityConfigInstance.SaveConfiguration())
                            {
                                Program.Log.Write("Write configuration file successfully.");
                            }
                            else
                            {
                                Program.Log.Write("Cannot write configuration file.");
                            }
                        }
                        agent.Uninitialize();
                    }
                    break;
                }

                case "responser":
                {
                    PullChannelConfig c = new PullChannelConfig();
                    c.ReceiverEntityID   = Program.ConfigMgt.Config.EntityAssembly.EntityInfo.EntityID;
                    c.ReceiverEntityName = Program.ConfigMgt.Config.EntityAssembly.EntityInfo.Name;
                    c.ProtocolType       = (ProtocolType)Enum.Parse(typeof(ProtocolType), protocolType);
                    c.SenderEntityID     = new Guid(entityID);
                    c.SenderEntityName   = entityName;

                    switch (c.ProtocolType)
                    {
                    case ProtocolType.LPC: ChannelHelper.GenerateLPCChannel(c); break;

                    default: Program.Log.Write("Following protocol type is not supported by now: " + c.ProtocolType.ToString()); return;
                    }

                    EntityConfigAgent agent = new EntityConfigAgent(Program.ConfigMgt.Config.EntityAssembly, Program.Log);
                    if (agent.Initialize(Program.ConfigMgt.Config.EntityAssembly.InitializeArgument))
                    {
                        EntityConfigBase cfg = agent.EntityConfig;
                        if (cfg == null)
                        {
                            Program.Log.Write("Cannot read configuration file.");
                        }
                        else
                        {
                            if (cfg.RequestConfig == null)
                            {
                                cfg.RequestConfig = new RequestConfig();
                            }
                            cfg.RequestConfig.Channels.Add(c);

                            if (agent.EntityConfigInstance.SaveConfiguration())
                            {
                                Program.Log.Write("Write configuration file successfully.");
                            }
                            else
                            {
                                Program.Log.Write("Cannot write configuration file.");
                            }
                        }
                        agent.Uninitialize();
                    }
                    break;
                }
                }
            }
            catch (Exception err)
            {
                Program.Log.Write(err);
            }

            ApplyChannelConfigurations(false);
        }