Helper class for constructing the multipart/form-data POST requests
Пример #1
0
        /// <summary>
        /// Prepares the request data
        /// </summary>
        /// <returns>The request data</returns>
        internal byte[] MakeRequestData()
        {
            MultipartData data = new MultipartData();

            data.AddValue("authenticity_token", Redmine.AuthenticityToken);
            data.AddValue("issue[tracker_id]", this.TrackerId.ToString());
            data.AddValue("issue[subject]", this.Subject);
            data.AddValue("issue[description]", this.Description);
            data.AddValue("issue[status_id]", this.StatusId.ToString());
            data.AddValue("issue[priority_id]", this.PriorityId.ToString());
            data.AddValue("issue[assigned_to_id]", this.AssignedTo.ToString());
            data.AddValue("issue[fixed_version_id]", this.TargetVersionId.ToString());
            if (this.Start != DateTime.MinValue)
            {
                data.AddValue("issue[start_date]", this.Start.ToString("yyyy-MM-dd"));
            }

            if (this.DueDate != DateTime.MinValue)
            {
                data.AddValue("issue[due_date]", this.DueDate.ToString("yyyy-MM-dd"));
            }

            data.AddValue("issue[estimated_hours]", this.EstimatedTime.ToString());
            data.AddValue("issue[done_ratio]", this.PercentDone.ToString());
            if (this.Attachments != null)
            {
                int counter = 1;
                foreach (KeyValuePair <string, string> attachment in this.Attachments)
                {
                    data.AddFile(String.Format("attachments[{0}][file]", counter), attachment.Key);
                    data.AddValue(String.Format("attachments[{0}][description]", counter), attachment.Value);
                    counter++;
                }
            }

            if (this.Watchers != null)
            {
                foreach (User watcher in this.Watchers)
                {
                    data.AddValue("issue[watcher_user_ids][]", watcher.Id.ToString());
                }
            }

            if (this.AdditionalParameters != null)
            {
                foreach (KeyValuePair <string, string> parameter in this.AdditionalParameters)
                {
                    data.AddValue(parameter.Key, parameter.Value);
                }
            }

            data.AddValue("commit", "Create");
            return(data.Data);
        }
Пример #2
0
        /// <summary>
        /// Prepares the request data
        /// </summary>
        /// <returns>The request data</returns>
        internal byte[] MakeRequestData()
        {
            MultipartData data = new MultipartData();
            data.AddValue("authenticity_token", Redmine.AuthenticityToken);
            data.AddValue("issue[tracker_id]", this.TrackerId.ToString());
            data.AddValue("issue[subject]", this.Subject);
            data.AddValue("issue[description]", this.Description);
            data.AddValue("issue[status_id]", this.StatusId.ToString());
            data.AddValue("issue[priority_id]", this.PriorityId.ToString());
            data.AddValue("issue[assigned_to_id]", this.AssignedTo.ToString());
            data.AddValue("issue[fixed_version_id]", this.TargetVersionId.ToString());
            if (this.Start != DateTime.MinValue)
            {
                data.AddValue("issue[start_date]", this.Start.ToString("yyyy-MM-dd"));
            }

            if (this.DueDate != DateTime.MinValue)
            {
                data.AddValue("issue[due_date]", this.DueDate.ToString("yyyy-MM-dd"));
            }

            data.AddValue("issue[estimated_hours]", this.EstimatedTime.ToString());
            data.AddValue("issue[done_ratio]", this.PercentDone.ToString());
            if (this.Attachments != null)
            {
                int counter = 1;
                foreach (KeyValuePair<string, string> attachment in this.Attachments)
                {
                    data.AddFile(String.Format("attachments[{0}][file]", counter), attachment.Key);
                    data.AddValue(String.Format("attachments[{0}][description]", counter), attachment.Value);
                    counter++;
                }
            }

            if (this.Watchers != null)
            {
                foreach (User watcher in this.Watchers)
                {
                    data.AddValue("issue[watcher_user_ids][]", watcher.Id.ToString());
                }
            }

            if (this.AdditionalParameters != null)
            {
                foreach (KeyValuePair<string, string> parameter in this.AdditionalParameters)
                {
                    data.AddValue(parameter.Key, parameter.Value);
                }
            }

            data.AddValue("commit", "Create");
            return data.Data;
        }