Exemplo n.º 1
0
        private void FindEqualTimeEntry(UserTimeEntry iUserTimeEntry,
                                        List <UserTimeEntry> listUserTimeEntry, out ExcelUserTimeEntry excelTimeEntry)
        {
            excelTimeEntry = new ExcelUserTimeEntry(iUserTimeEntry.ProjectName, iUserTimeEntry.IssueName,
                                                    iUserTimeEntry.Comment, iUserTimeEntry.ActivityName,
                                                    iUserTimeEntry.HeadName, iUserTimeEntry.DateStart,
                                                    iUserTimeEntry.DateFinish, iUserTimeEntry.Hours);

            int iIndex = 0;

            while (iIndex < listUserTimeEntry.Count)
            {
                UserTimeEntry jUserTimeEntry = listUserTimeEntry[iIndex];
                if ((jUserTimeEntry.ProjectName == iUserTimeEntry.ProjectName) &
                    (jUserTimeEntry.ActivityName == iUserTimeEntry.ActivityName) &
                    (jUserTimeEntry.Value.Id != iUserTimeEntry.Value.Id))
                {
                    if (jUserTimeEntry.DateFinish > excelTimeEntry.DateFinish)
                    {
                        excelTimeEntry.DateFinish = jUserTimeEntry.DateFinish;
                    }
                    excelTimeEntry.Hours = excelTimeEntry.Hours + jUserTimeEntry.Hours;
                }
                iIndex++;
            }
        }
Exemplo n.º 2
0
        private bool isExistExcelTimeEntry(UserTimeEntry userTimeEntry, List <ExcelUserTimeEntry> listExcelTimeEntry)
        {
            bool isEqual = false;

            ExcelUserTimeEntry excelUserTimeEntry = listExcelTimeEntry.Find(x => ((x.ProjectName == userTimeEntry.ProjectName) &
                                                                                  (x.IssueName == userTimeEntry.IssueName) &
                                                                                  (x.Comment == userTimeEntry.Comment) &
                                                                                  (x.ActivityName == userTimeEntry.ActivityName)));

            if (excelUserTimeEntry != null)
            {
                isEqual = true;
            }

            return(isEqual);
        }
Exemplo n.º 3
0
        public void GetTimeEntryFromRedmine()
        {
            redmineData.listUserTimeEntry.Clear();

            NameValueCollection parametr = new NameValueCollection {
                { "user_id", "*" }
            };

            foreach (var time in redmineManager.GetObjects <TimeEntry>(parametr))
            {
                Project project = redmineData.listProject.Find(x => (x.Id == time.Project.Id));
                if (project != null)
                {
                    UserTimeEntry userTimeEntry = new UserTimeEntry(time, redmineData.listIssue, redmineData.listUser);
                    redmineData.listUserTimeEntry.Add(userTimeEntry);
                }
            }
        }
Exemplo n.º 4
0
        public void GetExcelTimeEntry(UserRedmine userRedmine)
        {
            userRedmine.listExcelUserTimeEntry.Clear();

            int iIndex = 0;

            while (iIndex < userRedmine.listMounthUserTimeEntry.Count)
            {
                UserTimeEntry iUserTimeEntry = userRedmine.listMounthUserTimeEntry[iIndex];
                if (!isExistExcelTimeEntry(iUserTimeEntry, userRedmine.listExcelUserTimeEntry))
                {
                    ExcelUserTimeEntry excelUserTimeEntry = null;
                    FindEqualTimeEntry(iUserTimeEntry, userRedmine.listMounthUserTimeEntry, out excelUserTimeEntry);

                    if (excelUserTimeEntry != null)
                    {
                        userRedmine.listExcelUserTimeEntry.Add(excelUserTimeEntry);
                    }
                }
                iIndex++;
            }
        }
Exemplo n.º 5
0
        public void MakeReportIssue()
        {
            listProjectInfo.Clear();

            foreach (LoadProject loadProject in listLoadProject)
            {
                ProjectInfo projectInfo = new ProjectInfo();
                projectInfo.ProjectName = loadProject.userProject.Name;

                foreach (LoadIssue loadIssue in loadProject.listLoadOpenIssue)
                {
                    UserTimeEntry userTimeEntry = redmineData.listUserTimeEntry.Find(x => (x.time.Issue != null) &&
                                                                                     (x.time.Issue.Id == loadIssue.issue.Id));
                    if (userTimeEntry != null)
                    {
                        double factHours = (double)userTimeEntry.time.Hours;

                        double estimatedHours = 0;
                        if (loadIssue.issue.EstimatedHours != null)
                        {
                            estimatedHours = (float)loadIssue.issue.EstimatedHours;
                        }

                        double delta = factHours - estimatedHours * (float)loadIssue.issue.DoneRatio;
                        if (delta >= estimatedHours * 0.1)
                        {
                            projectInfo.Info += "На задачу http://188.242.201.77/issues/" + loadIssue.issue.Id.ToString() +
                                                " по оценке % выполненных работ % составляет " + estimatedHours.ToString("0") + "\n" +
                                                "по оценке фактических затрат составляет " + factHours.ToString("0") + "\n" +
                                                "задержка составляет " + delta.ToString("0") + "\n";
                        }
                    }
                }
                listProjectInfo.Add(projectInfo);
            }
        }
Exemplo n.º 6
0
        public void GetUserFromRedmine(Dictionary <string, string> bossName) //params string[] noNameForReport)
        {
            NameValueCollection parametr;

            countTotalRecord = 0;
            curReadRecord    = 0;

            ClearLists();

            progressBar.InvokeIfNeeded(delegate { progressBar.DisplayStyle = ProgressBarDisplayText.CustomText; });
            progressBar.InvokeIfNeeded(delegate { progressBar.CustomText = "Загрузка записей, подождите пожалуйста."; });
            progressBar.InvokeIfNeeded(delegate { progressBar.Minimum = 0; });


            //SetInitProgBar(progressBar, 0, 5, 1);

            try
            {
                //parametr = new NameValueCollection { { "user_id", "*" } };
                //countTotalRecord += redmineManager.GetObjects<User>(parametr).Count;
                //progressBar.InvokeIfNeeded(delegate { progressBar.PerformStep(); });
                //progressBar.InvokeIfNeeded(delegate { progressBar.CustomText = "Список № " + progressBar.Value + "/5"; });

                //parametr = new NameValueCollection { { "group_id", "*" } };
                //countTotalRecord += redmineManager.GetObjects<Group>(parametr).Count;
                //progressBar.InvokeIfNeeded(delegate { progressBar.PerformStep(); });
                //progressBar.InvokeIfNeeded(delegate { progressBar.CustomText = "Список № " + progressBar.Value + "/5"; });

                //parametr = new NameValueCollection { { "status_id", "*" } };
                //countTotalRecord += redmineManager.GetObjects<Issue>(parametr).Count;
                //progressBar.InvokeIfNeeded(delegate { progressBar.PerformStep(); });
                //progressBar.InvokeIfNeeded(delegate { progressBar.CustomText = "Список № " + progressBar.Value + "/5"; });

                //parametr = new NameValueCollection { { "project_id", "*" } };
                //countTotalRecord += redmineManager.GetObjects<Project>(parametr).Count;
                //progressBar.InvokeIfNeeded(delegate { progressBar.PerformStep(); });
                //progressBar.InvokeIfNeeded(delegate { progressBar.CustomText = "Список № " + progressBar.Value + "/5"; });

                //parametr = new NameValueCollection { { "user_id", "*" } };
                //countTotalRecord += redmineManager.GetObjects<TimeEntry>(parametr).Count;
                //progressBar.InvokeIfNeeded(delegate { progressBar.PerformStep(); });
                //progressBar.InvokeIfNeeded(delegate { progressBar.CustomText = "Список № " + progressBar.Value + "/5"; });

                //progressBar.InvokeIfNeeded(delegate { progressBar.Value = 0; });
                //progressBar.InvokeIfNeeded(delegate { progressBar.Maximum = countTotalRecord; });
                //progressBar.InvokeIfNeeded(delegate { progressBar.Step = 1; });

                parametr = new NameValueCollection {
                    { "user_id", "*" }
                };
                List <User> listUserRedm = redmineManager.GetObjects <User>(parametr);

                countTotalRecord = listUserRedm.Count;
                SetInitProgBar(progressBar, 0, countTotalRecord, 1);
                foreach (var user in listUserRedm)
                {
                    if (user.IsCustomFieldEqual("Учет трудозатратах/месяц"))
                    {
                        listUser.Add(user);
                        //userRedmine.listIssue = this.listIssue;

                        UserRedmine userRedmine = new UserRedmine(this.monthValueHours);
                        userRedmine.bossName    = bossName;
                        userRedmine.Value       = user;
                        userRedmine.listProject = this.listProject;

                        curReadRecord++;
                        progressBar.InvokeIfNeeded(delegate { progressBar.PerformStep(); });
                        progressBar.InvokeIfNeeded(delegate
                        {
                            progressBar.CustomText = "Запись № " + progressBar.Value +
                                                     "/ " + countTotalRecord;
                        });

                        listUserRedmine.Add(userRedmine);

                        Debug.WriteLine(curReadRecord);
                    }


                    //parametr = new NameValueCollection { { "user_id", user.Id.ToString() } };
                    //int count = redmineManager.GetObjects<TimeEntry>(parametr).Count;
                    //if (count > 0)
                    //{
                    //    UserRedmine userRedmine = new UserRedmine();
                    //    userRedmine.Value = user;
                    //    listUserRedmine.Add(userRedmine);
                    //    Console.WriteLine("Name = {0}, Count time entry = {1}", user.LastName, count);
                    //}
                }

                parametr = new NameValueCollection {
                    { "group_id", "*" }
                };
                List <Group> listGroupRedm = redmineManager.GetObjects <Group>(parametr);

                countTotalRecord = listGroupRedm.Count;
                SetInitProgBar(progressBar, 0, countTotalRecord, 1);
                foreach (Group group in listGroupRedm)
                {
                    curReadRecord++;
                    progressBar.InvokeIfNeeded(delegate { progressBar.PerformStep(); });
                    progressBar.InvokeIfNeeded(delegate
                    {
                        progressBar.CustomText = "Запись № " + progressBar.Value +
                                                 "/ " + countTotalRecord;
                    });


                    UserGroup userGroup = new UserGroup(group.Name, group.Id);
                    listUserRedm = redmineManager.GetObjects <User>(new NameValueCollection {
                        { "group_id", group.Id.ToString() }
                    });
                    foreach (User user in listUserRedm)
                    {
                        UserRedmine userRedmine = listUserRedmine.Find(x => x.Value.Id == user.Id);
                        if (userRedmine != null)
                        {
                            userRedmine.listUserGroup.Add(userGroup);
                        }
                    }
                }

                //parametr = new NameValueCollection { { "status_id", "*" } };//{ "status_id", "*" }
                //Issue issueIdRedm = redmineManager.GetObject<Issue>("1435", parametr);

                Issue issue_jornals = redmineManager.GetObject <Issue>("1435", new NameValueCollection {
                    { "include", "journals" }
                });
                if (issue_jornals != null)
                {
                    foreach (var journal in issue_jornals.Journals)
                    {
                        string note = journal.Notes;
                        if (!note.Equals(""))
                        {
                            MonthHours monthHours = new MonthHours(note);
                            listMonthHours.Add(monthHours);
                        }
                    }
                }

                parametr = new NameValueCollection {
                    { "created_on", ">=" + GetFirstDateCurYear() }
                };                                                                                    //{ "status_id", "*" }

                List <Issue> listIssueRedm = redmineManager.GetObjects <Issue>(parametr);

                countTotalRecord = listIssueRedm.Count;
                SetInitProgBar(progressBar, 0, countTotalRecord, 1);
                foreach (Issue issue in listIssueRedm)
                {
                    listIssue.Add(issue);
                    curReadRecord++;
                    progressBar.InvokeIfNeeded(delegate { progressBar.PerformStep(); });
                    progressBar.InvokeIfNeeded(delegate
                    {
                        progressBar.CustomText = "Запись № " + progressBar.Value +
                                                 "/ " + countTotalRecord;
                    });
                    Debug.WriteLine(curReadRecord);
                    Debug.WriteLine(issue.CreatedOn.Value);
                    //if (issue.Id == 1435)
                    //{
                    //    Issue issue_jornals = redmineManager.GetObject<Issue>(issue.Id.ToString(),
                    //                                                          new NameValueCollection { { "include", "journals" } });

                    //    foreach (var journal in issue_jornals.Journals)
                    //    {
                    //        string note = journal.Notes;
                    //        if (!note.Equals(""))
                    //        {
                    //            MonthHours monthHours = new MonthHours(note);
                    //            listMonthHours.Add(monthHours);
                    //        }
                    //    }
                    //}
                }

                parametr = new NameValueCollection {
                    { "project_id", "*" }
                };
                List <Project> listProjectRedm = redmineManager.GetObjects <Project>(parametr);

                countTotalRecord = listProjectRedm.Count;
                SetInitProgBar(progressBar, 0, countTotalRecord, 1);
                foreach (Project project in listProjectRedm)
                {
                    listProject.Add(project);
                    curReadRecord++;
                    progressBar.InvokeIfNeeded(delegate { progressBar.PerformStep(); });
                    progressBar.InvokeIfNeeded(delegate
                    {
                        progressBar.CustomText = "Запись № " + progressBar.Value +
                                                 "/ " + countTotalRecord;
                    });
                }


                parametr = new NameValueCollection {
                    { "spent_on", ">=" + GetFirstDateCurYear() }
                };                                                                                  //{ "user_id", "*" }
                List <TimeEntry> listTimeEntryRedm = redmineManager.GetObjects <TimeEntry>(parametr);

                //List<TimeEntry> listTimeEntryUnique = new List<TimeEntry>();

                TimeEntry timeUniqe;

                for (int i = 0; i < listTimeEntryRedm.Count; i++)
                {
                    TimeEntry timeI = listTimeEntryRedm[i];
                    timeUniqe = timeI;

                    int j = i + 1;
                    while (j < listTimeEntryRedm.Count)
                    {
                        TimeEntry timeJ = listTimeEntryRedm[j];
                        if ((timeI.User.Id == timeJ.User.Id) &
                            (timeI.Project.Id == timeJ.Project.Id) &
                            (timeI.Activity.Id == timeJ.Activity.Id) &
                            (timeI.Id != timeJ.Id) &
                            (timeI.SpentOn.Value.Date.Month == timeJ.SpentOn.Value.Date.Month))
                        {
                            // TODO добавить поиск даты старта и даты финиша суммарной задчи timeI
                            DateTime startDateTimeI  = timeI.GetDateValue("Дата старта", TypeDates.Start);
                            DateTime finishDateTimeI = timeI.GetDateValue("Дата завершения", TypeDates.Finish);

                            DateTime startDateTimeJ  = timeJ.GetDateValue("Дата старта", TypeDates.Start);
                            DateTime finishDateTimeJ = timeJ.GetDateValue("Дата завершения", TypeDates.Finish);

                            if (startDateTimeI.CompareTo(startDateTimeJ) > 0)
                            {
                                timeI.SetDateValue("Дата старта", startDateTimeJ);
                            }

                            if (finishDateTimeI.CompareTo(finishDateTimeJ) < 0)
                            {
                                timeI.SetDateValue("Дата завершения", finishDateTimeJ);
                            }

                            timeI.Hours += timeJ.Hours;
                            listTimeEntryRedm.Remove(timeJ);
                        }
                        else
                        {
                            j++;
                        }
                    }
                }

                countTotalRecord = listTimeEntryRedm.Count;
                SetInitProgBar(progressBar, 0, countTotalRecord, 1);

                var qTimeEntryAll = from time in listTimeEntryRedm
                                    from userRedmine in listUserRedmine
                                    from project in listProject
                                    where time.User.Id == userRedmine.Value.Id
                                    where ((time.Project.Id == project.Id) & project.IsPublic)
                                    select new
                {
                    listIssue   = userRedmine.listIssue,
                    listProject = userRedmine.listProject,
                    userRedmine = userRedmine,
                    listUser    = listUser,
                    Value       = time
                };

                foreach (var time in qTimeEntryAll)
                {
                    UserTimeEntry userTimeEntry = new UserTimeEntry(time.listIssue, time.listProject,
                                                                    time.userRedmine, time.listUser);
                    userTimeEntry.Value = time.Value;
                    time.userRedmine.listUserTimeEntry.Add(userTimeEntry);
                }

                //foreach (var time in listTimeEntryRedm)
                //{
                //    UserRedmine userRedmine = listUserRedmine.Find(x => x.Value.Id == time.User.Id);
                //    Project project = listProject.Find(x => x.Id == time.Project.Id);
                //    curReadRecord++;
                //    progressBar.InvokeIfNeeded(delegate { progressBar.PerformStep(); });
                //    progressBar.InvokeIfNeeded(delegate {progressBar.CustomText = "Запись № " + progressBar.Value +
                //                                        "/ " + countTotalRecord;
                //    });
                //    if (userRedmine != null)
                //    {
                //        if (project != null)
                //        {
                //            if (project.IsPublic)
                //            {
                //                UserTimeEntry userTimeEntry = new UserTimeEntry(userRedmine.listIssue, userRedmine.listProject,
                //                                                                userRedmine, listUser);
                //                userTimeEntry.Value = time;
                //                userRedmine.listUserTimeEntry.Add(userTimeEntry);
                //            }
                //        }
                //    }
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error - " + ex.Message);
            }

            listUserRedmine.Sort();
        }
Exemplo n.º 7
0
        public int CompareTo(object obj)
        {
            UserTimeEntry userTimeEntry = obj as UserTimeEntry;

            return(this.DateStart.CompareTo(userTimeEntry.DateStart));
        }