void TemplatesTreeViewButtonPressed(object o, ButtonPressEventArgs args)
        {
            SolutionTemplate template = GetSelectedTemplate();

            if ((template == null) || (template.AvailableLanguages.Count <= 1))
            {
                return;
            }

            if (languageCellRenderer.IsLanguageButtonPressed(args.Event))
            {
                HandlePopup(template, args.Event.Time);
            }
        }
Ejemplo n.º 2
0
 void AddLanguageMenuItems(Menu menu, SolutionTemplate template)
 {
     foreach (string language in template.AvailableLanguages.OrderBy(item => item))
     {
         var menuItem = new MenuItem(language);
         menuItem.Activated += (o, e) => {
             templateTextRenderer.SelectedLanguage = language;
             controller.SelectedLanguage           = language;
             templatesTreeView.QueueDraw();
             ShowSelectedTemplate();
         };
         menu.Append(menuItem);
     }
 }
Ejemplo n.º 3
0
        async Task CreateAndBuild(
            SolutionTemplate template,
            NewProjectConfiguration config)
        {
            var result = await templatingService.ProcessTemplate(template, config, null);

            solution = result.WorkspaceItems.FirstOrDefault() as Solution;
            await solution.SaveAsync(Util.GetMonitor());

            // RestoreDisableParallel prevents parallel restores which sometimes cause
            // the restore to fail on Mono.
            RunMSBuild($"/t:Restore /p:RestoreDisableParallel=true \"{solution.FileName}\"");
            RunMSBuild($"/t:Build \"{solution.FileName}\"");
        }
Ejemplo n.º 4
0
 SolutionTemplate GetTemplateForProcessing()
 {
     if (SelectedTemplate.HasCondition)
     {
         string           language = GetLanguageForTemplateProcessing();
         SolutionTemplate template = SelectedTemplate.GetTemplate(language, finalConfigurationPage.Parameters);
         if (template != null)
         {
             return(template);
         }
         throw new ApplicationException(String.Format("No template found matching condition '{0}'.", SelectedTemplate.Condition));
     }
     return(GetSelectedTemplateForSelectedLanguage());
 }
 void AddLanguageMenuItems(Xwt.Menu menu, SolutionTemplate template)
 {
     foreach (string language in template.AvailableLanguages.OrderBy(item => item))
     {
         var menuItem = new Xwt.MenuItem(language);
         menuItem.Accessible.Label = LanguageCellRenderer.GetAccessibleLanguageName(language);
         menuItem.Clicked         += (o, e) => {
             languageCellRenderer.SelectedLanguage = language;
             controller.SelectedLanguage           = language;
             templatesTreeView.QueueDraw();
             ShowSelectedTemplate();
         };
         menu.Items.Add(menuItem);
     }
 }
Ejemplo n.º 6
0
        public TransactionResult <Boolean> Edit([FromForm] SolutionTemplate info)
        {
            TransactionResult <Boolean> result = new TransactionResult <Boolean>();
            var serviceResult = solutionTemplateService.UpdateByID(info);

            if (serviceResult.ActionResult)
            {
                result.Data = serviceResult.Data;
            }
            else
            {
                result.Code    = ErrorCode.NoData;
                result.Message = "暂无数据";
            }
            return(result);
        }
        void TemplatesTreeViewButtonPressed(object o, ButtonPressEventArgs args)
        {
            SolutionTemplate template = GetSelectedTemplate();

            if ((template == null) || (template.AvailableLanguages.Count <= 1))
            {
                return;
            }

            // Only display the popup menu on a single press, ignore anything else
            // Fixes a crash when triple clicking. VSTS #849556
            if (args.Event.Type == Gdk.EventType.ButtonPress && languageCellRenderer.IsLanguageButtonPressed(args.Event))
            {
                HandlePopup(template, args.Event.Time);
            }
        }
        void SelectTemplate(SolutionTemplate template)
        {
            var iters = WalkTree(templatesTreeStore, TreeIter.Zero);

            foreach (var iter in iters)
            {
                var currentTemplate = templatesTreeStore.GetValue(iter, TemplateColumn) as SolutionTemplate;
                if (currentTemplate == template)
                {
                    templatesTreeView.Selection.SelectIter(iter);
                    TreePath path = templatesTreeStore.GetPath(iter);
                    templatesTreeView.ScrollToCell(path, null, true, 1, 0);
                    break;
                }
            }
        }
Ejemplo n.º 9
0
        public TransactionResult <SolutionTemplate> Add([FromForm] SolutionTemplate info)
        {
            TransactionResult <SolutionTemplate> result = new TransactionResult <SolutionTemplate>();

            var serviceResult = solutionTemplateService.Create(info);

            if (serviceResult.ActionResult & serviceResult.HavingData)
            {
                result.Data = serviceResult.Data;
            }
            else
            {
                result.Code    = ErrorCode.NoData;
                result.Message = "暂无数据";
            }
            return(result);
        }
        void SelectTemplateDefinedbyController()
        {
            SolutionTemplate selectedTemplate = controller.SelectedTemplate;

            if (controller.SelectedSecondLevelCategory == null)
            {
                SelectFirstSubTemplateCategory();
                return;
            }

            SelectTemplateCategory(controller.SelectedSecondLevelCategory);

            if (selectedTemplate != null)
            {
                SelectTemplate(selectedTemplate);
            }
        }
Ejemplo n.º 11
0
        static string GetProjectTypeGuid(SolutionTemplate template)
        {
            string language = ProjectTemplateTest.GetLanguage(template.Id);

            if (language == "F#")
            {
                return("{F2A71F9B-5D33-465A-A702-920D77279786}");
            }

            if (language == "VBNet")
            {
                return("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}");
            }

            // C#
            return("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}");
        }
        void ShowTemplate(SolutionTemplate template)
        {
            string language = GetLanguageForTemplate(controller.SelectedTemplate);

            TreeIter item;

            if (templatesTreeView.Selection.GetSelected(out item))
            {
                templatesTreeStore.SetValue(item, TemplateA11yLanguageNameColumn, language);
            }

            templateNameLabel.Markup      = MarkupTemplateName(template.Name);
            templateDescriptionLabel.Text = template.Description;
            templateImage.Image           = controller.GetImage(template);
            templateVBox.Visible          = true;
            templateVBox.ShowAll();
        }
Ejemplo n.º 13
0
        void SelectTemplate(SolutionTemplate template)
        {
            TreeIter iter = TreeIter.Zero;

            if (!templatesListStore.GetIterFirst(out iter))
            {
                return;
            }

            while (templatesListStore.IterNext(ref iter))
            {
                var currentTemplate = templatesListStore.GetValue(iter, TemplateColumn) as SolutionTemplate;
                if (currentTemplate == template)
                {
                    templatesTreeView.Selection.SelectIter(iter);
                    break;
                }
            }
        }
        public async Task MoveToNextPage()
        {
            if (controller.IsLastPage)
            {
                try {
                    CanMoveToNextPage = false;
                    // disable all controls on this dialog to prevent users actions
                    VBox.Sensitive = false;
                    await controller.Create();
                } catch {
                    // if something goes wrong, we need to enable dialog contols
                    VBox.Sensitive = true;
                    throw;
                } finally {
                    CanMoveToNextPage = true;
                }
                return;
            }

            controller.MoveToNextPage();

            SolutionTemplate template = controller.GetSelectedTemplateForSelectedLanguage();

            if (template == null)
            {
                return;
            }

            Widget widget = GetWidgetToDisplay();

            centreVBox.Remove(centreVBox.Children [0]);
            widget.ShowAll();
            centreVBox.PackStart(widget, true, true, 0);
            FocusWidget(widget);

            topBannerLabel.Text = controller.BannerText;

            previousButton.Sensitive = controller.CanMoveToPreviousPage;
            nextButton.Label         = controller.NextButtonText;
            CanMoveToNextPage        = controller.CanMoveToNextPage;
        }
        void SelectTemplate(SolutionTemplate template)
        {
            TreeIter iter = TreeIter.Zero;

            if (!templatesListStore.GetIterFirst(out iter))
            {
                return;
            }

            while (templatesListStore.IterNext(ref iter))
            {
                var currentTemplate = templatesListStore.GetValue(iter, TemplateColumn) as SolutionTemplate;
                if (currentTemplate == template)
                {
                    templatesTreeView.Selection.SelectIter(iter);
                    TreePath path = templatesListStore.GetPath(iter);
                    templatesTreeView.ScrollToCell(path, null, true, 1, 0);
                    break;
                }
            }
        }
Ejemplo n.º 16
0
        public string GetCategoryPathText(SolutionTemplate template)
        {
            foreach (TemplateCategory topLevelCategory in templateCategories)
            {
                foreach (TemplateCategory secondLevelCategory in topLevelCategory.Categories)
                {
                    foreach (TemplateCategory thirdLevelCategory in secondLevelCategory.Categories)
                    {
                        foreach (SolutionTemplate t in thirdLevelCategory.Templates)
                        {
                            if (t.GetTemplate(child => child == template) != null)
                            {
                                return(String.Format("{0} → {1}", topLevelCategory.Name, secondLevelCategory.Name));
                            }
                        }
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 17
0
        string GetSelectedCategoryPath()
        {
            foreach (TemplateCategory topLevelCategory in templateCategories)
            {
                foreach (TemplateCategory secondLevelCategory in topLevelCategory.Categories)
                {
                    foreach (TemplateCategory thirdLevelCategory in secondLevelCategory.Categories)
                    {
                        SolutionTemplate matchedTemplate = thirdLevelCategory
                                                           .Templates
                                                           .FirstOrDefault(template => template == SelectedTemplate);
                        if (matchedTemplate != null)
                        {
                            return(String.Format("{0}/{1}", topLevelCategory.Id, secondLevelCategory.Id));
                        }
                    }
                }
            }

            return(null);
        }
        void HandlePopup(SolutionTemplate template, uint eventTime)
        {
            if (popupMenu == null)
            {
                popupMenu = new Menu();
                popupMenu.AttachToWidget(this, null);
            }
            ClearPopupMenuItems();
            AddLanguageMenuItems(popupMenu, template);
            popupMenu.ModifyBg(StateType.Normal, Styles.NewProjectDialog.TemplateLanguageButtonBackground.ToGdkColor());
            popupMenu.ShowAll();

            MenuPositionFunc posFunc = (Menu m, out int x, out int y, out bool pushIn) => {
                Gdk.Rectangle rect       = languageCellRenderer.GetLanguageRect();
                Gdk.Rectangle screenRect = GtkUtil.ToScreenCoordinates(templatesTreeView, templatesTreeView.GdkWindow, rect);
                x      = screenRect.X;
                y      = screenRect.Bottom;
                pushIn = false;
            };

            popupMenu.Popup(null, null, posFunc, 0, eventTime);
        }
        void HandlePopup(SolutionTemplate template, uint eventTime)
        {
            var engine    = Platform.IsMac ? Xwt.Toolkit.NativeEngine : Xwt.Toolkit.CurrentEngine;
            var xwtParent = Xwt.Toolkit.CurrentEngine.WrapWidget(templatesTreeView);

            engine.Invoke(() => {
                if (popupMenu == null)
                {
                    popupMenu = new Xwt.Menu();
                }
                ClearPopupMenuItems();
                AddLanguageMenuItems(popupMenu, template);
                Gdk.Rectangle rect = languageCellRenderer.GetLanguageRect();

                try {
                    popupMenu.Popup(xwtParent, rect.X, rect.Bottom);
                } catch {
                    // popup at mouse position if the toolkit is not supported
                    popupMenu.Popup();
                }
            });
        }
        async Task MoveToNextPage()
        {
            if (controller.IsLastPage)
            {
                try {
                    CanMoveToNextPage = false;
                    await controller.Create();
                } catch {
                    throw;
                } finally {
                    CanMoveToNextPage = true;
                }
                return;
            }

            controller.MoveToNextPage();

            SolutionTemplate template = controller.GetSelectedTemplateForSelectedLanguage();

            if (template == null)
            {
                return;
            }

            Widget widget = GetWidgetToDisplay();

            centreVBox.Remove(centreVBox.Children [0]);
            widget.ShowAll();
            centreVBox.PackStart(widget, true, true, 0);
            FocusWidget(widget);

            topBannerLabel.Text = controller.BannerText;

            previousButton.Sensitive = controller.CanMoveToPreviousPage;
            nextButton.Label         = controller.NextButtonText;
            CanMoveToNextPage        = controller.CanMoveToNextPage;
        }
Ejemplo n.º 21
0
 void SelectTemplate(
     Func <SolutionTemplate, bool> isTemplateMatch,
     Func <TemplateCategory, bool> isTopLevelCategoryMatch,
     Func <TemplateCategory, bool> isSecondLevelCategoryMatch)
 {
     foreach (TemplateCategory topLevelCategory in templateCategories.Where(isTopLevelCategoryMatch))
     {
         foreach (TemplateCategory secondLevelCategory in topLevelCategory.Categories.Where(isSecondLevelCategoryMatch))
         {
             foreach (TemplateCategory thirdLevelCategory in secondLevelCategory.Categories)
             {
                 SolutionTemplate matchedTemplate = thirdLevelCategory
                                                    .Templates
                                                    .FirstOrDefault(isTemplateMatch);
                 if (matchedTemplate != null)
                 {
                     SelectedSecondLevelCategory = secondLevelCategory;
                     SelectedTemplate            = matchedTemplate;
                     return;
                 }
             }
         }
     }
 }
Ejemplo n.º 22
0
        async Task <bool> CreateProject()
        {
            if (!projectConfiguration.IsValid())
            {
                MessageService.ShowError(projectConfiguration.GetErrorMessage());
                return(false);
            }

            if (ParentFolder != null && ParentFolder.ParentSolution.FindProjectByName(projectConfiguration.ProjectName) != null)
            {
                MessageService.ShowError(GettextCatalog.GetString("A Project with that name is already in your Project Space"));
                return(false);
            }

            if (ParentWorkspace != null && SolutionAlreadyExistsInParentWorkspace())
            {
                MessageService.ShowError(GettextCatalog.GetString("A solution with that filename is already in your workspace"));
                return(false);
            }

            SolutionTemplate template = GetTemplateForProcessing();

            if (ProjectNameIsLanguageKeyword(template.Language, projectConfiguration.ProjectName))
            {
                MessageService.ShowError(GettextCatalog.GetString("Illegal project name.\nName cannot contain a language keyword."));
                return(false);
            }

            ProcessedTemplateResult result = null;

            try {
                if (Directory.Exists(projectConfiguration.ProjectLocation))
                {
                    var question = GettextCatalog.GetString("Directory {0} already exists.\nDo you want to continue creating the project?", projectConfiguration.ProjectLocation);
                    var btn      = MessageService.AskQuestion(question, AlertButton.No, AlertButton.Yes);
                    if (btn != AlertButton.Yes)
                    {
                        return(false);
                    }
                }

                Directory.CreateDirectory(projectConfiguration.ProjectLocation);
            } catch (IOException) {
                MessageService.ShowError(GettextCatalog.GetString("Could not create directory {0}. File already exists.", projectConfiguration.ProjectLocation));
                return(false);
            } catch (UnauthorizedAccessException) {
                MessageService.ShowError(GettextCatalog.GetString("You do not have permission to create to {0}", projectConfiguration.ProjectLocation));
                return(false);
            }

            DisposeExistingNewItems();

            try {
                result = await TemplatingService.ProcessTemplate(template, projectConfiguration, ParentFolder);

                SetFirstBuildProperty(result.WorkspaceItems);
                if (!result.WorkspaceItems.Any())
                {
                    return(false);
                }
            } catch (UserException ex) {
                MessageService.ShowError(ex.Message, ex.Details);
                return(false);
            } catch (Exception ex) {
                MessageService.ShowError(GettextCatalog.GetString("The project could not be created"), ex);
                return(false);
            }
            processedTemplate = result;
            return(true);
        }
Ejemplo n.º 23
0
 static bool IsTemplateMatch(SolutionTemplate template, SolutionTemplate templateToMatch, string language, ProjectCreateParameters parameters)
 {
     return(template.Id == templateToMatch.Id &&
            template.Category == templateToMatch.Category &&
            template.GetTemplate(language, parameters) != null);
 }
Ejemplo n.º 24
0
 public void SaveSolutionTemplate(SolutionTemplate SolutionTemplate, Guid AdvisorId)
 {
     throw new NotImplementedException();
 }
        public async Task <IActionResult> PostSolutionTemplate([FromBody] SolutionTemplateViewModel solutionTemplateViewModel)
        {
            Console.WriteLine(solutionTemplateViewModel);
            try
            {
                var deserializer     = new Deserializer();
                var solutionTemplate = new SolutionTemplate();
                Console.WriteLine(JsonConvert.SerializeObject(solutionTemplateViewModel));
                solutionTemplate.Intent = solutionTemplateViewModel.Intent;

                solutionTemplate.Tasks = deserializer.Deserialize(new StringReader(solutionTemplateViewModel.Tasks));
                Console.WriteLine(JsonConvert.SerializeObject(solutionTemplate));

                List <dynamic> actions = new List <dynamic>();

                foreach (var e in solutionTemplate.Tasks as List <dynamic> )
                {
                    Guid   g          = Guid.NewGuid();
                    string GuidString = Convert.ToBase64String(g.ToByteArray());
                    GuidString = GuidString.Replace("=", "");
                    GuidString = GuidString.Replace("+", "");

                    if (e["stage"] == "action")
                    {
                        e["tags"] = new List <string> {
                            GuidString
                        }
                    }
                    ;

                    var data = JObject.Parse(JsonConvert.SerializeObject(e));
                    //Console.WriteLine(data);

                    if (data["stage"].ToString() == "action")
                    {
                        var values = data.ToObject <Dictionary <string, object> >();
                        values.Remove("stage");
                        actions.Add(values);

                        try {
                            if (values["register"] != null)
                            {
                                object redisobj = new { name = "Store gitdata in redis", shell = "redis-cli -h ${{REDIS_HOST}} -p ${{REDIS_PORT}} HSET ${{threadId}}" + " " + values["register"] + " '{{" + values["register"] + ".content}}'", tags = values["tags"] };
                                actions.Add(redisobj);
                            }
                        }
                        catch (Exception ex) {}
                    }
                }
                Console.WriteLine(JsonConvert.SerializeObject(solutionTemplate.Tasks));

                object        scriptobj = new { hosts = "localhost", gather_facts = false, tasks = actions };
                List <object> final     = new List <object>()
                {
                    scriptobj
                };
                var finalJson = JsonConvert.SerializeObject(final);

                var     expConverter     = new ExpandoObjectConverter();
                dynamic desiralizeObject = JsonConvert.DeserializeObject <List <ExpandoObject> >(finalJson, expConverter);

                var    serializer = new YamlDotNet.Serialization.Serializer();
                string yaml       = serializer.Serialize(desiralizeObject);
                //Console.Write(solutionTemplate.Intent);
                solutionTemplate.Actions = yaml;

                var solutionTemplateAsJsonString   = JsonConvert.SerializeObject(solutionTemplate);
                var solutionTemplateAsBsonDocument = BsonDocument.Parse(solutionTemplateAsJsonString);
                Console.WriteLine(solutionTemplateAsBsonDocument);
                await _service.CreateSolution(solutionTemplateAsBsonDocument);

                return(Ok());
            }
            catch (Exception e)
            {
                return(BadRequest(e.StackTrace));
            }
        }
Ejemplo n.º 26
0
 public Task SaveSolutionTemplateAsync(SolutionTemplate SolutionTemplate, Guid AdvisorId)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 27
0
 public bool CanProcessTemplate(SolutionTemplate template)
 {
     return(template is CustomSolutionTemplate);
 }
 static bool MatchTemplate(SolutionTemplate template, string templateId)
 {
     return(template.Id == templateId);
 }
Ejemplo n.º 29
0
 public Image GetImage(SolutionTemplate template)
 {
     return(imageProvider.GetImage(template));
 }
Ejemplo n.º 30
0
        //public FunctionResult<Solution> MakeCodeSolution(List<DatabaseTable> model, SolutionTemplate codeTemplate)
        //{
        //    FunctionResult<Solution> result = new FunctionResult<Solution>();
        //    if (codeTemplate.SolutionTemplates != null)
        //    {
        //        codeTemplate.SolutionTemplates.ForEach(t =>
        //        {
        //            //获取返回结果代码段
        //            //替换检查与断言标签
        //            //数据业务实现
        //        });
        //    }
        //    return result;
        //}
        public FunctionResult <Solution> MakeCodeForMultiStoreySolution(List <string> tables, SolutionTemplate codeTemplatee, string databaseConnection, string databaseName, string savePath)
        {
            var result = new FunctionResult <Solution>();

            result.Data = new Solution()
            {
                SolutionPath = savePath
            };
            //生成数据库原型类
            CodeTemplate modelTemplate = codeTemplatee.SolutionTemplates.Find(ct => ct.GenCodeType == CodeType.DataAccessModel);

            if (modelTemplate != null)
            {
                MakeCodeForModel(tables, modelTemplate, databaseConnection, databaseName, savePath);
            }
            //生成Dao层代码
            CodeTemplate dalTemplate = codeTemplatee.SolutionTemplates.Find(ct => ct.GenCodeType == CodeType.Dao);

            if (dalTemplate != null)
            {
                MakeCodeForDao(tables, dalTemplate, databaseConnection, databaseName, savePath, modelTemplate.SpaceName);
            }
            //生成服务层代码
            CodeTemplate serviceTemplate = codeTemplatee.SolutionTemplates.Find(ct => ct.GenCodeType == CodeType.Service);

            if (serviceTemplate != null)
            {
                MakeCodeForService(tables, serviceTemplate, databaseConnection, databaseName, savePath);
            }
            //生成controller层代码
            CodeTemplate viewServiceTemplate = codeTemplatee.SolutionTemplates.Find(ct => ct.GenCodeType == CodeType.ViewService);

            if (viewServiceTemplate != null)
            {
                MakeCodeForViewService(tables, viewServiceTemplate, databaseConnection, databaseName, savePath);
            }
            return(result);
        }