예제 #1
0
        //public string GetFilePath(string path, bool addParams)
        //{
        //    string strRtn = path;

        //    if (path.IndexOf("http:") < 0)
        //    {
        //        string root = "http://" +
        //                    HttpContext.Current.Request.Url.Host +
        //                    ":" + HttpContext.Current.Request.Url.Port;

        //        strRtn = path.Replace("~", "");
        //        if (!strRtn.StartsWith("/"))
        //            strRtn += "/";

        //        strRtn = root + strRtn;
        //    }

        //    if (addParams)
        //        strRtn += GetParamsForServiceCall();

        //    return strRtn;
        //}


        string GetParamsForServiceCall()
        {
            ContentId = GetPropertyValue("ContentId", ContentId, DefaultContentId);
            Alias     = GetPropertyValue("Alias", Alias, "");
            Lineage   = GetPropertyValue("Lineage", Lineage, "");
            //Where = GetPropertyValue("where", Where, "");
            //SortBy = GetPropertyValue("sortby", SortBy, "");
            PageSize  = GetPropertyValue("pagesize", PageSize, 0);
            PageIndex = GetPropertyValue("pageindex", PageIndex, 0);
            Culture   = GetPropertyValue("culture", Culture, "");

            StringBuilder sb = new StringBuilder("");

            sb.Append("?method=" + MethodName);
            sb.Append("&siteid=" + SiteId);
            sb.Append("&type=" + XMLType.ToString());

            if (ContentId > 0)
            {
                sb.Append("&contentid=" + ContentId);
            }
            if (Culture.Trim() != "")
            {
                sb.Append("&culture=" + Culture);
            }
            if (Alias.Trim().Length > 0)
            {
                sb.Append("&alias=" + Alias);
            }
            if (Lineage.Trim().Length > 0)
            {
                sb.Append("&lineage=" + Lineage);
            }
            if (MaxTitleLength > 0)
            {
                sb.Append("&maxtitlelength=" + MaxTitleLength);
            }
            if (MaxDescriptionLength > 0)
            {
                sb.Append("&maxdesclength=" + MaxDescriptionLength);
            }
            if (PageSize > 0)
            {
                sb.Append("&pagesize=" + PageSize);
            }
            if (PageIndex > 0)
            {
                sb.Append("&pageindex=" + PageIndex);
            }
            if (Parameters.Trim().Length > 0)
            {
                sb.Append("&prms=" + Parameters);
            }
            if (Where.Trim().Length > 0)
            {
                sb.Append("&where=" + Where);
            }
            if (SortBy.Trim().Length > 0)
            {
                sb.Append("&sortby=" + SortBy);
            }

            if (IgnoredUriParameters.Trim() != "*" &&
                HttpContext.Current.Request.Url.Query != null &&
                HttpContext.Current.Request.Url.Query.Length > 0)
            {
                string[] prms = HttpContext.Current.Request.Url.Query.Replace("?", "").Split('&');

                //if paremeter isn't already added to the returning string
                foreach (string prm in prms)
                {
                    if (prm.Trim().Length == 0)
                    {
                        continue;
                    }

                    string prmName = (prm.Split('='))[0];

                    if (!IsInIgnoreList(prmName))
                    {
                        if (sb.ToString().ToLower().IndexOf(prmName.ToLower()) < 0)
                        {
                            sb.Append("&" + prm);
                        }
                    }
                }
            }

            if (HttpContext.Current.Request["currcontentid"] != null)
            {
                sb.Append("&currcontentid=" + HttpContext.Current.Request["currcontentid"].ToString());
            }
            else
            if (HttpContext.Current.Request["contentid"] != null)
            {
                sb.Append("&currcontentid=" + HttpContext.Current.Request["contentid"].ToString());
            }

            return(sb.ToString());
        }