public WebsiteHost(Website website)
 {
     Website = website;
 }
        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();
        }
Esempio n. 3
0
 public WebsiteHost(Website website)
 {
     Website = website;
 }