//Post a message using simple strings
 public void PostMessage(string v_Message, string v_Username = null, string v_Channel = null)
 {
     MessagePayload payload = new MessagePayload()
     {
         Channel = v_Channel,
         Username = v_Username,
         Text = v_Message
     };
     PostMessage(payload);
 }
Пример #2
0
        //Post a message using simple strings
        public void PostMessage(string v_Message, string v_Username = null, string v_Channel = null)
        {
            MessagePayload payload = new MessagePayload()
            {
                Channel  = v_Channel,
                Username = v_Username,
                Text     = v_Message
            };

            PostMessage(payload);
        }
 //Post a message using a Payload object
 public void PostMessage(MessagePayload v_Payload)
 {
     string l_PayloadJson = JsonConvert.SerializeObject(v_Payload);
     using (WebClient l_Client = new WebClient())
     {
         NameValueCollection l_Data = new NameValueCollection();
         l_Data["payload"] = l_PayloadJson;
         var l_Response = l_Client.UploadValues(m_Uri, "POST", l_Data);
         //The response text is usually "ok"
         string l_ResponseText = m_Encoding.GetString(l_Response);
     }
 }
Пример #4
0
        //Post a message using a Payload object
        public void PostMessage(MessagePayload v_Payload)
        {
            string l_PayloadJson = JsonConvert.SerializeObject(v_Payload);

            using (WebClient l_Client = new WebClient())
            {
                NameValueCollection l_Data = new NameValueCollection();
                l_Data["payload"] = l_PayloadJson;
                var l_Response = l_Client.UploadValues(m_Uri, "POST", l_Data);
                //The response text is usually "ok"
                string l_ResponseText = m_Encoding.GetString(l_Response);
            }
        }
Пример #5
0
        public static void SendToRoom(MessagePayload payload, string roomname, string token, string username = "******")
        {
            try
            {
                payload.Channel = string.Concat("#", roomname);
                payload.Username = username;

                SlackClient client = new SlackClient(token);
                client.PostMessage(payload);
            }
            catch (Exception ex)
            {
            }
        }
        public ActionResult TestSlack()
        {
            //RecruitmentController.SendMessage("Slack Test From Website");
            MessagePayload message = new MessagePayload();
            message.Attachments = new List<MessagePayloadAttachment>();

            message.Attachments.Add(new MessagePayloadAttachment()
            {
                Text = "Testing",
                TitleLink = string.Format(Properties.Settings.Default.EveWhoPilotURL, User.Identity.Name.Replace(" ", "+")),
                Title = "Check this out!",
                ThumbUrl = string.Format(Properties.Settings.Default.CharacterImageServerURL, "pilot", Api.GetCharacterID(User.Identity.Name))
            });
            RecruitmentController.SendMessage(message);

            return RedirectToAction("ViewUsers");
        }
 private static void SendPM(MessagePayload message)
 {
     if (Properties.Settings.Default.Plugin.ToUpper() == "HIPCHAT")
     {
         //Hipchat.SendPM(message, Properties.Settings.Default.HipchatToken, "Clyde en Marland");
     }
     else if (Properties.Settings.Default.Plugin.ToUpper() == "SLACK")
     {
         Slack.SendPM(message, "ClydeenMarland", Properties.Settings.Default.SlackWebhook);
     }
 }
 private static void SendMessage(MessagePayload message, string room)
 {
     if (Properties.Settings.Default.Plugin.ToUpper() == "HIPCHAT")
     {
         //Hipchat.SendToRoom(message, Properties.Settings.Default.RoomName, Properties.Settings.Default.HipchatToken);
     }
     else if (Properties.Settings.Default.Plugin.ToUpper() == "SLACK")
     {
         //message = Linkify(message);
         Slack.SendToRoom(message, room, Properties.Settings.Default.SlackWebhook);
     }
 }
        private static MessagePayload HyperFormatKillMessage(Announcement ann)
        {
            MessagePayload message = new MessagePayload();
            message.Attachments = new List<MessagePayloadAttachment>();
            string colour;
            if(ann.Category.ToLower() == "wardec info")
            {
                message.Text = "CODE SANGUINE";
                colour = "#850505";
            }
            else
            {
                message.Text = "CODE PINK";
                colour = "#FF3399";
            }

            message.Attachments.Add(new MessagePayloadAttachment()
            {
                Text = ann.Post,
                TitleLink = string.Format("http://forums.r3mus.org/chat/{0}", ann.Topic.ToLower().Replace(" ", "-")),
                Title = ann.Topic,
                ThumbUrl = "http://www.r3mus.org/Images/logo.png",
                AuthorName = ann.UserName,
                AuthorIcon = string.Format("http://image.eveonline.com/Character/{0}_32.jpg", JKON.EveWho.Api.GetCharacterID(ann.UserName)),
                Colour = colour
            });

            return message;
        }
 public static void SendMessage(MessagePayload message)
 {
     if (Properties.Settings.Default.Plugin.ToUpper() == "SLACK")
     {
         Slack.SendToRoom(message, Properties.Settings.Default.RecruitmentRoomName, Properties.Settings.Default.SlackWebhook);
     }
 }
        public ActionResult SubmitNewReviewItem(ApplicationReviewViewModel model)
        {            
            UserManager<ApplicationUser> UserManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(db));

            if(ModelState.IsValid)
            {
                model.NewReviewItem.Reviewer = UserManager.FindByName(model.NewReviewItem.Reviewer.UserName);
                model.Applicant = db.Applicants.Where(a => a.Id == model.NewReviewItem.ApplicantId).FirstOrDefault();
                model.NewReviewItem.Status = model.NewReviewItemStatus.GetDisplayName();
                
                model.NewReviewItem.DateTimeCreated = DateTime.Now;
                
                db.Applications.Add(model.NewReviewItem);
                db.SaveChanges();
                
                MessagePayload message = new MessagePayload();
                message.Attachments = new List<MessagePayloadAttachment>();

                message.Attachments.Add(new MessagePayloadAttachment()
                {
                    Text = string.Format(Properties.Settings.Default.AppUpdate_MessageFormatLine2, model.Applicant.Name, model.NewReviewItem.Status, model.NewReviewItem.Reviewer.UserName, model.NewReviewItem.DateTimeCreated.ToString("yyyy-MM-dd HH:mm:ss")),
                    TitleLink = string.Format(Properties.Settings.Default.EveWhoPilotURL, model.Applicant.Name.Replace(" ", "+")),
                    Title = Properties.Settings.Default.AppUpdate_MessageFormatLine1,
                    ThumbUrl = string.Format(Properties.Settings.Default.CharacterImageServerURL, Api.GetCharacterID(model.Applicant.Name), 64.ToString()),
                    Colour = "#FFC200"
                });
                RecruitmentController.SendMessage(message);

                if (model.NewReviewItemStatus == ApplicationReviewViewModel.ApplicationStatus.InScreening)
                {
                    return RedirectToAction("ReviewApplication", new { id = model.NewReviewItem.ApplicantId });
                }
                else
                {
                    return RedirectToAction("ShowApplications");
                }
            }
            return View(model);
        }
        public ActionResult SubmitApplication(ApplicantViewModel model)
        {
            var applicant = new Applicant() { Name = model.UserName, EmailAddress = model.Email, TimeZone = model.TimeZone, Information = model.Information, Age = model.Age, ToonAge = model.ToonAge, Source = model.Source };
            
            ApiInfo api = new ApiInfo() { ApiKey = Convert.ToInt32(model.ApiKey), VerificationCode = model.VerificationCode };
            bool goodAccessMask = api.ValidateAccessMask(ApplicationUser.IDType.Corporation);
            bool goodTZ = (model.TimeZone != "Select a Time Zone");

            if (goodAccessMask && goodTZ)
            {
                applicant.ApiKey = Convert.ToInt32(model.ApiKey);
                applicant.VerificationCode = model.VerificationCode;

                db.Applicants.Add(applicant);
                db.SaveChanges();

                //applicant = db.Applicants.Where(m => m.Name == applicant.Name).Last();
                var application = new Application() { ApplicantId = applicant.Id, Notes = "New application", Status = ApplicationReviewViewModel.ApplicationStatus.Applied.ToString(), DateTimeCreated = DateTime.Now };
                db.Applications.Add(application);
                db.SaveChanges();

                //SendMessage(string.Format(Properties.Settings.Default.NewApp_MessageFormatLine1, applicant.Name, application.DateTimeCreated.ToString("yyyy-MM-dd HH:mm:ss")));

                MessagePayload message = new MessagePayload();
                message.Attachments = new List<MessagePayloadAttachment>();

                message.Attachments.Add(new MessagePayloadAttachment()
                {
                    Text = string.Format(Properties.Settings.Default.NewApp_MessageFormatLine2, applicant.Name, application.DateTimeCreated.ToString("yyyy-MM-dd HH:mm:ss")),
                    TitleLink = string.Format(Properties.Settings.Default.EveWhoPilotURL, applicant.Name.Replace(" ", "+")),
                    Title = Properties.Settings.Default.NewApp_MessageFormatLine1,
                    ThumbUrl = string.Format(Properties.Settings.Default.CharacterImageServerURL, Api.GetCharacterID(applicant.Name), 64.ToString()),
                    Colour = "#FFC200"
                });
                RecruitmentController.SendMessage(message);

                TempData.Clear();
                TempData.Add("Message", "Thank you for your application. A recruiter will contact you shortly.");

                return RedirectToAction("Index", "Home");
            }

            if (!goodAccessMask)
            {
                ViewBag.Message = string.Format("The access mask for the API key you have submitted is not correct ({0}, should be {1}). Please correct this and try again.", api.AccessMask, Properties.Settings.Default.FullAPIAccessMask);
            }
            else if(!goodTZ)
            {
                ViewBag.Message = "Please select a valid Time Zone.";
            }
            return View(model);
        }