private void TasksUpdates()
        {
            Outlook.NameSpace   namespce = null;
            Outlook.Items       tasks    = null;
            Outlook.Application oApp     = new Outlook.Application();
            namespce = oApp.GetNamespace("MAPI");
            tasks    = namespce.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks).Items;
            string temp    = string.Empty;
            string tmpRedm = string.Empty;
            bool   isExist = false;
            string AddedTastFromOutlook = string.Empty;

            foreach (Issue issue in manager.GetObjectList <Issue>(new NameValueCollection()))
            {
                foreach (Outlook.TaskItem task in tasks)
                {
                    if (task.Subject == issue.Subject)
                    {
                        if ((DateTime)issue.UpdatedOn > task.LastModificationTime)
                        {
                            UpdateOneTask(task, issue);
                        }
                        isExist = true;
                        continue;
                    }

                    temp += $"{task.Body}+{Environment.NewLine}";
                    bool isCompleeted = task.Complete;                    //Check if your task is compleeted in your application you could use EntryID property to identify a task
                    if (isCompleeted == true && task.Status != OlTaskStatus.olTaskComplete)
                    {
                        task.MarkComplete();
                        task.Save();
                    }

                    isExist = false;
                }
                if (isExist)
                {
                    Outlook.TaskItem task = null;

                    task           = (Outlook.TaskItem) this.Application.CreateItem(Outlook.OlItemType.olTaskItem);
                    task.Subject   = "Review site design";
                    task.StartDate = DateTime.Now;
                    task.DueDate   = DateTime.Now.AddDays(2);
                    task.Status    = Outlook.OlTaskStatus.olTaskNotStarted;
                    task.Save();
                    //newTaskItem.StartDate = (DateTime)issue.StartDate;
                    //newTaskItem.DueDate = (DateTime)issue.DueDate;
                    //AddedTastFromOutlook += $"{newTaskItem.Subject}+{Environment.NewLine}";

                    //Create a issue.
                }
            }

            MessageBox.Show("NewTAsk  " + AddedTastFromOutlook);
        }
        static void Main()
        {
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new FormTest());

            string host   = "http://redmine.binhanh.com.vn:89/redmine";
            string apiKey = "buVJbgHAfzFtfDpyQVuo";

            var manager = new RedmineManager(host, "admin", "admin^CMt3,$Dq>%:@GN/");

            var parameters = new NameValueCollection {
                { "status_id", "*" }
            };

            foreach (var issue in manager.GetObjectList <Issue>(parameters))
            {
                Console.WriteLine("#{0}: {1}", issue.Id, issue.Subject);
            }

            var parameters_custom_fields = new NameValueCollection {
                { "custom_field", "*" }
            };

            foreach (var issue in manager.GetObjectList <CustomField>(parameters_custom_fields))
            {
                Console.WriteLine("#{0}: {1}", issue.Id, issue.Values);
            }
            //List customFieldsList = mgr.getIssues(projectKey, queryId).get(0).getCustomFields();

            //for (CustomField customField in manager.)
            //{
            //    System.out.println(customField.getName());
            //    if (customField.getName().equalsIgnoreCase("MyDate"))
            //    {
            //        customField.setValue("2012-08-02");
            //    }
            //}

            //    CustomField ThuocNhom = new CustomField();
            //ThuocNhom.
            //Create a issue.
            var newIssue = new Issue {
                Subject = "test",
                Project = new IdentifiableName {
                    Id = 1
                }
            };

            manager.CreateObject(newIssue);
        }
        public static List <T> GetAllObjectList <T>(this RedmineManager manager, NameValueCollection parameters = null) where T : class, new()
        {
            if (parameters == null)
            {
                parameters = new NameValueCollection();
            }

            IList <T> redmineAllRecordsResult;
            List <T>  allRecords = new List <T>();

            int limit  = 100;
            int offset = 0;

            do
            {
                parameters["offset"] = offset.ToString();
                parameters["limit"]  = limit.ToString();

                redmineAllRecordsResult = manager.GetObjectList <T>(parameters);
                allRecords.AddRange(redmineAllRecordsResult);

                offset += redmineAllRecordsResult.Count;
            }while (redmineAllRecordsResult.Count == limit);

            return(allRecords);
        }
        public bool Create()
        {
            try
            {
                RedmineManager manager = new RedmineManager(Configuration.RedmineHost,
                    Configuration.RedmineUser, Configuration.RedminePassword);

                //Create a issue.
                var newIssue = new Issue
                {
                    Subject = Title,
                    Description = Description,
                    Project = new IdentifiableName() { Id = ProjectId },
                    Tracker = new IdentifiableName() { Id = TrackerId }
                };

                User thisuser = (from u in manager.GetObjectList<User>(new System.Collections.Specialized.NameValueCollection())
                                 where u.Login == Configuration.RedmineUser
                                 select u).FirstOrDefault();
                if (thisuser != null)
                    newIssue.AssignedTo = new IdentifiableName() { Id = thisuser.Id };

                manager.CreateObject(newIssue);
            }
            catch { return false; }
            return true;
        }
Example #5
0
        public void RedmineProjectVersions_ShouldGetSpecificProjectVersions()
        {
            var versions = redmineManager.GetObjectList <Redmine.Net.Api.Types.Version>(new NameValueCollection {
                { "project_id", projectId }
            });

            Assert.IsTrue(versions.Count == numberOfVersions);
        }
Example #6
0
        public void RedmineUser_ShouldReturnAllUsers()
        {
            IList <User> users = redmineManager.GetObjectList <User>(new NameValueCollection {
                { "include", "groups" }, { "include", "memberships" }
            });

            Assert.IsTrue(users.Count == 3);
        }
        public void RedmineIssueCategories_ShouldGetAllIssueCategories()
        {
            var issueCategories = redmineManager.GetObjectList <IssueCategory>(new NameValueCollection {
                { "project_id", projectId }
            });

            Assert.IsNotNull(issueCategories);
        }
Example #8
0
        public void RedmineUser_ShouldReturnAllUsers()
        {
            IList <User> users = redmineManager.GetObjectList <User>(new NameValueCollection {
                { "include", "groups,memberships" }
            });

            Assert.IsNotNull(users);
        }
        public void RedmineIssueRelation_ShouldReturnRelationsByIssueId()
        {
            var relations = redmineManager.GetObjectList <IssueRelation>(new NameValueCollection {
                { "issue_id", "19" }
            });

            Assert.IsNotNull(relations);
        }
Example #10
0
        public void RedmineProjectMembership_ShouldGetAllByProject()
        {
            var projectMemberships = redmineManager.GetObjectList <ProjectMembership>(new NameValueCollection {
                { "project_id", projectId }
            });

            Assert.IsNotNull(projectMemberships);
        }
 public void fetchIssues()
 {
     if (this.manager != null)
     {
         try
         {
             var parameters = new NameValueCollection {
                 { "assigned_to_id", "me" }
             };
             parameters.Add("status_id", "open");
             this.Issues = manager.GetObjectList <Issue>(parameters);
         }
         catch (RedmineException e)
         {
             Console.WriteLine("ERROR : " + e.Message);
         }
     }
 }
Example #12
0
        public void GetProject_News()
        {
            var result = redmineManager.GetObjectList <News>(new NameValueCollection()
            {
                { "project_id", projectId }
            });

            Assert.IsNotNull(result);
        }
Example #13
0
        public void RedmineIssueCategories_ShouldGetAllIssueCategories()
        {
            string projectId = "9";

            var issueCategories = redmineManager.GetObjectList <IssueCategory>(new NameValueCollection {
                { "project_id", projectId }
            });

            Assert.IsTrue(issueCategories.Count == 1);
        }
        public void RedmineProjectVersions_ShouldGetSpecificProjectVersions()
        {
            int projectId = 6;

            var versions = redmineManager.GetObjectList <Redmine.Net.Api.Types.Version>(new NameValueCollection {
                { "project_id", projectId.ToString() }
            });

            Assert.IsTrue(versions.Count == 3);
        }
Example #15
0
        public static Dictionary<string, int> GetTrackers()
        {
            RedmineManager manager = new RedmineManager(Configuration.RedmineHost,
                Configuration.RedmineUser, Configuration.RedminePassword);
            Dictionary<string, int> Trackers = new Dictionary<string, int>();

            foreach (Tracker track in manager.GetObjectList<Tracker>(new NameValueCollection()))
            {
                Trackers.Add(track.Name, track.Id);
            }
            return Trackers;
        }
Example #16
0
        public static Dictionary<string, int> GetProjects()
        {
            RedmineManager manager = new RedmineManager(Configuration.RedmineHost,
                Configuration.RedmineUser, Configuration.RedminePassword);
            Dictionary<string, int> Projects = new Dictionary<string, int>();

            foreach (Project proj in manager.GetObjectList<Project>(new NameValueCollection()))
            {
                Projects.Add(proj.Name, proj.Id);
            }
            return Projects;
        }
Example #17
0
        public void UpdateIssue()
        {
            while (!ExtPing.GetPingHostResult("p.honestwalker.com"))
            {
                Thread.Sleep(1000);
            }
            var issues = _manager.GetObjectList <Issue>(paraAssignedToMe);

            CurrentResult.MyIssues = issues.ToList();
            IsSync = true;
            StartScheduledUpdate();
        }
Example #18
0
        public static Dictionary <string, int> GetProjects()
        {
            RedmineManager manager = new RedmineManager(Configuration.RedmineHost,
                                                        Configuration.RedmineUser, Configuration.RedminePassword);
            Dictionary <string, int> Projects = new Dictionary <string, int>();

            foreach (Project proj in manager.GetObjectList <Project>(new NameValueCollection()))
            {
                Projects.Add(proj.Name, proj.Id);
            }
            return(Projects);
        }
Example #19
0
        public static Dictionary <string, int> GetTrackers()
        {
            RedmineManager manager = new RedmineManager(Configuration.RedmineHost,
                                                        Configuration.RedmineUser, Configuration.RedminePassword);
            Dictionary <string, int> Trackers = new Dictionary <string, int>();

            foreach (Tracker track in manager.GetObjectList <Tracker>(new NameValueCollection()))
            {
                Trackers.Add(track.Name, track.Id);
            }
            return(Trackers);
        }
        /// <summary>
        /// Метод ,создающий задачу в Redmine.
        /// </summary>
        /// <param name="newTaskItem"></param>
        private void CreateNewTaskRedmine(TaskItem newTaskItem)
        {
            //To Do
            //Здесь нужно будет сделать выбор текущего проекта в Redmine
            int id = 1;

            foreach (Project proj in manager.GetObjectList <Project>(new NameValueCollection()))
            {
                if (proj.Name == RedmineOutlookAddIn.Properties.Settings.Default.CurrentFolder)
                {
                    id = proj.Id;
                }
            }

            var newIssue = new Issue
            {
                Subject = newTaskItem.Subject,
                //по умолчанию добавляется в первый проект,он будет текущим(их может быть несколько и у каждого есть свой номер)
                Project = new IdentifiableName {
                    Id = 1
                },
                //Tracker = new IdentifiableName { Name = "Bug" },
                //Status = new IdentifiableName { Name = "New" },
                //Priority = new IdentifiableName { Name = "Normal" },
                Description = newTaskItem.Body,
                StartDate   = newTaskItem.StartDate
            };

            if (newTaskItem.DueDate != null)
            {
                newIssue.DueDate = newTaskItem.DueDate;
            }
            MessageBox.Show($"Задача создана ***{newTaskItem.Subject}***{Environment.NewLine} в папке ***{CustomFolder.Name}*** ");
            //Добавляем такску в Redmine
            manager.CreateObject(newIssue);
        }
Example #21
0
        public bool Create()
        {
            try
            {
                RedmineManager manager = new RedmineManager(Configuration.RedmineHost,
                                                            Configuration.RedmineUser, Configuration.RedminePassword);

                //Create a issue.
                var newIssue = new Issue
                {
                    Subject     = Title,
                    Description = Description,
                    Project     = new IdentifiableName()
                    {
                        Id = ProjectId
                    },
                    Tracker = new IdentifiableName()
                    {
                        Id = TrackerId
                    }
                };

                User thisuser = (from u in manager.GetObjectList <User>(new System.Collections.Specialized.NameValueCollection())
                                 where u.Login == Configuration.RedmineUser
                                 select u).FirstOrDefault();
                if (thisuser != null)
                {
                    newIssue.AssignedTo = new IdentifiableName()
                    {
                        Id = thisuser.Id
                    }
                }
                ;

                manager.CreateObject(newIssue);
            }
            catch { return(false); }
            return(true);
        }
Example #22
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            JasonInformations info = new JasonInformations();

            var manager = new RedmineManager(info.host, textBoxUser.Text, passwordBox.Password);
            var parameters = new NameValueCollection { { "status_id", "*" }, { "limit", "100" } };

            try
            {
                var test = manager.GetObjectList<Issue>(parameters).ToList();
                MainWindow win2 = new MainWindow();
                win2.manager = manager;
                win2.subject = info.subject;
                win2.list = test;
                win2.info = info.destinatari;
                win2.Show();
                this.Close();
            }
            catch (Exception )
            {
                labelErrore.Visibility = Visibility.Visible;
                this.Show();
            }
        }
Example #23
0
        public void RedmineTrackers_ShouldGetAllTrackers()
        {
            var trackers = redmineManager.GetObjectList <Tracker>(null);

            Assert.IsTrue(trackers.Count == numberOfTrackers);
        }
Example #24
0
        public void RedmineQuery_ShouldGetAllQueries()
        {
            var queries = redmineManager.GetObjectList <Query>(null);

            Assert.IsTrue(queries.Count == 3);
        }
        public void RedmineTimeEntries_ShouldGetAll()
        {
            var timeEntries = redmineManager.GetObjectList <TimeEntry>(null);

            Assert.IsNotNull(timeEntries);
        }
Example #26
0
        public static Task GetChangesFromRedmine()
        {
            return(Task.Run(() =>
            {
                var parameters = new NameValueCollection {
                    { "include", "relations" }
                };
                var redProject = rm.GetObject <Project>("50", parameters);
                var versions = rm.GetObjectList <Redmine.Net.Api.Types.Version>(new NameValueCollection
                {
                    { "include", "relations" },
                    { "project_id", redProject.Id.ToString() }
                }).ToList();

                versions = versions.Where(v => v.DueDate > DateTime.Now.Subtract(TimeSpan.FromDays(1))).OrderBy(v => v.DueDate).ToList();

                Redmine.Net.Api.Types.Version selectedVersion = null;
                Application.Current.Dispatcher.Invoke(() =>
                {
                    var pickVersion = new SelectVersion(versions);
                    pickVersion.Owner = MainWindow.Instance;
                    pickVersion.ShowDialog();

                    selectedVersion = pickVersion.Version;
                    RedmineVersion = pickVersion.Version.Name;
                });

                rm.PageSize = 9998;
                int offset = 0;
                issues = rejectedIssues = designTickets = new List <Issue>();
                var issues_ =
                    rm.GetObjectList <Issue>(new NameValueCollection
                {
                    { "include", "relations" },
                    { "status_id", "5" },
                    { "project_id", redProject.Id.ToString() },
                    { "fixed_version_id", selectedVersion.Id.ToString() }
                });

                while (issues_.Count > 0)
                {
                    issues = issues.Concat(issues_).ToList();
                    offset += 25;
                    issues_ =
                        rm.GetObjectList <Issue>(new NameValueCollection
                    {
                        { "include", "relations" },
                        { "status_id", "5" },
                        { "offset", offset.ToString() },
                        { "project_id", redProject.Id.ToString() },
                        { "fixed_version_id", selectedVersion.Id.ToString() }
                    });
                }
                if (issues.Any(i => i.Tracker.Id == 4))
                {
                    designTickets = issues.Where(i => i.Tracker.Id == 4).ToList();
                    issues = issues.Where(i => i.Tracker.Id != 4).ToList();
                }

                //rejected
                offset = 0;
                _rejectedIssues = new List <Issue>();
                issues_ =
                    rm.GetObjectList <Issue>(new NameValueCollection
                {
                    { "include", "relations,journals" },
                    { "status_id", "6" },
                    { "project_id", redProject.Id.ToString() },
                    { "fixed_version_id", selectedVersion.Id.ToString() }
                });

                while (issues_.Count > 0)
                {
                    rejectedIssues = rejectedIssues.Concat(issues_).ToList();
                    offset += 25;
                    issues_ =
                        rm.GetObjectList <Issue>(new NameValueCollection
                    {
                        { "include", "relations,journals" },
                        { "status_id", "6" },
                        { "offset", offset.ToString() },
                        { "project_id", redProject.Id.ToString() },
                        { "fixed_version_id", selectedVersion.Id.ToString() }
                    });
                }

                var issuesWithoutSupport = issues;
                _supportIssuesCount = 0;
                issues = new List <Issue>();
                foreach (var iss in issuesWithoutSupport)
                {
                    if (iss.Tracker != null && iss.Tracker.Id != 3)
                    {
                        issues.Add(iss);
                    }
                    else
                    {
                        _supportIssuesCount++;
                    }
                }
            }));
        }
Example #27
0
 private Boolean connectRedmine(String url)
 {
     try
     {
         var parameters = new NameValueCollection { { "name", "*" } };
         redmine = new RedmineManager(url, parser.apiKey);
         redmine.GetObjectList<Project>(parameters);
         return true;
     }
     catch (RedmineException error)
     {
         Console.WriteLine(error);
         return false;
     }
 }
Example #28
0
        public void RedmineIssuePriorities_ShouldGetAllIssuePriorities()
        {
            var issuePriorities = redmineManager.GetObjectList <IssuePriority>(null);

            Assert.IsNotNull(issuePriorities);;
        }
        public void GetAllGroups()
        {
            var result = redmineManager.GetObjectList <Group>(null);

            Assert.IsNotNull(result);
        }
Example #30
0
 public IList <Project> getProjects(NameValueCollection parameters)
 {
     return(_manager.GetObjectList <Project>(parameters));
 }
Example #31
0
        public void RedmineIssuePriorities_ShouldGetAllIssuePriorities()
        {
            var issuePriorities = redmineManager.GetObjectList <IssuePriority>(null);

            Assert.IsTrue(issuePriorities.Count == 4);
        }
        public void RedmineCustomFields_ShouldGetAllCustomFields()
        {
            var customFields = redmineManager.GetObjectList <CustomField>(null);

            Assert.IsNotNull(customFields);
        }
Example #33
0
        public void RedmineIssueStatuses_ShouldGetAllIssueStatuses()
        {
            var issueStatuses = redmineManager.GetObjectList <IssueStatus>(null);

            Assert.IsNotNull(issueStatuses);
        }
Example #34
0
        public void RedmineRoles_ShouldGetAllRoles()
        {
            var roles = redmineManager.GetObjectList <Role>(null);

            Assert.IsTrue(roles.Count == numberOfRoles);
        }
        public void RedmineTimeEntryActivities_ShouldGetAllTimeEntryActivities()
        {
            var timeEntryActivities = redmineManager.GetObjectList <TimeEntryActivity>(null);

            Assert.IsTrue(timeEntryActivities.Count == numberOfTimeEntryActivities);
        }