Exemple #1
0
        public bool Connect()
        {
            Endpoint = new KustoEndpoint(_config);
            Endpoint.Authenticate();
            _failureQueryTime = _instance.StartTime.ToUniversalTime();

            if (!PopulateQueueEnumerators())
            {
                return(false);
            }

            if (_config.IsKustoPurgeRequested())
            {
                Purge();
                return(false);
            }
            else if (_config.KustoRecreateTable)
            {
                PurgeMessages(Endpoint.TableName);

                if (!Endpoint.DropTable(Endpoint.TableName))
                {
                    return(false);
                }
            }
            else if (_config.Unique && Endpoint.HasTable(Endpoint.TableName))
            {
                _appendingToExistingTableUnique = true;
                List <string> existingUploads = Endpoint.Query($"['{Endpoint.TableName}']|distinct RelativeUri");
                foreach (string existingUpload in existingUploads)
                {
                    _instance.FileObjects.Add(new FileObject(existingUpload)
                    {
                        Status = FileStatus.existing
                    });
                }
            }

            // monitor for new files to be uploaded
            if (_monitorTask == null)
            {
                _monitorTask = Task.Run((Action)QueueMonitor, _tokenSource.Token);
            }

            return(true);
        }