Esempio n. 1
0
        public Task <GenericPage> GetPageAsync(string link)
        {
            GenericPage Action()
            {
                using var conn = _conn;

                try
                {
                    var command = new SqliteCommand
                    {
                        Connection  = conn,
                        CommandText = "SELECT * FROM 'pages' WHERE link = @Link",
                    };
                    command.Parameters.AddWithValue("@Link", link);

                    conn.Open();
                    var reader = command.ExecuteReader();

                    var page = new GenericPage();
                    SqliteDataReaderToPageConverter.Instance.ConvertToPageModel(reader, page);

                    return(page);
                }
                catch (SqliteException e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }

            return(Task.Run(Action));
        }
        public IEnumerable <GenericPageHistory> ConvertToHistoryPageModels(SqliteDataReader reader)
        {
            var pages = new List <GenericPageHistory>();

            while (reader.Read())
            {
                var page = new GenericPage();
                if (SqliteDataToPageModel(reader, page))
                {
                    var action = (PageAction)reader.GetInt32(reader.GetOrdinal("action"));

                    var pageHistory = new GenericPageHistory(page)
                    {
                        ValidFrom =
                            Instant.FromUnixTimeMilliseconds(reader.GetInt64(reader.GetOrdinal("valid_from"))),
                        ValidTo = Instant.FromUnixTimeMilliseconds(reader.GetInt64(reader.GetOrdinal("valid_to"))),
                        Action  = (PageAction)reader.GetInt16(reader.GetOrdinal("action"))
                    };

                    pages.Add(pageHistory);
                }
            }

            return(pages);
        }
        protected bool SqliteDataToPageModel(SqliteDataReader reader, GenericPage page)
        {
            page.Id          = Guid.Parse(reader.GetString(reader.GetOrdinal("id")));
            page.Link        = reader.GetString(reader.GetOrdinal("link"));
            page.Content     = reader.GetString(reader.GetOrdinal("content"));
            page.Created     = Instant.FromUnixTimeMilliseconds(reader.GetInt64(reader.GetOrdinal("created")));
            page.LastChanged = Instant.FromUnixTimeMilliseconds(reader.GetInt64(reader.GetOrdinal("changed")));
            page.IsLocked    = reader.GetBoolean(reader.GetOrdinal("locked"));
            //page.ContentType = reader.GetString(reader.GetOrdinal("contentType"));
            page.ContentType = ContentType.Parse(reader.GetString(reader.GetOrdinal("contentType")));

            var link = reader.GetString(reader.GetOrdinal("link"));
            var path = link.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);

            if (path.Length > 1)
            {
                string[] path2 = new string[path.Length - 1];
                Array.Copy(path, path2, path.Length - 1);

                page.Path = Path.of(path2, path[path.Length - 1]);
            }
            else
            {
                page.Path = Path.ofLink(link);
            }

            return(true);
        }
Esempio n. 4
0
        public Task <bool> UpdatePage(GenericPage page, PageAction action)
        {
            bool PageAction(GenericPage page)
            {
                using var conn = _conn;

                var command = new SqliteCommand
                {
                    Connection  = conn,
                    CommandText =
                        "UPDATE 'pages_history' SET valid_to = @Now WHERE valid_to = -1 AND id = @Id;\nINSERT INTO 'pages_history' (id, link, content, created, changed, locked, contentType, valid_to, valid_from, action) VALUES (@Id, @Link, @Content, @Created, @Changed, @Locked, @ContentType, -1, @Now, @Action);\nUPDATE 'pages' SET id = @Id, link = @Link, content = @Content, created = @Created, changed = @Changed, locked = @Locked, contentType = @ContentType WHERE id = @Id;"
                };

                command.Parameters.AddWithValue("@Id", page.Id.ToString());
                command.Parameters.AddWithValue("@Link", page.Link);
                command.Parameters.AddWithValue("@Content", page.Content);
                command.Parameters.AddWithValue("@Created", page.Created.ToUnixTimeMilliseconds());
                command.Parameters.AddWithValue("@Changed", _clock.GetCurrentInstant().ToUnixTimeMilliseconds());
                command.Parameters.AddWithValue("@Locked", page.IsLocked);
                command.Parameters.AddWithValue("@ContentType", page.ContentType.Name);
                command.Parameters.AddWithValue("@Now", _clock.GetCurrentInstant().ToUnixTimeMilliseconds());
                command.Parameters.AddWithValue("@Action", action);

                conn.Open();
                var result = command.ExecuteNonQuery();

                return(true);
            }

            return(new TaskFactory <bool>().StartNew((page) => PageAction((GenericPage)page), page));
        }
Esempio n. 5
0
		public void GenericPageCtor_PageSizeZero_ThrowsArgumentOutOfRangeException()
		{
			int[] ints = { 1, 2, 3 };
			Assert.Throws(typeof(ArgumentOutOfRangeException), () =>
			{
				var page = new GenericPage<int>(ints, 0, 0);
			});
		}
Esempio n. 6
0
 private static void AddSharedCommonWorkflowNameQuestion(List <IWizardPage> pages)
 {
     pages.Add(GenericPage.Create(new TextQuestionInfo("What do you want the name of the shared common workflow assembly to be?")
     {
         DefaultResponse = GenericPage.GetSaveResultsFormat(Page.RootNamespace) + ".WorkflowCore",
         Description     = "This will be the name of a shared C# project that contains references to the workflow code.  It would only be required by assemblies containing a workflow."
     }));
 }
Esempio n. 7
0
 private static void AddSolutionNameQuestion(List <IWizardPage> pages)
 {
     pages.Add(GenericPage.Create(new PathQuestionInfo("What Solution?")
     {
         Filter      = "Solution Files (*.sln)|*.sln",
         Description = "This wizard will walk through the process of adding a plugin/workflow project to a solution that already has the DLaB/XrmUnitTest accelerators installed."
     }));
 }
Esempio n. 8
0
 public APLoginPage(IWebDriver driver) : base(driver)
 {
     Header          = new Header(driver);
     AccountMenuLeft = new AccountMenuLeft(driver);
     Helper          = new GenericPage(driver);
     this.detailSingInPage.Init(driver, SeleniumConstants.defaultWaitTime);
     this.InitializeWebElements();
 }
Esempio n. 9
0
        public AllPointsBaseWebPage(IWebDriver driver) : base(driver)
        {
            Header          = new Header(driver);
            AccountMenuLeft = new AccountMenuLeft(driver);

            //deprecated
            Helper = new GenericPage(driver);
        }
Esempio n. 10
0
 public void GenericPageCtor_PageSizeZero_ThrowsArgumentOutOfRangeException()
 {
     int[] ints = { 1, 2, 3 };
     Assert.Throws(typeof(ArgumentOutOfRangeException), () =>
     {
         var page = new GenericPage <int>(ints, 0, 0);
     });
 }
Esempio n. 11
0
 private static void AddSharedCommonNameQuestion(List <IWizardPage> pages)
 {
     pages.Add(GenericPage.Create(new TextQuestionInfo("What do you want the name of the shared common assembly to be?")
     {
         DefaultResponse = GenericPage.GetSaveResultsFormat(Page.RootNamespace),
         Description     = "This will be the name of a shared C# project that will be used to store common code including plugin logic and early bound entities if applicable"
     }));
 }
        public bool ConvertToPageModel(SqliteDataReader reader, GenericPage page)
        {
            while (reader.Read())
            {
                return(SqliteDataToPageModel(reader, page));
            }

            return(false);
        }
 public void Setup()
 {
     this.Browser    = new WebDriver();
     this.TestHelper = new TestSupport();
     this.Browser.OpenAndResetBrowserSize(ConfigurationManager.ConnectionStrings["SeleniumTestUrl"].ToString());
     this.Browser.WaitForPageAndAjax();
     this.GenericPage       = new GenericPage(this.Browser);
     this.StartPage         = new StartPage(this.Browser);
     this.SearchResultsPage = new SearchResultPage(this.Browser);
 }
Esempio n. 14
0
        protected override async void OnNavigatedTo([NotNull] NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var path = (string)e.Parameter;

            Page = await _storage.GetPageAsync(path);

            LaunchExternalEditor();
        }
Esempio n. 15
0
 private static void AddUseEarlyBoundQuestion(List <IWizardPage> pages)
 {
     pages.Add(GenericPage.Create(new ConditionalYesNoQuestionInfo("Do you want to use the Early Bound Generator To Create Early Bound Entities?")
     {
         Description = "If yes, generates the default Early Bound Generator Settings, but Configures the output paths of the entities/option sets/actions to generate files in the appropriate shared project within the solution."
                       + Environment.NewLine
                       + "The Early Bound Generator XrmToolBox plugin must be installed to generate the entities, and must be a version 1.2019.3.12 or greater."
                       + Environment.NewLine
                       + "The Early Bound Generator will also be triggered upon completion to generate the Early Bound classes."
     }));
 }
Esempio n. 16
0
 private static void AddCreateProjectQuestion(List <IWizardPage> pages, string projectType)
 {
     pages.Add(GenericPage.Create(new ConditionalYesNoQuestionInfo($"Do you want to create a {projectType} project?")
     {
         Yes = new TextQuestionInfo($"What should the {projectType} project be called?")
         {
             DefaultResponse = $"Something.{projectType}",
             Description     = $"The name and default namespace for the {projectType} project."
         },
         Description = $"This will add a new {projectType} project to the solution and wire up the appropriate references."
     }));
 }
Esempio n. 17
0
        private static void AddWorkflowTestProjectNameQuestion(List <IWizardPage> pages)
        {
            var page = GenericPage.Create(new TextQuestionInfo("What do you want the name of the workflow test project to be?")
            {
                DefaultResponse = GenericPage.GetSaveResultsFormat(Page.CreateWorkflow, 1) + ".Tests",
                Description     = "This will be the name of the Visual Studio Unit Test Project for the workflow assembly."
            });

            page.AddSavedValuedRequiredCondition(Page.CreateWorkflow, "Y");
            page.AddSavedValuedRequiredCondition(Page.UseXrmUnitTest, "Y");
            pages.Add(page);
        }
Esempio n. 18
0
        private static void AddCreateXrmUnitTestProjectQuestion(List <IWizardPage> pages, int forPage)
        {
            var page = GenericPage.Create(new ConditionalYesNoQuestionInfo("Do you want to create a XrmUnitTest test project for the new assembly?")
            {
                Yes = new TextQuestionInfo("What do you want the name of the test project to be?")
                {
                    DefaultResponse = GenericPage.GetSaveResultsFormat(forPage, 1) + ".Tests",
                    Description     = "This will be the name of the Visual Studio Unit Test Project for the assembly."
                }
            });

            page.AddSavedValuedRequiredCondition(forPage, "Y");
            pages.Add(page);
        }
        public IList <GenericPage> ConvertToPageModels(SqliteDataReader reader)
        {
            var pages = new List <GenericPage>();

            while (reader.Read())
            {
                var page = new GenericPage();
                if (SqliteDataToPageModel(reader, page))
                {
                    pages.Add(page);
                }
            }

            return(pages);
        }
Esempio n. 20
0
        private static void AddInstallCodeSnippetAndAddCodeGenerationQuestion(List <IWizardPage> pages)
        {
            var page = GenericPage.Create(new ComboQuestionInfo("Do you want to install code snippets for plugins and unit testing?")
            {
                DefaultResponse = 0,
                Description     = "This will install snippets in your local Visual Studio \"My Code Snippets\" directories."
            },
                                          new ComboQuestionInfo("Do you want to add Code Generation files to your solution?")
            {
                DefaultResponse = 0,
                Description     = "The snippet files installed and a LinqPad Guid Generator file will be added to the solution for reference."
            });

            pages.Add(page);
        }
Esempio n. 21
0
 private static void AddCreateWorkflowProjectQuestion(List <IWizardPage> pages)
 {
     pages.Add(GenericPage.Create(new ConditionalYesNoQuestionInfo("Do you want to create a Workflow Project?")
     {
         Yes = new TextQuestionInfo("What should the workflow project be called??")
         {
             DefaultResponse = GenericPage.GetSaveResultsFormat(Page.RootNamespace) + ".Workflow",
             Description     = "The name and default namespace for the workflow project."
         },
         Yes2 = new ComboQuestionInfo("Include example custom workflow activity?")
         {
             DefaultResponse = 0
         },
         Description = "This will add a new workflow project to the solution and wire up the appropriate references."
     }));
 }
Esempio n. 22
0
        public void LoginMethod()
        {
            LoginPage   lPage = new LoginPage();
            GenericPage gPage = new GenericPage();

            PageFactory.InitElements(Driver, lPage);
            PageFactory.InitElements(Driver, gPage);
            MobileGeneric mobileGeneric = new MobileGeneric();

            lPage.clearUserName();
            lPage.enterUserName(testdata.email.ToString());
            lPage.enterPassword(testdata.password.ToString());
            mobileGeneric.HideDeviceKeyboard();
            lPage.clickLoginBtn();
            mobileGeneric.StaticWait(5);
        }
        private async Task <bool> InsertTextTestPage()
        {
            if (await _backend.ContainsPageAsync("system:texttest").ConfigureAwait(false))
            {
                return(false);
            }

            var content = await _assetsService.GetTextTestPage().ConfigureAwait(false);

            var instant = _clock.GetCurrentInstant();

            var startPage = new GenericPage(Path.ofLink("system:texttest"), content, ContentType.Text, instant, instant, true);

            await _backend.InsertPageAsync(startPage).ConfigureAwait(false);

            return(true);
        }
Esempio n. 24
0
 private static void AddUseXrmUnitTestQuestion(List <IWizardPage> pages)
 {
     pages.Add(GenericPage.Create(new ConditionalYesNoQuestionInfo("Do you want to use XrmUnitTest for unit testing?")
     {
         Yes = new TextQuestionInfo("What do you want the Test Settings project to be called?")
         {
             DefaultResponse = GenericPage.GetSaveResultsFormat(Page.RootNamespace) + ".Test",
             Description     = "The Test Settings project will contain the single test settings config file and assumption xml files."
         },
         Yes2 = new TextQuestionInfo("What do you want the shared core test project to be called?")
         {
             DefaultResponse = GenericPage.GetSaveResultsFormat(Page.RootNamespace) + ".TestCore",
             Description     = "The shared Test Project will contain all other shared test code (Assumption Definitions, Builders, Test Base Class, etc)"
         },
         Description = "This will add the appropriate NuGet References and create the appropriate isolation projects."
     }));
 }
Esempio n. 25
0
 private static void AddCreatePluginProjectQuestion(List <IWizardPage> pages)
 {
     pages.Add(GenericPage.Create(new ConditionalYesNoQuestionInfo("Do you want to create a Plugin Project?")
     {
         Yes = new TextQuestionInfo("What should the plugin project be called?")
         {
             DefaultResponse = GenericPage.GetSaveResultsFormat(Page.RootNamespace) + ".Plugin",
             Description     = "The name and default namespace for the plugin project."
         },
         Yes2 = new ComboQuestionInfo("Include example plugin classes?")
         {
             DefaultResponse = 0,
             Description     = "If example plugin classes are included, it may contain compiler errors if the Early Bound Entities used in the files are not generated.",
         },
         Description = "This will add a new plugin project to the solution and wire up the appropriate references."
     }));
 }
        public async Task <bool> InsertHtmlTestPage()
        {
            if (await _backend.ContainsPageAsync("system:htmltest"))
            {
                return(false);
            }

            var content = await _assetsService.GetHtmlTestPage();

            var instant = _clock.GetCurrentInstant();

            var startPage = new GenericPage(Path.ofLink("system:htmltest"), content, ContentType.Html, instant, instant, true);

            await _backend.InsertPageAsync(startPage);

            return(true);
        }
Esempio n. 27
0
 private static void AddRootNamespaceQuestion(List <IWizardPage> pages)
 {
     pages.Add(GenericPage.Create(new TextQuestionInfo("What is the root NameSpace?")
     {
         DefaultResponse     = GenericPage.GetSaveResultsFormat(Page.SolutionPath, 1),
         EditDefaultResponse = (value) =>
         {
             value = System.IO.Path.GetFileNameWithoutExtension(value) ?? "MyCompanyAbrv.Xrm";
             if (!value.ToUpper().Contains("XRM"))
             {
                 value += ".Xrm";
             }
             return(value);
         },
         Description = "This is the root namespace that will the Plugin and (if desired) Early Bound Entities will be appended to."
     }));
 }
        public void AddPage(GenericPage page)
        {
            for (var i = 0; i < _mostRecentlyViewedPages.Count; i++)
            {
                var item = _mostRecentlyViewedPages[i];

                if (item.Id.Equals(page.Id))
                {
                    _mostRecentlyViewedPages.RemoveAt(i);
                    break;
                }
            }

            _mostRecentlyViewedPages.Add(new MostRecentlyViewedPagesItem(page.Id, page.Path));

            Normalize();
        }
Esempio n. 29
0
 private static void AddSolutionNameQuestion(List <IWizardPage> pages)
 {
     pages.Add(GenericPage.Create(new ConditionalYesNoQuestionInfo("Do you want to add the DLaB Accelerators to an existing solution?")
     {
         Yes = new PathQuestionInfo("What Solution?")
         {
             Filter      = "Solution Files (*.sln)|*.sln",
             Description = "This Wizard will walk through the process of adding isolation/plugin/workflow/testing projects based on the DLaB/XrmUnitTest framework.  The configured projects will be add to the solution defined here."
         },
         No = new PathQuestionInfo("What Solution?")
         {
             Filter            = "Solution Files (*.sln)|*.sln",
             Description       = "This Wizard will walk through the process of adding isolation/plugin/workflow/testing projects based on the DLaB/XrmUnitTest framework.  The configured projects will be add to a new solution created at the path defined here.",
             RequireFileExists = false,
             DefaultResponse   = "C:\\FolderUnderSourceControl\\YourCompanyAbbreviation.Xrm.sln"
         },
     }));
 }
Esempio n. 30
0
        public string RenderPage(GenericPage page)
        {
            switch (page.ContentType.MimeType)
            {
            case "text/markdown":
                var renderer = new MarkdownRenderer(_markdig);
                return(renderer.RenderToHtml(page.Content));

            case "text/html":
                return(page.Content);

            case "text/plain":
                return($"<pre>{page.Content}</pre>");

            default:
                return(page.Content);
            }
        }
Esempio n. 31
0
        public Task <bool> InsertPageAsync(GenericPage page)
        {
            bool PageAction(GenericPage page)
            {
                using var conn = _conn;

                try
                {
                    var command = new SqliteCommand
                    {
                        Connection  = conn,
                        CommandText =
                            "INSERT INTO 'pages' (id, link, content, created, changed, locked, contentType) VALUES (@Id, @Link, @Content, @Created, @Changed, @Locked, @ContentType);\nINSERT INTO 'pages_history' (id, link, content, created, changed, locked, contentType, valid_to, valid_from, action) VALUES (@Id, @Link, @Content, @Created, @Changed, @Locked, @ContentType, -1, @Now, @Action);"
                    };
                    command.Parameters.AddWithValue("@Id", page.Id.ToString());
                    command.Parameters.AddWithValue("@Link", page.Link);
                    command.Parameters.AddWithValue("@Content", page.Content);
                    command.Parameters.AddWithValue("@Created", _clock.GetCurrentInstant().ToUnixTimeMilliseconds());
                    command.Parameters.AddWithValue("@Changed", _clock.GetCurrentInstant().ToUnixTimeMilliseconds());
                    command.Parameters.AddWithValue("@Locked", page.IsLocked);
                    command.Parameters.AddWithValue("@ContentType", page.ContentType.Name);
                    command.Parameters.AddWithValue("@Now", _clock.GetCurrentInstant().ToUnixTimeMilliseconds());
                    command.Parameters.AddWithValue("@Action", global::PrivateWiki.DataModels.Pages.PageAction.Created);

                    conn.Open();

                    command.ExecuteReader();

                    return(true);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }

            return(new TaskFactory <bool>().StartNew((page) => PageAction((GenericPage)page), page));
        }