예제 #1
0
        public override void Execute(object parameter)
        {
            var context = parameter as ContentTreeContext;

            if (context == null)
            {
                return;
            }

            var item = context.SelectedItems.FirstOrDefault() as SiteTreeViewItem;

            if (item == null)
            {
                return;
            }

            var d = new UpdateServerComponentsDialog();

            d.Initialize(item.Site.DataService, item.Site.Name, item.Site.WebRootPath, item.Site, null);
            try
            {
                AppHost.Shell.ShowDialog(d);
            }
            catch (Exception ex)
            {
                AppHost.Output.LogException(ex);
            }
        }
예제 #2
0
        public static Site NewConnection([Localizable(false)][NotNull] string hostName, [NotNull] string userName, [CanBeNull] ConnectionFolderTreeViewItem parent)
        {
            Assert.ArgumentNotNull(hostName, nameof(hostName));
            Assert.ArgumentNotNull(userName, nameof(userName));

            var connection = new Connection
            {
                UserName = userName,
                Password = @"b",
                HostName = hostName
            };

            var site = new Site(connection);

            var dialog = new SiteEditor();

            dialog.Load(site);
            if (AppHost.Shell.ShowDialog(dialog) != true)
            {
                return(null);
            }

            var oldSite = FindSite(site.HostName, site.UserName);

            if (oldSite != null)
            {
                AppHost.Sites.Disconnect(oldSite);
            }

            if (parent != null)
            {
                connection.FileName = ConnectionManager.GetFileName(connection, parent.Folder);
            }

            Add(site);

            ConnectionManager.Add(site.Connection);
            ConnectionManager.Save();

            CreateSiteTreeViewItem(site, parent);

            Notifications.RaiseSiteAdded(site, site);

            var editor = dialog.DataServiceEditor as WebServiceSiteEditor;

            if (editor != null)
            {
                if (editor.AutomaticUpdate.IsChecked == true)
                {
                    UpdateServerComponentsDialog.AutomaticUpdate(site.DataService, site.Name, site.WebRootPath, site);
                }
            }

            return(site);
        }
예제 #3
0
        public override void Execute(object parameter)
        {
            var selectedItems = GetSelectedItems();

            if (selectedItems.Count != 1)
            {
                return;
            }

            var items = GetProjects(selectedItems);
            var item  = items[0];

            var project = ProjectManager.GetProject(item.FileName);

            if (project == null)
            {
                return;
            }

            var site = project.Site;

            if (site == null)
            {
                return;
            }

            var siteEditor = new SiteEditor();

            siteEditor.Load(site);

            if (AppHost.Shell.ShowDialog(siteEditor) != true)
            {
                return;
            }

            ConnectionManager.Save();

            project.HostName = site.HostName;
            project.UserName = site.UserName;
            project.Save();

            Notifications.RaiseSiteChanged(this, site);

            var editor = siteEditor.DataServiceEditor as WebServiceSiteEditor;

            if (editor != null)
            {
                if (editor.AutomaticUpdate.IsChecked == true)
                {
                    UpdateServerComponentsDialog.AutomaticUpdate(site.DataService, site.Name, site.WebRootPath, site);
                }
            }
        }
        protected override void Process(TroubleshooterPipeline pipeline)
        {
            Debug.ArgumentNotNull(pipeline, nameof(pipeline));

            if (pipeline.Exception == null)
            {
                return;
            }

            if (!(pipeline.Exception is EndpointNotFoundException))
            {
                return;
            }

            pipeline.Abort();

            pipeline.Cancelled = true;
            pipeline.Retry     = false;

            if (pipeline.Silent)
            {
                return;
            }

            if (pipeline.DataService is HardRockWebService && !pipeline.UpdatedServerComponents)
            {
                pipeline.UpdatedServerComponents = true;

                switch (AppHost.MessageBox("The web site does not respond.\n\nThe connection is using the Hard Rock Web Server which may not yet have been installed on the server.\n\nDo you want to update server components?", Resources.Information, MessageBoxButton.YesNoCancel, MessageBoxImage.Question))
                {
                case MessageBoxResult.Yes:
                    var d = new UpdateServerComponentsDialog();

                    d.Initialize(pipeline.DataService, string.Empty, string.Empty, null, null);
                    AppHost.Shell.ShowDialog(d);

                    pipeline.Cancelled = false;
                    pipeline.Retry     = true;
                    return;

                case MessageBoxResult.Cancel:
                    pipeline.Cancelled = true;
                    pipeline.Retry     = false;
                    return;
                }
            }

            if (AppHost.MessageBox("The web site does not respond.\n\nPlease make sure the web site is up and running.\n\nDo you want to retry?", Resources.Information, MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
            {
                pipeline.Cancelled = false;
                pipeline.Retry     = true;
            }
        }
예제 #5
0
        public static bool HandleExecute([NotNull] string response, [NotNull] ExecuteResult executeResult, bool silent)
        {
            Assert.ArgumentNotNull(response, nameof(response));
            Assert.ArgumentNotNull(executeResult, nameof(executeResult));

            if (executeResult.Cancelled)
            {
                return(false);
            }

            if (executeResult.Error != null)
            {
                TroubleshooterPipeline.Run().WithParameters(executeResult.DataService, false, executeResult.Error, executeResult.DataService.GetEndpoint(), silent);
                return(false);
            }

            if (!response.Contains(@"***ERROR***"))
            {
                return(true);
            }

            var message = response.Mid(12).Trim();

            AppHost.Usage.ReportServerError(message);

            if (message == @"The system cannot find the file specified. (Exception from HRESULT: 0x80070002)")
            {
                if (silent)
                {
                    return(false);
                }

                if (AppHost.MessageBox(Resources.DataService_HandleExecute_MissingFile, Resources.Error, MessageBoxButton.OKCancel, MessageBoxImage.Error) != MessageBoxResult.OK)
                {
                    return(false);
                }

                var d = new UpdateServerComponentsDialog();
                d.Initialize(executeResult.DataService, string.Empty, string.Empty, null, null);
                AppHost.Shell.ShowDialog(d);

                return(false);
            }

            if (!silent)
            {
                AppHost.MessageBox(message, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
            }

            return(false);
        }
예제 #6
0
        public bool InstallHardRockWebService(bool showMessage = true)
        {
            if (showMessage)
            {
                if (AppHost.MessageBox(Resources.OldWebService_InstallHardRockWebService_, Resources.Information, MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
                {
                    return(false);
                }
            }

            UpdateServerComponentsDialog.Execute(this, Connection.HostName, Connection.WebRootPath, null);

            return(true);
        }
예제 #7
0
        protected virtual void Update([NotNull] SiteEditor siteEditor, [NotNull] Site site)
        {
            Debug.ArgumentNotNull(site, nameof(site));
            Debug.ArgumentNotNull(siteEditor, nameof(siteEditor));

            var editor = siteEditor.DataServiceEditor as WebServiceSiteEditor;

            if (editor == null)
            {
                return;
            }

            if (editor.AutomaticUpdate.IsChecked == true)
            {
                UpdateServerComponentsDialog.AutomaticUpdate(site.DataService, site.Name, site.WebRootPath, site);
            }
        }
예제 #8
0
        protected override bool CheckVersion()
        {
            if (dataService == null || string.IsNullOrEmpty(WebServiceVersion))
            {
                InitializeDataService();

                if (dataService == null)
                {
                    return(false);
                }
            }

            var webServiceVersion = WebServiceVersion ?? string.Empty;
            var assemblyVersion   = Assembly.GetExecutingAssembly().GetFileVersion().ToString();

            if (webServiceVersion == assemblyVersion)
            {
                return(true);
            }

            if (DisableLoginErrorMessage)
            {
                return(false);
            }

            var text = string.Format(Resources.HardRockWebService_CheckVersion_, webServiceVersion, assemblyVersion);

            var dialogResult = AppHost.MessageBox(text, Resources.Warning, MessageBoxButton.OKCancel, MessageBoxImage.Warning);

            if (dialogResult != MessageBoxResult.OK)
            {
                return(false);
            }

            UpdateServerComponentsDialog.Execute(this, Connection.HostName, Connection.WebRootPath, null);

            return(false);
        }