示例#1
0
        public void Should_Update_Group()
        {
            const string UPDATED_GROUP_ID      = "58";
            const string UPDATED_GROUP_NAME    = "Best Developers";
            const int    UPDATED_GROUP_USER_ID = 2;

            var group = fixture.RedmineManager.GetObject <Group>(UPDATED_GROUP_ID,
                                                                 new NameValueCollection {
                { RedmineKeys.INCLUDE, RedmineKeys.USERS }
            });

            group.Name = UPDATED_GROUP_NAME;
            group.Users.Add((GroupUser)IdentifiableName.Create(UPDATED_GROUP_USER_ID));

            fixture.RedmineManager.UpdateObject(UPDATED_GROUP_ID, group);

            var updatedGroup = fixture.RedmineManager.GetObject <Group>(UPDATED_GROUP_ID,
                                                                        new NameValueCollection {
                { RedmineKeys.INCLUDE, RedmineKeys.USERS }
            });

            Assert.NotNull(updatedGroup);
            Assert.True(updatedGroup.Name.Equals(UPDATED_GROUP_NAME), "Group name was not updated.");
            Assert.NotNull(updatedGroup.Users);
            //     Assert.True(updatedGroup.Users.Find(u => u.Id == UPDATED_GROUP_USER_ID) != null,
            //"User was not added to group.");
        }
示例#2
0
        private static Project CreateTestProjectWithAllPropertiesSet()
        {
            var project = new Project
            {
                Name           = "Redmine Net Api Project Test All Properties",
                Description    = "This is a test project.",
                Identifier     = "rnaptap",
                HomePage       = "www.redminetest.com",
                IsPublic       = true,
                InheritMembers = true,
                EnabledModules = new List <ProjectEnabledModule>
                {
                    new ProjectEnabledModule {
                        Name = "issue_tracking"
                    },
                    new ProjectEnabledModule {
                        Name = "time_tracking"
                    }
                },
                Trackers = new List <ProjectTracker>
                {
                    (ProjectTracker)IdentifiableName.Create <ProjectTracker>(1),
                    (ProjectTracker)IdentifiableName.Create <ProjectTracker>(2)
                }
            };

            return(project);
        }
示例#3
0
        public void Should_Create_Time_Entry()
        {
            const int    NEW_TIME_ENTRY_ISSUE_ID    = 18;
            const int    NEW_TIME_ENTRY_PROJECT_ID  = 9;
            var          newTimeEntryDate           = DateTime.Now;
            const int    NEW_TIME_ENTRY_HOURS       = 1;
            const int    NEW_TIME_ENTRY_ACTIVITY_ID = 16;
            const string NEW_TIME_ENTRY_COMMENTS    = "Added time entry on project";

            var timeEntry = new TimeEntry
            {
                Issue    = IdentifiableName.Create(NEW_TIME_ENTRY_ISSUE_ID),
                Project  = IdentifiableName.Create(NEW_TIME_ENTRY_PROJECT_ID),
                SpentOn  = newTimeEntryDate,
                Hours    = NEW_TIME_ENTRY_HOURS,
                Activity = IdentifiableName.Create(NEW_TIME_ENTRY_ACTIVITY_ID),
                Comments = NEW_TIME_ENTRY_COMMENTS
            };

            var savedTimeEntry = fixture.RedmineManager.CreateObject(timeEntry);

            Assert.NotNull(savedTimeEntry);
            Assert.NotNull(savedTimeEntry.Issue);
            Assert.True(savedTimeEntry.Issue.Id == NEW_TIME_ENTRY_ISSUE_ID, "Issue id is invalid.");
            Assert.NotNull(savedTimeEntry.Project);
            Assert.True(savedTimeEntry.Project.Id == NEW_TIME_ENTRY_PROJECT_ID, "Project id is invalid.");
            Assert.NotNull(savedTimeEntry.SpentOn);
            Assert.True(DateTime.Compare(savedTimeEntry.SpentOn.Value.Date, newTimeEntryDate.Date) == 0,
                        "Date is invalid.");
            Assert.True(savedTimeEntry.Hours == NEW_TIME_ENTRY_HOURS, "Hours value is not valid.");
            Assert.NotNull(savedTimeEntry.Activity);
            Assert.True(savedTimeEntry.Activity.Id == NEW_TIME_ENTRY_ACTIVITY_ID, "Activity id is invalid.");
            Assert.NotNull(savedTimeEntry.Comments);
            Assert.True(savedTimeEntry.Comments.Equals(NEW_TIME_ENTRY_COMMENTS), "Coments value is invalid.");
        }
示例#4
0
 /// <summary>
 /// Writes the id if not null.
 /// </summary>
 /// <param name="writer">The writer.</param>
 /// <param name="ident">The ident.</param>
 /// <param name="tag">The tag.</param>
 public static void WriteIdIfNotNull(this XmlWriter writer, IdentifiableName ident, string tag)
 {
     if (ident != null)
     {
         writer.WriteElementString(tag, ident.Id.ToString(CultureInfo.InvariantCulture));
     }
 }
示例#5
0
        public void Should_Update_Issue()
        {
            const string UPDATED_ISSUE_ID                 = "98";
            const string UPDATED_ISSUE_SUBJECT            = "Issue updated subject";
            const string UPDATED_ISSUE_DESCRIPTION        = null;
            const int    UPDATED_ISSUE_PROJECT_ID         = 9;
            const int    UPDATED_ISSUE_TRACKER_ID         = 3;
            const int    UPDATED_ISSUE_PRIORITY_ID        = 8;
            const int    UPDATED_ISSUE_CATEGORY_ID        = 18;
            const int    UPDATED_ISSUE_ASSIGNED_TO_ID     = 2;
            const int    UPDATED_ISSUE_PARENT_ISSUE_ID    = 91;
            const int    UPDATED_ISSUE_CUSTOM_FIELD_ID    = 13;
            const string UPDATED_ISSUE_CUSTOM_FIELD_VALUE = "Another custom field completed";
            const int    UPDATED_ISSUE_ESTIMATED_HOURS    = 23;
            const string UPDATED_ISSUE_NOTES              = "A lot is changed";
            const bool   UPDATED_ISSUE_PRIVATE_NOTES      = true;

            DateTime?updatedIssueStartDate = default(DateTime?);

            var updatedIssueDueDate = DateTime.Now.AddMonths(1);

            var issue = fixture.RedmineManager.GetObject <Issue>(UPDATED_ISSUE_ID, new NameValueCollection
            {
                { RedmineKeys.INCLUDE, $"{RedmineKeys.CHILDREN},{RedmineKeys.ATTACHMENTS},{RedmineKeys.RELATIONS},{RedmineKeys.CHANGE_SETS},{RedmineKeys.JOURNALS},{RedmineKeys.WATCHERS}" }
            });

            issue.Subject     = UPDATED_ISSUE_SUBJECT;
            issue.Description = UPDATED_ISSUE_DESCRIPTION;
            issue.StartDate   = updatedIssueStartDate;
            issue.DueDate     = updatedIssueDueDate;
            issue.Project     = IdentifiableName.Create(UPDATED_ISSUE_PROJECT_ID);
            issue.Tracker     = IdentifiableName.Create(UPDATED_ISSUE_TRACKER_ID);
            issue.Priority    = IdentifiableName.Create(UPDATED_ISSUE_PRIORITY_ID);
            issue.Category    = IdentifiableName.Create(UPDATED_ISSUE_CATEGORY_ID);
            issue.AssignedTo  = IdentifiableName.Create(UPDATED_ISSUE_ASSIGNED_TO_ID);
            issue.ParentIssue = IdentifiableName.Create(UPDATED_ISSUE_PARENT_ISSUE_ID);

            var icf = (IssueCustomField)IdentifiableName.Create(UPDATED_ISSUE_CUSTOM_FIELD_ID);

            icf.Values = new List <CustomFieldValue> {
                new CustomFieldValue {
                    Info = UPDATED_ISSUE_CUSTOM_FIELD_VALUE
                }
            };

            issue.CustomFields?.Add(icf);
            issue.EstimatedHours = UPDATED_ISSUE_ESTIMATED_HOURS;
            issue.Notes          = UPDATED_ISSUE_NOTES;
            issue.PrivateNotes   = UPDATED_ISSUE_PRIVATE_NOTES;

            fixture.RedmineManager.UpdateObject(UPDATED_ISSUE_ID, issue);

            var updatedIssue = fixture.RedmineManager.GetObject <Issue>(UPDATED_ISSUE_ID, new NameValueCollection
            {
                { RedmineKeys.INCLUDE, $"{RedmineKeys.CHILDREN},{RedmineKeys.ATTACHMENTS},{RedmineKeys.RELATIONS},{RedmineKeys.CHANGE_SETS},{RedmineKeys.JOURNALS},{RedmineKeys.WATCHERS}" }
            });

            Assert.NotNull(updatedIssue);
            Assert.True(issue.Subject.Equals(updatedIssue.Subject), "Issue subject is invalid.");
        }
示例#6
0
        public async Task Should_Create_User()
        {
            var user = new User
            {
                Login                = "******",
                FirstName            = "userTestFirstName",
                LastName             = "userTestLastName",
                Email                = "*****@*****.**",
                Password             = "******",
                AuthenticationModeId = 1,
                MustChangePassword   = false
            };


            var icf = (IssueCustomField)IdentifiableName.Create(4);

            icf.Values = new List <CustomFieldValue> {
                new CustomFieldValue {
                    Info = "userTestCustomField:" + DateTime.UtcNow
                }
            };

            user.CustomFields = new List <IssueCustomField>();
            user.CustomFields.Add(icf);

            var createdUser = await fixture.RedmineManager.CreateObjectAsync(user);

            Assert.Equal(user.Login, createdUser.Login);
            Assert.Equal(user.Email, createdUser.Email);
        }
 public EditEnumForm(string enumName)
 {
     InitializeComponent();
     this.type = eFormType.New;
     this.enumName = enumName;
     this.enumValue = new IdentifiableName();
     LoadLanguage();
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="jsonWriter"></param>
 /// <param name="tag"></param>
 /// <param name="value"></param>
 public static void WriteIdIfNotNull(this JsonWriter jsonWriter, string tag, IdentifiableName value)
 {
     if (value != null)
     {
         jsonWriter.WritePropertyName(tag);
         jsonWriter.WriteValue(value.Id);
     }
 }
示例#9
0
 public static void WriteIdIfNotNull(
     this Dictionary <string, object> dictionary,
     IdentifiableName ident,
     string key)
 {
     if (ident != null)
     {
         dictionary.Add(key, ident.Id);
     }
 }
示例#10
0
        private static void OpenTicket(string dump, DumpData res,
                                       Configuration configuration)
        {
            OwnershipData ownershipData = configuration.Owners.FirstOrDefault(o => o.Filter == res.FilterOfInterest);
            Owner         assignee      = configuration.DefaultOwner;

            if (ownershipData != null)
            {
                assignee = ownershipData.Owner;
            }

            var author = new IdentifiableName {
                Id = _redmineManager.GetCurrentUser().Id
            };
            IdentifiableName assignedTo =
                _projectMembers.SingleOrDefault(pm => pm != null && pm.Name == assignee.Name) ??
                _projectMembers.SingleOrDefault(pm => pm != null && pm.Name == configuration.DefaultOwner.Name);

            if (assignedTo == null)
            {
                // TODO: do something about this?
            }

            string subject     = "Unexpected exception occurred";
            string description =
                string.Format("Please investigate a dump located at {0}.{1}{2}Here's the beginning of the call stack for the last event:{3}{4}",
                              dump,
                              Environment.NewLine, Environment.NewLine, Environment.NewLine,
                              string.Join(Environment.NewLine, res.CallStack.Take(Math.Min(res.CallStack.Count, 30))));

            if (res.FrameOfInterest != null)
            {
                subject = string.Format("A problem occurred in {0}.{1}: {2}",
                                        res.FrameOfInterest.ModuleName, res.FrameOfInterest.MethodName, res.LastEvent.Description);

                description = string.Format("There was a problem in {0}: {1}.{2}Please investigate a dump located at {3}.{4}{5}Here's the call stack for the last event:{6}{7}",
                                            res.FrameOfInterest.ModuleName, res.LastEvent, Environment.NewLine,
                                            dump,
                                            Environment.NewLine, Environment.NewLine, Environment.NewLine,
                                            string.Join(Environment.NewLine, res.CallStack.Take(Math.Min(res.CallStack.Count, 30))));
            }

            var issue = new Issue
            {
                Subject     = subject.Substring(0, Math.Min(subject.Length, 255)),
                Description = description,
                AssignedTo  = assignedTo,
                Author      = author,
                Project     = new IdentifiableName {
                    Id = _project.Id
                },
            };

            _redmineManager.CreateObject(issue);
        }
示例#11
0
 public static string TryGetName(IdentifiableName s)
 {
     if (s == null)
     {
         return(null);
     }
     else
     {
         return(s.Name);
     }
 }
示例#12
0
 public static string TryGetName(this IdentifiableName identifiableName)
 {
     if (identifiableName != null && identifiableName.Name != null)
     {
         return(identifiableName.Name);
     }
     else
     {
         return(null);
     }
 }
 public static void WriteIdOrEmpty(this XmlWriter writer, IdentifiableName ident, String tag)
 {
     if (ident != null)
     {
         writer.WriteElementString(tag, ident.Id.ToString(CultureInfo.InvariantCulture));
     }
     else
     {
         writer.WriteElementString(tag, string.Empty);
     }
 }
示例#14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="jsonWriter"></param>
 /// <param name="tag"></param>
 /// <param name="ident"></param>
 /// <param name="emptyValue"></param>
 public static void WriteIdOrEmpty(this JsonWriter jsonWriter, string tag, IdentifiableName ident, string emptyValue = null)
 {
     if (ident != null)
     {
         jsonWriter.WriteProperty(tag, ident.Id.ToString(CultureInfo.InvariantCulture));
     }
     else
     {
         jsonWriter.WriteProperty(tag, emptyValue);
     }
 }
示例#15
0
        private static Project CreateTestProjectWithParentSet(int parentId)
        {
            var project = new Project
            {
                Name       = "Redmine Net Api Project With Parent Set",
                Identifier = "rnapwps",
                Parent     = IdentifiableName.Create <IdentifiableName>(parentId)
            };

            return(project);
        }
        public EditEnumForm(string enumName, IdentifiableName enumValue)
        {
            InitializeComponent();
            this.type = eFormType.Edit;
            this.enumName = enumName;
            this.enumValue = enumValue;

            EnumIdTextBox.Text = enumValue.Id.ToString();
            EnumNameTextBox.Text = enumValue.Name;
            LoadLanguage();
        }
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            if (dictionary != null)
            {
                var entity = new IdentifiableName();

                entity.Id   = dictionary.GetValue <int>("id");
                entity.Name = dictionary.GetValue <string>("name");

                return(entity);
            }
            return(null);
        }
        public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            if (dictionary != null)
            {
                var entity = new IdentifiableName();

                entity.Id = dictionary.GetValue<int>(RedmineKeys.ID);
                entity.Name = dictionary.GetValue<string>(RedmineKeys.NAME);

                return entity;
            }
            return null;
        }
示例#19
0
        public void Should_Upload_Attachment()
        {
            const string ATTACHMENT_LOCAL_PATH   = "uploadAttachment.pages";
            const string ATTACHMENT_NAME         = "AttachmentUploaded.txt";
            const string ATTACHMENT_DESCRIPTION  = "File uploaded using REST API";
            const string ATTACHMENT_CONTENT_TYPE = "text/plain";
            const int    PROJECT_ID    = 9;
            const string ISSUE_SUBJECT = "Issue with attachments";

            //read document from specified path
            var documentData = System.IO.File.ReadAllBytes(AppDomain.CurrentDomain.BaseDirectory + ATTACHMENT_LOCAL_PATH);

            //upload attachment to redmine
            var attachment = fixture.RedmineManager.UploadFile(documentData);

            //set attachment properties
            attachment.FileName    = ATTACHMENT_NAME;
            attachment.Description = ATTACHMENT_DESCRIPTION;
            attachment.ContentType = ATTACHMENT_CONTENT_TYPE;

            //create list of attachments to be added to issue
            IList <Upload> attachments = new List <Upload>();

            attachments.Add(attachment);

            var issue = new Issue
            {
                Project = IdentifiableName.Create <IdentifiableName>(PROJECT_ID),
                Subject = ISSUE_SUBJECT,
                Uploads = attachments
            };

            //create issue and attach document
            var issueWithAttachment = fixture.RedmineManager.CreateObject(issue);

            issue = fixture.RedmineManager.GetObject <Issue>(issueWithAttachment.Id.ToString(),
                                                             new NameValueCollection {
                { RedmineKeys.INCLUDE, RedmineKeys.ATTACHMENTS }
            });

            Assert.NotNull(issue);
            Assert.NotNull(issue.Attachments);
            Assert.True(issue.Attachments.Count == 1, "Number of attachments ( " + issue.Attachments.Count + " ) != 1");

            var firstAttachment = issue.Attachments[0];

            Assert.True(firstAttachment.FileName == ATTACHMENT_NAME, "Attachment name is invalid.");
            Assert.True(firstAttachment.Description == ATTACHMENT_DESCRIPTION, "Attachment description is invalid.");
            Assert.True(firstAttachment.ContentType == ATTACHMENT_CONTENT_TYPE, "Attachment content type is invalid.");
        }
示例#20
0
        private static Project CreateTestProjectWithInvalidTrackersId()
        {
            var project = new Project
            {
                Name       = "Redmine Net Api Project Test Invalid Trackers",
                Identifier = "rnaptit",
                Trackers   = new List <ProjectTracker>
                {
                    (ProjectTracker)IdentifiableName.Create <ProjectTracker>(999999),
                    (ProjectTracker)IdentifiableName.Create <ProjectTracker>(999998)
                }
            };

            return(project);
        }
示例#21
0
        public void Should_Create_Wiki()
        {
            var author = new IdentifiableName();

            author.Id = 1;

            var result = fixture.RedmineManager.CreateOrUpdateWikiPage("1", "pagina2", new WikiPage
            {
                Text     = "ana are mere multe si rosii!",
                Comments = "asa",
                Version  = 1
            });

            Assert.NotNull(result);
        }
        public void Should_Create_IssueCategory()
        {
            var issueCategory = new IssueCategory
            {
                Name     = NEW_ISSUE_CATEGORY_NAME,
                AssignTo = IdentifiableName.Create <IdentifiableName>(NEW_ISSUE_CATEGORY_ASIGNEE_ID)
            };

            var savedIssueCategory = fixture.RedmineManager.CreateObject(issueCategory, PROJECT_ID);

            createdIssueCategoryId = savedIssueCategory.Id.ToString();

            Assert.NotNull(savedIssueCategory);
            Assert.True(savedIssueCategory.Name.Equals(NEW_ISSUE_CATEGORY_NAME), "Saved issue category name is invalid.");
        }
示例#23
0
        public void Should_Update_Project_Membership()
        {
            const string UPDATED_PROJECT_MEMBERSHIP_ID      = "143";
            const int    UPDATED_PROJECT_MEMBERSHIP_ROLE_ID = 4;

            var pm = fixture.RedmineManager.GetObject <ProjectMembership>(UPDATED_PROJECT_MEMBERSHIP_ID, null);

            pm.Roles.Add((MembershipRole)IdentifiableName.Create <MembershipRole>(UPDATED_PROJECT_MEMBERSHIP_ROLE_ID));

            fixture.RedmineManager.UpdateObject(UPDATED_PROJECT_MEMBERSHIP_ID, pm);

            var updatedPm = fixture.RedmineManager.GetObject <ProjectMembership>(UPDATED_PROJECT_MEMBERSHIP_ID, null);

            Assert.NotNull(updatedPm);
            Assert.NotNull(updatedPm.Roles);
            //Assert.True(updatedPm.Roles.Find(r => r.Id == UPDATED_PROJECT_MEMBERSHIP_ROLE_ID) != null,
            //    string.Format("Role with id {0} was not found in roles list.", UPDATED_PROJECT_MEMBERSHIP_ROLE_ID));
        }
        public IssueForm(Project project)
        {
            this.project = project;
            this.projectId = new IdentifiableName { Id = project.Id, Name = project.Name } ;
            this.type = DialogType.New;
            InitializeComponent();
            UpdateTitle(null);
            BtnCloseButton.Visible = false;
            linkEditInRedmine.Visible = false;
            DataGridViewCustomFields.Visible = false;
            downloadOpenToolStripMenuItem.Enabled = false;
            LangTools.UpdateControlsForLanguage(this.Controls);
            LangTools.UpdateControlsForLanguage(contextMenuStripAttachments.Items);

            // initialize new objects
            Issue issue = new Issue();
            issue.Attachments = new List<Attachment>();
        }
示例#25
0
        public void Should_Add_Group()
        {
            const string NEW_GROUP_NAME    = "Developers1";
            const int    NEW_GROUP_USER_ID = 8;

            var group = new Group();

            group.Name  = NEW_GROUP_NAME;
            group.Users = new List <GroupUser> {
                (GroupUser)IdentifiableName.Create(NEW_GROUP_USER_ID)
            };

            Group savedGroup = null;
            var   exception  =
                (RedmineException)Record.Exception(() => savedGroup = fixture.RedmineManager.CreateObject(group));

            Assert.Null(exception);
            Assert.NotNull(savedGroup);
            Assert.True(group.Name.Equals(savedGroup.Name), "Group name is not valid.");
        }
        public void Should_Update_IssueCategory()
        {
            const string ISSUE_CATEGORY_NAME_TO_UPDATE       = "Category updated";
            const int    ISSUE_CATEGORY_ASIGNEE_ID_TO_UPDATE = 2;

            var issueCategory = fixture.RedmineManager.GetObject <IssueCategory>(createdIssueCategoryId, null);

            issueCategory.Name     = ISSUE_CATEGORY_NAME_TO_UPDATE;
            issueCategory.AssignTo = IdentifiableName.Create <IdentifiableName>(ISSUE_CATEGORY_ASIGNEE_ID_TO_UPDATE);

            fixture.RedmineManager.UpdateObject(createdIssueCategoryId, issueCategory);

            var updatedIssueCategory = fixture.RedmineManager.GetObject <IssueCategory>(createdIssueCategoryId, null);

            Assert.NotNull(updatedIssueCategory);
            Assert.True(updatedIssueCategory.Name.Equals(ISSUE_CATEGORY_NAME_TO_UPDATE),
                        "Issue category name was not updated.");
            Assert.NotNull(updatedIssueCategory.AssignTo);
            Assert.True(updatedIssueCategory.AssignTo.Id == ISSUE_CATEGORY_ASIGNEE_ID_TO_UPDATE,
                        "Issue category asignee was not updated.");
        }
示例#27
0
        public void Should_Add_Project_Membership()
        {
            const int NEW_PROJECT_MEMBERSHIP_USER_ID = 2;
            const int NEW_PROJECT_MEMBERSHIP_ROLE_ID = 5;

            var pm = new ProjectMembership
            {
                User  = IdentifiableName.Create <IdentifiableName>(NEW_PROJECT_MEMBERSHIP_USER_ID),
                Roles = new List <MembershipRole> {
                    (MembershipRole)IdentifiableName.Create <MembershipRole>(NEW_PROJECT_MEMBERSHIP_ROLE_ID)
                }
            };

            var createdPm = fixture.RedmineManager.CreateObject(pm, PROJECT_IDENTIFIER);

            Assert.NotNull(createdPm);
            Assert.True(createdPm.User.Id == NEW_PROJECT_MEMBERSHIP_USER_ID, "User is invalid.");
            Assert.NotNull(createdPm.Roles);
            //Assert.True(createdPm.Roles.Exists(r => r.Id == NEW_PROJECT_MEMBERSHIP_ROLE_ID),
            //    string.Format("Role id {0} does not exist.", NEW_PROJECT_MEMBERSHIP_ROLE_ID));
        }
示例#28
0
        public void CreateDeploymentIssue(IList<Issue> issues)
        {
            var status = RedmineService.GetTotalObjectList<IssueStatus>(new NameValueCollection())
                .First(s => string.Equals(s.Name, "New", StringComparison.InvariantCultureIgnoreCase));

            var tracker = RedmineService.GetTotalObjectList<Redmine.Net.Api.Types.Tracker>(new NameValueCollection())
                .First(s => string.Equals(s.Name, "Salon", StringComparison.InvariantCultureIgnoreCase));

            foreach (var issue in issues)
            {
                issue.Status = status;

                var name = new IdentifiableName();
                name.Id = tracker.Id;
                name.Name = tracker.Name;
                issue.Tracker = name;
                var customField = new CustomFieldValue();
                customField.Info = "AppointmentBook";
                issue.CustomFields[1].Values.Add(new CustomFieldValue());
                RedmineService.CreateObject(issue);
            }
        }
示例#29
0
        public void Should_Clone_Issue()
        {
            const string ISSUE_TO_CLONE_SUBJECT            = "Issue to clone";
            const int    ISSUE_TO_CLONE_CUSTOM_FIELD_ID    = 13;
            const string ISSUE_TO_CLONE_CUSTOM_FIELD_VALUE = "Issue to clone custom field value";
            const int    CLONED_ISSUE_CUSTOM_FIELD_ID      = 13;
            const string CLONED_ISSUE_CUSTOM_FIELD_VALUE   = "Cloned issue custom field value";

            var icfc = (IssueCustomField)IdentifiableName.Create(ISSUE_TO_CLONE_CUSTOM_FIELD_ID);

            icfc.Values = new List <CustomFieldValue> {
                new CustomFieldValue {
                    Info = ISSUE_TO_CLONE_CUSTOM_FIELD_VALUE
                }
            };

            var issueToClone = new Issue
            {
                Subject      = ISSUE_TO_CLONE_SUBJECT,
                CustomFields = new List <IssueCustomField>()
                {
                    icfc
                }
            };

            var clonedIssue = (Issue)issueToClone.Clone();

            var icf = (IssueCustomField)IdentifiableName.Create(CLONED_ISSUE_CUSTOM_FIELD_ID);

            icf.Values = new List <CustomFieldValue> {
                new CustomFieldValue {
                    Info = CLONED_ISSUE_CUSTOM_FIELD_VALUE
                }
            };

            clonedIssue.CustomFields.Add(icf);

            Assert.True(issueToClone.CustomFields.Count != clonedIssue.CustomFields.Count);
        }
示例#30
0
        public void Should_Update_Time_Entry()
        {
            const string UPDATED_TIME_ENTRY_ID          = "31";
            const int    UPDATED_TIME_ENTRY_ISSUE_ID    = 18;
            const int    UPDATED_TIME_ENTRY_PROJECT_ID  = 9;
            const int    UPDATED_TIME_ENTRY_HOURS       = 3;
            const int    UPDATED_TIME_ENTRY_ACTIVITY_ID = 17;
            const string UPDATED_TIME_ENTRY_COMMENTS    = "Time entry updated";
            var          updatedTimeEntryDate           = DateTime.Now.AddDays(-2);

            var timeEntry = fixture.RedmineManager.GetObject <TimeEntry>(UPDATED_TIME_ENTRY_ID, null);

            timeEntry.Project  = IdentifiableName.Create(UPDATED_TIME_ENTRY_PROJECT_ID);
            timeEntry.Issue    = IdentifiableName.Create(UPDATED_TIME_ENTRY_ISSUE_ID);
            timeEntry.SpentOn  = updatedTimeEntryDate;
            timeEntry.Hours    = UPDATED_TIME_ENTRY_HOURS;
            timeEntry.Comments = UPDATED_TIME_ENTRY_COMMENTS;

            if (timeEntry.Activity == null)
            {
                timeEntry.Activity = IdentifiableName.Create(UPDATED_TIME_ENTRY_ACTIVITY_ID);
            }

            fixture.RedmineManager.UpdateObject(UPDATED_TIME_ENTRY_ID, timeEntry);

            var updatedTimeEntry = fixture.RedmineManager.GetObject <TimeEntry>(UPDATED_TIME_ENTRY_ID, null);

            Assert.NotNull(updatedTimeEntry);
            Assert.True(updatedTimeEntry.Project.Id == timeEntry.Project.Id, "Time entry project was not updated.");
            Assert.True(updatedTimeEntry.Issue.Id == timeEntry.Issue.Id, "Time entry issue was not updated.");
            Assert.True(
                updatedTimeEntry.SpentOn != null && timeEntry.SpentOn != null &&
                DateTime.Compare(updatedTimeEntry.SpentOn.Value.Date, timeEntry.SpentOn.Value.Date) == 0,
                "Time entry spent on field was not updated.");
            Assert.True(updatedTimeEntry.Hours == timeEntry.Hours, "Time entry hours was not updated.");
            Assert.True(updatedTimeEntry.Comments.Equals(timeEntry.Comments), "Time entry comments was not updated.");
        }
 private bool IsUnique(IdentifiableName identifiableName, IdentifiableName identifiableNameOri)
 {
     foreach (IdentifiableName item in enumeration)
     {
         if (identifiableNameOri != null)
             if (identifiableNameOri == item)
                 continue;
         if (item.Id == identifiableName.Id ||
             String.Compare(item.Name, identifiableName.Name, true) == 0)
             return false;
     }
     return true;
 }
 public static void WriteIdOrEmpty(this Dictionary <string, object> dictionary, IdentifiableName ident, String key, String emptyValue = null)
 {
     if (ident != null)
     {
         dictionary.Add(key, ident.Id);
     }
     else
     {
         dictionary.Add(key, emptyValue);
     }
 }
 private bool IsUnique(IdentifiableName identifiableName)
 {
     return IsUnique(identifiableName, null);
 }
        private static void ProcessExcelFile(List <IssueItem> issuesInRedmineProject, List <StatItem> statItems, List <string> envsNotExistingInConfigs)
        {
            //********************************************************************************************************/
            //read data from Excel
            var xlsx = new LinqToExcel.ExcelQueryFactory(MOM_FILE_PATH);

            foreach (string tabName in xlsx.GetWorksheetNames())
            {
                output.WriteLine("--------------------------------------------");
                output.WriteLine("Processing of {0}...", tabName);
                output.WriteLine("--------------------------------------------");

                MOMEnvSettings momEnvSettings = null;
                if (!MOM_ENV_SETTINGS.TryGetValue(tabName, out momEnvSettings))
                {
                    output.WriteLine("No MOMEnvSettings for {0}", tabName);
                    envsNotExistingInConfigs.Add(tabName);
                    //output.ReadKey();
                }
                else
                {
                    output.WriteLine("Start processing: {0}", tabName);

                    StatItem statItem = new StatItem();
                    statItem.Env = tabName;

                    var query =
                        from row in xlsx.Worksheet(tabName)
                        let item = new
                    {
                        ProblemID   = row["Problem ID"].Cast <string>(),
                        ProblemCode = row["Problem Code"].Cast <string>(),
                        MessageId   = row["Message ID"].Cast <string>(),
                        EventCode   = row["Event Code"].Cast <string>(),
                        Details     = row["Details"].Cast <string>(),
                        SenderCode  = row["Sender Code"].Cast <string>(),
                    }
                    select item;

                    IdentifiableName p = IdentifiableName.Create <Project>(Consts.PROJECT_NAMES.MOM.PROBLEMS);
                    foreach (var itemFromExcel in query)
                    {
                        string subject = string.Format("{0} - {1} - {2} - {3} - {4}", tabName, itemFromExcel.ProblemID, itemFromExcel.EventCode, itemFromExcel.ProblemCode, itemFromExcel.SenderCode);

                        //check if such the item exists in the Redmine project
                        var redmineIssue = issuesInRedmineProject.Where(issueFromRedmine => issueFromRedmine.Env == tabName && issueFromRedmine.ProblemId == itemFromExcel.ProblemID);
                        if (redmineIssue.Count() == 0)
                        {
                            string details = string.Format("{0}\r\nMessage link: {1}\r\nProblem link: {2}", itemFromExcel.Details, momEnvSettings.GetMessageLink(itemFromExcel.MessageId), momEnvSettings.GetProblemLink(itemFromExcel.MessageId));

                            var newIssue = new Issue {
                                Subject = subject, Project = p, Description = details
                            };
                            RMManegerService.RMManager.CreateObject(newIssue);

                            //add a new item to local cached items from redmine
                            IssueItem item = new IssueItem();

                            item.Env       = tabName;
                            item.ProblemId = itemFromExcel.ProblemID;

                            issuesInRedmineProject.Add(item);

                            statItem.Added++;
                        }
                        else
                        {
                            output.WriteLine("Issue exists! {0}", subject);
                            statItem.AlreadyExisted++;
                        }
                    }
                    statItems.Add(statItem);
                }
            }
        }
        private static void UpdateBasedOnExcelFile(List <IssueItem> issuesInRedmineProject,
                                                   List <StatItem> statItems,
                                                   bool allWithinDirectory)
        {
            //********************************************************************************************************/
            //read data from Excel
            List <string> filesToProcess = null;

            if (allWithinDirectory)
            {
                filesToProcess = Directory.EnumerateFiles(MOM_FILES_DIR, "*.xlsx").ToList();
            }
            else
            {
                filesToProcess = new List <string>();
                filesToProcess.Add(MOM_FILE_PATH);
            }

            foreach (string singleXSLXfile in filesToProcess)
            {
                var xlsx = new LinqToExcel.ExcelQueryFactory(singleXSLXfile);

                output.WriteLine("File: {0}", singleXSLXfile);

                foreach (string tabName in xlsx.GetWorksheetNames())
                {
                    output.WriteLine("--------------------------------------------");
                    output.WriteLine("Processing of {0}...", tabName);
                    output.WriteLine("--------------------------------------------");

                    StatItem statItem = new StatItem(tabName);
                    statItem.Env = tabName;

                    var query =
                        from row in xlsx.Worksheet(tabName)
                        let item = new
                    {
                        ProblemID   = row["Problem ID"].Cast <string>(),
                        ProblemCode = row["Problem Code"].Cast <string>(),
                        MessageId   = row["Message ID"].Cast <string>(),
                        EventCode   = row["Event Code"].Cast <string>(),
                        Details     = row["Details"].Cast <string>(),
                        SenderCode  = row["Sender Code"].Cast <string>(),
                    }
                    select item;

                    IdentifiableName p = IdentifiableName.Create <Project>(Consts.PROJECT_NAMES.MOM.PROBLEMS);
                    foreach (var itemFromExcel in query)
                    {
                        //look for the item in RM
                        var redmineIssue = issuesInRedmineProject.Where(issueFromRedmine => issueFromRedmine.Env == tabName && issueFromRedmine.ProblemId == itemFromExcel.ProblemID).FirstOrDefault();

                        if (redmineIssue != null && string.IsNullOrEmpty(redmineIssue.SenderCode))
                        {
                            if (!string.IsNullOrEmpty(itemFromExcel.SenderCode))
                            {
                                var issue = RMManegerService.RMManager.GetObject <Issue>(redmineIssue.Id.ToString(), null);

                                issue.Subject = issue.Subject + string.Format(" - {0}", itemFromExcel.SenderCode);

                                RMManegerService.RMManager.UpdateObject(redmineIssue.Id.ToString(), issue);
                                redmineIssue.SenderCode = itemFromExcel.SenderCode;

                                statItem.Updated++;
                                //  string subject = redmineIssue.sub
                                //string subject = string.Format("{0} - {1} - {2} - {3} - {4}", tabName, itemFromExcel.ProblemID, itemFromExcel.EventCode, itemFromExcel.ProblemCode, itemFromExcel.SenderCode);
                            }
                            else
                            {
                                statItem.NotUpdated++;
                            }
                        }
                        else
                        {
                            statItem.NotUpdated++;
                        }
                    }
                    statItems.Add(statItem);
                }
            }
        }
 private void RunWorkerAsync(IdentifiableName projectId)
 {
     AddBgWork(Lang.BgWork_GetIssue, () =>
         {
             try
             {
                 IssueFormData dataCache = new IssueFormData();
                 List<ClientIssueRelation> currentIssueRelations = new List<ClientIssueRelation>();
                 Issue currentIssue = null;
                 if (type == DialogType.Edit)
                 {
                     NameValueCollection issueParameters = new NameValueCollection { { "include", "journals,relations,children,attachments" } };
                     currentIssue = RedmineClientForm.redmine.GetObject<Issue>(issueId.ToString(), issueParameters);
                     if (currentIssue.ParentIssue != null && currentIssue.ParentIssue.Id != 0)
                     {
                         Issue parentIssue = RedmineClientForm.redmine.GetObject<Issue>(currentIssue.ParentIssue.Id.ToString(CultureInfo.InvariantCulture), null);
                         currentIssue.ParentIssue.Name = parentIssue.Subject;
                     }
                     this.projectId = projectId = currentIssue.Project;
                 }
                 else
                 {
                     // initialize new objects
                     currentIssue = new Issue();
                     currentIssue.Id = 0;
                     currentIssue.Subject = Lang.NewIssue;
                     currentIssue.Attachments = new List<Attachment>();
                 }
                 if (RedmineClientForm.RedmineVersion >= ApiVersion.V13x)
                 {
                     NameValueCollection parameters = new NameValueCollection { { "project_id", projectId.Id.ToString() } };
                     NameValueCollection projectParameters = new NameValueCollection { { "include", "trackers" } };
                     Project project = RedmineClientForm.redmine.GetObject<Project>(projectId.Id.ToString(), projectParameters);
                     dataCache.Trackers = project.Trackers;
                     dataCache.Categories = new List<IssueCategory>(RedmineClientForm.redmine.GetTotalObjectList<IssueCategory>(parameters));
                     dataCache.Categories.Insert(0, new IssueCategory { Id = 0, Name = "" });
                     dataCache.Statuses = RedmineClientForm.redmine.GetTotalObjectList<IssueStatus>(parameters);
                     dataCache.Versions = (List<Redmine.Net.Api.Types.Version>)RedmineClientForm.redmine.GetTotalObjectList<Redmine.Net.Api.Types.Version>(parameters);
                     dataCache.Versions.Insert(0, new Redmine.Net.Api.Types.Version { Id = 0, Name = "" });
                     if (RedmineClientForm.RedmineVersion >= ApiVersion.V14x)
                     {
                         List<ProjectMembership> projectMembers = (List<ProjectMembership>)RedmineClientForm.redmine.GetTotalObjectList<ProjectMembership>(parameters);
                         //RedmineClientForm.DataCache.Watchers = projectMembers.ConvertAll(new Converter<ProjectMembership, Assignee>(MemberToAssignee));
                         dataCache.ProjectMembers = projectMembers.ConvertAll(new Converter<ProjectMembership, ProjectMember>(ProjectMember.MembershipToMember));
                         dataCache.ProjectMembers.Insert(0, new ProjectMember(new ProjectMembership { Id = 0, User = new IdentifiableName { Id = 0, Name = "" } }));
                         if (RedmineClientForm.RedmineVersion >= ApiVersion.V22x)
                         {
                             Enumerations.UpdateIssuePriorities(RedmineClientForm.redmine.GetTotalObjectList<IssuePriority>(null));
                             Enumerations.SaveIssuePriorities();
                         }
                     }
                     if (currentIssue.Relations != null)
                     {
                         foreach (var r in currentIssue.Relations)
                         {
                             // swap id's if neccesary
                             if (r.IssueId != issueId)
                             {
                                 r.IssueToId = r.IssueId;
                                 r.IssueId = issueId;
                                 r.Type = ClientIssueRelation.InvertRelationType(r.Type);
                             }
                             Issue relatedIssue = RedmineClientForm.redmine.GetObject<Issue>(r.IssueToId.ToString(), null);
                             currentIssueRelations.Add(new ClientIssueRelation(r, relatedIssue));
                         }
                     }
                 }
                 return () =>
                     {
                         this.issue = currentIssue;
                         this.issueRelations = currentIssueRelations;
                         this.DataCache = dataCache;
                         FillForm();
                         this.BtnSaveButton.Enabled = true;
                         this.Cursor = Cursors.Default;
                     };
             }
             catch (Exception ex)
             {
                 return () =>
                     {
                         MessageBox.Show(String.Format(Lang.Error_Exception, ex.Message), Lang.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                         this.DialogResult = DialogResult.Cancel;
                         this.Close();
                         this.Cursor = Cursors.Default;
                     };
             }
         });
 }
 private void DeleteItem(IdentifiableName identifiableName)
 {
     enumeration.Remove(identifiableName);
     EnumerationListView.VirtualListSize = enumeration.Count;
 }
 private void AddItem(IdentifiableName identifiableName)
 {
     enumeration.Add(identifiableName);
     EnumerationListView.VirtualListSize = enumeration.Count;
 }
示例#39
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="writer"></param>
 /// <param name="elementName"></param>
 /// <param name="ident"></param>
 public static void WriteIdOrEmpty(this XmlWriter writer, string elementName, IdentifiableName ident)
 {
     writer.WriteElementString(elementName, ident != null ? ident.Id.ToString(CultureInfo.InvariantCulture) : string.Empty);
 }
示例#40
0
        private static void OpenTicket(string dump, DumpData res,
                                       Configuration configuration)
        {
            OwnershipData ownershipData = configuration.Owners.FirstOrDefault(o => o.Filter == res.FilterOfInterest);
            Owner assignee = configuration.DefaultOwner;
            if (ownershipData != null)
            {
                assignee = ownershipData.Owner;
            }

            var author = new IdentifiableName { Id = _redmineManager.GetCurrentUser().Id };
            IdentifiableName assignedTo =
                _projectMembers.SingleOrDefault(pm => pm != null && pm.Name == assignee.Name) ??
                _projectMembers.SingleOrDefault(pm => pm != null && pm.Name == configuration.DefaultOwner.Name);
            if (assignedTo == null)
            {
                // TODO: do something about this?
            }

            string subject = "Unexpected exception occurred";
            string description =
                string.Format("Please investigate a dump located at {0}.{1}{2}Here's the beginning of the call stack for the last event:{3}{4}",
                    dump,
                    Environment.NewLine, Environment.NewLine, Environment.NewLine,
                    string.Join(Environment.NewLine, res.CallStack.Take(Math.Min(res.CallStack.Count, 30))));

            if (res.FrameOfInterest != null)
            {
                subject = string.Format("A problem occurred in {0}.{1}: {2}",
                res.FrameOfInterest.ModuleName, res.FrameOfInterest.MethodName, res.LastEvent.Description);

                description = string.Format("There was a problem in {0}: {1}.{2}Please investigate a dump located at {3}.{4}{5}Here's the call stack for the last event:{6}{7}",
                    res.FrameOfInterest.ModuleName, res.LastEvent, Environment.NewLine,
                    dump,
                    Environment.NewLine, Environment.NewLine, Environment.NewLine,
                    string.Join(Environment.NewLine, res.CallStack.Take(Math.Min(res.CallStack.Count, 30))));
            }

            var issue = new Issue
                {
                    Subject = subject.Substring(0, Math.Min(subject.Length, 255)),
                    Description = description,
                    AssignedTo = assignedTo,
                    Author = author,
                    Project = new IdentifiableName { Id = _project.Id },
                };

            _redmineManager.CreateObject(issue);
        }
示例#41
0
 /// <summary>
 /// Writes the id if not null.
 /// </summary>
 /// <param name="writer">The writer.</param>
 /// <param name="elementName"></param>
 /// <param name="identifiableName"></param>
 public static void WriteIdIfNotNull(this XmlWriter writer, string elementName, IdentifiableName identifiableName)
 {
     if (identifiableName != null)
     {
         writer.WriteElementString(elementName, identifiableName.Id.ToString(CultureInfo.InvariantCulture));
     }
 }
示例#42
0
 public static string CreateUpdatedText(string fieldName, IdentifiableName from, IdentifiableName to)
 {
     return CreateUpdatedText(fieldName, from != null ? from.Name : null, to != null ? to.Name : null);
 }
 private void UpdateItem(IdentifiableName identifiableName, IdentifiableName original)
 {
     foreach (IdentifiableName item in enumeration)
     {
         if (original == item)
         {
             item.Id = identifiableName.Id;
             item.Name = identifiableName.Name;
             EnumerationListView.Invalidate();
             return;
         }
     }
 }
        public IssueForm(Issue issue)
        {
            this.issueId = issue.Id;
            this.projectId = issue.Project;
            this.type = DialogType.Edit;
            InitializeComponent();

            LangTools.UpdateControlsForLanguage(this.Controls);
            LangTools.UpdateControlsForLanguage(contextMenuStripAttachments.Items);
            UpdateTitle(issue);

            BtnDeleteButton.Visible = false;

            EnableDisableAllControls(false);
        }