示例#1
0
        private async Task <SLChatPostMessageResult> PostDefect(string groupId, ALMDefect defect)
        {
            StringBuilder sb = new StringBuilder("");

            sb.Append(cDefectStartLine);
            sb.Append("");
            sb.Append(defect.id.Replace("&", "'"));
            sb.Append(cDefectFieldsSeparator);
            sb.Append("Status: ");
            sb.Append(defect.status.Replace("&", "'"));
            sb.Append(cDefectFieldsSeparator);
            sb.Append("Severity: ");
            sb.Append(defect.priority.Replace("&", "'"));
            sb.Append(cDefectFieldsSeparator);
            sb.Append("Devlead: ");
            sb.Append(defect.owner_dev.Replace("&", "'"));
            sb.Append(cDefectFieldsSeparator);
            sb.Append("Qalead: ");
            sb.Append(defect.user_40_qalead.Replace("&", "'"));
            sb.Append("\n");
            sb.Append(defect.name.Replace("&", "'"));
            sb.Append("\n");
            sb.Append("```");
            return(await slWebApiClient.ChatPostMessageAsync(groupId, sb.ToString(), true));
        }
示例#2
0
        private async Task <SLChatPostMessageResult> PostCommit(IMAPMessage imapMsg, string channelID)
        {
            StringBuilder sb = new StringBuilder("");

            sb.Append(cCommitStartLine);
            sb.Append(imapMsg.Uid);
            sb.Append(cCommitFieldsSeparator);
            sb.Append(cCommitFromName);
            sb.Append(imapMsg.From[0].Address);
            sb.Append(cCommitFieldsSeparator);
            sb.Append(cCommitSubjectName);
            sb.Append(imapMsg.Subject);
            sb.Append(cCommitEndLIne);

            StringBuilder attachments = new StringBuilder();

            attachments.Append("[{");
            attachments.Append("\"text\":");
            string commitBody = "```" + SLNormalizer.EscapeJSONString(GetCommitBody(imapMsg)) + "```";

            attachments.Append("\"");
            attachments.Append(commitBody);
            attachments.Append("\",");
            attachments.Append("\"mrkdwn_in\": [\"text\"]");
            attachments.Append("}]");

            return(await slWebApiClient.ChatPostMessageAsync(channelID, sb.ToString(), true, false, attachments.ToString()));
        }
示例#3
0
        private async Task <SLChatPostMessageResult> PostBuild(IMAPMessage message, string groupID)
        {
            StringBuilder sb = new StringBuilder("");

            sb.Append(cBuildStartLine);
            sb.Append(" ");
            sb.Append(message.Uid);
            sb.Append("    ");
            sb.Append(message.Subject);
            sb.AppendLine();
            sb.Append(FindLoadRunnerBuildUrl(message));
            sb.Append("```");
            return(await slWebApiClient.ChatPostMessageAsync(groupID, sb.ToString(), true, true));
        }
        private async Task <SLChatPostMessageResult> PostCommitComment(IMAPMessage imapMsg, string channelID)
        {
            StringBuilder sb = new StringBuilder("");

            sb.Append(cCommitStartLine);
            //sb.Append(imapMsg.Uid);
            //sb.Append(cCommitFieldsSeparator);
            sb.Append(cCommitFromName);
            sb.Append(imapMsg.From[0]);
            sb.Append(cCommitFieldsSeparator);
            sb.Append(cCommitSubjectName);
            sb.Append(imapMsg.Subject);
            sb.Append(cCommitEndLIne);
            return(await slWebApiClient.ChatPostMessageAsync(channelID, sb.ToString(), true, false));
        }
 private async void HandleNoteCommand(string[] parameters, SLRuntimeEventArgs e)
 {
     if (parameters.Length >= 2)
     {
         string   option   = parameters[1];
         DBWorker dbWorker = new DBWorker(cDatabaseFolderPath + e.user + ".sqlite");
         dbWorker.Open();
         if (option.Equals("-l"))
         {
             List <DBNotesEntry> dbNotesEntriesList = dbWorker.SelectNotes();
             if (dbNotesEntriesList.Count > 0)
             {
                 foreach (DBNotesEntry dbNoteEntry in dbNotesEntriesList)
                 {
                     StringBuilder message = new StringBuilder("");
                     message.Append("Id: ");
                     message.Append(dbNoteEntry.id);
                     message.Append("\n");
                     message.Append("Note: ");
                     //string normalized = SLNormalizer.Normalize(dbNoteEntry.note);
                     //message.Append(normalized);
                     message.Append(dbNoteEntry.note);
                     message.Append("\n");
                     await slWebApiClient.ChatPostMessageAsync(e.channel, slWebApiClient.WrapWithConsoles(message.ToString()), true, true);
                 }
             }
             else
             {
                 string message = "There is 0 notes found in database";
                 await slWebApiClient.ChatPostMessageAsync(e.channel, slWebApiClient.WrapWithConsoles(message), true);
             }
         }
         else if (option.Equals("-d"))
         {
             if (parameters.Length >= 3)
             {
                 string id = parameters[2];
                 if (dbWorker.DeleteNote(id) > 0)
                 {
                     string message = "Note " + id + " was deleted";
                     await slWebApiClient.ChatPostMessageAsync(e.channel, slWebApiClient.WrapWithConsoles(message.ToString()), true);
                 }
                 else
                 {
                     string message = "Note was not deleted or there is no note to delete";
                     await slWebApiClient.ChatPostMessageAsync(e.channel, slWebApiClient.WrapWithConsoles(message), true);
                 }
             }
         }
         else if (option.Equals("-da"))
         {
             int deletedNotesCount = dbWorker.DeleteAllNotes();
             if (deletedNotesCount > 0)
             {
                 string message = deletedNotesCount + " notes was deleted";
                 await slWebApiClient.ChatPostMessageAsync(e.channel, slWebApiClient.WrapWithConsoles(message.ToString()), true);
             }
             else
             {
                 string message = "Notes was not deleted or there is no notes to delete";
                 await slWebApiClient.ChatPostMessageAsync(e.channel, slWebApiClient.WrapWithConsoles(message), true);
             }
         }
         else
         {
             string note = e.text.Substring((cNoteCommand + " ").Length);
             if ((dbWorker.InsertNote(SLNormalizer.Denormalize(note))) > 0)
             {
                 string message = "Note was added";
                 await slWebApiClient.ChatPostMessageAsync(e.channel, slWebApiClient.WrapWithConsoles(message.ToString()), true);
             }
             else
             {
                 string message = "For some reason note was not inserted";
                 await slWebApiClient.ChatPostMessageAsync(e.channel, slWebApiClient.WrapWithConsoles(message), true);
             }
         }
         dbWorker.Close();
     }
 }