Esempio n. 1
0
        public void BuildIndexAsync(string root, string alias)
        {
            if (Directory.Exists(root) == false)
            {
                throw new System.IO.DirectoryNotFoundException(INVALID_ROOT_MESSAGE);
            }

            DirectoryInfo directory = new DirectoryInfo(root);
            TrackedFolder folder    = new TrackedFolder()
            {
                FullPath = directory.FullName,
                Name     = directory.Name
            };

            using (DbModelContainer db = new DbModelContainer())
            {
                db.Indices.Add(new Index()
                {
                    Alias = alias,
                    Root  = folder
                });
                db.SaveChanges();
            }

            Thread thread = new Thread(() =>
            {
                DigDirectory(directory, folder.Id);
            });

            thread.Start();
        }
Esempio n. 2
0
        public void BuildIndexAsync(string root, string alias)
        {
            IsRunning = true;

            Thread thread = new Thread(() =>
            {
                if (Directory.Exists(root) == false)
                {
                    throw new System.IO.DirectoryNotFoundException(INVALID_ROOT_MESSAGE);
                }

                DirectoryInfo directory = new DirectoryInfo(root);
                TrackedFolder folder    = new TrackedFolder()
                {
                    FullPath = directory.FullName,
                    Name     = directory.Name
                };

                using (DbModelContainer db = new DbModelContainer())
                {
                    Index index = new Index()
                    {
                        Alias = alias,
                        Root  = folder
                    };

                    db.Indices.Add(index);

                    db.SaveChanges();

                    //temporarily assign this index object the ID of the
                    //newly created one for use in dig directory
                    this.Id    = index.Id;
                    this.Alias = alias;
                }


                DigDirectory(directory, folder.Id);
                IsRunning = false;
            });

            thread.Start();
        }