Пример #1
0
        public static async Task <(GenerationReturn generationReturn, MapComponentDto mapDto)> SaveAndGenerateData(
            MapComponentDto toSave, DateTime?generationVersion, IProgress <string> progress)
        {
            var validationReturn = await Validate(toSave);

            if (validationReturn.HasError)
            {
                return(validationReturn, null);
            }

            Db.DefaultPropertyCleanup(toSave);

            var savedComponent = await Db.SaveMapComponent(toSave);

            await GenerateData(savedComponent, progress);

            await Export.WriteLocalDbJson(savedComponent.Map);

            DataNotifications.PublishDataNotification("Map Component Generator", DataNotificationContentType.Map,
                                                      DataNotificationUpdateType.LocalContent, new List <Guid> {
                savedComponent.Map.ContentId
            });

            return(
                await GenerationReturn.Success(
                    $"Saved and Generated Map Component {savedComponent.Map.ContentId} - {savedComponent.Map.Title}"),
                savedComponent);
        }
Пример #2
0
        public static async Task <(GenerationReturn generationReturn, PointContentDto pointContent)> SaveAndGenerateHtml(
            PointContentDto toSave, DateTime?generationVersion, IProgress <string> progress)
        {
            var validationReturn = await Validate(toSave);

            if (validationReturn.HasError)
            {
                return(validationReturn, null);
            }

            Db.DefaultPropertyCleanup(toSave);
            toSave.Tags = Db.TagListCleanup(toSave.Tags);

            var savedPoint = await Db.SavePointContent(toSave);

            GenerateHtml(savedPoint, generationVersion, progress);
            await Export.WriteLocalDbJson(Db.PointContentDtoToPointContentAndDetails(savedPoint).content);

            DataNotifications.PublishDataNotification("Point Generator", DataNotificationContentType.Point,
                                                      DataNotificationUpdateType.LocalContent, new List <Guid> {
                savedPoint.ContentId
            });

            return(await GenerationReturn.Success($"Saved and Generated Content And Html for {savedPoint.Title}"),
                   savedPoint);
        }
Пример #3
0
        public static async Task <(GenerationReturn generationReturn, LinkContent linkContent)> SaveAndGenerateHtml(
            LinkContent toSave, DateTime?generationVersion, IProgress <string> progress)
        {
            var validationReturn = await Validate(toSave);

            if (validationReturn.HasError)
            {
                return(validationReturn, null);
            }

            Db.DefaultPropertyCleanup(toSave);
            toSave.Tags = Db.TagListCleanup(toSave.Tags);

            await Db.SaveLinkContent(toSave);

            await SaveLinkToPinboard(toSave, progress);

            GenerateHtmlAndJson(generationVersion, progress);

            DataNotifications.PublishDataNotification("Link Generator", DataNotificationContentType.Link,
                                                      DataNotificationUpdateType.LocalContent, new List <Guid> {
                toSave.ContentId
            });

            return(
                await GenerationReturn.Success($"Saved and Generated Content And Html for Links to Add {toSave.Title}"),
                toSave);
        }
Пример #4
0
        public static async Task <(GenerationReturn generationReturn, FileContent fileContent)> SaveAndGenerateHtml(
            FileContent toSave, FileInfo selectedFile, bool overwriteExistingFiles, DateTime?generationVersion,
            IProgress <string> progress)
        {
            var validationReturn = await Validate(toSave, selectedFile);

            if (validationReturn.HasError)
            {
                return(validationReturn, null);
            }

            Db.DefaultPropertyCleanup(toSave);
            toSave.Tags = Db.TagListCleanup(toSave.Tags);

            toSave.OriginalFileName = selectedFile.Name;
            FileManagement.WriteSelectedFileContentFileToMediaArchive(selectedFile);
            await Db.SaveFileContent(toSave);

            WriteFileFromMediaArchiveToLocalSite(toSave, overwriteExistingFiles, progress);
            GenerateHtml(toSave, generationVersion, progress);
            await Export.WriteLocalDbJson(toSave, progress);

            DataNotifications.PublishDataNotification("File Generator", DataNotificationContentType.File,
                                                      DataNotificationUpdateType.LocalContent, new List <Guid> {
                toSave.ContentId
            });

            return(await GenerationReturn.Success($"Saved and Generated Content And Html for {toSave.Title}"), toSave);
        }
Пример #5
0
        public LinkStreamListContext(StatusControlContext statusContext)
        {
            StatusContext = statusContext ?? new StatusControlContext();

            SortListCommand = new Command <string>(x => StatusContext.RunNonBlockingTask(() => SortList(x)));
            ToggleListSortDirectionCommand = new Command(() => StatusContext.RunNonBlockingTask(async() =>
            {
                SortDescending = !SortDescending;
                await SortList(_lastSortColumn);
            }));
            OpenUrlCommand = new Command <string>(x => StatusContext.RunNonBlockingTask(() => OpenUrl(x)));
            CopyUrlCommand = new Command <string>(x => StatusContext.RunNonBlockingTask(async() =>
            {
                await ThreadSwitcher.ResumeForegroundAsync();

                Clipboard.SetText(x);

                StatusContext.ToastSuccess($"To Clipboard {x}");
            }));
            ListSelectedLinksNotOnPinboardCommand = new Command(x =>
                                                                StatusContext.RunBlockingTask(async() =>
                                                                                              await ListSelectedLinksNotOnPinboard(StatusContext.ProgressTracker())));

            StatusContext.RunFireAndForgetBlockingTaskWithUiMessageReturn(LoadData);

            DataNotifications.DataNotificationChannel().MessageReceived += OnDataNotificationReceived;
        }
Пример #6
0
        public static async Task <(GenerationReturn generationReturn, NoteContent noteContent)> SaveAndGenerateHtml(
            NoteContent toSave, DateTime?generationVersion, IProgress <string> progress)
        {
            var validationReturn = await Validate(toSave);

            if (validationReturn.HasError)
            {
                return(validationReturn, null);
            }

            Db.DefaultPropertyCleanup(toSave);
            toSave.Tags = Db.TagListCleanup(toSave.Tags);

            await Db.SaveNoteContent(toSave);

            GenerateHtml(toSave, generationVersion, progress);
            await Export.WriteLocalDbJson(toSave, progress);

            DataNotifications.PublishDataNotification("Note Generator", DataNotificationContentType.Note,
                                                      DataNotificationUpdateType.LocalContent, new List <Guid> {
                toSave.ContentId
            });

            return(await GenerationReturn.Success($"Saved and Generated Content And Html for {toSave.Title}"), toSave);
        }
        public PhotoListContext(StatusControlContext statusContext, PhotoListLoadMode photoListLoadMode)
        {
            StatusContext = statusContext ?? new StatusControlContext();

            SortListCommand = new Command <string>(x => StatusContext.RunNonBlockingTask(() => SortList(x)));
            ToggleListSortDirectionCommand = new Command(() => StatusContext.RunNonBlockingTask(async() =>
            {
                SortDescending = !SortDescending;
                await SortList(_lastSortColumn);
            }));

            ToggleLoadRecentLoadAllCommand = new Command(x =>
            {
                if (LoadMode == PhotoListLoadMode.All)
                {
                    LoadMode = PhotoListLoadMode.Recent;
                    StatusContext.RunBlockingTask(LoadData);
                }
                else if (LoadMode == PhotoListLoadMode.Recent)
                {
                    LoadMode = PhotoListLoadMode.All;
                    StatusContext.RunBlockingTask(LoadData);
                }
            });

            LoadMode = photoListLoadMode;

            DataNotifications.DataNotificationChannel().MessageReceived += OnDataNotificationReceived;
        }
Пример #8
0
        public async Task A21_PhotoEditorGuiContextEditOfQuarryPhoto()
        {
            ThreadSwitcher.PinnedDispatcher        = Dispatcher.CurrentDispatcher;
            DataNotifications.SuspendNotifications = false;
            DataNotifications.NewDataNotificationChannel().MessageReceived += DebugTrackers.DataNotificationDiagnostic;

            var db = await Db.Context();

            var quarryPhoto = db.PhotoContents.Single(x => x.Title == IronwoodPhotoInfo.QuarryContent01.Title);

            var newContext = await PhotoContentEditorContext.CreateInstance(null);

            await newContext.LoadData(quarryPhoto);

            newContext.TitleSummarySlugFolder.TitleEntry.UserValue = string.Empty;
            Assert.True(newContext.TitleSummarySlugFolder.TitleEntry.HasChanges);
            Assert.True(newContext.TitleSummarySlugFolder.TitleEntry.HasValidationIssues);
            newContext.TitleSummarySlugFolder.TitleEntry.UserValue = IronwoodPhotoInfo.QuarryContent01.Title;
            Assert.False(newContext.TitleSummarySlugFolder.TitleEntry.HasChanges);

            newContext.TitleSummarySlugFolder.SlugEntry.UserValue += "\\\\";
            Assert.True(newContext.TitleSummarySlugFolder.SlugEntry.HasValidationIssues);
            Assert.True(newContext.TitleSummarySlugFolder.SlugEntry.HasChanges);
            newContext.TitleSummarySlugFolder.SlugEntry.UserValue =
                IronwoodPhotoInfo.QuarryContent02_BodyContentUpdateNotesTags.Slug;
            Assert.False(newContext.TitleSummarySlugFolder.SlugEntry.HasValidationIssues);

            newContext.TitleSummarySlugFolder.FolderEntry.UserValue =
                IronwoodPhotoInfo.QuarryContent02_BodyContentUpdateNotesTags.Folder;
            Assert.False(newContext.TitleSummarySlugFolder.FolderEntry.HasValidationIssues);

            newContext.TagEdit.Tags = IronwoodPhotoInfo.QuarryContent02_BodyContentUpdateNotesTags.Tags;
            Assert.False(newContext.TagEdit.HasValidationIssues);
            Assert.True(newContext.TagEdit.HasChanges);

            newContext.BodyContent.BodyContent =
                IronwoodPhotoInfo.QuarryContent02_BodyContentUpdateNotesTags.BodyContent;
            Assert.True(newContext.BodyContent.BodyContentHasChanges);

            newContext.UpdateNotes.UpdateNotes =
                IronwoodPhotoInfo.QuarryContent02_BodyContentUpdateNotesTags.UpdateNotes;
            Assert.True(newContext.UpdateNotes.UpdateNotesHasChanges);

            await newContext.SaveAndGenerateHtml(true);

            var comparison =
                IronwoodPhotoInfo.CompareContent(IronwoodPhotoInfo.QuarryContent02_BodyContentUpdateNotesTags,
                                                 newContext.DbEntry);

            Assert.True(comparison.areEqual, comparison.comparisonNotes);
        }
        public PostListContext(StatusControlContext statusContext)
        {
            StatusContext = statusContext ?? new StatusControlContext();

            SortListCommand = new Command <string>(x => StatusContext.RunNonBlockingTask(() => SortList(x)));
            ToggleListSortDirectionCommand = new Command(() => StatusContext.RunNonBlockingTask(async() =>
            {
                SortDescending = !SortDescending;
                await SortList(_lastSortColumn);
            }));

            StatusContext.RunFireAndForgetBlockingTaskWithUiMessageReturn(LoadData);

            DataNotifications.DataNotificationChannel().MessageReceived += OnDataNotificationReceived;
        }
        public PointListContext(StatusControlContext statusContext)
        {
            StatusContext = statusContext ?? new StatusControlContext();

            DataNotificationsProcessor = new DataNotificationsWorkQueue {
                Processor = DataNotificationReceived
            };

            SortListCommand = StatusContext.RunNonBlockingTaskCommand <string>(SortList);

            ToggleListSortDirectionCommand = StatusContext.RunNonBlockingTaskCommand(async() =>
            {
                SortDescending = !SortDescending;
                await SortList(_lastSortColumn);
            });

            StatusContext.RunFireAndForgetBlockingTaskWithUiMessageReturn(LoadData);

            DataNotifications.NewDataNotificationChannel().MessageReceived += OnDataNotificationReceived;
        }
Пример #11
0
        public async Task B01_NewFile()
        {
            ThreadSwitcher.PinnedDispatcher        = Dispatcher.CurrentDispatcher;
            DataNotifications.SuspendNotifications = false;
            DataNotifications.NewDataNotificationChannel().MessageReceived += DebugTrackers.DataNotificationDiagnostic;

            var testFile = new FileInfo(Path.Combine(Directory.GetCurrentDirectory(), "TestMedia",
                                                     TestFileInfo.TrailInfoGrandviewFilename));

            var newFileContext = await FileContentEditorContext.CreateInstance(null, testFile);

            //Starting State
            Assert.False(newFileContext.SelectedFileHasValidationIssues);
            Assert.True(newFileContext.SelectedFileHasPathOrNameChanges);

            //Simulate no file
            newFileContext.SelectedFile = null;

            Assert.That(() => newFileContext.SelectedFileHasValidationIssues, Is.True.After(4000));
            Assert.False(newFileContext.SelectedFileHasPathOrNameChanges);

            //To make clean URLs Files have a restricted set of allowed characters
            var illegalCharacterTestFile = new FileInfo(Path.Combine(Directory.GetCurrentDirectory(), "TestMedia",
                                                                     "GrandviewTrail'sIllegalName.pdf"));

            newFileContext.SelectedFile = illegalCharacterTestFile;

            Assert.That(() => newFileContext.SelectedFileHasValidationIssues, Is.True.After(1000));
            Assert.True(newFileContext.SelectedFileHasPathOrNameChanges);


            //Back to Valid File
            newFileContext.SelectedFile = testFile;

            Assert.That(() => newFileContext.SelectedFileHasValidationIssues, Is.False.After(1000));
            Assert.True(newFileContext.SelectedFileHasPathOrNameChanges);


            //Blank Title is the only validation issue

            //Initial State is blank and invalid
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.TitleEntry.HasValidationIssues);
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.TitleEntry.HasChanges);

            //Spaces detected as blank
            newFileContext.TitleSummarySlugFolder.TitleEntry.UserValue = "             ";
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.TitleEntry.HasValidationIssues);
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.TitleEntry.HasChanges);

            //Null detected as blank
            newFileContext.TitleSummarySlugFolder.TitleEntry.UserValue = null;
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.TitleEntry.HasValidationIssues);
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.TitleEntry.HasChanges);

            //Empty String detected as blank
            newFileContext.TitleSummarySlugFolder.TitleEntry.UserValue = string.Empty;
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.TitleEntry.HasValidationIssues);
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.TitleEntry.HasChanges);

            //Valid Title
            newFileContext.TitleSummarySlugFolder.TitleEntry.UserValue = TestFileInfo.GrandviewContent01.Title;
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.TitleEntry.HasValidationIssues);
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.TitleEntry.HasChanges);


            //Slug Tests
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.SlugEntry.HasValidationIssues);

            newFileContext.TitleSummarySlugFolder.TitleToSlug();
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.SlugEntry.HasValidationIssues);

            //Lowercase only
            newFileContext.TitleSummarySlugFolder.SlugEntry.UserValue = TestFileInfo.GrandviewContent01.Slug.ToUpper();
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.SlugEntry.HasValidationIssues);
            newFileContext.TitleSummarySlugFolder.SlugEntry.UserValue = TestFileInfo.GrandviewContent01.Slug;
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.SlugEntry.HasValidationIssues);

            //Can't check every excluded character so just check a few - ( is not legal
            newFileContext.TitleSummarySlugFolder.SlugEntry.UserValue = $"({TestFileInfo.GrandviewContent01.Slug}(";
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.SlugEntry.HasValidationIssues);
            newFileContext.TitleSummarySlugFolder.SlugEntry.UserValue = TestFileInfo.GrandviewContent01.Slug;
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.SlugEntry.HasValidationIssues);

            //Can't check every excluded character so just check a few - , is not legal
            newFileContext.TitleSummarySlugFolder.SlugEntry.UserValue =
                $"{TestFileInfo.GrandviewContent01.Slug},{TestFileInfo.GrandviewContent01.Slug}";
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.SlugEntry.HasValidationIssues);
            newFileContext.TitleSummarySlugFolder.SlugEntry.UserValue = TestFileInfo.GrandviewContent01.Slug;
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.SlugEntry.HasValidationIssues);

            //Can't check every excluded character so just check a few - [whitespace] is not legal
            newFileContext.TitleSummarySlugFolder.SlugEntry.UserValue =
                $"{TestFileInfo.GrandviewContent01.Slug}   {TestFileInfo.GrandviewContent01.Slug}";
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.SlugEntry.HasValidationIssues);
            newFileContext.TitleSummarySlugFolder.SlugEntry.UserValue = TestFileInfo.GrandviewContent01.Slug;
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.SlugEntry.HasValidationIssues);

            //Check that - and _ are allowed
            newFileContext.TitleSummarySlugFolder.SlugEntry.UserValue =
                $"----____{TestFileInfo.GrandviewContent01.Slug}---____";
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.SlugEntry.HasValidationIssues);

            //Check that 100 characters are allowed but 101 fails
            newFileContext.TitleSummarySlugFolder.SlugEntry.UserValue = $"{new string('-', 100)}";
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.SlugEntry.HasValidationIssues);
            newFileContext.TitleSummarySlugFolder.SlugEntry.UserValue = $"{new string('-', 101)}";
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.SlugEntry.HasValidationIssues);

            //Valid Slug Entry
            newFileContext.TitleSummarySlugFolder.TitleToSlug();
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.SlugEntry.HasValidationIssues);
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.SlugEntry.HasChanges);


            //Folder Tests
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.FolderEntry.HasValidationIssues);

            newFileContext.TitleSummarySlugFolder.FolderEntry.UserValue = TestFileInfo.GrandviewContent01.Folder;
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.FolderEntry.HasValidationIssues);
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.FolderEntry.HasChanges);

            //Upper Case permitted
            newFileContext.TitleSummarySlugFolder.FolderEntry.UserValue =
                TestFileInfo.GrandviewContent01.Slug.ToUpper();
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.FolderEntry.HasValidationIssues);

            //Spaces not permitted
            newFileContext.TitleSummarySlugFolder.FolderEntry.UserValue = "Test With Space";
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.FolderEntry.HasValidationIssues);
            newFileContext.TitleSummarySlugFolder.FolderEntry.UserValue = TestFileInfo.GrandviewContent01.Slug;
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.FolderEntry.HasValidationIssues);

            //Absolute File Path not permitted
            newFileContext.TitleSummarySlugFolder.FolderEntry.UserValue = "C:\\TestFolder";
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.FolderEntry.HasValidationIssues);
            newFileContext.TitleSummarySlugFolder.FolderEntry.UserValue = TestFileInfo.GrandviewContent01.Slug;
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.FolderEntry.HasValidationIssues);

            //Rel File Path not permitted
            newFileContext.TitleSummarySlugFolder.FolderEntry.UserValue = "\\TestFolder";
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.FolderEntry.HasValidationIssues);
            newFileContext.TitleSummarySlugFolder.FolderEntry.UserValue = TestFileInfo.GrandviewContent01.Slug;
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.FolderEntry.HasValidationIssues);

            //Comma not permitted
            newFileContext.TitleSummarySlugFolder.FolderEntry.UserValue = "Test,Folder";
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.FolderEntry.HasValidationIssues);
            newFileContext.TitleSummarySlugFolder.FolderEntry.UserValue = TestFileInfo.GrandviewContent01.Slug;
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.FolderEntry.HasValidationIssues);

            //Valid Entry for Folder
            newFileContext.TitleSummarySlugFolder.FolderEntry.UserValue = TestFileInfo.GrandviewContent01.Folder;
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.FolderEntry.HasValidationIssues);
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.FolderEntry.HasChanges);


            //Summary Tests

            //Blank is not valid and is starting condition
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.SummaryEntry.HasValidationIssues);
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.SummaryEntry.HasChanges);

            //Valid Entry
            newFileContext.TitleSummarySlugFolder.SummaryEntry.UserValue = "Simple Summary";
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.SummaryEntry.HasValidationIssues);
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.SummaryEntry.HasChanges);

            //Blank not permitted
            newFileContext.TitleSummarySlugFolder.SummaryEntry.UserValue = "";
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.SummaryEntry.HasValidationIssues);
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.SummaryEntry.HasChanges);

            //Null not permitted and handled ok
            newFileContext.TitleSummarySlugFolder.SummaryEntry.UserValue = null;
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.SummaryEntry.HasValidationIssues);
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.SummaryEntry.HasChanges);

            //All spaces detected as blank
            newFileContext.TitleSummarySlugFolder.SummaryEntry.UserValue = "              ";
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.SummaryEntry.HasValidationIssues);
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.SummaryEntry.HasChanges);

            //Valid Summary
            newFileContext.TitleSummarySlugFolder.SummaryEntry.UserValue = "Simple Summary";
            Assert.IsFalse(newFileContext.TitleSummarySlugFolder.SummaryEntry.HasValidationIssues);
            Assert.IsTrue(newFileContext.TitleSummarySlugFolder.SummaryEntry.HasChanges);


            //Tags

            //Invalid initial blank state
            Assert.IsTrue(newFileContext.TagEdit.HasValidationIssues);
            Assert.IsFalse(newFileContext.TagEdit.HasChanges);

            //Single valid tag
            newFileContext.TagEdit.Tags = "simple test";
            Assert.IsFalse(newFileContext.TagEdit.HasValidationIssues);
            Assert.IsTrue(newFileContext.TagEdit.HasChanges);

            //Blanks as nothing
            newFileContext.TagEdit.Tags = "    ";
            Assert.IsTrue(newFileContext.TagEdit.HasValidationIssues);
            Assert.IsFalse(newFileContext.TagEdit.HasChanges);

            //Null as nothing
            newFileContext.TagEdit.Tags = null;
            Assert.IsTrue(newFileContext.TagEdit.HasValidationIssues);
            Assert.IsFalse(newFileContext.TagEdit.HasChanges);

            //Reset to good state
            newFileContext.TagEdit.Tags = "simple test";
            Assert.IsFalse(newFileContext.TagEdit.HasValidationIssues);
            Assert.IsTrue(newFileContext.TagEdit.HasChanges);

            //Test invalid symbol is removed in processing
            newFileContext.TagEdit.Tags = "simple test; another ";
            Assert.IsFalse(newFileContext.TagEdit.HasValidationIssues);
            Assert.IsTrue(newFileContext.TagEdit.HasChanges);
            Assert.AreEqual("simple test another ", newFileContext.TagEdit.Tags);

            //Capitals removed
            newFileContext.TagEdit.Tags = "  SIMPLE TEST ";
            Assert.IsFalse(newFileContext.TagEdit.HasValidationIssues);
            Assert.IsTrue(newFileContext.TagEdit.HasChanges);
            Assert.AreEqual("  simple test ", newFileContext.TagEdit.Tags);

            //Hyphens Valid - 3 tags
            newFileContext.TagEdit.Tags = "test-one, test--two, test---three";
            Assert.IsFalse(newFileContext.TagEdit.HasValidationIssues);
            Assert.IsTrue(newFileContext.TagEdit.HasChanges);
            Assert.AreEqual(3, newFileContext.TagEdit.TagList().Count);

            //New Line not Valid
            newFileContext.TagEdit.Tags = "test-1, test--2, \r\n test---3";
            Assert.IsFalse(newFileContext.TagEdit.HasValidationIssues);
            Assert.IsTrue(newFileContext.TagEdit.HasChanges);
            Assert.AreEqual("test-1, test--2,  test---3", newFileContext.TagEdit.Tags);

            //Hyphens Valid - 3 tags
            newFileContext.TagEdit.Tags = "test-1, test--2, test---3";
            Assert.IsFalse(newFileContext.TagEdit.HasValidationIssues);
            Assert.IsTrue(newFileContext.TagEdit.HasChanges);
            Assert.AreEqual(3, newFileContext.TagEdit.TagList().Count);


            //Created/Updated By

            Assert.AreEqual("Trail Notes Ghost Writer", newFileContext.CreatedUpdatedDisplay.CreatedByEntry.UserValue);
            Assert.True(newFileContext.CreatedUpdatedDisplay.HasChanges);
            Assert.False(newFileContext.CreatedUpdatedDisplay.HasValidationIssues);

            newFileContext.CreatedUpdatedDisplay.CreatedByEntry.UserValue = "   ";
            Assert.False(newFileContext.CreatedUpdatedDisplay.HasChanges);
            Assert.True(newFileContext.CreatedUpdatedDisplay.HasValidationIssues);

            newFileContext.CreatedUpdatedDisplay.CreatedByEntry.UserValue = "Trail Notes Ghost Writer";
            Assert.True(newFileContext.CreatedUpdatedDisplay.HasChanges);
            Assert.False(newFileContext.CreatedUpdatedDisplay.HasValidationIssues);


            //Body Text
            Assert.False(newFileContext.BodyContent.HasChanges);
            newFileContext.BodyContent.BodyContent =
                "UI Context Testing File with Bad Content Id {{postlink c3c63473-6b60-4531-97f7-2d201d84e2be; Cocopa and Yuma Points, Grand Canyon - 9/30-10/1/2020}}";
            Assert.True(newFileContext.BodyContent.HasChanges);

            //Update Text
            Assert.False(newFileContext.UpdateNotes.HasChanges);
            newFileContext.UpdateNotes.UpdateNotes =
                "UI Context Testing File with Bad Content Id {{postlink c3c63473-6b60-4531-97f7-2d201d84e2be; text Bad Content Id Text ;Cocopa and Yuma Points, Grand Canyon - 9/30-10/1/2020}}";
            Assert.True(newFileContext.UpdateNotes.HasChanges);

            var validationResult = await FileGenerator.Validate(newFileContext.CurrentStateToFileContent(),
                                                                newFileContext.SelectedFile);

            Assert.True(validationResult.HasError);


            //Body Text
            newFileContext.BodyContent.BodyContent = "UI Context Testing File";
            Assert.True(newFileContext.BodyContent.HasChanges);

            validationResult = await FileGenerator.Validate(newFileContext.CurrentStateToFileContent(),
                                                            newFileContext.SelectedFile);

            Assert.True(validationResult.HasError);

            //Update Text
            newFileContext.UpdateNotes.UpdateNotes = "UI Context Testing File Update";
            Assert.True(newFileContext.UpdateNotes.HasChanges);

            validationResult = await FileGenerator.Validate(newFileContext.CurrentStateToFileContent(),
                                                            newFileContext.SelectedFile);

            Assert.False(validationResult.HasError);

            var saveResult = await FileGenerator.SaveAndGenerateHtml(newFileContext.CurrentStateToFileContent(),
                                                                     newFileContext.SelectedFile, false, null, DebugTrackers.DebugProgressTracker());

            Assert.IsFalse(saveResult.generationReturn.HasError);

            var db = await Db.Context();

            Assert.AreEqual(1, db.FileContents.Count());

            var dbContent = await db.FileContents.FirstOrDefaultAsync();

            Assert.True(dbContent.OriginalFileName == newFileContext.SelectedFile.Name);
            Assert.True(dbContent.Title == newFileContext.TitleSummarySlugFolder.TitleEntry.UserValue);
            Assert.True(dbContent.Slug == newFileContext.TitleSummarySlugFolder.SlugEntry.UserValue);
            Assert.True(dbContent.Folder == newFileContext.TitleSummarySlugFolder.FolderEntry.UserValue);
            Assert.True(dbContent.Summary == newFileContext.TitleSummarySlugFolder.SummaryEntry.UserValue);
            Assert.True(dbContent.Tags == newFileContext.TagEdit.TagListString());
            Assert.True(dbContent.CreatedBy == newFileContext.CreatedUpdatedDisplay.CreatedByEntry.UserValue);
            Assert.True(dbContent.BodyContent == newFileContext.BodyContent.BodyContent);
            Assert.True(dbContent.UpdateNotes == newFileContext.UpdateNotes.UpdateNotes);
        }
Пример #12
0
 public FMDataEventArgs(DataNotifications Datanotification, int deviceindex)
 {
     msg    = Datanotification;
     DIndex = deviceindex;
 }
Пример #13
0
    public void FillNotificationData(int SocietyID)
    {
        try
        {
            DataAccess dacess = new DataAccess();

            String DatalistQuery = "SELECT * FROM " + VIEW_NOTIFICATION + "  where SocietyID ='" + SocietyID + "' and EndDate  >= getDate() order by date desc";


            if (status == "Open")
            {
                DatalistQuery = "SELECT * FROM " + VIEW_NOTIFICATION + "  where SocietyID ='" + SocietyID + "' and  EndDate >= getDate() order by date desc";
            }
            else if (status == "Closed")
            {
                DatalistQuery = "Select * from " + VIEW_NOTIFICATION + " where SocietyID ='" + SocietyID + "' and  EndDate <= getDate() order by date desc ";
            }
            else if (status == "All")
            {
                DatalistQuery = " Select * from " + VIEW_NOTIFICATION + " Where SocietyID ='" + SocietyID + "'  order by date desc ";
            }

            DataSet ds = dacess.ReadData(DatalistQuery);

            if (ds == null)
            {
                drpNotifiFilter.Visible = false;
                lblEmptyTitle.Visible   = true;
                btnnext.Visible         = false;
                btnprevious.Visible     = false;
                showOpen.Visible        = false;
                showClose.Visible       = false;
                showAll.Visible         = false;
                // New_Notification.Visible = true;
                lblEmptyTitle.Text = "<h4>Notice Board is Empty Right Now!!</h4>";
            }

            else
            {
                DataTable dt = ds.Tables[0];

                if (ds.Tables.Count > 0)
                {
                    //DataNotifications.DataSource = ds;
                    //DataNotifications.DataBind();
                    DataNotifications.Visible = true;
                    lblEmptyTitle.Visible     = false;


                    adsource                     = new PagedDataSource();
                    adsource.DataSource          = ds.Tables[0].DefaultView;
                    adsource.PageSize            = 5;
                    adsource.AllowPaging         = true;
                    adsource.CurrentPageIndex    = pos;
                    DataNotifications.DataSource = adsource;
                    btnprevious.Visible          = !adsource.IsFirstPage;
                    btnnext.Visible              = !adsource.IsLastPage;
                    //dataListComplaint.DataSource = ds;
                    DataNotifications.DataBind();

                    lblPage.Text = "Page " + (adsource.CurrentPageIndex + 1) + " of " + adsource.PageCount;
                }
                else
                {
                }

                // showOpen.CssClass.Remove("Active");
                showOpen.Attributes["class"] = "Active";
                ClientScript.RegisterStartupScript(this.GetType(), "alert('')", " SetActiveClass('Open')", true);
            }
        }
        catch (Exception ex)
        {
        }
        // myModalNewNotficationPopup.Controls.Clear();
    }
Пример #14
0
    protected void drpNotifiFilter_SelectedIndexChanged(object sender, EventArgs e)
    {
        DataAccess dacess = new DataAccess();

        String Date       = drpNotifiFilter.SelectedItem.Text;
        String DateFilter = "";

        System.DateTime startDate = new DateTime();
        System.DateTime endDate   = new DateTime();


        if (Date == "All")
        {
            FillNotificationData(muser.currentResident.SocietyID);
            lblEmptyTitle.Visible = false;
        }

        else
        {
            if (Date == "This Month")
            {
                // System.DateTime date = System.DateTime.Now;
                DateTime date  = Utility.GetCurrentDateTimeinUTC();
                int      month = date.Month;
                int      year  = date.Year;
                int      days  = System.DateTime.DaysInMonth(year, month);
                startDate = new DateTime(year, month, 1);
                endDate   = new DateTime(year, month, days);
            }

            if (Date == "Last Month")
            {
                // System.DateTime date = System.DateTime.Now;

                DateTime date = Utility.GetCurrentDateTimeinUTC();

                System.DateTime prevDate = date.AddMonths(-1);

                int month = prevDate.Month;
                int year  = prevDate.Year;

                int days = System.DateTime.DaysInMonth(year, month);

                startDate = new DateTime(year, month, 1);
                endDate   = new DateTime(year, month, days);
            }

            if (Date == "This Year")
            {
                DateTime CurrentDate = Utility.GetCurrentDateTimeinUTC();

                int year = CurrentDate.Year;
                startDate = new DateTime(year, 1, 1);
                endDate   = new DateTime(year, 12, 31);
            }

            DateFilter = "Select * from " + VIEW_NOTIFICATION + " where Date between  '" + startDate + "' and '" + endDate + "' ";
            DataSet ds = dacess.ReadData(DateFilter);
            if (ds == null)
            {
                DataNotifications.Visible = false;
                lblEmptyTitle.Text        = "Selected Data is  not  Found.";
                lblEmptyTitle.Visible     = true;
            }

            else
            {
                DataNotifications.Visible = true;
                lblEmptyTitle.Text        = "";
                DataTable dta = ds.Tables[0];

                if (dta.Rows.Count != 0)
                {
                    DataNotifications.DataSource = ds;
                    DataNotifications.DataBind();
                }
            }
        }
    }