示例#1
0
 public void UpdateDeployLocationTextBlock()
 {
     if (DeveloperOptions.GetUseTestDirectory())
     {
         DeployLocationTextBlock.Text = "Test (\"/test\")";
     }
     else
     {
         DeployLocationTextBlock.Text = "Production";
     }
 }
示例#2
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (!FTPManager.ConfigurationLoaded)
            {
                FTPManager.LoadConfiguration();
            }
            UsernameTextBox.Text     = FTPManager.Username;
            PasswordTextBox.Password = FTPManager.Password;
            ServerTextBox.Text       = FTPManager.Server;

            BlankDeployCheckBox.IsChecked      = DeveloperOptions.GetBlankDeploy();
            UseTestDirectoryCheckBox.IsChecked = DeveloperOptions.GetUseTestDirectory();
            LocalDeployCheckBox.IsChecked      = DeveloperOptions.GetLocalDeploy();
        }
示例#3
0
 private void LocalDeployCheckBox_Click(object sender, RoutedEventArgs e)
 {
     DeveloperOptions.SetLocalDeploy((bool)LocalDeployCheckBox.IsChecked);
     DeveloperOptions.Save();
 }
示例#4
0
 private void UseTestDirectoryCheckBox_Click(object sender, RoutedEventArgs e)
 {
     DeveloperOptions.SetUseTestDirectory((bool)UseTestDirectoryCheckBox.IsChecked);
     DeveloperOptions.Save();
 }
        private async Task Deploy()
        {
            DateTime start    = DateTime.Now;
            double   interval = 100.0 / DeployPages.Count;
            int      i        = 1;

            DeployProgressBar.Value = 0;

            bool test  = DeveloperOptions.GetUseTestDirectory();
            bool blank = DeveloperOptions.GetBlankDeploy();

            if (DeveloperOptions.GetLocalDeploy())
            {
                StorageFolder deployFolder = null;
                if (await FileManager.GetExists(ApplicationData.Current.LocalFolder, "deploy"))
                {
                    deployFolder = (StorageFolder)(await ApplicationData.Current.LocalFolder.TryGetItemAsync("deploy"));
                    await deployFolder.DeleteAsync();
                }
                deployFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("deploy");

                foreach (ManagedWebPage page in DeployPages)
                {
                    StatusTextBlock.Text = $"{(DeployProgressBar.Value.ToString("0.00") + "%")} complete ({i} of {DeployPages.Count})";
                    Log($"\"{page.Title}\"... (Creating...)");

                    StorageFile indexHtml = await FileManager.CreateTemporaryFile(HTMLBuilder.GetFullPageHTML(page));

                    StorageFolder pageFolder = deployFolder, prev = deployFolder;
                    if (page.RelativeURL.Length > 1)
                    {
                        // recursively create folders
                        String[] dirs = page.RelativeURL.Split('/');
                        for (int ii = 0; ii < dirs.Length; ii++)
                        {
                            if (dirs[ii].Equals(""))
                            {
                                continue;
                            }
                            StorageFolder temp = prev;
                            if (await prev.TryGetItemAsync(dirs[ii]) == null)
                            {
                                prev = await temp.CreateFolderAsync(dirs[ii]);
                            }
                            else
                            {
                                prev = (StorageFolder)await temp.TryGetItemAsync(dirs[ii]);
                            }
                            pageFolder = prev;
                        }
                    }

                    // copy from temp to deploy
                    if (pageFolder != null)
                    {
                        await indexHtml.CopyAsync(pageFolder); // not home page, and needs its own directory
                    }
                    else
                    {
                        await indexHtml.CopyAsync(deployFolder); // must be home page
                    }
                    await indexHtml.DeleteAsync();

                    LogTextBlock.Text        = LogTextBlock.Text.Replace("(Creating...)", "(Done)");
                    DeployProgressBar.Value += interval;
                    i++;
                    page.Submitted();
                }
                // save because submitted times were updated
                await WebPageManager.Save();

                DeployProgressBar.Value = 100;
                StatusTextBlock.Text    = $"Finished ({(DateTime.Now.Subtract(start).TotalSeconds.ToString("0.0"))} seconds)";
                IsPrimaryButtonEnabled  = true;

                Log("Opening in File Explorer...");
                await Windows.System.Launcher.LaunchFolderAsync(deployFolder);

                return;
            }

            await FTPManager.Connect();

            // await Task.Delay(5000);
            // await FTPManager.Disconnect();
            Debug.Out("Connected!", "DEPLOY DIALOG");
            foreach (ManagedWebPage page in DeployPages)
            {
                string path = page.RelativeURL;
                if (test)
                {
                    path = $"/test{path}";
                }
                string percent = DeployProgressBar.Value.ToString("0.00") + "%";
                string msg     = "\"" + page.RelativeURL + "\"... (Uploading...)";

                StatusTextBlock.Text = percent + " complete (" + i + " of " + DeployPages.Count + ")";

                Log(msg);
                if (!blank)
                {
                    StorageFile file = await FileManager.CreateTemporaryFile(HTMLBuilder.GetFullPageHTML(page));

                    await FTPManager.UploadFile(file, path);

                    await file.DeleteAsync();

                    LogTextBlock.Text = LogTextBlock.Text.Replace("(Uploading...)", "(Finished)");
                }

                DeployProgressBar.Value += interval;
                i++;

                page.Submitted();
            }
            await FTPManager.Disconnect();

            // save because submitted times were updated
            await WebPageManager.Save();

            string timeTaken = DateTime.Now.Subtract(start).TotalSeconds.ToString("0.0");

            DeployProgressBar.Value = 100;
            StatusTextBlock.Text    = "Finished (" + timeTaken + " seconds)";
            IsPrimaryButtonEnabled  = true;
        }