예제 #1
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);
        }
예제 #2
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);
                }
            }
        }
예제 #3
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);
            }
        }