Exemplo n.º 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 CustomerRequirementsController(IContractorRepository contractorRepo,
                                       IContractRepository contractRepo,
                                       IPeriodRepository periodRepo,
                                       IRequirementRepository requirementRepo,
                                       IPresentationRepository presentationRepo,
                                       IPresentationServices presentationServ,
                                       IDocumentFileService documentFileServ,
                                       IWorkflowMessageService workflowMessageServ)
 {
     contractorRepository   = contractorRepo;
     contractRepository     = contractRepo;
     periodRepository       = periodRepo;
     requirementRepository  = requirementRepo;
     presentationRepository = presentationRepo;
     presentationServices   = presentationServ;
     documentFileService    = documentFileServ;
     workflowMessageService = workflowMessageServ;
 }
Exemplo n.º 3
0
 public RequirementsController(IRequirementRepository requirementRepo,
                               IPresentationRepository presentationRepo,
                               IDocumentFileService documentFileServ,
                               ICustomerAuditorRespository customerAuditorRespo,
                               IContractorRepository contractorRepo,
                               IPresentationServices presentationServ,
                               IWorkflowMessageService workflowMessageServ,
                               IDocumentationBusinessTypeRepository documentationBusinessTypeRepo,
                               IPeriodRepository periodRepo,
                               IEntityTypeRepository entityTypeRepo)
 {
     requirementRepository               = requirementRepo;
     presentationRepository              = presentationRepo;
     documentFileService                 = documentFileServ;
     customerAuditorRespository          = customerAuditorRespo;
     contractorRepository                = contractorRepo;
     presentationServices                = presentationServ;
     workflowMessageService              = workflowMessageServ;
     documentationBusinessTypeRepository = documentationBusinessTypeRepo;
     periodRepository     = periodRepo;
     entityTypeRepository = entityTypeRepo;
 }
 public DocumentFileController(IDocumentFileService documentService)
 {
     _IDocumentService = documentService;
 }
Exemplo n.º 5
0
 public PresentationsController(IPresentationRepository presentationRepo, IDocumentFileService documentFileServ, IRequirementRepository requirementRepo)
 {
     presentationRepository = presentationRepo;
     documentFileService    = documentFileServ;
     requirementRepository  = requirementRepo;
 }
Exemplo n.º 6
0
 public PresentationRepository(ILogger logger, IDocumentFileService docFileServices)
 {
     log = logger;
     documentFileService = docFileServices;
 }
Exemplo n.º 7
0
 public ProductDocumentService(ILogger logger, IProductDocumentRepository productDocumentRepo, IDocumentFileService documentFileServ)
 {
     log = logger;
     productDocumentRepository = productDocumentRepo;
     documentFileService       = documentFileServ;
 }
Exemplo n.º 8
0
 public DocumentFileController(IServiceProvider provider)
 {
     documentFileService = provider.GetRequiredService <IDocumentFileService>();
 }
Exemplo n.º 9
0
        public void GetDocumentFolders(IDocumentFolderService service, IDocumentFileService fileService, DocumentFolderViewModel dir, bool recursive = false)
        {
            if (CancelOperation)
            {
                return;
            }

            if (dir != null)
            {
                CloudFileDirectory dirPath = GetDirectory(dir.Path);
                if (dirPath != null && dirPath.Exists())
                {
                    currentlyIndexedNumber++;
                    IndexingDirectoryChanged?.Invoke(dir.Path, currentlyIndexedNumber);

                    if (dir.Id < 1)
                    {
                        var response = service.Create(dir);
                        if (response.Success)
                        {
                            dir.Id = response?.DocumentFolder?.Id ?? 0;
                        }
                        else
                        {
                            dir.Id = -1;
                        }
                    }
                    if (dir.Id > 0)
                    {
                        dirPath.FetchAttributes();
                        var subFilesAndDirectories = dirPath.ListFilesAndDirectories();

                        var subFiles = subFilesAndDirectories.OfType <CloudFile>()
                                       .Select(x => new DocumentFileViewModel()
                        {
                            Identifier     = Guid.NewGuid(),
                            DocumentFolder = dir,
                            Name           = x.Name,
                            Path           = x.Uri.LocalPath,

                            Company = new ServiceInterfaces.ViewModels.Common.Companies.CompanyViewModel()
                            {
                                Id = MainWindow.CurrentCompanyId
                            },
                            CreatedBy = new ServiceInterfaces.ViewModels.Common.Identity.UserViewModel()
                            {
                                Id = MainWindow.CurrentUserId
                            }
                        })
                                       .ToList();
                        subFiles.ForEach(x => GetDocumentAttributes(x));

                        var fileResponse = fileService.SubmitList(subFiles);



                        var subDirectories = subFilesAndDirectories.OfType <CloudFileDirectory>()
                                             .Select(x => new DocumentFolderViewModel()
                        {
                            Path    = x.Uri.LocalPath, Name = x.Name, Identifier = Guid.NewGuid(), ParentFolder = dir,
                            Company = new ServiceInterfaces.ViewModels.Common.Companies.CompanyViewModel()
                            {
                                Id = MainWindow.CurrentCompanyId
                            },
                            CreatedBy = new ServiceInterfaces.ViewModels.Common.Identity.UserViewModel()
                            {
                                Id = MainWindow.CurrentUserId
                            }
                        })
                                             .ToList();

                        var response = service.SubmitList(subDirectories);
                        if (response.Success)
                        {
                            dir.SubDirectories = new ObservableCollection <DocumentFolderViewModel>(response?.DocumentFolders ?? new List <DocumentFolderViewModel>());

                            if (recursive)
                            {
                                foreach (var item in dir.SubDirectories)
                                {
                                    if (CancelOperation)
                                    {
                                        return;
                                    }

                                    GetDocumentFolders(service, fileService, item, recursive);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
 public DocumentFileController(IDocumentFileService service)
 {
     _service = service;
 }
Exemplo n.º 11
0
        public Home()
        {
            businessPartnerService            = DependencyResolver.Kernel.Get <IBusinessPartnerService>();
            businessPartnerTypeService        = DependencyResolver.Kernel.Get <IBusinessPartnerTypeService>();
            businessPartnerBankService        = DependencyResolver.Kernel.Get <IBusinessPartnerBankService>();
            businessPartnerDocumentService    = DependencyResolver.Kernel.Get <IBusinessPartnerDocumentService>();
            businessPartnerInstitutionService = DependencyResolver.Kernel.Get <IBusinessPartnerInstitutionService>();
            businessPartnerLocationService    = DependencyResolver.Kernel.Get <IBusinessPartnerLocationService>();
            businessPartnerNoteService        = DependencyResolver.Kernel.Get <IBusinessPartnerNoteService>();
            //businessPartnerOrganizationUnitService = DependencyResolver.Kernel.Get<IBusinessPartnerOrganizationUnitService>();
            businessPartnerPhoneService = DependencyResolver.Kernel.Get <IBusinessPartnerPhoneService>();


            employeeService           = DependencyResolver.Kernel.Get <IEmployeeService>();
            employeeProfessionService = DependencyResolver.Kernel.Get <IEmployeeProfessionService>();
            employeeNoteService       = DependencyResolver.Kernel.Get <IEmployeeNoteService>();
            employeeLicenceService    = DependencyResolver.Kernel.Get <IEmployeeLicenceService>();
            employeeItemService       = DependencyResolver.Kernel.Get <IEmployeeItemService>();
            employeeDocumentService   = DependencyResolver.Kernel.Get <IEmployeeDocumentService>();
            employeeCardService       = DependencyResolver.Kernel.Get <IEmployeeCardService>();

            licenceTypeService  = DependencyResolver.Kernel.Get <ILicenceTypeService>();
            familyMemberService = DependencyResolver.Kernel.Get <IFamilyMemberService>();

            physicalPersonService           = DependencyResolver.Kernel.Get <IPhysicalPersonService>();
            physicalPersonProfessionService = DependencyResolver.Kernel.Get <IPhysicalPersonProfessionService>();
            physicalPersonNoteService       = DependencyResolver.Kernel.Get <IPhysicalPersonNoteService>();
            physicalPersonLicenceService    = DependencyResolver.Kernel.Get <IPhysicalPersonLicenceService>();
            physicalPersonItemService       = DependencyResolver.Kernel.Get <IPhysicalPersonItemService>();
            physicalPersonDocumentService   = DependencyResolver.Kernel.Get <IPhysicalPersonDocumentService>();
            physicalPersonCardService       = DependencyResolver.Kernel.Get <IPhysicalPersonCardService>();


            outputInvoiceService = DependencyResolver.Kernel.Get <IOutputInvoiceService>();
            inputInvoiceService  = DependencyResolver.Kernel.Get <IInputInvoiceService>();

            countryService      = DependencyResolver.Kernel.Get <ICountryService>();
            regionService       = DependencyResolver.Kernel.Get <IRegionService>();
            municipalityService = DependencyResolver.Kernel.Get <IMunicipalityService>();
            cityService         = DependencyResolver.Kernel.Get <ICityService>();

            sectorService     = DependencyResolver.Kernel.Get <ISectorService>();
            professionService = DependencyResolver.Kernel.Get <IProfessionService>();
            bankService       = DependencyResolver.Kernel.Get <IBankService>();
            agencyService     = DependencyResolver.Kernel.Get <IAgencyService>();

            constructionSiteService            = DependencyResolver.Kernel.Get <IConstructionSiteService>();
            constructionSiteDocumentService    = DependencyResolver.Kernel.Get <IConstructionSiteDocumentService>();
            constructionSiteCalculationService = DependencyResolver.Kernel.Get <IConstructionSiteCalculationService>();
            constructionSiteNoteService        = DependencyResolver.Kernel.Get <IConstructionSiteNoteService>();


            //employeeByBusinessPartnerService = DependencyResolver.Kernel.Get<IEmployeeByBusinessPartnerService>(); //radnici po firmama?
            //employeeByConstructionSiteService = DependencyResolver.Kernel.Get<IEmployeeByConstructionSiteService>(); // radnici po gradilistu
            //businessPartnerByConstructionSiteService = DependencyResolver.Kernel.Get<IBusinessPartnerByConstructionSiteService>(); //firme po gradilistu

            taxAdministrationService = DependencyResolver.Kernel.Get <ITaxAdministrationService>();

            limitationService      = DependencyResolver.Kernel.Get <ILimitationService>();
            userService            = DependencyResolver.Kernel.Get <IUserService>();
            vatService             = DependencyResolver.Kernel.Get <IVatService>();
            discountService        = DependencyResolver.Kernel.Get <IDiscountService>();
            serviceDeliveryService = DependencyResolver.Kernel.Get <IServiceDeliveryService>();
            statusService          = DependencyResolver.Kernel.Get <IStatusService>();
            shipmentService        = DependencyResolver.Kernel.Get <IShipmentService>();

            toDoService = DependencyResolver.Kernel.Get <IToDoService>();

            phonebookService  = DependencyResolver.Kernel.Get <IPhonebookService>();
            callCentarService = DependencyResolver.Kernel.Get <ICallCentarService>();

            employeeByConstructionSiteService        = DependencyResolver.Kernel.Get <IEmployeeByConstructionSiteService>();
            businessPartnerByConstructionSiteService = DependencyResolver.Kernel.Get <IBusinessPartnerByConstructionSiteService>();
            employeeByBusinessPartnerService         = DependencyResolver.Kernel.Get <IEmployeeByBusinessPartnerService>();

            documentFolderService = DependencyResolver.Kernel.Get <IDocumentFolderService>();
            documentFileService   = DependencyResolver.Kernel.Get <IDocumentFileService>();

            InitializeComponent();

            this.DataContext = this;

            var resp = new CompanyUserSQLiteRepository().GetCompanyUser(MainWindow.CurrentCompanyId, MainWindow.CurrentUser?.Identifier ?? Guid.Empty);

            if (resp.Success)
            {
                var userRoles = resp.CompanyUser?.UserRoles ?? new List <UserRoleViewModel>();
                if (userRoles.Any(x => x.Name == "CallCentar") || userRoles.Any(x => x.Name == "Admin"))
                {
                    CallCentarList.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    CallCentarList.Visibility = System.Windows.Visibility.Collapsed;
                }
            }
        }
        public void Sync(IDocumentFileService service, Action <int, int> callback = null)
        {
            try
            {
                SyncDocumentFileRequest request = new SyncDocumentFileRequest();
                request.CompanyId     = MainWindow.CurrentCompanyId;
                request.LastUpdatedAt = GetLastUpdatedAt(MainWindow.CurrentCompanyId);
                request.CurrentPage   = 1;
                request.ItemsPerPage  = 500;

                int toSync      = 0;
                int syncedItems = 0;

                DocumentFileListResponse response = service.Sync(request);
                if (!response.Success)
                {
                    throw new Exception(response.Message);
                }
                var items = new List <DocumentFileViewModel>(response?.DocumentFiles ?? new List <DocumentFileViewModel>());
                while (items.Count() > 0)
                {
                    toSync += response?.DocumentFiles?.Count ?? 0;

                    using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
                    {
                        db.Open();
                        using (var transaction = db.BeginTransaction())
                        {
                            SqliteCommand deleteCommand = db.CreateCommand();
                            deleteCommand.CommandText = "DELETE FROM DocumentFiles WHERE Identifier = @Identifier";

                            SqliteCommand insertCommand = db.CreateCommand();
                            insertCommand.CommandText = SqlCommandInsertPart;

                            foreach (var item in items)
                            {
                                deleteCommand.Parameters.AddWithValue("@Identifier", item.Identifier);
                                deleteCommand.ExecuteNonQuery();
                                deleteCommand.Parameters.Clear();

                                if (item.IsActive)
                                {
                                    insertCommand = AddCreateParameters(insertCommand, item);
                                    insertCommand.ExecuteNonQuery();
                                    insertCommand.Parameters.Clear();

                                    syncedItems++;
                                    callback?.Invoke(syncedItems, toSync);
                                }
                            }

                            transaction.Commit();
                        }
                        db.Close();
                    }
                    request.CurrentPage++;
                    response = service.Sync(request);
                    if (!response.Success)
                    {
                        throw new Exception(response.Message);
                    }
                    items = new List <DocumentFileViewModel>(response?.DocumentFiles ?? new List <DocumentFileViewModel>());
                }
            }
            catch (Exception ex)
            {
                MainWindow.ErrorMessage = ex.Message;
            }
        }