示例#1
0
        public string  PostAttachment(Attachment objAtt, string url)
        {
            string result = string.Empty;

            try
            {
                string postURL = String.Concat(url, ATTACHMENT_PAGE);

                MultipartForm mPost = new MultipartForm(postURL, _userID);

                mPost.SetField("bugid", objAtt.BugId.ToString());
                mPost.SetField("action", "insert");
                mPost.SetField("description", objAtt.Description);
                mPost.SetField("contenttypemethod", "list");
                mPost.SetField("contenttypeselection", objAtt.ContentType);
                mPost.SetField("contenttypeentry", string.Empty);
                mPost.SetField("comment", objAtt.Comment);
                mPost.FileContentType = objAtt.ContentType;

                mPost.SendFile(objAtt.FileName);

                result = mPost.ResponseText.ToString();
            }
            catch (Exception ex)
            {
                MyLogger.WriteWithStack(ex.Message, "PostToUrlWhenLogOn", LoggingCategory.Exception);

                throw;
            }

            return(result);
        }
示例#2
0
        public string PostMultipartWhenAddingBug(Bug addedBug, string myzillaUrl)
        {
            string result = string.Empty;

            try
            {
                string url = String.Concat(myzillaUrl, UPDATE_BUG_PAGE);

                MultipartForm mPost = new MultipartForm(url, _userID );

                mPost.SetField("product", HttpUtility.UrlEncode(addedBug.Product));
                mPost.SetField("version", HttpUtility.UrlEncode(addedBug.Version));
                mPost.SetField("component", HttpUtility.UrlEncode(addedBug.Component));
                mPost.SetField("bug_severity", HttpUtility.UrlEncode(addedBug.Severity));
                mPost.SetField("rep_platform", HttpUtility.UrlEncode(addedBug.Hardware));
                mPost.SetField("priority", HttpUtility.UrlEncode(addedBug.Priority));
                mPost.SetField("op_sys", HttpUtility.UrlEncode(addedBug.OS));

                if (!string.IsNullOrEmpty(addedBug.Milestone))
                    mPost.SetField("target_milestone", HttpUtility.UrlEncode(addedBug.Milestone));

                mPost.SetField("bug_status", HttpUtility.UrlEncode(addedBug.Status));
                mPost.SetField("assigned_to", HttpUtility.UrlEncode(addedBug.AssignedTo));

                // can be 1 cc
                if (addedBug.CC != null && addedBug.CC.Count == 1)
                {
                    mPost.SetField("cc", HttpUtility.UrlEncode(addedBug.CC[0]));
                }
                mPost.SetField("bug_file_loc", HttpUtility.UrlEncode(addedBug.Url));
                mPost.SetField("short_desc", HttpUtility.UrlEncode(addedBug.Summary));
                if (addedBug.Comment != null && addedBug.Comment.Count >= 1)
                {
                    mPost.SetField("comment", HttpUtility.UrlEncode(addedBug.Comment[0]) );
                }

                mPost.SetField("dependson", HttpUtility.UrlEncode(addedBug.DependsOn));
                mPost.SetField("blocked", HttpUtility.UrlEncode(addedBug.Blocks));
                mPost.SetField("form_name", "enter_bug");

                if (addedBug.Attachments.Count > 0)
                {
                    mPost.SetField("contenttypemethod", "autodetect");
                    mPost.SetField("contenttypeselection", "text/plain");
                    mPost.SetField("contenttypeentry", String.Empty);
                    mPost.SetField("description", HttpUtility.UrlEncode(addedBug.Attachments[0].Description));
                    mPost.FileContentType = addedBug.Attachments[0].ContentType;
                    mPost.SendFile(addedBug.Attachments[0].FileName);

                }
                else
                {
                    mPost.SendFile(String.Empty);
                }

                result = mPost.ResponseText.ToString();

            }
            catch (Exception ex)
            {
                MyLogger.WriteWithStack(ex.Message, "PostMultipartWhenAddingBug", LoggingCategory.Exception);

                throw;

            }

            return result;
        }
示例#3
0
        public string PostAttachment( Attachment objAtt, string url)
        {
            string result = string.Empty  ;

               try
               {
               string postURL = String.Concat(url, ATTACHMENT_PAGE);

               MultipartForm mPost = new MultipartForm(postURL , _userID );

               mPost.SetField("bugid", objAtt.BugId.ToString());
               mPost.SetField("action", "insert");
               mPost.SetField("description", objAtt.Description);
               mPost.SetField("contenttypemethod", "list");
               mPost.SetField("contenttypeselection", objAtt.ContentType);
               mPost.SetField("contenttypeentry", string.Empty);
               mPost.SetField("comment", objAtt.Comment);
               mPost.FileContentType = objAtt.ContentType;

               mPost.SendFile(objAtt.FileName);

               result = mPost.ResponseText.ToString();
               }
               catch (Exception ex)
               {
               MyLogger.WriteWithStack(ex.Message, "PostToUrlWhenLogOn", LoggingCategory.Exception);

               throw;
               }

               return result ;
        }
示例#4
0
        public string PostMultipartWhenAddingBug(Bug addedBug, string myzillaUrl)
        {
            string result = string.Empty;

            try
            {
                string url = String.Concat(myzillaUrl, UPDATE_BUG_PAGE);

                MultipartForm mPost = new MultipartForm(url, _userID);

                mPost.SetField("product", HttpUtility.UrlEncode(addedBug.Product));
                mPost.SetField("version", HttpUtility.UrlEncode(addedBug.Version));
                mPost.SetField("component", HttpUtility.UrlEncode(addedBug.Component));
                mPost.SetField("bug_severity", HttpUtility.UrlEncode(addedBug.Severity));
                mPost.SetField("rep_platform", HttpUtility.UrlEncode(addedBug.Hardware));
                mPost.SetField("priority", HttpUtility.UrlEncode(addedBug.Priority));
                mPost.SetField("op_sys", HttpUtility.UrlEncode(addedBug.OS));

                if (!string.IsNullOrEmpty(addedBug.Milestone))
                {
                    mPost.SetField("target_milestone", HttpUtility.UrlEncode(addedBug.Milestone));
                }

                mPost.SetField("bug_status", HttpUtility.UrlEncode(addedBug.Status));
                mPost.SetField("assigned_to", HttpUtility.UrlEncode(addedBug.AssignedTo));

                // can be 1 cc
                if (addedBug.CC != null && addedBug.CC.Count == 1)
                {
                    mPost.SetField("cc", HttpUtility.UrlEncode(addedBug.CC[0]));
                }
                mPost.SetField("bug_file_loc", HttpUtility.UrlEncode(addedBug.Url));
                mPost.SetField("short_desc", HttpUtility.UrlEncode(addedBug.Summary));
                if (addedBug.Comment != null && addedBug.Comment.Count >= 1)
                {
                    mPost.SetField("comment", HttpUtility.UrlEncode(addedBug.Comment[0]));
                }

                mPost.SetField("dependson", HttpUtility.UrlEncode(addedBug.DependsOn));
                mPost.SetField("blocked", HttpUtility.UrlEncode(addedBug.Blocks));
                mPost.SetField("form_name", "enter_bug");

                if (addedBug.Attachments.Count > 0)
                {
                    mPost.SetField("contenttypemethod", "autodetect");
                    mPost.SetField("contenttypeselection", "text/plain");
                    mPost.SetField("contenttypeentry", String.Empty);
                    mPost.SetField("description", HttpUtility.UrlEncode(addedBug.Attachments[0].Description));
                    mPost.FileContentType = addedBug.Attachments[0].ContentType;
                    mPost.SendFile(addedBug.Attachments[0].FileName);
                }
                else
                {
                    mPost.SendFile(String.Empty);
                }

                result = mPost.ResponseText.ToString();
            }
            catch (Exception ex)
            {
                MyLogger.WriteWithStack(ex.Message, "PostMultipartWhenAddingBug", LoggingCategory.Exception);

                throw;
            }

            return(result);
        }