public void Notify(FileInfo fileInfo)
        {
            var content = new StreamContent(new StreamReader(fileInfo.FullName).BaseStream);

            try
            {
                var response = client.PostAsync("http://upload.stormlogs.com/upload.php", content).Result;

                var message = response.Content.ReadAsStringAsync().Result;

                ReplayPublisher.Log.Information("Target: {0}\nFile: {1}\nResponse: {2}\nResponse content: {3}",
                                                this.Name,
                                                fileInfo.FullName,
                                                response.StatusCode,
                                                message);

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    TargetState.Update(Name, fileInfo.CreationTimeUtc);
                }
            }
            finally
            {
                content.Dispose();
            }
        }
예제 #2
0
        /// <summary>
        /// Uploads the replay file to a S3 bucket and notifies the HotsLogs website.
        /// </summary>
        /// <param name="fileInfo"></param>
        public void Notify(FileInfo fileInfo)
        {
            var request = new PutObjectRequest()
            {
                BucketName = "heroesreplays",
                Key        = Guid.NewGuid().ToString("D") + ".StormReplay",
                FilePath   = fileInfo.FullName,
            };

            var response = client.PutObject(request);

            if (response.HttpStatusCode == HttpStatusCode.OK)
            {
                NotifyHotsLogs(request.Key)
                .ContinueWith(success =>
                {
                    if (success.Result)
                    {
                        TargetState.Update(Name, fileInfo.CreationTimeUtc);
                    }
                });
            }
            else
            {
                ReplayPublisher.Log.Warning("File {filePath} was no succesfully uploaded to the HotsLogs S3 bucket.\nReturned statuscode: {statusCode}", fileInfo.FullName, response.HttpStatusCode);
            }
        }
예제 #3
0
        public void Notify(FileInfo fileInfo)
        {
            if (!available)
            {
                return;
            }

            var message = String.Format("File: {0}", fileInfo.FullName);

            EventLog.WriteEntry(sourceName, message, EventLogEntryType.Information, 1);

            TargetState.Update(Name, fileInfo.CreationTimeUtc);
        }
예제 #4
0
        public void Notify(FileInfo fileInfo)
        {
            Console.WriteLine("[{0}] {1}", DateTime.Now.ToString("HH:mm:ss"), fileInfo.Name);

            TargetState.Update(Name, fileInfo.CreationTimeUtc);
        }