/// <summary>
        /// Add document to index asynchronously
        /// </summary>
        public static void AddDocumentToIndexAsynchronously()
        {
            //ExStart:AddDocumentToIndexAsynchronously
            // Create index
            Index index = new Index(Utilities.indexPath);

            index.OperationFinished += Utilities.index_OperationFinished;
            // all files from folder and its subfolders will be added to the index
            index.AddToIndexAsync(Utilities.documentsPath);
            //ExEnd:AddDocumentToIndexAsynchronously
        }
        /// <summary>
        /// Subscription to events
        /// </summary>
        public static void SubscriptionToEvents()
        {
            //ExStart:SubscriptionToEvents
            // Create index in memory
            Index index = new Index();

            index.OperationFinished += Utilities.index_OperationFinished;
            index.AddToIndexAsync(Utilities.documentsPath);
            index.UpdateAsync();
            //ExEnd:SubscriptionToEvents
        }
        /// <summary>
        /// Break Index Repository
        /// This method is supported by version 18.8 or greater
        /// </summary>
        public static void BreakIndexRepository()
        {
            string indexFolder     = Utilities.indexPath;
            string documentsFolder = Utilities.documentsPath;

            IndexRepository repository = new IndexRepository();
            Index           index      = repository.Create(indexFolder);

            index.AddToIndexAsync(documentsFolder);

            // Breaking all processes in all indexes in repository
            repository.Break();
        }
        /// <summary>
        /// Break indexing with cancellation object
        /// This method is supported by version 18.7 or greater
        /// </summary>
        public static void BreakIndexingWithCancellationObject()
        {
            // Creating cancellation object
            Cancellation cancellation = new Cancellation();

            // Creating index
            Index index = new Index(Utilities.indexPath);

            // Indexing
            index.AddToIndexAsync(Utilities.documentsPath, cancellation);

            // Cancelling after 1 second of indexing
            Thread.Sleep(1000);
            cancellation.Cancel();
        }
        public static void MultiThreadedIndexingAsync()
        {
            try
            {
                // Creating index
                Index index = new Index(Utilities.indexPath);

                // Indexing in 2 threads
                index.AddToIndexAsync(Utilities.documentsPath, 2);

                // User can perform a search after the completion of the indexing operation
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
 /// <summary>
 /// Tracks all the changes in the index folder
 /// This method is support by version 18.6 or greater
 /// </summary>
 public static void BreakIndexingManually()
 {
     try
     {
         // Creating index
         Index index = new Index(Utilities.indexPath);
         // Subscribing on Operation Finished event
         index.OperationFinished += Utilities.index_OperationFinished;
         // Indexing selected folder asynchronously
         index.AddToIndexAsync(Utilities.documentsPath);
         //
         index.Break();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Esempio n. 7
0
        public async Task DocStore_Index()
        {
            var t = new Appointment(
                BeginDate: new Date(2017, 5, 15),
                BeginTime: new Time(9, 0, 0),
                EndDate: new Date(2017, 5, 15),
                EndTime: new Time(17, 0, 0),
                category: AppointmentCategory.@private,
                details: "MVC Kurs",
                Location: new mko.BI.Bo.Addresses.Location()
            {
                City = "Düsseldorf", Country = "de"
            },
                Owner: "ich");

            string id = docs.CreateDocHashId(t);
            await docs.PutAsync(id, t);

            await index.AddToIndexAsync(id, t);

            // Allgemeine Termine anlegen
            for (int jahr = 2015; jahr < 2030; jahr++)
            {
                foreach (var tupel in Appointment.RepeatingAppointments)
                {
                    var app = new Appointment(
                        BeginDate: new Date(jahr, tupel.Item2, tupel.Item1),
                        BeginTime: new Time(0),
                        EndDate: new Date(jahr, tupel.Item2, tupel.Item1),
                        EndTime: new Time(23, 59, 59),
                        category: tupel.Item3,
                        details: tupel.Item4,
                        Owner: "alle",
                        Location: new mko.BI.Bo.Addresses.Location());

                    id = docs.CreateDocHashId(app);

                    await docs.PutAsync(id, app);

                    await index.AddToIndexAsync(id, app);
                }
            }

            await index.SaveChangesAsync();

            // Abfragen
            var qb = index.CreateQueryBuilder();

            qb.Between = new BI.Bo.Interval <DateTime>(new DateTime(2017, 1, 1), new DateTime(2018, 1, 1));

            var sob = qb.GetSortOrderBuilder();

            sob.OrderByCategory(false);
            sob.OrderByBegin(true);

            var fss = sob.GetFilteredSortedSet();

            Assert.IsFalse(0 == fss.Count());

            var set = fss.Get();


            AppointmentCategory old_cat = AppointmentCategory.@private;
            IDate old_date = new Date(2100);

            foreach (var key in set)
            {
                var app = await docs.GetAsync(key);

                Debug.WriteLine(app.Category + ", " + app.BeginDate.ToStr() + "T" + app.BeginTime.ToStr() + ": " + app.Details);

                if (old_cat == app.Category)
                {
                    Assert.IsTrue(old_date.ToDateTime().Ticks >= app.BeginDate.ToDateTime().Ticks);
                    old_date = app.BeginDate;
                }
                else
                {
                    old_date = new Date(2100);
                    old_cat  = app.Category;
                }
            }
        }