Esempio n. 1
0
        private void GenerateExtraFiles(AddAzureServiceDialog dlg, string importName)
        {
            var item       = GetSelectedItem().Value;
            var dteProject = GetProject(item.pHier);

            if (dlg.AddDashboardDisplay.IsChecked.Value)
            {
                var targetFolder = GetTargetFolder(dteProject, dlg.DashboardTargetFolder.Text);

                switch (GetProjectKind(item))
                {
                case ProjectKind.Bottle:
                    AddToNewFile(
                        dlg.GenerateBottleDashboardTemplate(),
                        targetFolder,
                        dlg.ServiceName.Text + "_dashboard" + ".tpl"
                        );

                    // TODO: Find actual routes file
                    AddToExisting(
                        dteProject.ProjectItems.Item("routes.py"),
                        dlg.GenerateBottleDashboardRoute(importName)
                        );
                    break;
                }
            }

            if (dlg.AddInputForm.IsChecked.Value)
            {
                switch (GetProjectKind(item))
                {
                case ProjectKind.Bottle:
                    AddToNewFile(
                        dlg.GenerateBottleFormTemplate(),
                        GetTargetFolder(dteProject, dlg.InputTargetFolder.Text),
                        dlg.ServiceName.Text + "_form" + ".tpl"
                        );

                    if (!dlg.AddDashboardDisplay.IsChecked.Value)
                    {
                        // we need the dashboard template to view the results.
                        AddToNewFile(
                            dlg.GenerateBottleDashboardTemplate(),
                            GetTargetFolder(dteProject, dlg.InputTargetFolder.Text),
                            dlg.ServiceName.Text + "_dashboard" + ".tpl"
                            );
                    }

                    AddToExisting(
                        dteProject.ProjectItems.Item("routes.py"),
                        dlg.GenerateBottleFormRoute(importName)
                        );
                    break;
                }
            }
        }
Esempio n. 2
0
        private static void AddToNewFile(VSITEMSELECTION item, AddAzureServiceDialog dlg)
        {
            var code     = dlg.GenerateServiceCode();
            var tempFile = Path.GetTempFileName();

            File.WriteAllText(tempFile, code);

            var projectItem = GetProjectItems(item).AddFromTemplate(
                tempFile,
                dlg.ServiceName.Text + ".py"
                );
            var window = projectItem.Open();

            window.Activate();
        }
Esempio n. 3
0
        private static void AddToNewFile(VSITEMSELECTION item, AddAzureServiceDialog dlg) {
            var code = dlg.GenerateServiceCode();
            var tempFile = Path.GetTempFileName();
            File.WriteAllText(tempFile, code);

            var projectItem = GetProjectItems(item).AddFromTemplate(
                tempFile,
                dlg.ServiceName.Text + ".py"
            );
            var window = projectItem.Open();
            window.Activate();
        }
Esempio n. 4
0
        private void GenerateExtraFiles(AddAzureServiceDialog dlg, string importName) {
            var item = GetSelectedItem().Value;
            var dteProject = GetProject(item.pHier);

            if (dlg.AddDashboardDisplay.IsChecked.Value) {
                var targetFolder = GetTargetFolder(dteProject, dlg.DashboardTargetFolder.Text);

                switch (GetProjectKind(item)) {
                    case ProjectKind.Bottle:
                        AddToNewFile(
                            dlg.GenerateBottleDashboardTemplate(),
                            targetFolder, 
                            dlg.ServiceName.Text + "_dashboard" + ".tpl"
                        );

                        // TODO: Find actual routes file
                        AddToExisting(
                            dteProject.ProjectItems.Item("routes.py"), 
                            dlg.GenerateBottleDashboardRoute(importName)
                        );
                        break;
                }
            }

            if (dlg.AddInputForm.IsChecked.Value) {
                switch (GetProjectKind(item)) {
                    case ProjectKind.Bottle:
                        AddToNewFile(
                            dlg.GenerateBottleFormTemplate(),
                            GetTargetFolder(dteProject, dlg.InputTargetFolder.Text),
                            dlg.ServiceName.Text + "_form" + ".tpl"
                        );

                        if (!dlg.AddDashboardDisplay.IsChecked.Value) {
                            // we need the dashboard template to view the results.
                            AddToNewFile(
                                dlg.GenerateBottleDashboardTemplate(),
                                GetTargetFolder(dteProject, dlg.InputTargetFolder.Text),
                                dlg.ServiceName.Text + "_dashboard" + ".tpl"
                            );
                        }

                        AddToExisting(
                            dteProject.ProjectItems.Item("routes.py"),
                            dlg.GenerateBottleFormRoute(importName)
                        );
                        break;
                }
            }
        }