Esempio n. 1
0
        private void btnIndex_Click(object sender, EventArgs e)
        {
            var fldBrowser = new FolderBrowserDialog { Description = "Select Root Directory to Index (All Sub Folders will be indexed)" };
            var result = fldBrowser.ShowDialog();
            if (result == DialogResult.OK)
            {
                var paths = Directory.GetFiles(fldBrowser.SelectedPath, "*.rfa", SearchOption.AllDirectories);

                using (var jobModel = new FileQueueEntities(ConnectionString))
                {
                    var indexType = Enums.IndexType.Full;
                    if (rbNewOnly.Checked) indexType = Enums.IndexType.NewOnly;
                    if (rbNewAndVersion.Checked) indexType = Enums.IndexType.NewAndVersionUpdate;
                    var library = fldBrowser.RootFolder.ToString();
                    foreach (var filequeue in paths.Select(path =>
                                                           new FileQueue
                                                               {
                                                                   Id = Guid.NewGuid(),
                                                                   InstanceId = InstanceId,
                                                                   Library = library,
                                                                   FilePath = path,
                                                                   Attempts = 0,
                                                                   Status = Enums.IndexStatus.Queued.ToString(),
                                                                   RevitVersion = RevitVersion,
                                                                   IndexType = indexType.ToString(),
                                                                   AddedDateTime = DateTime.Now,
                                                                   FileName = path.Split('/')[path.Split('/').Count() -1]
                                                               }))
                    {
                        jobModel.AddObject("FileQueues", filequeue);
                        jobModel.SaveChanges();

                    }
                }
            }
        }