private void InitializePublisherAgent(EntityConfigBase cfg) { if ((cfg.Interaction & InteractionTypes.Publisher) != InteractionTypes.Publisher) { return; } IPublisher p = EntityInstance as IPublisher; if (p == null) { return; } _publisherAgent = new PushSenderAgent(p, _log); foreach (PushChannelConfig c in cfg.PublishConfig.Channels) { _publisherAgent.RegisterChannel(c); } _publisherAgent.InitializeChannels(); if (cfg.PublishConfig.ProcessConfig.IsEnable()) { _publisherAgent.OnProcessing += new OneWayMessageProcessHandler(_publisherAgent_OnProcessing); _log.Write(LogType.Debug, "Message processing handler is injected for publisher. " + cfg.EntityID.ToString()); } }
private void InitializeRequesterAgent(EntityConfigBase cfg) { if ((cfg.Interaction & InteractionTypes.Requester) != InteractionTypes.Requester) { return; } IRequester p = EntityInstance as IRequester; if (p == null) { return; } _requesterAgent = new PullSenderAgent(p, _log); foreach (PullChannelConfig c in cfg.RequestConfig.Channels) { _requesterAgent.RegisterChannel(c); } _requesterAgent.InitializeChannels(); if (cfg.RequestConfig.ProcessConfig.PreProcessConfig.IsEnable()) { _requesterAgent.OnPreProcessing += new DuplexMessagePreProcessHandler(_requesterAgent_OnPreProcessing); _log.Write(LogType.Debug, "Message pre processing handler is injected for requester. " + cfg.EntityID.ToString()); } if (cfg.RequestConfig.ProcessConfig.PostProcessConfig.IsEnable()) { _requesterAgent.OnPostProcessing += new DuplexMessagePostProcessHanlder(_requesterAgent_OnPostProcessing); _log.Write(LogType.Debug, "Message post processing handler is injected for requester. " + cfg.EntityID.ToString()); } }
public bool InitializeInteraction(InteractionTypes t) { EntityConfigBase c = EntityConfig; if (c == null) { return(false); } _log.Write(string.Format("Initializing {0} agent in entity {1}({2}).", t.ToString(), c.Name, c.EntityID.ToString())); if ((t & InteractionTypes.Publisher) == InteractionTypes.Publisher) { this.InitializePublisherAgent(c); } if ((t & InteractionTypes.Subscriber) == InteractionTypes.Subscriber) { this.InitializeSubscriberAgent(c); } if ((t & InteractionTypes.Requester) == InteractionTypes.Requester) { this.InitializeRequesterAgent(c); } if ((t & InteractionTypes.Responser) == InteractionTypes.Responser) { this.InitializeResponserAgent(c); } return(true); }
public void StartPrint(EntityConfigBase data, string text, string caption) { XmlNode config = GetConfig(data.pageConfig); DataFillToXml(data, ref config); xmldata = config; //初始化页面实体 pageentity = PageEntityManager <PageEntity> .Getentity(xmldata); DefaultPageSettings.Landscape = pageentity.Landscape; int PageWidth = CmToPix(pageentity.Width); int PageHeigth = CmToPix(pageentity.Height); PaperSize p1 = null; for (int i = 0; i < PrinterSettings.PaperSizes.Count; i++) { if (PrinterSettings.PaperSizes[i].PaperName == pageentity.PageName) { p1 = PrinterSettings.PaperSizes[i]; break; } } if (p1 == null) { p1 = new PaperSize(pageentity.PageName, PageWidth, PageHeigth); } DefaultPageSettings.PaperSize = p1; PrintShowDialog(text, caption); }
private void InitializeSubscriberAgent(EntityConfigBase cfg) { if ((cfg.Interaction & InteractionTypes.Subscriber) != InteractionTypes.Subscriber) { return; } ISubscriber s = EntityInstance as ISubscriber; if (s == null) { return; } _subscriberAgent = new PushReceiverAgent(s, _log); foreach (PushChannelConfig c in cfg.SubscribeConfig.Channels) { _subscriberAgent.RegisterChannel(c); } _subscriberAgent.InitializeChannels(); if (cfg.SubscribeConfig.ProcessConfig.IsEnable()) { _subscriberAgent.OnProcessing += new OneWayMessageProcessHandler(_subscriberAgent_OnProcessing); _log.Write(LogType.Debug, "Message processing handler is injected for subscriber. " + cfg.EntityID.ToString()); } }
private void LoadGeneralInformation(EntityConfigBase cfg) { this.textBoxEntityID.Text = cfg.EntityID.ToString(); this.textBoxEntityName.Text = cfg.Name; this.textBoxEntityDescription.Text = cfg.Description; this.textBoxInteraction.Text = cfg.Interaction.ToString(); }
public bool LoadSetting(EntityConfigBase cfg) { _entityConfig = cfg; RefreshChannelList(); RefreshChannelButton(); return(true); }
private bool CheckDuplicatedEntityName(EntityConfigBase cfg, string ename) { foreach (EntityContractBase c in Program.SolutionMgt.Config.Entities) { if (c.EntityID != cfg.EntityID && c.Name == ename) { return(false); } } return(true); }
private bool LoadEntity() { _entity = null; Type t = this.comboBoxClassName.SelectedItem as Type; if (t == null) { return(false); } E e = EntityLoader.CreateEntry <E>(t); _entry = e; if (e == null) { _log.Write(EntityLoader.LastError); MessageBox.Show(this, "Initialize message entity failed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } _entity = new EntityAssemblyConfig(); _entity.ClassName = t.ToString(); _entity.AssemblyLocation = this.textBoxAssemblyLocation.Text.Trim(); _entity.InitializeArgument.ConfigFilePath = this.textBoxConfigPath.Text.Trim(); if (!e.Initialize(_entity.InitializeArgument)) { MessageBox.Show(this, "Initialize message entity failed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } EntityConfigBase cfg = e.GetConfiguration(); _cfg = cfg; if (cfg == null) { MessageBox.Show(this, "Initialize message entity failed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } this.textBoxEntityName.Text = _entity.EntityInfo.Name = cfg.Name; this.textBoxEntityID.Text = (_entity.EntityInfo.EntityID = cfg.EntityID).ToString(); this.textBoxEntityDescription.Text = _entity.EntityInfo.Description = cfg.Description; return(true); }
private bool SaveGeneralInformation(EntityConfigBase cfg) { string ename = this.textBoxEntityName.Text.Trim(); if (!CheckDuplicatedEntityName(cfg, ename)) { MessageBox.Show(this, "Message Entity \"" + ename + "\" has already exsited, please input another name.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information); SelectTabPage(this.tabPageGeneral); this.textBoxEntityName.Focus(); return(false); } cfg.Name = ename; cfg.Description = this.textBoxEntityDescription.Text; cfg.EntityID = new Guid(this.textBoxEntityID.Text.Trim()); cfg.Interaction = (InteractionTypes)Enum.Parse(typeof(InteractionTypes), this.textBoxInteraction.Text.Trim()); return(true); }
public bool Initialize(EntityInitializeArgument arg) { IMessageEntity e = EntityInstance; if (e == null) { return(false); } if (!e.Initialize(arg)) { _log.Write("Initialize message entity failed. " + ToString()); return(false); } EntityConfigBase c = EntityConfig; if (c == null) { return(false); } return(true); }
private void LoadTransformPage() { _entityCfg = _entityConfig.GetConfiguration(); if (_entityCfg == null) { return; } // Note: assume that an entity should be publisher or subcriber, not both of them. if ((_entityCfg.Interaction & InteractionTypes.Publisher) == InteractionTypes.Publisher && _entityCfg.PublishConfig != null) { this.panelOneWayTransform.Visible = true; //this.checkBoxXSLT.Text = string.Format(this.checkBoxXSLT.Text, "sending to subscriber"); this.checkBoxXSLT.Text = string.Format(this.checkBoxXSLT.Text, "sending to publish channel"); this.checkBoxXSLT.Checked = _entityCfg.PublishConfig.ProcessConfig.EnableXSLTTransform; this.textBoxXSLT.Text = _entityCfg.PublishConfig.ProcessConfig.XSLTFileLocation; } else if ((_entityCfg.Interaction & InteractionTypes.Subscriber) == InteractionTypes.Subscriber && _entityCfg.SubscribeConfig != null) { this.panelOneWayTransform.Visible = true; //this.checkBoxXSLT.Text = string.Format(this.checkBoxXSLT.Text, "receiving from publisher"); this.checkBoxXSLT.Text = string.Format(this.checkBoxXSLT.Text, "receiving from publish channel"); this.checkBoxXSLT.Checked = _entityCfg.SubscribeConfig.ProcessConfig.EnableXSLTTransform; this.textBoxXSLT.Text = _entityCfg.SubscribeConfig.ProcessConfig.XSLTFileLocation; } else { this.panelOneWayTransform.Visible = false; } // Note: assume that an entity should be requseter or responser, not both of them. if ((_entityCfg.Interaction & InteractionTypes.Requester) == InteractionTypes.Requester && _entityCfg.RequestConfig != null) { this.panelDuplexTransform.Visible = true; //this.checkBoxXSLTRequest.Text = string.Format(this.checkBoxXSLTRequest.Text, "sending to responser"); this.checkBoxXSLTRequest.Text = string.Format(this.checkBoxXSLTRequest.Text, "sending to request channel"); this.checkBoxXSLTRequest.Checked = _entityCfg.RequestConfig.ProcessConfig.PreProcessConfig.EnableXSLTTransform; this.textBoxXSLTRequest.Text = _entityCfg.RequestConfig.ProcessConfig.PreProcessConfig.XSLTFileLocation; //this.checkBoxXSLTResponse.Text = string.Format(this.checkBoxXSLTResponse.Text, "receiving from responser"); this.checkBoxXSLTResponse.Text = string.Format(this.checkBoxXSLTResponse.Text, "receiving from request channel"); this.checkBoxXSLTResponse.Checked = _entityCfg.RequestConfig.ProcessConfig.PostProcessConfig.EnableXSLTTransform; this.textBoxXSLTResponse.Text = _entityCfg.RequestConfig.ProcessConfig.PostProcessConfig.XSLTFileLocation; } else if ((_entityCfg.Interaction & InteractionTypes.Responser) == InteractionTypes.Responser && _entityCfg.ResponseConfig != null) { this.panelDuplexTransform.Visible = true; //this.checkBoxXSLTRequest.Text = string.Format(this.checkBoxXSLTRequest.Text, "receiving from requester"); this.checkBoxXSLTRequest.Text = string.Format(this.checkBoxXSLTRequest.Text, "receiving from request channel"); this.checkBoxXSLTRequest.Checked = _entityCfg.ResponseConfig.ProcessConfig.PreProcessConfig.EnableXSLTTransform; this.textBoxXSLTRequest.Text = _entityCfg.ResponseConfig.ProcessConfig.PreProcessConfig.XSLTFileLocation; //this.checkBoxXSLTResponse.Text = string.Format(this.checkBoxXSLTResponse.Text, "sending to requester"); this.checkBoxXSLTResponse.Text = string.Format(this.checkBoxXSLTResponse.Text, "sending to request channel"); this.checkBoxXSLTResponse.Checked = _entityCfg.ResponseConfig.ProcessConfig.PostProcessConfig.EnableXSLTTransform; this.textBoxXSLTResponse.Text = _entityCfg.ResponseConfig.ProcessConfig.PostProcessConfig.XSLTFileLocation; } else { this.panelDuplexTransform.Visible = false; } if (this.panelOneWayTransform.Visible == false && this.panelDuplexTransform.Visible == true) { this.panelDuplexTransform.Location = this.panelOneWayTransform.Location; } }
static void RegisterEntityIntoSolution() { try { EntityAssemblyConfig entity = Program.ConfigMgt.Config.EntityAssembly; foreach (EntityContractBase e in SolutionMgt.Config.Entities) { if (e.EntityID == entity.EntityInfo.EntityID) { MessageBox.Show("Following message entity has already existed in the integration solution.\r\n\r\n" + entity.EntityInfo.Name + " (" + entity.EntityInfo.EntityID + ")", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } EntityConfigAgent agent = new EntityConfigAgent(Program.ConfigMgt.Config.EntityAssembly, Program.Log); if (agent.Initialize(Program.ConfigMgt.Config.EntityAssembly.InitializeArgument)) { EntityConfigBase cfg = agent.EntityConfig; EntityContractBase c = new EntityContractBase(); c.Name = cfg.Name; c.DeviceName = cfg.DeviceName; c.Direction = cfg.Direction; c.Interaction = cfg.Interaction; c.Description = cfg.Description; c.EntityID = cfg.EntityID; if (cfg.PublishConfig != null) { c.Publication = cfg.PublishConfig.Publication; } if (cfg.ResponseConfig != null) { c.ResponseDescription = cfg.ResponseConfig.ResponseContract; } c.AssemblyConfig = GetEntityAssemblyConfigForSolution(entity); //string webConfigFilePath = Path.Combine(Application.StartupPath, EntityWebConfig.EntityWebConfigFileName); //ConfigManager<EntityWebConfig> webmgt = new ConfigManager<EntityWebConfig>(webConfigFilePath); //if (webmgt.Load()) //{ // Log.Write("Register entity with default web config at: " + webConfigFilePath); // SolutionMgt.Config.RegisterEntity(c, webmgt.Config); //} //else //{ // Log.Write("Register entity without default web config."); // SolutionMgt.Config.RegisterEntity(c); //} Log.Write("Registering entity."); SolutionMgt.Config.RegisterEntity(c); if (SolutionMgt.Save()) { Log.Write("Save solution dir file succeeded. " + SolutionMgt.FileName); MessageBox.Show("Register following message entity into the integration solution succeeded.\r\n\r\n" + entity.EntityInfo.Name + " (" + entity.EntityInfo.EntityID + ")", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Log.Write(LogType.Error, "Save solution dir file failed."); Log.Write(SolutionMgt.LastError); MessageBox.Show("Register following message entity into the integration solution failed.\r\n\r\n" + entity.EntityInfo.Name + " (" + entity.EntityInfo.EntityID + ")", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } agent.Uninitialize(); } } catch (Exception err) { Log.Write(err); } }
protected void DataFillToXml(object data, ref XmlNode config) { PropertyInfo[] zz = data.GetType().GetProperties(); for (int n = 0; n < config.ChildNodes.Count; n++) { string configType = config.ChildNodes[n].Name; switch (configType) { case "text": foreach (PropertyInfo x in zz) { if (config.ChildNodes[n].Attributes["DataFieldName"] != null) { if (Convert.ToString(config.ChildNodes[n].Attributes["DataFieldName"].Value) == x.Name) { config.ChildNodes[n].Attributes["value"].Value = Convert.ToString(x.GetValue(data, null)); break; } } } break; case "loop": List <XmlNode> l = new List <XmlNode>(); foreach (PropertyInfo x in zz) { if (Convert.ToString(config.ChildNodes[n].Attributes["DataFieldName"].Value) == x.Name) { EntityConfigBase[] list = (EntityConfigBase[])x.GetValue(data, null); if (list != null) { //数据的偏移量 decimal y = 0; if (list.Length > 0) { PropertyInfo[] mm = list[0].GetType().GetProperties(); for (int i = 0; i < list.Length; i++) { //每行数据的初始偏移量 decimal yyy = y; EntityConfigBase d = list[i]; foreach (XmlNode r in config.ChildNodes[n].ChildNodes) { //记录该行最大的偏移量 decimal yy = yyy; foreach (PropertyInfo z in mm) { if (r.Attributes["DataFieldName"] != null) { if (Convert.ToString(r.Attributes["DataFieldName"].Value) == z.Name) { FormatXML_Loop(r, ref yy, ref l, Convert.ToString(z.GetValue(d, null))); XmlNode b = r.Clone(); l.Add(b); if (yy > y) { y = yy; } break; } } } } } } } } } config.ChildNodes[n].RemoveAll(); foreach (XmlNode newxml in l) { config.ChildNodes[n].AppendChild(newxml); } break; default: break; } } }
public void StartPrint(EntityConfigBase data) { StartPrint(data, string.Empty, string.Empty); }
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); }
private void LoadSetting() { EntityConfigBase cfg = _agent.EntityConfig; _config = cfg; this.tabControlMain.TabPages.Clear(); this.tabControlMain.TabPages.Add(this.tabPageGeneral); LoadGeneralInformation(cfg); if ((cfg.Interaction & InteractionTypes.Subscriber) == InteractionTypes.Subscriber) { this.tabControlMain.TabPages.Add(this.tabPageSubscribe); SubscribeConfigControler ctrl = new SubscribeConfigControler(this); this.tabPageSubscribe.Tag = ctrl; ctrl.LoadSetting(cfg); _fxGUIList.Add(ctrl); } if ((cfg.Interaction & InteractionTypes.Responser) == InteractionTypes.Responser) { this.tabControlMain.TabPages.Add(this.tabPageResponse); ResponseConfigControler ctrl = new ResponseConfigControler(this); this.tabPageResponse.Tag = ctrl; ctrl.LoadSetting(cfg); _fxGUIList.Add(ctrl); } IConfigUI[] guiList = _agent.EntityConfigInstance.GetIConfigUI(); if (guiList != null) { foreach (IConfigUI gui in guiList) { string title = gui.Title; Control ctl = gui.GetControl(); if (ctl != null) { TabPage page = new TabPage(title); page.AutoScroll = true; page.Tag = gui; EntityLoader.PrepareControl(ctl, this); page.Controls.Add(ctl); this.tabControlMain.TabPages.Add(page); gui.LoadConfig(); } _entityGUIList.Add(gui); } } if ((cfg.Interaction & InteractionTypes.Publisher) == InteractionTypes.Publisher) { this.tabControlMain.TabPages.Add(this.tabPagePublish); PublishConfigControler ctrl = new PublishConfigControler(this); this.tabPagePublish.Tag = ctrl; ctrl.LoadSetting(cfg); _fxGUIList.Add(ctrl); } if ((cfg.Interaction & InteractionTypes.Requester) == InteractionTypes.Requester) { this.tabControlMain.TabPages.Add(this.tabPageRequest); RequestConfigControler ctrl = new RequestConfigControler(this); this.tabPageRequest.Tag = ctrl; ctrl.LoadSetting(cfg); _fxGUIList.Add(ctrl); } }
static void DeleteChannel(string[] args) { int count = 3; if (args.Length < count) { Program.Log.Write("Arguement is not enough."); return; } try { string type = args[1]; string entityID = args[2]; Guid eID = new Guid(entityID); switch (type.ToLowerInvariant()) { case "publisher": { 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 || cfg.SubscribeConfig == null) { Program.Log.Write("Cannot read SubscribeConfig from configuration file."); } else { List <PushChannelConfig> dlist = new List <PushChannelConfig>(); foreach (PushChannelConfig c in cfg.SubscribeConfig.Channels) { if (c.SenderEntityID == eID) { dlist.Add(c); } } foreach (PushChannelConfig c in dlist) { cfg.SubscribeConfig.Channels.Remove(c); } agent.EntityConfigInstance.SaveConfiguration(); } agent.Uninitialize(); } break; } case "responser": { 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 || cfg.RequestConfig == null) { Program.Log.Write("Cannot read SubscribeConfig from configuration file."); } else { List <PushChannelConfig> dlist = new List <PushChannelConfig>(); foreach (PushChannelConfig c in cfg.RequestConfig.Channels) { if (c.ReceiverEntityID == eID) { dlist.Add(c); } } foreach (PushChannelConfig c in dlist) { cfg.RequestConfig.Channels.Remove(c); } agent.EntityConfigInstance.SaveConfiguration(); } agent.Uninitialize(); } break; } } } catch (Exception err) { Log.Write(err); } }
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); }
static void ApplyChannelConfigurations(bool showMsg) { try { EntityConfigAgent agent = new EntityConfigAgent(Program.ConfigMgt.Config.EntityAssembly, Program.Log); if (agent.Initialize(Program.ConfigMgt.Config.EntityAssembly.InitializeArgument)) { EntityConfigBase cfg = agent.EntityConfig; if ((cfg.Interaction & InteractionTypes.Subscriber) == InteractionTypes.Subscriber) { bool res = true; foreach (PushChannelConfig chn in cfg.SubscribeConfig.Channels) { if (!UpdateChannelInPublisher(chn)) { res = false; break; } } if (res) { string str = "Apply channels to publisher succeeded."; Log.Write(str); if (showMsg) { MessageBox.Show(str, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { string str = "Apply channels to publisher failed."; Log.Write(LogType.Error, str); if (showMsg) { MessageBox.Show(str, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } if ((cfg.Interaction & InteractionTypes.Requester) == InteractionTypes.Requester) { bool res = true; foreach (PullChannelConfig chn in cfg.RequestConfig.Channels) { if (!UpdateChannelInResponser(chn)) { res = false; break; } } if (res) { string str = "Apply channels to responser succeeded."; Log.Write(str); if (showMsg) { MessageBox.Show(str, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { string str = "Apply channels to responser failed."; Log.Write(LogType.Error, str); if (showMsg) { MessageBox.Show(str, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } //else //{ // MessageBox.Show("No channel need to be applied.", "Information", // MessageBoxButtons.OK, MessageBoxIcon.Information); //} agent.Uninitialize(); } } catch (Exception err) { Log.Write(err); } }