예제 #1
0
 private void btnHost_Click(object sender, EventArgs e)
 {
     FormValidationUtility.ValidateHostSiteForm(txtPath, txtPort, txtVirRoot, this,
                                                () =>
     {
         new ProgressForm(new HostSiteCommand(
                              new Website()
         {
             PhysicalPath =
                 txtPath.Text.EndsWith("\\", StringComparison.Ordinal)
                                  ? txtPath.Text
                                  : txtPath.Text + "\\",
             Port        = int.Parse(txtPort.Text),
             VirtualRoot = txtVirRoot.Text,
             IsRunning   = true
         }),
                          (results) =>
         {
             txtPort.Text    = txtPath.Text = string.Empty;
             txtVirRoot.Text = "/";
         },
                          (exceptions) => exceptions.ForEach(
                              exception =>
         {
             if (exception is PortInUseException || exception is WebsiteExistsAtTheSameUrl)
             {
                 TaskDialog.Show(
                     exception.Message,
                     App.APP_NAME,
                     string.Empty,
                     TaskDialogButton.OK,
                     TaskDialogIcon.Stop);
             }
             else
             {
                 TaskDialog.Show(
                     "Unhandled Exception.",
                     App.APP_NAME,
                     exception.StackTrace,
                     TaskDialogButton.OK,
                     TaskDialogIcon.Stop);
             }
         }),
                          () =>
         {
         }).ShowDialog(this);
     });
 }
예제 #2
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            var isReturnPending = false;
            var newWebSite      = new Website()
            {
                PhysicalPath =
                    txtPath.Text.EndsWith("\\", StringComparison.Ordinal)
                                             ? txtPath.Text
                                             : txtPath.Text + "\\",
                Port        = int.Parse(txtPort.Text),
                VirtualRoot = txtVirRoot.Text,
                IsRunning   = chkRunning.Checked
            };

            FormValidationUtility.ValidateHostSiteForm(txtPath, txtPort, txtVirRoot, this,
                                                       () =>
            {
                new ProgressForm(new ChangeSiteCommand(
                                     _Website,
                                     newWebSite),
                                 (results) =>
                {
                    _Website = newWebSite;
                },
                                 (exceptions) => exceptions.ForEach(
                                     exception =>
                {
                    if (exception is PortInUseException || exception is WebsiteExistsAtTheSameUrl)
                    {
                        TaskDialog.Show(
                            exception.Message,
                            App.APP_NAME,
                            string.Empty,
                            TaskDialogButton.OK,
                            TaskDialogIcon.Stop);
                    }
                    else
                    {
                        TaskDialog.Show(
                            "Unhandled Exception.",
                            App.APP_NAME,
                            exception.StackTrace,
                            TaskDialogButton.OK,
                            TaskDialogIcon.Stop);
                    }

                    isReturnPending = true;
                }),
                                 () =>
                {
                }).ShowDialog(this);
            });

            if (isReturnPending)
            {
                return;
            }

            if (App.Config.IsRunning)
            {
                if (!chkRunning.Checked)
                {
                    if (App.Config.Websites[_Website.Url].IsRunning)
                    {
                        new ProgressForm(new StopSiteCommand(_Website),
                                         () =>
                        {
                            Close();
                        }).ShowDialog(this);
                    }
                }
                else if (!App.Config.Websites[_Website.Url].IsRunning)
                {
                    new ProgressForm(new StartSiteCommand(_Website),
                                     () =>
                    {
                        Close();
                    }).ShowDialog(this);
                }
            }

            Dispose();
        }