Esempio n. 1
0
 /// <summary>
 /// Method to delete an object by its name
 /// </summary>
 /// <param name="objectIdentifier">the identifier of the object</param>
 /// <param name="nameValueCollection">the name value collection</param>
 public void DeleteTimeEntry(int?objectIdentifier, DataSourceParameter nameValueCollection)
 {
     if (objectIdentifier != null)
     {
         this._timeEntries.RemoveAll(new Predicate <TimeEntryInfo>(i => i.Id == objectIdentifier));
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Method to delete an object by its name
 /// </summary>
 /// <param name="objectIdentifier">the identifier of the object</param>
 /// <param name="parameters">the name value collection</param>
 public void DeleteTimeEntry(int?objectIdentifier, DataSourceParameter parameters)
 {
     if (objectIdentifier.HasValue)
     {
         try
         {
             this._redmineApi.DeleteObject <TimeEntry>(objectIdentifier.ToString(), this.GetParametersForQuery(parameters));
         }
         catch (RedmineException redmineException)
         {
             if (redmineException.Message.Equals("Not Found"))
             {
                 // nothing to do, the item does no longer exist in redmine, so we can delete it in the application
             }
             else
             {
                 var typeNumber = redmineException.HResult;
                 if (redmineException.Message.Contains("Die zugrunde liegende Verbindung wurde geschlossen"))
                 {
                     throw new ConnectionException(redmineException)
                           {
                               IdentifierNumber = typeNumber
                           };
                 }
                 else
                 {
                     throw new CrudException(OperationType.Delete, null, redmineException)
                           {
                               IdentifierNumber = typeNumber
                           };
                 }
             }
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Method to get the total object list of all time entries
        /// </summary>
        /// <param name="parameters">the parameters</param>
        /// <param name="statusCallback">a statusCallback to be run after the list is obtained</param>
        /// <returns>the list containing all objects</returns>
        public IList <TimeEntryInfo> GetTotalTimeEntryInfoList(DataSourceParameter parameters, Action <int, int> statusCallback = null)
        {
            var timeEntries    = this._redmineApi.GetTotalObjectList <TimeEntry>(this.GetParametersForQuery(parameters), statusCallback);
            var timeEntryInfos = timeEntries.Select(
                te =>
            {
                var timeOfAction = te.SpentOn.Value.Date;
                var customFields = te.CustomFields;
                var startField   = customFields.FirstOrDefault(f => f.Name == "Start");
                if (startField != null)
                {
                    var startText      = startField.Values.First().Info;
                    var startTextSplit = startText.Split(':');
                    if (startTextSplit.Length == 2)
                    {
                        var minutes         = 0;
                        var hours           = 0;
                        var parseSuccessful = int.TryParse(startTextSplit[1], out minutes) && int.TryParse(startTextSplit[0], out hours);

                        if (parseSuccessful)
                        {
                            var startDateTime = timeOfAction.AddHours(hours).AddMinutes(minutes);

                            var info = new TimeEntryInfo()
                            {
                                Id            = te.Id,
                                Name          = te.Comments,
                                UpdateTime    = te.UpdatedOn.Value,
                                StartDateTime = startDateTime,
                                EndDateTime   = startDateTime.AddHours((double)te.Hours),
                                IssueInfo     =
                                    new IssueInfo()
                                {
                                    Id               = te.Issue.Id,
                                    Name             = te.Issue.Name,
                                    ProjectId        = te.Project.Id,
                                    ProjectShortName = te.Project.Name
                                },
                                ActivityInfo = new ActivityInfo()
                                {
                                    Id = te.Activity.Id, Name = te.Activity.Name
                                },
                                ProjectInfo = new ProjectInfo()
                                {
                                    Id = te.Project.Id, Name = te.Project.Name,
                                },
                            };
                            return(info);
                        }
                    }
                }
                return(null);
            }).Where(i => i != null).ToList();

            return(timeEntryInfos);
        }
Esempio n. 4
0
        /// <summary>
        /// Method to get the total object list of all activities
        /// </summary>
        /// <param name="parameters">the parameters</param>
        /// <param name="statusCallback">a statusCallback to be run after the list is obtained</param>
        /// <returns>the list containing all objects</returns>
        public IList <ActivityInfo> GetTotalActivityInfoList(DataSourceParameter parameters, Action <int, int> statusCallback = null)
        {
            var activities    = this._redmineApi.GetTotalObjectList <TimeEntryActivity>(this.GetParametersForQuery(parameters), statusCallback);
            var activityInfos = activities.Select(a => new ActivityInfo()
            {
                Id = a.Id, Name = a.Name, IsDefault = a.IsDefault
            }).ToList();

            return(activityInfos);
        }
Esempio n. 5
0
        /// <summary>
        /// Method to get the total object list of all projects
        /// </summary>
        /// <param name="parameters">the parameters</param>
        /// <param name="statusCallback">a statusCallback to be run after the list is obtained</param>
        /// <returns>the list containing all objects</returns>
        public IList <ProjectInfo> GetTotalProjectList(DataSourceParameter parameters, Action <int, int> statusCallback = null)
        {
            var projects     = this._redmineApi.GetTotalObjectList <Project>(this.GetParametersForQuery(parameters), statusCallback);
            var projectInfos = projects.Select(p => new ProjectInfo()
            {
                Id = p.Id, Name = p.Identifier
            }).ToList();

            return(projectInfos);
        }
Esempio n. 6
0
        /// <summary>
        /// Method to get the parameter to use for the query
        /// </summary>
        /// <param name="parameter">the parameter given</param>
        /// <returns>the parameter to use</returns>
        internal NameValueCollection GetParametersForQuery(DataSourceParameter parameter)
        {
            var queryParameter = new NameValueCollection();

            if (parameter != null)
            {
                if (parameter.Limit.HasValue)
                {
                    queryParameter.Add("limit", parameter.Limit.ToString());
                }
                else if (parameter.UseLimit.HasValue && parameter.UseLimit.Value)
                {
                    queryParameter.Add("limit", this.Limit.ToString());
                }

                if (parameter.StatusId.HasValue)
                {
                    queryParameter.Add("status_id", parameter.StatusId.Value == -1 ? "*" : parameter.StatusId.Value.ToString());
                }
                if (parameter.ProjectId.HasValue)
                {
                    queryParameter.Add("project_id", parameter.ProjectId.Value.ToString());
                }
                if (parameter.UpdateStartDateTime.HasValue)
                {
                    queryParameter.Add("updated_on", ">=" + parameter.UpdateStartDateTime.Value.ToString("yyyy-MM-dd"));
                }
                if (parameter.UserId.HasValue)
                {
                    queryParameter.Add("user_id", parameter.UserId.Value == -1 ? "me" : parameter.UserId.Value.ToString());
                }
                if (parameter.SpentDateTimeTuple != null)
                {
                    var tuple = parameter.SpentDateTimeTuple;
                    queryParameter.Add("spent_on", string.Format("><{0:yyyy-MM-dd}|{1:yyyy-MM-dd}", tuple.Item1, tuple.Item2));
                }
                if (parameter.IssueId.HasValue)
                {
                    queryParameter.Add("issue_id", parameter.IssueId.Value.ToString());
                }
                if (parameter.AssignedToUserId.HasValue)
                {
                    queryParameter.Add("assigned_to_id", parameter.AssignedToUserId.Value == -1 ? "me" : parameter.AssignedToUserId.Value.ToString());
                }
            }

            return(queryParameter);
        }
Esempio n. 7
0
        /// <summary>
        /// Method to get the list of all issues matching the given parameter
        /// </summary>
        /// <param name="parameters">the parameters</param>
        /// <returns>the list containing all objects</returns>
        public IList <IssueInfo> GetIssueInfoList(DataSourceParameter parameters)
        {
            var parameter = this.GetParametersForQuery(parameters);
            var issues    = this._redmineApi.GetObjectList <Issue>(parameter);

            var issueInfos =
                issues.Select(
                    i =>
                    new IssueInfo()
            {
                Id               = i.Id,
                Name             = i.Subject,
                ProjectShortName = i.Project.Name,
                ProjectId        = i.Project.Id
            }).ToList();

            return(issueInfos);
        }
Esempio n. 8
0
        /// <summary>
        /// Method to get the total object list of all issues
        /// </summary>
        /// <param name="parameters">the parameters</param>
        /// <param name="statusCallback">a statusCallback to be run after the list is obtained</param>
        /// <returns>the list containing all objects</returns>
        public IList <IssueInfo> GetTotalIssueInfoList(DataSourceParameter parameters, Action <int, int> statusCallback = null)
        {
            // assert that there is no limit parameter set
            if (parameters.Limit.HasValue)
            {
                throw new ArgumentException("No limit parameter may be set for this method.");
            }

            // get parameter and issues
            var parameter = this.GetParametersForQuery(parameters);
            var issues    = this._redmineApi.GetTotalObjectList <Issue>(parameter, statusCallback);

            // convert issues
            var issueInfos =
                issues.Select(i => new IssueInfo()
            {
                Id = i.Id, Name = i.Subject, ProjectShortName = i.Project.Name, ProjectId = i.Project.Id,
            })
                .ToList();

            return(issueInfos);
        }
Esempio n. 9
0
 /// <summary>
 /// Method to get the total object list of all time entries
 /// </summary>
 /// <param name="parameters">the parameters</param>
 /// <param name="statusCallback">a statusCallback to be run after the list is obtained</param>
 /// <returns>the list containing all objects</returns>
 public IList <TimeEntryInfo> GetTotalTimeEntryInfoList(DataSourceParameter parameters, Action <int, int> statusCallback = null)
 {
     return(this._timeEntries);
 }
Esempio n. 10
0
 /// <summary>
 /// Method to get the list of all issues matching the given parameter
 /// </summary>
 /// <param name="parameters">the parameters</param>
 /// <returns>the list containing all objects</returns>
 public IList <IssueInfo> GetIssueInfoList(DataSourceParameter parameters)
 {
     return(this._issues);
 }
Esempio n. 11
0
 /// <summary>
 /// Method to get the total object list of all issues
 /// </summary>
 /// <param name="parameters">the parameters</param>
 /// <param name="statusCallback">a statusCallback to be run after the list is obtained</param>
 /// <returns>the list containing all objects</returns>
 public IList <IssueInfo> GetTotalIssueInfoList(DataSourceParameter parameters, Action <int, int> statusCallback = null)
 {
     return(this._issues);
 }
Esempio n. 12
0
 /// <summary>
 /// Method to get the total object list of all projects
 /// </summary>
 /// <param name="parameters">the parameters</param>
 /// <param name="statusCallback">a statusCallback to be run after the list is obtained</param>
 /// <returns>the list containing all objects</returns>
 public IList <ProjectInfo> GetTotalProjectList(DataSourceParameter parameters, Action <int, int> statusCallback = null)
 {
     return(this._projects);
 }