コード例 #1
0
        public string GetQueryString(RemedyValuesModel obj)
        {
            var result = new List <string>();
            var props  = obj.GetType().GetProperties().Where(p => p.GetValue(obj, null) != null);

            foreach (var p in props)
            {
                var value      = p.GetValue(obj, null);
                var enumerable = value as ICollection <string>;
                if (enumerable != null)
                {
                    result.AddRange(from object v in enumerable select string.Format("{0}={1}", p.Name, HttpUtility.UrlEncode(v.ToString())));
                }
                else
                {
                    result.Add(string.Format("{0}={1}", p.Name, HttpUtility.UrlEncode(value.ToString())));
                }
            }

            return(string.Join("&", result.ToArray()));
        }
コード例 #2
0
        public void FetchDataFromRemedy(string remedyValues)
        {
            WriteLog(remedyValues);
            RemedyValuesModel values = new RemedyValuesModel();
            // values.BusinessOwner=
            string resultUrl   = string.Empty;
            string QueryString = GetQueryString(values);
            Uri    result      = default(Uri);

            if (Uri.TryCreate(
                    string.Concat("serverurl", "/job/", "projectname", "/buildWithParameters/", QueryString),
                    UriKind.Absolute, out result))
            {
                resultUrl = result.AbsoluteUri;
            }
            else
            {
                throw new ArgumentException(
                          "The Parameterized Queue Build Url was not created correctly.");
            }
        }