Ejemplo n.º 1
0
        private async Task <GitHubRepository> CreateRepositoryInternal(NewRepository newRepository, string organization)
        {
            try
            {
                logger.Trace("Creating repository");

                await ValidateKeychain();
                await ValidateCurrentUserInternal();

                GitHubRepository repository;
                if (!string.IsNullOrEmpty(organization))
                {
                    logger.Trace("Creating repository for organization");

                    repository = (await githubClient.Repository.Create(organization, newRepository)).ToGitHubRepository();
                }
                else
                {
                    logger.Trace("Creating repository for user");

                    repository = (await githubClient.Repository.Create(newRepository)).ToGitHubRepository();
                }

                logger.Trace("Created Repository");
                return(repository);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error Creating Repository");
                throw;
            }
        }
Ejemplo n.º 2
0
        public override void Set <T>(string key, T value)
        {
            if (cacheData == null)
            {
                Initialize();
            }

            try
            {
                object val = value;
                if (value is DateTimeOffset)
                {
                    val = ((DateTimeOffset)(object)value).ToString(DateTimeFormatConstants.Iso8601Format);
                }
                if (!cacheData.ContainsKey(key))
                {
                    cacheData.Add(key, val);
                }
                else
                {
                    cacheData[key] = val;
                }
                SaveToCache(cachePath);
            }
            catch (Exception e)
            {
                logger.Error(e, "Error storing to cache");
                throw;
            }
        }
Ejemplo n.º 3
0
        /*============================================================================*/
        /* Private Functions                                                          */
        /*============================================================================*/

        private void HandleContextView(object contextViewObject)
        {
            IContextView contextView = contextViewObject as IContextView;

            _contextView = contextView.view;

            if (!_injector.HasDirectMapping(typeof(IViewStateWatcher)))
            {
                _logger.Error("No IViewStateWatcher installed prior to Modularity Extension. The Modularity extension requires IViewStateWatcher to be installed first");
                return;
            }
            _contextViewStateWatcher = _injector.GetInstance(typeof(IViewStateWatcher)) as IViewStateWatcher;

            if (!_injector.HasDirectMapping(typeof(IParentFinder)))
            {
                _logger.Error("No IParentFinder Installed. The Modularity extension required this");
                return;
            }
            _parentFinder = _injector.GetInstance(typeof(IParentFinder)) as IParentFinder;

            if (_expose)
            {
                ConfigureExistenceWatcher();
            }
            if (_inherit)
            {
                ConfigureExistenceBroadcaster();
            }
        }
Ejemplo n.º 4
0
 public void Start()
 {
     try
     {
         Logger.Info($"Starting http server on port {Port} serving from {rootDirectory}");
         listener.Start();
         while (true)
         {
             try
             {
                 abort = false;
                 Logger.Info($"Waiting for a request...");
                 var context = listener.GetContext();
                 var thread  = new Thread(p => Process((HttpListenerContext)p));
                 thread.Start(context);
             }
             catch (Exception ex)
             {
                 Logger.Error(ex);
                 break;
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
 }
Ejemplo n.º 5
0
        private async Task <GitHubRepository> CreateRepositoryInternal(string repositoryName, string organization, string description, bool isPrivate)
        {
            try
            {
                logger.Trace("Creating repository");

                var user = await GetCurrentUser();

                var keychainAdapter = keychain.Connect(OriginalUrl);

                var command = new StringBuilder("publish -r \"");
                command.Append(repositoryName);
                command.Append("\"");

                if (!string.IsNullOrEmpty(description))
                {
                    command.Append(" -d \"");
                    command.Append(description);
                    command.Append("\"");
                }

                if (!string.IsNullOrEmpty(organization))
                {
                    command.Append(" -o \"");
                    command.Append(organization);
                    command.Append("\"");
                }

                if (isPrivate)
                {
                    command.Append(" -p");
                }

                var octorunTask = new OctorunTask(taskManager.Token, nodeJsExecutablePath, octorunScriptPath, command.ToString(),
                                                  user: user.Login, userToken: keychainAdapter.Credential.Token)
                                  .Configure(processManager);

                var ret = await octorunTask.StartAwait();

                if (ret.IsSuccess && ret.Output.Length == 2)
                {
                    return(new GitHubRepository
                    {
                        Name = ret.Output[0],
                        CloneUrl = ret.Output[1]
                    });
                }

                throw new ApiClientException(ret.GetApiErrorMessage() ?? "Publish failed");
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error Creating Repository");
                throw;
            }
        }
Ejemplo n.º 6
0
        public static UpdateInfo?GetUpdateInfo(string fileLocation, ApplicationMetadata metadata, bool grabDeltaUpdates, object?tag = null, string?folderLocation = null)
        {
            if (!File.Exists(fileLocation))
            {
                Logger.Error("{0} doesn't exist, can't get UpdateInfo", fileLocation);
                return(null);
            }

            return(new UpdateInfo(metadata.ApplicationVersion,
                                  ReleaseFile.ReadReleaseFile(File.ReadLines(fileLocation))
                                  .ToReleaseEntries(folderLocation ?? metadata.TempFolder, tag)
                                  .FilterReleases(metadata.ApplicationFolder, grabDeltaUpdates, metadata.ApplicationVersion).ToArray()));
        }
Ejemplo n.º 7
0
        public void ActivateUser(Guid userId)
        {
            _logger.Info("START :: UserService.ActivateUser()");
            Entities.User user = _repository.Read <Entities.User>(userId);

            if (user == default(Entities.User))
            {
                _logger.Error("Error :: UserService.ActivateUser()");
                throw new InvalidOperationException("User doesn't exist for id: " + userId);
            }

            user.Active = true;
            _repository.Persist <Entities.User>(user);
            _logger.Info("END :: UserService.ActivateUser()");
        }
Ejemplo n.º 8
0
 private T ScheduleUI <T>(T task, bool setupFaultHandler)
     where T : ITask
 {
     if (setupFaultHandler)
     {
         task.Task.ContinueWith(tt =>
         {
             logger.Error(tt.Exception.InnerException, String.Format("Exception on ui thread: {0} {1}", tt.Id, task.Name));
         },
                                cts.Token,
                                TaskContinuationOptions.OnlyOnFaulted, ConcurrentScheduler
                                );
     }
     return((T)task.Start(UIScheduler));
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates a RELEASE file
        /// </summary>
        /// <param name="releaseFiles">All the release data to put into the RELEASE file</param>
        /// <param name="fileLocation">Where the file should be located (Do not give a filename, we add that ourselves)</param>
        /// <returns>If we was able to create a RELEASE file</returns>
        public static async Task <bool> CreateReleaseFile(IEnumerable <ReleaseFile> releaseFiles, string fileLocation)
        {
            if (!Directory.Exists(fileLocation))
            {
                Logging.Error("Directory {0} doesn't exist, failing...", fileLocation);
                return(false);
            }

            fileLocation = Path.Combine(fileLocation, "RELEASE");
            var file        = new FileInfo(fileLocation);
            var oldReleases = Array.Empty <ReleaseFile>();

            if (file.Exists)
            {
                Logging.Warning("{0} already exists, grabbing all valid releases and recreating file", fileLocation);
                oldReleases = ReadReleaseFile(File.ReadLines(fileLocation)).ToArray();
                file.Delete();
            }

            using var textFileStream = file.CreateText();
            foreach (var releaseFile in releaseFiles.Concat(oldReleases))
            {
                await textFileStream.WriteLineAsync(releaseFile.ToString());
            }

            return(true);
        }
Ejemplo n.º 10
0
        public static Action WrapAction(Action action, ILogging logger = null)
        {
            if (!Settings.ParallelCatchErrors)
            {
                return(action);
            }
            string initTrace = "";

            if (Settings.ParallelTracing)
            {
                try
                {
                    throw new Exception();
                }
                catch (Exception e)
                {
                    initTrace = e.StackTrace;
                }
            }
            return(() =>
            {
                try
                {
                    action();
                }
                catch (Exception e)
                {
                    logger?.Error("Invoke error: {0}\nScheduled from: {1}", e, initTrace);
                }
            });
        }
Ejemplo n.º 11
0
        public void Notification(string[] to, string body)
        {
            MailConfiguration mailConfiguration = mailConfigurationLazy.Value;
            SmtpClient        _smtp             = new SmtpClient();

            _smtp.Host                  = mailConfiguration.Host;
            _smtp.Port                  = mailConfiguration.Port;
            _smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
            _smtp.EnableSsl             = mailConfiguration.EnableSsl;
            _smtp.UseDefaultCredentials = true;
            _smtp.Credentials           = new NetworkCredential(mailConfiguration.Account, mailConfiguration.Password);

            List <MailMessage> msgList = GetSendMessageList(mailConfiguration.Account, mailConfiguration.Name, to, "待办通知", body);

            foreach (var message in msgList)
            {
                try
                {
                    _smtp.Send(message);
                }
                catch (Exception ex)
                {
                    logging.Error(ex.ToString());
                }
            }
        }
Ejemplo n.º 12
0
        public async Task <IEnumerable <Account> > GetListOfAccountsAsync()
        {
            try
            {
                if (string.IsNullOrWhiteSpace(_serviceURI))
                {
                    return(DummyAccounts()); // In case user hasn't set the uri, return instrctions in the list
                }
                System.Net.WebClient client = new System.Net.WebClient();
                var response = await client.DownloadDataTaskAsync(_serviceURI);

                if (response != null)
                {
                    var content = Encoding.UTF8.GetString(response, 0, response.Length);
                    var Items   = JsonConvert.DeserializeObject <List <Account> >(content, _settings);
                    return(Items);
                }
            }
            catch (Exception ex)
            {
                _loggingService?.Error(ex);
                throw ex;
            }
            return(new List <Account>());
        }
Ejemplo n.º 13
0
        private async void PublishWireTransferOnTopic(PublishWireTransferOnTopicNotification notification,
                                                      CancellationToken cancellationToken)
        {
            using var producer = new ProducerBuilder <string, string>(GetProducerConfig()).Build();

            var messageId = Guid.NewGuid().ToString();
            await producer.ProduceAsync(
                _publishTopicSettings.TopicName,
                new Message <string, string>
            {
                Key   = messageId,
                Value = JsonConvert.SerializeObject(notification.WireTransfer,
                                                    new JsonApiSerializerSettings())
            }, cancellationToken).ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    _logging.Error(task.Exception);
                }

                if (task.IsCompletedSuccessfully)
                {
                    _logging.Information(task);
                }
            }, cancellationToken);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Downloads all updates from a <see cref="UpdateInfo"/> that are going to be applied
        /// </summary>
        /// <param name="updateInfo">Updates to download</param>
        /// <param name="progress">Progress of downloading updates</param>
        /// <returns>If we was able to download the updates</returns>
        public virtual async Task <bool> DownloadUpdate(UpdateInfo updateInfo, Action <double>?progress = null)
        {
            var updates = updateInfo.Updates.OrderBy(x => x.Version).ThenByDescending(x => x.IsDelta).ToArray();

            /*Go through every update we have, reporting the
             * progress by how many updates we have*/
            var totalBytesToDownload = updates.Select(x => x.Filesize).Sum();
            var totalBytesDownloaded = 0L;

            foreach (var updateEntry in updates)
            {
                /*Base path changes based on if the first update has been done*/
                if (!await DownloadUpdate(updateEntry,
                                          updateProgress =>
                {
                    progress?.Invoke(((updateEntry.Filesize * updateProgress) + totalBytesDownloaded) /
                                     totalBytesToDownload);
                }))
                {
                    Logger.Error("Downloading version {0} failed", updateEntry.Version);
                    return(false);
                }

                totalBytesDownloaded += updateEntry.Filesize;
            }

            return(true);
        }
Ejemplo n.º 15
0
        private NPath FindExecutableInPath(NPath executable, string searchPaths = null)
        {
            Guard.ArgumentNotNullOrWhiteSpace(executable, "executable");

            if (executable.IsRelative)
            {
                return(executable);
            }

            searchPaths = searchPaths ?? environment.GetEnvironmentVariable("PATH");
            var executablePath = searchPaths.Split(Path.PathSeparator)
                                 .Where(x => !String.IsNullOrEmpty(x))
                                 .Select(directory =>
            {
                try
                {
                    var unquoted = directory.RemoveSurroundingQuotes();
                    var expanded = environment.ExpandEnvironmentVariables(unquoted);
                    return(expanded.ToNPath().Combine(executable));
                }
                catch (Exception e)
                {
                    logger.Error("Error while looking for {0} in {1}\n{2}", executable, directory, e);
                    return(null);
                }
            })
                                 .Where(x => x != null)
                                 .FirstOrDefault(x => x.FileExists());

            return(executablePath);
        }
Ejemplo n.º 16
0
        private async Task ExecuteLoadAccountsCommand()
        {
            IsLoading = true;

            try
            {
                var accounts = await GetListOfAccounts();

                if (IsGrouped)
                {
                    CopyAccountResultsToGroupObservable(accounts);
                }
                else
                {
                    CopyAccountResultsToObservable(accounts);
                }
            }
            catch (Exception ex)
            {
                _loggingService?.Error(ex); //TODO:
            }
            finally
            {
                IsLoading = false;
            }
        }
Ejemplo n.º 17
0
        public void Send()
        {
            var msg = Encoding.ASCII.GetBytes(Message);

            try {
                var client = new UdpClient();
                client.Client.Bind(new IPEndPoint(LocalAddress, 0));
                client.Ttl = 10;
                client.Client.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 10);
                client.BeginSend(msg, msg.Length, EndPoint, result =>
                {
                    try {
                        client.EndSend(result);
                    }
                    catch (Exception ex) {
                        _logger.Debug(ex);
                    }
                    finally {
                        try {
                            client.Close();
                        }
                        catch (Exception) {
                        }
                    }
                }, null);
            }
            catch (Exception ex) {
                _logger.Error(ex);
            }
            ++SendCount;
        }
Ejemplo n.º 18
0
        public async Task <decimal> GetInterestRateAsync()
        {
            try
            {
                var response = await _interestRateApiQueryConfig.Host
                               .AppendPathSegment(_interestRateApiQueryConfig.Path)
                               .ConfigureRequest(setup =>
                {
                    setup.JsonSerializer = new NewtonsoftJsonSerializer(new JsonApiSerializerSettings());
                    setup.BeforeCall     = call =>
                    {
                        _logging.Information(new
                        {
                            details = "calling InterestRateApiQuery",
                            request = new { requestUri = call.Request.RequestUri, boby = call.Request.Content }
                        });
                    };
                })
                               .GetAsync()
                               .ReceiveJson <InterestRateResponse>() ?? new InterestRateResponse();

                return(response.InterestRate);
            }
            catch (Exception e)
            {
                _logging.Error(new
                {
                    details = "get interest rate", exception = new { inner = e.InnerException, message = e.Message }
                });

                throw;
            }
        }
Ejemplo n.º 19
0
        public bool Publish(string channel, object message)
        {
            if (message == null)
            {
                throw new PublishMessageNullException();
            }

            if (_rabbitChannel == null || _rabbitChannel.IsClosed)
            {
                initRabbit();
                _rabbitChannel.QueueDeclare(channel, true, false, false, null);
            }

            IBasicProperties props = createProperties();

            try
            {
                publishAsync(channel, message, props);
            }
            catch (Exception e)
            {
                _logging.Error(e);
            }

            return(true);
        }
Ejemplo n.º 20
0
        public static void Copy(NPath fromPath, NPath toPath)
        {
            try
            {
                CopyFolder(fromPath, toPath);
            }
            catch (Exception ex1)
            {
                Logger.Warning(ex1, "Error copying from " + fromPath + " to " + toPath + ". Attempting to copy contents.");

                try
                {
                    CopyFolderContents(fromPath, toPath);
                }
                catch (Exception ex2)
                {
                    Logger.Error(ex2, "Error copying from " + fromPath + " to " + toPath + ".");
                    throw;
                }
            }
            finally
            {
                fromPath.DeleteIfExists();
            }
        }
Ejemplo n.º 21
0
 private void BeforeInitializing()
 {
     if (!HasContextBinding())
     {
         _logger.Error("Warning, you initilaized the context without a context view when the context view extension was installed");
     }
 }
Ejemplo n.º 22
0
        public void Initialize(IRepositoryManager theRepositoryManager, ITaskManager theTaskManager)
        {
            Guard.ArgumentNotNull(theRepositoryManager, nameof(theRepositoryManager));
            Guard.ArgumentNotNull(theTaskManager, nameof(theTaskManager));

            this.taskManager       = theTaskManager;
            this.repositoryManager = theRepositoryManager;
            this.repositoryManager.CurrentBranchUpdated        += RepositoryManagerOnCurrentBranchUpdated;
            this.repositoryManager.GitStatusUpdated            += RepositoryManagerOnGitStatusUpdated;
            this.repositoryManager.GitAheadBehindStatusUpdated += RepositoryManagerOnGitAheadBehindStatusUpdated;
            this.repositoryManager.GitLogUpdated         += RepositoryManagerOnGitLogUpdated;
            this.repositoryManager.GitFileLogUpdated     += RepositoryManagerOnGitFileLogUpdated;
            this.repositoryManager.GitLocksUpdated       += RepositoryManagerOnGitLocksUpdated;
            this.repositoryManager.LocalBranchesUpdated  += RepositoryManagerOnLocalBranchesUpdated;
            this.repositoryManager.RemoteBranchesUpdated += RepositoryManagerOnRemoteBranchesUpdated;
            this.repositoryManager.DataNeedsRefreshing   += RefreshCache;
            try
            {
                this.taskManager.OnProgress += progressReporter.UpdateProgress;
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
Ejemplo n.º 23
0
        private void ReadCacheFromDisk()
        {
            logger.Trace("ReadCacheFromDisk Path:{0}", cachePath.ToString());

            ConnectionCacheItem[] connections = null;

            if (cachePath.FileExists())
            {
                var json = cachePath.ReadAllText();
                try
                {
                    connections = SimpleJson.DeserializeObject <ConnectionCacheItem[]>(json);
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "Error deserializing connection cache: {0}", cachePath);
                    cachePath.Delete();
                }
            }

            if (connections != null)
            {
                connectionCache =
                    connections.Select(item => new Connection {
                    Host = new UriString(item.Host), Username = item.Username
                })
                    .ToDictionary(connection => connection.Host);
            }
            else
            {
                connectionCache = new Dictionary <UriString, Connection>();
            }
        }
Ejemplo n.º 24
0
        /// <summary>Raises the exception event.</summary>
        /// <param name="actionExecutedContext">The context for the action.</param>
        public override void OnException(HttpActionExecutedContext actionExecutedContext)
        {
            Exception ex = actionExecutedContext.Exception;

            base.OnException(actionExecutedContext);

            Type type = ex.GetType();

            if (IsException(type))
            {
                var response = actionExecutedContext.Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message);
                throw new HttpResponseException(response);
            }

            if (ex.GetType() == typeof(AggregateException) && ((AggregateException)ex).InnerExceptions.All(x => IsException(x.GetType())) &&
                ((AggregateException)ex).InnerExceptions.All(x => x.GetType() == ((AggregateException)ex).InnerExceptions.First().GetType()))
            {
                var response = actionExecutedContext.Request.CreateErrorResponse(HttpStatusCode.BadRequest,
                                                                                 ((AggregateException)ex).InnerExceptions.First().Message);

                throw new HttpResponseException(response);
            }

            _logging.Error(ex, "Unhandled exception");
        }
Ejemplo n.º 25
0
        public static void Copy(SPath fromPath, SPath toPath)
        {
            Logger.Trace("Copying from {0} to {1}", fromPath, toPath);

            try
            {
                CopyFolder(fromPath, toPath);
            }
            catch (Exception ex1)
            {
                Logger.Warning(ex1, "Error copying.");

                try
                {
                    CopyFolderContents(fromPath, toPath);
                }
                catch (Exception ex2)
                {
                    Logger.Error(ex2, "Error copying contents.");
                    throw;
                }
            }
            finally
            {
                fromPath.DeleteIfExists();
            }
        }
Ejemplo n.º 26
0
        private void SetupResponse()
        {
            State = HttpStates.WRITEBEGIN;
            try {
                if (!owner.AuthorizeClient(this))
                {
                    throw new HttpStatusException(HttpCode.Denied);
                }
                if (string.IsNullOrEmpty(path))
                {
                    _logger.Error("Empty path");
                    throw new HttpStatusException(HttpCode.NotFound);
                }
                var handler = owner.FindHandler(path);
                if (handler == null)
                {
                    throw new HttpStatusException(HttpCode.NotFound);
                }
                response = handler.HandleRequest(this);
                if (response == null)
                {
                    throw new ArgumentException("Handler did not return a response");
                }
            }
            catch (HttpStatusException ex) {
#if DEBUG
                _logger.Warn(String.Format("{0} - Got a {2}: {1}", this, path, ex.Code), ex);
#else
                _logger.InfoFormat("{0} - Got a {2}: {1}", this, path, ex.Code);
#endif
                switch (ex.Code)
                {
                case HttpCode.NotFound:
                    response = Error404.HandleRequest(this);
                    break;

                case HttpCode.Denied:
                    response = Error403.HandleRequest(this);
                    break;

                case HttpCode.InternalError:
                    response = Error500.HandleRequest(this);
                    break;

                default:
                    response = new StaticHandler(new StringResponse(
                                                     ex.Code,
                                                     "text/plain",
                                                     ex.Message
                                                     )).HandleRequest(this);
                    break;
                }
            }
            catch (Exception ex) {
                _logger.Warn(String.Format("{0} - Failed to process response", this), ex);
                response = Error500.HandleRequest(this);
            }
            SendResponse();
        }
Ejemplo n.º 27
0
 public void extension_throws_for_ERROR()
 {
     Assert.Throws(typeof(VigilantException), new TestDelegate(() =>
     {
         logger.Error("");
     }
                                                               ));
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Downloads the release file and creates the <see cref="UpdateInfo"/>
        /// </summary>
        /// <param name="tagName">What the tag that contains the RELEASE file is</param>
        /// <param name="fileSize">How big the RELEASE file should be</param>
        /// <param name="downloadUrl">The URI with the the RELEASE file</param>
        /// <param name="grabDeltaUpdates">If we want to grab only delta updates from the RELEASE file (If false we only grab full update files)</param>
        protected async Task <UpdateInfo?> DownloadAndParseReleaseFile(string tagName, long fileSize, string downloadUrl, bool grabDeltaUpdates)
        {
            var releaseFileLocation = Path.Combine(ApplicationMetadata.TempFolder,
                                                   $"RELEASES-{ApplicationMetadata.ApplicationName}-{tagName}");
            var fileLength = await _githubClient.DownloadReleaseFile(releaseFileLocation, downloadUrl);

            //Just do a sanity check of the file size
            if (fileLength != fileSize)
            {
                Logger.Error("RELEASE file isn't the length as expected, deleting and returning null...");
                File.Delete(releaseFileLocation);
                return(null);
            }

            //Create the UpdateInfo
            return(ReleaseFileExt.GetUpdateInfo(releaseFileLocation, ApplicationMetadata, grabDeltaUpdates, tagName));
        }
Ejemplo n.º 29
0
        /// <inheritdoc cref="IDeltaUpdate.CreateDeltaFile"/>
        public bool CreateDeltaFile(
            TemporaryFolder tempFolder,
            string originalFileLocation,
            string newFileLocation,
            string deltaFileLocation,
            out Stream?deltaFileStream,
            Action <double>?progress = null)
        {
            deltaFileStream = null;
            if (OSHelper.ActiveOS != OSPlatform.Windows)
            {
                _logger.Error("We aren't on Windows so can't apply MSDiff update");
                return(false);
            }

            return(CreateDelta(FileTypeSet.ExecutablesLatest, GetCreateFlags(), CreateFlags.None, originalFileLocation,
                               newFileLocation, null, null, new DeltaInput(), IntPtr.Zero, HashAlgId.Crc32, deltaFileLocation));
        }
Ejemplo n.º 30
0
        static void RunWebServer(SPath path, int port)
        {
            if (!path.IsInitialized)
            {
                path = typeof(Program).Assembly.Location.ToSPath().Parent.Combine("files");
            }

            var server = new TestWebServer.HttpServer(path, port);
            var thread = new Thread(() =>
            {
                Logger.Error($"Press any key to exit");
                server.Start();
            });

            thread.Start();
            Console.Read();
            server.Stop();
        }