예제 #1
0
        private void btnRecalculateIndexes_Click(object sender, RoutedEventArgs e)
        {
            Thread td = new Thread(() =>
            {
                DocumentIndexingButtonEnabled = false;

                try
                {
                    DocumentIndexingButtonContent = " Priprema ... ";
                    IDocumentFolderService documentFolderService = DependencyResolver.Kernel.Get <IDocumentFolderService>();
                    IDocumentFileService documentFileService     = DependencyResolver.Kernel.Get <IDocumentFileService>();

                    var clearResponse = documentFolderService.Clear(MainWindow.CurrentCompanyId);

                    if (clearResponse.Success)
                    {
                        var clearFileResponse = documentFileService.Clear(MainWindow.CurrentCompanyId);
                        if (clearFileResponse.Success)
                        {
                            var azureClient = new AzureDataClient();
                            var rootFolder  = new DocumentFolderViewModel()
                            {
                                Identifier = Guid.NewGuid(),

                                Name    = "Documents",
                                Path    = azureClient.rootDirectory.Uri.LocalPath,
                                Company = new CompanyViewModel()
                                {
                                    Id = MainWindow.CurrentCompanyId
                                },
                                CreatedBy = new UserViewModel()
                                {
                                    Id = MainWindow.CurrentUserId
                                }
                            };
                            azureClient.IndexingDirectoryChanged += delegate(string currentPath, int totalIndexed)
                            {
                                DocumentIndexingButtonContent = $" Indeksirano foldera: {totalIndexed}. Trenutni folder: {currentPath}";
                            };
                            azureClient.ResetIndexNumber();
                            azureClient.GetDocumentFolders(documentFolderService, documentFileService, rootFolder, true);
                        }
                    }
                    DocumentIndexingButtonEnabled = true;
                    DocumentIndexingButtonContent = " Indeksiranje dokumenata ";
                } catch (Exception ex)
                {
                    MainWindow.ErrorMessage       = ex.Message;
                    DocumentIndexingButtonEnabled = true;
                }
            });

            td.IsBackground = true;
            td.Start();
        }
        public JsonResult Clear(int CompanyId)
        {
            DocumentFolderResponse response = new DocumentFolderResponse();

            try
            {
                response = documentFolderService.Clear(CompanyId);
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
                Console.WriteLine(ex.Message);
            }

            return(Json(response, new Newtonsoft.Json.JsonSerializerSettings()
            {
                Formatting = Newtonsoft.Json.Formatting.Indented
            }));
        }