예제 #1
0
        public static async Task IntegrateWithSlackAsync(string message, bool success)
        {
            string message_to_send = "";

            if (message == "end")
            {
                if (success)
                {
                    message_to_send = "Algolia Data Sync Completed Successfully at " + DateTime.Now;
                }
                else
                {
                    message_to_send = "Algolia Data Sync Failed at " + DateTime.Now;
                }
            }
            else
            {
                message_to_send = "Algolia Sync Started at " + DateTime.Now;
            }
            var webhookUrl  = new Uri("https://hooks.slack.com/services/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");
            var slackClient = new SlackClient(webhookUrl);
            var response    = await slackClient.SendMessageAsync(message_to_send);

            var isValid = response.IsSuccessStatusCode ? "valid" : "invalid";
        }
    public static async Task IntegrateWithSlackAsync(string message = "")
    {
        var webhookUrl  = new Uri("https://hooks.slack.com/services/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"); // This is unique for RumbleOn clsautomation-status channel
        var slackClient = new SlackClient(webhookUrl);
        var response    = await slackClient.SendMessageAsync(message);

        var isValid = response.IsSuccessStatusCode ? "valid" : "invalid";

        Console.WriteLine($"Received {isValid} response.");
    }
예제 #3
0
        private static async Task ReportToSlack(SlackConfiguration config, ILogger logger, IEnumerable <ValidationReport> reports)
        {
            var slackClient = new SlackClient(config);

            using var response = await slackClient.SendMessageAsync(reports);

            var isValid = response.IsSuccessStatusCode ? "valid" : "invalid";

            logger.LogInformation("Received {isValid} response.", isValid);
        }
        public async Task FunctionHandler(SNSEvent snsEvent, ILambdaContext context)
        {
            var log = context.Logger;

            foreach (var record in snsEvent.Records)
            {
                var snsRecord = record.Sns;

                var response = await _slackClient.SendMessageAsync(snsRecord.Message);

                if (!response.IsSuccessStatusCode)
                {
                    log.LogLine($"ERROR [{record.EventSource} {snsRecord.Timestamp}] " +
                                $"SnsMessage = {snsRecord.Message} " +
                                $"HttpStatusCode = {response.StatusCode} " +
                                $"HttpResponse = {response.Content.ReadAsStringAsync().Result}");
                }
            }
        }
예제 #5
0
        public void LogCompanySearch(string companyName)
        {
            TCompanies companyRecord = null;

            if (companyName != null && companyName != "")
            {
                companyRecord = _clashdbContext.TCompanies.Where(record => record.CompanyName == companyName).FirstOrDefault();
            }

            if (companyRecord != null)
            {
                /* ------------ [Dec 8th 2017]
                 *  Choosing to leave this simple for the MVP, but this will underestimate searches duing high traffic loads because it is not thread safe.
                 *  We can rely on Google Analytics data for a sanity check on the level of underestimation.  Diff of >5% is probably worth fixing.
                 *  Consider moving to a worker queue if we decide to add more user behavior tracking or need to guarantee thread safefy.*/
                companyRecord.TimesSearched++;
                //------------

                _clashdbContext.SaveChanges();
            }
            else
            {
                try
                {
                    string webhookString = Environment.GetEnvironmentVariable("SPARTANCLASH_SLACKWEBHOOKURL");
                    var    webhookUrl    = new Uri(webhookString);

                    var slackClient = new SlackClient(webhookUrl);


                    slackClient.SendMessageAsync("Failed search for '" + companyName + "'").Wait();
                }
                catch (Exception e)
                {
                    //TODO: What kind of errors do we experience?
                    //So far...
                    //  -> Bad environment variable formatting
                    //  -> No response from slack channel
                }
            }
        }