public void DeleteFormFieldAssociatedWithBookmark()
        {
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.StartBookmark("MyBookmark");
            builder.InsertTextInput("TextInput1", TextFormFieldType.Regular, "TestFormField", "SomeText", 0);
            builder.EndBookmark("MyBookmark");

            MemoryStream dstStream = new MemoryStream();

            doc.Save(dstStream, SaveFormat.Docx);

            BookmarkCollection bookmarkBeforeDeleteFormField = doc.Range.Bookmarks;

            Assert.AreEqual("MyBookmark", bookmarkBeforeDeleteFormField[0].Name);

            FormField formField = doc.Range.FormFields[0];

            formField.RemoveField();

            BookmarkCollection bookmarkAfterDeleteFormField = doc.Range.Bookmarks;

            Assert.AreEqual("MyBookmark", bookmarkAfterDeleteFormField[0].Name);
        }
        public async Task <IActionResult> GetUndFormVersionPdf(int id)
        {
            var undFormVersion = await _context.UndFormVersion.FindAsync(id);

            if (undFormVersion == null)
            {
                return(NotFound());
            }

            // SaveEndorsementDocumentForPreview(id);
            // var fileName = HighlightNextEndorsementDocumentForPreview(id);
            var getFilePath = undFormVersion.FileName.ToString();

            Document           endorsement = new Document(getFilePath);
            DocumentBuilder    builder     = new DocumentBuilder(endorsement);
            BookmarkCollection bookmarks   = endorsement.Range.Bookmarks;

            foreach (var bookmark in bookmarks)
            {
                if (bookmark.Name.StartsWith(undFormVersion.FormVersionNo.Substring(0, 6)))
                {
                    builder.MoveToBookmark(bookmark.Name);
                    builder.Font.HighlightColor = Color.Yellow;
                    builder.Write("Blank " + bookmark.Name.Substring(bookmark.Name.Length - 2) + " ");
                }
            }
            //endorsement.Save(newFilePath + newFileName, SaveFormat.Docx);
            using var stream = new MemoryStream();
            endorsement.Save(stream, SaveFormat.Pdf);
            var bytes = stream.ToArray();

            return(File(bytes, "application/pdf"));
        }
        void richEditControl1_MouseMove(object sender, MouseEventArgs e)
        {
            Point point = e.GetPosition((UIElement)richEditControl1);

            System.Drawing.PointF pt = new System.Drawing.PointF(Units.PixelsToDocumentsF((float)point.X, richEditControl1.DpiX),
                                                                 Units.PixelsToDocumentsF((float)point.Y, richEditControl1.DpiY));
            DocumentPosition pos = richEditControl1.GetPositionFromPoint(pt);

            BookmarkCollection bmCollection = richEditControl1.Document.Bookmarks;

            textBlock1.Text = String.Empty; //Clear a text block displaying bookmark info

            if (pos != null)
            {
                foreach (Bookmark bm in bmCollection)
                {
                    if (bm.Range.Contains(pos))
                    {
                        Bookmark bmHovered = bm;
                        richEditControl1.Document.Bookmarks.Select(bmHovered);
                        ShowBookmarkInTextBlock(bmHovered);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Mounts the default bookmark if any
        /// </summary>
        /// <param name="controller"></param>
        public static void OpenDefaultBookmark(BrowserController controller)
        {
            String defaultBookmark = PreferencesFactory.get().getProperty("browser.open.bookmark.default");

            if (null == defaultBookmark)
            {
                return; //No default bookmark given
            }
            Host bookmark = BookmarkCollection.defaultCollection().lookup(defaultBookmark);

            if (null == bookmark)
            {
                Logger.info("Default bookmark no more available");
                return;
            }
            foreach (BrowserController browser in Browsers)
            {
                if (browser.IsMounted())
                {
                    if (bookmark.equals(browser.Session.getHost()))
                    {
                        Logger.debug("Default bookmark already mounted");
                        return;
                    }
                }
            }
            Logger.debug("Mounting default bookmark " + bookmark);
            controller.Mount(bookmark);
        }
Ejemplo n.º 5
0
        public BookmarkCollection Import(string path)
        {
            var bookmarksTxt = TxtToListConverter.Convert(path);

            bookmarksTxt.RemoveAll(x => BadTexts(x));

            var result = new BookmarkCollection
            {
                FullPath  = path,
                Bookmarks = new List <Bookmark>()
            };

            for (int bookmarksTxtIndex = 0; bookmarksTxtIndex < bookmarksTxt.Count - 1; bookmarksTxtIndex += 2)
            {
                var bookmarkTxt = bookmarksTxt[bookmarksTxtIndex];
                if (!IsMetadataLine(bookmarkTxt))
                {
                    throw new InvalidOperationException($"{bookmarkTxt} wasn't metadata.");
                }

                BookmarkMetadata metadata = VoiceBookmarkMetadataConverter.Convert(bookmarkTxt);

                bookmarkTxt = bookmarksTxt[bookmarksTxtIndex + 1];
                result.Bookmarks.Add(new Bookmark
                {
                    Text     = bookmarkTxt,
                    Metadata = metadata
                });
            }

            return(result);
        }
Ejemplo n.º 6
0
        public BookmarkCollection Import(string path)
        {
            var bookmarksTxt = TxtToListConverter.Convert(path);

            var result = new BookmarkCollection
            {
                FullPath  = path,
                Bookmarks = new List <Bookmark>()
            };

            for (int bookmarksTxtIndex = 0; bookmarksTxtIndex < bookmarksTxt.Count - 1; bookmarksTxtIndex += 1)
            {
                var bookmarkTxt = bookmarksTxt[bookmarksTxtIndex];

                BookmarkMetadata metadata = new BookmarkMetadata
                {
                    Colour = HighlightType.Color1,
                    Text   = bookmarkTxt
                };

                result.Bookmarks.Add(new Bookmark
                {
                    Text     = bookmarkTxt,
                    Metadata = metadata
                });
            }

            return(result);
        }
        private void OnBookmarksMenuItemClicked(object sender, PopupMenu.MenuItemClickEventArgs e)
        {
            // Get title from the selected item
            var selectedBookmarkName = e.Item.TitleCondensedFormatted.ToString();

            // If this is the "Add ..." choice, call a function to create a new bookmark
            if (selectedBookmarkName == "Add ...")
            {
                AddBookmark();
                return;
            }

            // Get the collection of bookmarks in the map
            BookmarkCollection myBookmarkCollection = _myMapView.Map.Bookmarks;

            // Loop through bookmarks
            foreach (var myBookmark in myBookmarkCollection)
            {
                // Get this bookmark name
                var theBookmarkName = myBookmark.Name;

                // If this is the selected bookmark, use it to set the map's viewpoint
                if (theBookmarkName == selectedBookmarkName)
                {
                    _myMapView.SetViewpoint(myBookmark.Viewpoint);

                    // Set the name of the button to display the current bookmark
                    _bookmarksButton.Text = selectedBookmarkName;

                    break;
                }
            }
        }
Ejemplo n.º 8
0
        [Test] //ExSkip
        public void CreateUpdateAndPrintBookmarks()
        {
            // Create a document with 3 bookmarks: "MyBookmark 1", "MyBookmark 2", "MyBookmark 3"
            Document           doc       = CreateDocumentWithBookmarks();
            BookmarkCollection bookmarks = doc.Range.Bookmarks;

            Assert.AreEqual(3, bookmarks.Count);                                //ExSkip
            Assert.AreEqual("MyBookmark 1", bookmarks[0].Name);                 //ExSkip
            Assert.AreEqual("Text content of MyBookmark 2", bookmarks[1].Text); //ExSkip

            // Look at initial values of our bookmarks
            PrintAllBookmarkInfo(bookmarks);

            // Obtain bookmarks from a bookmark collection by index/name and update their values
            bookmarks[0].Name = "Updated name of " + bookmarks[0].Name;
            bookmarks["MyBookmark 2"].Text = "Updated text content of " + bookmarks[1].Name;
            // Remove the latest bookmark
            // The bookmarked text is not deleted
            bookmarks[2].Remove();

            bookmarks = doc.Range.Bookmarks;
            // Check that we have 2 bookmarks after the latest bookmark was deleted
            Assert.AreEqual(2, bookmarks.Count);
            Assert.AreEqual("Updated name of MyBookmark 1", bookmarks[0].Name);         //ExSkip
            Assert.AreEqual("Updated text content of MyBookmark 2", bookmarks[1].Text); //ExSkip

            // Look at updated values of our bookmarks
            PrintAllBookmarkInfo(bookmarks);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Removes the single bookmark passed in
        /// </summary>
        /// <param name="threadID">Thread ID.</param>
        /// <param name="userID">User ID.</param>
        /// <returns></returns>
        public static void RemoveSingleBookmark(int threadID, int userID)
        {
            BookmarkCollection bookmarks = new BookmarkCollection();

            // delete the bookmark directly from the database, no need for fetching it first.
            bookmarks.DeleteMulti((BookmarkFields.ThreadID == threadID).And(BookmarkFields.UserID == userID));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Removes the threads with threadid in the arraylist passed in from the bookmarks
        /// </summary>
        /// <param name="threadIDsToRemove">Thread I ds to remove.</param>
        /// <param name="userID">user for whom these bookmarks have to be deleted</param>
        public static void RemoveBookmarks(ArrayList threadIDsToRemove, int userID)
        {
            BookmarkCollection bookmarks = new BookmarkCollection();

            // delete the bookmarks matching the filter directly from the database.
            bookmarks.DeleteMulti((BookmarkFields.ThreadID == threadIDsToRemove).And(BookmarkFields.UserID == userID));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Mounts the default bookmark if any
        /// </summary>
        /// <param name="controller"></param>
        public static void OpenDefaultBookmark(BrowserController controller)
        {
            String defaultBookmark = Preferences.instance().getProperty("browser.defaultBookmark");

            if (null == defaultBookmark)
            {
                return; //No default bookmark given
            }

            foreach (Host bookmark in BookmarkCollection.defaultCollection())
            {
                if (bookmark.getNickname().Equals(defaultBookmark))
                {
                    foreach (BrowserController browser in Browsers)
                    {
                        if (browser.HasSession())
                        {
                            if (browser.getSession().getHost().equals(bookmark))
                            {
                                Logger.debug("Default bookmark already mounted");
                                return;
                            }
                        }
                    }
                    Logger.debug("Mounting default bookmark " + bookmark);
                    controller.Mount(bookmark);
                    return;
                }
            }
        }
        private string HighlightEndorsementForPreview(int id)
        {
            var undFormVersion = _context.UndFormVersion.Find(id);
            var getFilePath    = undFormVersion.FileName.ToString();

            string newFileName = "EndrosementBlankPreview.pdf";

            Document           endorsement = new Document(getFilePath);
            DocumentBuilder    builder     = new DocumentBuilder(endorsement);
            BookmarkCollection bookmarks   = endorsement.Range.Bookmarks;

            foreach (var bookmark in bookmarks)
            {
                if ((bookmark.Name == "insured_name1") || (bookmark.Name == "policy_period1") || (bookmark.Name == "policy_number1") || (bookmark.Name == "effective_date1"))
                {
                    builder.MoveToBookmark(bookmark.Name);
                    builder.Font.HighlightColor = Color.Yellow;
                    builder.Writeln(bookmark.Name);
                }
            }
            var savedFileName = newFilePath + newFileName;

            endorsement.Save(savedFileName, SaveFormat.Pdf);
            return(savedFileName);
        }
Ejemplo n.º 13
0
        public void TestDeadlockWhenRemovingAnActiveDataSource()
        {
            var logFile    = new Mock <ILogSource>();
            var dataSource = new Mock <IDataSource>();

            dataSource.Setup(x => x.UnfilteredLogSource).Returns(logFile.Object);

            var collection = new BookmarkCollection(_bookmarks.Object, TimeSpan.Zero);

            logFile.Setup(x => x.RemoveListener(It.IsAny <ILogSourceListener>()))
            .Callback((ILogSourceListener unused) =>
            {
                // In order to produce the deadlock, we have to simulate what's happening in reality.
                // Any ILogFile implementation will hold a lock both while invoking listeners and while
                // Removing them. Waiting on the OnLogFileModified() call simulates exactly that...
                var task = new Task(() =>
                {
                    collection.OnLogFileModified(logFile.Object, LogSourceModification.Removed(0, 10));
                }, TaskCreationOptions.LongRunning);

                task.Start();
                task.Wait();
            });

            collection.AddDataSource(dataSource.Object);

            var removeTask = Task.Factory.StartNew(() => collection.RemoveDataSource(dataSource.Object));

            removeTask.Wait(TimeSpan.FromSeconds(1)).Should().BeTrue("because RemoveDataSource should not block at all");

            logFile.Verify(x => x.RemoveListener(collection), Times.Once);
        }
Ejemplo n.º 14
0
        private void RefreshJumpList()
        {
            InitJumpList();

            try
            {
                Iterator iterator = HistoryCollection.defaultCollection().iterator();
                _jumpListManager.ClearAllUserTasks();
                while (iterator.hasNext())
                {
                    Host host = (Host)iterator.next();
                    var  file = BookmarkCollection.defaultCollection().getFile(host);
                    if (file.exists())
                    {
                        bookmarkCategory.AddJumpListItems(new JumpListLink(file.getAbsolute(), BookmarkNameProvider.toString(host))
                        {
                            IconReference = new IconReference(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "cyberduck-application.ico"), 0),
                        });
                    }
                }
                _jumpListManager.Refresh();
            }
            catch (Exception exception)
            {
                Logger.warn("Exception while refreshing jump list", exception);
            }
        }
Ejemplo n.º 15
0
 protected override void Invalidate()
 {
     _ticklerReachability.Change(Timeout.Infinite, Timeout.Infinite);
     _ticklerFavicon.Change(Timeout.Infinite, Timeout.Infinite);
     PreferencesFactory.get().setProperty(ToggleProperty, View.OptionsVisible);
     BookmarkCollection.defaultCollection().removeListener(_bookmarkCollectionListener);
     base.Invalidate();
 }
Ejemplo n.º 16
0
 protected override void Invalidate()
 {
     _ticklerRechability.Change(Timeout.Infinite, Timeout.Infinite);
     _ticklerFavicon.Change(Timeout.Infinite, Timeout.Infinite);
     Preferences.instance().setProperty("bookmark.toggle.options", View.OptionsVisible);
     BookmarkCollection.defaultCollection().removeListener(_bookmarkCollectionListener);
     base.Invalidate();
 }
Ejemplo n.º 17
0
        static void GemBoxDocument3()
        {
            DocumentModel doc = null;

            try
            {
                string CreateDoc = @"c:\1\TestGemBox.docx";

                doc = new DocumentModel();
                doc.Save(CreateDoc);

                // Путь до файла
                string destFileName2 = @"c:\1\TestGemBox2.docx";

                //// Create a new empty Word file.
                //var doc = new DocumentModel();

                // Обязательная строка, указываем, что мы используем лимитированную версию
                ComponentInfo.SetLicense("FREE-LIMITED-KEY");

                // Загружаем в память наш документ
                doc = DocumentModel.Load(CreateDoc);

                string[] data = new string[] { "Alex", "Gulynin", "27" };

                //Коллекция закладок
                BookmarkCollection wBookmarks = doc.Bookmarks;

                // ContentRange - это область содержимого в документе
                ContentRange wRange;

                int i = 0;

                // Пробегаем по всем закладкам в документе
                foreach (Bookmark mark in doc.Bookmarks)
                {
                    //   Получаем содержимое закладки
                    wRange = mark.GetContent(false);
                    //   Загружаем туда нужный текст
                    wRange.LoadText(data[i].ToString());
                    i++;
                }

                // Сохраняем изменения в нашем документе
                doc.Save(destFileName2);
                doc = null;
            }
            catch (Exception ex)
            {
                doc = null;
                Console.WriteLine("Во время выполнения программы произошла ошибка! Текст ошибки: {0}", ex.Message);
                Console.ReadLine();
            }
        }
Ejemplo n.º 18
0
		async Task<FileHeader> ReadFileAsync(string fileName, BookmarkCollection bookmarks, IProgress<int> progress)
		{
			using (FileStream readStream = new FileStream(fileName, FileMode.Open, FileAccess.Read))
			{
				var cic = FileHeader.Load(readStream);
				// ID確認
				if (cic == null)
					throw new ArgumentException(Properties.Resources.InvalidFileFormat);
				bookmarks.Load(readStream); // 目次
				await Images.LoadAsync(readStream, cic.FileVersion, progress).ConfigureAwait(false); // 画像
				return cic;
			}
		}
Ejemplo n.º 19
0
        public void TestConstruction1()
        {
            var collection = new BookmarkCollection(_bookmarks.Object, TimeSpan.Zero);

            collection.Count.Should().Be(0);
            collection.Bookmarks.Should().BeEmpty();

            collection.Contains(null, 0).Should().BeFalse();
            collection.Contains(_dataSource.Object, -1).Should().BeFalse();
            collection.Contains(_dataSource.Object, 0).Should().BeFalse();
            collection.Contains(_dataSource.Object, 1).Should().BeFalse();
            collection.Contains(_dataSource.Object, 2).Should().BeFalse();
        }
Ejemplo n.º 20
0
		public void SetBookmarks(BookmarkCollection bookmarks)
		{
			if (_bookmarks != bookmarks)
			{
				if (_bookmarks != null)
					_bookmarks.CollectionChanged -= Bookmarks_CollectionChanged;
				_bookmarks = bookmarks;
				if (bookmarks != null)
				{
					bookmarks.CollectionChanged += Bookmarks_CollectionChanged;
					Bookmarks_CollectionChanged(bookmarks, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
				}
			}
		}
Ejemplo n.º 21
0
 internal override void Detach()
 {
     base.Detach();
     if (!base.DeepDetached)
     {
         BookmarkCollection bookmarks = base.Document.Bookmarks;
         Bookmark           bookmark  = bookmarks.FindByName(this.Name);
         if (bookmark != null)
         {
             bookmark.method_0(null);
             bookmarks.Remove(bookmark);
         }
     }
 }
Ejemplo n.º 22
0
        public void TestAddSameBookmarkTwice()
        {
            var collection = new BookmarkCollection(_bookmarks.Object, TimeSpan.Zero);

            collection.AddDataSource(_dataSource.Object);

            _logSource.AddEntry("", LevelFlags.Error);
            _logSource.AddEntry("", LevelFlags.Error);

            var bookmark = collection.TryAddBookmark(_dataSource.Object, 1);

            collection.TryAddBookmark(_dataSource.Object, 1).Should().BeNull();
            collection.Count.Should().Be(1);
            collection.Bookmarks.Should().BeEquivalentTo(new object[] { bookmark });
        }
        public IEnumerable <string> GetBookmarkNames(int id)
        {
            var undFormVersion = _context.UndFormVersion.Find(id);
            var getFilePath    = undFormVersion.FileName.ToString();

            //string newFileName = "EndrosementBlankPreview.pdf";

            Document           endorsement = new Document(getFilePath);
            DocumentBuilder    builder     = new DocumentBuilder(endorsement);
            BookmarkCollection bookmarks   = endorsement.Range.Bookmarks;

            var bookmarkNames = bookmarks.Select(b => b.Name);

            return(bookmarkNames);
        }
Ejemplo n.º 24
0
        public DataSources(ILogFileFactory logFileFactory, ITaskScheduler taskScheduler, IDataSourcesSettings settings)
        {
            if (logFileFactory == null)
            {
                throw new ArgumentNullException(nameof(logFileFactory));
            }
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            _logFileFactory  = logFileFactory;
            _taskScheduler   = taskScheduler;
            _maximumWaitTime = TimeSpan.FromMilliseconds(100);
            _syncRoot        = new object();
            _settings        = settings;
            _bookmarks       = new BookmarkCollection(_maximumWaitTime);
            _dataSources     = new List <IDataSource>();
            _dataSourceIds   = new HashSet <DataSourceId>();
            foreach (DataSource dataSource in settings)
            {
                AddDataSource(dataSource);
            }

            foreach (IDataSource dataSource in _dataSources)
            {
                DataSourceId parentId = dataSource.Settings.ParentId;
                if (parentId != DataSourceId.Empty)
                {
                    var parent = _dataSources.FirstOrDefault(x => x.Id == parentId) as MergedDataSource;
                    if (parent != null)
                    {
                        parent.Add(dataSource);
                    }
                    else
                    {
                        Log.WarnFormat("DataSource '{0} ({1})' is assigned a parent '{2}' but we don't know that one",
                                       dataSource.FullFileName,
                                       dataSource.Id,
                                       parentId);
                        // We don't want the rest of the application having to deal with this.
                        // Therefore we'll simply remove the parent link and treat this data
                        // source as any other ungrouped one.
                        dataSource.Settings.ParentId = DataSourceId.Empty;
                    }
                }
            }
        }
Ejemplo n.º 25
0
 public void SetBookmarks(BookmarkCollection bookmarks)
 {
     if (_bookmarks != bookmarks)
     {
         if (_bookmarks != null)
         {
             _bookmarks.CollectionChanged -= Bookmarks_CollectionChanged;
         }
         _bookmarks = bookmarks;
         if (bookmarks != null)
         {
             bookmarks.CollectionChanged += Bookmarks_CollectionChanged;
             Bookmarks_CollectionChanged(bookmarks, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
         }
     }
 }
Ejemplo n.º 26
0
        public void TestAddOneBookmark()
        {
            var collection = new BookmarkCollection(TimeSpan.Zero);

            collection.AddDataSource(_dataSource.Object);

            _logFile.AddEntry("", LevelFlags.Error);
            _logFile.AddEntry("", LevelFlags.Error);

            var bookmark = collection.TryAddBookmark(_dataSource.Object, 1);

            bookmark.Should().NotBeNull();
            bookmark.Index.Should().Be(new LogLineIndex(1));
            collection.Count.Should().Be(1);
            collection.Bookmarks.Should().BeEquivalentTo(new object[] { bookmark });
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Deletes the threads matching the passed in filter, inside the transaction specified.
        /// </summary>
        /// <param name="threadFilter">The thread filter.</param>
        /// <param name="trans">The transaction to use.</param>
        private static void DeleteThreads(PredicateExpression threadFilter, Transaction trans)
        {
            // we've to perform a set of actions in a given order to make sure we're not violating FK constraints in the DB.

            // delete messages in thread
            MessageManager.DeleteAllMessagesInThreads(threadFilter, trans);

            // delete bookmarks (if exists) of the threads to be deleted
            BookmarkCollection bookmarks = new BookmarkCollection();

            trans.Add(bookmarks);
            // use again a fieldcompareset predicate
            bookmarks.DeleteMulti(new FieldCompareSetPredicate(BookmarkFields.ThreadID, ThreadFields.ThreadID, SetOperator.In, threadFilter));

            // delete audit info related to this thread. Can't be done directly on the db due to the fact the entities are in a TargetPerEntity hierarchy, which
            // can't be deleted directly on the db, so we've to fetch the entities first.
            AuditDataThreadRelatedCollection threadAuditData = new AuditDataThreadRelatedCollection();

            trans.Add(threadAuditData);
            // use a fieldcompareset predicate filter, based on the threadFilter.
            threadAuditData.GetMulti(new FieldCompareSetPredicate(AuditDataThreadRelatedFields.ThreadID, ThreadFields.ThreadID, SetOperator.In, threadFilter));
            threadAuditData.DeleteMulti();

            // delete support queue thread entity for this thread (if any)
            SupportQueueThreadCollection supportQueueThreads = new SupportQueueThreadCollection();

            trans.Add(supportQueueThreads);
            // use again a fieldcompareset predicate
            supportQueueThreads.DeleteMulti(new FieldCompareSetPredicate(SupportQueueThreadFields.ThreadID, ThreadFields.ThreadID, SetOperator.In, threadFilter));

            // delete threadsubscription entities
            ThreadSubscriptionCollection threadSubscriptions = new ThreadSubscriptionCollection();

            trans.Add(threadSubscriptions);
            // use again a fieldcompareset predicate
            threadSubscriptions.DeleteMulti(new FieldCompareSetPredicate(ThreadSubscriptionFields.ThreadID, ThreadFields.ThreadID, SetOperator.In, threadFilter));

            // delete the threads
            ThreadCollection threads = new ThreadCollection();

            trans.Add(threads);
            // we already have the filter to use, namely the filter passed in.
            threads.DeleteMulti(threadFilter);

            // don't commit the transaction, that's up to the caller.
        }
Ejemplo n.º 28
0
        [Test] //ExSkip
        public void CreateUpdateAndPrintBookmarks()
        {
            // Create a document with three bookmarks, then use a custom document visitor implementation to print their contents.
            Document           doc       = CreateDocumentWithBookmarks(3);
            BookmarkCollection bookmarks = doc.Range.Bookmarks;

            Assert.AreEqual(3, bookmarks.Count); //ExSkip

            PrintAllBookmarkInfo(bookmarks);

            // Bookmarks can be accessed in the bookmark collection by index or name, and their names can be updated.
            bookmarks[0].Name = $"{bookmarks[0].Name}_NewName";
            bookmarks["MyBookmark_2"].Text = $"Updated text contents of {bookmarks[1].Name}";

            // Print all bookmarks again to see updated values.
            PrintAllBookmarkInfo(bookmarks);
        }
Ejemplo n.º 29
0
        public IActionResult BookmakerCollectionHandler(BookmarkCollection FromForm)
        {
            System.Console.WriteLine($"you have reached the backend of bookmaker collection {FromForm.Title}");
            if (HttpContext.Session.GetInt32("UserId") == null)
            {
                return(RedirectToAction("index"));
            }
            int GetUserbyId = (int)HttpContext.Session.GetInt32("UserId");

            FromForm.UserId = GetUserbyId;


            _context.Add(FromForm);
            _context.SaveChanges();

            return(Json(new { Status = "Success" }));
        }
Ejemplo n.º 30
0
        public void TestRemoveBookmark()
        {
            var collection = new BookmarkCollection(_bookmarks.Object, TimeSpan.Zero);

            collection.AddDataSource(_dataSource.Object);

            _logSource.AddEntry("", LevelFlags.Error);
            _logSource.AddEntry("", LevelFlags.Error);

            var bookmark = collection.TryAddBookmark(_dataSource.Object, 1);

            _bookmarks.Verify(x => x.SaveAsync(), Times.Once);

            collection.RemoveBookmark(bookmark);
            _bookmarks.Verify(x => x.SaveAsync(), Times.Exactly(2));
            collection.Bookmarks.Should().BeEmpty();
        }
Ejemplo n.º 31
0
        public void TestAddTwoBookmarks()
        {
            var collection = new BookmarkCollection(_bookmarks.Object, TimeSpan.Zero);

            collection.AddDataSource(_dataSource.Object);

            _logSource.AddEntry("", LevelFlags.Error);
            _logSource.AddEntry("", LevelFlags.Error);

            var bookmark1 = collection.TryAddBookmark(_dataSource.Object, 1);
            var bookmark2 = collection.TryAddBookmark(_dataSource.Object, 0);

            bookmark2.Should().NotBeNull();
            bookmark2.Index.Should().Be(new LogLineIndex(0));
            collection.Count.Should().Be(2);
            collection.Bookmarks.Should().BeEquivalentTo(new object[] { bookmark1, bookmark2 });
        }
Ejemplo n.º 32
0
		static async Task WriteFileAsync(string fileName, IReadOnlyList<ImageReference> images, FileHeader cic, BookmarkCollection bookmarks, IProgress<int> progress)
		{
			using (FileStream writeStream = new FileStream(fileName, FileMode.Create, FileAccess.Write))
			{
				cic.Save(writeStream);
				bookmarks.Save(writeStream);
				using (BinaryWriter writer = new BinaryWriter(writeStream, System.Text.Encoding.Unicode, true))
				{
					writer.Write(images.Count); // 画像数
					for (int i = 0; i < images.Count; i++)
					{
						await images[i].SaveAsync(writer).ConfigureAwait(false);
						progress?.Report((i + 1) * 100 / images.Count);
					}
				}
			}
		}
Ejemplo n.º 33
0
        private bool method_239(string A_0, string A_1)
        {
            bool flag = false;
            BookmarkCollection bookmarks = base.Document.Bookmarks;

            if (bookmarks.Count > 0)
            {
                Bookmark bookmark = bookmarks[A_0];
                if (((bookmark != null) && (bookmark.BookmarkStart != null)) && (bookmark.BookmarkEnd != null))
                {
                    bookmark.BookmarkStart.method_30(A_1);
                    bookmark.BookmarkEnd.method_30(A_1);
                    flag = true;
                }
            }
            return(flag);
        }
Ejemplo n.º 34
0
		protected virtual void Dispose(bool disposing)
		{
			if (disposing)
			{
				using (EnterUndirtiableSection())
				{
					if (_images != null)
					{
						_images.Clear();
						_images.Dispose();
						_images = null;
					}
					if (_bookmarks != null)
					{
						_bookmarks.Clear();
						_bookmarks.Dispose();
						_bookmarks = null;
					}
					Thumbnail = null;
					Title = Author = string.Empty;
					IsDirty = false;
				}
			}
		}
Ejemplo n.º 35
0
        /// <summary>
        /// Deletes the user with the ID passed in. Will reset all posts made by the user to the userid 0. 
        /// </summary>
        /// <param name="userID">The user ID.</param>
        /// <remarks>Can't delete user 0</remarks>
        /// <returns>true if succeeded, false otherwise</returns>
        public static bool DeleteUser(int userID)
        {
            if(userID == 0)
            {
                // can't delete the Anonymous coward user.
                return false;
            }

            UserEntity toDelete = UserGuiHelper.GetUser(userID);
            if(toDelete==null)
            {
                // user doesn't exist
                return false;
            }

            // all actions have to take place in a transaction.
            Transaction trans = new Transaction(IsolationLevel.ReadCommitted, "DeleteUser");

            try
            {
                // we'll first update all PostedByUserId fields of all messages which are posted by the user to delete.
                MessageEntity messageUpdater = new MessageEntity();
                messageUpdater.PostedByUserID = 0;	// reset to AC.
                MessageCollection messages = new MessageCollection();
                trans.Add(messages);	// add to the transaction
                // update all entities directly in the DB, which match the following filter and update them with the new values set in messageUpdater.
                messages.UpdateMulti(messageUpdater, (MessageFields.PostedByUserID == userID));

                // set the startuser of threads started by this user to 0
                ThreadEntity threadUpdater = new ThreadEntity();
                threadUpdater.StartedByUserID = 0;
                ThreadCollection threads = new ThreadCollection();
                trans.Add(threads);
                threads.UpdateMulti(threadUpdater, (ThreadFields.StartedByUserID == userID));

                // remove the user from the UserRoles set, as the user shouldn't be in any roles.
                RoleUserCollection roleUsersDeleter = new RoleUserCollection();
                trans.Add(roleUsersDeleter);
                // delete all entities directly from the DB which match the following filter.
                roleUsersDeleter.DeleteMulti(RoleUserFields.UserID == userID);

                // delete all bookmarks of user
                BookmarkCollection bookmarkDeleter = new BookmarkCollection();
                trans.Add(bookmarkDeleter);
                // delete all bookmarks for this user directly from the DB using the following filter.
                bookmarkDeleter.DeleteMulti(BookmarkFields.UserID == userID);

                // delete all audit data
                AuditDataCoreCollection auditDataDeleter = new AuditDataCoreCollection();
                // first fetch it, then delete all entities from the collection, as the audit data is in an inheritance hierarchy of TargetPerEntity which can't
                // be deleted directly from the db.
                trans.Add(auditDataDeleter);
                auditDataDeleter.GetMulti(AuditDataCoreFields.UserID == userID);
                auditDataDeleter.DeleteMulti();

                // set IP bans set by this user to userid 0
                IPBanEntity ipbanUpdater = new IPBanEntity();
                ipbanUpdater.IPBanSetByUserID = 0;
                IPBanCollection ipBans = new IPBanCollection();
                trans.Add(ipBans);
                ipBans.UpdateMulti(ipbanUpdater, (IPBanFields.IPBanSetByUserID == userID));

                // delete threadsubscriptions
                ThreadSubscriptionCollection threadSubscriptionsDeleter = new ThreadSubscriptionCollection();
                trans.Add(threadSubscriptionsDeleter);
                threadSubscriptionsDeleter.DeleteMulti(ThreadSubscriptionFields.UserID == userID);

                // remove supportqueuethread claims
                SupportQueueThreadCollection supportQueueThreads = new SupportQueueThreadCollection();
                trans.Add(supportQueueThreads);
                supportQueueThreads.DeleteMulti(SupportQueueThreadFields.ClaimedByUserID == userID);

                // set all placed in queue references to userid 0, so the threads stay in the queues.
                SupportQueueThreadEntity supportQueueThreadUpdater = new SupportQueueThreadEntity();
                supportQueueThreadUpdater.PlacedInQueueByUserID=0;
                supportQueueThreads.UpdateMulti(supportQueueThreadUpdater, (SupportQueueThreadFields.PlacedInQueueByUserID == userID));

                // now delete the actual user entity
                trans.Add(toDelete);
                toDelete.Delete();

                // all done
                trans.Commit();
                return true;
            }
            catch
            {
                trans.Rollback();
                throw;
            }
            finally
            {
                trans.Dispose();
            }
        }
Ejemplo n.º 36
0
 /// <summary>
 /// Removes the threads with threadid in the arraylist passed in from the bookmarks
 /// </summary>
 /// <param name="threadIDsToRemove">Thread I ds to remove.</param>
 /// <param name="userID">user for whom these bookmarks have to be deleted</param>
 public static void RemoveBookmarks(ArrayList threadIDsToRemove, int userID)
 {
     BookmarkCollection bookmarks = new BookmarkCollection();
     // delete the bookmarks matching the filter directly from the database.
     bookmarks.DeleteMulti((BookmarkFields.ThreadID == threadIDsToRemove).And(BookmarkFields.UserID == userID));
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Removes the single bookmark passed in
 /// </summary>
 /// <param name="threadID">Thread ID.</param>
 /// <param name="userID">User ID.</param>
 /// <returns></returns>
 public static void RemoveSingleBookmark(int threadID, int userID)
 {
     BookmarkCollection bookmarks = new BookmarkCollection();
     // delete the bookmark directly from the database, no need for fetching it first.
     bookmarks.DeleteMulti((BookmarkFields.ThreadID == threadID).And(BookmarkFields.UserID == userID));
 }
Ejemplo n.º 38
0
        /// <summary>
        /// Deletes the threads matching the passed in filter, inside the transaction specified.
        /// </summary>
        /// <param name="threadFilter">The thread filter.</param>
        /// <param name="trans">The transaction to use.</param>
        private static void DeleteThreads(PredicateExpression threadFilter, Transaction trans)
        {
            // we've to perform a set of actions in a given order to make sure we're not violating FK constraints in the DB.

            // delete messages in thread
            MessageManager.DeleteAllMessagesInThreads(threadFilter, trans);

            // delete bookmarks (if exists) of the threads to be deleted
            BookmarkCollection bookmarks = new BookmarkCollection();
            trans.Add(bookmarks);
            // use again a fieldcompareset predicate
            bookmarks.DeleteMulti(new FieldCompareSetPredicate(BookmarkFields.ThreadID, ThreadFields.ThreadID, SetOperator.In, threadFilter));

            // delete audit info related to this thread. Can't be done directly on the db due to the fact the entities are in a TargetPerEntity hierarchy, which
            // can't be deleted directly on the db, so we've to fetch the entities first.
            AuditDataThreadRelatedCollection threadAuditData = new AuditDataThreadRelatedCollection();
            trans.Add(threadAuditData);
            // use a fieldcompareset predicate filter, based on the threadFilter.
            threadAuditData.GetMulti(new FieldCompareSetPredicate(AuditDataThreadRelatedFields.ThreadID, ThreadFields.ThreadID, SetOperator.In, threadFilter));
            threadAuditData.DeleteMulti();

            // delete support queue thread entity for this thread (if any)
            SupportQueueThreadCollection supportQueueThreads = new SupportQueueThreadCollection();
            trans.Add(supportQueueThreads);
            // use again a fieldcompareset predicate
            supportQueueThreads.DeleteMulti(new FieldCompareSetPredicate(SupportQueueThreadFields.ThreadID, ThreadFields.ThreadID, SetOperator.In, threadFilter));

            // delete threadsubscription entities
            ThreadSubscriptionCollection threadSubscriptions = new ThreadSubscriptionCollection();
            trans.Add(threadSubscriptions);
            // use again a fieldcompareset predicate
            threadSubscriptions.DeleteMulti(new FieldCompareSetPredicate(ThreadSubscriptionFields.ThreadID, ThreadFields.ThreadID, SetOperator.In, threadFilter));

            // delete the threads
            ThreadCollection threads = new ThreadCollection();
            trans.Add(threads);
            // we already have the filter to use, namely the filter passed in.
            threads.DeleteMulti(threadFilter);

            // don't commit the transaction, that's up to the caller.
        }
Ejemplo n.º 39
0
		public async Task ExtractAsync(string fileName, IEnumerable<ImageReference> images, IProgress<int> progress)
		{
			using (EnterSingleOperation())
			using (var bookmarks = new BookmarkCollection())
				await WriteFileAsync(fileName, images.ToArray(), new FileHeader(string.Empty, Author, null, PageTurningDirection, null), bookmarks, progress).ConfigureAwait(false);
		}
Ejemplo n.º 40
0
		public async Task AppendAsync(string fileName, IProgress<int> progress)
		{
			using (EnterSingleOperation())
			using (Images.EnterUnnotifiedSection())
			using (var bookmarks = new BookmarkCollection())
				await ReadFileAsync(fileName, bookmarks, progress).ConfigureAwait(false);
		}