public void Update()
        {
            var parseErrorNotifications = (int?)System.Runtime.Caching.MemoryCache.Default["ParseErrorNotifications"] ?? 0;

            try
            {
                var serverAdminJsonCreator = new ServerAdminJsonCreator();
                var serverAdminJson        = serverAdminJsonCreator.Create();
                var contents         = Encoding.UTF8.GetBytes(serverAdminJson);
                var host             = ConfigurationManager.AppSettings["FtpHost"];
                var port             = Convert.ToInt32(ConfigurationManager.AppSettings["FtpPort"]);
                var username         = ConfigurationManager.AppSettings["TgUsername"];
                var password         = ConfigurationManager.AppSettings["TgPassword"];
                var path             = ConfigurationManager.AppSettings["ConfigDirFtpPath"];
                var sftpFileUploader = new SftpFileUploader();
                sftpFileUploader.Upload(contents, host, port, username, password, $"{path}/ServerAdmin.json");
                System.Runtime.Caching.MemoryCache.Default["ParseErrorNotifications"] = 0;
            }
            catch (Exception e)
            {
                if (parseErrorNotifications > 0 && parseErrorNotifications <= 3)
                {
                    _messagePusher.Push("tgns-admin", "Update Error", $"Message: {e.Message}");
                }
                System.Runtime.Caching.MemoryCache.Default["ParseErrorNotifications"] = parseErrorNotifications + 1;
            }
        }
Exemplo n.º 2
0
 public ActionResult Add(string subject, string body)
 {
     if (!(string.IsNullOrWhiteSpace(subject) || string.IsNullOrWhiteSpace(body)))
     {
         _feedbacksSetter.Set(PlayerId, subject, body);
         _messagePusher.Push("tgns-admin", "Feedback", "Feedback has been shared.");
         TempData["Success"] = "Feedback submitted successfully.";
     }
     else
     {
         TempData["Subject"] = subject;
         TempData["Body"]    = body;
         TempData["Error"]   = "Both Subject and Body are required.";
     }
     return(RedirectToAction("Index", "Feedback"));
 }
        public ActionResult Broadcast(string title, string message)
        {
            ActionResult result;

            if (string.IsNullOrWhiteSpace(title) || string.IsNullOrWhiteSpace(message))
            {
                ViewBag.Message = TempData["Message"] ?? "Specify title and message.";
                result          = View();
            }
            else
            {
                var pushSummary = _messagePusher.Push("tgns-broadcasts", title, message);
                _messagePushLogger.Log("ns2", PlayerId, _messagePusher.PlatformName, pushSummary.Input, pushSummary.Output, pushSummary.ResultCode, pushSummary.ResultDescription);
                _steamBotMessageSender.Send("ns2", PlayerId, "tgns-broadcasts", title, message, null, null);
                TempData["Message"] = $"Success. ({title} - {message})";
                result = RedirectToAction("Broadcast");
            }
            return(result);
        }
Exemplo n.º 4
0
        public double CheckPrice(string currency, double previousPrice, double minimum)
        {
            var data         = _apiData.GetData(currency);
            var bla          = data.Single(q => q.symbol == currency.ToUpperInvariant());
            var currentPrice = Math.Round(double.Parse(bla.price_eur), 2);
            var message      = $"The current {bla.name} value is {Euro} {currentPrice} ({bla.percent_change_1h}%)";

            Console.ForegroundColor = currentPrice >= previousPrice ? ConsoleColor.Green : ConsoleColor.Red;

            if (currentPrice <= minimum)
            {
                message = $"The {bla.name} price has dropped below the threshold of {minimum}! The current value is {Euro} {currentPrice} ({bla.percent_change_1h}%)";
                _messagePusher.Push(message);
            }

            Console.WriteLine(message);

            return(currentPrice);
        }
 public ActionResult Send(string channelId, string title, string message)
 {
     if (string.IsNullOrWhiteSpace(channelId) || string.IsNullOrWhiteSpace(title) || string.IsNullOrWhiteSpace(message))
     {
         TempData["error"] = "Channel, Title, and Message are required when sending notifications.";
         TempData["PushInputChannelId"] = channelId;
         TempData["PushInputTitle"]     = title;
         TempData["PushInputMessage"]   = message;
     }
     else
     {
         var pushSummary = _messagePusher.Push(channelId, title, message);
         _messagePushLogger.Log("ns2", PlayerId, _messagePusher.PlatformName, pushSummary.Input, pushSummary.Output, pushSummary.ResultCode, pushSummary.ResultDescription);
         if (_messagePusher.WasSuccessful(pushSummary))
         {
             TempData["success"] = "Push successful.";
         }
         else
         {
             TempData["error"] = "Push failed. See log below for details.";
         }
     }
     return(RedirectToAction("Index", "Pushes"));
 }
Exemplo n.º 6
0
 public IDictionary<string, dynamic> Push(string channelId, string title, string message)
 {
     var pushResponse = _messagePusher.Push(channelId, title, message);
     var result = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(pushResponse.Output);
     return result;
 }
Exemplo n.º 7
0
 public CryptoCurrencyException(IMessagePusher messagePusher, string message)
     : base(message)
 {
     messagePusher.Push(message);
 }
Exemplo n.º 8
0
 public CryptoCurrencyException(IMessagePusher messagePusher, Exception inner)
     : base(inner.Message, inner)
 {
     messagePusher.Push(inner.Message);
 }