public ContainerForm(ServiceBusHelper serviceBusHelper, MainForm mainForm, FormTypeEnum formType, SubscriptionWrapper subscriptionWrapper) { try { InitializeComponent(); Task.Factory.StartNew(AsyncWriteToLog).ContinueWith(t => { if (t.IsFaulted && t.Exception != null) { WriteToLog(t.Exception.Message); } }); this.mainForm = mainForm; mainSplitterDistance = mainSplitContainer.SplitterDistance; SuspendLayout(); panelMain.SuspendDrawing(); panelMain.Controls.Clear(); panelMain.BackColor = SystemColors.GradientInactiveCaption; if (formType == FormTypeEnum.Listener) { var listenerControl = new ListenerControl(WriteToLog, StopLog, StartLog, new ServiceBusHelper(WriteToLog, serviceBusHelper), subscriptionWrapper.SubscriptionDescription) { Location = new Point(1, panelMain.HeaderHeight + 1), Size = new Size(panelMain.Size.Width - 3, subscriptionWrapper.SubscriptionDescription.RequiresSession ? 544 : 520), Anchor = AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right }; listenerControl.Focus(); Text = string.Format(SubscriptionListenerFormat, subscriptionWrapper.SubscriptionDescription.Name); mainSplitContainer.SplitterDistance = subscriptionWrapper.SubscriptionDescription.RequiresSession ? 570 : listenerControl.Size.Height + 26; panelMain.HeaderText = string.Format(HeaderTextSubscriptionListenerFormat, subscriptionWrapper.SubscriptionDescription.Name); panelMain.Controls.Add(listenerControl); } else { testSubscriptionControl = new TestSubscriptionControl(mainForm, WriteToLog, StopLog, StartLog, new ServiceBusHelper(WriteToLog, serviceBusHelper), subscriptionWrapper) { Location = new Point(1, panelMain.HeaderHeight + 1), Size = new Size(panelMain.Size.Width - 3, panelMain.Size.Height - 26), Anchor = AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right }; testSubscriptionControl.btnCancel.Click -= testSubscriptionControl.btnCancel_Click; testSubscriptionControl.btnCancel.Click += BtnCancelOnClick; testSubscriptionControl.Focus(); Text = string.Format(TestSubscriptionFormat, subscriptionWrapper.SubscriptionDescription.Name); panelMain.HeaderText = string.Format(HeaderTextTestSubscriptionFormat, subscriptionWrapper.SubscriptionDescription.Name); panelMain.Controls.Add(testSubscriptionControl); } SetStyle(ControlStyles.ResizeRedraw, true); } finally { panelMain.ResumeDrawing(); ResumeLayout(); } }
/// <summary> /// Local HTTP Web Serve Start /// </summary> public async void Start_Server() { Log.Instance.Info("## HTTP Web Server Start ##"); AddText(MSGVIEW.WEB, "서버시작 중..."); try { if (listener != null && listener.IsListening) { Log.Instance.Info("## HTTP Web Serve is already start ##"); Log.Instance.Info("## HTTP Web Server ReStart (Stop -> Start) ##"); AddText(MSGVIEW.WEB, "이미 서버가 실행중이므로 종료 후 재시작"); Stop_Server(); AddText(MSGVIEW.WEB, "서버 재시작..."); } listener = new HttpListener(); listener.Prefixes.Add(string.Format("http://localhost:{0}/", serverPort)); listener.Prefixes.Add(string.Format("http://127.0.0.1:{0}/", serverPort)); listener.AuthenticationSchemes = AuthenticationSchemes.Anonymous; listener.Start(); // RequestQueue Length Size Up. ListenerControl.SetRequestQueueLength(listener, 5000); AddText(MSGVIEW.WEB, "서버시작 완료\n"); AddText(MSGVIEW.WEB, string.Format("서버 : 로컬영역, 포트 : {0}", serverPort)); AddText(MSGVIEW.WEB, "http://localhost:" + serverPort); Log.Instance.Info("## HTTP Web Server Start Success ##"); await handleClientConnection(listener); } catch (ObjectDisposedException error) { Log.Instance.Info(">> HTTP Web Server is Stopped..." + error.Message); } catch (NullReferenceException error) { Log.Instance.Error(">> HTTP Web Server NullReferenceException... Error MSG : " + error.Message); } catch (TaskCanceledException error) { Log.Instance.Error(">> HTTP Web Server TaskCanceledException... Error MSG : " + error.Message); } catch (Exception error) { Log.Instance.Error(">> HTTP Web Server Start Faild... Error MSG : " + error.Message); AddText(MSGVIEW.WEB, "서버 시작 실패\n"); } }
public ContainerForm(ServiceBusHelper serviceBusHelper, MainForm mainForm, FormTypeEnum formType, QueueDescription queueDescription) { try { InitializeComponent(); Task.Factory.StartNew(AsyncWriteToLog).ContinueWith(t => { if (t.IsFaulted && t.Exception != null) { WriteToLog(t.Exception.Message); } }); this.mainForm = mainForm; mainSplitterDistance = mainSplitContainer.SplitterDistance; SuspendLayout(); panelMain.SuspendDrawing(); panelMain.Controls.Clear(); panelMain.BackColor = SystemColors.GradientInactiveCaption; if (formType == FormTypeEnum.Listener) { var listenerControl = new ListenerControl(WriteToLog, StopLog, StartLog, new ServiceBusHelper(WriteToLog, serviceBusHelper), queueDescription) { Location = new Point(1, panelMain.HeaderHeight + 1), Size = new Size(panelMain.Size.Width - 3, queueDescription.RequiresSession ? 544 : 520), Anchor = AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right }; listenerControl.Focus(); Text = string.Format(QueueListenerFormat, queueDescription.Path); mainSplitContainer.SplitterDistance = queueDescription.RequiresSession ? 570 : listenerControl.Size.Height + 26; panelMain.HeaderText = string.Format(HeaderTextQueueListenerFormat, queueDescription.Path); panelMain.Controls.Add(listenerControl); } else { testQueueControl = new TestQueueControl(mainForm, WriteToLog, StopLog, StartLog, new ServiceBusHelper(WriteToLog, serviceBusHelper), queueDescription) { Location = new Point(1, panelMain.HeaderHeight + 1), Size = new Size(panelMain.Size.Width - 3, panelMain.Size.Height - 26), Anchor = AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right }; if (formType == FormTypeEnum.Send) { testQueueControl.mainTabControl.TabPages.RemoveAt(2); testQueueControl.receiverEnabledCheckBox.Checked = false; testQueueControl.senderEnabledCheckBox.Checked = true; testQueueControl.senderEnabledCheckBox.Visible = false; testQueueControl.grouperMessage.Location = new Point(testQueueControl.grouperMessage.Location.X, 8); testQueueControl.grouperMessage.Size = new Size(testQueueControl.grouperMessage.Size.Width, testQueueControl.grouperMessage.Size.Height + 16); testQueueControl.grouperSender.Location = new Point(testQueueControl.grouperSender.Location.X, 8); testQueueControl.grouperSender.Size = new Size(testQueueControl.grouperSender.Size.Width, testQueueControl.grouperSender.Size.Height + 16); Text = string.Format(SendMessagesFormat, queueDescription.Path); } else { Text = string.Format(TestQueueFormat, queueDescription.Path); logTraceListener = new LogTraceListener(WriteToLog); Trace.Listeners.Add(logTraceListener); } testQueueControl.btnCancel.Text = CloseLabel; testQueueControl.btnCancel.Click -= testQueueControl.btnCancel_Click; testQueueControl.btnCancel.Click += BtnCancelOnClick; testQueueControl.Focus(); panelMain.HeaderText = string.Format(HeaderTextTestQueueFormat, queueDescription.Path); panelMain.Controls.Add(testQueueControl); } SetStyle(ControlStyles.ResizeRedraw, true); } finally { panelMain.ResumeDrawing(); ResumeLayout(); } }