Beispiel #1
0
        public void addComment(string issueKey, string commentString)
        {
            RemoteComment comment = new RemoteComment();

            comment.body = commentString;
            checkCredentials();
            jira.addComment(credentials, issueKey, comment);
        }
        public void AddComment(string issueKey, string comment)
        {
            var remoteComment = new RemoteComment {
                body = comment
            };

            soapService.addComment(loginToken, issueKey, remoteComment);
        }
Beispiel #3
0
        public override void AddComment(JiraContext context, string issueId, string commentText)
        {
            var comment = new RemoteComment {
                body = commentText
            };

            this.Service.addComment(this.Token, issueId, comment);
        }
        /// <summary>
        /// Adds a comment to an Issue
        /// </summary>
        /// <param name="comment">The <c>RemoteComment</c> to add to the issue</param>
        /// <param name="issueKey">The key of the issue to which the comment will be added</param>
        public void AddCommentToIssue(string issueKey, IssueComment comment)
        {
            RemoteComment rc = new RemoteComment();

            rc.body          = comment.Text;
            rc.timePerformed = comment.Date;
            rc.username      = comment.Author;
            JiraSoapHelper.GetJiraSoapServiceProxy().addComment(this.AuthenticationToken, issueKey, rc);
        }
Beispiel #5
0
 /// <summary>The CreationDate of the comment, converted to Local Time.</summary>
 /// <param name="comment">The comment.</param>
 /// <returns>Nullable DateTime</returns>
 public static DateTime?getDisplayDate(this RemoteComment comment)
 {
     if (comment.CreationDate.HasValue)
     {
         return(comment.CreationDate.Value.ToLocalTime());
     }
     else
     {
         return(null);
     }
 }
Beispiel #6
0
        internal void AddComment(JiraIssue issue, string comment)
        {
            if (String.IsNullOrEmpty(comment))
            {
                return;
            }

            RemoteComment rc = new RemoteComment();

            rc.author  = CurrentUser.Id;
            rc.body    = comment;
            rc.created = DateTime.Now;

            _service.addComment(_token, issue.DisplayId, rc);
        }
Beispiel #7
0
        public void LogCommentConversion(XDoc spaceManifest, string space, RemoteComment comment, string mtPath)
        {
            string xpath      = string.Format("comment[@c.commentid='{0}']", comment.id);
            XDoc   commentXml = spaceManifest[xpath];

            if (commentXml.IsEmpty)
            {
                spaceManifest.Start("comment");
                spaceManifest.Attr("c.space", space);
                spaceManifest.Attr("c.commentid", comment.id);
                spaceManifest.Attr("c.pageid", comment.pageId);
                spaceManifest.Attr("c.path", Utils.GetUrlLocalUri(_confBaseUrl, comment.url, true, false));
                spaceManifest.Attr("mt.path", mtPath);
                spaceManifest.End();
            }
        }
Beispiel #8
0
        public RemoteComment AddCommentToPage(long pageId, string commentTitle, string commentContent)
        {
            RemoteComment comment = null;

            this.ExecuteLoggedIn(
                (confluence, token) =>
            {
                var remoteComment = new RemoteComment {
                    pageId = pageId, creator = this.UserName, title = commentTitle, content = commentContent,
                };
                var addedComment = confluence.addComment(token, remoteComment);
                comment          = addedComment;
            });

            return(comment);
        }
Beispiel #9
0
        private void jiraUploadBySoapWithToken()
        {
            try {
                JiraSoapServiceService service = new JiraSoapServiceService {
                    Url = serverUrl + "/rpc/soap/jirasoapservice-v2"
                };

                string[] fileNames = new[] { name };
                byte[]   bytes     = File.ReadAllBytes(path);

                service.addBase64EncodedAttachmentsToIssue(token, issueKey, fileNames, new[] { Convert.ToBase64String(bytes) });
                if (!string.IsNullOrEmpty(comment) && comment.Trim().Length > 0)
                {
                    RemoteComment c = new RemoteComment {
                        body = comment
                    };
                    service.addComment(token, issueKey, c);
                }

                Invoke(new MethodInvoker(delegate
                {
                    uploadLog.Text += "Done. See " + serverUrl + "/browse/" + issueKey + "\r\n";
                }));
            } catch (Exception e) {
                Debug.Write(e.StackTrace);
                Invoke(new MethodInvoker(delegate
                {
                    uploadLog.Text += "Failed: " + e.Message + "\r\n";
                }));
            }

            done = true;

            Invoke(new MethodInvoker(delegate
            {
                saveLastUsed();
                buttonCancel.Enabled = true;
                buttonCancel.Text    = "Close";
            }));
        }
        public async Task <IStandardComment> CreateCommentAsync(IStandardComment comment)
        {
            var jiraIssue = await _resourceClient.RestClient.Issues.GetIssueAsync(comment.Identifiers[InstanceKeyNames.JIRA_ISSUE].Id);


            var jiraComment = await _commentMapper.ToNewSpecialComment(comment);

            //Hack to get the right user to post comment, because JIRA doesnt allow custom author out-of-the-box.
            //Using extension "Extender for JIRA"
            RemoteComment remoteComment = new RemoteComment()
            {
                author     = jiraComment.Author,
                body       = jiraComment.Body,
                roleLevel  = jiraComment.RoleLevel,
                groupLevel = jiraComment.GroupLevel
            };

            var resource = String.Format("rest/api/2/issue/{0}/comment", jiraIssue.Key);

            var request = new RestRequest(resource, Method.POST);

            request.AddHeader("contextUser", comment.Author.UserMap[_configSettings.UserColumnName]);
            request.RequestFormat  = DataFormat.Json;
            request.JsonSerializer = new RestSharpJsonSerializer(JsonSerializer.Create(_resourceClient.RestClient.RestClient.Settings.JsonSerializerSettings));
            request.AddJsonBody(remoteComment);

            var response = await _resourceClient.RestClient.RestClient.RestSharpClient.ExecuteTaskAsync(request);

            // End hack

            //var createdComment = await jiraIssue.AddCommentAsync(jiraComment);



            return(comment);
        }
 /// <remarks/>
 public void editCommentAsync(string in0, RemoteComment in1) {
     this.editCommentAsync(in0, in1, null);
 }
 public RemoteComment editComment(string in0, RemoteComment in1) {
     object[] results = this.Invoke("editComment", new object[] {
                 in0,
                 in1});
     return ((RemoteComment)(results[0]));
 }
 /// <remarks/>
 public void hasPermissionToEditCommentAsync(string in0, RemoteComment in1) {
     this.hasPermissionToEditCommentAsync(in0, in1, null);
 }
 public bool hasPermissionToEditComment(string in0, RemoteComment in1) {
     object[] results = this.Invoke("hasPermissionToEditComment", new object[] {
                 in0,
                 in1});
     return ((bool)(results[0]));
 }
 /// <remarks/>
 public void addCommentAsync(string in0, string in1, RemoteComment in2) {
     this.addCommentAsync(in0, in1, in2, null);
 }
 public void addComment(string in0, string in1, RemoteComment in2) {
     this.Invoke("addComment", new object[] {
                 in0,
                 in1,
                 in2});
 }
Beispiel #17
0
 public RemoteComment EditComment(string in0, RemoteComment in1)
 {
     throw new NotImplementedException();
 }
Beispiel #18
0
 public void AddComment(string token, string key, RemoteComment comment)
 {
     var resource    = String.Format("rest/api/2/issue/{0}/comment", key);
     var responseObj = this.ExecuteRequest(Method.POST, resource, comment);
 }
 /// <remarks/>
 public System.IAsyncResult BegineditComment(string in0, RemoteComment in1, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("editComment", new object[] {
                 in0,
                 in1}, callback, asyncState);
 }
Beispiel #20
0
 public bool HasPermissionToEditComment(string in0, RemoteComment in1)
 {
     return(_client.hasPermissionToEditComment(in0, in1));
 }
Beispiel #21
0
 public void AddComment(string token, string key, RemoteComment comment)
 {
     _client.addComment(token, key, comment);
 }
        private void processSpiraAccount(Pop3Client clientPOP3, AccountDetails account, ApplicationSystem appServer)
        {
            const string METHOD = CLASS + "processSpiraAccount()";

            this._eventLog.EntryLog(METHOD);

            //Create the application client and connect to our project and get users..
            SoapServiceClient clientAppl = (SoapServiceClient)this.CreateApplicationClient(appServer, account);

            //Get users in the project..
            List <RemoteProjectUser> spiraUsers = clientAppl.Project_RetrieveUserMembership();

            //Get the known message IDs..
            List <string> seenUIDs = this.readMessageIDsForAccount(account.AccountID.Value);

            //Get new emails from the client.
            List <Message> newMsgs = this.popGetNewMessages(clientPOP3, account, seenUIDs);

            //Get all projects..
            List <RemoteProject> spiraProjs = clientAppl.Project_Retrieve();

            //Loop through each email.
            foreach (Message msg in newMsgs)
            {
                this._eventLog.WriteTrace(METHOD, "Starting on message " + msg.MessageLogID + "...");

                //Make sure we have a from address, otherwise skip (Delivery Returned messages have no FROM address)
                //First see if the message should be skipped. (Keywords, Headers, or Email Addresses)
                if (msg.Headers != null &&
                    msg.Headers.From != null &&
                    !String.IsNullOrWhiteSpace(msg.Headers.From.Address) &&
                    msg.Headers.From.Address.ToLowerInvariant().Trim() != account.AccountEmail.ToLowerInvariant().Trim())
                {
                    string filterMsg;
                    if (this.doesMessageClearFilters(msg, out filterMsg))
                    {
                        //First see if there's a header we can get the artifact ID from..
                        ArtifactTypeEnum artType = ArtifactTypeEnum.None;
                        int artId = -1;
                        if (msg.Headers.UnknownHeaders[Common.MESSAGEHEADER_SPIRA_ARTIFACT] != null && rgxArtifactToken.IsMatch(msg.Headers.UnknownHeaders[Common.MESSAGEHEADER_SPIRA_ARTIFACT]))
                        {
                            //Get the art type and the id..
                            Match matches = rgxArtifactToken.Match(msg.Headers.UnknownHeaders[Common.MESSAGEHEADER_SPIRA_ARTIFACT]);
                            this.retrieveArtTypeAndId(matches.Groups["type"].Value, matches.Groups["id"].Value, out artType, out artId);
                        }

                        if (artId == -1 || artType == ArtifactTypeEnum.None)
                        {
                            if (rgxArtifactToken.IsMatch(msg.Headers.Subject))
                            {
                                //Get the art type and the id..
                                Match matches = rgxArtifactToken.Match(msg.Headers.Subject);
                                this.retrieveArtTypeAndId(matches.Groups["type"].Value, matches.Groups["id"].Value, out artType, out artId);
                            }
                        }

                        //Change projects, if necessary, and if we're able to..
                        try
                        {
                            int projNum = clientAppl.System_GetProjectIdForArtifact((int)artType, artId);
                            if (projNum != 0)
                            {
                                bool succNewProject = clientAppl.Connection_ConnectToProject(projNum);

                                if (!succNewProject)
                                {
                                    //Couldn't connect to the project this item belongs to. Throw an error.
                                    this._eventLog.WriteMessage("Message " + msg.MessageLogID + " contains information for a project [PR:" + projNum.ToString() + "] that the client could not connect to. Skipping.", System.Diagnostics.EventLogEntryType.Information);
                                    artType = ArtifactTypeEnum.Skip;
                                    artId   = 0;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            this._eventLog.WriteMessage(METHOD, ex, "Message " + msg.MessageLogID + " - while trying to retrieve project number from artifact. Skipping.");
                        }

                        //If we have a match, find the user..
                        if (artId > 0 && artType != ArtifactTypeEnum.None)
                        {
                            //Detect if more than one user is found..
                            int userCnt = spiraUsers.Where(su => su.EmailAddress.ToLowerInvariant() == msg.Headers.From.MailAddress.Address.ToLowerInvariant()).Count();
                            if (userCnt == 1)
                            {
                                RemoteProjectUser selUser = spiraUsers.Where(su => su.EmailAddress.ToLowerInvariant() == msg.Headers.From.MailAddress.Address.ToLowerInvariant()).Single();

                                //See if the item exists in the server..
                                RemoteArtifact remArt = null;
                                try
                                {
                                    switch (artType)
                                    {
                                    case ArtifactTypeEnum.Requirement:
                                        remArt = clientAppl.Requirement_RetrieveById(artId);
                                        break;

                                    case ArtifactTypeEnum.Test_Case:
                                        remArt = clientAppl.TestCase_RetrieveById(artId);
                                        break;

                                    case ArtifactTypeEnum.Incident:
                                        remArt = clientAppl.Incident_RetrieveById(artId);
                                        break;

                                    case ArtifactTypeEnum.Release:
                                        remArt = clientAppl.Release_RetrieveById(artId);
                                        break;

                                    case ArtifactTypeEnum.Task:
                                        remArt = clientAppl.Task_RetrieveById(artId);
                                        break;

                                    case ArtifactTypeEnum.Test_Set:
                                        remArt = clientAppl.TestSet_RetrieveById(artId);
                                        break;
                                    }

                                    if (remArt == null)
                                    {
                                        throw new Exception("Artifact did not exist: " + artType.ToString() + " #" + artId.ToString());
                                    }
                                }
                                catch (Exception ex)
                                {
                                    this._eventLog.WriteMessage(METHOD, ex, "For message " + msg.MessageLogID + ", referenced artifact did not exist.");
                                    continue;
                                }

                                try
                                {
                                    //The artifact exists, let's add a comment..
                                    RemoteComment comment = new RemoteComment();
                                    comment.ArtifactId   = artId;
                                    comment.CreationDate = DateTime.UtcNow;
                                    comment.UserId       = selUser.UserId;
                                    comment.Text         = this.getTextFromMessage(msg, true, true);

                                    switch (artType)
                                    {
                                    case ArtifactTypeEnum.Requirement:
                                        comment = clientAppl.Requirement_CreateComment(comment);
                                        break;

                                    case ArtifactTypeEnum.Test_Case:
                                        comment = clientAppl.TestCase_CreateComment(comment);
                                        break;

                                    case ArtifactTypeEnum.Incident:
                                        comment = clientAppl.Incident_AddComments(new List <RemoteComment>()
                                        {
                                            comment
                                        }).FirstOrDefault();
                                        break;

                                    case ArtifactTypeEnum.Release:
                                        comment = clientAppl.Release_CreateComment(comment);
                                        break;

                                    case ArtifactTypeEnum.Task:
                                        comment = clientAppl.Task_CreateComment(comment);
                                        break;

                                    case ArtifactTypeEnum.Test_Set:
                                        comment = clientAppl.TestSet_CreateComment(comment);
                                        break;
                                    }

                                    if (comment != null && comment.CommentId.HasValue)
                                    {
                                        //Now check for attachments
                                        try
                                        {
                                            foreach (MessagePart attach in msg.FindAllAttachments().Where(aa => aa.IsMultiPart == false && aa.IsText == false))
                                            {
                                                //Add the file..
                                                RemoteLinkedArtifact artifactLink = new RemoteLinkedArtifact();
                                                artifactLink.ArtifactId     = comment.ArtifactId;
                                                artifactLink.ArtifactTypeId = (int)artType;
                                                RemoteDocument newDoc = new RemoteDocument();
                                                newDoc.AttachedArtifacts = new List <RemoteLinkedArtifact>()
                                                {
                                                    artifactLink
                                                };
                                                newDoc.AttachmentTypeId = 1;
                                                newDoc.AuthorId         = selUser.UserId;
                                                newDoc.FilenameOrUrl    = attach.FileName;
                                                newDoc.UploadDate       = DateTime.UtcNow;

                                                //Check for string overrun and add extension if necessary.
                                                if (newDoc.FilenameOrUrl.Length > 250)
                                                {
                                                    newDoc.FilenameOrUrl = newDoc.FilenameOrUrl.Substring(0, 250);
                                                }
                                                if (string.IsNullOrWhiteSpace(Path.GetExtension(newDoc.FilenameOrUrl)) && attach.ContentType != null)
                                                {
                                                    string tempFileExtension = Utils.GetExtensionFromMimeType(attach.ContentType.MediaType);
                                                    if (!string.IsNullOrWhiteSpace(tempFileExtension))
                                                    {
                                                        newDoc.FilenameOrUrl += "." + tempFileExtension;
                                                    }
                                                }

                                                //Call the function to upload the file to Spira
                                                newDoc = clientAppl.Document_AddFile(newDoc, attach.Body);

                                                //Log it.
                                                this._eventLog.WriteMessage("Attachment #" + newDoc.AttachmentId.ToSafeString() + " created from file '" + attach.FileName + "' for Artifact " + artType + " #:" + comment.ArtifactId + " from message " + msg.MessageLogID + ".", System.Diagnostics.EventLogEntryType.Information);
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            //Log and continue
                                            this._eventLog.WriteMessage(METHOD, ex, "Saving attachment for message " + msg.MessageLogID);
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    this._eventLog.WriteMessage(METHOD, ex, "While trying to save message '" + msg.MessageLogID + "' as a new comment.");
                                    continue;
                                }

                                //If we get this far, mark the message as processed.
                                try
                                {
                                    //Add it to our list..
                                    seenUIDs.Add(msg.MessageUID);

                                    if (account.RemoveFromServer)
                                    {
                                        clientPOP3.DeleteMessage(msg.MessageIndex);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    this._eventLog.WriteMessage(METHOD, ex, "Trying to delete message " + msg.MessageLogID + " from server.");
                                }
                            }
                            else
                            {
                                string msgLog = "";
                                if (userCnt == 0)
                                {
                                    msgLog = "Message " + msg.MessageLogID + " was sent from a user not a mamber of the specified project. Not importing unknown users.";
                                }
                                else if (userCnt > 1)
                                {
                                    msgLog = "Message " + msg.MessageLogID + " was sent from a user that did not have a unique email address. Cannot import to avoid selecting the wrong user.";
                                }

                                this._eventLog.WriteMessage(msgLog, System.Diagnostics.EventLogEntryType.Information);
                            }
                        }
                        else
                        {
                            if (artType != ArtifactTypeEnum.Skip)
                            {
                                int userCnt = spiraUsers.Where(su => su.EmailAddress.ToLowerInvariant() == msg.Headers.From.MailAddress.Address.ToLowerInvariant()).Count();
                                if (userCnt == 1)
                                {
                                    RemoteProjectUser selUser = spiraUsers.Where(su => su.EmailAddress.ToLowerInvariant() == msg.Headers.From.MailAddress.Address.ToLowerInvariant()).Single();

                                    //Create a new Incident..
                                    RemoteIncident newIncident = new RemoteIncident();
                                    newIncident.CreationDate = DateTime.Now;
                                    newIncident.Description  = this.getTextFromMessage(msg, true, false);
                                    newIncident.Name         = msg.Headers.Subject;
                                    newIncident.OpenerId     = selUser.UserId;

                                    //Check regex other projects
                                    if (account.UseRegexToMatch)
                                    {
                                        Regex regProj1 = new Regex(@"\[PR[\:\-\s](\d*?)\]", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
                                        if (regProj1.IsMatch(newIncident.Description) || regProj1.IsMatch(newIncident.Name))
                                        {
                                            //Someone used the PR tag in the email body, we'll use it, if possible.
                                            string matchNum = "";
                                            if (regProj1.IsMatch(newIncident.Name))
                                            {
                                                matchNum = regProj1.Matches(newIncident.Name)[0].Groups[1].Value;
                                            }
                                            else if (regProj1.IsMatch(newIncident.Description))
                                            {
                                                matchNum = regProj1.Matches(newIncident.Description)[0].Groups[1].Value;
                                            }
                                            else
                                            {
                                                this._eventLog.WriteMessage("ERROR: At least one RegEx returned IsMatch, but none contained match.", System.Diagnostics.EventLogEntryType.Information);
                                                continue;
                                            }

                                            int projNum = 0;
                                            if (int.TryParse(matchNum, out projNum))
                                            {
                                                //We had a number, let's see if it's a valid product.
                                                RemoteProject proj = spiraProjs.FirstOrDefault(prd => prd.ProjectId == projNum);
                                                if (proj != null)
                                                {
                                                    //Connect to project..
                                                    if (clientAppl.Connection_ConnectToProject(proj.ProjectId.Value))
                                                    {
                                                        newIncident.ProjectId = proj.ProjectId.Value;
                                                        this._eventLog.WriteMessage("Message " + msg.MessageLogID + " changed to Project '" + proj.Name + "' due to having [PR:xx] tag.", System.Diagnostics.EventLogEntryType.Information);
                                                    }
                                                    else
                                                    {
                                                        this._eventLog.WriteMessage("Message " + msg.MessageLogID + " contained project token for project '" + proj.Name + "', but email import has no access to that project. Using default.", System.Diagnostics.EventLogEntryType.Information);
                                                    }
                                                }
                                                else
                                                {
                                                    this._eventLog.WriteMessage("Message '" + msg.MessageLogID + "' contained token for project " + projNum.ToString() + " but project was inaccessible. Using default.", System.Diagnostics.EventLogEntryType.Information);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            foreach (RemoteProject prod in spiraProjs)
                                            {
                                                Regex regProd3 = new Regex(@"\b" + prod.Name + @"\b", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
                                                if (regProd3.IsMatch(newIncident.Description) || regProd3.IsMatch(newIncident.Name))
                                                {
                                                    newIncident.ProjectId = prod.ProjectId.Value;
                                                    this._eventLog.WriteMessage("Message " + msg.MessageLogID + " changed to Product '" + prod.Name + "' due to having Product name '" + prod.Name + "'", System.Diagnostics.EventLogEntryType.Information);
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    //Now save the Incident..
                                    try
                                    {
                                        newIncident = clientAppl.Incident_Create(newIncident);

                                        if (newIncident.IncidentId.HasValue)
                                        {
                                            //Now check for attachments
                                            try
                                            {
                                                foreach (MessagePart attach in msg.FindAllAttachments().Where(aa => aa.IsMultiPart == false && aa.IsText == false))
                                                {
                                                    //Add the file..
                                                    RemoteLinkedArtifact artifactLink = new RemoteLinkedArtifact();
                                                    artifactLink.ArtifactId     = newIncident.IncidentId.Value;
                                                    artifactLink.ArtifactTypeId = 3; /* Incident */
                                                    RemoteDocument newDoc = new RemoteDocument();
                                                    newDoc.AttachedArtifacts = new List <RemoteLinkedArtifact>()
                                                    {
                                                        artifactLink
                                                    };
                                                    newDoc.AttachmentTypeId = 1;
                                                    newDoc.AuthorId         = selUser.UserId;
                                                    newDoc.FilenameOrUrl    = attach.FileName;
                                                    newDoc.UploadDate       = DateTime.UtcNow;

                                                    //Check for string overrun and add extension if necessary.
                                                    if (newDoc.FilenameOrUrl.Length > 250)
                                                    {
                                                        newDoc.FilenameOrUrl = newDoc.FilenameOrUrl.Substring(0, 250);
                                                    }
                                                    if (string.IsNullOrWhiteSpace(Path.GetExtension(newDoc.FilenameOrUrl)) && attach.ContentType != null)
                                                    {
                                                        string tempFileExtension = Utils.GetExtensionFromMimeType(attach.ContentType.MediaType);
                                                        if (!string.IsNullOrWhiteSpace(tempFileExtension))
                                                        {
                                                            newDoc.FilenameOrUrl += "." + tempFileExtension;
                                                        }
                                                    }

                                                    //Call the function to upload the file to Spira
                                                    newDoc = clientAppl.Document_AddFile(newDoc, attach.Body);

                                                    //Log it.
                                                    this._eventLog.WriteMessage("Attachment #" + newDoc.AttachmentId.ToSafeString() + " created from file '" + attach.FileName + "' for Incident IN:" + newIncident.IncidentId.Value + " from message " + msg.MessageLogID + ".", System.Diagnostics.EventLogEntryType.Information);
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                //Log and continue
                                                this._eventLog.WriteMessage(METHOD, ex, "Saving attachment for message " + msg.MessageLogID);
                                            }
                                        }

                                        //If we get this far, mark the message as processed.
                                        try
                                        {
                                            //Add it to our list..
                                            seenUIDs.Add(msg.MessageUID);

                                            if (account.RemoveFromServer)
                                            {
                                                clientPOP3.DeleteMessage(msg.MessageIndex);
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            this._eventLog.WriteMessage(METHOD, ex, "Trying to delete message " + msg.MessageLogID + " from server.");
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        this._eventLog.WriteMessage(METHOD, ex, "While trying to save message '" + msg.MessageLogID + "' as an incident.");
                                    }
                                }
                                else
                                {
                                    string msgLog = "";
                                    if (userCnt == 0)
                                    {
                                        msgLog = "Message " + msg.MessageLogID + " was sent from a user not a mamber of the specified project. Not importing unknown users.";
                                    }
                                    else if (userCnt > 1)
                                    {
                                        msgLog = "Message " + msg.MessageLogID + " was sent from a user that did not have a unique email address. Cannot import to avoid selecting the wrong user.";
                                    }

                                    this._eventLog.WriteMessage(msgLog, System.Diagnostics.EventLogEntryType.Information);
                                }
                            }
                            else
                            {
                            }
                        }
                    }
                    else
                    {
                        //Log it..
                        this._eventLog.WriteMessage("Message " + msg.MessageLogID + " on the server did not pass filters:" + Environment.NewLine + "Subject: " + msg.Headers.Subject + Environment.NewLine + "Reasons: " + Environment.NewLine + filterMsg, System.Diagnostics.EventLogEntryType.Warning);
                    }
                }
                else
                {
                    //Log it..
                    this._eventLog.WriteMessage("Message " + msg.MessageLogID + " had no From address or was from the import account --" + Environment.NewLine + "Subject: " + msg.Headers.Subject + Environment.NewLine + "Msg UID: " + msg.Headers.MessageId + Environment.NewLine + "For reason: From Email address same as importing account, or was null.", System.Diagnostics.EventLogEntryType.Warning);
                }
            }
            //Save the seen message IDs..
            this.saveMessageIDsForAccount(account.AccountID.Value, seenUIDs);

            //Disconnect client and POP3..
            try
            {
                clientPOP3.Disconnect();
                clientAppl.Connection_Disconnect();
            }
            catch (Exception ex)
            {
                this._eventLog.WriteMessage(METHOD, ex, "Trying to close connections.");
            }
        }
 /// <remarks/>
 public void editCommentAsync(string in0, RemoteComment in1, object userState) {
     if ((this.editCommentOperationCompleted == null)) {
         this.editCommentOperationCompleted = new System.Threading.SendOrPostCallback(this.OneditCommentOperationCompleted);
     }
     this.InvokeAsync("editComment", new object[] {
                 in0,
                 in1}, this.editCommentOperationCompleted, userState);
 }
Beispiel #24
0
 public RemoteComment EditComment(string in0, RemoteComment in1)
 {
     return(_client.editComment(in0, in1));
 }
 /// <summary>
 /// Adds a comment to an Issue
 /// </summary>
 /// <param name="comment">The <c>RemoteComment</c> to add to the issue</param>
 /// <param name="issueKey">The key of the issue to which the comment will be added</param>
 public void AddCommentToIssue(string issueKey, IssueComment comment) {
     RemoteComment rc = new RemoteComment();
     rc.body = comment.Text;
     rc.timePerformed = comment.Date;
     rc.username = comment.Author;
     JiraSoapHelper.GetJiraSoapServiceProxy().addComment(this.AuthenticationToken, issueKey,rc);
 }
Beispiel #26
0
        /// <summary>Hit when we're finished updating the main information.</summary>
        /// <param name="sender">ImportExportClient</param>
        /// <param name="e">AsyncCompletedEventArgs</param>
        private void clientSave_Requirement_UpdateCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            const string METHOD = CLASS + "clientSave_Requirement_UpdateCompleted()";

            Logger.LogTrace_EnterMethod(METHOD + "  " + this._clientNumSaving.ToString() + " running.");
            try
            {
                ImportExportClient client = (sender as ImportExportClient);
                this._clientNumSaving--;
                this.barSavingReq.Value++;

                if (!e.Cancelled)
                {
                    if (e.Error == null)
                    {
                        //See if we need to add a resolution.
                        if (this._isResChanged)
                        {
                            //We need to save a resolution.
                            RemoteComment newRes = new RemoteComment();
                            newRes.CreationDate = DateTime.Now.ToUniversalTime();
                            newRes.UserId       = ((SpiraProject)this._ArtifactDetails.ArtifactParentProject.ArtifactTag).UserID;
                            newRes.ArtifactId   = this._ArtifactDetails.ArtifactId;
                            newRes.Text         = this.cntrlResolution.HTMLText;

                            this._clientNumSaving++;
                            client.Requirement_CreateCommentAsync(newRes, this._clientNum++);
                        }
                        else
                        {
                            //We're finished.
                            this.barSavingReq.Value++;
                            this._clientNumSaving++;
                            client.Connection_DisconnectAsync(this._clientNum++);
                        }
                    }
                    else
                    {
                        //Log error.
                        Logger.LogMessage(e.Error, "Saving Incident Changes to Database");

                        //If we get a concurrency error, get the current data.
                        if (e.Error is FaultException <ServiceFaultMessage> && ((FaultException <ServiceFaultMessage>)e.Error).Detail.Type == "DataAccessConcurrencyException")
                        {
                            client.Requirement_RetrieveByIdCompleted += new EventHandler <Requirement_RetrieveByIdCompletedEventArgs>(client_Requirement_RetrieveByIdCompleted);

                            //Fire it off.
                            this._clientNumSaving++;
                            client.Requirement_RetrieveByIdAsync(this._ArtifactDetails.ArtifactId, this._clientNum++);
                        }
                        else
                        {
                            //Display the error screen here.

                            //Cancel calls.
                            this._clientNumSaving++;
                            client.Connection_DisconnectAsync(this._clientNum++);
                        }
                    }
                }

                //See if it's okay to reload.
                this.save_CheckIfOkayToLoad();
            }
            catch (Exception ex)
            {
                Logger.LogMessage(ex, METHOD);
                MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error);
            }
            Logger.LogTrace_ExitMethod(METHOD + "  " + this._clientNumSaving.ToString() + " clients left.");
        }
Beispiel #27
0
 public bool HasPermissionToEditComment(string in0, RemoteComment in1)
 {
     throw new NotImplementedException();
 }